Skip to content

Commit

Permalink
Merge pull request #44 from cosmicjs/jazib/add-slug-and-trigger_webho…
Browse files Browse the repository at this point in the history
…ok-support

add typing for insert revision method
  • Loading branch information
jazibsawar authored Oct 28, 2024
2 parents e279862 + 9057418 commit 2d26642
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cool-games-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cosmicjs/sdk': patch
---

Added typescript type for add revision method
3 changes: 2 additions & 1 deletion src/clients/bucket/objectRevisions/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions src/types/objectRevision.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { GenericObject } from './generic.types';

export type InsertObjectRevisionType = {
title?: string;
slug?: string;
content?: string;
publish_at?: number;
unpublish_at?: number;
metadata?: GenericObject;
locale?: string;
thumbnail?: string;
trigger_webhook?: boolean;
pretty?: boolean;
};

0 comments on commit 2d26642

Please sign in to comment.