Skip to content

Commit

Permalink
fix: Cron response types (#2987)
Browse files Browse the repository at this point in the history
technically a breaking change, however the old response type was
incorrect.
  • Loading branch information
bracesproul authored Jan 10, 2025
2 parents 10d46ac + c302724 commit 8355a17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
19 changes: 12 additions & 7 deletions libs/sdk-js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
ListNamespaceResponse,
Item,
ThreadStatus,
CronCreateResponse,
CronCreateForThreadResponse,
} from "./schema.js";
import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
import {
Expand Down Expand Up @@ -184,7 +186,7 @@ export class CronsClient extends BaseClient {
threadId: string,
assistantId: string,
payload?: CronsCreatePayload,
): Promise<Run> {
): Promise<CronCreateForThreadResponse> {
const json: Record<string, any> = {
schedule: payload?.schedule,
input: payload?.input,
Expand All @@ -197,10 +199,13 @@ export class CronsClient extends BaseClient {
multitask_strategy: payload?.multitaskStrategy,
if_not_exists: payload?.ifNotExists,
};
return this.fetch<Run>(`/threads/${threadId}/runs/crons`, {
method: "POST",
json,
});
return this.fetch<CronCreateForThreadResponse>(
`/threads/${threadId}/runs/crons`,
{
method: "POST",
json,
},
);
}

/**
Expand All @@ -212,7 +217,7 @@ export class CronsClient extends BaseClient {
async create(
assistantId: string,
payload?: CronsCreatePayload,
): Promise<Run> {
): Promise<CronCreateResponse> {
const json: Record<string, any> = {
schedule: payload?.schedule,
input: payload?.input,
Expand All @@ -225,7 +230,7 @@ export class CronsClient extends BaseClient {
multitask_strategy: payload?.multitaskStrategy,
if_not_exists: payload?.ifNotExists,
};
return this.fetch<Run>(`/runs/crons`, {
return this.fetch<CronCreateResponse>(`/runs/crons`, {
method: "POST",
json,
});
Expand Down
19 changes: 19 additions & 0 deletions libs/sdk-js/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,22 @@ 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<string, unknown>;
schedule: string;
next_run_date: string;
end_time: string | undefined;
created_at: string;
updated_at: string;
metadata: Metadata;
}

export interface CronCreateForThreadResponse
extends Omit<CronCreateResponse, "thread_id"> {
thread_id: string;
}

0 comments on commit 8355a17

Please sign in to comment.