@trigger.dev/sdk 3.0.0-beta.26 → 3.0.0-beta.28

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.
@@ -1,7 +1,53 @@
1
- import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult } from '@trigger.dev/core/v3';
2
- export { APIError, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, RetryOptions, ProjectConfig as TriggerConfig, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
1
+ import { RetryOptions, FetchRetryOptions, TaskRunContext, QueueOptions, InitOutput, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, RetrieveRunResponse, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult, ApiClientConfiguration } from '@trigger.dev/core/v3';
2
+ export { APIError, ApiClientConfiguration, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, 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];
@@ -285,56 +331,12 @@ declare const wait: {
285
331
  }) => Promise<void>;
286
332
  };
287
333
 
288
- type CacheMetadata = {
289
- createdTime: number;
290
- ttl?: number | null;
291
- };
292
- type CacheEntry<Value = unknown> = {
293
- metadata: CacheMetadata;
294
- value: Value;
295
- };
296
- type Eventually<Value> = Value | null | undefined | Promise<Value | null | undefined>;
297
- type CacheStore<Value = any> = {
298
- name?: string;
299
- get: (key: string) => Eventually<CacheEntry<Value>>;
300
- set: (key: string, value: CacheEntry<Value>) => unknown | Promise<unknown>;
301
- delete: (key: string) => unknown | Promise<unknown>;
302
- };
303
- type CacheFunction = <Value>(cacheKey: string, fn: () => Promise<Value> | Value) => Promise<Value> | Value;
304
- declare class InMemoryCache<Value = any> {
305
- private _cache;
306
- get(key: string): Eventually<CacheEntry<Value>>;
307
- set(key: string, value: CacheEntry<Value>): unknown;
308
- delete(key: string): unknown;
309
- }
310
- /**
311
- * Create a cache function that uses the provided store to cache values. Using InMemoryCache is safe because each task run is isolated.
312
- * @param store
313
- * @returns
314
- */
315
- declare function createCache(store: CacheStore): CacheFunction;
316
-
317
- declare function onThrow<T>(fn: (options: {
318
- attempt: number;
319
- maxAttempts: number;
320
- }) => Promise<T>, options: RetryOptions): Promise<T>;
321
- interface RetryFetchRequestInit extends RequestInit {
322
- retry?: FetchRetryOptions;
323
- timeoutInMs?: number;
324
- }
325
- declare function retryFetch(input: RequestInfo | URL, init?: RetryFetchRequestInit | undefined): Promise<Response>;
326
- declare const retry: {
327
- onThrow: typeof onThrow;
328
- fetch: typeof retryFetch;
329
- interceptFetch: (...handlers: Array<HttpHandler>) => {
330
- run: <T>(fn: (...args: any[]) => Promise<T>) => Promise<T>;
331
- };
332
- };
333
-
334
334
  declare const runs: {
335
335
  replay: typeof replayRun;
336
336
  cancel: typeof cancelRun;
337
+ retrieve: typeof retrieveRun;
337
338
  };
339
+ declare function retrieveRun(runId: string): Promise<RetrieveRunResponse>;
338
340
  declare function replayRun(runId: string): Promise<ReplayRunResponse>;
339
341
  declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
340
342
 
@@ -401,4 +403,23 @@ declare namespace index {
401
403
  export { index_activate as activate, index_create as create, index_deactivate as deactivate, index_del as del, index_list as list, index_retrieve as retrieve, index_task as task, index_update as update };
402
404
  }
403
405
 
