@trigger.dev/core 3.0.0-beta.5 → 3.0.0-beta.51
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/api-Pl9fxB8v.d.mts +13879 -0
- package/dist/api-sNoooMbT.d.ts +13879 -0
- package/dist/catalog-H7yFiZ60.d.mts +202 -0
- package/dist/catalog-h79CG5Wy.d.ts +202 -0
- package/dist/common-CLW82lkt.d.mts +1423 -0
- package/dist/common-CLW82lkt.d.ts +1423 -0
- package/dist/{eventFilterMatches-2kHImluE.d.mts → eventFilter-66NaBAMi.d.mts} +1 -3
- package/dist/{eventFilterMatches-2kHImluE.d.ts → eventFilter-66NaBAMi.d.ts} +1 -3
- package/dist/eventFilterMatches.d.mts +6 -0
- package/dist/eventFilterMatches.d.ts +6 -0
- package/dist/eventFilterMatches.js +165 -0
- package/dist/eventFilterMatches.js.map +1 -0
- package/dist/eventFilterMatches.mjs +163 -0
- package/dist/eventFilterMatches.mjs.map +1 -0
- package/dist/index.d.mts +14 -16657
- package/dist/index.d.ts +14 -16657
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/dist/json-DBPEJQRe.d.mts +16 -0
- package/dist/json-DBPEJQRe.d.ts +16 -0
- package/dist/manager-KvCabW1a.d.mts +18 -0
- package/dist/manager-OBA35PzR.d.ts +18 -0
- package/dist/messages-JvHJ83wv.d.mts +19428 -0
- package/dist/messages-JvHJ83wv.d.ts +19428 -0
- package/dist/replacements.d.mts +22 -0
- package/dist/replacements.d.ts +22 -0
- package/dist/replacements.js +33 -0
- package/dist/replacements.js.map +1 -0
- package/dist/replacements.mjs +28 -0
- package/dist/replacements.mjs.map +1 -0
- package/dist/requestFilter-HNZQEpQb.d.ts +180 -0
- package/dist/requestFilter-b5W2_1oP.d.mts +180 -0
- package/dist/requestFilterMatches.d.mts +13 -0
- package/dist/requestFilterMatches.d.ts +13 -0
- package/dist/requestFilterMatches.js +238 -0
- package/dist/requestFilterMatches.js.map +1 -0
- package/dist/requestFilterMatches.mjs +235 -0
- package/dist/requestFilterMatches.mjs.map +1 -0
- package/dist/retry.d.mts +10 -0
- package/dist/retry.d.ts +10 -0
- package/dist/retry.js +100 -0
- package/dist/retry.js.map +1 -0
- package/dist/retry.mjs +97 -0
- package/dist/retry.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2611 -0
- package/dist/schemas/index.d.ts +2611 -0
- package/dist/schemas/index.js +1630 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/index.mjs +1463 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas-C9ssfehv.d.mts +2568 -0
- package/dist/schemas-C9ssfehv.d.ts +2568 -0
- package/dist/taskLogger-CzADe4je.d.ts +33 -0
- package/dist/taskLogger-r_AFTX45.d.mts +33 -0
- package/dist/tracer-N0p2Fuuv.d.mts +23 -0
- package/dist/tracer-N0p2Fuuv.d.ts +23 -0
- package/dist/types.d.mts +11 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +3 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +7 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +33 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +30 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/v3/dev/index.d.mts +29 -0
- package/dist/v3/dev/index.d.ts +29 -0
- package/dist/v3/dev/index.js +93 -0
- package/dist/v3/dev/index.js.map +1 -0
- package/dist/v3/dev/index.mjs +91 -0
- package/dist/v3/dev/index.mjs.map +1 -0
- package/dist/v3/errors.d.mts +39 -0
- package/dist/v3/errors.d.ts +39 -0
- package/dist/v3/errors.js +204 -0
- package/dist/v3/errors.js.map +1 -0
- package/dist/v3/errors.mjs +195 -0
- package/dist/v3/errors.mjs.map +1 -0
- package/dist/v3/index.d.mts +445 -20508
- package/dist/v3/index.d.ts +445 -20508
- package/dist/v3/index.js +2843 -2884
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +2785 -2856
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/logger-api.d.mts +24 -0
- package/dist/v3/logger-api.d.ts +24 -0
- package/dist/v3/logger-api.js +118 -0
- package/dist/v3/logger-api.js.map +1 -0
- package/dist/v3/logger-api.mjs +116 -0
- package/dist/v3/logger-api.mjs.map +1 -0
- package/dist/v3/otel/index.js +119 -53
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +119 -53
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +46 -0
- package/dist/v3/prod/index.d.ts +46 -0
- package/dist/v3/prod/index.js +180 -0
- package/dist/v3/prod/index.js.map +1 -0
- package/dist/v3/prod/index.mjs +178 -0
- package/dist/v3/prod/index.mjs.map +1 -0
- package/dist/v3/schemas/index.d.mts +4807 -0
- package/dist/v3/schemas/index.d.ts +4807 -0
- package/dist/v3/schemas/index.js +2054 -0
- package/dist/v3/schemas/index.js.map +1 -0
- package/dist/v3/schemas/index.mjs +1913 -0
- package/dist/v3/schemas/index.mjs.map +1 -0
- package/dist/v3/semanticInternalAttributes.d.mts +56 -0
- package/dist/v3/semanticInternalAttributes.d.ts +56 -0
- package/dist/v3/semanticInternalAttributes.js +61 -0
- package/dist/v3/semanticInternalAttributes.js.map +1 -0
- package/dist/v3/semanticInternalAttributes.mjs +59 -0
- package/dist/v3/semanticInternalAttributes.mjs.map +1 -0
- package/dist/v3/utils/durations.d.mts +15 -0
- package/dist/v3/utils/durations.d.ts +15 -0
- package/dist/v3/utils/durations.js +93 -0
- package/dist/v3/utils/durations.js.map +1 -0
- package/dist/v3/utils/durations.mjs +82 -0
- package/dist/v3/utils/durations.mjs.map +1 -0
- package/dist/v3/utils/flattenAttributes.d.mts +8 -0
- package/dist/v3/utils/flattenAttributes.d.ts +8 -0
- package/dist/v3/utils/flattenAttributes.js +131 -0
- package/dist/v3/utils/flattenAttributes.js.map +1 -0
- package/dist/v3/utils/flattenAttributes.mjs +126 -0
- package/dist/v3/utils/flattenAttributes.mjs.map +1 -0
- package/dist/v3/utils/ioSerialization.d.mts +21 -0
- package/dist/v3/utils/ioSerialization.d.ts +21 -0
- package/dist/v3/utils/ioSerialization.js +2392 -0
- package/dist/v3/utils/ioSerialization.js.map +1 -0
- package/dist/v3/utils/ioSerialization.mjs +2383 -0
- package/dist/v3/utils/ioSerialization.mjs.map +1 -0
- package/dist/v3/utils/omit.d.mts +3 -0
- package/dist/v3/utils/omit.d.ts +3 -0
- package/dist/v3/utils/omit.js +20 -0
- package/dist/v3/utils/omit.js.map +1 -0
- package/dist/v3/utils/omit.mjs +18 -0
- package/dist/v3/utils/omit.mjs.map +1 -0
- package/dist/v3/utils/retries.d.mts +46 -0
- package/dist/v3/utils/retries.d.ts +46 -0
- package/dist/v3/utils/retries.js +118 -0
- package/dist/v3/utils/retries.js.map +1 -0
- package/dist/v3/utils/retries.mjs +113 -0
- package/dist/v3/utils/retries.mjs.map +1 -0
- package/dist/v3/utils/structuredLogger.d.mts +31 -0
- package/dist/v3/utils/structuredLogger.d.ts +31 -0
- package/dist/v3/utils/structuredLogger.js +88 -0
- package/dist/v3/utils/structuredLogger.js.map +1 -0
- package/dist/v3/utils/structuredLogger.mjs +86 -0
- package/dist/v3/utils/structuredLogger.mjs.map +1 -0
- package/dist/v3/utils/timers.d.mts +6 -0
- package/dist/v3/utils/timers.d.ts +6 -0
- package/dist/v3/utils/timers.js +31 -0
- package/dist/v3/utils/timers.js.map +1 -0
- package/dist/v3/utils/timers.mjs +28 -0
- package/dist/v3/utils/timers.mjs.map +1 -0
- package/dist/v3/workers/index.d.mts +144 -0
- package/dist/v3/workers/index.d.ts +144 -0
- package/dist/v3/workers/index.js +3708 -0
- package/dist/v3/workers/index.js.map +1 -0
- package/dist/v3/workers/index.mjs +3689 -0
- package/dist/v3/workers/index.mjs.map +1 -0
- package/dist/v3/zodIpc.d.mts +32 -0
- package/dist/v3/zodIpc.d.ts +32 -0
- package/dist/v3/zodIpc.js +268 -0
- package/dist/v3/zodIpc.js.map +1 -0
- package/dist/v3/zodIpc.mjs +266 -0
- package/dist/v3/zodIpc.mjs.map +1 -0
- package/dist/v3/zodMessageHandler.d.mts +82 -0
- package/dist/v3/zodMessageHandler.d.ts +82 -0
- package/dist/v3/zodMessageHandler.js +222 -0
- package/dist/v3/zodMessageHandler.js.map +1 -0
- package/dist/v3/zodMessageHandler.mjs +217 -0
- package/dist/v3/zodMessageHandler.mjs.map +1 -0
- package/dist/v3/zodNamespace.d.mts +3663 -0
- package/dist/v3/zodNamespace.d.ts +3663 -0
- package/dist/v3/zodNamespace.js +397 -0
- package/dist/v3/zodNamespace.js.map +1 -0
- package/dist/v3/zodNamespace.mjs +395 -0
- package/dist/v3/zodNamespace.mjs.map +1 -0
- package/dist/v3/zodSocket.d.mts +93 -0
- package/dist/v3/zodSocket.d.ts +93 -0
- package/dist/v3/zodSocket.js +350 -0
- package/dist/v3/zodSocket.js.map +1 -0
- package/dist/v3/zodSocket.mjs +346 -0
- package/dist/v3/zodSocket.mjs.map +1 -0
- package/dist/v3/zodfetch.d.mts +219 -0
- package/dist/v3/zodfetch.d.ts +219 -0
- package/dist/v3/zodfetch.js +834 -0
- package/dist/v3/zodfetch.js.map +1 -0
- package/dist/v3/zodfetch.mjs +811 -0
- package/dist/v3/zodfetch.mjs.map +1 -0
- package/dist/versions.d.mts +11 -0
- package/dist/versions.d.ts +11 -0
- package/dist/versions.js +31 -0
- package/dist/versions.js.map +1 -0
- package/dist/versions.mjs +27 -0
- package/dist/versions.mjs.map +1 -0
- package/package.json +223 -5
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { L as LogLevel } from './taskLogger-r_AFTX45.mjs';
|
|
2
|
+
import { M as MachinePresetName, a as TaskRunContext } from './common-CLW82lkt.mjs';
|
|
3
|
+
import { R as RetryOptions, P as Prettify, T as TaskMetadata, a as TaskFileMetadata, b as TaskMetadataWithFilePath } from './schemas-C9ssfehv.mjs';
|
|
4
|
+
import { InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
5
|
+
|
|
6
|
+
interface ProjectConfig {
|
|
7
|
+
project: string;
|
|
8
|
+
triggerDirectories?: string | string[];
|
|
9
|
+
triggerUrl?: string;
|
|
10
|
+
retries?: {
|
|
11
|
+
enabledInDev?: boolean;
|
|
12
|
+
default?: RetryOptions;
|
|
13
|
+
};
|
|
14
|
+
additionalPackages?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* The default machine preset to use for your deployed trigger.dev tasks. You can override this on a per-task basis.
|
|
17
|
+
* @default "small-1x"
|
|
18
|
+
*/
|
|
19
|
+
machine?: MachinePresetName;
|
|
20
|
+
/**
|
|
21
|
+
* List of additional files to include in your trigger.dev bundle. e.g. ["./prisma/schema.prisma"]
|
|
22
|
+
*
|
|
23
|
+
* Supports glob patterns.
|
|
24
|
+
*
|
|
25
|
+
* Note: The path separator for glob patterns is `/`, even on Windows!
|
|
26
|
+
*/
|
|
27
|
+
additionalFiles?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* 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.
|
|
30
|
+
*/
|
|
31
|
+
dependenciesToBundle?: Array<string | RegExp>;
|
|
32
|
+
/**
|
|
33
|
+
* The path to your project's tsconfig.json file. Will use tsconfig.json in the project directory if not provided.
|
|
34
|
+
*/
|
|
35
|
+
tsconfigPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The OpenTelemetry instrumentations to enable
|
|
38
|
+
*/
|
|
39
|
+
instrumentations?: InstrumentationOption[];
|
|
40
|
+
/**
|
|
41
|
+
* Set the log level for the logger. Defaults to "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
|
|
42
|
+
*
|
|
43
|
+
* We automatically set the logLevel to "debug" during test runs
|
|
44
|
+
*
|
|
45
|
+
* @default "info"
|
|
46
|
+
*/
|
|
47
|
+
logLevel?: LogLevel;
|
|
48
|
+
/**
|
|
49
|
+
* 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.
|
|
50
|
+
*/
|
|
51
|
+
enableConsoleLogging?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
|
|
54
|
+
*/
|
|
55
|
+
init?: (payload: unknown, params: InitFnParams) => void | Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* onSuccess is called after the run function has successfully completed.
|
|
58
|
+
*/
|
|
59
|
+
onSuccess?: (payload: unknown, output: unknown, params: SuccessFnParams<any>) => Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
|
|
62
|
+
*/
|
|
63
|
+
onFailure?: (payload: unknown, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* onStart is called the first time a task is executed in a run (not before every retry)
|
|
66
|
+
*/
|
|
67
|
+
onStart?: (payload: unknown, params: StartFnParams) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* postInstall will run during the deploy build step, after all the dependencies have been installed.
|
|
70
|
+
*
|
|
71
|
+
* @example "prisma generate"
|
|
72
|
+
*/
|
|
73
|
+
postInstall?: string;
|
|
74
|
+
/**
|
|
75
|
+
* CA Cert file to be added to NODE_EXTRA_CA_CERT environment variable in, useful in use with self signed cert in the trigger.dev environment.
|
|
76
|
+
*
|
|
77
|
+
* @example "./certs/ca.crt"
|
|
78
|
+
* Note: must start with "./" and be relative to the project root.
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
extraCACerts?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type InitOutput = Record<string, any> | void | undefined;
|
|
85
|
+
type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
86
|
+
/** Metadata about the task, run, attempt, queue, environment, organization, project and batch. */
|
|
87
|
+
ctx: Context;
|
|
88
|
+
/** If you use the `init` function, this will be whatever you returned. */
|
|
89
|
+
init?: TInitOutput;
|
|
90
|
+
}>;
|
|
91
|
+
type MiddlewareFnParams = Prettify<{
|
|
92
|
+
ctx: Context;
|
|
93
|
+
next: () => Promise<void>;
|
|
94
|
+
}>;
|
|
95
|
+
type InitFnParams = Prettify<{
|
|
96
|
+
ctx: Context;
|
|
97
|
+
}>;
|
|
98
|
+
type StartFnParams = Prettify<{
|
|
99
|
+
ctx: Context;
|
|
100
|
+
}>;
|
|
101
|
+
type Context = TaskRunContext;
|
|
102
|
+
type SuccessFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
103
|
+
type FailureFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
104
|
+
type HandleErrorFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput> & Prettify<{
|
|
105
|
+
retry?: RetryOptions;
|
|
106
|
+
retryAt?: Date;
|
|
107
|
+
retryDelayInMs?: number;
|
|
108
|
+
}>;
|
|
109
|
+
type HandleErrorModificationOptions = {
|
|
110
|
+
skipRetrying?: boolean | undefined;
|
|
111
|
+
retryAt?: Date | undefined;
|
|
112
|
+
retryDelayInMs?: number | undefined;
|
|
113
|
+
retry?: RetryOptions | undefined;
|
|
114
|
+
error?: unknown;
|
|
115
|
+
};
|
|
116
|
+
type HandleErrorResult = undefined | void | HandleErrorModificationOptions | Promise<undefined | void | HandleErrorModificationOptions>;
|
|
117
|
+
type HandleErrorArgs = {
|
|
118
|
+
ctx: Context;
|
|
119
|
+
retry?: RetryOptions;
|
|
120
|
+
retryAt?: Date;
|
|
121
|
+
retryDelayInMs?: number;
|
|
122
|
+
};
|
|
123
|
+
type HandleErrorFunction = (payload: any, error: unknown, params: HandleErrorArgs) => HandleErrorResult;
|
|
124
|
+
type ResolveEnvironmentVariablesOptions = {
|
|
125
|
+
variables: Record<string, string> | Array<{
|
|
126
|
+
name: string;
|
|
127
|
+
value: string;
|
|
128
|
+
}>;
|
|
129
|
+
override?: boolean;
|
|
130
|
+
};
|
|
131
|
+
type ResolveEnvironmentVariablesResult = ResolveEnvironmentVariablesOptions | Promise<void | undefined | ResolveEnvironmentVariablesOptions> | void | undefined;
|
|
132
|
+
type ResolveEnvironmentVariablesParams = {
|
|
133
|
+
projectRef: string;
|
|
134
|
+
environment: "dev" | "staging" | "prod";
|
|
135
|
+
env: Record<string, string>;
|
|
136
|
+
};
|
|
137
|
+
type ResolveEnvironmentVariablesFunction = (params: ResolveEnvironmentVariablesParams) => ResolveEnvironmentVariablesResult;
|
|
138
|
+
type TaskMetadataWithFunctions = TaskMetadata & {
|
|
139
|
+
fns: {
|
|
140
|
+
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
141
|
+
init?: (payload: any, params: InitFnParams) => Promise<InitOutput>;
|
|
142
|
+
cleanup?: (payload: any, params: RunFnParams<any>) => Promise<void>;
|
|
143
|
+
middleware?: (payload: any, params: MiddlewareFnParams) => Promise<void>;
|
|
144
|
+
handleError?: (payload: any, error: unknown, params: HandleErrorFnParams<any>) => HandleErrorResult;
|
|
145
|
+
onSuccess?: (payload: any, output: any, params: SuccessFnParams<any>) => Promise<void>;
|
|
146
|
+
onFailure?: (payload: any, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
147
|
+
onStart?: (payload: any, params: StartFnParams) => Promise<void>;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Contains two parts: the first part is the seconds, the second part is the nanoseconds.
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
type ClockTime = [number, number];
|
|
156
|
+
interface Clock {
|
|
157
|
+
preciseNow(): ClockTime;
|
|
158
|
+
reset(): void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type UsageSample = {
|
|
162
|
+
cpuTime: number;
|
|
163
|
+
wallTime: number;
|
|
164
|
+
};
|
|
165
|
+
interface UsageMeasurement {
|
|
166
|
+
sample(): UsageSample;
|
|
167
|
+
}
|
|
168
|
+
interface UsageManager {
|
|
169
|
+
disable(): void;
|
|
170
|
+
start(): UsageMeasurement;
|
|
171
|
+
stop(measurement: UsageMeasurement): UsageSample;
|
|
172
|
+
sample(): UsageSample | undefined;
|
|
173
|
+
pauseAsync<T>(cb: () => Promise<T>): Promise<T>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare class UsageAPI implements UsageManager {
|
|
177
|
+
#private;
|
|
178
|
+
private static _instance?;
|
|
179
|
+
private constructor();
|
|
180
|
+
static getInstance(): UsageAPI;
|
|
181
|
+
setGlobalUsageManager(manager: UsageManager): boolean;
|
|
182
|
+
disable(): void;
|
|
183
|
+
start(): UsageMeasurement;
|
|
184
|
+
stop(measurement: UsageMeasurement): UsageSample;
|
|
185
|
+
pauseAsync<T>(cb: () => Promise<T>): Promise<T>;
|
|
186
|
+
sample(): UsageSample | undefined;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Entrypoint for usage API */
|
|
190
|
+
declare const usage: UsageAPI;
|
|
191
|
+
|
|
192
|
+
interface TaskCatalog {
|
|
193
|
+
registerTaskMetadata(task: TaskMetadataWithFunctions): void;
|
|
194
|
+
updateTaskMetadata(id: string, task: Partial<TaskMetadataWithFunctions>): void;
|
|
195
|
+
registerTaskFileMetadata(id: string, metadata: TaskFileMetadata): void;
|
|
196
|
+
getAllTaskMetadata(): Array<TaskMetadataWithFilePath>;
|
|
197
|
+
getTaskMetadata(id: string): TaskMetadataWithFilePath | undefined;
|
|
198
|
+
getTask(id: string): TaskMetadataWithFunctions | undefined;
|
|
199
|
+
taskExists(id: string): boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { type Clock as C, type FailureFnParams as F, type HandleErrorFunction as H, type InitOutput as I, type MiddlewareFnParams as M, type ProjectConfig as P, type RunFnParams as R, type StartFnParams as S, type TaskMetadataWithFunctions as T, type UsageMeasurement as U, type ClockTime as a, type TaskCatalog as b, type UsageManager as c, type UsageSample as d, type InitFnParams as e, type Context as f, type SuccessFnParams as g, type HandleErrorFnParams as h, type HandleErrorModificationOptions as i, type HandleErrorResult as j, type HandleErrorArgs as k, type ResolveEnvironmentVariablesResult as l, type ResolveEnvironmentVariablesParams as m, type ResolveEnvironmentVariablesFunction as n, usage as u };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { L as LogLevel } from './taskLogger-CzADe4je.js';
|
|
2
|
+
import { M as MachinePresetName, a as TaskRunContext } from './common-CLW82lkt.js';
|
|
3
|
+
import { R as RetryOptions, P as Prettify, T as TaskMetadata, a as TaskFileMetadata, b as TaskMetadataWithFilePath } from './schemas-C9ssfehv.js';
|
|
4
|
+
import { InstrumentationOption } from '@opentelemetry/instrumentation';
|
|
5
|
+
|
|
6
|
+
interface ProjectConfig {
|
|
7
|
+
project: string;
|
|
8
|
+
triggerDirectories?: string | string[];
|
|
9
|
+
triggerUrl?: string;
|
|
10
|
+
retries?: {
|
|
11
|
+
enabledInDev?: boolean;
|
|
12
|
+
default?: RetryOptions;
|
|
13
|
+
};
|
|
14
|
+
additionalPackages?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* The default machine preset to use for your deployed trigger.dev tasks. You can override this on a per-task basis.
|
|
17
|
+
* @default "small-1x"
|
|
18
|
+
*/
|
|
19
|
+
machine?: MachinePresetName;
|
|
20
|
+
/**
|
|
21
|
+
* List of additional files to include in your trigger.dev bundle. e.g. ["./prisma/schema.prisma"]
|
|
22
|
+
*
|
|
23
|
+
* Supports glob patterns.
|
|
24
|
+
*
|
|
25
|
+
* Note: The path separator for glob patterns is `/`, even on Windows!
|
|
26
|
+
*/
|
|
27
|
+
additionalFiles?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* 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.
|
|
30
|
+
*/
|
|
31
|
+
dependenciesToBundle?: Array<string | RegExp>;
|
|
32
|
+
/**
|
|
33
|
+
* The path to your project's tsconfig.json file. Will use tsconfig.json in the project directory if not provided.
|
|
34
|
+
*/
|
|
35
|
+
tsconfigPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The OpenTelemetry instrumentations to enable
|
|
38
|
+
*/
|
|
39
|
+
instrumentations?: InstrumentationOption[];
|
|
40
|
+
/**
|
|
41
|
+
* Set the log level for the logger. Defaults to "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
|
|
42
|
+
*
|
|
43
|
+
* We automatically set the logLevel to "debug" during test runs
|
|
44
|
+
*
|
|
45
|
+
* @default "info"
|
|
46
|
+
*/
|
|
47
|
+
logLevel?: LogLevel;
|
|
48
|
+
/**
|
|
49
|
+
* 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.
|
|
50
|
+
*/
|
|
51
|
+
enableConsoleLogging?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
|
|
54
|
+
*/
|
|
55
|
+
init?: (payload: unknown, params: InitFnParams) => void | Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* onSuccess is called after the run function has successfully completed.
|
|
58
|
+
*/
|
|
59
|
+
onSuccess?: (payload: unknown, output: unknown, params: SuccessFnParams<any>) => Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
|
|
62
|
+
*/
|
|
63
|
+
onFailure?: (payload: unknown, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* onStart is called the first time a task is executed in a run (not before every retry)
|
|
66
|
+
*/
|
|
67
|
+
onStart?: (payload: unknown, params: StartFnParams) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* postInstall will run during the deploy build step, after all the dependencies have been installed.
|
|
70
|
+
*
|
|
71
|
+
* @example "prisma generate"
|
|
72
|
+
*/
|
|
73
|
+
postInstall?: string;
|
|
74
|
+
/**
|
|
75
|
+
* CA Cert file to be added to NODE_EXTRA_CA_CERT environment variable in, useful in use with self signed cert in the trigger.dev environment.
|
|
76
|
+
*
|
|
77
|
+
* @example "./certs/ca.crt"
|
|
78
|
+
* Note: must start with "./" and be relative to the project root.
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
extraCACerts?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type InitOutput = Record<string, any> | void | undefined;
|
|
85
|
+
type RunFnParams<TInitOutput extends InitOutput> = Prettify<{
|
|
86
|
+
/** Metadata about the task, run, attempt, queue, environment, organization, project and batch. */
|
|
87
|
+
ctx: Context;
|
|
88
|
+
/** If you use the `init` function, this will be whatever you returned. */
|
|
89
|
+
init?: TInitOutput;
|
|
90
|
+
}>;
|
|
91
|
+
type MiddlewareFnParams = Prettify<{
|
|
92
|
+
ctx: Context;
|
|
93
|
+
next: () => Promise<void>;
|
|
94
|
+
}>;
|
|
95
|
+
type InitFnParams = Prettify<{
|
|
96
|
+
ctx: Context;
|
|
97
|
+
}>;
|
|
98
|
+
type StartFnParams = Prettify<{
|
|
99
|
+
ctx: Context;
|
|
100
|
+
}>;
|
|
101
|
+
type Context = TaskRunContext;
|
|
102
|
+
type SuccessFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
103
|
+
type FailureFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput>;
|
|
104
|
+
type HandleErrorFnParams<TInitOutput extends InitOutput> = RunFnParams<TInitOutput> & Prettify<{
|
|
105
|
+
retry?: RetryOptions;
|
|
106
|
+
retryAt?: Date;
|
|
107
|
+
retryDelayInMs?: number;
|
|
108
|
+
}>;
|
|
109
|
+
type HandleErrorModificationOptions = {
|
|
110
|
+
skipRetrying?: boolean | undefined;
|
|
111
|
+
retryAt?: Date | undefined;
|
|
112
|
+
retryDelayInMs?: number | undefined;
|
|
113
|
+
retry?: RetryOptions | undefined;
|
|
114
|
+
error?: unknown;
|
|
115
|
+
};
|
|
116
|
+
type HandleErrorResult = undefined | void | HandleErrorModificationOptions | Promise<undefined | void | HandleErrorModificationOptions>;
|
|
117
|
+
type HandleErrorArgs = {
|
|
118
|
+
ctx: Context;
|
|
119
|
+
retry?: RetryOptions;
|
|
120
|
+
retryAt?: Date;
|
|
121
|
+
retryDelayInMs?: number;
|
|
122
|
+
};
|
|
123
|
+
type HandleErrorFunction = (payload: any, error: unknown, params: HandleErrorArgs) => HandleErrorResult;
|
|
124
|
+
type ResolveEnvironmentVariablesOptions = {
|
|
125
|
+
variables: Record<string, string> | Array<{
|
|
126
|
+
name: string;
|
|
127
|
+
value: string;
|
|
128
|
+
}>;
|
|
129
|
+
override?: boolean;
|
|
130
|
+
};
|
|
131
|
+
type ResolveEnvironmentVariablesResult = ResolveEnvironmentVariablesOptions | Promise<void | undefined | ResolveEnvironmentVariablesOptions> | void | undefined;
|
|
132
|
+
type ResolveEnvironmentVariablesParams = {
|
|
133
|
+
projectRef: string;
|
|
134
|
+
environment: "dev" | "staging" | "prod";
|
|
135
|
+
env: Record<string, string>;
|
|
136
|
+
};
|
|
137
|
+
type ResolveEnvironmentVariablesFunction = (params: ResolveEnvironmentVariablesParams) => ResolveEnvironmentVariablesResult;
|
|
138
|
+
type TaskMetadataWithFunctions = TaskMetadata & {
|
|
139
|
+
fns: {
|
|
140
|
+
run: (payload: any, params: RunFnParams<any>) => Promise<any>;
|
|
141
|
+
init?: (payload: any, params: InitFnParams) => Promise<InitOutput>;
|
|
142
|
+
cleanup?: (payload: any, params: RunFnParams<any>) => Promise<void>;
|
|
143
|
+
middleware?: (payload: any, params: MiddlewareFnParams) => Promise<void>;
|
|
144
|
+
handleError?: (payload: any, error: unknown, params: HandleErrorFnParams<any>) => HandleErrorResult;
|
|
145
|
+
onSuccess?: (payload: any, output: any, params: SuccessFnParams<any>) => Promise<void>;
|
|
146
|
+
onFailure?: (payload: any, error: unknown, params: FailureFnParams<any>) => Promise<void>;
|
|
147
|
+
onStart?: (payload: any, params: StartFnParams) => Promise<void>;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Contains two parts: the first part is the seconds, the second part is the nanoseconds.
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
type ClockTime = [number, number];
|
|
156
|
+
interface Clock {
|
|
157
|
+
preciseNow(): ClockTime;
|
|
158
|
+
reset(): void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type UsageSample = {
|
|
162
|
+
cpuTime: number;
|
|
163
|
+
wallTime: number;
|
|
164
|
+
};
|
|
165
|
+
interface UsageMeasurement {
|
|
166
|
+
sample(): UsageSample;
|
|
167
|
+
}
|
|
168
|
+
interface UsageManager {
|
|
169
|
+
disable(): void;
|
|
170
|
+
start(): UsageMeasurement;
|
|
171
|
+
stop(measurement: UsageMeasurement): UsageSample;
|
|
172
|
+
sample(): UsageSample | undefined;
|
|
173
|
+
pauseAsync<T>(cb: () => Promise<T>): Promise<T>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare class UsageAPI implements UsageManager {
|
|
177
|
+
#private;
|
|
178
|
+
private static _instance?;
|
|
179
|
+
private constructor();
|
|
180
|
+
static getInstance(): UsageAPI;
|
|
181
|
+
setGlobalUsageManager(manager: UsageManager): boolean;
|
|
182
|
+
disable(): void;
|
|
183
|
+
start(): UsageMeasurement;
|
|
184
|
+
stop(measurement: UsageMeasurement): UsageSample;
|
|
185
|
+
pauseAsync<T>(cb: () => Promise<T>): Promise<T>;
|
|
186
|
+
sample(): UsageSample | undefined;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Entrypoint for usage API */
|
|
190
|
+
declare const usage: UsageAPI;
|
|
191
|
+
|
|
192
|
+
interface TaskCatalog {
|
|
193
|
+
registerTaskMetadata(task: TaskMetadataWithFunctions): void;
|
|
194
|
+
updateTaskMetadata(id: string, task: Partial<TaskMetadataWithFunctions>): void;
|
|
195
|
+
registerTaskFileMetadata(id: string, metadata: TaskFileMetadata): void;
|
|
196
|
+
getAllTaskMetadata(): Array<TaskMetadataWithFilePath>;
|
|
197
|
+
getTaskMetadata(id: string): TaskMetadataWithFilePath | undefined;
|
|
198
|
+
getTask(id: string): TaskMetadataWithFunctions | undefined;
|
|
199
|
+
taskExists(id: string): boolean;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { type Clock as C, type FailureFnParams as F, type HandleErrorFunction as H, type InitOutput as I, type MiddlewareFnParams as M, type ProjectConfig as P, type RunFnParams as R, type StartFnParams as S, type TaskMetadataWithFunctions as T, type UsageMeasurement as U, type ClockTime as a, type TaskCatalog as b, type UsageManager as c, type UsageSample as d, type InitFnParams as e, type Context as f, type SuccessFnParams as g, type HandleErrorFnParams as h, type HandleErrorModificationOptions as i, type HandleErrorResult as j, type HandleErrorArgs as k, type ResolveEnvironmentVariablesResult as l, type ResolveEnvironmentVariablesParams as m, type ResolveEnvironmentVariablesFunction as n, usage as u };
|