@trigger.dev/core 3.0.0-beta.23 → 3.0.0-beta.24

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.
@@ -0,0 +1,2487 @@
1
+ import { Context as Context$1, Span, SpanOptions, Tracer } from '@opentelemetry/api';
2
+ import { Logger } from '@opentelemetry/api-logs';
3
+ import { InstrumentationOption } from '@opentelemetry/instrumentation';
4
+ import { z } from 'zod';
5
+ import { b as TaskRunContext } from './manager-WNMVbgHf.mjs';
6
+
7
+ type RequireKeys<T extends object, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K> extends infer O ? {
8
+ [P in keyof O]: O[P];
9
+ } : never;
10
+ type Prettify<T> = {
11
+ [K in keyof T]: T[K];
12
+ } & {};
13
+
14
+ type TriggerTracerConfig = {
15
+ name: string;
16
+ version: string;
17
+ } | {
18
+ tracer: Tracer;
19
+ logger: Logger;
20
+ };
21
+ declare class TriggerTracer {
22
+ private readonly _config;
23
+ constructor(_config: TriggerTracerConfig);
24
+ private _tracer;
25
+ private get tracer();
26
+ private _logger;
27
+ private get logger();
28
+ extractContext(traceContext?: Record<string, unknown>): Context$1;
29
+ startActiveSpan<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions, ctx?: Context$1): Promise<T>;
30
+ startSpan(name: string, options?: SpanOptions, ctx?: Context$1): Span;
31
+ }
32
+
33
+ type LogLevel = "none" | "log" | "error" | "warn" | "info" | "debug";
34
+ declare const logLevels: Array<LogLevel>;
35
+ type TaskLoggerConfig = {
36
+ logger: Logger;
37
+ tracer: TriggerTracer;
38
+ level: LogLevel;
39
+ };
40
+ interface TaskLogger {
41
+ debug(message: string, properties?: Record<string, unknown>): void;
42
+ log(message: string, properties?: Record<string, unknown>): void;
43
+ info(message: string, properties?: Record<string, unknown>): void;
44
+ warn(message: string, properties?: Record<string, unknown>): void;
45
+ error(message: string, properties?: Record<string, unknown>): void;
46
+ trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
47
+ }
48
+ declare class OtelTaskLogger implements TaskLogger {
49
+ #private;
50
+ private readonly _config;
51
+ private readonly _level;
52
+ constructor(_config: TaskLoggerConfig);
53
+ debug(message: string, properties?: Record<string, unknown>): void;
54
+ log(message: string, properties?: Record<string, unknown>): void;
55
+ info(message: string, properties?: Record<string, unknown>): void;
56
+ warn(message: string, properties?: Record<string, unknown>): void;
57
+ error(message: string, properties?: Record<string, unknown>): void;
58
+ trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: SpanOptions): Promise<T>;
59
+ }
60
+
61
+ interface ProjectConfig {
62
+ project: string;
63
+ triggerDirectories?: string | string[];
64
+ triggerUrl?: string;
65
+ retries?: {
66
+ enabledInDev?: boolean;
67
+ default?: RetryOptions;
68
+ };
69
+ additionalPackages?: string[];
70
+ /**
71
+ * List of additional files to include in your trigger.dev bundle. e.g. ["./prisma/schema.prisma"]
72
+ *
73
+ * Supports glob patterns.
74
+ *
75
+ * Note: The path separator for glob patterns is `/`, even on Windows!
76
+ */
77
+ additionalFiles?: string[];
78
+ /**
79
+ * List of patterns that determine if a module is included in your trigger.dev bundle. This is needed when consuming ESM only packages, since the trigger.dev bundle is currently built as a CJS module.
80
+ */
81
+ dependenciesToBundle?: Array<string | RegExp>;
82
+ /**
83
+ * The path to your project's tsconfig.json file. Will use tsconfig.json in the project directory if not provided.
84
+ */
85
+ tsconfigPath?: string;
86
+ /**
87
+ * The OpenTelemetry instrumentations to enable
88
+ */
89
+ instrumentations?: InstrumentationOption[];
90
+ /**
91
+ * Set the log level for the logger. Defaults to "log", so you will see "log", "warn", and "error" messages, but not "info", or "debug" messages.
92
+ *
93
+ * We automatically set the logLevel to "debug" during test runs
94
+ *
95
+ * @default "log"
96
+ */
97
+ logLevel?: LogLevel;
98
+ /**
99
+ * Enable console logging while running the dev CLI. This will print out logs from console.log, console.warn, and console.error. By default all logs are sent to the trigger.dev backend, and not logged to the console.
100
+ */
101
+ enableConsoleLogging?: boolean;
102
+ /**
103
+ * Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
104
+ */
105
+ init?: (payload: unknown, params: InitFnParams) => void | Promise<void>;
106
+ /**
107
+ * onSuccess is called after the run function has successfully completed.
108
+ */
109
+ onSuccess?: (payload: unknown, output: unknown, params: SuccessFnParams<any>) => Promise<void>;
110
+ /**
111
+ * onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
112
+ */
113
+ onFailure?: (payload: unknown, error: unknown, params: FailureFnParams<any>) => Promise<void>;
114
+ /**
115
+ * onStart is called the first time a task is executed in a run (not before every retry)
116
+ */
117
+ onStart?: (payload: unknown, params: StartFnParams) => Promise<void>;
118
+ }
119
+
120
+ type InitOutput = Record<string, any> | void | undefined;
121
+ type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
122
+ /** Metadata about the task, run, attempt, queue, environment, organization, project and batch. */
123
+ ctx: Context;
124
+ /** If you use the `init` function, this will be whatever you returned. */
125
+ init?: TInitOutput;
126
+ }>;
127
+ type MiddlewareFnParams = Prettify<{
128
+ ctx: Context;
129
+ next: () => Promise<void>;
130
+ }>;
131
+ type InitFnParams = Prettify<{
132
+ ctx: Context;
133
+ }>;
134
+ type StartFnParams = Prettify<{
135
+ ctx: Context;
136
+ }>;
137
+ type Context = TaskRunContext;
138
+ type SuccessFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
139
+ type FailureFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
140
+ type HandleErrorFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput> & Prettify<{
141
+ retry?: RetryOptions;
142
+ retryAt?: Date;
143
+ retryDelayInMs?: number;
144
+ }>;
145
+ type HandleErrorModificationOptions = {
146
+ skipRetrying?: boolean | undefined;
147
+ retryAt?: Date | undefined;
148
+ retryDelayInMs?: number | undefined;
149
+ retry?: RetryOptions | undefined;
150
+ error?: unknown;
151
+ };
152
+ type HandleErrorResult = undefined | void | HandleErrorModificationOptions | Promise<undefined | void | HandleErrorModificationOptions>;
153
+ type HandleErrorArgs = {
154
+ ctx: Context;
155
+ retry?: RetryOptions;
156
+ retryAt?: Date;
157
+ retryDelayInMs?: number;
158
+ };
159
+ type HandleErrorFunction = (payload: any, error: unknown, params: HandleErrorArgs) => HandleErrorResult;
160
+ type TaskMetadataWithFunctions = TaskMetadata & {
161
+ fns: {
162
+ run: (payload: any, params: RunFnParams<any>) => Promise<any>;
163
+ init?: (payload: any, params: InitFnParams) => Promise<InitOutput>;
164
+ cleanup?: (payload: any, params: RunFnParams<any>) => Promise<void>;
165
+ middleware?: (payload: any, params: MiddlewareFnParams) => Promise<void>;
166
+ handleError?: (payload: any, error: unknown, params: HandleErrorFnParams<any>) => HandleErrorResult;
167
+ onSuccess?: (payload: any, output: any, params: SuccessFnParams<any>) => Promise<void>;
168
+ onFailure?: (payload: any, error: unknown, params: FailureFnParams<any>) => Promise<void>;
169
+ onStart?: (payload: any, params: StartFnParams) => Promise<void>;
170
+ };
171
+ };
172
+
173
+ declare const EnvironmentType: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
174
+ type EnvironmentType = z.infer<typeof EnvironmentType>;
175
+ declare const MachineCpu: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
176
+ type MachineCpu = z.infer<typeof MachineCpu>;
177
+ declare const MachineMemory: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>, z.ZodLiteral<8>]>>;
178
+ type MachineMemory = z.infer<typeof MachineMemory>;
179
+ declare const Machine: z.ZodObject<{
180
+ version: z.ZodDefault<z.ZodLiteral<"v1">>;
181
+ cpu: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
182
+ memory: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>, z.ZodLiteral<8>]>>;
183
+ }, "strip", z.ZodTypeAny, {
184
+ version: "v1";
185
+ cpu: 2 | 1 | 4 | 0.25 | 0.5;
186
+ memory: 2 | 1 | 4 | 0.25 | 0.5 | 8;
187
+ }, {
188
+ version?: "v1" | undefined;
189
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
190
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
191
+ }>;
192
+ type Machine = z.infer<typeof Machine>;
193
+ declare const TaskRunExecutionPayload: z.ZodObject<{
194
+ execution: z.ZodObject<{
195
+ task: z.ZodObject<{
196
+ id: z.ZodString;
197
+ filePath: z.ZodString;
198
+ exportName: z.ZodString;
199
+ }, "strip", z.ZodTypeAny, {
200
+ id: string;
201
+ filePath: string;
202
+ exportName: string;
203
+ }, {
204
+ id: string;
205
+ filePath: string;
206
+ exportName: string;
207
+ }>;
208
+ attempt: z.ZodObject<{
209
+ id: z.ZodString;
210
+ number: z.ZodNumber;
211
+ startedAt: z.ZodDate;
212
+ backgroundWorkerId: z.ZodString;
213
+ backgroundWorkerTaskId: z.ZodString;
214
+ status: z.ZodString;
215
+ }, "strip", z.ZodTypeAny, {
216
+ number: number;
217
+ status: string;
218
+ id: string;
219
+ startedAt: Date;
220
+ backgroundWorkerId: string;
221
+ backgroundWorkerTaskId: string;
222
+ }, {
223
+ number: number;
224
+ status: string;
225
+ id: string;
226
+ startedAt: Date;
227
+ backgroundWorkerId: string;
228
+ backgroundWorkerTaskId: string;
229
+ }>;
230
+ run: z.ZodObject<{
231
+ id: z.ZodString;
232
+ payload: z.ZodString;
233
+ payloadType: z.ZodString;
234
+ context: z.ZodAny;
235
+ tags: z.ZodArray<z.ZodString, "many">;
236
+ isTest: z.ZodDefault<z.ZodBoolean>;
237
+ createdAt: z.ZodDate;
238
+ idempotencyKey: z.ZodOptional<z.ZodString>;
239
+ }, "strip", z.ZodTypeAny, {
240
+ id: string;
241
+ payload: string;
242
+ payloadType: string;
243
+ tags: string[];
244
+ isTest: boolean;
245
+ createdAt: Date;
246
+ context?: any;
247
+ idempotencyKey?: string | undefined;
248
+ }, {
249
+ id: string;
250
+ payload: string;
251
+ payloadType: string;
252
+ tags: string[];
253
+ createdAt: Date;
254
+ context?: any;
255
+ isTest?: boolean | undefined;
256
+ idempotencyKey?: string | undefined;
257
+ }>;
258
+ queue: z.ZodObject<{
259
+ id: z.ZodString;
260
+ name: z.ZodString;
261
+ }, "strip", z.ZodTypeAny, {
262
+ id: string;
263
+ name: string;
264
+ }, {
265
+ id: string;
266
+ name: string;
267
+ }>;
268
+ environment: z.ZodObject<{
269
+ id: z.ZodString;
270
+ slug: z.ZodString;
271
+ type: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
272
+ }, "strip", z.ZodTypeAny, {
273
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
274
+ id: string;
275
+ slug: string;
276
+ }, {
277
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
278
+ id: string;
279
+ slug: string;
280
+ }>;
281
+ organization: z.ZodObject<{
282
+ id: z.ZodString;
283
+ slug: z.ZodString;
284
+ name: z.ZodString;
285
+ }, "strip", z.ZodTypeAny, {
286
+ id: string;
287
+ name: string;
288
+ slug: string;
289
+ }, {
290
+ id: string;
291
+ name: string;
292
+ slug: string;
293
+ }>;
294
+ project: z.ZodObject<{
295
+ id: z.ZodString;
296
+ ref: z.ZodString;
297
+ slug: z.ZodString;
298
+ name: z.ZodString;
299
+ }, "strip", z.ZodTypeAny, {
300
+ id: string;
301
+ name: string;
302
+ slug: string;
303
+ ref: string;
304
+ }, {
305
+ id: string;
306
+ name: string;
307
+ slug: string;
308
+ ref: string;
309
+ }>;
310
+ batch: z.ZodOptional<z.ZodObject<{
311
+ id: z.ZodString;
312
+ }, "strip", z.ZodTypeAny, {
313
+ id: string;
314
+ }, {
315
+ id: string;
316
+ }>>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ task: {
319
+ id: string;
320
+ filePath: string;
321
+ exportName: string;
322
+ };
323
+ attempt: {
324
+ number: number;
325
+ status: string;
326
+ id: string;
327
+ startedAt: Date;
328
+ backgroundWorkerId: string;
329
+ backgroundWorkerTaskId: string;
330
+ };
331
+ run: {
332
+ id: string;
333
+ payload: string;
334
+ payloadType: string;
335
+ tags: string[];
336
+ isTest: boolean;
337
+ createdAt: Date;
338
+ context?: any;
339
+ idempotencyKey?: string | undefined;
340
+ };
341
+ queue: {
342
+ id: string;
343
+ name: string;
344
+ };
345
+ environment: {
346
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
347
+ id: string;
348
+ slug: string;
349
+ };
350
+ organization: {
351
+ id: string;
352
+ name: string;
353
+ slug: string;
354
+ };
355
+ project: {
356
+ id: string;
357
+ name: string;
358
+ slug: string;
359
+ ref: string;
360
+ };
361
+ batch?: {
362
+ id: string;
363
+ } | undefined;
364
+ }, {
365
+ task: {
366
+ id: string;
367
+ filePath: string;
368
+ exportName: string;
369
+ };
370
+ attempt: {
371
+ number: number;
372
+ status: string;
373
+ id: string;
374
+ startedAt: Date;
375
+ backgroundWorkerId: string;
376
+ backgroundWorkerTaskId: string;
377
+ };
378
+ run: {
379
+ id: string;
380
+ payload: string;
381
+ payloadType: string;
382
+ tags: string[];
383
+ createdAt: Date;
384
+ context?: any;
385
+ isTest?: boolean | undefined;
386
+ idempotencyKey?: string | undefined;
387
+ };
388
+ queue: {
389
+ id: string;
390
+ name: string;
391
+ };
392
+ environment: {
393
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
394
+ id: string;
395
+ slug: string;
396
+ };
397
+ organization: {
398
+ id: string;
399
+ name: string;
400
+ slug: string;
401
+ };
402
+ project: {
403
+ id: string;
404
+ name: string;
405
+ slug: string;
406
+ ref: string;
407
+ };
408
+ batch?: {
409
+ id: string;
410
+ } | undefined;
411
+ }>;
412
+ traceContext: z.ZodRecord<z.ZodString, z.ZodUnknown>;
413
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
414
+ }, "strip", z.ZodTypeAny, {
415
+ execution: {
416
+ task: {
417
+ id: string;
418
+ filePath: string;
419
+ exportName: string;
420
+ };
421
+ attempt: {
422
+ number: number;
423
+ status: string;
424
+ id: string;
425
+ startedAt: Date;
426
+ backgroundWorkerId: string;
427
+ backgroundWorkerTaskId: string;
428
+ };
429
+ run: {
430
+ id: string;
431
+ payload: string;
432
+ payloadType: string;
433
+ tags: string[];
434
+ isTest: boolean;
435
+ createdAt: Date;
436
+ context?: any;
437
+ idempotencyKey?: string | undefined;
438
+ };
439
+ queue: {
440
+ id: string;
441
+ name: string;
442
+ };
443
+ environment: {
444
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
445
+ id: string;
446
+ slug: string;
447
+ };
448
+ organization: {
449
+ id: string;
450
+ name: string;
451
+ slug: string;
452
+ };
453
+ project: {
454
+ id: string;
455
+ name: string;
456
+ slug: string;
457
+ ref: string;
458
+ };
459
+ batch?: {
460
+ id: string;
461
+ } | undefined;
462
+ };
463
+ traceContext: Record<string, unknown>;
464
+ environment?: Record<string, string> | undefined;
465
+ }, {
466
+ execution: {
467
+ task: {
468
+ id: string;
469
+ filePath: string;
470
+ exportName: string;
471
+ };
472
+ attempt: {
473
+ number: number;
474
+ status: string;
475
+ id: string;
476
+ startedAt: Date;
477
+ backgroundWorkerId: string;
478
+ backgroundWorkerTaskId: string;
479
+ };
480
+ run: {
481
+ id: string;
482
+ payload: string;
483
+ payloadType: string;
484
+ tags: string[];
485
+ createdAt: Date;
486
+ context?: any;
487
+ isTest?: boolean | undefined;
488
+ idempotencyKey?: string | undefined;
489
+ };
490
+ queue: {
491
+ id: string;
492
+ name: string;
493
+ };
494
+ environment: {
495
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
496
+ id: string;
497
+ slug: string;
498
+ };
499
+ organization: {
500
+ id: string;
501
+ name: string;
502
+ slug: string;
503
+ };
504
+ project: {
505
+ id: string;
506
+ name: string;
507
+ slug: string;
508
+ ref: string;
509
+ };
510
+ batch?: {
511
+ id: string;
512
+ } | undefined;
513
+ };
514
+ traceContext: Record<string, unknown>;
515
+ environment?: Record<string, string> | undefined;
516
+ }>;
517
+ type TaskRunExecutionPayload = z.infer<typeof TaskRunExecutionPayload>;
518
+ declare const ProdTaskRunExecution: z.ZodObject<{
519
+ task: z.ZodObject<{
520
+ id: z.ZodString;
521
+ filePath: z.ZodString;
522
+ exportName: z.ZodString;
523
+ }, "strip", z.ZodTypeAny, {
524
+ id: string;
525
+ filePath: string;
526
+ exportName: string;
527
+ }, {
528
+ id: string;
529
+ filePath: string;
530
+ exportName: string;
531
+ }>;
532
+ attempt: z.ZodObject<{
533
+ id: z.ZodString;
534
+ number: z.ZodNumber;
535
+ startedAt: z.ZodDate;
536
+ backgroundWorkerId: z.ZodString;
537
+ backgroundWorkerTaskId: z.ZodString;
538
+ status: z.ZodString;
539
+ }, "strip", z.ZodTypeAny, {
540
+ number: number;
541
+ status: string;
542
+ id: string;
543
+ startedAt: Date;
544
+ backgroundWorkerId: string;
545
+ backgroundWorkerTaskId: string;
546
+ }, {
547
+ number: number;
548
+ status: string;
549
+ id: string;
550
+ startedAt: Date;
551
+ backgroundWorkerId: string;
552
+ backgroundWorkerTaskId: string;
553
+ }>;
554
+ run: z.ZodObject<{
555
+ id: z.ZodString;
556
+ payload: z.ZodString;
557
+ payloadType: z.ZodString;
558
+ context: z.ZodAny;
559
+ tags: z.ZodArray<z.ZodString, "many">;
560
+ isTest: z.ZodDefault<z.ZodBoolean>;
561
+ createdAt: z.ZodDate;
562
+ idempotencyKey: z.ZodOptional<z.ZodString>;
563
+ }, "strip", z.ZodTypeAny, {
564
+ id: string;
565
+ payload: string;
566
+ payloadType: string;
567
+ tags: string[];
568
+ isTest: boolean;
569
+ createdAt: Date;
570
+ context?: any;
571
+ idempotencyKey?: string | undefined;
572
+ }, {
573
+ id: string;
574
+ payload: string;
575
+ payloadType: string;
576
+ tags: string[];
577
+ createdAt: Date;
578
+ context?: any;
579
+ isTest?: boolean | undefined;
580
+ idempotencyKey?: string | undefined;
581
+ }>;
582
+ queue: z.ZodObject<{
583
+ id: z.ZodString;
584
+ name: z.ZodString;
585
+ }, "strip", z.ZodTypeAny, {
586
+ id: string;
587
+ name: string;
588
+ }, {
589
+ id: string;
590
+ name: string;
591
+ }>;
592
+ environment: z.ZodObject<{
593
+ id: z.ZodString;
594
+ slug: z.ZodString;
595
+ type: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
596
+ }, "strip", z.ZodTypeAny, {
597
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
598
+ id: string;
599
+ slug: string;
600
+ }, {
601
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
602
+ id: string;
603
+ slug: string;
604
+ }>;
605
+ organization: z.ZodObject<{
606
+ id: z.ZodString;
607
+ slug: z.ZodString;
608
+ name: z.ZodString;
609
+ }, "strip", z.ZodTypeAny, {
610
+ id: string;
611
+ name: string;
612
+ slug: string;
613
+ }, {
614
+ id: string;
615
+ name: string;
616
+ slug: string;
617
+ }>;
618
+ project: z.ZodObject<{
619
+ id: z.ZodString;
620
+ ref: z.ZodString;
621
+ slug: z.ZodString;
622
+ name: z.ZodString;
623
+ }, "strip", z.ZodTypeAny, {
624
+ id: string;
625
+ name: string;
626
+ slug: string;
627
+ ref: string;
628
+ }, {
629
+ id: string;
630
+ name: string;
631
+ slug: string;
632
+ ref: string;
633
+ }>;
634
+ batch: z.ZodOptional<z.ZodObject<{
635
+ id: z.ZodString;
636
+ }, "strip", z.ZodTypeAny, {
637
+ id: string;
638
+ }, {
639
+ id: string;
640
+ }>>;
641
+ worker: z.ZodObject<{
642
+ id: z.ZodString;
643
+ contentHash: z.ZodString;
644
+ version: z.ZodString;
645
+ }, "strip", z.ZodTypeAny, {
646
+ id: string;
647
+ version: string;
648
+ contentHash: string;
649
+ }, {
650
+ id: string;
651
+ version: string;
652
+ contentHash: string;
653
+ }>;
654
+ }, "strip", z.ZodTypeAny, {
655
+ task: {
656
+ id: string;
657
+ filePath: string;
658
+ exportName: string;
659
+ };
660
+ attempt: {
661
+ number: number;
662
+ status: string;
663
+ id: string;
664
+ startedAt: Date;
665
+ backgroundWorkerId: string;
666
+ backgroundWorkerTaskId: string;
667
+ };
668
+ run: {
669
+ id: string;
670
+ payload: string;
671
+ payloadType: string;
672
+ tags: string[];
673
+ isTest: boolean;
674
+ createdAt: Date;
675
+ context?: any;
676
+ idempotencyKey?: string | undefined;
677
+ };
678
+ queue: {
679
+ id: string;
680
+ name: string;
681
+ };
682
+ environment: {
683
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
684
+ id: string;
685
+ slug: string;
686
+ };
687
+ organization: {
688
+ id: string;
689
+ name: string;
690
+ slug: string;
691
+ };
692
+ project: {
693
+ id: string;
694
+ name: string;
695
+ slug: string;
696
+ ref: string;
697
+ };
698
+ worker: {
699
+ id: string;
700
+ version: string;
701
+ contentHash: string;
702
+ };
703
+ batch?: {
704
+ id: string;
705
+ } | undefined;
706
+ }, {
707
+ task: {
708
+ id: string;
709
+ filePath: string;
710
+ exportName: string;
711
+ };
712
+ attempt: {
713
+ number: number;
714
+ status: string;
715
+ id: string;
716
+ startedAt: Date;
717
+ backgroundWorkerId: string;
718
+ backgroundWorkerTaskId: string;
719
+ };
720
+ run: {
721
+ id: string;
722
+ payload: string;
723
+ payloadType: string;
724
+ tags: string[];
725
+ createdAt: Date;
726
+ context?: any;
727
+ isTest?: boolean | undefined;
728
+ idempotencyKey?: string | undefined;
729
+ };
730
+ queue: {
731
+ id: string;
732
+ name: string;
733
+ };
734
+ environment: {
735
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
736
+ id: string;
737
+ slug: string;
738
+ };
739
+ organization: {
740
+ id: string;
741
+ name: string;
742
+ slug: string;
743
+ };
744
+ project: {
745
+ id: string;
746
+ name: string;
747
+ slug: string;
748
+ ref: string;
749
+ };
750
+ worker: {
751
+ id: string;
752
+ version: string;
753
+ contentHash: string;
754
+ };
755
+ batch?: {
756
+ id: string;
757
+ } | undefined;
758
+ }>;
759
+ type ProdTaskRunExecution = z.infer<typeof ProdTaskRunExecution>;
760
+ declare const ProdTaskRunExecutionPayload: z.ZodObject<{
761
+ execution: z.ZodObject<{
762
+ task: z.ZodObject<{
763
+ id: z.ZodString;
764
+ filePath: z.ZodString;
765
+ exportName: z.ZodString;
766
+ }, "strip", z.ZodTypeAny, {
767
+ id: string;
768
+ filePath: string;
769
+ exportName: string;
770
+ }, {
771
+ id: string;
772
+ filePath: string;
773
+ exportName: string;
774
+ }>;
775
+ attempt: z.ZodObject<{
776
+ id: z.ZodString;
777
+ number: z.ZodNumber;
778
+ startedAt: z.ZodDate;
779
+ backgroundWorkerId: z.ZodString;
780
+ backgroundWorkerTaskId: z.ZodString;
781
+ status: z.ZodString;
782
+ }, "strip", z.ZodTypeAny, {
783
+ number: number;
784
+ status: string;
785
+ id: string;
786
+ startedAt: Date;
787
+ backgroundWorkerId: string;
788
+ backgroundWorkerTaskId: string;
789
+ }, {
790
+ number: number;
791
+ status: string;
792
+ id: string;
793
+ startedAt: Date;
794
+ backgroundWorkerId: string;
795
+ backgroundWorkerTaskId: string;
796
+ }>;
797
+ run: z.ZodObject<{
798
+ id: z.ZodString;
799
+ payload: z.ZodString;
800
+ payloadType: z.ZodString;
801
+ context: z.ZodAny;
802
+ tags: z.ZodArray<z.ZodString, "many">;
803
+ isTest: z.ZodDefault<z.ZodBoolean>;
804
+ createdAt: z.ZodDate;
805
+ idempotencyKey: z.ZodOptional<z.ZodString>;
806
+ }, "strip", z.ZodTypeAny, {
807
+ id: string;
808
+ payload: string;
809
+ payloadType: string;
810
+ tags: string[];
811
+ isTest: boolean;
812
+ createdAt: Date;
813
+ context?: any;
814
+ idempotencyKey?: string | undefined;
815
+ }, {
816
+ id: string;
817
+ payload: string;
818
+ payloadType: string;
819
+ tags: string[];
820
+ createdAt: Date;
821
+ context?: any;
822
+ isTest?: boolean | undefined;
823
+ idempotencyKey?: string | undefined;
824
+ }>;
825
+ queue: z.ZodObject<{
826
+ id: z.ZodString;
827
+ name: z.ZodString;
828
+ }, "strip", z.ZodTypeAny, {
829
+ id: string;
830
+ name: string;
831
+ }, {
832
+ id: string;
833
+ name: string;
834
+ }>;
835
+ environment: z.ZodObject<{
836
+ id: z.ZodString;
837
+ slug: z.ZodString;
838
+ type: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
839
+ }, "strip", z.ZodTypeAny, {
840
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
841
+ id: string;
842
+ slug: string;
843
+ }, {
844
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
845
+ id: string;
846
+ slug: string;
847
+ }>;
848
+ organization: z.ZodObject<{
849
+ id: z.ZodString;
850
+ slug: z.ZodString;
851
+ name: z.ZodString;
852
+ }, "strip", z.ZodTypeAny, {
853
+ id: string;
854
+ name: string;
855
+ slug: string;
856
+ }, {
857
+ id: string;
858
+ name: string;
859
+ slug: string;
860
+ }>;
861
+ project: z.ZodObject<{
862
+ id: z.ZodString;
863
+ ref: z.ZodString;
864
+ slug: z.ZodString;
865
+ name: z.ZodString;
866
+ }, "strip", z.ZodTypeAny, {
867
+ id: string;
868
+ name: string;
869
+ slug: string;
870
+ ref: string;
871
+ }, {
872
+ id: string;
873
+ name: string;
874
+ slug: string;
875
+ ref: string;
876
+ }>;
877
+ batch: z.ZodOptional<z.ZodObject<{
878
+ id: z.ZodString;
879
+ }, "strip", z.ZodTypeAny, {
880
+ id: string;
881
+ }, {
882
+ id: string;
883
+ }>>;
884
+ worker: z.ZodObject<{
885
+ id: z.ZodString;
886
+ contentHash: z.ZodString;
887
+ version: z.ZodString;
888
+ }, "strip", z.ZodTypeAny, {
889
+ id: string;
890
+ version: string;
891
+ contentHash: string;
892
+ }, {
893
+ id: string;
894
+ version: string;
895
+ contentHash: string;
896
+ }>;
897
+ }, "strip", z.ZodTypeAny, {
898
+ task: {
899
+ id: string;
900
+ filePath: string;
901
+ exportName: string;
902
+ };
903
+ attempt: {
904
+ number: number;
905
+ status: string;
906
+ id: string;
907
+ startedAt: Date;
908
+ backgroundWorkerId: string;
909
+ backgroundWorkerTaskId: string;
910
+ };
911
+ run: {
912
+ id: string;
913
+ payload: string;
914
+ payloadType: string;
915
+ tags: string[];
916
+ isTest: boolean;
917
+ createdAt: Date;
918
+ context?: any;
919
+ idempotencyKey?: string | undefined;
920
+ };
921
+ queue: {
922
+ id: string;
923
+ name: string;
924
+ };
925
+ environment: {
926
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
927
+ id: string;
928
+ slug: string;
929
+ };
930
+ organization: {
931
+ id: string;
932
+ name: string;
933
+ slug: string;
934
+ };
935
+ project: {
936
+ id: string;
937
+ name: string;
938
+ slug: string;
939
+ ref: string;
940
+ };
941
+ worker: {
942
+ id: string;
943
+ version: string;
944
+ contentHash: string;
945
+ };
946
+ batch?: {
947
+ id: string;
948
+ } | undefined;
949
+ }, {
950
+ task: {
951
+ id: string;
952
+ filePath: string;
953
+ exportName: string;
954
+ };
955
+ attempt: {
956
+ number: number;
957
+ status: string;
958
+ id: string;
959
+ startedAt: Date;
960
+ backgroundWorkerId: string;
961
+ backgroundWorkerTaskId: string;
962
+ };
963
+ run: {
964
+ id: string;
965
+ payload: string;
966
+ payloadType: string;
967
+ tags: string[];
968
+ createdAt: Date;
969
+ context?: any;
970
+ isTest?: boolean | undefined;
971
+ idempotencyKey?: string | undefined;
972
+ };
973
+ queue: {
974
+ id: string;
975
+ name: string;
976
+ };
977
+ environment: {
978
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
979
+ id: string;
980
+ slug: string;
981
+ };
982
+ organization: {
983
+ id: string;
984
+ name: string;
985
+ slug: string;
986
+ };
987
+ project: {
988
+ id: string;
989
+ name: string;
990
+ slug: string;
991
+ ref: string;
992
+ };
993
+ worker: {
994
+ id: string;
995
+ version: string;
996
+ contentHash: string;
997
+ };
998
+ batch?: {
999
+ id: string;
1000
+ } | undefined;
1001
+ }>;
1002
+ traceContext: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1003
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1004
+ }, "strip", z.ZodTypeAny, {
1005
+ execution: {
1006
+ task: {
1007
+ id: string;
1008
+ filePath: string;
1009
+ exportName: string;
1010
+ };
1011
+ attempt: {
1012
+ number: number;
1013
+ status: string;
1014
+ id: string;
1015
+ startedAt: Date;
1016
+ backgroundWorkerId: string;
1017
+ backgroundWorkerTaskId: string;
1018
+ };
1019
+ run: {
1020
+ id: string;
1021
+ payload: string;
1022
+ payloadType: string;
1023
+ tags: string[];
1024
+ isTest: boolean;
1025
+ createdAt: Date;
1026
+ context?: any;
1027
+ idempotencyKey?: string | undefined;
1028
+ };
1029
+ queue: {
1030
+ id: string;
1031
+ name: string;
1032
+ };
1033
+ environment: {
1034
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
1035
+ id: string;
1036
+ slug: string;
1037
+ };
1038
+ organization: {
1039
+ id: string;
1040
+ name: string;
1041
+ slug: string;
1042
+ };
1043
+ project: {
1044
+ id: string;
1045
+ name: string;
1046
+ slug: string;
1047
+ ref: string;
1048
+ };
1049
+ worker: {
1050
+ id: string;
1051
+ version: string;
1052
+ contentHash: string;
1053
+ };
1054
+ batch?: {
1055
+ id: string;
1056
+ } | undefined;
1057
+ };
1058
+ traceContext: Record<string, unknown>;
1059
+ environment?: Record<string, string> | undefined;
1060
+ }, {
1061
+ execution: {
1062
+ task: {
1063
+ id: string;
1064
+ filePath: string;
1065
+ exportName: string;
1066
+ };
1067
+ attempt: {
1068
+ number: number;
1069
+ status: string;
1070
+ id: string;
1071
+ startedAt: Date;
1072
+ backgroundWorkerId: string;
1073
+ backgroundWorkerTaskId: string;
1074
+ };
1075
+ run: {
1076
+ id: string;
1077
+ payload: string;
1078
+ payloadType: string;
1079
+ tags: string[];
1080
+ createdAt: Date;
1081
+ context?: any;
1082
+ isTest?: boolean | undefined;
1083
+ idempotencyKey?: string | undefined;
1084
+ };
1085
+ queue: {
1086
+ id: string;
1087
+ name: string;
1088
+ };
1089
+ environment: {
1090
+ type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
1091
+ id: string;
1092
+ slug: string;
1093
+ };
1094
+ organization: {
1095
+ id: string;
1096
+ name: string;
1097
+ slug: string;
1098
+ };
1099
+ project: {
1100
+ id: string;
1101
+ name: string;
1102
+ slug: string;
1103
+ ref: string;
1104
+ };
1105
+ worker: {
1106
+ id: string;
1107
+ version: string;
1108
+ contentHash: string;
1109
+ };
1110
+ batch?: {
1111
+ id: string;
1112
+ } | undefined;
1113
+ };
1114
+ traceContext: Record<string, unknown>;
1115
+ environment?: Record<string, string> | undefined;
1116
+ }>;
1117
+ type ProdTaskRunExecutionPayload = z.infer<typeof ProdTaskRunExecutionPayload>;
1118
+ declare const FixedWindowRateLimit: z.ZodObject<{
1119
+ type: z.ZodLiteral<"fixed-window">;
1120
+ limit: z.ZodNumber;
1121
+ window: z.ZodUnion<[z.ZodObject<{
1122
+ seconds: z.ZodNumber;
1123
+ }, "strip", z.ZodTypeAny, {
1124
+ seconds: number;
1125
+ }, {
1126
+ seconds: number;
1127
+ }>, z.ZodObject<{
1128
+ minutes: z.ZodNumber;
1129
+ }, "strip", z.ZodTypeAny, {
1130
+ minutes: number;
1131
+ }, {
1132
+ minutes: number;
1133
+ }>, z.ZodObject<{
1134
+ hours: z.ZodNumber;
1135
+ }, "strip", z.ZodTypeAny, {
1136
+ hours: number;
1137
+ }, {
1138
+ hours: number;
1139
+ }>]>;
1140
+ }, "strip", z.ZodTypeAny, {
1141
+ type: "fixed-window";
1142
+ limit: number;
1143
+ window: ({
1144
+ seconds: number;
1145
+ } | {
1146
+ minutes: number;
1147
+ } | {
1148
+ hours: number;
1149
+ }) & ({
1150
+ seconds: number;
1151
+ } | {
1152
+ minutes: number;
1153
+ } | {
1154
+ hours: number;
1155
+ } | undefined);
1156
+ }, {
1157
+ type: "fixed-window";
1158
+ limit: number;
1159
+ window: ({
1160
+ seconds: number;
1161
+ } | {
1162
+ minutes: number;
1163
+ } | {
1164
+ hours: number;
1165
+ }) & ({
1166
+ seconds: number;
1167
+ } | {
1168
+ minutes: number;
1169
+ } | {
1170
+ hours: number;
1171
+ } | undefined);
1172
+ }>;
1173
+ declare const SlidingWindowRateLimit: z.ZodObject<{
1174
+ type: z.ZodLiteral<"sliding-window">;
1175
+ limit: z.ZodNumber;
1176
+ window: z.ZodUnion<[z.ZodObject<{
1177
+ seconds: z.ZodNumber;
1178
+ }, "strip", z.ZodTypeAny, {
1179
+ seconds: number;
1180
+ }, {
1181
+ seconds: number;
1182
+ }>, z.ZodObject<{
1183
+ minutes: z.ZodNumber;
1184
+ }, "strip", z.ZodTypeAny, {
1185
+ minutes: number;
1186
+ }, {
1187
+ minutes: number;
1188
+ }>, z.ZodObject<{
1189
+ hours: z.ZodNumber;
1190
+ }, "strip", z.ZodTypeAny, {
1191
+ hours: number;
1192
+ }, {
1193
+ hours: number;
1194
+ }>]>;
1195
+ }, "strip", z.ZodTypeAny, {
1196
+ type: "sliding-window";
1197
+ limit: number;
1198
+ window: ({
1199
+ seconds: number;
1200
+ } | {
1201
+ minutes: number;
1202
+ } | {
1203
+ hours: number;
1204
+ }) & ({
1205
+ seconds: number;
1206
+ } | {
1207
+ minutes: number;
1208
+ } | {
1209
+ hours: number;
1210
+ } | undefined);
1211
+ }, {
1212
+ type: "sliding-window";
1213
+ limit: number;
1214
+ window: ({
1215
+ seconds: number;
1216
+ } | {
1217
+ minutes: number;
1218
+ } | {
1219
+ hours: number;
1220
+ }) & ({
1221
+ seconds: number;
1222
+ } | {
1223
+ minutes: number;
1224
+ } | {
1225
+ hours: number;
1226
+ } | undefined);
1227
+ }>;
1228
+ declare const RateLimitOptions: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1229
+ type: z.ZodLiteral<"fixed-window">;
1230
+ limit: z.ZodNumber;
1231
+ window: z.ZodUnion<[z.ZodObject<{
1232
+ seconds: z.ZodNumber;
1233
+ }, "strip", z.ZodTypeAny, {
1234
+ seconds: number;
1235
+ }, {
1236
+ seconds: number;
1237
+ }>, z.ZodObject<{
1238
+ minutes: z.ZodNumber;
1239
+ }, "strip", z.ZodTypeAny, {
1240
+ minutes: number;
1241
+ }, {
1242
+ minutes: number;
1243
+ }>, z.ZodObject<{
1244
+ hours: z.ZodNumber;
1245
+ }, "strip", z.ZodTypeAny, {
1246
+ hours: number;
1247
+ }, {
1248
+ hours: number;
1249
+ }>]>;
1250
+ }, "strip", z.ZodTypeAny, {
1251
+ type: "fixed-window";
1252
+ limit: number;
1253
+ window: ({
1254
+ seconds: number;
1255
+ } | {
1256
+ minutes: number;
1257
+ } | {
1258
+ hours: number;
1259
+ }) & ({
1260
+ seconds: number;
1261
+ } | {
1262
+ minutes: number;
1263
+ } | {
1264
+ hours: number;
1265
+ } | undefined);
1266
+ }, {
1267
+ type: "fixed-window";
1268
+ limit: number;
1269
+ window: ({
1270
+ seconds: number;
1271
+ } | {
1272
+ minutes: number;
1273
+ } | {
1274
+ hours: number;
1275
+ }) & ({
1276
+ seconds: number;
1277
+ } | {
1278
+ minutes: number;
1279
+ } | {
1280
+ hours: number;
1281
+ } | undefined);
1282
+ }>, z.ZodObject<{
1283
+ type: z.ZodLiteral<"sliding-window">;
1284
+ limit: z.ZodNumber;
1285
+ window: z.ZodUnion<[z.ZodObject<{
1286
+ seconds: z.ZodNumber;
1287
+ }, "strip", z.ZodTypeAny, {
1288
+ seconds: number;
1289
+ }, {
1290
+ seconds: number;
1291
+ }>, z.ZodObject<{
1292
+ minutes: z.ZodNumber;
1293
+ }, "strip", z.ZodTypeAny, {
1294
+ minutes: number;
1295
+ }, {
1296
+ minutes: number;
1297
+ }>, z.ZodObject<{
1298
+ hours: z.ZodNumber;
1299
+ }, "strip", z.ZodTypeAny, {
1300
+ hours: number;
1301
+ }, {
1302
+ hours: number;
1303
+ }>]>;
1304
+ }, "strip", z.ZodTypeAny, {
1305
+ type: "sliding-window";
1306
+ limit: number;
1307
+ window: ({
1308
+ seconds: number;
1309
+ } | {
1310
+ minutes: number;
1311
+ } | {
1312
+ hours: number;
1313
+ }) & ({
1314
+ seconds: number;
1315
+ } | {
1316
+ minutes: number;
1317
+ } | {
1318
+ hours: number;
1319
+ } | undefined);
1320
+ }, {
1321
+ type: "sliding-window";
1322
+ limit: number;
1323
+ window: ({
1324
+ seconds: number;
1325
+ } | {
1326
+ minutes: number;
1327
+ } | {
1328
+ hours: number;
1329
+ }) & ({
1330
+ seconds: number;
1331
+ } | {
1332
+ minutes: number;
1333
+ } | {
1334
+ hours: number;
1335
+ } | undefined);
1336
+ }>]>;
1337
+ type RateLimitOptions = z.infer<typeof RateLimitOptions>;
1338
+ declare const RetryOptions: z.ZodObject<{
1339
+ /** The number of attempts before giving up */
1340
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
1341
+ /** The exponential factor to use when calculating the next retry time.
1342
+ *
1343
+ * Each subsequent retry will be calculated as `previousTimeout * factor`
1344
+ */
1345
+ factor: z.ZodOptional<z.ZodNumber>;
1346
+ /** The minimum time to wait before retrying */
1347
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1348
+ /** The maximum time to wait before retrying */
1349
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1350
+ /** Randomize the timeout between retries.
1351
+ *
1352
+ * This can be useful to prevent the thundering herd problem where all retries happen at the same time.
1353
+ */
1354
+ randomize: z.ZodOptional<z.ZodBoolean>;
1355
+ }, "strip", z.ZodTypeAny, {
1356
+ maxAttempts?: number | undefined;
1357
+ factor?: number | undefined;
1358
+ minTimeoutInMs?: number | undefined;
1359
+ maxTimeoutInMs?: number | undefined;
1360
+ randomize?: boolean | undefined;
1361
+ }, {
1362
+ maxAttempts?: number | undefined;
1363
+ factor?: number | undefined;
1364
+ minTimeoutInMs?: number | undefined;
1365
+ maxTimeoutInMs?: number | undefined;
1366
+ randomize?: boolean | undefined;
1367
+ }>;
1368
+ type RetryOptions = z.infer<typeof RetryOptions>;
1369
+ declare const QueueOptions: z.ZodObject<{
1370
+ /** You can define a shared queue and then pass the name in to your task.
1371
+ *
1372
+ * @example
1373
+ *
1374
+ * ```ts
1375
+ * const myQueue = queue({
1376
+ name: "my-queue",
1377
+ concurrencyLimit: 1,
1378
+ });
1379
+
1380
+ export const task1 = task({
1381
+ id: "task-1",
1382
+ queue: {
1383
+ name: "my-queue",
1384
+ },
1385
+ run: async (payload: { message: string }) => {
1386
+ // ...
1387
+ },
1388
+ });
1389
+
1390
+ export const task2 = task({
1391
+ id: "task-2",
1392
+ queue: {
1393
+ name: "my-queue",
1394
+ },
1395
+ run: async (payload: { message: string }) => {
1396
+ // ...
1397
+ },
1398
+ });
1399
+ * ```
1400
+ */
1401
+ name: z.ZodOptional<z.ZodString>;
1402
+ /** An optional property that specifies the maximum number of concurrent run executions.
1403
+ *
1404
+ * If this property is omitted, the task can potentially use up the full concurrency of an environment. */
1405
+ concurrencyLimit: z.ZodOptional<z.ZodNumber>;
1406
+ /** @deprecated This feature is coming soon */
1407
+ rateLimit: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1408
+ type: z.ZodLiteral<"fixed-window">;
1409
+ limit: z.ZodNumber;
1410
+ window: z.ZodUnion<[z.ZodObject<{
1411
+ seconds: z.ZodNumber;
1412
+ }, "strip", z.ZodTypeAny, {
1413
+ seconds: number;
1414
+ }, {
1415
+ seconds: number;
1416
+ }>, z.ZodObject<{
1417
+ minutes: z.ZodNumber;
1418
+ }, "strip", z.ZodTypeAny, {
1419
+ minutes: number;
1420
+ }, {
1421
+ minutes: number;
1422
+ }>, z.ZodObject<{
1423
+ hours: z.ZodNumber;
1424
+ }, "strip", z.ZodTypeAny, {
1425
+ hours: number;
1426
+ }, {
1427
+ hours: number;
1428
+ }>]>;
1429
+ }, "strip", z.ZodTypeAny, {
1430
+ type: "fixed-window";
1431
+ limit: number;
1432
+ window: ({
1433
+ seconds: number;
1434
+ } | {
1435
+ minutes: number;
1436
+ } | {
1437
+ hours: number;
1438
+ }) & ({
1439
+ seconds: number;
1440
+ } | {
1441
+ minutes: number;
1442
+ } | {
1443
+ hours: number;
1444
+ } | undefined);
1445
+ }, {
1446
+ type: "fixed-window";
1447
+ limit: number;
1448
+ window: ({
1449
+ seconds: number;
1450
+ } | {
1451
+ minutes: number;
1452
+ } | {
1453
+ hours: number;
1454
+ }) & ({
1455
+ seconds: number;
1456
+ } | {
1457
+ minutes: number;
1458
+ } | {
1459
+ hours: number;
1460
+ } | undefined);
1461
+ }>, z.ZodObject<{
1462
+ type: z.ZodLiteral<"sliding-window">;
1463
+ limit: z.ZodNumber;
1464
+ window: z.ZodUnion<[z.ZodObject<{
1465
+ seconds: z.ZodNumber;
1466
+ }, "strip", z.ZodTypeAny, {
1467
+ seconds: number;
1468
+ }, {
1469
+ seconds: number;
1470
+ }>, z.ZodObject<{
1471
+ minutes: z.ZodNumber;
1472
+ }, "strip", z.ZodTypeAny, {
1473
+ minutes: number;
1474
+ }, {
1475
+ minutes: number;
1476
+ }>, z.ZodObject<{
1477
+ hours: z.ZodNumber;
1478
+ }, "strip", z.ZodTypeAny, {
1479
+ hours: number;
1480
+ }, {
1481
+ hours: number;
1482
+ }>]>;
1483
+ }, "strip", z.ZodTypeAny, {
1484
+ type: "sliding-window";
1485
+ limit: number;
1486
+ window: ({
1487
+ seconds: number;
1488
+ } | {
1489
+ minutes: number;
1490
+ } | {
1491
+ hours: number;
1492
+ }) & ({
1493
+ seconds: number;
1494
+ } | {
1495
+ minutes: number;
1496
+ } | {
1497
+ hours: number;
1498
+ } | undefined);
1499
+ }, {
1500
+ type: "sliding-window";
1501
+ limit: number;
1502
+ window: ({
1503
+ seconds: number;
1504
+ } | {
1505
+ minutes: number;
1506
+ } | {
1507
+ hours: number;
1508
+ }) & ({
1509
+ seconds: number;
1510
+ } | {
1511
+ minutes: number;
1512
+ } | {
1513
+ hours: number;
1514
+ } | undefined);
1515
+ }>]>>;
1516
+ }, "strip", z.ZodTypeAny, {
1517
+ name?: string | undefined;
1518
+ concurrencyLimit?: number | undefined;
1519
+ rateLimit?: {
1520
+ type: "fixed-window";
1521
+ limit: number;
1522
+ window: ({
1523
+ seconds: number;
1524
+ } | {
1525
+ minutes: number;
1526
+ } | {
1527
+ hours: number;
1528
+ }) & ({
1529
+ seconds: number;
1530
+ } | {
1531
+ minutes: number;
1532
+ } | {
1533
+ hours: number;
1534
+ } | undefined);
1535
+ } | {
1536
+ type: "sliding-window";
1537
+ limit: number;
1538
+ window: ({
1539
+ seconds: number;
1540
+ } | {
1541
+ minutes: number;
1542
+ } | {
1543
+ hours: number;
1544
+ }) & ({
1545
+ seconds: number;
1546
+ } | {
1547
+ minutes: number;
1548
+ } | {
1549
+ hours: number;
1550
+ } | undefined);
1551
+ } | undefined;
1552
+ }, {
1553
+ name?: string | undefined;
1554
+ concurrencyLimit?: number | undefined;
1555
+ rateLimit?: {
1556
+ type: "fixed-window";
1557
+ limit: number;
1558
+ window: ({
1559
+ seconds: number;
1560
+ } | {
1561
+ minutes: number;
1562
+ } | {
1563
+ hours: number;
1564
+ }) & ({
1565
+ seconds: number;
1566
+ } | {
1567
+ minutes: number;
1568
+ } | {
1569
+ hours: number;
1570
+ } | undefined);
1571
+ } | {
1572
+ type: "sliding-window";
1573
+ limit: number;
1574
+ window: ({
1575
+ seconds: number;
1576
+ } | {
1577
+ minutes: number;
1578
+ } | {
1579
+ hours: number;
1580
+ }) & ({
1581
+ seconds: number;
1582
+ } | {
1583
+ minutes: number;
1584
+ } | {
1585
+ hours: number;
1586
+ } | undefined);
1587
+ } | undefined;
1588
+ }>;
1589
+ type QueueOptions = z.infer<typeof QueueOptions>;
1590
+ declare const TaskMetadata: z.ZodObject<{
1591
+ id: z.ZodString;
1592
+ packageVersion: z.ZodString;
1593
+ queue: z.ZodOptional<z.ZodObject<{
1594
+ /** You can define a shared queue and then pass the name in to your task.
1595
+ *
1596
+ * @example
1597
+ *
1598
+ * ```ts
1599
+ * const myQueue = queue({
1600
+ name: "my-queue",
1601
+ concurrencyLimit: 1,
1602
+ });
1603
+
1604
+ export const task1 = task({
1605
+ id: "task-1",
1606
+ queue: {
1607
+ name: "my-queue",
1608
+ },
1609
+ run: async (payload: { message: string }) => {
1610
+ // ...
1611
+ },
1612
+ });
1613
+
1614
+ export const task2 = task({
1615
+ id: "task-2",
1616
+ queue: {
1617
+ name: "my-queue",
1618
+ },
1619
+ run: async (payload: { message: string }) => {
1620
+ // ...
1621
+ },
1622
+ });
1623
+ * ```
1624
+ */
1625
+ name: z.ZodOptional<z.ZodString>;
1626
+ /** An optional property that specifies the maximum number of concurrent run executions.
1627
+ *
1628
+ * If this property is omitted, the task can potentially use up the full concurrency of an environment. */
1629
+ concurrencyLimit: z.ZodOptional<z.ZodNumber>;
1630
+ /** @deprecated This feature is coming soon */
1631
+ rateLimit: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1632
+ type: z.ZodLiteral<"fixed-window">;
1633
+ limit: z.ZodNumber;
1634
+ window: z.ZodUnion<[z.ZodObject<{
1635
+ seconds: z.ZodNumber;
1636
+ }, "strip", z.ZodTypeAny, {
1637
+ seconds: number;
1638
+ }, {
1639
+ seconds: number;
1640
+ }>, z.ZodObject<{
1641
+ minutes: z.ZodNumber;
1642
+ }, "strip", z.ZodTypeAny, {
1643
+ minutes: number;
1644
+ }, {
1645
+ minutes: number;
1646
+ }>, z.ZodObject<{
1647
+ hours: z.ZodNumber;
1648
+ }, "strip", z.ZodTypeAny, {
1649
+ hours: number;
1650
+ }, {
1651
+ hours: number;
1652
+ }>]>;
1653
+ }, "strip", z.ZodTypeAny, {
1654
+ type: "fixed-window";
1655
+ limit: number;
1656
+ window: ({
1657
+ seconds: number;
1658
+ } | {
1659
+ minutes: number;
1660
+ } | {
1661
+ hours: number;
1662
+ }) & ({
1663
+ seconds: number;
1664
+ } | {
1665
+ minutes: number;
1666
+ } | {
1667
+ hours: number;
1668
+ } | undefined);
1669
+ }, {
1670
+ type: "fixed-window";
1671
+ limit: number;
1672
+ window: ({
1673
+ seconds: number;
1674
+ } | {
1675
+ minutes: number;
1676
+ } | {
1677
+ hours: number;
1678
+ }) & ({
1679
+ seconds: number;
1680
+ } | {
1681
+ minutes: number;
1682
+ } | {
1683
+ hours: number;
1684
+ } | undefined);
1685
+ }>, z.ZodObject<{
1686
+ type: z.ZodLiteral<"sliding-window">;
1687
+ limit: z.ZodNumber;
1688
+ window: z.ZodUnion<[z.ZodObject<{
1689
+ seconds: z.ZodNumber;
1690
+ }, "strip", z.ZodTypeAny, {
1691
+ seconds: number;
1692
+ }, {
1693
+ seconds: number;
1694
+ }>, z.ZodObject<{
1695
+ minutes: z.ZodNumber;
1696
+ }, "strip", z.ZodTypeAny, {
1697
+ minutes: number;
1698
+ }, {
1699
+ minutes: number;
1700
+ }>, z.ZodObject<{
1701
+ hours: z.ZodNumber;
1702
+ }, "strip", z.ZodTypeAny, {
1703
+ hours: number;
1704
+ }, {
1705
+ hours: number;
1706
+ }>]>;
1707
+ }, "strip", z.ZodTypeAny, {
1708
+ type: "sliding-window";
1709
+ limit: number;
1710
+ window: ({
1711
+ seconds: number;
1712
+ } | {
1713
+ minutes: number;
1714
+ } | {
1715
+ hours: number;
1716
+ }) & ({
1717
+ seconds: number;
1718
+ } | {
1719
+ minutes: number;
1720
+ } | {
1721
+ hours: number;
1722
+ } | undefined);
1723
+ }, {
1724
+ type: "sliding-window";
1725
+ limit: number;
1726
+ window: ({
1727
+ seconds: number;
1728
+ } | {
1729
+ minutes: number;
1730
+ } | {
1731
+ hours: number;
1732
+ }) & ({
1733
+ seconds: number;
1734
+ } | {
1735
+ minutes: number;
1736
+ } | {
1737
+ hours: number;
1738
+ } | undefined);
1739
+ }>]>>;
1740
+ }, "strip", z.ZodTypeAny, {
1741
+ name?: string | undefined;
1742
+ concurrencyLimit?: number | undefined;
1743
+ rateLimit?: {
1744
+ type: "fixed-window";
1745
+ limit: number;
1746
+ window: ({
1747
+ seconds: number;
1748
+ } | {
1749
+ minutes: number;
1750
+ } | {
1751
+ hours: number;
1752
+ }) & ({
1753
+ seconds: number;
1754
+ } | {
1755
+ minutes: number;
1756
+ } | {
1757
+ hours: number;
1758
+ } | undefined);
1759
+ } | {
1760
+ type: "sliding-window";
1761
+ limit: number;
1762
+ window: ({
1763
+ seconds: number;
1764
+ } | {
1765
+ minutes: number;
1766
+ } | {
1767
+ hours: number;
1768
+ }) & ({
1769
+ seconds: number;
1770
+ } | {
1771
+ minutes: number;
1772
+ } | {
1773
+ hours: number;
1774
+ } | undefined);
1775
+ } | undefined;
1776
+ }, {
1777
+ name?: string | undefined;
1778
+ concurrencyLimit?: number | undefined;
1779
+ rateLimit?: {
1780
+ type: "fixed-window";
1781
+ limit: number;
1782
+ window: ({
1783
+ seconds: number;
1784
+ } | {
1785
+ minutes: number;
1786
+ } | {
1787
+ hours: number;
1788
+ }) & ({
1789
+ seconds: number;
1790
+ } | {
1791
+ minutes: number;
1792
+ } | {
1793
+ hours: number;
1794
+ } | undefined);
1795
+ } | {
1796
+ type: "sliding-window";
1797
+ limit: number;
1798
+ window: ({
1799
+ seconds: number;
1800
+ } | {
1801
+ minutes: number;
1802
+ } | {
1803
+ hours: number;
1804
+ }) & ({
1805
+ seconds: number;
1806
+ } | {
1807
+ minutes: number;
1808
+ } | {
1809
+ hours: number;
1810
+ } | undefined);
1811
+ } | undefined;
1812
+ }>>;
1813
+ retry: z.ZodOptional<z.ZodObject<{
1814
+ /** The number of attempts before giving up */
1815
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
1816
+ /** The exponential factor to use when calculating the next retry time.
1817
+ *
1818
+ * Each subsequent retry will be calculated as `previousTimeout * factor`
1819
+ */
1820
+ factor: z.ZodOptional<z.ZodNumber>;
1821
+ /** The minimum time to wait before retrying */
1822
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1823
+ /** The maximum time to wait before retrying */
1824
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1825
+ /** Randomize the timeout between retries.
1826
+ *
1827
+ * This can be useful to prevent the thundering herd problem where all retries happen at the same time.
1828
+ */
1829
+ randomize: z.ZodOptional<z.ZodBoolean>;
1830
+ }, "strip", z.ZodTypeAny, {
1831
+ maxAttempts?: number | undefined;
1832
+ factor?: number | undefined;
1833
+ minTimeoutInMs?: number | undefined;
1834
+ maxTimeoutInMs?: number | undefined;
1835
+ randomize?: boolean | undefined;
1836
+ }, {
1837
+ maxAttempts?: number | undefined;
1838
+ factor?: number | undefined;
1839
+ minTimeoutInMs?: number | undefined;
1840
+ maxTimeoutInMs?: number | undefined;
1841
+ randomize?: boolean | undefined;
1842
+ }>>;
1843
+ machine: z.ZodOptional<z.ZodObject<{
1844
+ version: z.ZodOptional<z.ZodDefault<z.ZodLiteral<"v1">>>;
1845
+ cpu: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>>;
1846
+ memory: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>, z.ZodLiteral<8>]>>>;
1847
+ }, "strip", z.ZodTypeAny, {
1848
+ version?: "v1" | undefined;
1849
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
1850
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
1851
+ }, {
1852
+ version?: "v1" | undefined;
1853
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
1854
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
1855
+ }>>;
1856
+ triggerSource: z.ZodOptional<z.ZodString>;
1857
+ }, "strip", z.ZodTypeAny, {
1858
+ id: string;
1859
+ packageVersion: string;
1860
+ queue?: {
1861
+ name?: string | undefined;
1862
+ concurrencyLimit?: number | undefined;
1863
+ rateLimit?: {
1864
+ type: "fixed-window";
1865
+ limit: number;
1866
+ window: ({
1867
+ seconds: number;
1868
+ } | {
1869
+ minutes: number;
1870
+ } | {
1871
+ hours: number;
1872
+ }) & ({
1873
+ seconds: number;
1874
+ } | {
1875
+ minutes: number;
1876
+ } | {
1877
+ hours: number;
1878
+ } | undefined);
1879
+ } | {
1880
+ type: "sliding-window";
1881
+ limit: number;
1882
+ window: ({
1883
+ seconds: number;
1884
+ } | {
1885
+ minutes: number;
1886
+ } | {
1887
+ hours: number;
1888
+ }) & ({
1889
+ seconds: number;
1890
+ } | {
1891
+ minutes: number;
1892
+ } | {
1893
+ hours: number;
1894
+ } | undefined);
1895
+ } | undefined;
1896
+ } | undefined;
1897
+ retry?: {
1898
+ maxAttempts?: number | undefined;
1899
+ factor?: number | undefined;
1900
+ minTimeoutInMs?: number | undefined;
1901
+ maxTimeoutInMs?: number | undefined;
1902
+ randomize?: boolean | undefined;
1903
+ } | undefined;
1904
+ machine?: {
1905
+ version?: "v1" | undefined;
1906
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
1907
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
1908
+ } | undefined;
1909
+ triggerSource?: string | undefined;
1910
+ }, {
1911
+ id: string;
1912
+ packageVersion: string;
1913
+ queue?: {
1914
+ name?: string | undefined;
1915
+ concurrencyLimit?: number | undefined;
1916
+ rateLimit?: {
1917
+ type: "fixed-window";
1918
+ limit: number;
1919
+ window: ({
1920
+ seconds: number;
1921
+ } | {
1922
+ minutes: number;
1923
+ } | {
1924
+ hours: number;
1925
+ }) & ({
1926
+ seconds: number;
1927
+ } | {
1928
+ minutes: number;
1929
+ } | {
1930
+ hours: number;
1931
+ } | undefined);
1932
+ } | {
1933
+ type: "sliding-window";
1934
+ limit: number;
1935
+ window: ({
1936
+ seconds: number;
1937
+ } | {
1938
+ minutes: number;
1939
+ } | {
1940
+ hours: number;
1941
+ }) & ({
1942
+ seconds: number;
1943
+ } | {
1944
+ minutes: number;
1945
+ } | {
1946
+ hours: number;
1947
+ } | undefined);
1948
+ } | undefined;
1949
+ } | undefined;
1950
+ retry?: {
1951
+ maxAttempts?: number | undefined;
1952
+ factor?: number | undefined;
1953
+ minTimeoutInMs?: number | undefined;
1954
+ maxTimeoutInMs?: number | undefined;
1955
+ randomize?: boolean | undefined;
1956
+ } | undefined;
1957
+ machine?: {
1958
+ version?: "v1" | undefined;
1959
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
1960
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
1961
+ } | undefined;
1962
+ triggerSource?: string | undefined;
1963
+ }>;
1964
+ type TaskMetadata = z.infer<typeof TaskMetadata>;
1965
+ declare const TaskFileMetadata: z.ZodObject<{
1966
+ filePath: z.ZodString;
1967
+ exportName: z.ZodString;
1968
+ }, "strip", z.ZodTypeAny, {
1969
+ filePath: string;
1970
+ exportName: string;
1971
+ }, {
1972
+ filePath: string;
1973
+ exportName: string;
1974
+ }>;
1975
+ type TaskFileMetadata = z.infer<typeof TaskFileMetadata>;
1976
+ declare const TaskMetadataWithFilePath: z.ZodObject<{
1977
+ id: z.ZodString;
1978
+ queue: z.ZodOptional<z.ZodObject<{
1979
+ /** You can define a shared queue and then pass the name in to your task.
1980
+ *
1981
+ * @example
1982
+ *
1983
+ * ```ts
1984
+ * const myQueue = queue({
1985
+ name: "my-queue",
1986
+ concurrencyLimit: 1,
1987
+ });
1988
+
1989
+ export const task1 = task({
1990
+ id: "task-1",
1991
+ queue: {
1992
+ name: "my-queue",
1993
+ },
1994
+ run: async (payload: { message: string }) => {
1995
+ // ...
1996
+ },
1997
+ });
1998
+
1999
+ export const task2 = task({
2000
+ id: "task-2",
2001
+ queue: {
2002
+ name: "my-queue",
2003
+ },
2004
+ run: async (payload: { message: string }) => {
2005
+ // ...
2006
+ },
2007
+ });
2008
+ * ```
2009
+ */
2010
+ name: z.ZodOptional<z.ZodString>;
2011
+ /** An optional property that specifies the maximum number of concurrent run executions.
2012
+ *
2013
+ * If this property is omitted, the task can potentially use up the full concurrency of an environment. */
2014
+ concurrencyLimit: z.ZodOptional<z.ZodNumber>;
2015
+ /** @deprecated This feature is coming soon */
2016
+ rateLimit: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2017
+ type: z.ZodLiteral<"fixed-window">;
2018
+ limit: z.ZodNumber;
2019
+ window: z.ZodUnion<[z.ZodObject<{
2020
+ seconds: z.ZodNumber;
2021
+ }, "strip", z.ZodTypeAny, {
2022
+ seconds: number;
2023
+ }, {
2024
+ seconds: number;
2025
+ }>, z.ZodObject<{
2026
+ minutes: z.ZodNumber;
2027
+ }, "strip", z.ZodTypeAny, {
2028
+ minutes: number;
2029
+ }, {
2030
+ minutes: number;
2031
+ }>, z.ZodObject<{
2032
+ hours: z.ZodNumber;
2033
+ }, "strip", z.ZodTypeAny, {
2034
+ hours: number;
2035
+ }, {
2036
+ hours: number;
2037
+ }>]>;
2038
+ }, "strip", z.ZodTypeAny, {
2039
+ type: "fixed-window";
2040
+ limit: number;
2041
+ window: ({
2042
+ seconds: number;
2043
+ } | {
2044
+ minutes: number;
2045
+ } | {
2046
+ hours: number;
2047
+ }) & ({
2048
+ seconds: number;
2049
+ } | {
2050
+ minutes: number;
2051
+ } | {
2052
+ hours: number;
2053
+ } | undefined);
2054
+ }, {
2055
+ type: "fixed-window";
2056
+ limit: number;
2057
+ window: ({
2058
+ seconds: number;
2059
+ } | {
2060
+ minutes: number;
2061
+ } | {
2062
+ hours: number;
2063
+ }) & ({
2064
+ seconds: number;
2065
+ } | {
2066
+ minutes: number;
2067
+ } | {
2068
+ hours: number;
2069
+ } | undefined);
2070
+ }>, z.ZodObject<{
2071
+ type: z.ZodLiteral<"sliding-window">;
2072
+ limit: z.ZodNumber;
2073
+ window: z.ZodUnion<[z.ZodObject<{
2074
+ seconds: z.ZodNumber;
2075
+ }, "strip", z.ZodTypeAny, {
2076
+ seconds: number;
2077
+ }, {
2078
+ seconds: number;
2079
+ }>, z.ZodObject<{
2080
+ minutes: z.ZodNumber;
2081
+ }, "strip", z.ZodTypeAny, {
2082
+ minutes: number;
2083
+ }, {
2084
+ minutes: number;
2085
+ }>, z.ZodObject<{
2086
+ hours: z.ZodNumber;
2087
+ }, "strip", z.ZodTypeAny, {
2088
+ hours: number;
2089
+ }, {
2090
+ hours: number;
2091
+ }>]>;
2092
+ }, "strip", z.ZodTypeAny, {
2093
+ type: "sliding-window";
2094
+ limit: number;
2095
+ window: ({
2096
+ seconds: number;
2097
+ } | {
2098
+ minutes: number;
2099
+ } | {
2100
+ hours: number;
2101
+ }) & ({
2102
+ seconds: number;
2103
+ } | {
2104
+ minutes: number;
2105
+ } | {
2106
+ hours: number;
2107
+ } | undefined);
2108
+ }, {
2109
+ type: "sliding-window";
2110
+ limit: number;
2111
+ window: ({
2112
+ seconds: number;
2113
+ } | {
2114
+ minutes: number;
2115
+ } | {
2116
+ hours: number;
2117
+ }) & ({
2118
+ seconds: number;
2119
+ } | {
2120
+ minutes: number;
2121
+ } | {
2122
+ hours: number;
2123
+ } | undefined);
2124
+ }>]>>;
2125
+ }, "strip", z.ZodTypeAny, {
2126
+ name?: string | undefined;
2127
+ concurrencyLimit?: number | undefined;
2128
+ rateLimit?: {
2129
+ type: "fixed-window";
2130
+ limit: number;
2131
+ window: ({
2132
+ seconds: number;
2133
+ } | {
2134
+ minutes: number;
2135
+ } | {
2136
+ hours: number;
2137
+ }) & ({
2138
+ seconds: number;
2139
+ } | {
2140
+ minutes: number;
2141
+ } | {
2142
+ hours: number;
2143
+ } | undefined);
2144
+ } | {
2145
+ type: "sliding-window";
2146
+ limit: number;
2147
+ window: ({
2148
+ seconds: number;
2149
+ } | {
2150
+ minutes: number;
2151
+ } | {
2152
+ hours: number;
2153
+ }) & ({
2154
+ seconds: number;
2155
+ } | {
2156
+ minutes: number;
2157
+ } | {
2158
+ hours: number;
2159
+ } | undefined);
2160
+ } | undefined;
2161
+ }, {
2162
+ name?: string | undefined;
2163
+ concurrencyLimit?: number | undefined;
2164
+ rateLimit?: {
2165
+ type: "fixed-window";
2166
+ limit: number;
2167
+ window: ({
2168
+ seconds: number;
2169
+ } | {
2170
+ minutes: number;
2171
+ } | {
2172
+ hours: number;
2173
+ }) & ({
2174
+ seconds: number;
2175
+ } | {
2176
+ minutes: number;
2177
+ } | {
2178
+ hours: number;
2179
+ } | undefined);
2180
+ } | {
2181
+ type: "sliding-window";
2182
+ limit: number;
2183
+ window: ({
2184
+ seconds: number;
2185
+ } | {
2186
+ minutes: number;
2187
+ } | {
2188
+ hours: number;
2189
+ }) & ({
2190
+ seconds: number;
2191
+ } | {
2192
+ minutes: number;
2193
+ } | {
2194
+ hours: number;
2195
+ } | undefined);
2196
+ } | undefined;
2197
+ }>>;
2198
+ retry: z.ZodOptional<z.ZodObject<{
2199
+ /** The number of attempts before giving up */
2200
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
2201
+ /** The exponential factor to use when calculating the next retry time.
2202
+ *
2203
+ * Each subsequent retry will be calculated as `previousTimeout * factor`
2204
+ */
2205
+ factor: z.ZodOptional<z.ZodNumber>;
2206
+ /** The minimum time to wait before retrying */
2207
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2208
+ /** The maximum time to wait before retrying */
2209
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2210
+ /** Randomize the timeout between retries.
2211
+ *
2212
+ * This can be useful to prevent the thundering herd problem where all retries happen at the same time.
2213
+ */
2214
+ randomize: z.ZodOptional<z.ZodBoolean>;
2215
+ }, "strip", z.ZodTypeAny, {
2216
+ maxAttempts?: number | undefined;
2217
+ factor?: number | undefined;
2218
+ minTimeoutInMs?: number | undefined;
2219
+ maxTimeoutInMs?: number | undefined;
2220
+ randomize?: boolean | undefined;
2221
+ }, {
2222
+ maxAttempts?: number | undefined;
2223
+ factor?: number | undefined;
2224
+ minTimeoutInMs?: number | undefined;
2225
+ maxTimeoutInMs?: number | undefined;
2226
+ randomize?: boolean | undefined;
2227
+ }>>;
2228
+ packageVersion: z.ZodString;
2229
+ machine: z.ZodOptional<z.ZodObject<{
2230
+ version: z.ZodOptional<z.ZodDefault<z.ZodLiteral<"v1">>>;
2231
+ cpu: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>>;
2232
+ memory: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>, z.ZodLiteral<8>]>>>;
2233
+ }, "strip", z.ZodTypeAny, {
2234
+ version?: "v1" | undefined;
2235
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
2236
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
2237
+ }, {
2238
+ version?: "v1" | undefined;
2239
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
2240
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
2241
+ }>>;
2242
+ triggerSource: z.ZodOptional<z.ZodString>;
2243
+ filePath: z.ZodString;
2244
+ exportName: z.ZodString;
2245
+ }, "strip", z.ZodTypeAny, {
2246
+ id: string;
2247
+ filePath: string;
2248
+ exportName: string;
2249
+ packageVersion: string;
2250
+ queue?: {
2251
+ name?: string | undefined;
2252
+ concurrencyLimit?: number | undefined;
2253
+ rateLimit?: {
2254
+ type: "fixed-window";
2255
+ limit: number;
2256
+ window: ({
2257
+ seconds: number;
2258
+ } | {
2259
+ minutes: number;
2260
+ } | {
2261
+ hours: number;
2262
+ }) & ({
2263
+ seconds: number;
2264
+ } | {
2265
+ minutes: number;
2266
+ } | {
2267
+ hours: number;
2268
+ } | undefined);
2269
+ } | {
2270
+ type: "sliding-window";
2271
+ limit: number;
2272
+ window: ({
2273
+ seconds: number;
2274
+ } | {
2275
+ minutes: number;
2276
+ } | {
2277
+ hours: number;
2278
+ }) & ({
2279
+ seconds: number;
2280
+ } | {
2281
+ minutes: number;
2282
+ } | {
2283
+ hours: number;
2284
+ } | undefined);
2285
+ } | undefined;
2286
+ } | undefined;
2287
+ retry?: {
2288
+ maxAttempts?: number | undefined;
2289
+ factor?: number | undefined;
2290
+ minTimeoutInMs?: number | undefined;
2291
+ maxTimeoutInMs?: number | undefined;
2292
+ randomize?: boolean | undefined;
2293
+ } | undefined;
2294
+ machine?: {
2295
+ version?: "v1" | undefined;
2296
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
2297
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
2298
+ } | undefined;
2299
+ triggerSource?: string | undefined;
2300
+ }, {
2301
+ id: string;
2302
+ filePath: string;
2303
+ exportName: string;
2304
+ packageVersion: string;
2305
+ queue?: {
2306
+ name?: string | undefined;
2307
+ concurrencyLimit?: number | undefined;
2308
+ rateLimit?: {
2309
+ type: "fixed-window";
2310
+ limit: number;
2311
+ window: ({
2312
+ seconds: number;
2313
+ } | {
2314
+ minutes: number;
2315
+ } | {
2316
+ hours: number;
2317
+ }) & ({
2318
+ seconds: number;
2319
+ } | {
2320
+ minutes: number;
2321
+ } | {
2322
+ hours: number;
2323
+ } | undefined);
2324
+ } | {
2325
+ type: "sliding-window";
2326
+ limit: number;
2327
+ window: ({
2328
+ seconds: number;
2329
+ } | {
2330
+ minutes: number;
2331
+ } | {
2332
+ hours: number;
2333
+ }) & ({
2334
+ seconds: number;
2335
+ } | {
2336
+ minutes: number;
2337
+ } | {
2338
+ hours: number;
2339
+ } | undefined);
2340
+ } | undefined;
2341
+ } | undefined;
2342
+ retry?: {
2343
+ maxAttempts?: number | undefined;
2344
+ factor?: number | undefined;
2345
+ minTimeoutInMs?: number | undefined;
2346
+ maxTimeoutInMs?: number | undefined;
2347
+ randomize?: boolean | undefined;
2348
+ } | undefined;
2349
+ machine?: {
2350
+ version?: "v1" | undefined;
2351
+ cpu?: 2 | 1 | 4 | 0.25 | 0.5 | undefined;
2352
+ memory?: 2 | 1 | 4 | 0.25 | 0.5 | 8 | undefined;
2353
+ } | undefined;
2354
+ triggerSource?: string | undefined;
2355
+ }>;
2356
+ type TaskMetadataWithFilePath = z.infer<typeof TaskMetadataWithFilePath>;
2357
+ declare const PostStartCauses: z.ZodEnum<["index", "create", "restore"]>;
2358
+ type PostStartCauses = z.infer<typeof PostStartCauses>;
2359
+ declare const PreStopCauses: z.ZodEnum<["terminate"]>;
2360
+ type PreStopCauses = z.infer<typeof PreStopCauses>;
2361
+ declare const Config: z.ZodObject<{
2362
+ project: z.ZodString;
2363
+ triggerDirectories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2364
+ triggerUrl: z.ZodOptional<z.ZodString>;
2365
+ projectDir: z.ZodOptional<z.ZodString>;
2366
+ tsconfigPath: z.ZodOptional<z.ZodString>;
2367
+ retries: z.ZodOptional<z.ZodObject<{
2368
+ enabledInDev: z.ZodDefault<z.ZodBoolean>;
2369
+ default: z.ZodOptional<z.ZodObject<{
2370
+ /** The number of attempts before giving up */
2371
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
2372
+ /** The exponential factor to use when calculating the next retry time.
2373
+ *
2374
+ * Each subsequent retry will be calculated as `previousTimeout * factor`
2375
+ */
2376
+ factor: z.ZodOptional<z.ZodNumber>;
2377
+ /** The minimum time to wait before retrying */
2378
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2379
+ /** The maximum time to wait before retrying */
2380
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2381
+ /** Randomize the timeout between retries.
2382
+ *
2383
+ * This can be useful to prevent the thundering herd problem where all retries happen at the same time.
2384
+ */
2385
+ randomize: z.ZodOptional<z.ZodBoolean>;
2386
+ }, "strip", z.ZodTypeAny, {
2387
+ maxAttempts?: number | undefined;
2388
+ factor?: number | undefined;
2389
+ minTimeoutInMs?: number | undefined;
2390
+ maxTimeoutInMs?: number | undefined;
2391
+ randomize?: boolean | undefined;
2392
+ }, {
2393
+ maxAttempts?: number | undefined;
2394
+ factor?: number | undefined;
2395
+ minTimeoutInMs?: number | undefined;
2396
+ maxTimeoutInMs?: number | undefined;
2397
+ randomize?: boolean | undefined;
2398
+ }>>;
2399
+ }, "strip", z.ZodTypeAny, {
2400
+ enabledInDev: boolean;
2401
+ default?: {
2402
+ maxAttempts?: number | undefined;
2403
+ factor?: number | undefined;
2404
+ minTimeoutInMs?: number | undefined;
2405
+ maxTimeoutInMs?: number | undefined;
2406
+ randomize?: boolean | undefined;
2407
+ } | undefined;
2408
+ }, {
2409
+ enabledInDev?: boolean | undefined;
2410
+ default?: {
2411
+ maxAttempts?: number | undefined;
2412
+ factor?: number | undefined;
2413
+ minTimeoutInMs?: number | undefined;
2414
+ maxTimeoutInMs?: number | undefined;
2415
+ randomize?: boolean | undefined;
2416
+ } | undefined;
2417
+ }>>;
2418
+ additionalPackages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2419
+ additionalFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2420
+ dependenciesToBundle: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">>;
2421
+ logLevel: z.ZodOptional<z.ZodString>;
2422
+ enableConsoleLogging: z.ZodOptional<z.ZodBoolean>;
2423
+ }, "strip", z.ZodTypeAny, {
2424
+ project: string;
2425
+ triggerDirectories?: string[] | undefined;
2426
+ triggerUrl?: string | undefined;
2427
+ projectDir?: string | undefined;
2428
+ tsconfigPath?: string | undefined;
2429
+ retries?: {
2430
+ enabledInDev: boolean;
2431
+ default?: {
2432
+ maxAttempts?: number | undefined;
2433
+ factor?: number | undefined;
2434
+ minTimeoutInMs?: number | undefined;
2435
+ maxTimeoutInMs?: number | undefined;
2436
+ randomize?: boolean | undefined;
2437
+ } | undefined;
2438
+ } | undefined;
2439
+ additionalPackages?: string[] | undefined;
2440
+ additionalFiles?: string[] | undefined;
2441
+ dependenciesToBundle?: (string | RegExp)[] | undefined;
2442
+ logLevel?: string | undefined;
2443
+ enableConsoleLogging?: boolean | undefined;
2444
+ }, {
2445
+ project: string;
2446
+ triggerDirectories?: string[] | undefined;
2447
+ triggerUrl?: string | undefined;
2448
+ projectDir?: string | undefined;
2449
+ tsconfigPath?: string | undefined;
2450
+ retries?: {
2451
+ enabledInDev?: boolean | undefined;
2452
+ default?: {
2453
+ maxAttempts?: number | undefined;
2454
+ factor?: number | undefined;
2455
+ minTimeoutInMs?: number | undefined;
2456
+ maxTimeoutInMs?: number | undefined;
2457
+ randomize?: boolean | undefined;
2458
+ } | undefined;
2459
+ } | undefined;
2460
+ additionalPackages?: string[] | undefined;
2461
+ additionalFiles?: string[] | undefined;
2462
+ dependenciesToBundle?: (string | RegExp)[] | undefined;
2463
+ logLevel?: string | undefined;
2464
+ enableConsoleLogging?: boolean | undefined;
2465
+ }>;
2466
+ type Config = z.infer<typeof Config>;
2467
+ type ResolvedConfig = RequireKeys<Config, "triggerDirectories" | "triggerUrl" | "projectDir" | "tsconfigPath">;
2468
+ declare const WaitReason: z.ZodEnum<["WAIT_FOR_DURATION", "WAIT_FOR_TASK", "WAIT_FOR_BATCH"]>;
2469
+ type WaitReason = z.infer<typeof WaitReason>;
2470
+
2471
+ type ClockTime = [number, number];
2472
+ interface Clock {
2473
+ preciseNow(): ClockTime;
2474
+ reset(): void;
2475
+ }
2476
+
2477
+ interface TaskCatalog {
2478
+ registerTaskMetadata(task: TaskMetadataWithFunctions): void;
2479
+ updateTaskMetadata(id: string, task: Partial<TaskMetadataWithFunctions>): void;
2480
+ registerTaskFileMetadata(id: string, metadata: TaskFileMetadata): void;
2481
+ getAllTaskMetadata(): Array<TaskMetadataWithFilePath>;
2482
+ getTaskMetadata(id: string): TaskMetadataWithFilePath | undefined;
2483
+ getTask(id: string): TaskMetadataWithFunctions | undefined;
2484
+ taskExists(id: string): boolean;
2485
+ }
2486
+
2487
+ export { type HandleErrorArgs as A, type HandleErrorFunction as B, type Clock as C, type RequireKeys as D, EnvironmentType as E, FixedWindowRateLimit as F, type ProjectConfig as G, type HandleErrorFnParams as H, type InitOutput as I, logLevels as J, type LogLevel as L, MachineCpu as M, OtelTaskLogger as O, type Prettify as P, QueueOptions as Q, RetryOptions as R, SlidingWindowRateLimit as S, type TaskLogger as T, WaitReason as W, type ClockTime as a, type TaskCatalog as b, type TaskMetadataWithFunctions as c, TaskFileMetadata as d, TaskMetadataWithFilePath as e, TriggerTracer as f, MachineMemory as g, Machine as h, TaskRunExecutionPayload as i, ProdTaskRunExecution as j, ProdTaskRunExecutionPayload as k, RateLimitOptions as l, TaskMetadata as m, PostStartCauses as n, PreStopCauses as o, Config as p, type ResolvedConfig as q, type RunFnParams as r, type MiddlewareFnParams as s, type InitFnParams as t, type StartFnParams as u, type Context as v, type SuccessFnParams as w, type FailureFnParams as x, type HandleErrorModificationOptions as y, type HandleErrorResult as z };