From c624ff69e1830b626598820e541b782cd9eadfda Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 10 Jan 2025 10:01:51 -0800 Subject: [PATCH 1/2] fix: Cron response types --- libs/sdk-js/src/client.ts | 9 +++++---- libs/sdk-js/src/schema.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libs/sdk-js/src/client.ts b/libs/sdk-js/src/client.ts index b340274ca..64b84d8c1 100644 --- a/libs/sdk-js/src/client.ts +++ b/libs/sdk-js/src/client.ts @@ -18,6 +18,7 @@ import { ListNamespaceResponse, Item, ThreadStatus, + CronCreateResponse, } from "./schema.js"; import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js"; import { @@ -184,7 +185,7 @@ export class CronsClient extends BaseClient { threadId: string, assistantId: string, payload?: CronsCreatePayload, - ): Promise { + ): Promise { const json: Record = { schedule: payload?.schedule, input: payload?.input, @@ -197,7 +198,7 @@ export class CronsClient extends BaseClient { multitask_strategy: payload?.multitaskStrategy, if_not_exists: payload?.ifNotExists, }; - return this.fetch(`/threads/${threadId}/runs/crons`, { + return this.fetch(`/threads/${threadId}/runs/crons`, { method: "POST", json, }); @@ -212,7 +213,7 @@ export class CronsClient extends BaseClient { async create( assistantId: string, payload?: CronsCreatePayload, - ): Promise { + ): Promise { const json: Record = { schedule: payload?.schedule, input: payload?.input, @@ -225,7 +226,7 @@ export class CronsClient extends BaseClient { multitask_strategy: payload?.multitaskStrategy, if_not_exists: payload?.ifNotExists, }; - return this.fetch(`/runs/crons`, { + return this.fetch(`/runs/crons`, { method: "POST", json, }); diff --git a/libs/sdk-js/src/schema.ts b/libs/sdk-js/src/schema.ts index 259bcd539..224d1a311 100644 --- a/libs/sdk-js/src/schema.ts +++ b/libs/sdk-js/src/schema.ts @@ -278,3 +278,17 @@ export interface SearchItem extends Item { export interface SearchItemsResponse { items: SearchItem[]; } + +export interface CronCreateResponse { + cron_id: string; + assistant_id: string; + thread_id: string | undefined; + user_id: string; + payload: Record; + schedule: string; + next_run_date: string; + end_time: string | undefined; + created_at: string; + updated_at: string; + metadata: Metadata; +} From c302724394213b9d0c811010470cd67a28c6a605 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 10 Jan 2025 10:05:57 -0800 Subject: [PATCH 2/2] fix cron create for thread return type --- libs/sdk-js/src/client.ts | 14 +++++++++----- libs/sdk-js/src/schema.ts | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libs/sdk-js/src/client.ts b/libs/sdk-js/src/client.ts index 64b84d8c1..fd69e41aa 100644 --- a/libs/sdk-js/src/client.ts +++ b/libs/sdk-js/src/client.ts @@ -19,6 +19,7 @@ import { Item, ThreadStatus, CronCreateResponse, + CronCreateForThreadResponse, } from "./schema.js"; import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js"; import { @@ -185,7 +186,7 @@ export class CronsClient extends BaseClient { threadId: string, assistantId: string, payload?: CronsCreatePayload, - ): Promise { + ): Promise { const json: Record = { schedule: payload?.schedule, input: payload?.input, @@ -198,10 +199,13 @@ export class CronsClient extends BaseClient { multitask_strategy: payload?.multitaskStrategy, if_not_exists: payload?.ifNotExists, }; - return this.fetch(`/threads/${threadId}/runs/crons`, { - method: "POST", - json, - }); + return this.fetch( + `/threads/${threadId}/runs/crons`, + { + method: "POST", + json, + }, + ); } /** diff --git a/libs/sdk-js/src/schema.ts b/libs/sdk-js/src/schema.ts index 224d1a311..6d6621012 100644 --- a/libs/sdk-js/src/schema.ts +++ b/libs/sdk-js/src/schema.ts @@ -292,3 +292,8 @@ export interface CronCreateResponse { updated_at: string; metadata: Metadata; } + +export interface CronCreateForThreadResponse + extends Omit { + thread_id: string; +}