@trigger.dev/sdk 3.0.0-beta.2 → 3.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { TaskRunContext, InitOutput, RetryOptions, QueueOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, FetchRetryOptions } from '@trigger.dev/core/v3';
2
- export { HandleErrorArgs, HandleErrorFunction, RetryOptions, ProjectConfig as TriggerConfig, logger } from '@trigger.dev/core/v3';
1
+ import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult } from '@trigger.dev/core/v3';
2
+ export { APIError, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, RetryOptions, ProjectConfig as TriggerConfig, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
3
3
  import { HttpHandler } from 'msw';
4
4
 
5
5
  type Context = TaskRunContext;
@@ -9,7 +9,10 @@ type RequireOne<T, K extends keyof T> = {
9
9
  [P in K]-?: T[P];
10
10
  };
11
11
  type Queue = RequireOne<QueueOptions, "name">;
12
- type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any> = {
12
+ declare function queue(options: {
13
+ name: string;
14
+ } & QueueOptions): Queue;
15
+ type TaskOptions<TPayload = void, TOutput = unknown, TInitOutput extends InitOutput = any> = {
13
16
  /** An id for your task. This must be unique inside your project and not change between versions. */
14
17
  id: string;
15
18
  /** The retry settings when an uncaught error is thrown.
@@ -99,11 +102,48 @@ type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any>
99
102
  * @param params - Metadata about the run.
100
103
  */
101
104
  run: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<TOutput>;
105
+ /**
106
+ * init is called before the run function is called. It's useful for setting up any global state.
107
+ */
102
108
  init?: (payload: TPayload, params: InitFnParams) => Promise<TInitOutput>;
103
- handleError?: (payload: TPayload, error: unknown, params: HandleErrorFnParams<TInitOutput>) => HandleErrorResult;
109
+ /**
110
+ * cleanup is called after the run function has completed.
111
+ */
104
112
  cleanup?: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<void>;
113
+ /**
114
+ * handleError is called when the run function throws an error. It can be used to modify the error or return new retry options.
115
+ */
116
+ handleError?: (payload: TPayload, error: unknown, params: HandleErrorFnParams<TInitOutput>) => HandleErrorResult;
117
+ /**
118
+ * middleware allows you to run code "around" the run function. This can be useful for logging, metrics, or other cross-cutting concerns.
119
+ *
120
+ * When writing middleware, you should always call `next()` to continue the execution of the task:
121
+ *
122
+ * ```ts
123
+ * export const middlewareTask = task({
124
+ * id: "middleware-task",
125
+ * middleware: async (payload, { ctx, next }) => {
126
+ * console.log("Before run");
127
+ * await next();
128
+ * console.log("After run");
129
+ * },
130
+ * run: async (payload, { ctx }) => {}
131
+ * });
132
+ * ```
133
+ */
105
134
  middleware?: (payload: TPayload, params: MiddlewareFnParams) => Promise<void>;
106
- onSuccess?: (payload: TPayload, params: SuccessFnParams<TOutput, TInitOutput>) => Promise<void>;
135
+ /**
136
+ * onStart is called the first time a task is executed in a run (not before every retry)
137
+ */
138
+ onStart?: (payload: TPayload, params: StartFnParams) => Promise<void>;
139
+ /**
140
+ * onSuccess is called after the run function has successfully completed.
141
+ */
142
+ onSuccess?: (payload: TPayload, output: TOutput, params: SuccessFnParams<TInitOutput>) => Promise<void>;
143
+ /**
144
+ * onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
145
+ */
146
+ onFailure?: (payload: TPayload, error: unknown, params: FailureFnParams<TInitOutput>) => Promise<void>;
107
147
  };
108
148
  type InvokeHandle = {
109
149
  id: string;
@@ -119,36 +159,79 @@ type TaskRunResult<TOutput = any> = {
119
159
  } | {
120
160
  ok: false;
121
161
  id: string;
122
- error: any;
162
+ error: unknown;
123
163
  };
124
164
  type BatchResult<TOutput = any> = {
125
165
  id: string;
126
166
  runs: TaskRunResult<TOutput>[];
127
167
  };
128
- type Task<TInput, TOutput = any> = {
129
- trigger: (params: {
130
- payload: TInput;
131
- options?: TaskRunOptions;
132
- }) => Promise<InvokeHandle>;
133
- batchTrigger: (params: {
134
- items: {
135
- payload: TInput;
136
- options?: TaskRunOptions;
137
- }[];
138
- batchOptions?: BatchRunOptions;
139
- }) => Promise<InvokeBatchHandle>;
140
- triggerAndWait: (params: {
141
- payload: TInput;
142
- options?: TaskRunOptions;
143
- }) => Promise<TOutput>;
144
- batchTriggerAndWait: (params: {
145
- items: {
146
- payload: TInput;
147
- options?: TaskRunOptions;
148
- }[];
149
- batchOptions?: BatchRunOptions;
150
- }) => Promise<BatchResult<TOutput>>;
168
+ type BatchItem<TInput> = TInput extends void ? {
169
+ payload?: TInput;
170
+ options?: TaskRunOptions;
171
+ } : {
172
+ payload: TInput;
173
+ options?: TaskRunOptions;
151
174
  };
175
+ interface Task<TInput = void, TOutput = any> {
176
+ /**
177
+ * The id of the task.
178
+ */
179
+ id: string;
180
+ /**
181
+ * Trigger a task with the given payload, and continue without waiting for the result. If you want to wait for the result, use `triggerAndWait`. Returns the id of the triggered task run.
182
+ * @param payload
183
+ * @param options
184
+ * @returns InvokeHandle
185
+ * - `id` - The id of the triggered task run.
186
+ */
187
+ trigger: (payload: TInput, options?: TaskRunOptions) => Promise<InvokeHandle>;
188
+ /**
189
+ * Batch trigger multiple task runs with the given payloads, and continue without waiting for the results. If you want to wait for the results, use `batchTriggerAndWait`. Returns the id of the triggered batch.
190
+ * @param items
191
+ * @returns InvokeBatchHandle
192
+ * - `batchId` - The id of the triggered batch.
193
+ * - `runs` - The ids of the triggered task runs.
194
+ */
195
+ batchTrigger: (items: Array<BatchItem<TInput>>) => Promise<InvokeBatchHandle>;
196
+ /**
197
+ * Trigger a task with the given payload, and wait for the result. Returns the result of the task run
198
+ * @param payload
199
+ * @param options - Options for the task run
200
+ * @returns TaskRunResult
201
+ * @example
202
+ * ```
203
+ * const result = await task.triggerAndWait({ foo: "bar" });
204
+ *
205
+ * if (result.ok) {
206
+ * console.log(result.output);
207
+ * } else {
208
+ * console.error(result.error);
209
+ * }
210
+ * ```
211
+ */
212
+ triggerAndWait: (payload: TInput, options?: TaskRunOptions) => Promise<TaskRunResult<TOutput>>;
213
+ /**
214
+ * Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
215
+ * @param items
216
+ * @returns BatchResult
217
+ * @example
218
+ * ```
219
+ * const result = await task.batchTriggerAndWait([
220
+ * { payload: { foo: "bar" } },
221
+ * { payload: { foo: "baz" } },
222
+ * ]);
223
+ *
224
+ * for (const run of result.runs) {
225
+ * if (run.ok) {
226
+ * console.log(run.output);
227
+ * } else {
228
+ * console.error(run.error);
229
+ * }
230
+ * }
231
+ * ```
232
+ */
233
+ batchTriggerAndWait: (items: Array<BatchItem<TInput>>) => Promise<BatchResult<TOutput>>;
234
+ }
152
235
  type TaskRunOptions = {
153
236
  idempotencyKey?: string;
154
237
  maxAttempts?: number;
@@ -158,9 +241,6 @@ type TaskRunOptions = {
158
241
  concurrencyKey?: string;
159
242
  };
160
243
  type TaskRunConcurrencyOptions = Queue;
161
- type BatchRunOptions = TaskRunOptions & {
162
- maxConcurrency?: number;
163
- };
164
244
 
165
245
  /** Creates a task that can be triggered
166
246
  * @param options - Task options
@@ -180,7 +260,7 @@ type BatchRunOptions = TaskRunOptions & {
180
260
  *
181
261
  * @returns A task that can be triggered
182
262
  */
183
- declare function task<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
263
+ declare function task$1<TInput = void, TOutput = unknown, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
184
264
 
185
265
  type WaitOptions = {
186
266
  seconds: number;
@@ -251,4 +331,74 @@ declare const retry: {
251
331
  };
252
332
  };
253
333
 
254
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, retry, task, wait };
334
+ declare const runs: {
335
+ replay: typeof replayRun;
336
+ cancel: typeof cancelRun;
337
+ };
338
+ declare function replayRun(runId: string): Promise<ReplayRunResponse>;
339
+ declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
340
+
341
+ declare function task<TOutput, TInitOutput extends InitOutput>(params: TaskOptions<ScheduledTaskPayload, TOutput, TInitOutput>): Task<ScheduledTaskPayload, TOutput>;
342
+ /**
343
+ * Creates a new schedule
344
+ * @param options
345
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
346
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
347
+ * @param options.externalId - An optional external identifier for the schedule
348
+ * @param options.deduplicationKey - An optional deduplication key for the schedule
349
+ * @returns The created schedule
350
+ */
351
+ declare function create(options: CreateScheduleOptions): Promise<ScheduleObject>;
352
+ /**
353
+ * Retrieves a schedule
354
+ * @param scheduleId - The ID of the schedule to retrieve
355
+ * @returns The retrieved schedule
356
+ */
357
+ declare function retrieve(scheduleId: string): Promise<ScheduleObject>;
358
+ /**
359
+ * Updates a schedule
360
+ * @param scheduleId - The ID of the schedule to update
361
+ * @param options - The updated schedule options
362
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
363
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
364
+ * @param options.externalId - An optional external identifier for the schedule
365
+ * @returns The updated schedule
366
+ */
367
+ declare function update(scheduleId: string, options: UpdateScheduleOptions): Promise<ScheduleObject>;
368
+ /**
369
+ * Deletes a schedule
370
+ * @param scheduleId - The ID of the schedule to delete
371
+ */
372
+ declare function del(scheduleId: string): Promise<DeletedScheduleObject>;
373
+ /**
374
+ * Deactivates a schedule
375
+ * @param scheduleId - The ID of the schedule to deactivate
376
+ */
377
+ declare function deactivate(scheduleId: string): Promise<ScheduleObject>;
378
+ /**
379
+ * Activates a schedule
380
+ * @param scheduleId - The ID of the schedule to activate
381
+ */
382
+ declare function activate(scheduleId: string): Promise<ScheduleObject>;
383
+ /**
384
+ * Lists schedules
385
+ * @param options - The list options
386
+ * @param options.page - The page number
387
+ * @param options.perPage - The number of schedules per page
388
+ * @returns The list of schedules
389
+ */
390
+ declare function list(options?: ListScheduleOptions): Promise<ListSchedulesResult>;
391
+
392
+ declare const index_activate: typeof activate;
393
+ declare const index_create: typeof create;
394
+ declare const index_deactivate: typeof deactivate;
395
+ declare const index_del: typeof del;
396
+ declare const index_list: typeof list;
397
+ declare const index_retrieve: typeof retrieve;
398
+ declare const index_task: typeof task;
399
+ declare const index_update: typeof update;
400
+ declare namespace index {
401
+ export { index_activate as activate, index_create as create, index_deactivate as deactivate, index_del as del, index_list as list, index_retrieve as retrieve, index_task as task, index_update as update };
402
+ }
403
+
404
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
@@ -1,5 +1,5 @@
1
- import { TaskRunContext, InitOutput, RetryOptions, QueueOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, FetchRetryOptions } from '@trigger.dev/core/v3';
2
- export { HandleErrorArgs, HandleErrorFunction, RetryOptions, ProjectConfig as TriggerConfig, logger } from '@trigger.dev/core/v3';
1
+ import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult } from '@trigger.dev/core/v3';
2
+ export { APIError, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, RetryOptions, ProjectConfig as TriggerConfig, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
3
3
  import { HttpHandler } from 'msw';
4
4
 
5
5
  type Context = TaskRunContext;
@@ -9,7 +9,10 @@ type RequireOne<T, K extends keyof T> = {
9
9
  [P in K]-?: T[P];
10
10
  };
11
11
  type Queue = RequireOne<QueueOptions, "name">;
12
- type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any> = {
12
+ declare function queue(options: {
13
+ name: string;
14
+ } & QueueOptions): Queue;
15
+ type TaskOptions<TPayload = void, TOutput = unknown, TInitOutput extends InitOutput = any> = {
13
16
  /** An id for your task. This must be unique inside your project and not change between versions. */
14
17
  id: string;
15
18
  /** The retry settings when an uncaught error is thrown.
@@ -99,11 +102,48 @@ type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any>
99
102
  * @param params - Metadata about the run.
100
103
  */
101
104
  run: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<TOutput>;
105
+ /**
106
+ * init is called before the run function is called. It's useful for setting up any global state.
107
+ */
102
108
  init?: (payload: TPayload, params: InitFnParams) => Promise<TInitOutput>;
103
- handleError?: (payload: TPayload, error: unknown, params: HandleErrorFnParams<TInitOutput>) => HandleErrorResult;
109
+ /**
110
+ * cleanup is called after the run function has completed.
111
+ */
104
112
  cleanup?: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<void>;
113
+ /**
114
+ * handleError is called when the run function throws an error. It can be used to modify the error or return new retry options.
115
+ */
116
+ handleError?: (payload: TPayload, error: unknown, params: HandleErrorFnParams<TInitOutput>) => HandleErrorResult;
117
+ /**
118
+ * middleware allows you to run code "around" the run function. This can be useful for logging, metrics, or other cross-cutting concerns.
119
+ *
120
+ * When writing middleware, you should always call `next()` to continue the execution of the task:
121
+ *
122
+ * ```ts
123
+ * export const middlewareTask = task({
124
+ * id: "middleware-task",
125
+ * middleware: async (payload, { ctx, next }) => {
126
+ * console.log("Before run");
127
+ * await next();
128
+ * console.log("After run");
129
+ * },
130
+ * run: async (payload, { ctx }) => {}
131
+ * });
132
+ * ```
133
+ */
105
134
  middleware?: (payload: TPayload, params: MiddlewareFnParams) => Promise<void>;
106
- onSuccess?: (payload: TPayload, params: SuccessFnParams<TOutput, TInitOutput>) => Promise<void>;
135
+ /**
136
+ * onStart is called the first time a task is executed in a run (not before every retry)
137
+ */
138
+ onStart?: (payload: TPayload, params: StartFnParams) => Promise<void>;
139
+ /**
140
+ * onSuccess is called after the run function has successfully completed.
141
+ */
142
+ onSuccess?: (payload: TPayload, output: TOutput, params: SuccessFnParams<TInitOutput>) => Promise<void>;
143
+ /**
144
+ * onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
145
+ */
146
+ onFailure?: (payload: TPayload, error: unknown, params: FailureFnParams<TInitOutput>) => Promise<void>;
107
147
  };
108
148
  type InvokeHandle = {
109
149
  id: string;
@@ -119,36 +159,79 @@ type TaskRunResult<TOutput = any> = {
119
159
  } | {
120
160
  ok: false;
121
161
  id: string;
122
- error: any;
162
+ error: unknown;
123
163
  };
124
164
  type BatchResult<TOutput = any> = {
125
165
  id: string;
126
166
  runs: TaskRunResult<TOutput>[];
127
167
  };
128
- type Task<TInput, TOutput = any> = {
129
- trigger: (params: {
130
- payload: TInput;
131
- options?: TaskRunOptions;
132
- }) => Promise<InvokeHandle>;
133
- batchTrigger: (params: {
134
- items: {
135
- payload: TInput;
136
- options?: TaskRunOptions;
137
- }[];
138
- batchOptions?: BatchRunOptions;
139
- }) => Promise<InvokeBatchHandle>;
140
- triggerAndWait: (params: {
141
- payload: TInput;
142
- options?: TaskRunOptions;
143
- }) => Promise<TOutput>;
144
- batchTriggerAndWait: (params: {
145
- items: {
146
- payload: TInput;
147
- options?: TaskRunOptions;
148
- }[];
149
- batchOptions?: BatchRunOptions;
150
- }) => Promise<BatchResult<TOutput>>;
168
+ type BatchItem<TInput> = TInput extends void ? {
169
+ payload?: TInput;
170
+ options?: TaskRunOptions;
171
+ } : {
172
+ payload: TInput;
173
+ options?: TaskRunOptions;
151
174
  };
175
+ interface Task<TInput = void, TOutput = any> {
176
+ /**
177
+ * The id of the task.
178
+ */
179
+ id: string;
180
+ /**
181
+ * Trigger a task with the given payload, and continue without waiting for the result. If you want to wait for the result, use `triggerAndWait`. Returns the id of the triggered task run.
182
+ * @param payload
183
+ * @param options
184
+ * @returns InvokeHandle
185
+ * - `id` - The id of the triggered task run.
186
+ */
187
+ trigger: (payload: TInput, options?: TaskRunOptions) => Promise<InvokeHandle>;
188
+ /**
189
+ * Batch trigger multiple task runs with the given payloads, and continue without waiting for the results. If you want to wait for the results, use `batchTriggerAndWait`. Returns the id of the triggered batch.
190
+ * @param items
191
+ * @returns InvokeBatchHandle
192
+ * - `batchId` - The id of the triggered batch.
193
+ * - `runs` - The ids of the triggered task runs.
194
+ */
195
+ batchTrigger: (items: Array<BatchItem<TInput>>) => Promise<InvokeBatchHandle>;
196
+ /**
197
+ * Trigger a task with the given payload, and wait for the result. Returns the result of the task run
198
+ * @param payload
199
+ * @param options - Options for the task run
200
+ * @returns TaskRunResult
201
+ * @example
202
+ * ```
203
+ * const result = await task.triggerAndWait({ foo: "bar" });
204
+ *
205
+ * if (result.ok) {
206
+ * console.log(result.output);
207
+ * } else {
208
+ * console.error(result.error);
209
+ * }
210
+ * ```
211
+ */
212
+ triggerAndWait: (payload: TInput, options?: TaskRunOptions) => Promise<TaskRunResult<TOutput>>;
213
+ /**
214
+ * Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
215
+ * @param items
216
+ * @returns BatchResult
217
+ * @example
218
+ * ```
219
+ * const result = await task.batchTriggerAndWait([
220
+ * { payload: { foo: "bar" } },
221
+ * { payload: { foo: "baz" } },
222
+ * ]);
223
+ *
224
+ * for (const run of result.runs) {
225
+ * if (run.ok) {
226
+ * console.log(run.output);
227
+ * } else {
228
+ * console.error(run.error);
229
+ * }
230
+ * }
231
+ * ```
232
+ */
233
+ batchTriggerAndWait: (items: Array<BatchItem<TInput>>) => Promise<BatchResult<TOutput>>;
234
+ }
152
235
  type TaskRunOptions = {
153
236
  idempotencyKey?: string;
154
237
  maxAttempts?: number;
@@ -158,9 +241,6 @@ type TaskRunOptions = {
158
241
  concurrencyKey?: string;
159
242
  };
160
243
  type TaskRunConcurrencyOptions = Queue;
161
- type BatchRunOptions = TaskRunOptions & {
162
- maxConcurrency?: number;
163
- };
164
244
 
165
245
  /** Creates a task that can be triggered
166
246
  * @param options - Task options
@@ -180,7 +260,7 @@ type BatchRunOptions = TaskRunOptions & {
180
260
  *
181
261
  * @returns A task that can be triggered
182
262
  */
183
- declare function task<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
263
+ declare function task$1<TInput = void, TOutput = unknown, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
184
264
 
185
265
  type WaitOptions = {
186
266
  seconds: number;
@@ -251,4 +331,74 @@ declare const retry: {
251
331
  };
252
332
  };
253
333
 
254
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, retry, task, wait };
334
+ declare const runs: {
335
+ replay: typeof replayRun;
336
+ cancel: typeof cancelRun;
337
+ };
338
+ declare function replayRun(runId: string): Promise<ReplayRunResponse>;
339
+ declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
340
+
341
+ declare function task<TOutput, TInitOutput extends InitOutput>(params: TaskOptions<ScheduledTaskPayload, TOutput, TInitOutput>): Task<ScheduledTaskPayload, TOutput>;
342
+ /**
343
+ * Creates a new schedule
344
+ * @param options
345
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
346
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
347
+ * @param options.externalId - An optional external identifier for the schedule
348
+ * @param options.deduplicationKey - An optional deduplication key for the schedule
349
+ * @returns The created schedule
350
+ */
351
+ declare function create(options: CreateScheduleOptions): Promise<ScheduleObject>;
352
+ /**
353
+ * Retrieves a schedule
354
+ * @param scheduleId - The ID of the schedule to retrieve
355
+ * @returns The retrieved schedule
356
+ */
357
+ declare function retrieve(scheduleId: string): Promise<ScheduleObject>;
358
+ /**
359
+ * Updates a schedule
360
+ * @param scheduleId - The ID of the schedule to update
361
+ * @param options - The updated schedule options
362
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
363
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
364
+ * @param options.externalId - An optional external identifier for the schedule
365
+ * @returns The updated schedule
366
+ */
367
+ declare function update(scheduleId: string, options: UpdateScheduleOptions): Promise<ScheduleObject>;
368
+ /**
369
+ * Deletes a schedule
370
+ * @param scheduleId - The ID of the schedule to delete
371
+ */
372
+ declare function del(scheduleId: string): Promise<DeletedScheduleObject>;
373
+ /**
374
+ * Deactivates a schedule
375
+ * @param scheduleId - The ID of the schedule to deactivate
376
+ */
377
+ declare function deactivate(scheduleId: string): Promise<ScheduleObject>;
378
+ /**
379
+ * Activates a schedule
380
+ * @param scheduleId - The ID of the schedule to activate
381
+ */
382
+ declare function activate(scheduleId: string): Promise<ScheduleObject>;
383
+ /**
384
+ * Lists schedules
385
+ * @param options - The list options
386
+ * @param options.page - The page number
387
+ * @param options.perPage - The number of schedules per page
388
+ * @returns The list of schedules
389
+ */
390
+ declare function list(options?: ListScheduleOptions): Promise<ListSchedulesResult>;
391
+
392
+ declare const index_activate: typeof activate;
393
+ declare const index_create: typeof create;
394
+ declare const index_deactivate: typeof deactivate;
395
+ declare const index_del: typeof del;
396
+ declare const index_list: typeof list;
397
+ declare const index_retrieve: typeof retrieve;
398
+ declare const index_task: typeof task;
399
+ declare const index_update: typeof update;
400
+ declare namespace index {
401
+ export { index_activate as activate, index_create as create, index_deactivate as deactivate, index_del as del, index_list as list, index_retrieve as retrieve, index_task as task, index_update as update };
402
+ }
403
+
404
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };