@trigger.dev/core 3.2.2 → 3.3.1
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.
- package/dist/commonjs/v3/apiClient/index.d.ts +45 -27
- package/dist/commonjs/v3/apiClient/index.js +29 -12
- package/dist/commonjs/v3/apiClient/index.js.map +1 -1
- package/dist/commonjs/v3/apiClient/runStream.d.ts +1 -0
- package/dist/commonjs/v3/apiClient/runStream.js.map +1 -1
- package/dist/commonjs/v3/apiClient/types.d.ts +1 -0
- package/dist/commonjs/v3/schemas/api.d.ts +432 -777
- package/dist/commonjs/v3/schemas/api.js +51 -2
- package/dist/commonjs/v3/schemas/api.js.map +1 -1
- package/dist/commonjs/v3/schemas/build.d.ts +0 -506
- package/dist/commonjs/v3/schemas/common.d.ts +22 -0
- package/dist/commonjs/v3/schemas/common.js +4 -0
- package/dist/commonjs/v3/schemas/common.js.map +1 -1
- package/dist/commonjs/v3/schemas/messages.d.ts +147 -1181
- package/dist/commonjs/v3/schemas/resources.d.ts +0 -380
- package/dist/commonjs/v3/schemas/schemas.d.ts +0 -468
- package/dist/commonjs/v3/schemas/schemas.js +0 -2
- package/dist/commonjs/v3/schemas/schemas.js.map +1 -1
- package/dist/commonjs/v3/types/tasks.d.ts +93 -16
- package/dist/commonjs/v3/types/tasks.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/apiClient/index.d.ts +45 -27
- package/dist/esm/v3/apiClient/index.js +30 -13
- package/dist/esm/v3/apiClient/index.js.map +1 -1
- package/dist/esm/v3/apiClient/runStream.d.ts +1 -0
- package/dist/esm/v3/apiClient/runStream.js.map +1 -1
- package/dist/esm/v3/apiClient/types.d.ts +1 -0
- package/dist/esm/v3/schemas/api.d.ts +432 -777
- package/dist/esm/v3/schemas/api.js +49 -0
- package/dist/esm/v3/schemas/api.js.map +1 -1
- package/dist/esm/v3/schemas/build.d.ts +0 -506
- package/dist/esm/v3/schemas/common.d.ts +22 -0
- package/dist/esm/v3/schemas/common.js +4 -0
- package/dist/esm/v3/schemas/common.js.map +1 -1
- package/dist/esm/v3/schemas/messages.d.ts +147 -1181
- package/dist/esm/v3/schemas/resources.d.ts +0 -380
- package/dist/esm/v3/schemas/schemas.d.ts +0 -468
- package/dist/esm/v3/schemas/schemas.js +0 -2
- package/dist/esm/v3/schemas/schemas.js.map +1 -1
- package/dist/esm/v3/types/tasks.d.ts +93 -16
- package/dist/esm/v3/types/tasks.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -22,10 +22,10 @@ export declare class SubtaskUnwrapError extends Error {
|
|
|
22
22
|
readonly cause?: unknown;
|
|
23
23
|
constructor(taskId: string, runId: string, subtaskError: unknown);
|
|
24
24
|
}
|
|
25
|
-
export declare class TaskRunPromise<
|
|
25
|
+
export declare class TaskRunPromise<TIdentifier extends string, TOutput> extends Promise<TaskRunResult<TIdentifier, TOutput>> {
|
|
26
26
|
private readonly taskId;
|
|
27
|
-
constructor(executor: (resolve: (value: TaskRunResult<
|
|
28
|
-
unwrap(): Promise<
|
|
27
|
+
constructor(executor: (resolve: (value: TaskRunResult<TIdentifier, TOutput> | PromiseLike<TaskRunResult<TIdentifier, TOutput>>) => void, reject: (reason?: any) => void) => void, taskId: TIdentifier);
|
|
28
|
+
unwrap(): Promise<TOutput>;
|
|
29
29
|
}
|
|
30
30
|
export type InitOutput = Record<string, any> | void | undefined;
|
|
31
31
|
export type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
@@ -245,34 +245,84 @@ export type RunHandle<TTaskIdentifier extends string, TPayload, TOutput> = Brand
|
|
|
245
245
|
taskIdentifier: TTaskIdentifier;
|
|
246
246
|
}, TPayload, TOutput>;
|
|
247
247
|
export type AnyRunHandle = RunHandle<string, any, any>;
|
|
248
|
+
export type BatchedRunHandle<TTaskIdentifier extends string, TPayload, TOutput> = BrandedRun<{
|
|
249
|
+
id: string;
|
|
250
|
+
taskIdentifier: TTaskIdentifier;
|
|
251
|
+
isCached: boolean;
|
|
252
|
+
idempotencyKey?: string;
|
|
253
|
+
}, TPayload, TOutput>;
|
|
254
|
+
export type AnyBatchedRunHandle = BatchedRunHandle<string, any, any>;
|
|
248
255
|
/**
|
|
249
256
|
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
250
257
|
*/
|
|
251
258
|
export type BatchRunHandle<TTaskIdentifier extends string, TPayload, TOutput> = BrandedRun<{
|
|
252
259
|
batchId: string;
|
|
253
|
-
|
|
260
|
+
isCached: boolean;
|
|
261
|
+
idempotencyKey?: string;
|
|
262
|
+
runs: Array<BatchedRunHandle<TTaskIdentifier, TPayload, TOutput>>;
|
|
254
263
|
publicAccessToken: string;
|
|
255
|
-
taskIdentifier: TTaskIdentifier;
|
|
256
264
|
}, TOutput, TPayload>;
|
|
257
265
|
export type RunHandleOutput<TRunHandle> = TRunHandle extends RunHandle<string, any, infer TOutput> ? TOutput : never;
|
|
258
266
|
export type RunHandlePayload<TRunHandle> = TRunHandle extends RunHandle<string, infer TPayload, any> ? TPayload : never;
|
|
259
267
|
export type RunHandleTaskIdentifier<TRunHandle> = TRunHandle extends RunHandle<infer TTaskIdentifier, any, any> ? TTaskIdentifier : never;
|
|
260
|
-
export type TaskRunResult<TOutput = any> = {
|
|
268
|
+
export type TaskRunResult<TIdentifier extends string, TOutput = any> = {
|
|
261
269
|
ok: true;
|
|
262
270
|
id: string;
|
|
271
|
+
taskIdentifier: TIdentifier;
|
|
263
272
|
output: TOutput;
|
|
264
273
|
} | {
|
|
265
274
|
ok: false;
|
|
266
275
|
id: string;
|
|
276
|
+
taskIdentifier: TIdentifier;
|
|
267
277
|
error: unknown;
|
|
268
278
|
};
|
|
269
|
-
export type
|
|
279
|
+
export type AnyTaskRunResult = TaskRunResult<string, any>;
|
|
280
|
+
export type TaskRunResultFromTask<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, any, infer TOutput> ? TaskRunResult<TIdentifier, TOutput> : never;
|
|
281
|
+
export type BatchResult<TIdentifier extends string, TOutput = any> = {
|
|
270
282
|
id: string;
|
|
271
|
-
runs: TaskRunResult<TOutput>[];
|
|
283
|
+
runs: TaskRunResult<TIdentifier, TOutput>[];
|
|
272
284
|
};
|
|
285
|
+
export type BatchByIdResult<TTask extends AnyTask> = {
|
|
286
|
+
id: string;
|
|
287
|
+
runs: Array<TaskRunResultFromTask<TTask>>;
|
|
288
|
+
};
|
|
289
|
+
export type BatchByTaskResult<TTasks extends readonly AnyTask[]> = {
|
|
290
|
+
id: string;
|
|
291
|
+
runs: {
|
|
292
|
+
[K in keyof TTasks]: TaskRunResultFromTask<TTasks[K]>;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
297
|
+
*/
|
|
298
|
+
export type BatchTasksResult<TTasks extends readonly AnyTask[]> = BatchTasksRunHandle<TTasks>;
|
|
273
299
|
export type BatchItem<TInput> = {
|
|
274
300
|
payload: TInput;
|
|
275
|
-
options?:
|
|
301
|
+
options?: TriggerOptions;
|
|
302
|
+
};
|
|
303
|
+
export type BatchTriggerAndWaitItem<TInput> = {
|
|
304
|
+
payload: TInput;
|
|
305
|
+
options?: TriggerAndWaitOptions;
|
|
306
|
+
};
|
|
307
|
+
export type BatchByIdItem<TRunTypes extends AnyRunTypes> = {
|
|
308
|
+
id: TRunTypes["taskIdentifier"];
|
|
309
|
+
payload: TRunTypes["payload"];
|
|
310
|
+
options?: TriggerOptions;
|
|
311
|
+
};
|
|
312
|
+
export type BatchByIdAndWaitItem<TRunTypes extends AnyRunTypes> = {
|
|
313
|
+
id: TRunTypes["taskIdentifier"];
|
|
314
|
+
payload: TRunTypes["payload"];
|
|
315
|
+
options?: TriggerAndWaitOptions;
|
|
316
|
+
};
|
|
317
|
+
export type BatchByTaskItem<TTask extends AnyTask> = {
|
|
318
|
+
task: TTask;
|
|
319
|
+
payload: TaskPayload<TTask>;
|
|
320
|
+
options?: TriggerOptions;
|
|
321
|
+
};
|
|
322
|
+
export type BatchByTaskAndWaitItem<TTask extends AnyTask> = {
|
|
323
|
+
task: TTask;
|
|
324
|
+
payload: TaskPayload<TTask>;
|
|
325
|
+
options?: TriggerAndWaitOptions;
|
|
276
326
|
};
|
|
277
327
|
export interface Task<TIdentifier extends string, TInput = void, TOutput = any> {
|
|
278
328
|
/**
|
|
@@ -287,7 +337,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
287
337
|
* @returns RunHandle
|
|
288
338
|
* - `id` - The id of the triggered task run.
|
|
289
339
|
*/
|
|
290
|
-
trigger: (payload: TInput, options?:
|
|
340
|
+
trigger: (payload: TInput, options?: TriggerOptions, requestOptions?: TriggerApiRequestOptions) => Promise<RunHandle<TIdentifier, TInput, TOutput>>;
|
|
291
341
|
/**
|
|
292
342
|
* 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.
|
|
293
343
|
* @param items
|
|
@@ -295,7 +345,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
295
345
|
* - `batchId` - The id of the triggered batch.
|
|
296
346
|
* - `runs` - The ids of the triggered task runs.
|
|
297
347
|
*/
|
|
298
|
-
batchTrigger: (items: Array<BatchItem<TInput>>, requestOptions?: TriggerApiRequestOptions) => Promise<BatchRunHandle<TIdentifier, TInput, TOutput>>;
|
|
348
|
+
batchTrigger: (items: Array<BatchItem<TInput>>, options?: BatchTriggerOptions, requestOptions?: TriggerApiRequestOptions) => Promise<BatchRunHandle<TIdentifier, TInput, TOutput>>;
|
|
299
349
|
/**
|
|
300
350
|
* Trigger a task with the given payload, and wait for the result. Returns the result of the task run
|
|
301
351
|
* @param payload
|
|
@@ -312,7 +362,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
312
362
|
* }
|
|
313
363
|
* ```
|
|
314
364
|
*/
|
|
315
|
-
triggerAndWait: (payload: TInput, options?:
|
|
365
|
+
triggerAndWait: (payload: TInput, options?: TriggerAndWaitOptions) => TaskRunPromise<TIdentifier, TOutput>;
|
|
316
366
|
/**
|
|
317
367
|
* Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
|
|
318
368
|
* @param items
|
|
@@ -333,7 +383,7 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
|
|
|
333
383
|
* }
|
|
334
384
|
* ```
|
|
335
385
|
*/
|
|
336
|
-
batchTriggerAndWait: (items: Array<
|
|
386
|
+
batchTriggerAndWait: (items: Array<BatchTriggerAndWaitItem<TInput>>) => Promise<BatchResult<TIdentifier, TOutput>>;
|
|
337
387
|
}
|
|
338
388
|
export interface TaskWithSchema<TIdentifier extends string, TSchema extends TaskSchema | undefined = undefined, TOutput = any> extends Task<TIdentifier, inferSchemaIn<TSchema>, TOutput> {
|
|
339
389
|
schema?: TSchema;
|
|
@@ -351,6 +401,9 @@ export type TaskOutput<TTask extends AnyTask> = TTask extends Task<string, any,
|
|
|
351
401
|
export type TaskOutputHandle<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, infer TInput, infer TOutput> ? RunHandle<TIdentifier, TOutput, TInput> : never;
|
|
352
402
|
export type TaskBatchOutputHandle<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, infer TInput, infer TOutput> ? BatchRunHandle<TIdentifier, TOutput, TInput> : never;
|
|
353
403
|
export type TaskIdentifier<TTask extends AnyTask> = TTask extends Task<infer TIdentifier, any, any> ? TIdentifier : never;
|
|
404
|
+
export type TaskFromIdentifier<TTask extends AnyTask, TIdentifier extends TTask["id"]> = TTask extends {
|
|
405
|
+
id: TIdentifier;
|
|
406
|
+
} ? TTask : never;
|
|
354
407
|
export type TriggerJwtOptions = {
|
|
355
408
|
/**
|
|
356
409
|
* The expiration time of the JWT. This can be a string like "1h" or a Date object.
|
|
@@ -359,7 +412,7 @@ export type TriggerJwtOptions = {
|
|
|
359
412
|
*/
|
|
360
413
|
expirationTime?: number | Date | string;
|
|
361
414
|
};
|
|
362
|
-
export type
|
|
415
|
+
export type TriggerOptions = {
|
|
363
416
|
/**
|
|
364
417
|
* A unique key that can be used to ensure that a task is only triggered once per key.
|
|
365
418
|
*
|
|
@@ -406,6 +459,12 @@ export type TaskRunOptions = {
|
|
|
406
459
|
*
|
|
407
460
|
*/
|
|
408
461
|
idempotencyKey?: IdempotencyKey | string | string[];
|
|
462
|
+
/**
|
|
463
|
+
* The time-to-live for the idempotency key. Once the TTL has passed, the key can be used again.
|
|
464
|
+
*
|
|
465
|
+
* Specify a duration string like "1h", "10s", "30m", etc.
|
|
466
|
+
*/
|
|
467
|
+
idempotencyKeyTTL?: string;
|
|
409
468
|
maxAttempts?: number;
|
|
410
469
|
queue?: TaskRunConcurrencyOptions;
|
|
411
470
|
concurrencyKey?: string;
|
|
@@ -463,6 +522,11 @@ export type TaskRunOptions = {
|
|
|
463
522
|
*/
|
|
464
523
|
maxDuration?: number;
|
|
465
524
|
};
|
|
525
|
+
export type TriggerAndWaitOptions = Omit<TriggerOptions, "idempotencyKey" | "idempotencyKeyTTL">;
|
|
526
|
+
export type BatchTriggerOptions = {
|
|
527
|
+
idempotencyKey?: IdempotencyKey | string | string[];
|
|
528
|
+
idempotencyKeyTTL?: string;
|
|
529
|
+
};
|
|
466
530
|
export type TaskMetadataWithFunctions = TaskMetadata & {
|
|
467
531
|
fns: {
|
|
468
532
|
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
@@ -482,6 +546,19 @@ export type RunTypes<TTaskIdentifier extends string, TPayload, TOutput> = {
|
|
|
482
546
|
taskIdentifier: TTaskIdentifier;
|
|
483
547
|
};
|
|
484
548
|
export type AnyRunTypes = RunTypes<string, any, any>;
|
|
485
|
-
export type InferRunTypes<T> = T extends RunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends Task<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : AnyRunTypes;
|
|
549
|
+
export type InferRunTypes<T> = T extends RunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends BatchedRunHandle<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : T extends Task<infer TTaskIdentifier, infer TPayload, infer TOutput> ? RunTypes<TTaskIdentifier, TPayload, TOutput> : AnyRunTypes;
|
|
486
550
|
export type RunHandleFromTypes<TRunTypes extends AnyRunTypes> = RunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]>;
|
|
487
|
-
export type BatchRunHandleFromTypes<TRunTypes extends AnyRunTypes> = BatchRunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]
|
|
551
|
+
export type BatchRunHandleFromTypes<TRunTypes extends AnyRunTypes> = TRunTypes extends AnyRunTypes ? BatchRunHandle<TRunTypes["taskIdentifier"], TRunTypes["payload"], TRunTypes["output"]> : never;
|
|
552
|
+
/**
|
|
553
|
+
* A BatchRunHandle can be used to retrieve the runs of a batch trigger in a typesafe manner.
|
|
554
|
+
*/
|
|
555
|
+
export type BatchTasksRunHandle<TTasks extends readonly AnyTask[]> = BrandedRun<{
|
|
556
|
+
batchId: string;
|
|
557
|
+
isCached: boolean;
|
|
558
|
+
idempotencyKey?: string;
|
|
559
|
+
runs: {
|
|
560
|
+
[K in keyof TTasks]: BatchedRunHandle<TaskIdentifier<TTasks[K]>, TaskPayload<TTasks[K]>, TaskOutput<TTasks[K]>>;
|
|
561
|
+
};
|
|
562
|
+
publicAccessToken: string;
|
|
563
|
+
}, any, any>;
|
|
564
|
+
export type BatchTasksRunHandleFromTypes<TTasks extends readonly AnyTask[]> = BatchTasksRunHandle<TTasks>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../../src/v3/types/tasks.ts"],"names":[],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