@trigger.dev/sdk 3.0.0-beta.12 → 3.0.0-beta.14

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,5 +1,5 @@
1
- import { TaskRunContext, InitOutput, RetryOptions, QueueOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse } from '@trigger.dev/core/v3';
2
- export { HandleErrorArgs, HandleErrorFunction, LogLevel, RetryOptions, ProjectConfig as TriggerConfig, logger } from '@trigger.dev/core/v3';
1
+ import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, 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';
3
3
  import { HttpHandler } from 'msw';
4
4
 
5
5
  type Context = TaskRunContext;
@@ -9,6 +9,9 @@ type RequireOne<T, K extends keyof T> = {
9
9
  [P in K]-?: T[P];
10
10
  };
11
11
  type Queue = RequireOne<QueueOptions, "name">;
12
+ declare function queue(options: {
13
+ name: string;
14
+ } & QueueOptions): Queue;
12
15
  type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any> = {
13
16
  /** An id for your task. This must be unique inside your project and not change between versions. */
14
17
  id: string;
@@ -125,7 +128,8 @@ type BatchResult<TOutput = any> = {
125
128
  id: string;
126
129
  runs: TaskRunResult<TOutput>[];
127
130
  };
128
- type Task<TInput, TOutput = any> = {
131
+ interface Task<TInput, TOutput = any> {
132
+ id: string;
129
133
  trigger: (params: {
130
134
  payload: TInput;
131
135
  options?: TaskRunOptions;
@@ -135,7 +139,6 @@ type Task<TInput, TOutput = any> = {
135
139
  payload: TInput;
136
140
  options?: TaskRunOptions;
137
141
  }[];
138
- batchOptions?: BatchRunOptions;
139
142
  }) => Promise<InvokeBatchHandle>;
140
143
  triggerAndWait: (params: {
141
144
  payload: TInput;
@@ -146,9 +149,8 @@ type Task<TInput, TOutput = any> = {
146
149
  payload: TInput;
147
150
  options?: TaskRunOptions;
148
151
  }[];
149
- batchOptions?: BatchRunOptions;
150
152
  }) => Promise<BatchResult<TOutput>>;
151
- };
153
+ }
152
154
  type TaskRunOptions = {
153
155
  idempotencyKey?: string;
154
156
  maxAttempts?: number;
@@ -158,9 +160,6 @@ type TaskRunOptions = {
158
160
  concurrencyKey?: string;
159
161
  };
160
162
  type TaskRunConcurrencyOptions = Queue;
161
- type BatchRunOptions = TaskRunOptions & {
162
- maxConcurrency?: number;
163
- };
164
163
 
165
164
  /** Creates a task that can be triggered
166
165
  * @param options - Task options
@@ -180,7 +179,7 @@ type BatchRunOptions = TaskRunOptions & {
180
179
  *
181
180
  * @returns A task that can be triggered
182
181
  */
183
- declare function task<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
182
+ declare function task$1<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
184
183
 
185
184
  type WaitOptions = {
186
185
  seconds: number;
@@ -258,4 +257,67 @@ declare const runs: {
258
257
  declare function replayRun(runId: string): Promise<ReplayRunResponse>;
259
258
  declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
260
259
 
261
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, retry, runs, task, wait };
260
+ declare function task<TOutput, TInitOutput extends InitOutput>(params: TaskOptions<ScheduledTaskPayload, TOutput, TInitOutput>): Task<ScheduledTaskPayload, TOutput>;
261
+ /**
262
+ * Creates a new schedule
263
+ * @param options
264
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
265
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
266
+ * @param options.externalId - An optional external identifier for the schedule
267
+ * @param options.deduplicationKey - An optional deduplication key for the schedule
268
+ * @returns The created schedule
269
+ */
270
+ declare function create(options: CreateScheduleOptions): Promise<ScheduleObject>;
271
+ /**
272
+ * Retrieves a schedule
273
+ * @param scheduleId - The ID of the schedule to retrieve
274
+ * @returns The retrieved schedule
275
+ */
276
+ declare function retrieve(scheduleId: string): Promise<ScheduleObject>;
277
+ /**
278
+ * Updates a schedule
279
+ * @param scheduleId - The ID of the schedule to update
280
+ * @param options - The updated schedule options
281
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
282
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
283
+ * @param options.externalId - An optional external identifier for the schedule
284
+ * @returns The updated schedule
285
+ */
286
+ declare function update(scheduleId: string, options: UpdateScheduleOptions): Promise<ScheduleObject>;
287
+ /**
288
+ * Deletes a schedule
289
+ * @param scheduleId - The ID of the schedule to delete
290
+ */
291
+ declare function del(scheduleId: string): Promise<DeletedScheduleObject>;
292
+ /**
293
+ * Deactivates a schedule
294
+ * @param scheduleId - The ID of the schedule to deactivate
295
+ */
296
+ declare function deactivate(scheduleId: string): Promise<ScheduleObject>;
297
+ /**
298
+ * Activates a schedule
299
+ * @param scheduleId - The ID of the schedule to activate
300
+ */
301
+ declare function activate(scheduleId: string): Promise<ScheduleObject>;
302
+ /**
303
+ * Lists schedules
304
+ * @param options - The list options
305
+ * @param options.page - The page number
306
+ * @param options.perPage - The number of schedules per page
307
+ * @returns The list of schedules
308
+ */
309
+ declare function list(options?: ListScheduleOptions): Promise<ListSchedulesResult>;
310
+
311
+ declare const index_activate: typeof activate;
312
+ declare const index_create: typeof create;
313
+ declare const index_deactivate: typeof deactivate;
314
+ declare const index_del: typeof del;
315
+ declare const index_list: typeof list;
316
+ declare const index_retrieve: typeof retrieve;
317
+ declare const index_task: typeof task;
318
+ declare const index_update: typeof update;
319
+ declare namespace index {
320
+ 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 };
321
+ }
322
+
323
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
@@ -1,5 +1,5 @@
1
- import { TaskRunContext, InitOutput, RetryOptions, QueueOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, FetchRetryOptions, ReplayRunResponse, CanceledRunResponse } from '@trigger.dev/core/v3';
2
- export { HandleErrorArgs, HandleErrorFunction, LogLevel, RetryOptions, ProjectConfig as TriggerConfig, logger } from '@trigger.dev/core/v3';
1
+ import { TaskRunContext, QueueOptions, InitOutput, RetryOptions, MachineCpu, MachineMemory, RunFnParams, InitFnParams, HandleErrorFnParams, HandleErrorResult, MiddlewareFnParams, SuccessFnParams, 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';
3
3
  import { HttpHandler } from 'msw';
4
4
 
5
5
  type Context = TaskRunContext;
@@ -9,6 +9,9 @@ type RequireOne<T, K extends keyof T> = {
9
9
  [P in K]-?: T[P];
10
10
  };
11
11
  type Queue = RequireOne<QueueOptions, "name">;
12
+ declare function queue(options: {
13
+ name: string;
14
+ } & QueueOptions): Queue;
12
15
  type TaskOptions<TPayload, TOutput = any, TInitOutput extends InitOutput = any> = {
13
16
  /** An id for your task. This must be unique inside your project and not change between versions. */
14
17
  id: string;
@@ -125,7 +128,8 @@ type BatchResult<TOutput = any> = {
125
128
  id: string;
126
129
  runs: TaskRunResult<TOutput>[];
127
130
  };
128
- type Task<TInput, TOutput = any> = {
131
+ interface Task<TInput, TOutput = any> {
132
+ id: string;
129
133
  trigger: (params: {
130
134
  payload: TInput;
131
135
  options?: TaskRunOptions;
@@ -135,7 +139,6 @@ type Task<TInput, TOutput = any> = {
135
139
  payload: TInput;
136
140
  options?: TaskRunOptions;
137
141
  }[];
138
- batchOptions?: BatchRunOptions;
139
142
  }) => Promise<InvokeBatchHandle>;
140
143
  triggerAndWait: (params: {
141
144
  payload: TInput;
@@ -146,9 +149,8 @@ type Task<TInput, TOutput = any> = {
146
149
  payload: TInput;
147
150
  options?: TaskRunOptions;
148
151
  }[];
149
- batchOptions?: BatchRunOptions;
150
152
  }) => Promise<BatchResult<TOutput>>;
151
- };
153
+ }
152
154
  type TaskRunOptions = {
153
155
  idempotencyKey?: string;
154
156
  maxAttempts?: number;
@@ -158,9 +160,6 @@ type TaskRunOptions = {
158
160
  concurrencyKey?: string;
159
161
  };
160
162
  type TaskRunConcurrencyOptions = Queue;
161
- type BatchRunOptions = TaskRunOptions & {
162
- maxConcurrency?: number;
163
- };
164
163
 
165
164
  /** Creates a task that can be triggered
166
165
  * @param options - Task options
@@ -180,7 +179,7 @@ type BatchRunOptions = TaskRunOptions & {
180
179
  *
181
180
  * @returns A task that can be triggered
182
181
  */
183
- declare function task<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
182
+ declare function task$1<TInput, TOutput = any, TInitOutput extends InitOutput = any>(options: TaskOptions<TInput, TOutput, TInitOutput>): Task<TInput, TOutput>;
184
183
 
185
184
  type WaitOptions = {
186
185
  seconds: number;
@@ -258,4 +257,67 @@ declare const runs: {
258
257
  declare function replayRun(runId: string): Promise<ReplayRunResponse>;
259
258
  declare function cancelRun(runId: string): Promise<CanceledRunResponse>;
260
259
 
261
- export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, retry, runs, task, wait };
260
+ declare function task<TOutput, TInitOutput extends InitOutput>(params: TaskOptions<ScheduledTaskPayload, TOutput, TInitOutput>): Task<ScheduledTaskPayload, TOutput>;
261
+ /**
262
+ * Creates a new schedule
263
+ * @param options
264
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
265
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
266
+ * @param options.externalId - An optional external identifier for the schedule
267
+ * @param options.deduplicationKey - An optional deduplication key for the schedule
268
+ * @returns The created schedule
269
+ */
270
+ declare function create(options: CreateScheduleOptions): Promise<ScheduleObject>;
271
+ /**
272
+ * Retrieves a schedule
273
+ * @param scheduleId - The ID of the schedule to retrieve
274
+ * @returns The retrieved schedule
275
+ */
276
+ declare function retrieve(scheduleId: string): Promise<ScheduleObject>;
277
+ /**
278
+ * Updates a schedule
279
+ * @param scheduleId - The ID of the schedule to update
280
+ * @param options - The updated schedule options
281
+ * @param options.task - The identifier of the task to be scheduled (Must already exist and be a scheduled task)
282
+ * @param options.cron - The cron expression for the schedule (e.g. `0 0 * * *`)
283
+ * @param options.externalId - An optional external identifier for the schedule
284
+ * @returns The updated schedule
285
+ */
286
+ declare function update(scheduleId: string, options: UpdateScheduleOptions): Promise<ScheduleObject>;
287
+ /**
288
+ * Deletes a schedule
289
+ * @param scheduleId - The ID of the schedule to delete
290
+ */
291
+ declare function del(scheduleId: string): Promise<DeletedScheduleObject>;
292
+ /**
293
+ * Deactivates a schedule
294
+ * @param scheduleId - The ID of the schedule to deactivate
295
+ */
296
+ declare function deactivate(scheduleId: string): Promise<ScheduleObject>;
297
+ /**
298
+ * Activates a schedule
299
+ * @param scheduleId - The ID of the schedule to activate
300
+ */
301
+ declare function activate(scheduleId: string): Promise<ScheduleObject>;
302
+ /**
303
+ * Lists schedules
304
+ * @param options - The list options
305
+ * @param options.page - The page number
306
+ * @param options.perPage - The number of schedules per page
307
+ * @returns The list of schedules
308
+ */
309
+ declare function list(options?: ListScheduleOptions): Promise<ListSchedulesResult>;
310
+
311
+ declare const index_activate: typeof activate;
312
+ declare const index_create: typeof create;
313
+ declare const index_deactivate: typeof deactivate;
314
+ declare const index_del: typeof del;
315
+ declare const index_list: typeof list;
316
+ declare const index_retrieve: typeof retrieve;
317
+ declare const index_task: typeof task;
318
+ declare const index_update: typeof update;
319
+ declare namespace index {
320
+ 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 };
321
+ }
322
+
323
+ export { type CacheEntry, type CacheFunction, type CacheMetadata, type CacheStore, type Context, type Eventually, InMemoryCache, type WaitOptions, createCache, queue, retry, runs, index as schedules, task$1 as task, wait };
package/dist/v3/index.js CHANGED
@@ -8,43 +8,52 @@ var node_async_hooks = require('node:async_hooks');
8
8
  var __defProp = Object.defineProperty;
9
9
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
10
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
11
15
  var __publicField = (obj, key, value) => {
12
16
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
17
  return value;
14
18
  };
15
19
 
16
20
  // package.json
17
- var version = "3.0.0-beta.12";
21
+ var version = "3.0.0-beta.14";
18
22
  var tracer = new v3.TriggerTracer({
19
23
  name: "@trigger.dev/sdk",
20
24
  version
21
25
  });
22
26
 
23
27
  // src/v3/shared.ts
28
+ function queue(options) {
29
+ return options;
30
+ }
31
+ __name(queue, "queue");
24
32
  function createTask(params) {
25
- const task2 = {
33
+ const task3 = {
34
+ id: params.id,
26
35
  trigger: async ({ payload, options }) => {
27
36
  const apiClient = v3.apiClientManager.client;
28
37
  if (!apiClient) {
29
38
  throw apiClientMissingError();
30
39
  }
31
- const taskMetadata = v3.runtime.getTaskMetadata(params.id);
40
+ const taskMetadata = v3.taskCatalog.getTaskMetadata(params.id);
41
+ const payloadPacket = await v3.stringifyIO(payload);
32
42
  const handle = await tracer.startActiveSpan(taskMetadata ? "Trigger" : `${params.id} trigger()`, async (span) => {
33
43
  const response = await apiClient.triggerTask(params.id, {
34
- payload,
44
+ payload: payloadPacket.data,
35
45
  options: {
36
46
  queue: params.queue,
37
47
  concurrencyKey: options?.concurrencyKey,
38
- test: v3.taskContextManager.ctx?.run.isTest
48
+ test: v3.taskContextManager.ctx?.run.isTest,
49
+ payloadType: payloadPacket.dataType,
50
+ idempotencyKey: options?.idempotencyKey
39
51
  }
40
52
  }, {
41
53
  spanParentAsLink: true
42
54
  });
43
- if (!response.ok) {
44
- throw new Error(response.error);
45
- }
46
- span.setAttribute("messaging.message.id", response.data.id);
47
- return response.data;
55
+ span.setAttribute("messaging.message.id", response.id);
56
+ return response;
48
57
  }, {
49
58
  kind: api.SpanKind.PRODUCER,
50
59
  attributes: {
@@ -72,25 +81,27 @@ function createTask(params) {
72
81
  if (!apiClient) {
73
82
  throw apiClientMissingError();
74
83
  }
75
- const taskMetadata = v3.runtime.getTaskMetadata(params.id);
84
+ const taskMetadata = v3.taskCatalog.getTaskMetadata(params.id);
76
85
  const response = await tracer.startActiveSpan(taskMetadata ? "Batch trigger" : `${params.id} batchTrigger()`, async (span) => {
77
86
  const response2 = await apiClient.batchTriggerTask(params.id, {
78
- items: items.map((item) => ({
79
- payload: item.payload,
80
- options: {
81
- queue: item.options?.queue ?? params.queue,
82
- concurrencyKey: item.options?.concurrencyKey,
83
- test: v3.taskContextManager.ctx?.run.isTest
84
- }
87
+ items: await Promise.all(items.map(async (item) => {
88
+ const payloadPacket = await v3.stringifyIO(item.payload);
89
+ return {
90
+ payload: payloadPacket.data,
91
+ options: {
92
+ queue: item.options?.queue ?? params.queue,
93
+ concurrencyKey: item.options?.concurrencyKey,
94
+ test: v3.taskContextManager.ctx?.run.isTest,
95
+ payloadType: payloadPacket.dataType,
96
+ idempotencyKey: item.options?.idempotencyKey
97
+ }
98
+ };
85
99
  }))
86
100
  }, {
87
101
  spanParentAsLink: true
88
102
  });
89
- if (!response2.ok) {
90
- throw new Error(response2.error);
91
- }
92
- span.setAttribute("messaging.message.id", response2.data.batchId);
93
- return response2.data;
103
+ span.setAttribute("messaging.message.id", response2.batchId);
104
+ return response2;
94
105
  }, {
95
106
  kind: api.SpanKind.PRODUCER,
96
107
  attributes: {
@@ -123,24 +134,24 @@ function createTask(params) {
123
134
  if (!apiClient) {
124
135
  throw apiClientMissingError();
125
136
  }
126
- const taskMetadata = v3.runtime.getTaskMetadata(params.id);
137
+ const taskMetadata = v3.taskCatalog.getTaskMetadata(params.id);
138
+ const payloadPacket = await v3.stringifyIO(payload);
127
139
  return await tracer.startActiveSpan(taskMetadata ? "Trigger" : `${params.id} triggerAndWait()`, async (span) => {
128
140
  const response = await apiClient.triggerTask(params.id, {
129
- payload,
141
+ payload: payloadPacket.data,
130
142
  options: {
131
143
  dependentAttempt: ctx.attempt.id,
132
144
  lockToVersion: v3.taskContextManager.worker?.version,
133
145
  queue: params.queue,
134
146
  concurrencyKey: options?.concurrencyKey,
135
- test: v3.taskContextManager.ctx?.run.isTest
147
+ test: v3.taskContextManager.ctx?.run.isTest,
148
+ payloadType: payloadPacket.dataType,
149
+ idempotencyKey: options?.idempotencyKey
136
150
  }
137
151
  });
138
- if (!response.ok) {
139
- throw new Error(response.error);
140
- }
141
- span.setAttribute("messaging.message.id", response.data.id);
152
+ span.setAttribute("messaging.message.id", response.id);
142
153
  const result = await v3.runtime.waitForTask({
143
- id: response.data.id,
154
+ id: response.id,
144
155
  ctx
145
156
  });
146
157
  const runResult = await handleTaskRunExecutionResult(result);
@@ -177,27 +188,29 @@ function createTask(params) {
177
188
  if (!apiClient) {
178
189
  throw apiClientMissingError();
179
190
  }
180
- const taskMetadata = v3.runtime.getTaskMetadata(params.id);
191
+ const taskMetadata = v3.taskCatalog.getTaskMetadata(params.id);
181
192
  return await tracer.startActiveSpan(taskMetadata ? "Batch trigger" : `${params.id} batchTriggerAndWait()`, async (span) => {
182
193
  const response = await apiClient.batchTriggerTask(params.id, {
183
- items: items.map((item) => ({
184
- payload: item.payload,
185
- options: {
186
- lockToVersion: v3.taskContextManager.worker?.version,
187
- queue: item.options?.queue ?? params.queue,
188
- concurrencyKey: item.options?.concurrencyKey,
189
- test: v3.taskContextManager.ctx?.run.isTest
190
- }
194
+ items: await Promise.all(items.map(async (item) => {
195
+ const payloadPacket = await v3.stringifyIO(item.payload);
196
+ return {
197
+ payload: payloadPacket.data,
198
+ options: {
199
+ lockToVersion: v3.taskContextManager.worker?.version,
200
+ queue: item.options?.queue ?? params.queue,
201
+ concurrencyKey: item.options?.concurrencyKey,
202
+ test: v3.taskContextManager.ctx?.run.isTest,
203
+ payloadType: payloadPacket.dataType,
204
+ idempotencyKey: item.options?.idempotencyKey
205
+ }
206
+ };
191
207
  })),
192
208
  dependentAttempt: ctx.attempt.id
193
209
  });
194
- if (!response.ok) {
195
- throw new Error(response.error);
196
- }
197
- span.setAttribute("messaging.message.id", response.data.batchId);
210
+ span.setAttribute("messaging.message.id", response.batchId);
198
211
  const result = await v3.runtime.waitForBatch({
199
- id: response.data.batchId,
200
- runs: response.data.runs,
212
+ id: response.batchId,
213
+ runs: response.runs,
201
214
  ctx
202
215
  });
203
216
  const runs2 = await handleBatchTaskRunExecutionResult(result.items);
@@ -228,27 +241,24 @@ function createTask(params) {
228
241
  });
229
242
  }
230
243
  };
231
- Object.defineProperty(task2, "__trigger", {
232
- value: {
233
- id: params.id,
234
- packageVersion: version,
235
- queue: params.queue,
236
- retry: params.retry ? {
237
- ...v3.defaultRetryOptions,
238
- ...params.retry
239
- } : void 0,
240
- machine: params.machine,
241
- fns: {
242
- run: params.run,
243
- init: params.init,
244
- cleanup: params.cleanup,
245
- middleware: params.middleware,
246
- handleError: params.handleError
247
- }
248
- },
249
- enumerable: false
244
+ v3.taskCatalog.registerTaskMetadata({
245
+ id: params.id,
246
+ packageVersion: version,
247
+ queue: params.queue,
248
+ retry: params.retry ? {
249
+ ...v3.defaultRetryOptions,
250
+ ...params.retry
251
+ } : void 0,
252
+ machine: params.machine,
253
+ fns: {
254
+ run: params.run,
255
+ init: params.init,
256
+ cleanup: params.cleanup,
257
+ middleware: params.middleware,
258
+ handleError: params.handleError
259
+ }
250
260
  });
251
- return task2;
261
+ return task3;
252
262
  }
253
263
  __name(createTask, "createTask");
254
264
  async function handleBatchTaskRunExecutionResult(items) {
@@ -887,11 +897,7 @@ async function replayRun(runId) {
887
897
  if (!apiClient) {
888
898
  throw apiClientMissingError();
889
899
  }
890
- const response = await apiClient.replayRun(runId);
891
- if (!response.ok) {
892
- throw new Error(response.error);
893
- }
894
- return response.data;
900
+ return await apiClient.replayRun(runId);
895
901
  }
896
902
  __name(replayRun, "replayRun");
897
903
  async function cancelRun(runId) {
@@ -899,22 +905,133 @@ async function cancelRun(runId) {
899
905
  if (!apiClient) {
900
906
  throw apiClientMissingError();
901
907
  }
902
- const response = await apiClient.cancelRun(runId);
903
- if (!response.ok) {
904
- throw new Error(response.error);
905
- }
906
- return response.data;
908
+ return await apiClient.cancelRun(runId);
907
909
  }
908
910
  __name(cancelRun, "cancelRun");
909
911
 
912
+ // src/v3/schedules/index.ts
913
+ var schedules_exports = {};
914
+ __export(schedules_exports, {
915
+ activate: () => activate,
916
+ create: () => create,
917
+ deactivate: () => deactivate,
918
+ del: () => del,
919
+ list: () => list,
920
+ retrieve: () => retrieve,
921
+ task: () => task2,
922
+ update: () => update
923
+ });
924
+ function task2(params) {
925
+ const task3 = createTask(params);
926
+ v3.taskCatalog.updateTaskMetadata(task3.id, {
927
+ triggerSource: "schedule"
928
+ });
929
+ return task3;
930
+ }
931
+ __name(task2, "task");
932
+ async function create(options) {
933
+ const apiClient = v3.apiClientManager.client;
934
+ if (!apiClient) {
935
+ throw apiClientMissingError();
936
+ }
937
+ return apiClient.createSchedule(options);
938
+ }
939
+ __name(create, "create");
940
+ async function retrieve(scheduleId) {
941
+ const apiClient = v3.apiClientManager.client;
942
+ if (!apiClient) {
943
+ throw apiClientMissingError();
944
+ }
945
+ return apiClient.retrieveSchedule(scheduleId);
946
+ }
947
+ __name(retrieve, "retrieve");
948
+ async function update(scheduleId, options) {
949
+ const apiClient = v3.apiClientManager.client;
950
+ if (!apiClient) {
951
+ throw apiClientMissingError();
952
+ }
953
+ return apiClient.updateSchedule(scheduleId, options);
954
+ }
955
+ __name(update, "update");
956
+ async function del(scheduleId) {
957
+ const apiClient = v3.apiClientManager.client;
958
+ if (!apiClient) {
959
+ throw apiClientMissingError();
960
+ }
961
+ return apiClient.deleteSchedule(scheduleId);
962
+ }
963
+ __name(del, "del");
964
+ async function deactivate(scheduleId) {
965
+ const apiClient = v3.apiClientManager.client;
966
+ if (!apiClient) {
967
+ throw apiClientMissingError();
968
+ }
969
+ return apiClient.deactivateSchedule(scheduleId);
970
+ }
971
+ __name(deactivate, "deactivate");
972
+ async function activate(scheduleId) {
973
+ const apiClient = v3.apiClientManager.client;
974
+ if (!apiClient) {
975
+ throw apiClientMissingError();
976
+ }
977
+ return apiClient.activateSchedule(scheduleId);
978
+ }
979
+ __name(activate, "activate");
980
+ async function list(options) {
981
+ const apiClient = v3.apiClientManager.client;
982
+ if (!apiClient) {
983
+ throw apiClientMissingError();
984
+ }
985
+ return apiClient.listSchedules(options);
986
+ }
987
+ __name(list, "list");
988
+
989
+ Object.defineProperty(exports, 'APIError', {
990
+ enumerable: true,
991
+ get: function () { return v3.APIError; }
992
+ });
993
+ Object.defineProperty(exports, 'AuthenticationError', {
994
+ enumerable: true,
995
+ get: function () { return v3.AuthenticationError; }
996
+ });
997
+ Object.defineProperty(exports, 'BadRequestError', {
998
+ enumerable: true,
999
+ get: function () { return v3.BadRequestError; }
1000
+ });
1001
+ Object.defineProperty(exports, 'ConflictError', {
1002
+ enumerable: true,
1003
+ get: function () { return v3.ConflictError; }
1004
+ });
1005
+ Object.defineProperty(exports, 'InternalServerError', {
1006
+ enumerable: true,
1007
+ get: function () { return v3.InternalServerError; }
1008
+ });
1009
+ Object.defineProperty(exports, 'NotFoundError', {
1010
+ enumerable: true,
1011
+ get: function () { return v3.NotFoundError; }
1012
+ });
1013
+ Object.defineProperty(exports, 'PermissionDeniedError', {
1014
+ enumerable: true,
1015
+ get: function () { return v3.PermissionDeniedError; }
1016
+ });
1017
+ Object.defineProperty(exports, 'RateLimitError', {
1018
+ enumerable: true,
1019
+ get: function () { return v3.RateLimitError; }
1020
+ });
1021
+ Object.defineProperty(exports, 'UnprocessableEntityError', {
1022
+ enumerable: true,
1023
+ get: function () { return v3.UnprocessableEntityError; }
1024
+ });
910
1025
  Object.defineProperty(exports, 'logger', {
911
1026
  enumerable: true,
912
1027
  get: function () { return v3.logger; }
913
1028
  });
914
1029
  exports.InMemoryCache = InMemoryCache;
915
1030
  exports.createCache = createCache;
1031
+ exports.queue = queue;
916
1032
  exports.retry = retry;
917
1033
  exports.runs = runs;
1034
+ exports.schedules = schedules_exports;
918
1035
  exports.task = task;
919
1036
  exports.wait = wait;
920
1037
  //# sourceMappingURL=out.js.map