-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathconfig.ts
More file actions
401 lines (352 loc) · 12 KB
/
config.ts
File metadata and controls
401 lines (352 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
import type { Instrumentation } from "@opentelemetry/instrumentation";
import type { SpanExporter } from "@opentelemetry/sdk-trace-base";
import type { MetricReader, PushMetricExporter } from "@opentelemetry/sdk-metrics";
import type { BuildExtension } from "./build/extensions.js";
import type {
AnyOnFailureHookFunction,
AnyOnInitHookFunction,
AnyOnStartHookFunction,
AnyOnSuccessHookFunction,
BuildRuntime,
RetryOptions,
} from "./index.js";
import type { LogLevel } from "./logger/taskLogger.js";
import type { MachinePresetName } from "./schemas/common.js";
import { LogRecordExporter } from "@opentelemetry/sdk-logs";
import type { Resource } from "@opentelemetry/resources";
export type CompatibilityFlag = "run_engine_v2";
export type CompatibilityFlagFeatures = {
[key in CompatibilityFlag]: boolean;
};
type ProcessKeepAlive =
| boolean
| {
enabled: boolean;
/**
* The maximum number of executions per process. If the process has run more than this number of times, it will be killed.
*
* @default 50
*/
maxExecutionsPerProcess?: number;
/**
* The maximum number of processes to keep alive in dev.
*
* @default 25
*/
devMaxPoolSize?: number;
};
export type TriggerConfig = {
/**
* @default "node"
*/
runtime?: BuildRuntime;
/**
* Specify the project ref for your trigger.dev tasks. This is the project ref that you get when you create a new project in the trigger.dev dashboard.
*/
project: string;
/**
* Specify the directories that contain your trigger.dev tasks. This is useful if you have multiple directories that contain tasks.
*
* We automatically detect directories named `trigger` to be task directories. You can override this behavior by specifying the directories here.
*
* @see @see https://trigger.dev/docs/config/config-file#dirs
*/
dirs?: string[];
/**
* Specify glob patterns to ignore when detecting task files. By default we ignore:
*
* - *.test.ts
* - *.spec.ts
* - *.test.mts
* - *.spec.mts
* - *.test.cts
* - *.spec.cts
* - *.test.js
* - *.spec.js
* - *.test.mjs
* - *.spec.mjs
* - *.test.cjs
* - *.spec.cjs
*
*/
ignorePatterns?: string[];
/**
* Instrumentations to use for OpenTelemetry. This is useful if you want to add custom instrumentations to your tasks.
*
* @see https://trigger.dev/docs/config/config-file#instrumentations
*
* @deprecated Use the `telemetry.instrumentations` option instead.
*/
instrumentations?: Array<Instrumentation>;
telemetry?: {
/**
* Instrumentations to use for OpenTelemetry. This is useful if you want to add custom instrumentations to your tasks.
*
* @see https://trigger.dev/docs/config/config-file#instrumentations
*/
instrumentations?: Array<Instrumentation>;
/**
* Exporters to use for OpenTelemetry. This is useful if you want to add custom exporters to your tasks.
*
* @see https://trigger.dev/docs/config/config-file#exporters
*/
exporters?: Array<SpanExporter>;
/**
* Log exporters to use for OpenTelemetry. This is useful if you want to add custom log exporters to your tasks.
*
* @see https://trigger.dev/docs/config/config-file#exporters
*/
logExporters?: Array<LogRecordExporter>;
/**
* Metric exporters to use for OpenTelemetry. This is useful if you want to export metrics to external services.
* Each exporter is automatically wrapped in a PeriodicExportingMetricReader.
*
* For more control over the reader configuration, use `metricReaders` instead.
*/
metricExporters?: Array<PushMetricExporter>;
/**
* Metric readers for OpenTelemetry. Add custom metric readers to export
* metrics to external services alongside the default Trigger.dev exporter.
*/
metricReaders?: Array<MetricReader>;
/**
* Resource to use for OpenTelemetry. This is useful if you want to add custom resources to your tasks.
*
* @see https://trigger.dev/docs/config/config-file#resource
*/
resource?: Resource;
};
/**
* Specify a custom path to your tsconfig file. This is useful if you have a custom tsconfig file that you want to use.
*/
tsconfig?: string;
/**
* Specify the global retry options for your tasks. You can override this on a per-task basis.
*
* @see https://trigger.dev/docs/tasks/overview#retry-options
*/
retries?: {
enabledInDev?: boolean;
default?: RetryOptions;
};
compatibilityFlags?: Array<CompatibilityFlag>;
/**
* The default machine preset to use for your deployed trigger.dev tasks. You can override this on a per-task basis.
* @default "small-1x"
*
* @see https://trigger.dev/docs/machines
*/
machine?: MachinePresetName;
/**
* Set the log level for the logger. Defaults to "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
*
* We automatically set the logLevel to "debug" during test runs
*
* @default "info"
*/
logLevel?: LogLevel;
/**
* The maximum duration in compute-time seconds that a task run is allowed to run. If the task run exceeds this duration, it will be stopped.
*
* Minimum value is 5 seconds
*
* Setting this value will effect all tasks in the project.
*
* @see https://trigger.dev/docs/tasks/overview#maxduration-option
*/
maxDuration: number;
/**
* Set a default time-to-live (TTL) for all task runs in the project. If a run is not executed within this time, it will be removed from the queue and never execute.
*
* This can be a string like "1h" (1 hour), "30m" (30 minutes), "1d" (1 day), or a number of seconds.
*
* You can override this on a per-task basis by setting the `ttl` option on the task definition, or per-trigger by setting the `ttl` option when triggering.
*
* @example
*
* ```ts
* export default defineConfig({
* project: "my-project",
* maxDuration: 3600,
* ttl: "1h",
* });
* ```
*/
ttl?: string | number;
/**
* 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.
*/
enableConsoleLogging?: boolean;
/**
* Disable the console interceptor. This will prevent logs from being sent to the trigger.dev backend.
*/
disableConsoleInterceptor?: boolean;
build?: {
/**
* Add custom conditions to the esbuild build. For example, if you are importing `ai/rsc`, you'll need to add "react-server" condition.
*
* By default we add the following conditions:
*
* - "trigger.dev"
* - "module"
* - "node"
*/
conditions?: string[];
/**
* Add custom build extensions to the build process.
*
* @see https://trigger.dev/docs/config/config-file#extensions
*/
extensions?: BuildExtension[];
/**
* External dependencies to exclude from the bundle. This is useful if you want to keep some dependencies as external, and not bundle them with your code.
*
* @see https://trigger.dev/docs/config/config-file#external
*/
external?: string[];
/**
* This still works but use `autoDetectExternal` instead.
*
* @deprecated (use autoDetectExternal instead)
*/
experimental_autoDetectExternal?: boolean;
/**
* Automatically detect dependencies that shouldn't be bundled and mark them as external. For example, native modules.
*
* Turn this off if you are having issues and want to manually specify all `external` dependencies.
*
* @default true
*/
autoDetectExternal?: boolean;
/**
* This still works but use `keepNames` instead.
*
* @deprecated (use keepNames instead)
*/
experimental_keepNames?: boolean;
/* Set to false to minify the original names of functions and classes in the bundle.
* This can make bundles smaller at the cost of compatibility with frameworks that rely on function/class/variable names.
*
* @link https://esbuild.github.io/api/#keep-names
*
* @default true
*/
keepNames?: boolean;
/**
* This still works but use `minify` instead.
*
* @deprecated (use minify instead)
*/
experimental_minify?: boolean;
/**
* **WARNING: This is an experimental feature and might be removed in a future version.**
*
* "Minification is not safe for 100% of all JavaScript code" - esbuild docs
*
* Minify the generated code to help decrease bundle size. This may break stuff.
*
* @link https://esbuild.github.io/api/#minify
*
* @default false
*/
minify?: boolean;
jsx?: {
/**
* @default "React.createElement"
*/
factory?: string;
/**
* @default "React.Fragment"
*/
fragment?: string;
/**
* @default true
* @description Set the esbuild jsx option to automatic. Set this to false if you aren't using React.
* @see https://esbuild.github.io/api/#jsx
*/
automatic?: boolean;
};
};
deploy?: {
env?: Record<string, string>;
};
/**
* This still works but use `processKeepAlive` instead.
*
* @deprecated (use processKeepAlive instead)
*/
experimental_processKeepAlive?: ProcessKeepAlive;
/**
* @default false
* @description Keep the process alive after the task has finished running so the next task doesn't have to wait for the process to start up again.
*
* Note that the process could be killed at any time, and we don't make any guarantees about the process being alive for a certain amount of time
*/
processKeepAlive?: ProcessKeepAlive;
/**
* @default true
* @description If set to true when running the dev CLI, the current working directory will be set to where the command is run from.
*
* Setting this to `false` will set the current working directory to the build directory.
* This more closely matches the behavior of the CLI when running in production and is highly recommended.
*
* This impacts the value of process.cwd() in your task code.
*/
legacyDevProcessCwdBehaviour?: boolean;
/**
* @deprecated Use `dirs` instead
*/
triggerDirectories?: string[];
/**
* @deprecated Use the `additionalPackages` extension instead.
*/
additionalPackages?: string[];
/**
* @deprecated Use the `additionalFiles` extension instead.
*/
additionalFiles?: string[];
/**
* @deprecated Dependencies are now bundled by default. If you want to exclude some dependencies from the bundle, use the `build.external` option.
*/
dependenciesToBundle?: Array<string | RegExp>;
/**
* @deprecated Use `tsconfig` instead.
*/
tsconfigPath?: string;
/**
* CA Cert file to be added to NODE_EXTRA_CA_CERT environment variable, useful in use with self signed cert in the trigger.dev environment.
*
* @example "./certs/ca.crt"
* Note: must start with "./" and be relative to the project root.
*
*/
extraCACerts?: string;
/**
* Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
*
* @deprecated, please use tasks.init instead
*/
init?: AnyOnInitHookFunction;
/**
* onSuccess is called after the run function has successfully completed.
*
* @deprecated, please use tasks.onSuccess instead
*/
onSuccess?: AnyOnSuccessHookFunction;
/**
* onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
*
* @deprecated, please use tasks.onFailure instead
*/
onFailure?: AnyOnFailureHookFunction;
/**
* onStart is called the first time a task is executed in a run (not before every retry)
*
* @deprecated, please use tasks.onStart instead
*/
onStart?: AnyOnStartHookFunction;
/**
* @deprecated Use a custom build extension to add post install commands
*/
postInstall?: string;
};