fix: Cron response types (#2987)

technically a breaking change, however the old response type was
incorrect.
This commit is contained in:
Brace Sproul
2025-01-10 10:15:03 -08:00
committed by GitHub
2 changed files with 31 additions and 7 deletions
+12 -7
View File
@@ -18,6 +18,8 @@ import {
ListNamespaceResponse,
Item,
ThreadStatus,
CronCreateResponse,
CronCreateForThreadResponse,
} from "./schema.js";
import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
import {
@@ -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,
@@ -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,
},
);
}
/**
@@ -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,
@@ -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,
});
+19
View File
@@ -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;
}