@trigger.dev/sdk 3.0.0-beta.4 → 3.0.0-beta.40
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +221 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +221 -69
- package/dist/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +361 -72
- package/dist/v3/index.d.ts +361 -72
- package/dist/v3/index.js +1018 -477
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +978 -479
- package/dist/v3/index.mjs.map +1 -1
- package/package.json +7 -14
package/dist/v3/index.d.ts
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { HandleErrorArgs, HandleErrorFunction, LogLevel, RetryOptions, ProjectConfig as TriggerConfig, logger } from '@trigger.dev/core/v3';
|
|
1
|
+
import { RetryOptions, FetchRetryOptions, TaskRunContext, QueueOptions, InitOutput, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, ListProjectRunsQueryParams, CursorPagePromise, ListRunResponseItem, ListRunsQueryParams, ApiPromise, ReplayRunResponse, CanceledRunResponse, RetrieveRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, OffsetLimitPagePromise, ImportEnvironmentVariablesParams, EnvironmentVariableResponseBody, EnvironmentVariables, CreateEnvironmentVariableParams, EnvironmentVariableValue, UpdateEnvironmentVariableParams, ApiClientConfiguration } from '@trigger.dev/core/v3';
|
|
2
|
+
export { ApiClientConfiguration, ApiError, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, ImportEnvironmentVariablesParams, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, ResolveEnvironmentVariablesFunction, ResolveEnvironmentVariablesParams, ResolveEnvironmentVariablesResult, RetryOptions, ProjectConfig as TriggerConfig, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
|
|
3
3
|
import { HttpHandler } from 'msw';
|
|
4
4
|
|
|
5
|
+
type CacheMetadata = {
|
|
6
|
+
createdTime: number;
|
|
7
|
+
ttl?: number | null;
|
|
8
|
+
};
|
|
9
|
+
type CacheEntry<Value = unknown> = {
|
|
10
|
+
metadata: CacheMetadata;
|
|
11
|
+
value: Value;
|
|
12
|
+
};
|
|
13
|
+
type Eventually<Value> = Value | null | undefined | Promise<Value | null | undefined>;
|
|
14
|
+
type CacheStore<Value = any> = {
|
|
15
|
+
name?: string;
|
|
16
|
+
get: (key: string) => Eventually<CacheEntry<Value>>;
|
|
17
|
+
set: (key: string, value: CacheEntry<Value>) => unknown | Promise<unknown>;
|
|
18
|
+
delete: (key: string) => unknown | Promise<unknown>;
|
|
19
|
+
};
|
|
20
|
+
type CacheFunction = <Value>(cacheKey: string, fn: () => Promise<Value> | Value) => Promise<Value> | Value;
|
|
21
|
+
declare class InMemoryCache<Value = any> {
|
|
22
|
+
private _cache;
|
|
23
|
+
get(key: string): Eventually<CacheEntry<Value>>;
|
|
24
|
+
set(key: string, value: CacheEntry<Value>): unknown;
|
|
25
|
+
delete(key: string): unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a cache function that uses the provided store to cache values. Using InMemoryCache is safe because each task run is isolated.
|
|
29
|
+
* @param store
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
declare function createCache(store: CacheStore): CacheFunction;
|
|
33
|
+
|
|
34
|
+
declare function onThrow<T>(fn: (options: {
|
|
35
|
+
attempt: number;
|
|
36
|
+
maxAttempts: number;
|
|
37
|
+
}) => Promise<T>, options: RetryOptions): Promise<T>;
|
|
38
|
+
interface RetryFetchRequestInit extends RequestInit {
|
|
39
|
+
retry?: FetchRetryOptions;
|
|
40
|
+
timeoutInMs?: number;
|
|
41
|
+
}
|
|
42
|
+
declare function retryFetch(input: RequestInfo | URL, init?: RetryFetchRequestInit | undefined): Promise<Response>;
|
|
43
|
+
declare const retry: {
|
|
44
|
+
onThrow: typeof onThrow;
|
|
45
|
+
fetch: typeof retryFetch;
|
|
46
|
+
interceptFetch: (...handlers: Array<HttpHandler>) => {
|
|
47
|
+
run: <T>(fn: (...args: any[]) => Promise<T>) => Promise<T>;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
5
51
|
type Context = TaskRunContext;
|
|
6
52
|
type RequireOne<T, K extends keyof T> = {
|
|
7
53
|
[X in Exclude<keyof T, K>]?: T[X];
|
|
@@ -9,7 +55,10 @@ type RequireOne<T, K extends keyof T> = {
|
|
|
9
55
|
[P in K]-?: T[P];
|
|
10
56
|
};
|
|
11
57
|
type Queue = RequireOne<QueueOptions, "name">;
|
|
12
|
-
|
|
58
|
+
declare function queue(options: {
|
|
59
|
+
name: string;
|
|
60
|
+
} & QueueOptions): Queue;
|
|
61
|
+
type TaskOptions<TPayload = void, TOutput = unknown, TInitOutput extends InitOutput = any> = {
|
|
13
62
|
/** An id for your task. This must be unique inside your project and not change between versions. */
|
|
14
63
|
id: string;
|
|
15
64
|
/** The retry settings when an uncaught error is thrown.
|
|
@@ -79,6 +128,7 @@ type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any>
|
|
|
79
128
|
* - 1
|
|
80
129
|
* - 2
|
|
81
130
|
* - 4
|
|
131
|
+
* @deprecated use preset instead
|
|
82
132
|
*/
|
|
83
133
|
cpu?: MachineCpu;
|
|
84
134
|
/** In GBs of RAM. The default is 1.
|
|
@@ -90,8 +140,11 @@ type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any>
|
|
|
90
140
|
* - 2
|
|
91
141
|
* - 4
|
|
92
142
|
* - 8
|
|
143
|
+
* * @deprecated use preset instead
|
|
93
144
|
*/
|
|
94
145
|
memory?: MachineMemory;
|
|
146
|
+
/** Preset to use for the machine. Defaults to small-1x */
|
|
147
|
+
preset?: "micro" | "small-1x" | "small-2x" | "medium-1x" | "medium-2x" | "large-1x" | "large-2x";
|
|
95
148
|
};
|
|
96
149
|
/** This gets called when a task is triggered. It's where you put the code you want to execute.
|
|
97
150
|
*
|
|
@@ -99,11 +152,48 @@ type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any>
|
|
|
99
152
|
* @param params - Metadata about the run.
|
|
100
153
|
*/
|
|
101
154
|
run: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<TOutput>;
|
|
155
|
+
/**
|
|
156
|
+
* init is called before the run function is called. It's useful for setting up any global state.
|
|
157
|
+
*/
|
|
102
158
|
init?: (payload: TPayload, params: InitFnParams) => Promise<TInitOutput>;
|
|
103
|
-
|
|
159
|
+
/**
|
|
160
|
+
* cleanup is called after the run function has completed.
|
|
161
|
+
*/
|
|
104
162
|
cleanup?: (payload: TPayload, params: RunFnParams<TInitOutput>) => Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* handleError is called when the run function throws an error. It can be used to modify the error or return new retry options.
|
|
165
|
+
*/
|
|
166
|
+
handleError?: (payload: TPayload, error: unknown, params: HandleErrorFnParams<TInitOutput>) => HandleErrorResult;
|
|
167
|
+
/**
|
|
168
|
+
* middleware allows you to run code "around" the run function. This can be useful for logging, metrics, or other cross-cutting concerns.
|
|
169
|
+
*
|
|
170
|
+
* When writing middleware, you should always call `next()` to continue the execution of the task:
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* export const middlewareTask = task({
|
|
174
|
+
* id: "middleware-task",
|
|
175
|
+
* middleware: async (payload, { ctx, next }) => {
|
|
176
|
+
* console.log("Before run");
|
|
177
|
+
* await next();
|
|
178
|
+
* console.log("After run");
|
|
179
|
+
* },
|
|
180
|
+
* run: async (payload, { ctx }) => {}
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
105
184
|
middleware?: (payload: TPayload, params: MiddlewareFnParams) => Promise<void>;
|
|
106
|
-
|
|
185
|
+
/**
|
|
186
|
+
* onStart is called the first time a task is executed in a run (not before every retry)
|
|
187
|
+
*/
|
|
188
|
+
onStart?: (payload: TPayload, params: StartFnParams) => Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* onSuccess is called after the run function has successfully completed.
|
|
191
|
+
*/
|
|
192
|
+
onSuccess?: (payload: TPayload, output: TOutput, params: SuccessFnParams<TInitOutput>) => Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* onFailure is called after a task run has failed (meaning the run function threw an error and won't be retried anymore)
|
|
195
|
+
*/
|
|
196
|
+
onFailure?: (payload: TPayload, error: unknown, params: FailureFnParams<TInitOutput>) => Promise<void>;
|
|
107
197
|
};
|
|
108
198
|
type InvokeHandle = {
|
|
109
199
|
id: string;
|
|
@@ -119,36 +209,79 @@ type TaskRunResult<TOutput = any> = {
|
|
|
119
209
|
} | {
|
|
120
210
|
ok: false;
|
|
121
211
|
id: string;
|
|
122
|
-
error:
|
|
212
|
+
error: unknown;
|
|
123
213
|
};
|
|
124
214
|
type BatchResult<TOutput = any> = {
|
|
125
215
|
id: string;
|
|
126
216
|
runs: TaskRunResult<TOutput>[];
|
|
127
217
|
};
|
|
128
|
-
type
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
items: {
|
|
135
|
-
payload: TInput;
|
|
136
|
-
options?: TaskRunOptions;
|
|
137
|
-
}[];
|
|
138
|
-
batchOptions?: BatchRunOptions;
|
|
139
|
-
}) => Promise<InvokeBatchHandle>;
|
|
140
|
-
triggerAndWait: (params: {
|
|
141
|
-
payload: TInput;
|
|
142
|
-
options?: TaskRunOptions;
|
|
143
|
-
}) => Promise<TOutput>;
|
|
144
|
-
batchTriggerAndWait: (params: {
|
|
145
|
-
items: {
|
|
146
|
-
payload: TInput;
|
|
147
|
-
options?: TaskRunOptions;
|
|
148
|
-
}[];
|
|
149
|
-
batchOptions?: BatchRunOptions;
|
|
150
|
-
}) => Promise<BatchResult<TOutput>>;
|
|
218
|
+
type BatchItem<TInput> = TInput extends void ? {
|
|
219
|
+
payload?: TInput;
|
|
220
|
+
options?: TaskRunOptions;
|
|
221
|
+
} : {
|
|
222
|
+
payload: TInput;
|
|
223
|
+
options?: TaskRunOptions;
|
|
151
224
|
};
|
|
225
|
+
interface Task<TInput = void, TOutput = any> {
|
|
226
|
+
/**
|
|
227
|
+
* The id of the task.
|
|
228
|
+
*/
|
|
229
|
+
id: string;
|
|
230
|
+
/**
|
|
231
|
+
* Trigger a task with the given payload, and continue without waiting for the result. If you want to wait for the result, use `triggerAndWait`. Returns the id of the triggered task run.
|
|
232
|
+
* @param payload
|
|
233
|
+
* @param options
|
|
234
|
+
* @returns InvokeHandle
|
|
235
|
+
* - `id` - The id of the triggered task run.
|
|
236
|
+
*/
|
|
237
|
+
trigger: (payload: TInput, options?: TaskRunOptions) => Promise<InvokeHandle>;
|
|
238
|
+
/**
|
|
239
|
+
* Batch trigger multiple task runs with the given payloads, and continue without waiting for the results. If you want to wait for the results, use `batchTriggerAndWait`. Returns the id of the triggered batch.
|
|
240
|
+
* @param items
|
|
241
|
+
* @returns InvokeBatchHandle
|
|
242
|
+
* - `batchId` - The id of the triggered batch.
|
|
243
|
+
* - `runs` - The ids of the triggered task runs.
|
|
244
|
+
*/
|
|
245
|
+
batchTrigger: (items: Array<BatchItem<TInput>>) => Promise<InvokeBatchHandle>;
|
|
246
|
+
/**
|
|
247
|
+
* Trigger a task with the given payload, and wait for the result. Returns the result of the task run
|
|
248
|
+
* @param payload
|
|
249
|
+
* @param options - Options for the task run
|
|
250
|
+
* @returns TaskRunResult
|
|
251
|
+
* @example
|
|
252
|
+
* ```
|
|
253
|
+
* const result = await task.triggerAndWait({ foo: "bar" });
|
|
254
|
+
*
|
|
255
|
+
* if (result.ok) {
|
|
256
|
+
* console.log(result.output);
|
|
257
|
+
* } else {
|
|
258
|
+
* console.error(result.error);
|
|
259
|
+
* }
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
triggerAndWait: (payload: TInput, options?: TaskRunOptions) => Promise<TaskRunResult<TOutput>>;
|
|
263
|
+
/**
|
|
264
|
+
* Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
|
|
265
|
+
* @param items
|
|
266
|
+
* @returns BatchResult
|
|
267
|
+
* @example
|
|
268
|
+
* ```
|
|
269
|
+
* const result = await task.batchTriggerAndWait([
|
|
270
|
+
* { payload: { foo: "bar" } },
|
|
271
|
+
* { payload: { foo: "baz" } },
|
|
272
|
+
* ]);
|
|
273
|
+
*
|
|
274
|
+
* for (const run of result.runs) {
|
|
275
|
+
* if (run.ok) {
|
|
276
|
+
* console.log(run.output);
|
|
277
|
+
* } else {
|
|
278
|
+
* console.error(run.error);
|
|
279
|
+
* }
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
batchTriggerAndWait: (items: Array<BatchItem<TInput>>) => Promise<BatchResult<TOutput>>;
|
|
284
|
+
}
|
|
152
285
|
type TaskRunOptions = {
|
|
153
286
|
idempotencyKey?: string;
|
|
154
287
|
maxAttempts?: number;
|
|
@@ -158,9 +291,6 @@ type TaskRunOptions = {
|
|
|
158
291
|
concurrencyKey?: string;
|
|
159
292
|
};
|
|
160
293
|
type TaskRunConcurrencyOptions = Queue;
|
|
161
|
-
type BatchRunOptions = TaskRunOptions & {
|
|
162
|
-
maxConcurrency?: number;
|
|
163
|
-
};
|
|
164
294
|
|
|
165
295
|
/** Creates a task that can be triggered
|
|
166
296
|
* @param options - Task options
|
|
@@ -180,7 +310,7 @@ type BatchRunOptions = TaskRunOptions & {
|
|
|
180
310
|
*
|
|
181
311
|
* @returns A task that can be triggered
|
|
182
312
|
*/
|
|
183
|
-
declare function task<TInput, TOutput =
|
|
313
|
+
declare function task$1<TInput = void, TOutput = unknown, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
|
|
184
314
|
|
|
185
315
|
type WaitOptions = {
|
|
186
316
|
seconds: number;
|
|
@@ -205,50 +335,209 @@ declare const wait: {
|
|
|
205
335
|
}) => Promise<void>;
|
|
206
336
|
};
|
|
207
337
|
|
|
208
|
-
type
|
|
209
|
-
|
|
210
|
-
|
|
338
|
+
type ComputeUsage = {
|
|
339
|
+
costInCents: number;
|
|
340
|
+
durationMs: number;
|
|
211
341
|
};
|
|
212
|
-
type
|
|
213
|
-
|
|
214
|
-
|
|
342
|
+
type CurrentUsage = {
|
|
343
|
+
compute: {
|
|
344
|
+
attempt: ComputeUsage;
|
|
345
|
+
total: ComputeUsage;
|
|
346
|
+
};
|
|
347
|
+
baseCostInCents: number;
|
|
348
|
+
totalCostInCents: number;
|
|
215
349
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
350
|
+
declare const usage: {
|
|
351
|
+
/**
|
|
352
|
+
* Get the current running usage of this task run.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
*
|
|
356
|
+
* ```typescript
|
|
357
|
+
* import { usage, task } from "@trigger.dev/sdk/v3";
|
|
358
|
+
*
|
|
359
|
+
* export const myTask = task({
|
|
360
|
+
* id: "my-task",
|
|
361
|
+
* run: async (payload, { ctx }) => {
|
|
362
|
+
* // ... Do a bunch of work
|
|
363
|
+
*
|
|
364
|
+
* const currentUsage = usage.getCurrent();
|
|
365
|
+
*
|
|
366
|
+
* // You have access to the current compute cost and duration up to this point
|
|
367
|
+
* console.log("Current attempt compute cost and duration", {
|
|
368
|
+
* cost: currentUsage.compute.attempt.costInCents,
|
|
369
|
+
* duration: currentUsage.compute.attempt.durationMs,
|
|
370
|
+
* });
|
|
371
|
+
*
|
|
372
|
+
* // You also can see the total compute cost and duration up to this point in the run, across all attempts
|
|
373
|
+
* console.log("Current total compute cost and duration", {
|
|
374
|
+
* cost: currentUsage.compute.total.costInCents,
|
|
375
|
+
* duration: currentUsage.compute.total.durationMs,
|
|
376
|
+
* });
|
|
377
|
+
*
|
|
378
|
+
* // You can see the base cost of the run, which is the cost of the run before any compute costs
|
|
379
|
+
* console.log("Total cost", {
|
|
380
|
+
* cost: currentUsage.totalCostInCents,
|
|
381
|
+
* baseCost: currentUsage.baseCostInCents,
|
|
382
|
+
* });
|
|
383
|
+
* },
|
|
384
|
+
* });
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
getCurrent: () => CurrentUsage;
|
|
388
|
+
/**
|
|
389
|
+
* Measure the cost and duration of a function.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
*
|
|
393
|
+
* ```typescript
|
|
394
|
+
* import { usage } from "@trigger.dev/sdk/v3";
|
|
395
|
+
*
|
|
396
|
+
* export const myTask = task({
|
|
397
|
+
* id: "my-task",
|
|
398
|
+
* run: async (payload, { ctx }) => {
|
|
399
|
+
* const { result, compute } = await usage.measure(async () => {
|
|
400
|
+
* // Do some work
|
|
401
|
+
* return "result";
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* console.log("Result", result);
|
|
405
|
+
* console.log("Cost and duration", { cost: compute.costInCents, duration: compute.durationMs });
|
|
406
|
+
* },
|
|
407
|
+
* });
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
measure: <T>(cb: () => Promise<T>) => Promise<{
|
|
411
|
+
result: T;
|
|
412
|
+
compute: ComputeUsage;
|
|
413
|
+
}>;
|
|
222
414
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
415
|
+
|
|
416
|
+
type RetrieveRunResult = RetrieveRunResponse;
|
|
417
|
+
declare const runs: {
|
|
418
|
+
replay: typeof replayRun;
|
|
419
|
+
cancel: typeof cancelRun;
|
|
420
|
+
retrieve: typeof retrieveRun;
|
|
421
|
+
list: typeof listRuns;
|
|
422
|
+
};
|
|
423
|
+
declare function listRuns(projectRef: string, params?: ListProjectRunsQueryParams): CursorPagePromise<typeof ListRunResponseItem>;
|
|
424
|
+
declare function listRuns(params?: ListRunsQueryParams): CursorPagePromise<typeof ListRunResponseItem>;
|
|
425
|
+
declare function retrieveRun(runId: string): ApiPromise<RetrieveRunResult>;
|
|
426
|
+
declare function replayRun(runId: string): ApiPromise<ReplayRunResponse>;
|
|
427
|
+
declare function cancelRun(runId: string): ApiPromise<CanceledRunResponse>;
|
|
428
|
+
|
|
429
|
+
declare function task<TOutput, TInitOutput extends InitOutput>(params: TaskOptions<ScheduledTaskPayload, TOutput, TInitOutput>): Task<ScheduledTaskPayload, TOutput>;
|
|
230
430
|
/**
|
|
231
|
-
*
|
|
232
|
-
* @param
|
|
233
|
-
* @
|
|
431
|
+
* Creates a new schedule
|
|
432
|
+
* @param options
|
|
433
|
+
* @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
|
|
434
|
+
* @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
|
|
435
|
+
* @param options.timezone - An optional timezone for the schedule in the IANA format (e.g. `America/Los_Angeles`). Defaults to "UTC".
|
|
436
|
+
* @param options.externalId - An optional external identifier for the schedule
|
|
437
|
+
* @param options.deduplicationKey - An optional deduplication key for the schedule
|
|
438
|
+
* @returns The created schedule
|
|
234
439
|
*/
|
|
235
|
-
declare function
|
|
440
|
+
declare function create$1(options: CreateScheduleOptions): ApiPromise<ScheduleObject>;
|
|
441
|
+
/**
|
|
442
|
+
* Retrieves a schedule
|
|
443
|
+
* @param scheduleId - The ID of the schedule to retrieve
|
|
444
|
+
* @returns The retrieved schedule
|
|
445
|
+
*/
|
|
446
|
+
declare function retrieve$1(scheduleId: string): ApiPromise<ScheduleObject>;
|
|
447
|
+
/**
|
|
448
|
+
* Updates a schedule
|
|
449
|
+
* @param scheduleId - The ID of the schedule to update
|
|
450
|
+
* @param options - The updated schedule options
|
|
451
|
+
* @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
|
|
452
|
+
* @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
|
|
453
|
+
* @param options.timezone - An optional timezone for the schedule in the IANA format (e.g. `America/Los_Angeles`). Defaults to "UTC".
|
|
454
|
+
* @param options.externalId - An optional external identifier for the schedule
|
|
455
|
+
* @returns The updated schedule
|
|
456
|
+
*/
|
|
457
|
+
declare function update$1(scheduleId: string, options: UpdateScheduleOptions): ApiPromise<ScheduleObject>;
|
|
458
|
+
/**
|
|
459
|
+
* Deletes a schedule
|
|
460
|
+
* @param scheduleId - The ID of the schedule to delete
|
|
461
|
+
*/
|
|
462
|
+
declare function del$1(scheduleId: string): ApiPromise<DeletedScheduleObject>;
|
|
463
|
+
/**
|
|
464
|
+
* Deactivates a schedule
|
|
465
|
+
* @param scheduleId - The ID of the schedule to deactivate
|
|
466
|
+
*/
|
|
467
|
+
declare function deactivate(scheduleId: string): ApiPromise<ScheduleObject>;
|
|
468
|
+
/**
|
|
469
|
+
* Activates a schedule
|
|
470
|
+
* @param scheduleId - The ID of the schedule to activate
|
|
471
|
+
*/
|
|
472
|
+
declare function activate(scheduleId: string): ApiPromise<ScheduleObject>;
|
|
473
|
+
/**
|
|
474
|
+
* Lists schedules
|
|
475
|
+
* @param options - The list options
|
|
476
|
+
* @param options.page - The page number
|
|
477
|
+
* @param options.perPage - The number of schedules per page
|
|
478
|
+
* @returns The list of schedules
|
|
479
|
+
*/
|
|
480
|
+
declare function list$1(options?: ListScheduleOptions): OffsetLimitPagePromise<typeof ScheduleObject>;
|
|
481
|
+
/**
|
|
482
|
+
* Lists the possible timezones we support
|
|
483
|
+
* @param excludeUtc - By default "UTC" is included and is first. If true, "UTC" will be excluded.
|
|
484
|
+
*/
|
|
485
|
+
declare function timezones(options?: {
|
|
486
|
+
excludeUtc?: boolean;
|
|
487
|
+
}): ApiPromise<{
|
|
488
|
+
timezones: string[];
|
|
489
|
+
}>;
|
|
236
490
|
|
|
237
|
-
declare
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
timeoutInMs?: number;
|
|
491
|
+
declare const index_activate: typeof activate;
|
|
492
|
+
declare const index_deactivate: typeof deactivate;
|
|
493
|
+
declare const index_task: typeof task;
|
|
494
|
+
declare const index_timezones: typeof timezones;
|
|
495
|
+
declare namespace index {
|
|
496
|
+
export { index_activate as activate, create$1 as create, index_deactivate as deactivate, del$1 as del, list$1 as list, retrieve$1 as retrieve, index_task as task, index_timezones as timezones, update$1 as update };
|
|
244
497
|
}
|
|
245
|
-
declare function retryFetch(input: RequestInfo | URL, init?: RetryFetchRequestInit | undefined): Promise<Response>;
|
|
246
|
-
declare const retry: {
|
|
247
|
-
onThrow: typeof onThrow;
|
|
248
|
-
fetch: typeof retryFetch;
|
|
249
|
-
interceptFetch: (...handlers: Array<HttpHandler>) => {
|
|
250
|
-
run: <T>(fn: (...args: any[]) => Promise<T>) => Promise<T>;
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
498
|
|
|
254
|
-
|
|
499
|
+
declare function upload(projectRef: string, slug: string, params: ImportEnvironmentVariablesParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
500
|
+
declare function upload(params: ImportEnvironmentVariablesParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
501
|
+
declare function list(projectRef: string, slug: string): ApiPromise<EnvironmentVariables>;
|
|
502
|
+
declare function list(): ApiPromise<EnvironmentVariables>;
|
|
503
|
+
declare function create(projectRef: string, slug: string, params: CreateEnvironmentVariableParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
504
|
+
declare function create(params: CreateEnvironmentVariableParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
505
|
+
declare function retrieve(projectRef: string, slug: string, name: string): ApiPromise<EnvironmentVariableValue>;
|
|
506
|
+
declare function retrieve(name: string): ApiPromise<EnvironmentVariableValue>;
|
|
507
|
+
declare function del(projectRef: string, slug: string, name: string): ApiPromise<EnvironmentVariableResponseBody>;
|
|
508
|
+
declare function del(name: string): ApiPromise<EnvironmentVariableResponseBody>;
|
|
509
|
+
declare function update(projectRef: string, slug: string, name: string, params: UpdateEnvironmentVariableParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
510
|
+
declare function update(name: string, params: UpdateEnvironmentVariableParams): ApiPromise<EnvironmentVariableResponseBody>;
|
|
511
|
+
|
|
512
|
+
declare const envvars_CreateEnvironmentVariableParams: typeof CreateEnvironmentVariableParams;
|
|
513
|
+
declare const envvars_ImportEnvironmentVariablesParams: typeof ImportEnvironmentVariablesParams;
|
|
514
|
+
declare const envvars_create: typeof create;
|
|
515
|
+
declare const envvars_del: typeof del;
|
|
516
|
+
declare const envvars_list: typeof list;
|
|
517
|
+
declare const envvars_retrieve: typeof retrieve;
|
|
518
|
+
declare const envvars_update: typeof update;
|
|
519
|
+
declare const envvars_upload: typeof upload;
|
|
520
|
+
declare namespace envvars {
|
|
521
|
+
export { envvars_CreateEnvironmentVariableParams as CreateEnvironmentVariableParams, envvars_ImportEnvironmentVariablesParams as ImportEnvironmentVariablesParams, envvars_create as create, envvars_del as del, envvars_list as list, envvars_retrieve as retrieve, envvars_update as update, envvars_upload as upload };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
|
|
526
|
+
* @param options The API client configuration.
|
|
527
|
+
* @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
|
|
528
|
+
* @param options.secretKey The secret key to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
*
|
|
532
|
+
* ```typescript
|
|
533
|
+
* import { configure } from "@trigger.dev/sdk/v3";
|
|
534
|
+
*
|
|
535
|
+
* configure({
|
|
536
|
+
* baseURL: "https://api.trigger.dev",
|
|
537
|
+
* secretKey: "tr_dev_1234567890"
|
|
538
|
+
* });
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
declare function configure(options: ApiClientConfiguration): void;
|
|
542
|
+
|
|
543
|
+
export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type ComputeUsage, type Context, type CurrentUsage, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, configure, createCache, envvars, queue, retry, runs, index as schedules, task$1 as task, usage, wait };
|