Skip to content

Commit

Permalink
refactor: do not use getEntryBaseUrl in getEntityBaseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Oct 25, 2023
1 parent 62e8265 commit 85ef723
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/adapters/REST/endpoints/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ function getParentPlural(parentEntityType: 'ContentType' | 'Entry' | 'Workflow')
}

/**
* Comments can be added to either an entry or a workflow. The latter one requires a version
* Comments can be added to a content type, an entry, and a workflow. Workflow comments requires a version
* to be set as part of the URL path. Workflow comments only support `create` (with
* versionized URL) and `getMany` (without version). The API might support more methods
* in the future with new use cases being discovered.
*/
const getEntityBaseUrl = (params: GetEntryParams | GetManyCommentsParams) => {
if ('entryId' in params) {
return getEntryBaseUrl(params)
}
const getEntityBaseUrl = (paramsOrg: GetEntryParams | GetManyCommentsParams) => {
const params: GetManyCommentsParams =
'entryId' in paramsOrg
? {
spaceId: paramsOrg.spaceId,
environmentId: paramsOrg.environmentId,
parentEntityType: 'Entry' as const,
parentEntityId: paramsOrg.entryId,
}
: paramsOrg

const { parentEntityId, parentEntityType } = params
const parentPlural = getParentPlural(parentEntityType)
const versionPath =
Expand Down

0 comments on commit 85ef723

Please sign in to comment.