diff --git a/.changeset/cool-games-cover.md b/.changeset/cool-games-cover.md new file mode 100644 index 0000000..cb5f238 --- /dev/null +++ b/.changeset/cool-games-cover.md @@ -0,0 +1,5 @@ +--- +'@cosmicjs/sdk': patch +--- + +Added typescript type for add revision method diff --git a/src/clients/bucket/objectRevisions/index.ts b/src/clients/bucket/objectRevisions/index.ts index 94dcbc2..4c56973 100644 --- a/src/clients/bucket/objectRevisions/index.ts +++ b/src/clients/bucket/objectRevisions/index.ts @@ -1,5 +1,6 @@ import HTTP_METHODS from '../../../constants/httpMethods.constants'; import { APIConfig, BucketConfig } from '../../../types/config.types'; +import { InsertObjectRevisionType } from '../../../types/objectRevision.type'; import { GenericObject } from '../../../types/generic.types'; import { requestHandler } from '../../../utils/request.handler'; import { validateWriteKeyAndReturnHeaders } from '../../../utils/writeKey.validation'; @@ -10,7 +11,7 @@ export const objectRevisionsChainMethods = ( bucketConfig: BucketConfig, apiConfig: APIConfig ) => ({ - async insertOne(objectId: string, data: GenericObject) { + async insertOne(objectId: string, data: InsertObjectRevisionType) { const endpoint = `${apiConfig.apiUrl}/buckets/${bucketConfig.bucketSlug}/objects/${objectId}/revisions`; headers = validateWriteKeyAndReturnHeaders(bucketConfig.writeKey); return requestHandler(HTTP_METHODS.POST, endpoint, data, headers); diff --git a/src/types/generic.types.ts b/src/types/generic.types.ts index c574f6a..92f2c7f 100644 --- a/src/types/generic.types.ts +++ b/src/types/generic.types.ts @@ -1,3 +1,8 @@ export type GenericObject = Record; export type NonEmptyObject> = T extends Record ? never : T; + +export type GenericOptionsType = { + slug_field?: boolean; + content_editor?: boolean; +}; diff --git a/src/types/objectRevision.type.ts b/src/types/objectRevision.type.ts new file mode 100644 index 0000000..183d4be --- /dev/null +++ b/src/types/objectRevision.type.ts @@ -0,0 +1,15 @@ +import { GenericObject, GenericOptionsType } from './generic.types'; + +export type InsertObjectRevisionType = { + title?: string; + slug?: string; + content?: string; + options?: GenericOptionsType; + publish_at?: number; + unpublish_at?: number; + metadata?: GenericObject; + locale?: string; + thumbnail?: string; + trigger_webhook?: boolean; + pretty?: boolean; +};