From 5addbfb8c0d4e4004e5b2377479b74d7e7b26c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20P=C3=A4tzold?= Date: Wed, 25 Oct 2023 13:18:52 +0200 Subject: [PATCH] fix: remove entry-specific behavior --- lib/adapters/REST/endpoints/comment.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/adapters/REST/endpoints/comment.ts b/lib/adapters/REST/endpoints/comment.ts index 8a273a718e..f93b2b6f61 100644 --- a/lib/adapters/REST/endpoints/comment.ts +++ b/lib/adapters/REST/endpoints/comment.ts @@ -27,10 +27,8 @@ const BODY_FORMAT_HEADER = 'x-contentful-comment-body-format' const getSpaceEnvBaseUrl = (params: GetSpaceEnvironmentParams) => `/spaces/${params.spaceId}/environments/${params.environmentId}` -const getEntryBaseUrl = (params: GetEntryParams) => - `${getSpaceEnvBaseUrl(params)}/entries/${params.entryId}/comments` -const getEntryCommentUrl = (params: GetCommentParams) => - `${getEntryBaseUrl(params)}/${params.commentId}` +const getEntityCommentUrl = (params: GetCommentParams) => + `${getEntityBaseUrl(params)}/${params.commentId}` function getParentPlural(parentEntityType: 'ContentType' | 'Entry' | 'Workflow') { switch (parentEntityType) { @@ -71,7 +69,7 @@ export const get: RestEndpoint<'Comment', 'get'> = ( http: AxiosInstance, params: GetCommentParams & (PlainTextBodyFormat | RichTextBodyFormat) ) => - raw.get(http, getEntryCommentUrl(params), { + raw.get(http, getEntityCommentUrl(params), { headers: params.bodyFormat === 'rich-text' ? { @@ -119,7 +117,7 @@ export const update: RestEndpoint<'Comment', 'update'> = ( const data: SetOptional = copy(rawData) delete data.sys - return raw.put(http, getEntryCommentUrl(params), data, { + return raw.put(http, getEntityCommentUrl(params), data, { headers: { 'X-Contentful-Version': rawData.sys.version ?? 0, ...(typeof rawData.body !== 'string' @@ -136,7 +134,9 @@ export const del: RestEndpoint<'Comment', 'delete'> = ( http: AxiosInstance, { version, ...params }: DeleteCommentParams ) => { - return raw.del(http, getEntryCommentUrl(params), { headers: { 'X-Contentful-Version': version } }) + return raw.del(http, getEntityCommentUrl(params), { + headers: { 'X-Contentful-Version': version }, + }) } // Add a deprecation notice. But `getAll` may never be removed for app compatibility reasons.