From f8e940a8957925c10704b1376f742cb4ed9f9471 Mon Sep 17 00:00:00 2001
From: jazibsawar <jazibsawar@gmail.com>
Date: Mon, 28 Oct 2024 19:34:58 +0200
Subject: [PATCH] add trigger webhook and slug support

---
 .changeset/cool-games-cover.md              |  5 +++++
 src/clients/bucket/objectRevisions/index.ts |  3 ++-
 src/types/generic.types.ts                  |  5 +++++
 src/types/objectRevision.type.ts            | 15 +++++++++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 .changeset/cool-games-cover.md
 create mode 100644 src/types/objectRevision.type.ts

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<string, any>;
 export type NonEmptyObject<T extends Record<string, unknown>> =
   T extends Record<string, never> ? 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;
+};