404
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
406
+ /**
407
+ * Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
408
+ * @param options The API client configuration.
409
+ * @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
410
+ * @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.
411
+ *
412
+ * @example
413
+ *
414
+ * ```typescript
415
+ * import { configure } from "@trigger.dev/sdk/v3";
416
+ *
417
+ * configure({
418
+ * baseURL: "https://api.trigger.dev",
419
+ * secretKey: "tr_dev_1234567890"
420
+ * });
421
+ * ```
422
+ */
423
+ declare function configure(options: ApiClientConfiguration): void;
424
+
425
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, configure, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
@@ -1,7 +1,53 @@
1
- import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult } from '@trigger.dev/core/v3';
2
- export { APIError, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, RetryOptions, ProjectConfig as TriggerConfig, UnprocessableEntityError, logger } from '@trigger.dev/core/v3';
1
+ import { RetryOptions, FetchRetryOptions, TaskRunContext, QueueOptions, InitOutput, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, StartFnParams, SuccessFnParams, FailureFnParams, RetrieveRunResponse, ReplayRunResponse, CanceledRunResponse, ScheduledTaskPayload, CreateScheduleOptions, ScheduleObject, UpdateScheduleOptions, DeletedScheduleObject, ListScheduleOptions, ListSchedulesResult, ApiClientConfiguration } from '@trigger.dev/core/v3';
2
+ export { APIError, ApiClientConfiguration, AuthenticationError, BadRequestError, ConflictError, HandleErrorArgs, HandleErrorFunction, InternalServerError, LogLevel, NotFoundError, PermissionDeniedError, RateLimitError, 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];
@@ -285,56 +331,12 @@ declare const wait: {
285
331
  }) => Promise<void>;
286
332
  };
287
333
 
288
- type CacheMetadata = {
289
- createdTime: number;
290
- ttl?: number | null;
291
- };
292
- type CacheEntry<Value = unknown> = {
293
- metadata: CacheMetadata;
294
- value: Value;
295
- };
296
- type Eventually<Value> = Value | null | undefined | Promise<Value | null | undefined>;
297
- type CacheStore<Value = any> = {
298
- name?: string;
299
- get: (key: string) => Eventually<CacheEntry<Value>>;
300
- set: (key: string, value: CacheEntry<Value>) => unknown | Promise<unknown>;
301
- delete: (key: string) => unknown | Promise<unknown>;
302
- };
303
- type CacheFunction = <Value>(cacheKey: string, fn: () => Promise<Value> | Value) => Promise<Value> | Value;
304
- declare class InMemoryCache<Value = any> {
305
- private _cache;
306
- get(key: string): Eventually<CacheEntry<Value>>;
307
- set(key: string, value: CacheEntry<Value>): unknown;
308
- delete(key: string): unknown;
309
- }
310
- /**
311
- * Create a cache function that uses the provided store to cache values. Using InMemoryCache is safe because each task run is isolated.
312
- * @param store
313
- * @returns
314
- */
315
- declare function createCache(store: CacheStore): CacheFunction;
316
-
317
- declare function onThrow<T>(fn: (options: {
318
- attempt: number;
319
- maxAttempts: number;
320
- }) => Promise<T>, options: RetryOptions): Promise<T>;
321
- interface RetryFetchRequestInit extends RequestInit {
322
- retry?: FetchRetryOptions;
323
- timeoutInMs?: number;
324
- }
325
- declare function retryFetch(input: RequestInfo | URL, init?: RetryFetchRequestInit | undefined): Promise<Response>;
326
- declare const retry: {
327
- onThrow: typeof onThrow;
328
- fetch: typeof retryFetch;
329
- interceptFetch: (...handlers: Array<HttpHandler>) => {
330
- run: <T>(fn: (...args: any[]) => Promise<T>) => Promise<T>;
331
- };
332
- };
333
-
334
334
  declare const runs: {
335
335
  replay: typeof replayRun;
336
336
  cancel: typeof cancelRun;
337
+ retrieve: typeof retrieveRun;
337
338
  };
339
+ declare function retrieveRun(runId: string): Promise<RetrieveRunResponse>;
338
340
  declare function replayRun(runId: string): Promise<ReplayRunResponse>;
339
341
  declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
340
342
 
@@ -401,4 +403,23 @@ declare namespace index {
401
403
  export { index_activate as activate, index_create as create, index_deactivate as deactivate, index_del as del, index_list as list, index_retrieve as retrieve, index_task as task, index_update as update };
402
404
  }
403
405
 
404
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
406
+ /**
407
+ * Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables.
408
+ * @param options The API client configuration.
409
+ * @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`)
410
+ * @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.
411
+ *
412
+ * @example
413
+ *
414
+ * ```typescript
415
+ * import { configure } from "@trigger.dev/sdk/v3";
416
+ *
417
+ * configure({
418
+ * baseURL: "https://api.trigger.dev",
419
+ * secretKey: "tr_dev_1234567890"
420
+ * });
421
+ * ```
422
+ */
423
+ declare function configure(options: ApiClientConfiguration): void;
424
+
425
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type Task, type TaskOptions, type WaitOptions, configure, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };