@trigger.dev/core 3.0.0-beta.34 → 3.0.0-beta.35
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/catalog-BUwiuDbt.d.mts +202 -0
- package/dist/catalog-eKgqBHUA.d.ts +202 -0
- package/dist/{manager-WNMVbgHf.d.mts → manager-uPyMRN8k.d.mts} +24 -23
- package/dist/{manager-WNMVbgHf.d.ts → manager-uPyMRN8k.d.ts} +24 -23
- package/dist/{messages-vq7Bk4Ap.d.mts → messages-l9PdIyKF.d.mts} +4975 -1072
- package/dist/{messages-vq7Bk4Ap.d.ts → messages-l9PdIyKF.d.ts} +4975 -1072
- package/dist/{catalog-tX1P4jZQ.d.ts → schemas-b8tRw8dX.d.mts} +21 -200
- package/dist/{catalog-Y8FyPWvh.d.mts → schemas-b8tRw8dX.d.ts} +21 -200
- package/dist/v3/dev/index.d.mts +2 -2
- package/dist/v3/dev/index.d.ts +2 -2
- package/dist/v3/dev/index.js +4 -4
- package/dist/v3/dev/index.js.map +1 -1
- package/dist/v3/dev/index.mjs +4 -4
- package/dist/v3/dev/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +14 -39
- package/dist/v3/index.d.ts +14 -39
- package/dist/v3/index.js +231 -39
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +232 -41
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.js +1 -1
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +1 -1
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +3 -3
- package/dist/v3/prod/index.d.ts +3 -3
- package/dist/v3/prod/index.js +90 -15
- package/dist/v3/prod/index.js.map +1 -1
- package/dist/v3/prod/index.mjs +90 -15
- package/dist/v3/prod/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +6 -5
- package/dist/v3/workers/index.d.ts +6 -5
- package/dist/v3/workers/index.js +14 -3
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +15 -4
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodNamespace.js +16 -6
- package/dist/v3/zodNamespace.js.map +1 -1
- package/dist/v3/zodNamespace.mjs +17 -7
- package/dist/v3/zodNamespace.mjs.map +1 -1
- package/dist/v3/zodSocket.js +16 -6
- package/dist/v3/zodSocket.js.map +1 -1
- package/dist/v3/zodSocket.mjs +17 -7
- package/dist/v3/zodSocket.mjs.map +1 -1
- package/dist/v3/zodfetch.d.mts +78 -0
- package/dist/v3/zodfetch.d.ts +78 -0
- package/dist/v3/zodfetch.js +446 -0
- package/dist/v3/zodfetch.js.map +1 -0
- package/dist/v3/zodfetch.mjs +433 -0
- package/dist/v3/zodfetch.mjs.map +1 -0
- package/package.json +9 -1
|
@@ -1,8 +1,4 @@
|
|
|
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
1
|
import { z } from 'zod';
|
|
5
|
-
import { b as TaskRunContext } from './manager-WNMVbgHf.js';
|
|
6
2
|
|
|
7
3
|
type RequireKeys<T extends object, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K> extends infer O ? {
|
|
8
4
|
[P in keyof O]: O[P];
|
|
@@ -11,185 +7,6 @@ type Prettify<T> = {
|
|
|
11
7
|
[K in keyof T]: T[K];
|
|
12
8
|
} & {};
|
|
13
9
|
|
|
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" | "error" | "warn" | "info" | "debug" | "log";
|
|
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 "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
|
|
92
|
-
*
|
|
93
|
-
* We automatically set the logLevel to "debug" during test runs
|
|
94
|
-
*
|
|
95
|
-
* @default "info"
|
|
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
|
-
* postInstall will run during the deploy build step, after all the dependencies have been installed.
|
|
120
|
-
*
|
|
121
|
-
* @example "prisma generate"
|
|
122
|
-
*/
|
|
123
|
-
postInstall?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
type InitOutput = Record<string, any> | void | undefined;
|
|
127
|
-
type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
128
|
-
/** Metadata about the task, run, attempt, queue, environment, organization, project and batch. */
|
|
129
|
-
ctx: Context;
|
|
130
|
-
/** If you use the `init` function, this will be whatever you returned. */
|
|
131
|
-
init?: TInitOutput;
|
|
132
|
-
}>;
|
|
133
|
-
type MiddlewareFnParams = Prettify<{
|
|
134
|
-
ctx: Context;
|
|
135
|
-
next: () => Promise<void>;
|
|
136
|
-
}>;
|
|
137
|
-
type InitFnParams = Prettify<{
|
|
138
|
-
ctx: Context;
|
|
139
|
-
}>;
|
|
140
|
-
type StartFnParams = Prettify<{
|
|
141
|
-
ctx: Context;
|
|
142
|
-
}>;
|
|
143
|
-
type Context = TaskRunContext;
|
|
144
|
-
type SuccessFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
145
|
-
type FailureFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
146
|
-
type HandleErrorFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput> & Prettify<{
|
|
147
|
-
retry?: RetryOptions;
|
|
148
|
-
retryAt?: Date;
|
|
149
|
-
retryDelayInMs?: number;
|
|
150
|
-
}>;
|
|
151
|
-
type HandleErrorModificationOptions = {
|
|
152
|
-
skipRetrying?: boolean | undefined;
|
|
153
|
-
retryAt?: Date | undefined;
|
|
154
|
-
retryDelayInMs?: number | undefined;
|
|
155
|
-
retry?: RetryOptions | undefined;
|
|
156
|
-
error?: unknown;
|
|
157
|
-
};
|
|
158
|
-
type HandleErrorResult = undefined | void | HandleErrorModificationOptions | Promise<undefined | void | HandleErrorModificationOptions>;
|
|
159
|
-
type HandleErrorArgs = {
|
|
160
|
-
ctx: Context;
|
|
161
|
-
retry?: RetryOptions;
|
|
162
|
-
retryAt?: Date;
|
|
163
|
-
retryDelayInMs?: number;
|
|
164
|
-
};
|
|
165
|
-
type HandleErrorFunction = (payload: any, error: unknown, params: HandleErrorArgs) => HandleErrorResult;
|
|
166
|
-
type ResolveEnvironmentVariablesOptions = {
|
|
167
|
-
variables: Record<string, string> | Array<{
|
|
168
|
-
name: string;
|
|
169
|
-
value: string;
|
|
170
|
-
}>;
|
|
171
|
-
override?: boolean;
|
|
172
|
-
};
|
|
173
|
-
type ResolveEnvironmentVariablesResult = ResolveEnvironmentVariablesOptions | Promise<void | undefined | ResolveEnvironmentVariablesOptions> | void | undefined;
|
|
174
|
-
type ResolveEnvironmentVariablesParams = {
|
|
175
|
-
projectRef: string;
|
|
176
|
-
environment: "dev" | "staging" | "prod";
|
|
177
|
-
env: Record<string, string>;
|
|
178
|
-
};
|
|
179
|
-
type ResolveEnvironmentVariablesFunction = (params: ResolveEnvironmentVariablesParams) => ResolveEnvironmentVariablesResult;
|
|
180
|
-
type TaskMetadataWithFunctions = TaskMetadata & {
|
|
181
|
-
fns: {
|
|
182
|
-
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
183
|
-
init?: (payload: any, params: InitFnParams) => Promise<InitOutput>;
|
|
184
|
-
cleanup?: (payload: any, params: RunFnParams<any>) => Promise<void>;
|
|
185
|
-
middleware?: (payload: any, params: MiddlewareFnParams) => Promise<void>;
|
|
186
|
-
handleError?: (payload: any, error: unknown, params: HandleErrorFnParams<any>) => HandleErrorResult;
|
|
187
|
-
onSuccess?: (payload: any, output: any, params: SuccessFnParams<any>) => Promise<void>;
|
|
188
|
-
onFailure?: (payload: any, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
189
|
-
onStart?: (payload: any, params: StartFnParams) => Promise<void>;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
10
|
declare const EnvironmentType: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
|
|
194
11
|
type EnvironmentType = z.infer<typeof EnvironmentType>;
|
|
195
12
|
declare const MachineCpu: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
|
|
@@ -2490,21 +2307,25 @@ type Config = z.infer<typeof Config>;
|
|
|
2490
2307
|
type ResolvedConfig = RequireKeys<Config, "triggerDirectories" | "triggerUrl" | "projectDir" | "tsconfigPath">;
|
|
2491
2308
|
declare const WaitReason: z.ZodEnum<["WAIT_FOR_DURATION", "WAIT_FOR_TASK", "WAIT_FOR_BATCH"]>;
|
|
2492
2309
|
type WaitReason = z.infer<typeof WaitReason>;
|
|
2310
|
+
declare const TaskRunExecutionLazyAttemptPayload: z.ZodObject<{
|
|
2311
|
+
runId: z.ZodString;
|
|
2312
|
+
messageId: z.ZodString;
|
|
2313
|
+
isTest: z.ZodBoolean;
|
|
2314
|
+
traceContext: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2315
|
+
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2316
|
+
}, "strip", z.ZodTypeAny, {
|
|
2317
|
+
isTest: boolean;
|
|
2318
|
+
traceContext: Record<string, unknown>;
|
|
2319
|
+
runId: string;
|
|
2320
|
+
messageId: string;
|
|
2321
|
+
environment?: Record<string, string> | undefined;
|
|
2322
|
+
}, {
|
|
2323
|
+
isTest: boolean;
|
|
2324
|
+
traceContext: Record<string, unknown>;
|
|
2325
|
+
runId: string;
|
|
2326
|
+
messageId: string;
|
|
2327
|
+
environment?: Record<string, string> | undefined;
|
|
2328
|
+
}>;
|
|
2329
|
+
type TaskRunExecutionLazyAttemptPayload = z.infer<typeof TaskRunExecutionLazyAttemptPayload>;
|
|
2493
2330
|
|
|
2494
|
-
type
|
|
2495
|
-
interface Clock {
|
|
2496
|
-
preciseNow(): ClockTime;
|
|
2497
|
-
reset(): void;
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
interface TaskCatalog {
|
|
2501
|
-
registerTaskMetadata(task: TaskMetadataWithFunctions): void;
|
|
2502
|
-
updateTaskMetadata(id: string, task: Partial<TaskMetadataWithFunctions>): void;
|
|
2503
|
-
registerTaskFileMetadata(id: string, metadata: TaskFileMetadata): void;
|
|
2504
|
-
getAllTaskMetadata(): Array<TaskMetadataWithFilePath>;
|
|
2505
|
-
getTaskMetadata(id: string): TaskMetadataWithFilePath | undefined;
|
|
2506
|
-
getTask(id: string): TaskMetadataWithFunctions | undefined;
|
|
2507
|
-
taskExists(id: string): boolean;
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
export { type HandleErrorArgs as A, type HandleErrorFunction as B, type Clock as C, type ResolveEnvironmentVariablesResult as D, EnvironmentType as E, FixedWindowRateLimit as F, type ResolveEnvironmentVariablesParams as G, type HandleErrorFnParams as H, type InitOutput as I, type ResolveEnvironmentVariablesFunction as J, type RequireKeys as K, type LogLevel as L, MachineCpu as M, type ProjectConfig as N, OtelTaskLogger as O, type Prettify as P, QueueOptions as Q, RetryOptions as R, SlidingWindowRateLimit as S, type TaskLogger as T, logLevels as U, 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 };
|
|
2331
|
+
export { Config as C, EnvironmentType as E, FixedWindowRateLimit as F, MachineCpu as M, type Prettify as P, QueueOptions as Q, RetryOptions as R, SlidingWindowRateLimit as S, TaskFileMetadata as T, WaitReason as W, TaskMetadataWithFilePath as a, MachineMemory as b, Machine as c, TaskRunExecutionPayload as d, ProdTaskRunExecution as e, ProdTaskRunExecutionPayload as f, RateLimitOptions as g, TaskMetadata as h, PostStartCauses as i, PreStopCauses as j, type ResolvedConfig as k, TaskRunExecutionLazyAttemptPayload as l, type RequireKeys as m };
|
|
@@ -1,8 +1,4 @@
|
|
|
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
1
|
import { z } from 'zod';
|
|
5
|
-
import { b as TaskRunContext } from './manager-WNMVbgHf.mjs';
|
|
6
2
|
|
|
7
3
|
type RequireKeys<T extends object, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K> extends infer O ? {
|
|
8
4
|
[P in keyof O]: O[P];
|
|
@@ -11,185 +7,6 @@ type Prettify<T> = {
|
|
|
11
7
|
[K in keyof T]: T[K];
|
|
12
8
|
} & {};
|
|
13
9
|
|
|
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" | "error" | "warn" | "info" | "debug" | "log";
|
|
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 "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
|
|
92
|
-
*
|
|
93
|
-
* We automatically set the logLevel to "debug" during test runs
|
|
94
|
-
*
|
|
95
|
-
* @default "info"
|
|
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
|
-
* postInstall will run during the deploy build step, after all the dependencies have been installed.
|
|
120
|
-
*
|
|
121
|
-
* @example "prisma generate"
|
|
122
|
-
*/
|
|
123
|
-
postInstall?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
type InitOutput = Record<string, any> | void | undefined;
|
|
127
|
-
type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
128
|
-
/** Metadata about the task, run, attempt, queue, environment, organization, project and batch. */
|
|
129
|
-
ctx: Context;
|
|
130
|
-
/** If you use the `init` function, this will be whatever you returned. */
|
|
131
|
-
init?: TInitOutput;
|
|
132
|
-
}>;
|
|
133
|
-
type MiddlewareFnParams = Prettify<{
|
|
134
|
-
ctx: Context;
|
|
135
|
-
next: () => Promise<void>;
|
|
136
|
-
}>;
|
|
137
|
-
type InitFnParams = Prettify<{
|
|
138
|
-
ctx: Context;
|
|
139
|
-
}>;
|
|
140
|
-
type StartFnParams = Prettify<{
|
|
141
|
-
ctx: Context;
|
|
142
|
-
}>;
|
|
143
|
-
type Context = TaskRunContext;
|
|
144
|
-
type SuccessFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
145
|
-
type FailureFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
146
|
-
type HandleErrorFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput> & Prettify<{
|
|
147
|
-
retry?: RetryOptions;
|
|
148
|
-
retryAt?: Date;
|
|
149
|
-
retryDelayInMs?: number;
|
|
150
|
-
}>;
|
|
151
|
-
type HandleErrorModificationOptions = {
|
|
152
|
-
skipRetrying?: boolean | undefined;
|
|
153
|
-
retryAt?: Date | undefined;
|
|
154
|
-
retryDelayInMs?: number | undefined;
|
|
155
|
-
retry?: RetryOptions | undefined;
|
|
156
|
-
error?: unknown;
|
|
157
|
-
};
|
|
158
|
-
type HandleErrorResult = undefined | void | HandleErrorModificationOptions | Promise<undefined | void | HandleErrorModificationOptions>;
|
|
159
|
-
type HandleErrorArgs = {
|
|
160
|
-
ctx: Context;
|
|
161
|
-
retry?: RetryOptions;
|
|
162
|
-
retryAt?: Date;
|
|
163
|
-
retryDelayInMs?: number;
|
|
164
|
-
};
|
|
165
|
-
type HandleErrorFunction = (payload: any, error: unknown, params: HandleErrorArgs) => HandleErrorResult;
|
|
166
|
-
type ResolveEnvironmentVariablesOptions = {
|
|
167
|
-
variables: Record<string, string> | Array<{
|
|
168
|
-
name: string;
|
|
169
|
-
value: string;
|
|
170
|
-
}>;
|
|
171
|
-
override?: boolean;
|
|
172
|
-
};
|
|
173
|
-
type ResolveEnvironmentVariablesResult = ResolveEnvironmentVariablesOptions | Promise<void | undefined | ResolveEnvironmentVariablesOptions> | void | undefined;
|
|
174
|
-
type ResolveEnvironmentVariablesParams = {
|
|
175
|
-
projectRef: string;
|
|
176
|
-
environment: "dev" | "staging" | "prod";
|
|
177
|
-
env: Record<string, string>;
|
|
178
|
-
};
|
|
179
|
-
type ResolveEnvironmentVariablesFunction = (params: ResolveEnvironmentVariablesParams) => ResolveEnvironmentVariablesResult;
|
|
180
|
-
type TaskMetadataWithFunctions = TaskMetadata & {
|
|
181
|
-
fns: {
|
|
182
|
-
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
183
|
-
init?: (payload: any, params: InitFnParams) => Promise<InitOutput>;
|
|
184
|
-
cleanup?: (payload: any, params: RunFnParams<any>) => Promise<void>;
|
|
185
|
-
middleware?: (payload: any, params: MiddlewareFnParams) => Promise<void>;
|
|
186
|
-
handleError?: (payload: any, error: unknown, params: HandleErrorFnParams<any>) => HandleErrorResult;
|
|
187
|
-
onSuccess?: (payload: any, output: any, params: SuccessFnParams<any>) => Promise<void>;
|
|
188
|
-
onFailure?: (payload: any, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
189
|
-
onStart?: (payload: any, params: StartFnParams) => Promise<void>;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
10
|
declare const EnvironmentType: z.ZodEnum<["PRODUCTION", "STAGING", "DEVELOPMENT", "PREVIEW"]>;
|
|
194
11
|
type EnvironmentType = z.infer<typeof EnvironmentType>;
|
|
195
12
|
declare const MachineCpu: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<0.25>, z.ZodLiteral<0.5>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
|
|
@@ -2490,21 +2307,25 @@ type Config = z.infer<typeof Config>;
|
|
|
2490
2307
|
type ResolvedConfig = RequireKeys<Config, "triggerDirectories" | "triggerUrl" | "projectDir" | "tsconfigPath">;
|
|
2491
2308
|
declare const WaitReason: z.ZodEnum<["WAIT_FOR_DURATION", "WAIT_FOR_TASK", "WAIT_FOR_BATCH"]>;
|
|
2492
2309
|
type WaitReason = z.infer<typeof WaitReason>;
|
|
2310
|
+
declare const TaskRunExecutionLazyAttemptPayload: z.ZodObject<{
|
|
2311
|
+
runId: z.ZodString;
|
|
2312
|
+
messageId: z.ZodString;
|
|
2313
|
+
isTest: z.ZodBoolean;
|
|
2314
|
+
traceContext: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2315
|
+
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2316
|
+
}, "strip", z.ZodTypeAny, {
|
|
2317
|
+
isTest: boolean;
|
|
2318
|
+
traceContext: Record<string, unknown>;
|
|
2319
|
+
runId: string;
|
|
2320
|
+
messageId: string;
|
|
2321
|
+
environment?: Record<string, string> | undefined;
|
|
2322
|
+
}, {
|
|
2323
|
+
isTest: boolean;
|
|
2324
|
+
traceContext: Record<string, unknown>;
|
|
2325
|
+
runId: string;
|
|
2326
|
+
messageId: string;
|
|
2327
|
+
environment?: Record<string, string> | undefined;
|
|
2328
|
+
}>;
|
|
2329
|
+
type TaskRunExecutionLazyAttemptPayload = z.infer<typeof TaskRunExecutionLazyAttemptPayload>;
|
|
2493
2330
|
|
|
2494
|
-
type
|
|
2495
|
-
interface Clock {
|
|
2496
|
-
preciseNow(): ClockTime;
|
|
2497
|
-
reset(): void;
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
interface TaskCatalog {
|
|
2501
|
-
registerTaskMetadata(task: TaskMetadataWithFunctions): void;
|
|
2502
|
-
updateTaskMetadata(id: string, task: Partial<TaskMetadataWithFunctions>): void;
|
|
2503
|
-
registerTaskFileMetadata(id: string, metadata: TaskFileMetadata): void;
|
|
2504
|
-
getAllTaskMetadata(): Array<TaskMetadataWithFilePath>;
|
|
2505
|
-
getTaskMetadata(id: string): TaskMetadataWithFilePath | undefined;
|
|
2506
|
-
getTask(id: string): TaskMetadataWithFunctions | undefined;
|
|
2507
|
-
taskExists(id: string): boolean;
|
|
2508
|
-
}
|
|
2509
|
-
|
|
2510
|
-
export { type HandleErrorArgs as A, type HandleErrorFunction as B, type Clock as C, type ResolveEnvironmentVariablesResult as D, EnvironmentType as E, FixedWindowRateLimit as F, type ResolveEnvironmentVariablesParams as G, type HandleErrorFnParams as H, type InitOutput as I, type ResolveEnvironmentVariablesFunction as J, type RequireKeys as K, type LogLevel as L, MachineCpu as M, type ProjectConfig as N, OtelTaskLogger as O, type Prettify as P, QueueOptions as Q, RetryOptions as R, SlidingWindowRateLimit as S, type TaskLogger as T, logLevels as U, 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 };
|
|
2331
|
+
export { Config as C, EnvironmentType as E, FixedWindowRateLimit as F, MachineCpu as M, type Prettify as P, QueueOptions as Q, RetryOptions as R, SlidingWindowRateLimit as S, TaskFileMetadata as T, WaitReason as W, TaskMetadataWithFilePath as a, MachineMemory as b, Machine as c, TaskRunExecutionPayload as d, ProdTaskRunExecution as e, ProdTaskRunExecutionPayload as f, RateLimitOptions as g, TaskMetadata as h, PostStartCauses as i, PreStopCauses as j, type ResolvedConfig as k, TaskRunExecutionLazyAttemptPayload as l, type RequireKeys as m };
|
package/dist/v3/dev/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RuntimeManager, T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, b as TaskRunContext
|
|
1
|
+
import { R as RuntimeManager, T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, b as TaskRunContext } from '../../manager-uPyMRN8k.mjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
declare class DevRuntimeManager implements RuntimeManager {
|
|
@@ -22,7 +22,7 @@ declare class DevRuntimeManager implements RuntimeManager {
|
|
|
22
22
|
runs: string[];
|
|
23
23
|
ctx: TaskRunContext;
|
|
24
24
|
}): Promise<BatchTaskRunExecutionResult>;
|
|
25
|
-
resumeTask(completion: TaskRunExecutionResult,
|
|
25
|
+
resumeTask(completion: TaskRunExecutionResult, runId: string): void;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export { DevRuntimeManager };
|
package/dist/v3/dev/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RuntimeManager, T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, b as TaskRunContext
|
|
1
|
+
import { R as RuntimeManager, T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, b as TaskRunContext } from '../../manager-uPyMRN8k.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
declare class DevRuntimeManager implements RuntimeManager {
|
|
@@ -22,7 +22,7 @@ declare class DevRuntimeManager implements RuntimeManager {
|
|
|
22
22
|
runs: string[];
|
|
23
23
|
ctx: TaskRunContext;
|
|
24
24
|
}): Promise<BatchTaskRunExecutionResult>;
|
|
25
|
-
resumeTask(completion: TaskRunExecutionResult,
|
|
25
|
+
resumeTask(completion: TaskRunExecutionResult, runId: string): void;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export { DevRuntimeManager };
|
package/dist/v3/dev/index.js
CHANGED
|
@@ -75,14 +75,14 @@ var _DevRuntimeManager = class _DevRuntimeManager {
|
|
|
75
75
|
items: results
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
resumeTask(completion,
|
|
79
|
-
const wait = this._taskWaits.get(
|
|
78
|
+
resumeTask(completion, runId) {
|
|
79
|
+
const wait = this._taskWaits.get(runId);
|
|
80
80
|
if (!wait) {
|
|
81
|
-
this._pendingCompletionNotifications.set(
|
|
81
|
+
this._pendingCompletionNotifications.set(runId, completion);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
wait.resolve(completion);
|
|
85
|
-
this._taskWaits.delete(
|
|
85
|
+
this._taskWaits.delete(runId);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
__name(_DevRuntimeManager, "DevRuntimeManager");
|
package/dist/v3/dev/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","
|
|
1
|
+
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","wait"],"mappings":";;;;;;;;;AACA,SAASA,aAAaC,kBAAkB;AAExC,eAAsBC,iBACpBC,QAAgB,GAChBC,OACAC,SACY;AACZ,QAAMC,WAAW;AAEjB,QAAMC,eAAeC,KAAKC,MAAMN,QAAQG,QAAAA;AACxC,QAAMI,iBAAiBP,QAAQG;AAE/B,MAAIK,oBAAoB,MAAMV,WAAWS,gBAAgBN,OAAOC,OAAAA;AAEhE,WAASO,IAAI,GAAGA,IAAIL,cAAcK,KAAK;AACrCD,wBAAoB,MAAMV,WAAWK,UAAUF,OAAOC,OAAAA;EACxD;AAEA,SAAOM;AACT;AAjBsBT;;;ACMf,IAAMW,qBAAN,MAAMA,mBAAAA;EAAN;AACLC,sCAAgF,oBAAIC,IAAAA;AAEpFC,uCAGI,oBAAID,IAAAA;AAERE,2DAAuE,oBAAIF,IAAAA;;EAE3EG,UAAgB;EAEhB;EAEA,MAAMC,gBAAgBC,IAA2B;AAC/C,UAAMlB,iBAAiBkB,EAAAA;EACzB;EAEA,MAAMC,UAAUC,MAA2B;AACzC,WAAO,KAAKH,gBAAgBG,KAAKC,QAAO,IAAKC,KAAKC,IAAG,CAAA;EACvD;EAEA,MAAMC,YAAYC,QAA8E;AAC9F,UAAMC,oBAAoB,KAAKX,gCAAgCY,IAAIF,OAAOG,EAAE;AAE5E,QAAIF,mBAAmB;AACrB,WAAKX,gCAAgCc,OAAOJ,OAAOG,EAAE;AAErD,aAAOF;IACT;AAEA,UAAMI,UAAU,IAAIC,QAAgC,CAACC,YAAY;AAC/D,WAAKpB,WAAWqB,IAAIR,OAAOG,IAAI;QAAEI;MAAQ,CAAA;IAC3C,CAAA;AAEA,WAAO,MAAMF;EACf;EAEA,MAAMI,aAAaT,QAIsB;AACvC,QAAI,CAACA,OAAOU,KAAKC,QAAQ;AACvB,aAAOL,QAAQC,QAAQ;QAAEJ,IAAIH,OAAOG;QAAIS,OAAO,CAAA;MAAG,CAAA;IACpD;AAEA,UAAMP,UAAUC,QAAQO,IACtBb,OAAOU,KAAKI,IAAI,CAACC,UAAU;AACzB,aAAO,IAAIT,QAAgC,CAACC,SAASS,WAAW;AAC9D,cAAMf,oBAAoB,KAAKX,gCAAgCY,IAAIa,KAAAA;AAEnE,YAAId,mBAAmB;AACrB,eAAKX,gCAAgCc,OAAOW,KAAAA;AAE5CR,kBAAQN,iBAAAA;AAER;QACF;AAEA,aAAKd,WAAWqB,IAAIO,OAAO;UAAER;QAAQ,CAAA;MACvC,CAAA;IACF,CAAA,CAAA;AAGF,UAAMU,UAAU,MAAMZ;AAEtB,WAAO;MACLF,IAAIH,OAAOG;MACXS,OAAOK;IACT;EACF;EAEAC,WAAWC,YAAoCJ,OAAqB;AAClE,UAAMK,OAAO,KAAKjC,WAAWe,IAAIa,KAAAA;AAEjC,QAAI,CAACK,MAAM;AAET,WAAK9B,gCAAgCkB,IAAIO,OAAOI,UAAAA;AAEhD;IACF;AAEAC,SAAKb,QAAQY,UAAAA;AAEb,SAAKhC,WAAWiB,OAAOW,KAAAA;EACzB;AACF;AAvFa7B;AAAN,IAAMA,oBAAN","sourcesContent":["import { TimerOptions } from \"node:timers\";\nimport { setInterval, setTimeout } from \"node:timers/promises\";\n\nexport async function unboundedTimeout<T = void>(\n delay: number = 0,\n value?: T,\n options?: TimerOptions\n): Promise<T> {\n const maxDelay = 2147483647; // Highest value that will fit in a 32-bit signed integer\n\n const fullTimeouts = Math.floor(delay / maxDelay);\n const remainingDelay = delay % maxDelay;\n\n let lastTimeoutResult = await setTimeout(remainingDelay, value, options);\n\n for (let i = 0; i < fullTimeouts; i++) {\n lastTimeoutResult = await setTimeout(maxDelay, value, options);\n }\n\n return lastTimeoutResult;\n}\n\nexport async function checkpointSafeTimeout(delay: number = 0): Promise<void> {\n const scanIntervalMs = 1000;\n\n // Every scanIntervalMs, check if delay has elapsed\n for await (const start of setInterval(scanIntervalMs, Date.now())) {\n if (Date.now() - start > delay) {\n break;\n }\n }\n}\n","import {\n BatchTaskRunExecutionResult,\n TaskRunContext,\n TaskRunExecution,\n TaskRunExecutionResult,\n} from \"../schemas\";\nimport { RuntimeManager } from \"./manager\";\nimport { unboundedTimeout } from \"../utils/timers\";\n\nexport class DevRuntimeManager implements RuntimeManager {\n _taskWaits: Map<string, { resolve: (value: TaskRunExecutionResult) => void }> = new Map();\n\n _batchWaits: Map<\n string,\n { resolve: (value: BatchTaskRunExecutionResult) => void; reject: (err?: any) => void }\n > = new Map();\n\n _pendingCompletionNotifications: Map<string, TaskRunExecutionResult> = new Map();\n\n disable(): void {\n // do nothing\n }\n\n async waitForDuration(ms: number): Promise<void> {\n await unboundedTimeout(ms);\n }\n\n async waitUntil(date: Date): Promise<void> {\n return this.waitForDuration(date.getTime() - Date.now());\n }\n\n async waitForTask(params: { id: string; ctx: TaskRunContext }): Promise<TaskRunExecutionResult> {\n const pendingCompletion = this._pendingCompletionNotifications.get(params.id);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(params.id);\n\n return pendingCompletion;\n }\n\n const promise = new Promise<TaskRunExecutionResult>((resolve) => {\n this._taskWaits.set(params.id, { resolve });\n });\n\n return await promise;\n }\n\n async waitForBatch(params: {\n id: string;\n runs: string[];\n ctx: TaskRunContext;\n }): Promise<BatchTaskRunExecutionResult> {\n if (!params.runs.length) {\n return Promise.resolve({ id: params.id, items: [] });\n }\n\n const promise = Promise.all(\n params.runs.map((runId) => {\n return new Promise<TaskRunExecutionResult>((resolve, reject) => {\n const pendingCompletion = this._pendingCompletionNotifications.get(runId);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(runId);\n\n resolve(pendingCompletion);\n\n return;\n }\n\n this._taskWaits.set(runId, { resolve });\n });\n })\n );\n\n const results = await promise;\n\n return {\n id: params.id,\n items: results,\n };\n }\n\n resumeTask(completion: TaskRunExecutionResult, runId: string): void {\n const wait = this._taskWaits.get(runId);\n\n if (!wait) {\n // We need to store the completion in case the task is awaited later\n this._pendingCompletionNotifications.set(runId, completion);\n\n return;\n }\n\n wait.resolve(completion);\n\n this._taskWaits.delete(runId);\n }\n}\n"]}
|
package/dist/v3/dev/index.mjs
CHANGED
|
@@ -73,14 +73,14 @@ var _DevRuntimeManager = class _DevRuntimeManager {
|
|
|
73
73
|
items: results
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
resumeTask(completion,
|
|
77
|
-
const wait = this._taskWaits.get(
|
|
76
|
+
resumeTask(completion, runId) {
|
|
77
|
+
const wait = this._taskWaits.get(runId);
|
|
78
78
|
if (!wait) {
|
|
79
|
-
this._pendingCompletionNotifications.set(
|
|
79
|
+
this._pendingCompletionNotifications.set(runId, completion);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
wait.resolve(completion);
|
|
83
|
-
this._taskWaits.delete(
|
|
83
|
+
this._taskWaits.delete(runId);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
__name(_DevRuntimeManager, "DevRuntimeManager");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","
|
|
1
|
+
{"version":3,"sources":["../../../src/v3/utils/timers.ts","../../../src/v3/runtime/devRuntimeManager.ts"],"names":["setInterval","setTimeout","unboundedTimeout","delay","value","options","maxDelay","fullTimeouts","Math","floor","remainingDelay","lastTimeoutResult","i","DevRuntimeManager","_taskWaits","Map","_batchWaits","_pendingCompletionNotifications","disable","waitForDuration","ms","waitUntil","date","getTime","Date","now","waitForTask","params","pendingCompletion","get","id","delete","promise","Promise","resolve","set","waitForBatch","runs","length","items","all","map","runId","reject","results","resumeTask","completion","wait"],"mappings":";;;;;;;;;AACA,SAASA,aAAaC,kBAAkB;AAExC,eAAsBC,iBACpBC,QAAgB,GAChBC,OACAC,SACY;AACZ,QAAMC,WAAW;AAEjB,QAAMC,eAAeC,KAAKC,MAAMN,QAAQG,QAAAA;AACxC,QAAMI,iBAAiBP,QAAQG;AAE/B,MAAIK,oBAAoB,MAAMV,WAAWS,gBAAgBN,OAAOC,OAAAA;AAEhE,WAASO,IAAI,GAAGA,IAAIL,cAAcK,KAAK;AACrCD,wBAAoB,MAAMV,WAAWK,UAAUF,OAAOC,OAAAA;EACxD;AAEA,SAAOM;AACT;AAjBsBT;;;ACMf,IAAMW,qBAAN,MAAMA,mBAAAA;EAAN;AACLC,sCAAgF,oBAAIC,IAAAA;AAEpFC,uCAGI,oBAAID,IAAAA;AAERE,2DAAuE,oBAAIF,IAAAA;;EAE3EG,UAAgB;EAEhB;EAEA,MAAMC,gBAAgBC,IAA2B;AAC/C,UAAMlB,iBAAiBkB,EAAAA;EACzB;EAEA,MAAMC,UAAUC,MAA2B;AACzC,WAAO,KAAKH,gBAAgBG,KAAKC,QAAO,IAAKC,KAAKC,IAAG,CAAA;EACvD;EAEA,MAAMC,YAAYC,QAA8E;AAC9F,UAAMC,oBAAoB,KAAKX,gCAAgCY,IAAIF,OAAOG,EAAE;AAE5E,QAAIF,mBAAmB;AACrB,WAAKX,gCAAgCc,OAAOJ,OAAOG,EAAE;AAErD,aAAOF;IACT;AAEA,UAAMI,UAAU,IAAIC,QAAgC,CAACC,YAAY;AAC/D,WAAKpB,WAAWqB,IAAIR,OAAOG,IAAI;QAAEI;MAAQ,CAAA;IAC3C,CAAA;AAEA,WAAO,MAAMF;EACf;EAEA,MAAMI,aAAaT,QAIsB;AACvC,QAAI,CAACA,OAAOU,KAAKC,QAAQ;AACvB,aAAOL,QAAQC,QAAQ;QAAEJ,IAAIH,OAAOG;QAAIS,OAAO,CAAA;MAAG,CAAA;IACpD;AAEA,UAAMP,UAAUC,QAAQO,IACtBb,OAAOU,KAAKI,IAAI,CAACC,UAAU;AACzB,aAAO,IAAIT,QAAgC,CAACC,SAASS,WAAW;AAC9D,cAAMf,oBAAoB,KAAKX,gCAAgCY,IAAIa,KAAAA;AAEnE,YAAId,mBAAmB;AACrB,eAAKX,gCAAgCc,OAAOW,KAAAA;AAE5CR,kBAAQN,iBAAAA;AAER;QACF;AAEA,aAAKd,WAAWqB,IAAIO,OAAO;UAAER;QAAQ,CAAA;MACvC,CAAA;IACF,CAAA,CAAA;AAGF,UAAMU,UAAU,MAAMZ;AAEtB,WAAO;MACLF,IAAIH,OAAOG;MACXS,OAAOK;IACT;EACF;EAEAC,WAAWC,YAAoCJ,OAAqB;AAClE,UAAMK,OAAO,KAAKjC,WAAWe,IAAIa,KAAAA;AAEjC,QAAI,CAACK,MAAM;AAET,WAAK9B,gCAAgCkB,IAAIO,OAAOI,UAAAA;AAEhD;IACF;AAEAC,SAAKb,QAAQY,UAAAA;AAEb,SAAKhC,WAAWiB,OAAOW,KAAAA;EACzB;AACF;AAvFa7B;AAAN,IAAMA,oBAAN","sourcesContent":["import { TimerOptions } from \"node:timers\";\nimport { setInterval, setTimeout } from \"node:timers/promises\";\n\nexport async function unboundedTimeout<T = void>(\n delay: number = 0,\n value?: T,\n options?: TimerOptions\n): Promise<T> {\n const maxDelay = 2147483647; // Highest value that will fit in a 32-bit signed integer\n\n const fullTimeouts = Math.floor(delay / maxDelay);\n const remainingDelay = delay % maxDelay;\n\n let lastTimeoutResult = await setTimeout(remainingDelay, value, options);\n\n for (let i = 0; i < fullTimeouts; i++) {\n lastTimeoutResult = await setTimeout(maxDelay, value, options);\n }\n\n return lastTimeoutResult;\n}\n\nexport async function checkpointSafeTimeout(delay: number = 0): Promise<void> {\n const scanIntervalMs = 1000;\n\n // Every scanIntervalMs, check if delay has elapsed\n for await (const start of setInterval(scanIntervalMs, Date.now())) {\n if (Date.now() - start > delay) {\n break;\n }\n }\n}\n","import {\n BatchTaskRunExecutionResult,\n TaskRunContext,\n TaskRunExecution,\n TaskRunExecutionResult,\n} from \"../schemas\";\nimport { RuntimeManager } from \"./manager\";\nimport { unboundedTimeout } from \"../utils/timers\";\n\nexport class DevRuntimeManager implements RuntimeManager {\n _taskWaits: Map<string, { resolve: (value: TaskRunExecutionResult) => void }> = new Map();\n\n _batchWaits: Map<\n string,\n { resolve: (value: BatchTaskRunExecutionResult) => void; reject: (err?: any) => void }\n > = new Map();\n\n _pendingCompletionNotifications: Map<string, TaskRunExecutionResult> = new Map();\n\n disable(): void {\n // do nothing\n }\n\n async waitForDuration(ms: number): Promise<void> {\n await unboundedTimeout(ms);\n }\n\n async waitUntil(date: Date): Promise<void> {\n return this.waitForDuration(date.getTime() - Date.now());\n }\n\n async waitForTask(params: { id: string; ctx: TaskRunContext }): Promise<TaskRunExecutionResult> {\n const pendingCompletion = this._pendingCompletionNotifications.get(params.id);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(params.id);\n\n return pendingCompletion;\n }\n\n const promise = new Promise<TaskRunExecutionResult>((resolve) => {\n this._taskWaits.set(params.id, { resolve });\n });\n\n return await promise;\n }\n\n async waitForBatch(params: {\n id: string;\n runs: string[];\n ctx: TaskRunContext;\n }): Promise<BatchTaskRunExecutionResult> {\n if (!params.runs.length) {\n return Promise.resolve({ id: params.id, items: [] });\n }\n\n const promise = Promise.all(\n params.runs.map((runId) => {\n return new Promise<TaskRunExecutionResult>((resolve, reject) => {\n const pendingCompletion = this._pendingCompletionNotifications.get(runId);\n\n if (pendingCompletion) {\n this._pendingCompletionNotifications.delete(runId);\n\n resolve(pendingCompletion);\n\n return;\n }\n\n this._taskWaits.set(runId, { resolve });\n });\n })\n );\n\n const results = await promise;\n\n return {\n id: params.id,\n items: results,\n };\n }\n\n resumeTask(completion: TaskRunExecutionResult, runId: string): void {\n const wait = this._taskWaits.get(runId);\n\n if (!wait) {\n // We need to store the completion in case the task is awaited later\n this._pendingCompletionNotifications.set(runId, completion);\n\n return;\n }\n\n wait.resolve(completion);\n\n this._taskWaits.delete(runId);\n }\n}\n"]}
|