@trigger.dev/core 0.0.0-statuses-20230920011059 → 0.0.0-svelte-test-20231206141434

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.js CHANGED
@@ -1,22 +1,12 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var node_process = require('node:process');
4
+ var node_buffer = require('node:buffer');
5
+ var ulidx = require('ulidx');
6
+ var zod = require('zod');
7
+
2
8
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
9
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
10
  var __accessCheck = (obj, member, msg) => {
21
11
  if (!member.has(obj))
22
12
  throw TypeError("Cannot " + msg);
@@ -39,142 +29,6 @@ var __privateMethod = (obj, member, method) => {
39
29
  __accessCheck(obj, member, "access private method");
40
30
  return method;
41
31
  };
42
-
43
- // src/index.ts
44
- var src_exports = {};
45
- __export(src_exports, {
46
- ApiEventLogSchema: () => ApiEventLogSchema,
47
- CachedTaskSchema: () => CachedTaskSchema,
48
- CommonMissingConnectionNotificationPayloadSchema: () => CommonMissingConnectionNotificationPayloadSchema,
49
- CommonMissingConnectionNotificationResolvedPayloadSchema: () => CommonMissingConnectionNotificationResolvedPayloadSchema,
50
- CompleteTaskBodyInputSchema: () => CompleteTaskBodyInputSchema,
51
- ConnectionAuthSchema: () => ConnectionAuthSchema,
52
- CreateExternalConnectionBodySchema: () => CreateExternalConnectionBodySchema,
53
- CreateRunResponseBodySchema: () => CreateRunResponseBodySchema,
54
- CronMetadataSchema: () => CronMetadataSchema,
55
- CronOptionsSchema: () => CronOptionsSchema,
56
- DeliverEventResponseSchema: () => DeliverEventResponseSchema,
57
- DeserializedJsonSchema: () => DeserializedJsonSchema,
58
- DisplayPropertiesSchema: () => DisplayPropertiesSchema,
59
- DisplayPropertySchema: () => DisplayPropertySchema,
60
- DynamicTriggerEndpointMetadataSchema: () => DynamicTriggerEndpointMetadataSchema,
61
- DynamicTriggerMetadataSchema: () => DynamicTriggerMetadataSchema,
62
- ErrorWithStackSchema: () => ErrorWithStackSchema,
63
- EventExampleSchema: () => EventExampleSchema,
64
- EventFilterSchema: () => EventFilterSchema,
65
- EventRuleSchema: () => EventRuleSchema,
66
- EventSpecificationSchema: () => EventSpecificationSchema,
67
- FailTaskBodyInputSchema: () => FailTaskBodyInputSchema,
68
- FetchOperationSchema: () => FetchOperationSchema,
69
- FetchRequestInitSchema: () => FetchRequestInitSchema,
70
- FetchRetryBackoffStrategySchema: () => FetchRetryBackoffStrategySchema,
71
- FetchRetryHeadersStrategySchema: () => FetchRetryHeadersStrategySchema,
72
- FetchRetryOptionsSchema: () => FetchRetryOptionsSchema,
73
- FetchRetryStrategySchema: () => FetchRetryStrategySchema,
74
- GetEventSchema: () => GetEventSchema,
75
- GetRunSchema: () => GetRunSchema,
76
- GetRunStatusesSchema: () => GetRunStatusesSchema,
77
- GetRunsSchema: () => GetRunsSchema,
78
- HandleTriggerSourceSchema: () => HandleTriggerSourceSchema,
79
- HttpSourceRequestHeadersSchema: () => HttpSourceRequestHeadersSchema,
80
- HttpSourceRequestSchema: () => HttpSourceRequestSchema,
81
- HttpSourceResponseSchema: () => HttpSourceResponseSchema,
82
- IndexEndpointResponseSchema: () => IndexEndpointResponseSchema,
83
- InitializeCronScheduleBodySchema: () => InitializeCronScheduleBodySchema,
84
- InitializeTriggerBodySchema: () => InitializeTriggerBodySchema,
85
- IntegrationConfigSchema: () => IntegrationConfigSchema,
86
- IntegrationMetadataSchema: () => IntegrationMetadataSchema,
87
- IntervalMetadataSchema: () => IntervalMetadataSchema,
88
- IntervalOptionsSchema: () => IntervalOptionsSchema,
89
- JobMetadataSchema: () => JobMetadataSchema,
90
- JobRunStatusRecordSchema: () => JobRunStatusRecordSchema,
91
- LogMessageSchema: () => LogMessageSchema,
92
- Logger: () => Logger,
93
- MISSING_CONNECTION_NOTIFICATION: () => MISSING_CONNECTION_NOTIFICATION,
94
- MISSING_CONNECTION_RESOLVED_NOTIFICATION: () => MISSING_CONNECTION_RESOLVED_NOTIFICATION,
95
- MissingConnectionNotificationPayloadSchema: () => MissingConnectionNotificationPayloadSchema,
96
- MissingConnectionResolvedNotificationPayloadSchema: () => MissingConnectionResolvedNotificationPayloadSchema,
97
- MissingDeveloperConnectionNotificationPayloadSchema: () => MissingDeveloperConnectionNotificationPayloadSchema,
98
- MissingDeveloperConnectionResolvedNotificationPayloadSchema: () => MissingDeveloperConnectionResolvedNotificationPayloadSchema,
99
- MissingExternalConnectionNotificationPayloadSchema: () => MissingExternalConnectionNotificationPayloadSchema,
100
- MissingExternalConnectionResolvedNotificationPayloadSchema: () => MissingExternalConnectionResolvedNotificationPayloadSchema,
101
- NormalizedRequestSchema: () => NormalizedRequestSchema,
102
- NormalizedResponseSchema: () => NormalizedResponseSchema,
103
- PongErrorResponseSchema: () => PongErrorResponseSchema,
104
- PongResponseSchema: () => PongResponseSchema,
105
- PongSuccessResponseSchema: () => PongSuccessResponseSchema,
106
- PreprocessRunBodySchema: () => PreprocessRunBodySchema,
107
- PreprocessRunResponseSchema: () => PreprocessRunResponseSchema,
108
- QueueOptionsSchema: () => QueueOptionsSchema,
109
- REGISTER_SOURCE_EVENT_V1: () => REGISTER_SOURCE_EVENT_V1,
110
- REGISTER_SOURCE_EVENT_V2: () => REGISTER_SOURCE_EVENT_V2,
111
- RawEventSchema: () => RawEventSchema,
112
- RedactSchema: () => RedactSchema,
113
- RedactStringSchema: () => RedactStringSchema,
114
- RegisterDynamicSchedulePayloadSchema: () => RegisterDynamicSchedulePayloadSchema,
115
- RegisterHTTPTriggerSourceBodySchema: () => RegisterHTTPTriggerSourceBodySchema,
116
- RegisterIntervalScheduleBodySchema: () => RegisterIntervalScheduleBodySchema,
117
- RegisterSMTPTriggerSourceBodySchema: () => RegisterSMTPTriggerSourceBodySchema,
118
- RegisterSQSTriggerSourceBodySchema: () => RegisterSQSTriggerSourceBodySchema,
119
- RegisterScheduleBodySchema: () => RegisterScheduleBodySchema,
120
- RegisterScheduleResponseBodySchema: () => RegisterScheduleResponseBodySchema,
121
- RegisterSourceChannelBodySchema: () => RegisterSourceChannelBodySchema,
122
- RegisterSourceEventSchemaV1: () => RegisterSourceEventSchemaV1,
123
- RegisterSourceEventSchemaV2: () => RegisterSourceEventSchemaV2,
124
- RegisterTriggerBodySchemaV1: () => RegisterTriggerBodySchemaV1,
125
- RegisterTriggerBodySchemaV2: () => RegisterTriggerBodySchemaV2,
126
- RegisterTriggerSourceSchema: () => RegisterTriggerSourceSchema,
127
- RetryOptionsSchema: () => RetryOptionsSchema,
128
- RunJobBodySchema: () => RunJobBodySchema,
129
- RunJobCanceledWithTaskSchema: () => RunJobCanceledWithTaskSchema,
130
- RunJobErrorSchema: () => RunJobErrorSchema,
131
- RunJobResponseSchema: () => RunJobResponseSchema,
132
- RunJobResumeWithTaskSchema: () => RunJobResumeWithTaskSchema,
133
- RunJobRetryWithTaskSchema: () => RunJobRetryWithTaskSchema,
134
- RunJobSuccessSchema: () => RunJobSuccessSchema,
135
- RunSourceContextSchema: () => RunSourceContextSchema,
136
- RunStatusSchema: () => RunStatusSchema,
137
- RunTaskBodyInputSchema: () => RunTaskBodyInputSchema,
138
- RunTaskBodyOutputSchema: () => RunTaskBodyOutputSchema,
139
- RunTaskOptionsSchema: () => RunTaskOptionsSchema,
140
- RunTaskSchema: () => RunTaskSchema,
141
- RuntimeEnvironmentTypeSchema: () => RuntimeEnvironmentTypeSchema,
142
- SCHEDULED_EVENT: () => SCHEDULED_EVENT,
143
- ScheduleMetadataSchema: () => ScheduleMetadataSchema,
144
- ScheduledPayloadSchema: () => ScheduledPayloadSchema,
145
- ScheduledTriggerMetadataSchema: () => ScheduledTriggerMetadataSchema,
146
- SendEventBodySchema: () => SendEventBodySchema,
147
- SendEventOptionsSchema: () => SendEventOptionsSchema,
148
- SerializableJsonSchema: () => SerializableJsonSchema,
149
- ServerTaskSchema: () => ServerTaskSchema,
150
- SourceMetadataV2Schema: () => SourceMetadataV2Schema,
151
- StaticTriggerMetadataSchema: () => StaticTriggerMetadataSchema,
152
- StatusHistorySchema: () => StatusHistorySchema,
153
- StatusUpdateSchema: () => StatusUpdateSchema,
154
- StatusUpdateStateSchema: () => StatusUpdateStateSchema,
155
- StyleSchema: () => StyleSchema,
156
- TaskSchema: () => TaskSchema,
157
- TaskStatusSchema: () => TaskStatusSchema,
158
- TriggerMetadataSchema: () => TriggerMetadataSchema,
159
- TriggerSourceSchema: () => TriggerSourceSchema,
160
- UpdateTriggerSourceBodyV1Schema: () => UpdateTriggerSourceBodyV1Schema,
161
- UpdateTriggerSourceBodyV2Schema: () => UpdateTriggerSourceBodyV2Schema,
162
- ValidateErrorResponseSchema: () => ValidateErrorResponseSchema,
163
- ValidateResponseSchema: () => ValidateResponseSchema,
164
- ValidateSuccessResponseSchema: () => ValidateSuccessResponseSchema,
165
- addMissingVersionField: () => addMissingVersionField,
166
- calculateRetryAt: () => calculateRetryAt,
167
- currentDate: () => currentDate,
168
- currentTimestampMilliseconds: () => currentTimestampMilliseconds,
169
- currentTimestampSeconds: () => currentTimestampSeconds,
170
- deepMergeFilters: () => deepMergeFilters,
171
- eventFilterMatches: () => eventFilterMatches,
172
- replacements: () => replacements,
173
- urlWithSearchParams: () => urlWithSearchParams
174
- });
175
- module.exports = __toCommonJS(src_exports);
176
-
177
- // src/logger.ts
178
32
  var logLevels = [
179
33
  "log",
180
34
  "error",
@@ -182,18 +36,20 @@ var logLevels = [
182
36
  "info",
183
37
  "debug"
184
38
  ];
185
- var _name, _level, _filteredKeys, _jsonReplacer, _structuredLog, structuredLog_fn;
39
+ var _name, _level, _filteredKeys, _jsonReplacer, _additionalFields, _structuredLog, structuredLog_fn;
186
40
  var _Logger = class _Logger {
187
- constructor(name, level = "info", filteredKeys = [], jsonReplacer) {
41
+ constructor(name, level = "info", filteredKeys = [], jsonReplacer, additionalFields) {
188
42
  __privateAdd(this, _structuredLog);
189
43
  __privateAdd(this, _name, void 0);
190
44
  __privateAdd(this, _level, void 0);
191
45
  __privateAdd(this, _filteredKeys, []);
192
46
  __privateAdd(this, _jsonReplacer, void 0);
47
+ __privateAdd(this, _additionalFields, void 0);
193
48
  __privateSet(this, _name, name);
194
- __privateSet(this, _level, logLevels.indexOf(process.env.TRIGGER_LOG_LEVEL ?? level));
49
+ __privateSet(this, _level, logLevels.indexOf(node_process.env.TRIGGER_LOG_LEVEL ?? level));
195
50
  __privateSet(this, _filteredKeys, filteredKeys);
196
- __privateSet(this, _jsonReplacer, jsonReplacer);
51
+ __privateSet(this, _jsonReplacer, createReplacer(jsonReplacer));
52
+ __privateSet(this, _additionalFields, additionalFields ?? (() => ({})));
197
53
  }
198
54
  // Return a new Logger instance with the same name and a new log level
199
55
  // but filter out the keys from the log messages (at any level)
@@ -206,42 +62,45 @@ var _Logger = class _Logger {
206
62
  log(message, ...args) {
207
63
  if (__privateGet(this, _level) < 0)
208
64
  return;
209
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.log, message, ...args);
65
+ __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.log, message, "log", ...args);
210
66
  }
211
67
  error(message, ...args) {
212
68
  if (__privateGet(this, _level) < 1)
213
69
  return;
214
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.error, message, ...args);
70
+ __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.error, message, "error", ...args);
215
71
  }
216
72
  warn(message, ...args) {
217
73
  if (__privateGet(this, _level) < 2)
218
74
  return;
219
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.warn, message, ...args);
75
+ __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.warn, message, "warn", ...args);
220
76
  }
221
77
  info(message, ...args) {
222
78
  if (__privateGet(this, _level) < 3)
223
79
  return;
224
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.info, message, ...args);
80
+ __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.info, message, "info", ...args);
225
81
  }
226
82
  debug(message, ...args) {
227
83
  if (__privateGet(this, _level) < 4)
228
84
  return;
229
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.debug, message, ...args);
85
+ __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.debug, message, "debug", ...args);
230
86
  }
231
87
  };
232
88
  _name = new WeakMap();
233
89
  _level = new WeakMap();
234
90
  _filteredKeys = new WeakMap();
235
91
  _jsonReplacer = new WeakMap();
92
+ _additionalFields = new WeakMap();
236
93
  _structuredLog = new WeakSet();
237
- structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, ...args) {
94
+ structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, level, ...args) {
238
95
  const structuredLog = {
239
96
  ...structureArgs(safeJsonClone(args), __privateGet(this, _filteredKeys)),
97
+ ...__privateGet(this, _additionalFields).call(this),
240
98
  timestamp: /* @__PURE__ */ new Date(),
241
99
  name: __privateGet(this, _name),
242
- message
100
+ message,
101
+ level
243
102
  };
244
- loggerFunction(JSON.stringify(structuredLog, createReplacer(__privateGet(this, _jsonReplacer))));
103
+ loggerFunction(JSON.stringify(structuredLog, __privateGet(this, _jsonReplacer)));
245
104
  }, "#structuredLog");
246
105
  __name(_Logger, "Logger");
247
106
  var Logger = _Logger;
@@ -268,11 +127,14 @@ function safeJsonClone(obj) {
268
127
  try {
269
128
  return JSON.parse(JSON.stringify(obj, bigIntReplacer));
270
129
  } catch (e) {
271
- return obj;
130
+ return;
272
131
  }
273
132
  }
274
133
  __name(safeJsonClone, "safeJsonClone");
275
134
  function structureArgs(args, filteredKeys = []) {
135
+ if (!args) {
136
+ return;
137
+ }
276
138
  if (args.length === 0) {
277
139
  return;
278
140
  }
@@ -305,10 +167,10 @@ function filterKeys(obj, keys) {
305
167
  }
306
168
  __name(filterKeys, "filterKeys");
307
169
  function prettyPrintBytes(value) {
308
- if (process.env.NODE_ENV === "production") {
170
+ if (node_process.env.NODE_ENV === "production") {
309
171
  return "skipped size";
310
172
  }
311
- const sizeInBytes = Buffer.byteLength(JSON.stringify(value), "utf8");
173
+ const sizeInBytes = getSizeInBytes(value);
312
174
  if (sizeInBytes < 1024) {
313
175
  return `${sizeInBytes} bytes`;
314
176
  }
@@ -321,10 +183,15 @@ function prettyPrintBytes(value) {
321
183
  return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
322
184
  }
323
185
  __name(prettyPrintBytes, "prettyPrintBytes");
324
-
325
- // src/schemas/api.ts
326
- var import_ulid = require("ulid");
327
- var import_zod11 = require("zod");
186
+ function getSizeInBytes(value) {
187
+ const jsonString = JSON.stringify(value);
188
+ if (typeof window === "undefined") {
189
+ return node_buffer.Buffer.byteLength(jsonString, "utf8");
190
+ } else {
191
+ return new TextEncoder().encode(jsonString).length;
192
+ }
193
+ }
194
+ __name(getSizeInBytes, "getSizeInBytes");
328
195
 
329
196
  // src/schemas/addMissingVersionField.ts
330
197
  function addMissingVersionField(val) {
@@ -337,210 +204,204 @@ function addMissingVersionField(val) {
337
204
  return val;
338
205
  }
339
206
  __name(addMissingVersionField, "addMissingVersionField");
340
-
341
- // src/schemas/errors.ts
342
- var import_zod = require("zod");
343
- var ErrorWithStackSchema = import_zod.z.object({
344
- message: import_zod.z.string(),
345
- name: import_zod.z.string().optional(),
346
- stack: import_zod.z.string().optional()
347
- });
348
-
349
- // src/schemas/eventFilter.ts
350
- var import_zod2 = require("zod");
351
- var EventMatcherSchema = import_zod2.z.union([
207
+ var ErrorWithStackSchema = zod.z.object({
208
+ message: zod.z.string(),
209
+ name: zod.z.string().optional(),
210
+ stack: zod.z.string().optional()
211
+ });
212
+ var SchemaErrorSchema = zod.z.object({
213
+ path: zod.z.array(zod.z.string()),
214
+ message: zod.z.string()
215
+ });
216
+ var stringPatternMatchers = [
217
+ zod.z.object({
218
+ $endsWith: zod.z.string()
219
+ }),
220
+ zod.z.object({
221
+ $startsWith: zod.z.string()
222
+ }),
223
+ zod.z.object({
224
+ $ignoreCaseEquals: zod.z.string()
225
+ })
226
+ ];
227
+ var EventMatcherSchema = zod.z.union([
352
228
  /** Match against a string */
353
- import_zod2.z.array(import_zod2.z.string()),
229
+ zod.z.array(zod.z.string()),
354
230
  /** Match against a number */
355
- import_zod2.z.array(import_zod2.z.number()),
231
+ zod.z.array(zod.z.number()),
356
232
  /** Match against a boolean */
357
- import_zod2.z.array(import_zod2.z.boolean()),
358
- import_zod2.z.array(import_zod2.z.union([
359
- import_zod2.z.object({
360
- $endsWith: import_zod2.z.string()
361
- }),
362
- import_zod2.z.object({
363
- $startsWith: import_zod2.z.string()
364
- }),
365
- import_zod2.z.object({
366
- $exists: import_zod2.z.boolean()
233
+ zod.z.array(zod.z.boolean()),
234
+ zod.z.array(zod.z.union([
235
+ ...stringPatternMatchers,
236
+ zod.z.object({
237
+ $exists: zod.z.boolean()
367
238
  }),
368
- import_zod2.z.object({
369
- $isNull: import_zod2.z.boolean()
239
+ zod.z.object({
240
+ $isNull: zod.z.boolean()
370
241
  }),
371
- import_zod2.z.object({
372
- $anythingBut: import_zod2.z.union([
373
- import_zod2.z.string(),
374
- import_zod2.z.number(),
375
- import_zod2.z.boolean()
242
+ zod.z.object({
243
+ $anythingBut: zod.z.union([
244
+ zod.z.string(),
245
+ zod.z.number(),
246
+ zod.z.boolean()
376
247
  ])
377
248
  }),
378
- import_zod2.z.object({
379
- $anythingBut: import_zod2.z.union([
380
- import_zod2.z.array(import_zod2.z.string()),
381
- import_zod2.z.array(import_zod2.z.number()),
382
- import_zod2.z.array(import_zod2.z.boolean())
249
+ zod.z.object({
250
+ $anythingBut: zod.z.union([
251
+ zod.z.array(zod.z.string()),
252
+ zod.z.array(zod.z.number()),
253
+ zod.z.array(zod.z.boolean())
383
254
  ])
384
255
  }),
385
- import_zod2.z.object({
386
- $gt: import_zod2.z.number()
256
+ zod.z.object({
257
+ $gt: zod.z.number()
387
258
  }),
388
- import_zod2.z.object({
389
- $lt: import_zod2.z.number()
259
+ zod.z.object({
260
+ $lt: zod.z.number()
390
261
  }),
391
- import_zod2.z.object({
392
- $gte: import_zod2.z.number()
262
+ zod.z.object({
263
+ $gte: zod.z.number()
393
264
  }),
394
- import_zod2.z.object({
395
- $lte: import_zod2.z.number()
265
+ zod.z.object({
266
+ $lte: zod.z.number()
396
267
  }),
397
- import_zod2.z.object({
398
- $between: import_zod2.z.tuple([
399
- import_zod2.z.number(),
400
- import_zod2.z.number()
268
+ zod.z.object({
269
+ $between: zod.z.tuple([
270
+ zod.z.number(),
271
+ zod.z.number()
401
272
  ])
402
273
  }),
403
- import_zod2.z.object({
404
- $includes: import_zod2.z.union([
405
- import_zod2.z.string(),
406
- import_zod2.z.number(),
407
- import_zod2.z.boolean()
274
+ zod.z.object({
275
+ $includes: zod.z.union([
276
+ zod.z.string(),
277
+ zod.z.number(),
278
+ zod.z.boolean()
408
279
  ])
409
- }),
410
- import_zod2.z.object({
411
- $ignoreCaseEquals: import_zod2.z.string()
412
280
  })
413
281
  ]))
414
282
  ]);
415
- var EventFilterSchema = import_zod2.z.lazy(() => import_zod2.z.record(import_zod2.z.union([
283
+ var EventFilterSchema = zod.z.lazy(() => zod.z.record(zod.z.union([
416
284
  EventMatcherSchema,
417
285
  EventFilterSchema
418
286
  ])));
419
- var EventRuleSchema = import_zod2.z.object({
420
- event: import_zod2.z.string().or(import_zod2.z.array(import_zod2.z.string())),
421
- source: import_zod2.z.string(),
287
+ var EventRuleSchema = zod.z.object({
288
+ event: zod.z.string().or(zod.z.array(zod.z.string())),
289
+ source: zod.z.string(),
422
290
  payload: EventFilterSchema.optional(),
423
291
  context: EventFilterSchema.optional()
424
292
  });
425
-
426
- // src/schemas/integrations.ts
427
- var import_zod3 = require("zod");
428
- var ConnectionAuthSchema = import_zod3.z.object({
429
- type: import_zod3.z.enum([
430
- "oauth2"
293
+ var ConnectionAuthSchema = zod.z.object({
294
+ type: zod.z.enum([
295
+ "oauth2",
296
+ "apiKey"
431
297
  ]),
432
- accessToken: import_zod3.z.string(),
433
- scopes: import_zod3.z.array(import_zod3.z.string()).optional(),
434
- additionalFields: import_zod3.z.record(import_zod3.z.string()).optional()
298
+ accessToken: zod.z.string(),
299
+ scopes: zod.z.array(zod.z.string()).optional(),
300
+ additionalFields: zod.z.record(zod.z.string()).optional()
435
301
  });
436
- var IntegrationMetadataSchema = import_zod3.z.object({
437
- id: import_zod3.z.string(),
438
- name: import_zod3.z.string(),
439
- instructions: import_zod3.z.string().optional()
302
+ var IntegrationMetadataSchema = zod.z.object({
303
+ id: zod.z.string(),
304
+ name: zod.z.string(),
305
+ instructions: zod.z.string().optional()
440
306
  });
441
- var IntegrationConfigSchema = import_zod3.z.object({
442
- id: import_zod3.z.string(),
307
+ var IntegrationConfigSchema = zod.z.object({
308
+ id: zod.z.string(),
443
309
  metadata: IntegrationMetadataSchema,
444
- authSource: import_zod3.z.enum([
310
+ authSource: zod.z.enum([
445
311
  "HOSTED",
446
- "LOCAL"
312
+ "LOCAL",
313
+ "RESOLVER"
447
314
  ])
448
315
  });
449
-
450
- // src/schemas/json.ts
451
- var import_zod4 = require("zod");
452
- var LiteralSchema = import_zod4.z.union([
453
- import_zod4.z.string(),
454
- import_zod4.z.number(),
455
- import_zod4.z.boolean(),
456
- import_zod4.z.null()
316
+ var LiteralSchema = zod.z.union([
317
+ zod.z.string(),
318
+ zod.z.number(),
319
+ zod.z.boolean(),
320
+ zod.z.null()
457
321
  ]);
458
- var DeserializedJsonSchema = import_zod4.z.lazy(() => import_zod4.z.union([
322
+ var DeserializedJsonSchema = zod.z.lazy(() => zod.z.union([
459
323
  LiteralSchema,
460
- import_zod4.z.array(DeserializedJsonSchema),
461
- import_zod4.z.record(DeserializedJsonSchema)
324
+ zod.z.array(DeserializedJsonSchema),
325
+ zod.z.record(DeserializedJsonSchema)
462
326
  ]));
463
- var SerializableSchema = import_zod4.z.union([
464
- import_zod4.z.string(),
465
- import_zod4.z.number(),
466
- import_zod4.z.boolean(),
467
- import_zod4.z.null(),
468
- import_zod4.z.date(),
469
- import_zod4.z.undefined(),
470
- import_zod4.z.symbol()
327
+ var SerializableSchema = zod.z.union([
328
+ zod.z.string(),
329
+ zod.z.number(),
330
+ zod.z.boolean(),
331
+ zod.z.null(),
332
+ zod.z.date(),
333
+ zod.z.undefined(),
334
+ zod.z.symbol()
471
335
  ]);
472
- var SerializableJsonSchema = import_zod4.z.lazy(() => import_zod4.z.union([
336
+ var SerializableJsonSchema = zod.z.lazy(() => zod.z.union([
473
337
  SerializableSchema,
474
- import_zod4.z.array(SerializableJsonSchema),
475
- import_zod4.z.record(SerializableJsonSchema)
338
+ zod.z.array(SerializableJsonSchema),
339
+ zod.z.record(SerializableJsonSchema)
476
340
  ]));
477
-
478
- // src/schemas/properties.ts
479
- var import_zod5 = require("zod");
480
- var DisplayPropertySchema = import_zod5.z.object({
341
+ var DisplayPropertySchema = zod.z.object({
481
342
  /** The label for the property */
482
- label: import_zod5.z.string(),
343
+ label: zod.z.string(),
483
344
  /** The value of the property */
484
- text: import_zod5.z.string(),
345
+ text: zod.z.string(),
485
346
  /** The URL to link to when the property is clicked */
486
- url: import_zod5.z.string().optional()
347
+ url: zod.z.string().optional(),
348
+ /** The URL to a list of images to display next to the property */
349
+ imageUrl: zod.z.array(zod.z.string()).optional()
487
350
  });
488
- var DisplayPropertiesSchema = import_zod5.z.array(DisplayPropertySchema);
489
- var StyleSchema = import_zod5.z.object({
351
+ var DisplayPropertiesSchema = zod.z.array(DisplayPropertySchema);
352
+ var StyleSchema = zod.z.object({
490
353
  /** The style, `normal` or `minimal` */
491
- style: import_zod5.z.enum([
354
+ style: zod.z.enum([
492
355
  "normal",
493
356
  "minimal"
494
357
  ]),
495
358
  /** A variant of the style. */
496
- variant: import_zod5.z.string().optional()
359
+ variant: zod.z.string().optional()
497
360
  });
498
-
499
- // src/schemas/schedules.ts
500
- var import_zod6 = require("zod");
501
361
  var SCHEDULED_EVENT = "dev.trigger.scheduled";
502
- var ScheduledPayloadSchema = import_zod6.z.object({
503
- ts: import_zod6.z.coerce.date(),
504
- lastTimestamp: import_zod6.z.coerce.date().optional()
362
+ var ScheduledPayloadSchema = zod.z.object({
363
+ ts: zod.z.coerce.date(),
364
+ lastTimestamp: zod.z.coerce.date().optional()
505
365
  });
506
- var IntervalOptionsSchema = import_zod6.z.object({
507
- /** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
508
- seconds: import_zod6.z.number().int().positive().min(60).max(86400)
366
+ var IntervalOptionsSchema = zod.z.object({
367
+ /** The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days) */
368
+ seconds: zod.z.number().int().positive().min(60).max(2592e3)
509
369
  });
510
- var CronOptionsSchema = import_zod6.z.object({
370
+ var CronOptionsSchema = zod.z.object({
511
371
  /** A CRON expression that defines the schedule. A useful tool when writing CRON
512
372
  expressions is [crontab guru](https://crontab.guru). Note that the timezone
513
373
  used is UTC. */
514
- cron: import_zod6.z.string()
374
+ cron: zod.z.string()
515
375
  });
516
- var CronMetadataSchema = import_zod6.z.object({
517
- type: import_zod6.z.literal("cron"),
376
+ var CronMetadataSchema = zod.z.object({
377
+ type: zod.z.literal("cron"),
518
378
  options: CronOptionsSchema,
519
- metadata: import_zod6.z.any()
379
+ /** An optional Account ID to associate with runs triggered by this interval */
380
+ accountId: zod.z.string().optional(),
381
+ metadata: zod.z.any()
520
382
  });
521
- var IntervalMetadataSchema = import_zod6.z.object({
383
+ var IntervalMetadataSchema = zod.z.object({
522
384
  /** An interval reoccurs at the specified number of seconds */
523
- type: import_zod6.z.literal("interval"),
385
+ type: zod.z.literal("interval"),
524
386
  /** An object containing options about the interval. */
525
387
  options: IntervalOptionsSchema,
388
+ /** An optional Account ID to associate with runs triggered by this interval */
389
+ accountId: zod.z.string().optional(),
526
390
  /** Any additional metadata about the schedule. */
527
- metadata: import_zod6.z.any()
391
+ metadata: zod.z.any()
528
392
  });
529
- var ScheduleMetadataSchema = import_zod6.z.discriminatedUnion("type", [
393
+ var ScheduleMetadataSchema = zod.z.discriminatedUnion("type", [
530
394
  IntervalMetadataSchema,
531
395
  CronMetadataSchema
532
396
  ]);
533
- var RegisterDynamicSchedulePayloadSchema = import_zod6.z.object({
534
- id: import_zod6.z.string(),
535
- jobs: import_zod6.z.array(import_zod6.z.object({
536
- id: import_zod6.z.string(),
537
- version: import_zod6.z.string()
397
+ var RegisterDynamicSchedulePayloadSchema = zod.z.object({
398
+ id: zod.z.string(),
399
+ jobs: zod.z.array(zod.z.object({
400
+ id: zod.z.string(),
401
+ version: zod.z.string()
538
402
  }))
539
403
  });
540
-
541
- // src/schemas/tasks.ts
542
- var import_zod7 = require("zod");
543
- var TaskStatusSchema = import_zod7.z.enum([
404
+ var TaskStatusSchema = zod.z.enum([
544
405
  "PENDING",
545
406
  "WAITING",
546
407
  "RUNNING",
@@ -548,638 +409,937 @@ var TaskStatusSchema = import_zod7.z.enum([
548
409
  "ERRORED",
549
410
  "CANCELED"
550
411
  ]);
551
- var TaskSchema = import_zod7.z.object({
552
- id: import_zod7.z.string(),
553
- name: import_zod7.z.string(),
554
- icon: import_zod7.z.string().optional().nullable(),
555
- noop: import_zod7.z.boolean(),
556
- startedAt: import_zod7.z.coerce.date().optional().nullable(),
557
- completedAt: import_zod7.z.coerce.date().optional().nullable(),
558
- delayUntil: import_zod7.z.coerce.date().optional().nullable(),
412
+ var TaskSchema = zod.z.object({
413
+ id: zod.z.string(),
414
+ name: zod.z.string(),
415
+ icon: zod.z.string().optional().nullable(),
416
+ noop: zod.z.boolean(),
417
+ startedAt: zod.z.coerce.date().optional().nullable(),
418
+ completedAt: zod.z.coerce.date().optional().nullable(),
419
+ delayUntil: zod.z.coerce.date().optional().nullable(),
559
420
  status: TaskStatusSchema,
560
- description: import_zod7.z.string().optional().nullable(),
561
- properties: import_zod7.z.array(DisplayPropertySchema).optional().nullable(),
562
- outputProperties: import_zod7.z.array(DisplayPropertySchema).optional().nullable(),
421
+ description: zod.z.string().optional().nullable(),
422
+ properties: zod.z.array(DisplayPropertySchema).optional().nullable(),
423
+ outputProperties: zod.z.array(DisplayPropertySchema).optional().nullable(),
563
424
  params: DeserializedJsonSchema.optional().nullable(),
564
425
  output: DeserializedJsonSchema.optional().nullable(),
565
- error: import_zod7.z.string().optional().nullable(),
566
- parentId: import_zod7.z.string().optional().nullable(),
426
+ context: DeserializedJsonSchema.optional().nullable(),
427
+ error: zod.z.string().optional().nullable(),
428
+ parentId: zod.z.string().optional().nullable(),
567
429
  style: StyleSchema.optional().nullable(),
568
- operation: import_zod7.z.string().optional().nullable()
430
+ operation: zod.z.string().optional().nullable(),
431
+ callbackUrl: zod.z.string().optional().nullable(),
432
+ childExecutionMode: zod.z.enum([
433
+ "SEQUENTIAL",
434
+ "PARALLEL"
435
+ ]).optional().nullable()
569
436
  });
570
437
  var ServerTaskSchema = TaskSchema.extend({
571
- idempotencyKey: import_zod7.z.string(),
572
- attempts: import_zod7.z.number()
438
+ idempotencyKey: zod.z.string(),
439
+ attempts: zod.z.number(),
440
+ forceYield: zod.z.boolean().optional().nullable()
573
441
  });
574
- var CachedTaskSchema = import_zod7.z.object({
575
- id: import_zod7.z.string(),
576
- idempotencyKey: import_zod7.z.string(),
442
+ var CachedTaskSchema = zod.z.object({
443
+ id: zod.z.string(),
444
+ idempotencyKey: zod.z.string(),
577
445
  status: TaskStatusSchema,
578
- noop: import_zod7.z.boolean().default(false),
446
+ noop: zod.z.boolean().default(false),
579
447
  output: DeserializedJsonSchema.optional().nullable(),
580
- parentId: import_zod7.z.string().optional().nullable()
581
- });
582
-
583
- // src/schemas/triggers.ts
584
- var import_zod8 = require("zod");
585
- var EventExampleSchema = import_zod8.z.object({
586
- id: import_zod8.z.string(),
587
- icon: import_zod8.z.string().optional(),
588
- name: import_zod8.z.string(),
589
- payload: import_zod8.z.any()
590
- });
591
- var EventSpecificationSchema = import_zod8.z.object({
592
- name: import_zod8.z.string().or(import_zod8.z.array(import_zod8.z.string())),
593
- title: import_zod8.z.string(),
594
- source: import_zod8.z.string(),
595
- icon: import_zod8.z.string(),
448
+ parentId: zod.z.string().optional().nullable()
449
+ });
450
+ var EventExampleSchema = zod.z.object({
451
+ id: zod.z.string(),
452
+ icon: zod.z.string().optional(),
453
+ name: zod.z.string(),
454
+ payload: zod.z.any()
455
+ });
456
+ var EventSpecificationSchema = zod.z.object({
457
+ name: zod.z.string().or(zod.z.array(zod.z.string())),
458
+ title: zod.z.string(),
459
+ source: zod.z.string(),
460
+ icon: zod.z.string(),
596
461
  filter: EventFilterSchema.optional(),
597
- properties: import_zod8.z.array(DisplayPropertySchema).optional(),
598
- schema: import_zod8.z.any().optional(),
599
- examples: import_zod8.z.array(EventExampleSchema).optional()
600
- });
601
- var DynamicTriggerMetadataSchema = import_zod8.z.object({
602
- type: import_zod8.z.literal("dynamic"),
603
- id: import_zod8.z.string()
604
- });
605
- var StaticTriggerMetadataSchema = import_zod8.z.object({
606
- type: import_zod8.z.literal("static"),
607
- title: import_zod8.z.union([
608
- import_zod8.z.string(),
609
- import_zod8.z.array(import_zod8.z.string())
462
+ properties: zod.z.array(DisplayPropertySchema).optional(),
463
+ schema: zod.z.any().optional(),
464
+ examples: zod.z.array(EventExampleSchema).optional()
465
+ });
466
+ var DynamicTriggerMetadataSchema = zod.z.object({
467
+ type: zod.z.literal("dynamic"),
468
+ id: zod.z.string()
469
+ });
470
+ var TriggerHelpSchema = zod.z.object({
471
+ noRuns: zod.z.object({
472
+ text: zod.z.string(),
473
+ link: zod.z.string().optional()
474
+ }).optional()
475
+ });
476
+ var StaticTriggerMetadataSchema = zod.z.object({
477
+ type: zod.z.literal("static"),
478
+ title: zod.z.union([
479
+ zod.z.string(),
480
+ zod.z.array(zod.z.string())
610
481
  ]),
611
- properties: import_zod8.z.array(DisplayPropertySchema).optional(),
612
- rule: EventRuleSchema
482
+ properties: zod.z.array(DisplayPropertySchema).optional(),
483
+ rule: EventRuleSchema,
484
+ link: zod.z.string().optional(),
485
+ help: TriggerHelpSchema.optional()
613
486
  });
614
- var ScheduledTriggerMetadataSchema = import_zod8.z.object({
615
- type: import_zod8.z.literal("scheduled"),
487
+ var InvokeTriggerMetadataSchema = zod.z.object({
488
+ type: zod.z.literal("invoke")
489
+ });
490
+ var ScheduledTriggerMetadataSchema = zod.z.object({
491
+ type: zod.z.literal("scheduled"),
616
492
  schedule: ScheduleMetadataSchema
617
493
  });
618
- var TriggerMetadataSchema = import_zod8.z.discriminatedUnion("type", [
494
+ var TriggerMetadataSchema = zod.z.discriminatedUnion("type", [
619
495
  DynamicTriggerMetadataSchema,
620
496
  StaticTriggerMetadataSchema,
621
- ScheduledTriggerMetadataSchema
497
+ ScheduledTriggerMetadataSchema,
498
+ InvokeTriggerMetadataSchema
622
499
  ]);
623
-
624
- // src/schemas/runs.ts
625
- var import_zod10 = require("zod");
626
-
627
- // src/schemas/statuses.ts
628
- var import_zod9 = require("zod");
629
- var StatusUpdateStateSchema = import_zod9.z.union([
630
- import_zod9.z.literal("loading"),
631
- import_zod9.z.literal("success"),
632
- import_zod9.z.literal("failure")
500
+ var StatusUpdateStateSchema = zod.z.union([
501
+ zod.z.literal("loading"),
502
+ zod.z.literal("success"),
503
+ zod.z.literal("failure")
633
504
  ]);
634
- var StatusUpdateDataSchema = import_zod9.z.record(SerializableJsonSchema);
635
- var StatusUpdateSchema = import_zod9.z.object({
636
- label: import_zod9.z.string().optional(),
505
+ var StatusUpdateDataSchema = zod.z.record(SerializableJsonSchema);
506
+ var StatusUpdateSchema = zod.z.object({
507
+ label: zod.z.string().optional(),
637
508
  state: StatusUpdateStateSchema.optional(),
638
509
  data: StatusUpdateDataSchema.optional()
639
510
  });
640
511
  var InitalStatusUpdateSchema = StatusUpdateSchema.required({
641
512
  label: true
642
513
  });
643
- var StatusHistorySchema = import_zod9.z.array(StatusUpdateSchema);
514
+ var StatusHistorySchema = zod.z.array(StatusUpdateSchema);
644
515
  var JobRunStatusRecordSchema = InitalStatusUpdateSchema.extend({
645
- key: import_zod9.z.string(),
516
+ key: zod.z.string(),
646
517
  history: StatusHistorySchema
647
518
  });
648
519
 
649
520
  // src/schemas/runs.ts
650
- var RunStatusSchema = import_zod10.z.union([
651
- import_zod10.z.literal("PENDING"),
652
- import_zod10.z.literal("QUEUED"),
653
- import_zod10.z.literal("WAITING_ON_CONNECTIONS"),
654
- import_zod10.z.literal("PREPROCESSING"),
655
- import_zod10.z.literal("STARTED"),
656
- import_zod10.z.literal("SUCCESS"),
657
- import_zod10.z.literal("FAILURE"),
658
- import_zod10.z.literal("TIMED_OUT"),
659
- import_zod10.z.literal("ABORTED"),
660
- import_zod10.z.literal("CANCELED")
521
+ var RunStatusSchema = zod.z.union([
522
+ zod.z.literal("PENDING"),
523
+ zod.z.literal("QUEUED"),
524
+ zod.z.literal("WAITING_ON_CONNECTIONS"),
525
+ zod.z.literal("PREPROCESSING"),
526
+ zod.z.literal("STARTED"),
527
+ zod.z.literal("SUCCESS"),
528
+ zod.z.literal("FAILURE"),
529
+ zod.z.literal("TIMED_OUT"),
530
+ zod.z.literal("ABORTED"),
531
+ zod.z.literal("CANCELED"),
532
+ zod.z.literal("UNRESOLVED_AUTH"),
533
+ zod.z.literal("INVALID_PAYLOAD"),
534
+ zod.z.literal("EXECUTING"),
535
+ zod.z.literal("WAITING_TO_CONTINUE"),
536
+ zod.z.literal("WAITING_TO_EXECUTE")
661
537
  ]);
662
- var RunTaskSchema = import_zod10.z.object({
538
+ var RunTaskSchema = zod.z.object({
663
539
  /** The Task id */
664
- id: import_zod10.z.string(),
540
+ id: zod.z.string(),
665
541
  /** The key that you defined when creating the Task, the first param in any task. */
666
- displayKey: import_zod10.z.string().nullable(),
542
+ displayKey: zod.z.string().nullable(),
667
543
  /** The Task status */
668
544
  status: TaskStatusSchema,
669
545
  /** The name of the Task */
670
- name: import_zod10.z.string(),
546
+ name: zod.z.string(),
671
547
  /** The icon of the Task, a string.
672
548
  * For integrations, this will be a lowercase name of the company.
673
549
  * Can be used with the [@trigger.dev/companyicons](https://www.npmjs.com/package/@trigger.dev/companyicons) package to display an svg. */
674
- icon: import_zod10.z.string().nullable(),
550
+ icon: zod.z.string().nullable(),
675
551
  /** When the task started */
676
- startedAt: import_zod10.z.coerce.date().nullable(),
552
+ startedAt: zod.z.coerce.date().nullable(),
677
553
  /** When the task completed */
678
- completedAt: import_zod10.z.coerce.date().nullable()
554
+ completedAt: zod.z.coerce.date().nullable()
679
555
  });
680
556
  var RunTaskWithSubtasksSchema = RunTaskSchema.extend({
681
- subtasks: import_zod10.z.lazy(() => RunTaskWithSubtasksSchema.array()).optional()
557
+ subtasks: zod.z.lazy(() => RunTaskWithSubtasksSchema.array()).optional()
682
558
  });
683
- var GetRunOptionsSchema = import_zod10.z.object({
559
+ var GetRunOptionsSchema = zod.z.object({
684
560
  /** Return subtasks, which appear in a `subtasks` array on a task. @default false */
685
- subtasks: import_zod10.z.boolean().optional(),
561
+ subtasks: zod.z.boolean().optional(),
686
562
  /** You can use this to get more tasks, if there are more than are returned in a single batch @default undefined */
687
- cursor: import_zod10.z.string().optional(),
563
+ cursor: zod.z.string().optional(),
688
564
  /** How many tasks you want to return in one go, max 50. @default 20 */
689
- take: import_zod10.z.number().optional()
565
+ take: zod.z.number().optional()
690
566
  });
691
- var GetRunOptionsWithTaskDetailsSchema = GetRunOptionsSchema.extend({
567
+ GetRunOptionsSchema.extend({
692
568
  /** If `true`, it returns the `params` and `output` of all tasks. @default false */
693
- taskdetails: import_zod10.z.boolean().optional()
569
+ taskdetails: zod.z.boolean().optional()
694
570
  });
695
- var RunSchema = import_zod10.z.object({
571
+ var RunSchema = zod.z.object({
696
572
  /** The Run id */
697
- id: import_zod10.z.string(),
573
+ id: zod.z.string(),
698
574
  /** The Run status */
699
575
  status: RunStatusSchema,
700
576
  /** When the run started */
701
- startedAt: import_zod10.z.coerce.date().nullable(),
577
+ startedAt: zod.z.coerce.date().nullable(),
702
578
  /** When the run was last updated */
703
- updatedAt: import_zod10.z.coerce.date().nullable(),
579
+ updatedAt: zod.z.coerce.date().nullable(),
704
580
  /** When the run was completed */
705
- completedAt: import_zod10.z.coerce.date().nullable()
581
+ completedAt: zod.z.coerce.date().nullable()
706
582
  });
707
583
  var GetRunSchema = RunSchema.extend({
708
584
  /** The output of the run */
709
- output: import_zod10.z.any().optional(),
585
+ output: zod.z.any().optional(),
710
586
  /** The tasks from the run */
711
- tasks: import_zod10.z.array(RunTaskWithSubtasksSchema),
587
+ tasks: zod.z.array(RunTaskWithSubtasksSchema),
712
588
  /** Any status updates that were published from the run */
713
- statuses: import_zod10.z.array(JobRunStatusRecordSchema),
589
+ statuses: zod.z.array(JobRunStatusRecordSchema).default([]),
714
590
  /** If there are more tasks, you can use this to get them */
715
- nextCursor: import_zod10.z.string().optional()
591
+ nextCursor: zod.z.string().optional()
716
592
  });
717
- var GetRunsOptionsSchema = import_zod10.z.object({
593
+ zod.z.object({
718
594
  /** You can use this to get more tasks, if there are more than are returned in a single batch @default undefined */
719
- cursor: import_zod10.z.string().optional(),
595
+ cursor: zod.z.string().optional(),
720
596
  /** How many runs you want to return in one go, max 50. @default 20 */
721
- take: import_zod10.z.number().optional()
597
+ take: zod.z.number().optional()
722
598
  });
723
- var GetRunsSchema = import_zod10.z.object({
599
+ var GetRunsSchema = zod.z.object({
724
600
  /** The runs from the query */
725
601
  runs: RunSchema.array(),
726
602
  /** If there are more runs, you can use this to get them */
727
- nextCursor: import_zod10.z.string().optional()
603
+ nextCursor: zod.z.string().optional()
604
+ });
605
+ var StringMatchSchema = zod.z.union([
606
+ /** Match against a string */
607
+ zod.z.array(zod.z.string()),
608
+ zod.z.array(zod.z.union(stringPatternMatchers))
609
+ ]);
610
+ var HTTPMethodUnionSchema = zod.z.union([
611
+ zod.z.literal("GET"),
612
+ zod.z.literal("POST"),
613
+ zod.z.literal("PUT"),
614
+ zod.z.literal("PATCH"),
615
+ zod.z.literal("DELETE"),
616
+ zod.z.literal("HEAD"),
617
+ zod.z.literal("OPTIONS")
618
+ ]);
619
+ var RequestFilterSchema = zod.z.object({
620
+ /** An array of HTTP methods to match.
621
+ * For example, `["GET", "POST"]` will match both `GET` and `POST` Requests. */
622
+ method: zod.z.array(HTTPMethodUnionSchema).optional(),
623
+ /** An object of header key/values to match.
624
+ * This uses the [EventFilter matching syntax](https://trigger.dev/docs/documentation/guides/event-filter).
625
+
626
+ @example
627
+ ```ts
628
+ filter: {
629
+ header: {
630
+ "content-type": ["application/json"],
631
+ },
632
+ },
633
+ ``` */
634
+ headers: zod.z.record(StringMatchSchema).optional(),
635
+ /** An object of query parameters to match.
636
+ * This uses the [EventFilter matching syntax](https://trigger.dev/docs/documentation/guides/event-filter).
637
+
638
+ @example
639
+ ```ts
640
+ filter: {
641
+ query: {
642
+ "hub.mode": [{ $startsWith: "sub" }],
643
+ },
644
+ },
645
+ ``` */
646
+ query: zod.z.record(StringMatchSchema).optional(),
647
+ /** An object of key/values to match.
648
+ * This uses the [EventFilter matching syntax](https://trigger.dev/docs/documentation/guides/event-filter).
649
+ */
650
+ body: EventFilterSchema.optional()
651
+ });
652
+ var ResponseFilterSchema = RequestFilterSchema.omit({
653
+ method: true,
654
+ query: true
655
+ }).extend({
656
+ status: zod.z.array(zod.z.number()).optional()
728
657
  });
729
658
 
730
659
  // src/schemas/api.ts
731
- var UpdateTriggerSourceBodyV1Schema = import_zod11.z.object({
732
- registeredEvents: import_zod11.z.array(import_zod11.z.string()),
733
- secret: import_zod11.z.string().optional(),
660
+ var UpdateTriggerSourceBodyV1Schema = zod.z.object({
661
+ registeredEvents: zod.z.array(zod.z.string()),
662
+ secret: zod.z.string().optional(),
734
663
  data: SerializableJsonSchema.optional()
735
664
  });
736
- var UpdateTriggerSourceBodyV2Schema = import_zod11.z.object({
737
- secret: import_zod11.z.string().optional(),
665
+ var UpdateTriggerSourceBodyV2Schema = zod.z.object({
666
+ secret: zod.z.string().optional(),
738
667
  data: SerializableJsonSchema.optional(),
739
- options: import_zod11.z.object({
740
- event: import_zod11.z.array(import_zod11.z.string())
741
- }).and(import_zod11.z.record(import_zod11.z.string(), import_zod11.z.array(import_zod11.z.string())).optional())
668
+ options: zod.z.object({
669
+ event: zod.z.array(zod.z.string())
670
+ }).and(zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).optional())
742
671
  });
743
- var RegisterHTTPTriggerSourceBodySchema = import_zod11.z.object({
744
- type: import_zod11.z.literal("HTTP"),
745
- url: import_zod11.z.string().url()
672
+ var UpdateWebhookBodySchema = zod.z.discriminatedUnion("active", [
673
+ zod.z.object({
674
+ active: zod.z.literal(false)
675
+ }),
676
+ zod.z.object({
677
+ active: zod.z.literal(true),
678
+ config: zod.z.record(zod.z.string().array())
679
+ })
680
+ ]);
681
+ var RegisterHTTPTriggerSourceBodySchema = zod.z.object({
682
+ type: zod.z.literal("HTTP"),
683
+ url: zod.z.string().url()
746
684
  });
747
- var RegisterSMTPTriggerSourceBodySchema = import_zod11.z.object({
748
- type: import_zod11.z.literal("SMTP")
685
+ var RegisterSMTPTriggerSourceBodySchema = zod.z.object({
686
+ type: zod.z.literal("SMTP")
749
687
  });
750
- var RegisterSQSTriggerSourceBodySchema = import_zod11.z.object({
751
- type: import_zod11.z.literal("SQS")
688
+ var RegisterSQSTriggerSourceBodySchema = zod.z.object({
689
+ type: zod.z.literal("SQS")
752
690
  });
753
- var RegisterSourceChannelBodySchema = import_zod11.z.discriminatedUnion("type", [
691
+ var RegisterSourceChannelBodySchema = zod.z.discriminatedUnion("type", [
754
692
  RegisterHTTPTriggerSourceBodySchema,
755
693
  RegisterSMTPTriggerSourceBodySchema,
756
694
  RegisterSQSTriggerSourceBodySchema
757
695
  ]);
696
+ var REGISTER_WEBHOOK = "dev.trigger.webhook.register";
697
+ var DELIVER_WEBHOOK_REQUEST = "dev.trigger.webhook.deliver";
698
+ var RegisterWebhookSourceSchema = zod.z.object({
699
+ key: zod.z.string(),
700
+ params: zod.z.any(),
701
+ config: zod.z.any(),
702
+ active: zod.z.boolean(),
703
+ secret: zod.z.string(),
704
+ url: zod.z.string(),
705
+ data: DeserializedJsonSchema.optional(),
706
+ clientId: zod.z.string().optional()
707
+ });
708
+ var RegisterWebhookPayloadSchema = zod.z.object({
709
+ active: zod.z.boolean(),
710
+ params: zod.z.any().optional(),
711
+ config: zod.z.object({
712
+ current: zod.z.record(zod.z.string().array()),
713
+ desired: zod.z.record(zod.z.string().array())
714
+ }),
715
+ // from HTTP Endpoint
716
+ url: zod.z.string(),
717
+ secret: zod.z.string()
718
+ });
758
719
  var REGISTER_SOURCE_EVENT_V1 = "dev.trigger.source.register";
759
720
  var REGISTER_SOURCE_EVENT_V2 = "dev.trigger.source.register.v2";
760
- var RegisterTriggerSourceSchema = import_zod11.z.object({
761
- key: import_zod11.z.string(),
762
- params: import_zod11.z.any(),
763
- active: import_zod11.z.boolean(),
764
- secret: import_zod11.z.string(),
721
+ var RegisterTriggerSourceSchema = zod.z.object({
722
+ key: zod.z.string(),
723
+ params: zod.z.any(),
724
+ active: zod.z.boolean(),
725
+ secret: zod.z.string(),
765
726
  data: DeserializedJsonSchema.optional(),
766
727
  channel: RegisterSourceChannelBodySchema,
767
- clientId: import_zod11.z.string().optional()
728
+ clientId: zod.z.string().optional()
768
729
  });
769
- var SourceEventOptionSchema = import_zod11.z.object({
770
- name: import_zod11.z.string(),
771
- value: import_zod11.z.string()
730
+ zod.z.object({
731
+ name: zod.z.string(),
732
+ value: zod.z.string()
772
733
  });
773
- var RegisterSourceEventSchemaV1 = import_zod11.z.object({
734
+ var RegisterSourceEventSchemaV1 = zod.z.object({
774
735
  /** The id of the source */
775
- id: import_zod11.z.string(),
736
+ id: zod.z.string(),
776
737
  source: RegisterTriggerSourceSchema,
777
- events: import_zod11.z.array(import_zod11.z.string()),
778
- missingEvents: import_zod11.z.array(import_zod11.z.string()),
779
- orphanedEvents: import_zod11.z.array(import_zod11.z.string()),
780
- dynamicTriggerId: import_zod11.z.string().optional()
738
+ events: zod.z.array(zod.z.string()),
739
+ missingEvents: zod.z.array(zod.z.string()),
740
+ orphanedEvents: zod.z.array(zod.z.string()),
741
+ dynamicTriggerId: zod.z.string().optional()
781
742
  });
782
- var RegisteredOptionsDiffSchema = import_zod11.z.object({
783
- desired: import_zod11.z.array(import_zod11.z.string()),
784
- missing: import_zod11.z.array(import_zod11.z.string()),
785
- orphaned: import_zod11.z.array(import_zod11.z.string())
743
+ var RegisteredOptionsDiffSchema = zod.z.object({
744
+ desired: zod.z.array(zod.z.string()),
745
+ missing: zod.z.array(zod.z.string()),
746
+ orphaned: zod.z.array(zod.z.string())
786
747
  });
787
- var RegisterSourceEventOptionsSchema = import_zod11.z.object({
748
+ var RegisterSourceEventOptionsSchema = zod.z.object({
788
749
  event: RegisteredOptionsDiffSchema
789
- }).and(import_zod11.z.record(import_zod11.z.string(), RegisteredOptionsDiffSchema));
790
- var RegisterSourceEventSchemaV2 = import_zod11.z.object({
750
+ }).and(zod.z.record(zod.z.string(), RegisteredOptionsDiffSchema));
751
+ var RegisterSourceEventSchemaV2 = zod.z.object({
791
752
  /** The id of the source */
792
- id: import_zod11.z.string(),
753
+ id: zod.z.string(),
793
754
  source: RegisterTriggerSourceSchema,
794
755
  options: RegisterSourceEventOptionsSchema,
795
- dynamicTriggerId: import_zod11.z.string().optional()
756
+ dynamicTriggerId: zod.z.string().optional()
796
757
  });
797
- var TriggerSourceSchema = import_zod11.z.object({
798
- id: import_zod11.z.string(),
799
- key: import_zod11.z.string()
758
+ var TriggerSourceSchema = zod.z.object({
759
+ id: zod.z.string(),
760
+ key: zod.z.string()
800
761
  });
801
762
  var HttpSourceResponseMetadataSchema = DeserializedJsonSchema;
802
- var HandleTriggerSourceSchema = import_zod11.z.object({
803
- key: import_zod11.z.string(),
804
- secret: import_zod11.z.string(),
805
- data: import_zod11.z.any(),
806
- params: import_zod11.z.any(),
763
+ var HandleTriggerSourceSchema = zod.z.object({
764
+ key: zod.z.string(),
765
+ secret: zod.z.string(),
766
+ data: zod.z.any(),
767
+ params: zod.z.any(),
807
768
  auth: ConnectionAuthSchema.optional(),
808
769
  metadata: HttpSourceResponseMetadataSchema.optional()
809
770
  });
810
- var HttpSourceRequestSchema = import_zod11.z.object({
811
- url: import_zod11.z.string().url(),
812
- method: import_zod11.z.string(),
813
- headers: import_zod11.z.record(import_zod11.z.string()),
814
- rawBody: import_zod11.z.instanceof(Buffer).optional().nullable()
815
- });
816
- var HttpSourceRequestHeadersSchema = import_zod11.z.object({
817
- "x-ts-key": import_zod11.z.string(),
818
- "x-ts-dynamic-id": import_zod11.z.string().optional(),
819
- "x-ts-secret": import_zod11.z.string(),
820
- "x-ts-data": import_zod11.z.string().transform((s) => JSON.parse(s)),
821
- "x-ts-params": import_zod11.z.string().transform((s) => JSON.parse(s)),
822
- "x-ts-http-url": import_zod11.z.string(),
823
- "x-ts-http-method": import_zod11.z.string(),
824
- "x-ts-http-headers": import_zod11.z.string().transform((s) => import_zod11.z.record(import_zod11.z.string()).parse(JSON.parse(s))),
825
- "x-ts-auth": import_zod11.z.string().optional().transform((s) => {
771
+ var HttpSourceRequestHeadersSchema = zod.z.object({
772
+ "x-ts-key": zod.z.string(),
773
+ "x-ts-dynamic-id": zod.z.string().optional(),
774
+ "x-ts-secret": zod.z.string(),
775
+ "x-ts-data": zod.z.string().transform((s) => JSON.parse(s)),
776
+ "x-ts-params": zod.z.string().transform((s) => JSON.parse(s)),
777
+ "x-ts-http-url": zod.z.string(),
778
+ "x-ts-http-method": zod.z.string(),
779
+ "x-ts-http-headers": zod.z.string().transform((s) => zod.z.record(zod.z.string()).parse(JSON.parse(s))),
780
+ "x-ts-auth": zod.z.string().optional().transform((s) => {
826
781
  if (s === void 0)
827
782
  return;
828
783
  const json = JSON.parse(s);
829
784
  return ConnectionAuthSchema.parse(json);
830
785
  }),
831
- "x-ts-metadata": import_zod11.z.string().optional().transform((s) => {
786
+ "x-ts-metadata": zod.z.string().optional().transform((s) => {
832
787
  if (s === void 0)
833
788
  return;
834
789
  const json = JSON.parse(s);
835
790
  return DeserializedJsonSchema.parse(json);
836
791
  })
837
792
  });
838
- var PongSuccessResponseSchema = import_zod11.z.object({
839
- ok: import_zod11.z.literal(true)
840
- });
841
- var PongErrorResponseSchema = import_zod11.z.object({
842
- ok: import_zod11.z.literal(false),
843
- error: import_zod11.z.string()
844
- });
845
- var PongResponseSchema = import_zod11.z.discriminatedUnion("ok", [
793
+ var HttpEndpointRequestHeadersSchema = zod.z.object({
794
+ "x-ts-key": zod.z.string(),
795
+ "x-ts-http-url": zod.z.string(),
796
+ "x-ts-http-method": zod.z.string(),
797
+ "x-ts-http-headers": zod.z.string().transform((s) => zod.z.record(zod.z.string()).parse(JSON.parse(s)))
798
+ });
799
+ var WebhookSourceRequestHeadersSchema = zod.z.object({
800
+ "x-ts-key": zod.z.string(),
801
+ "x-ts-dynamic-id": zod.z.string().optional(),
802
+ "x-ts-secret": zod.z.string(),
803
+ "x-ts-params": zod.z.string().transform((s) => JSON.parse(s)),
804
+ "x-ts-http-url": zod.z.string(),
805
+ "x-ts-http-method": zod.z.string(),
806
+ "x-ts-http-headers": zod.z.string().transform((s) => zod.z.record(zod.z.string()).parse(JSON.parse(s)))
807
+ });
808
+ var PongSuccessResponseSchema = zod.z.object({
809
+ ok: zod.z.literal(true),
810
+ triggerVersion: zod.z.string().optional(),
811
+ triggerSdkVersion: zod.z.string().optional()
812
+ });
813
+ var PongErrorResponseSchema = zod.z.object({
814
+ ok: zod.z.literal(false),
815
+ error: zod.z.string(),
816
+ triggerVersion: zod.z.string().optional(),
817
+ triggerSdkVersion: zod.z.string().optional()
818
+ });
819
+ var PongResponseSchema = zod.z.discriminatedUnion("ok", [
846
820
  PongSuccessResponseSchema,
847
821
  PongErrorResponseSchema
848
822
  ]);
849
- var ValidateSuccessResponseSchema = import_zod11.z.object({
850
- ok: import_zod11.z.literal(true),
851
- endpointId: import_zod11.z.string()
823
+ var ValidateSuccessResponseSchema = zod.z.object({
824
+ ok: zod.z.literal(true),
825
+ endpointId: zod.z.string(),
826
+ triggerVersion: zod.z.string().optional()
852
827
  });
853
- var ValidateErrorResponseSchema = import_zod11.z.object({
854
- ok: import_zod11.z.literal(false),
855
- error: import_zod11.z.string()
828
+ var ValidateErrorResponseSchema = zod.z.object({
829
+ ok: zod.z.literal(false),
830
+ error: zod.z.string(),
831
+ triggerVersion: zod.z.string().optional()
856
832
  });
857
- var ValidateResponseSchema = import_zod11.z.discriminatedUnion("ok", [
833
+ var ValidateResponseSchema = zod.z.discriminatedUnion("ok", [
858
834
  ValidateSuccessResponseSchema,
859
835
  ValidateErrorResponseSchema
860
836
  ]);
861
- var QueueOptionsSchema = import_zod11.z.object({
862
- name: import_zod11.z.string(),
863
- maxConcurrent: import_zod11.z.number().optional()
864
- });
865
- var JobMetadataSchema = import_zod11.z.object({
866
- id: import_zod11.z.string(),
867
- name: import_zod11.z.string(),
868
- version: import_zod11.z.string(),
837
+ var QueueOptionsSchema = zod.z.object({
838
+ name: zod.z.string(),
839
+ maxConcurrent: zod.z.number().optional()
840
+ });
841
+ var ConcurrencyLimitOptionsSchema = zod.z.object({
842
+ id: zod.z.string(),
843
+ limit: zod.z.number()
844
+ });
845
+ var JobMetadataSchema = zod.z.object({
846
+ id: zod.z.string(),
847
+ name: zod.z.string(),
848
+ version: zod.z.string(),
869
849
  event: EventSpecificationSchema,
870
850
  trigger: TriggerMetadataSchema,
871
- integrations: import_zod11.z.record(IntegrationConfigSchema),
872
- internal: import_zod11.z.boolean().default(false),
873
- enabled: import_zod11.z.boolean(),
874
- startPosition: import_zod11.z.enum([
851
+ integrations: zod.z.record(IntegrationConfigSchema),
852
+ internal: zod.z.boolean().default(false),
853
+ enabled: zod.z.boolean(),
854
+ startPosition: zod.z.enum([
875
855
  "initial",
876
856
  "latest"
877
857
  ]),
878
- preprocessRuns: import_zod11.z.boolean()
858
+ preprocessRuns: zod.z.boolean(),
859
+ concurrencyLimit: ConcurrencyLimitOptionsSchema.or(zod.z.number().int().positive()).optional()
879
860
  });
880
- var SourceMetadataV1Schema = import_zod11.z.object({
881
- version: import_zod11.z.literal("1"),
882
- channel: import_zod11.z.enum([
861
+ var SourceMetadataV1Schema = zod.z.object({
862
+ version: zod.z.literal("1"),
863
+ channel: zod.z.enum([
883
864
  "HTTP",
884
865
  "SQS",
885
866
  "SMTP"
886
867
  ]),
887
868
  integration: IntegrationConfigSchema,
888
- key: import_zod11.z.string(),
889
- params: import_zod11.z.any(),
890
- events: import_zod11.z.array(import_zod11.z.string()),
891
- registerSourceJob: import_zod11.z.object({
892
- id: import_zod11.z.string(),
893
- version: import_zod11.z.string()
869
+ key: zod.z.string(),
870
+ params: zod.z.any(),
871
+ events: zod.z.array(zod.z.string()),
872
+ registerSourceJob: zod.z.object({
873
+ id: zod.z.string(),
874
+ version: zod.z.string()
894
875
  }).optional()
895
876
  });
896
- var SourceMetadataV2Schema = import_zod11.z.object({
897
- version: import_zod11.z.literal("2"),
898
- channel: import_zod11.z.enum([
877
+ var SourceMetadataV2Schema = zod.z.object({
878
+ version: zod.z.literal("2"),
879
+ channel: zod.z.enum([
899
880
  "HTTP",
900
881
  "SQS",
901
882
  "SMTP"
902
883
  ]),
903
884
  integration: IntegrationConfigSchema,
904
- key: import_zod11.z.string(),
905
- params: import_zod11.z.any(),
906
- options: import_zod11.z.record(import_zod11.z.array(import_zod11.z.string())),
907
- registerSourceJob: import_zod11.z.object({
908
- id: import_zod11.z.string(),
909
- version: import_zod11.z.string()
885
+ key: zod.z.string(),
886
+ params: zod.z.any(),
887
+ options: zod.z.record(zod.z.array(zod.z.string())),
888
+ registerSourceJob: zod.z.object({
889
+ id: zod.z.string(),
890
+ version: zod.z.string()
910
891
  }).optional()
911
892
  });
912
- var SourceMetadataSchema = import_zod11.z.preprocess(addMissingVersionField, import_zod11.z.discriminatedUnion("version", [
893
+ var SourceMetadataSchema = zod.z.preprocess(addMissingVersionField, zod.z.discriminatedUnion("version", [
913
894
  SourceMetadataV1Schema,
914
895
  SourceMetadataV2Schema
915
896
  ]));
916
- var DynamicTriggerEndpointMetadataSchema = import_zod11.z.object({
917
- id: import_zod11.z.string(),
918
- jobs: import_zod11.z.array(JobMetadataSchema.pick({
897
+ var WebhookMetadataSchema = zod.z.object({
898
+ key: zod.z.string(),
899
+ params: zod.z.any(),
900
+ config: zod.z.record(zod.z.array(zod.z.string())),
901
+ integration: IntegrationConfigSchema,
902
+ httpEndpoint: zod.z.object({
903
+ id: zod.z.string()
904
+ })
905
+ });
906
+ var WebhookContextMetadataSchema = zod.z.object({
907
+ params: zod.z.any(),
908
+ config: zod.z.record(zod.z.string().array()),
909
+ secret: zod.z.string()
910
+ });
911
+ var DynamicTriggerEndpointMetadataSchema = zod.z.object({
912
+ id: zod.z.string(),
913
+ jobs: zod.z.array(JobMetadataSchema.pick({
919
914
  id: true,
920
915
  version: true
921
916
  })),
922
- registerSourceJob: import_zod11.z.object({
923
- id: import_zod11.z.string(),
924
- version: import_zod11.z.string()
917
+ registerSourceJob: zod.z.object({
918
+ id: zod.z.string(),
919
+ version: zod.z.string()
925
920
  }).optional()
926
921
  });
927
- var IndexEndpointResponseSchema = import_zod11.z.object({
928
- jobs: import_zod11.z.array(JobMetadataSchema),
929
- sources: import_zod11.z.array(SourceMetadataSchema),
930
- dynamicTriggers: import_zod11.z.array(DynamicTriggerEndpointMetadataSchema),
931
- dynamicSchedules: import_zod11.z.array(RegisterDynamicSchedulePayloadSchema)
922
+ var HttpEndpointMetadataSchema = zod.z.object({
923
+ id: zod.z.string(),
924
+ version: zod.z.string(),
925
+ enabled: zod.z.boolean(),
926
+ title: zod.z.string().optional(),
927
+ icon: zod.z.string().optional(),
928
+ properties: zod.z.array(DisplayPropertySchema).optional(),
929
+ event: EventSpecificationSchema,
930
+ immediateResponseFilter: RequestFilterSchema.optional(),
931
+ skipTriggeringRuns: zod.z.boolean().optional(),
932
+ source: zod.z.string()
933
+ });
934
+ var IndexEndpointResponseSchema = zod.z.object({
935
+ jobs: zod.z.array(JobMetadataSchema),
936
+ sources: zod.z.array(SourceMetadataSchema),
937
+ webhooks: zod.z.array(WebhookMetadataSchema).optional(),
938
+ dynamicTriggers: zod.z.array(DynamicTriggerEndpointMetadataSchema),
939
+ dynamicSchedules: zod.z.array(RegisterDynamicSchedulePayloadSchema),
940
+ httpEndpoints: zod.z.array(HttpEndpointMetadataSchema).optional()
941
+ });
942
+ var EndpointIndexErrorSchema = zod.z.object({
943
+ message: zod.z.string(),
944
+ raw: zod.z.any().optional()
945
+ });
946
+ var IndexEndpointStatsSchema = zod.z.object({
947
+ jobs: zod.z.number(),
948
+ sources: zod.z.number(),
949
+ webhooks: zod.z.number().optional(),
950
+ dynamicTriggers: zod.z.number(),
951
+ dynamicSchedules: zod.z.number(),
952
+ disabledJobs: zod.z.number().default(0),
953
+ httpEndpoints: zod.z.number().default(0)
954
+ });
955
+ function parseEndpointIndexStats(stats) {
956
+ if (stats === null || stats === void 0) {
957
+ return;
958
+ }
959
+ return IndexEndpointStatsSchema.parse(stats);
960
+ }
961
+ __name(parseEndpointIndexStats, "parseEndpointIndexStats");
962
+ var GetEndpointIndexResponseSchema = zod.z.discriminatedUnion("status", [
963
+ zod.z.object({
964
+ status: zod.z.literal("PENDING"),
965
+ updatedAt: zod.z.coerce.date()
966
+ }),
967
+ zod.z.object({
968
+ status: zod.z.literal("STARTED"),
969
+ updatedAt: zod.z.coerce.date()
970
+ }),
971
+ zod.z.object({
972
+ status: zod.z.literal("SUCCESS"),
973
+ stats: IndexEndpointStatsSchema,
974
+ updatedAt: zod.z.coerce.date()
975
+ }),
976
+ zod.z.object({
977
+ status: zod.z.literal("FAILURE"),
978
+ error: EndpointIndexErrorSchema,
979
+ updatedAt: zod.z.coerce.date()
980
+ })
981
+ ]);
982
+ var EndpointHeadersSchema = zod.z.object({
983
+ "trigger-version": zod.z.string().optional(),
984
+ "trigger-sdk-version": zod.z.string().optional()
985
+ });
986
+ var ExecuteJobRunMetadataSchema = zod.z.object({
987
+ successSubscription: zod.z.boolean().optional(),
988
+ failedSubscription: zod.z.boolean().optional()
989
+ });
990
+ var ExecuteJobHeadersSchema = EndpointHeadersSchema.extend({
991
+ "x-trigger-run-metadata": zod.z.preprocess((val) => typeof val === "string" && JSON.parse(val), ExecuteJobRunMetadataSchema).optional()
932
992
  });
933
- var RawEventSchema = import_zod11.z.object({
993
+ var RawEventSchema = zod.z.object({
934
994
  /** The `name` property must exactly match any subscriptions you want to
935
995
  trigger. */
936
- name: import_zod11.z.string(),
996
+ name: zod.z.string(),
937
997
  /** The `payload` property will be sent to any matching Jobs and will appear
938
998
  as the `payload` param of the `run()` function. You can leave this
939
999
  parameter out if you just want to trigger a Job without any input data. */
940
- payload: import_zod11.z.any(),
1000
+ payload: zod.z.any(),
941
1001
  /** The optional `context` property will be sent to any matching Jobs and will
942
1002
  be passed through as the `context.event.context` param of the `run()`
943
1003
  function. This is optional but can be useful if you want to pass through
944
1004
  some additional context to the Job. */
945
- context: import_zod11.z.any().optional(),
1005
+ context: zod.z.any().optional(),
946
1006
  /** The `id` property uniquely identify this particular event. If unset it
947
1007
  will be set automatically using `ulid`. */
948
- id: import_zod11.z.string().default(() => (0, import_ulid.ulid)()),
1008
+ id: zod.z.string().default(() => ulidx.ulid()),
949
1009
  /** This is optional, it defaults to the current timestamp. Usually you would
950
1010
  only set this if you have a timestamp that you wish to pass through, e.g.
951
1011
  you receive a timestamp from a service and you want the same timestamp to
952
1012
  be used in your Job. */
953
- timestamp: import_zod11.z.coerce.date().optional(),
1013
+ timestamp: zod.z.coerce.date().optional(),
954
1014
  /** This is optional, it defaults to "trigger.dev". It can be useful to set
955
1015
  this as you can filter events using this in the `eventTrigger()`. */
956
- source: import_zod11.z.string().optional()
1016
+ source: zod.z.string().optional(),
1017
+ /** This is optional, it defaults to "JSON". If your event is actually a request,
1018
+ with a url, headers, method and rawBody you can use "REQUEST" */
1019
+ payloadType: zod.z.union([
1020
+ zod.z.literal("JSON"),
1021
+ zod.z.literal("REQUEST")
1022
+ ]).optional()
957
1023
  });
958
- var ApiEventLogSchema = import_zod11.z.object({
1024
+ var ApiEventLogSchema = zod.z.object({
959
1025
  /** The `id` of the event that was sent.
960
1026
  */
961
- id: import_zod11.z.string(),
1027
+ id: zod.z.string(),
962
1028
  /** The `name` of the event that was sent. */
963
- name: import_zod11.z.string(),
1029
+ name: zod.z.string(),
964
1030
  /** The `payload` of the event that was sent */
965
1031
  payload: DeserializedJsonSchema,
966
1032
  /** The `context` of the event that was sent. Is `undefined` if no context was
967
1033
  set when sending the event. */
968
1034
  context: DeserializedJsonSchema.optional().nullable(),
969
1035
  /** The `timestamp` of the event that was sent */
970
- timestamp: import_zod11.z.coerce.date(),
1036
+ timestamp: zod.z.coerce.date(),
971
1037
  /** The timestamp when the event will be delivered to any matching Jobs. Is
972
1038
  `undefined` if `deliverAt` or `deliverAfter` wasn't set when sending the
973
1039
  event. */
974
- deliverAt: import_zod11.z.coerce.date().optional().nullable(),
1040
+ deliverAt: zod.z.coerce.date().optional().nullable(),
975
1041
  /** The timestamp when the event was delivered. Is `undefined` if `deliverAt`
976
1042
  or `deliverAfter` were set when sending the event. */
977
- deliveredAt: import_zod11.z.coerce.date().optional().nullable(),
1043
+ deliveredAt: zod.z.coerce.date().optional().nullable(),
978
1044
  /** The timestamp when the event was cancelled. Is `undefined` if the event
979
1045
  * wasn't cancelled. */
980
- cancelledAt: import_zod11.z.coerce.date().optional().nullable()
1046
+ cancelledAt: zod.z.coerce.date().optional().nullable()
981
1047
  });
982
- var SendEventOptionsSchema = import_zod11.z.object({
1048
+ var SendEventOptionsSchema = zod.z.object({
983
1049
  /** An optional Date when you want the event to trigger Jobs. The event will
984
1050
  be sent to the platform immediately but won't be acted upon until the
985
1051
  specified time. */
986
- deliverAt: import_zod11.z.coerce.date().optional(),
1052
+ deliverAt: zod.z.coerce.date().optional(),
987
1053
  /** An optional number of seconds you want to wait for the event to trigger
988
1054
  any relevant Jobs. The event will be sent to the platform immediately but
989
1055
  won't be delivered until after the elapsed number of seconds. */
990
- deliverAfter: import_zod11.z.number().int().optional(),
1056
+ deliverAfter: zod.z.number().int().optional(),
991
1057
  /** This optional param will be used by Trigger.dev Connect, which
992
1058
  is coming soon. */
993
- accountId: import_zod11.z.string().optional()
1059
+ accountId: zod.z.string().optional()
994
1060
  });
995
- var SendEventBodySchema = import_zod11.z.object({
1061
+ var SendEventBodySchema = zod.z.object({
996
1062
  event: RawEventSchema,
997
1063
  options: SendEventOptionsSchema.optional()
998
1064
  });
999
- var DeliverEventResponseSchema = import_zod11.z.object({
1000
- deliveredAt: import_zod11.z.string().datetime()
1065
+ var SendBulkEventsBodySchema = zod.z.object({
1066
+ events: RawEventSchema.array(),
1067
+ options: SendEventOptionsSchema.optional()
1068
+ });
1069
+ var DeliverEventResponseSchema = zod.z.object({
1070
+ deliveredAt: zod.z.string().datetime()
1001
1071
  });
1002
- var RuntimeEnvironmentTypeSchema = import_zod11.z.enum([
1072
+ var RuntimeEnvironmentTypeSchema = zod.z.enum([
1003
1073
  "PRODUCTION",
1004
1074
  "STAGING",
1005
1075
  "DEVELOPMENT",
1006
1076
  "PREVIEW"
1007
1077
  ]);
1008
- var RunSourceContextSchema = import_zod11.z.object({
1009
- id: import_zod11.z.string(),
1010
- metadata: import_zod11.z.any()
1078
+ var RunSourceContextSchema = zod.z.object({
1079
+ id: zod.z.string(),
1080
+ metadata: zod.z.any()
1011
1081
  });
1012
- var RunJobBodySchema = import_zod11.z.object({
1082
+ var AutoYieldConfigSchema = zod.z.object({
1083
+ startTaskThreshold: zod.z.number(),
1084
+ beforeExecuteTaskThreshold: zod.z.number(),
1085
+ beforeCompleteTaskThreshold: zod.z.number(),
1086
+ afterCompleteTaskThreshold: zod.z.number()
1087
+ });
1088
+ var RunJobBodySchema = zod.z.object({
1013
1089
  event: ApiEventLogSchema,
1014
- job: import_zod11.z.object({
1015
- id: import_zod11.z.string(),
1016
- version: import_zod11.z.string()
1090
+ job: zod.z.object({
1091
+ id: zod.z.string(),
1092
+ version: zod.z.string()
1017
1093
  }),
1018
- run: import_zod11.z.object({
1019
- id: import_zod11.z.string(),
1020
- isTest: import_zod11.z.boolean(),
1021
- isRetry: import_zod11.z.boolean().default(false),
1022
- startedAt: import_zod11.z.coerce.date()
1094
+ run: zod.z.object({
1095
+ id: zod.z.string(),
1096
+ isTest: zod.z.boolean(),
1097
+ isRetry: zod.z.boolean().default(false),
1098
+ startedAt: zod.z.coerce.date()
1023
1099
  }),
1024
- environment: import_zod11.z.object({
1025
- id: import_zod11.z.string(),
1026
- slug: import_zod11.z.string(),
1100
+ environment: zod.z.object({
1101
+ id: zod.z.string(),
1102
+ slug: zod.z.string(),
1027
1103
  type: RuntimeEnvironmentTypeSchema
1028
1104
  }),
1029
- organization: import_zod11.z.object({
1030
- id: import_zod11.z.string(),
1031
- title: import_zod11.z.string(),
1032
- slug: import_zod11.z.string()
1105
+ organization: zod.z.object({
1106
+ id: zod.z.string(),
1107
+ title: zod.z.string(),
1108
+ slug: zod.z.string()
1033
1109
  }),
1034
- account: import_zod11.z.object({
1035
- id: import_zod11.z.string(),
1036
- metadata: import_zod11.z.any()
1110
+ project: zod.z.object({
1111
+ id: zod.z.string(),
1112
+ name: zod.z.string(),
1113
+ slug: zod.z.string()
1114
+ }).optional(),
1115
+ account: zod.z.object({
1116
+ id: zod.z.string(),
1117
+ metadata: zod.z.any()
1037
1118
  }).optional(),
1038
1119
  source: RunSourceContextSchema.optional(),
1039
- tasks: import_zod11.z.array(CachedTaskSchema).optional(),
1040
- connections: import_zod11.z.record(ConnectionAuthSchema).optional()
1041
- });
1042
- var RunJobErrorSchema = import_zod11.z.object({
1043
- status: import_zod11.z.literal("ERROR"),
1120
+ tasks: zod.z.array(CachedTaskSchema).optional(),
1121
+ cachedTaskCursor: zod.z.string().optional(),
1122
+ noopTasksSet: zod.z.string().optional(),
1123
+ connections: zod.z.record(ConnectionAuthSchema).optional(),
1124
+ yieldedExecutions: zod.z.string().array().optional(),
1125
+ runChunkExecutionLimit: zod.z.number().optional(),
1126
+ autoYieldConfig: AutoYieldConfigSchema.optional()
1127
+ });
1128
+ var RunJobErrorSchema = zod.z.object({
1129
+ status: zod.z.literal("ERROR"),
1044
1130
  error: ErrorWithStackSchema,
1045
1131
  task: TaskSchema.optional()
1046
1132
  });
1047
- var RunJobResumeWithTaskSchema = import_zod11.z.object({
1048
- status: import_zod11.z.literal("RESUME_WITH_TASK"),
1133
+ var RunJobYieldExecutionErrorSchema = zod.z.object({
1134
+ status: zod.z.literal("YIELD_EXECUTION"),
1135
+ key: zod.z.string()
1136
+ });
1137
+ var AutoYieldMetadataSchema = zod.z.object({
1138
+ location: zod.z.string(),
1139
+ timeRemaining: zod.z.number(),
1140
+ timeElapsed: zod.z.number(),
1141
+ limit: zod.z.number().optional()
1142
+ });
1143
+ var RunJobAutoYieldExecutionErrorSchema = AutoYieldMetadataSchema.extend({
1144
+ status: zod.z.literal("AUTO_YIELD_EXECUTION")
1145
+ });
1146
+ var RunJobAutoYieldWithCompletedTaskExecutionErrorSchema = zod.z.object({
1147
+ status: zod.z.literal("AUTO_YIELD_EXECUTION_WITH_COMPLETED_TASK"),
1148
+ id: zod.z.string(),
1149
+ properties: zod.z.array(DisplayPropertySchema).optional(),
1150
+ output: zod.z.string().optional(),
1151
+ data: AutoYieldMetadataSchema
1152
+ });
1153
+ var RunJobInvalidPayloadErrorSchema = zod.z.object({
1154
+ status: zod.z.literal("INVALID_PAYLOAD"),
1155
+ errors: zod.z.array(SchemaErrorSchema)
1156
+ });
1157
+ var RunJobUnresolvedAuthErrorSchema = zod.z.object({
1158
+ status: zod.z.literal("UNRESOLVED_AUTH_ERROR"),
1159
+ issues: zod.z.record(zod.z.object({
1160
+ id: zod.z.string(),
1161
+ error: zod.z.string()
1162
+ }))
1163
+ });
1164
+ var RunJobResumeWithTaskSchema = zod.z.object({
1165
+ status: zod.z.literal("RESUME_WITH_TASK"),
1049
1166
  task: TaskSchema
1050
1167
  });
1051
- var RunJobRetryWithTaskSchema = import_zod11.z.object({
1052
- status: import_zod11.z.literal("RETRY_WITH_TASK"),
1168
+ var RunJobRetryWithTaskSchema = zod.z.object({
1169
+ status: zod.z.literal("RETRY_WITH_TASK"),
1053
1170
  task: TaskSchema,
1054
1171
  error: ErrorWithStackSchema,
1055
- retryAt: import_zod11.z.coerce.date()
1172
+ retryAt: zod.z.coerce.date()
1056
1173
  });
1057
- var RunJobCanceledWithTaskSchema = import_zod11.z.object({
1058
- status: import_zod11.z.literal("CANCELED"),
1174
+ var RunJobCanceledWithTaskSchema = zod.z.object({
1175
+ status: zod.z.literal("CANCELED"),
1059
1176
  task: TaskSchema
1060
1177
  });
1061
- var RunJobSuccessSchema = import_zod11.z.object({
1062
- status: import_zod11.z.literal("SUCCESS"),
1178
+ var RunJobSuccessSchema = zod.z.object({
1179
+ status: zod.z.literal("SUCCESS"),
1063
1180
  output: DeserializedJsonSchema.optional()
1064
1181
  });
1065
- var RunJobResponseSchema = import_zod11.z.discriminatedUnion("status", [
1182
+ var RunJobErrorResponseSchema = zod.z.union([
1183
+ RunJobAutoYieldExecutionErrorSchema,
1184
+ RunJobAutoYieldWithCompletedTaskExecutionErrorSchema,
1185
+ RunJobYieldExecutionErrorSchema,
1066
1186
  RunJobErrorSchema,
1187
+ RunJobUnresolvedAuthErrorSchema,
1188
+ RunJobInvalidPayloadErrorSchema,
1067
1189
  RunJobResumeWithTaskSchema,
1068
1190
  RunJobRetryWithTaskSchema,
1191
+ RunJobCanceledWithTaskSchema
1192
+ ]);
1193
+ var RunJobResumeWithParallelTaskSchema = zod.z.object({
1194
+ status: zod.z.literal("RESUME_WITH_PARALLEL_TASK"),
1195
+ task: TaskSchema,
1196
+ childErrors: zod.z.array(RunJobErrorResponseSchema)
1197
+ });
1198
+ var RunJobResponseSchema = zod.z.discriminatedUnion("status", [
1199
+ RunJobAutoYieldExecutionErrorSchema,
1200
+ RunJobAutoYieldWithCompletedTaskExecutionErrorSchema,
1201
+ RunJobYieldExecutionErrorSchema,
1202
+ RunJobErrorSchema,
1203
+ RunJobUnresolvedAuthErrorSchema,
1204
+ RunJobInvalidPayloadErrorSchema,
1205
+ RunJobResumeWithTaskSchema,
1206
+ RunJobResumeWithParallelTaskSchema,
1207
+ RunJobRetryWithTaskSchema,
1069
1208
  RunJobCanceledWithTaskSchema,
1070
1209
  RunJobSuccessSchema
1071
1210
  ]);
1072
- var PreprocessRunBodySchema = import_zod11.z.object({
1211
+ var PreprocessRunBodySchema = zod.z.object({
1073
1212
  event: ApiEventLogSchema,
1074
- job: import_zod11.z.object({
1075
- id: import_zod11.z.string(),
1076
- version: import_zod11.z.string()
1213
+ job: zod.z.object({
1214
+ id: zod.z.string(),
1215
+ version: zod.z.string()
1077
1216
  }),
1078
- run: import_zod11.z.object({
1079
- id: import_zod11.z.string(),
1080
- isTest: import_zod11.z.boolean()
1217
+ run: zod.z.object({
1218
+ id: zod.z.string(),
1219
+ isTest: zod.z.boolean()
1081
1220
  }),
1082
- environment: import_zod11.z.object({
1083
- id: import_zod11.z.string(),
1084
- slug: import_zod11.z.string(),
1221
+ environment: zod.z.object({
1222
+ id: zod.z.string(),
1223
+ slug: zod.z.string(),
1085
1224
  type: RuntimeEnvironmentTypeSchema
1086
1225
  }),
1087
- organization: import_zod11.z.object({
1088
- id: import_zod11.z.string(),
1089
- title: import_zod11.z.string(),
1090
- slug: import_zod11.z.string()
1226
+ organization: zod.z.object({
1227
+ id: zod.z.string(),
1228
+ title: zod.z.string(),
1229
+ slug: zod.z.string()
1091
1230
  }),
1092
- account: import_zod11.z.object({
1093
- id: import_zod11.z.string(),
1094
- metadata: import_zod11.z.any()
1231
+ account: zod.z.object({
1232
+ id: zod.z.string(),
1233
+ metadata: zod.z.any()
1095
1234
  }).optional()
1096
1235
  });
1097
- var PreprocessRunResponseSchema = import_zod11.z.object({
1098
- abort: import_zod11.z.boolean(),
1099
- properties: import_zod11.z.array(DisplayPropertySchema).optional()
1236
+ var PreprocessRunResponseSchema = zod.z.object({
1237
+ abort: zod.z.boolean(),
1238
+ properties: zod.z.array(DisplayPropertySchema).optional()
1100
1239
  });
1101
- var CreateRunResponseOkSchema = import_zod11.z.object({
1102
- ok: import_zod11.z.literal(true),
1103
- data: import_zod11.z.object({
1104
- id: import_zod11.z.string()
1240
+ var CreateRunResponseOkSchema = zod.z.object({
1241
+ ok: zod.z.literal(true),
1242
+ data: zod.z.object({
1243
+ id: zod.z.string()
1105
1244
  })
1106
1245
  });
1107
- var CreateRunResponseErrorSchema = import_zod11.z.object({
1108
- ok: import_zod11.z.literal(false),
1109
- error: import_zod11.z.string()
1246
+ var CreateRunResponseErrorSchema = zod.z.object({
1247
+ ok: zod.z.literal(false),
1248
+ error: zod.z.string()
1110
1249
  });
1111
- var CreateRunResponseBodySchema = import_zod11.z.discriminatedUnion("ok", [
1250
+ var CreateRunResponseBodySchema = zod.z.discriminatedUnion("ok", [
1112
1251
  CreateRunResponseOkSchema,
1113
1252
  CreateRunResponseErrorSchema
1114
1253
  ]);
1115
- var RedactStringSchema = import_zod11.z.object({
1116
- __redactedString: import_zod11.z.literal(true),
1117
- strings: import_zod11.z.array(import_zod11.z.string()),
1118
- interpolations: import_zod11.z.array(import_zod11.z.string())
1254
+ var RedactStringSchema = zod.z.object({
1255
+ __redactedString: zod.z.literal(true),
1256
+ strings: zod.z.array(zod.z.string()),
1257
+ interpolations: zod.z.array(zod.z.string())
1119
1258
  });
1120
- var LogMessageSchema = import_zod11.z.object({
1121
- level: import_zod11.z.enum([
1259
+ var LogMessageSchema = zod.z.object({
1260
+ level: zod.z.enum([
1122
1261
  "DEBUG",
1123
1262
  "INFO",
1124
1263
  "WARN",
1125
1264
  "ERROR"
1126
1265
  ]),
1127
- message: import_zod11.z.string(),
1266
+ message: zod.z.string(),
1128
1267
  data: SerializableJsonSchema.optional()
1129
1268
  });
1130
- var RedactSchema = import_zod11.z.object({
1131
- paths: import_zod11.z.array(import_zod11.z.string())
1269
+ var RedactSchema = zod.z.object({
1270
+ paths: zod.z.array(zod.z.string())
1132
1271
  });
1133
- var RetryOptionsSchema = import_zod11.z.object({
1272
+ var RetryOptionsSchema = zod.z.object({
1134
1273
  /** The maximum number of times to retry the request. */
1135
- limit: import_zod11.z.number().optional(),
1274
+ limit: zod.z.number().optional(),
1136
1275
  /** The exponential factor to use when calculating the next retry time. */
1137
- factor: import_zod11.z.number().optional(),
1276
+ factor: zod.z.number().optional(),
1138
1277
  /** The minimum amount of time to wait before retrying the request. */
1139
- minTimeoutInMs: import_zod11.z.number().optional(),
1278
+ minTimeoutInMs: zod.z.number().optional(),
1140
1279
  /** The maximum amount of time to wait before retrying the request. */
1141
- maxTimeoutInMs: import_zod11.z.number().optional(),
1280
+ maxTimeoutInMs: zod.z.number().optional(),
1142
1281
  /** Whether to randomize the retry time. */
1143
- randomize: import_zod11.z.boolean().optional()
1282
+ randomize: zod.z.boolean().optional()
1144
1283
  });
1145
- var RunTaskOptionsSchema = import_zod11.z.object({
1284
+ var RunTaskOptionsSchema = zod.z.object({
1146
1285
  /** The name of the Task is required. This is displayed on the Task in the logs. */
1147
- name: import_zod11.z.string().optional(),
1286
+ name: zod.z.string().optional(),
1148
1287
  /** The Task will wait and only start at the specified Date */
1149
- delayUntil: import_zod11.z.coerce.date().optional(),
1288
+ delayUntil: zod.z.coerce.date().optional(),
1150
1289
  /** Retry options */
1151
1290
  retry: RetryOptionsSchema.optional(),
1152
1291
  /** The icon for the Task, it will appear in the logs.
1153
1292
  * You can use the name of a company in lowercase, e.g. "github".
1154
- * Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
1155
- icon: import_zod11.z.string().optional(),
1293
+ * Or any icon name that [Tabler Icons](https://tabler-icons.io/) supports. */
1294
+ icon: zod.z.string().optional(),
1156
1295
  /** The key for the Task that you want to appear in the logs */
1157
- displayKey: import_zod11.z.string().optional(),
1296
+ displayKey: zod.z.string().optional(),
1158
1297
  /** A description of the Task */
1159
- description: import_zod11.z.string().optional(),
1298
+ description: zod.z.string().optional(),
1160
1299
  /** Properties that are displayed in the logs */
1161
- properties: import_zod11.z.array(DisplayPropertySchema).optional(),
1300
+ properties: zod.z.array(DisplayPropertySchema).optional(),
1162
1301
  /** The input params to the Task, will be displayed in the logs */
1163
- params: import_zod11.z.any(),
1302
+ params: zod.z.any(),
1164
1303
  /** The style of the log entry. */
1165
1304
  style: StyleSchema.optional(),
1305
+ /** Allows you to expose a `task.callbackUrl` to use in your tasks. Enabling this feature will cause the task to return the data sent to the callbackUrl instead of the usual async callback result. */
1306
+ callback: zod.z.object({
1307
+ /** Causes the task to wait for and return the data of the first request sent to `task.callbackUrl`. */
1308
+ enabled: zod.z.boolean(),
1309
+ /** Time to wait for the first request to `task.callbackUrl`. Default: One hour. */
1310
+ timeoutInSeconds: zod.z.number()
1311
+ }).partial().optional(),
1166
1312
  /** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
1167
- connectionKey: import_zod11.z.string().optional(),
1168
- /** An operation you want to perform on the Trigger.dev platform, current only "fetch" is supported. If you wish to `fetch` use [`io.backgroundFetch()`](https://trigger.dev/docs/sdk/io/backgroundfetch) instead. */
1169
- operation: import_zod11.z.enum([
1170
- "fetch"
1313
+ connectionKey: zod.z.string().optional(),
1314
+ /** An operation you want to perform on the Trigger.dev platform, current only "fetch", "fetch-response", and "fetch-poll" is supported. If you wish to `fetch` use [`io.backgroundFetch()`](https://trigger.dev/docs/sdk/io/backgroundfetch) instead. */
1315
+ operation: zod.z.enum([
1316
+ "fetch",
1317
+ "fetch-response",
1318
+ "fetch-poll"
1171
1319
  ]).optional(),
1172
1320
  /** A No Operation means that the code won't be executed. This is used internally to implement features like [io.wait()](https://trigger.dev/docs/sdk/io/wait). */
1173
- noop: import_zod11.z.boolean().default(false),
1321
+ noop: zod.z.boolean().default(false),
1174
1322
  redact: RedactSchema.optional(),
1175
- trigger: TriggerMetadataSchema.optional()
1323
+ parallel: zod.z.boolean().optional()
1176
1324
  });
1177
1325
  var RunTaskBodyInputSchema = RunTaskOptionsSchema.extend({
1178
- idempotencyKey: import_zod11.z.string(),
1179
- parentId: import_zod11.z.string().optional()
1326
+ idempotencyKey: zod.z.string(),
1327
+ parentId: zod.z.string().optional()
1180
1328
  });
1181
1329
  var RunTaskBodyOutputSchema = RunTaskBodyInputSchema.extend({
1182
- params: DeserializedJsonSchema.optional().nullable()
1330
+ properties: zod.z.array(DisplayPropertySchema.partial()).optional(),
1331
+ params: DeserializedJsonSchema.optional().nullable(),
1332
+ callback: zod.z.object({
1333
+ enabled: zod.z.boolean(),
1334
+ timeoutInSeconds: zod.z.number().default(3600)
1335
+ }).optional()
1336
+ });
1337
+ var RunTaskResponseWithCachedTasksBodySchema = zod.z.object({
1338
+ task: ServerTaskSchema,
1339
+ cachedTasks: zod.z.object({
1340
+ tasks: zod.z.array(CachedTaskSchema),
1341
+ cursor: zod.z.string().optional()
1342
+ }).optional()
1183
1343
  });
1184
1344
  var CompleteTaskBodyInputSchema = RunTaskBodyInputSchema.pick({
1185
1345
  properties: true,
@@ -1188,198 +1348,287 @@ var CompleteTaskBodyInputSchema = RunTaskBodyInputSchema.pick({
1188
1348
  }).extend({
1189
1349
  output: SerializableJsonSchema.optional().transform((v) => v ? DeserializedJsonSchema.parse(JSON.parse(JSON.stringify(v))) : {})
1190
1350
  });
1191
- var FailTaskBodyInputSchema = import_zod11.z.object({
1351
+ var CompleteTaskBodyV2InputSchema = RunTaskBodyInputSchema.pick({
1352
+ properties: true,
1353
+ description: true,
1354
+ params: true
1355
+ }).extend({
1356
+ output: zod.z.string().optional()
1357
+ });
1358
+ var FailTaskBodyInputSchema = zod.z.object({
1192
1359
  error: ErrorWithStackSchema
1193
1360
  });
1194
- var NormalizedRequestSchema = import_zod11.z.object({
1195
- headers: import_zod11.z.record(import_zod11.z.string()),
1196
- method: import_zod11.z.string(),
1197
- query: import_zod11.z.record(import_zod11.z.string()),
1198
- url: import_zod11.z.string(),
1199
- body: import_zod11.z.any()
1361
+ var NormalizedRequestSchema = zod.z.object({
1362
+ headers: zod.z.record(zod.z.string()),
1363
+ method: zod.z.string(),
1364
+ query: zod.z.record(zod.z.string()),
1365
+ url: zod.z.string(),
1366
+ body: zod.z.any()
1200
1367
  });
1201
- var NormalizedResponseSchema = import_zod11.z.object({
1202
- status: import_zod11.z.number(),
1203
- body: import_zod11.z.any(),
1204
- headers: import_zod11.z.record(import_zod11.z.string()).optional()
1368
+ var NormalizedResponseSchema = zod.z.object({
1369
+ status: zod.z.number(),
1370
+ body: zod.z.any(),
1371
+ headers: zod.z.record(zod.z.string()).optional()
1205
1372
  });
1206
- var HttpSourceResponseSchema = import_zod11.z.object({
1373
+ var HttpSourceResponseSchema = zod.z.object({
1207
1374
  response: NormalizedResponseSchema,
1208
- events: import_zod11.z.array(RawEventSchema),
1375
+ events: zod.z.array(RawEventSchema),
1209
1376
  metadata: HttpSourceResponseMetadataSchema.optional()
1210
1377
  });
1211
- var RegisterTriggerBodySchemaV1 = import_zod11.z.object({
1378
+ var WebhookDeliveryResponseSchema = zod.z.object({
1379
+ response: NormalizedResponseSchema,
1380
+ verified: zod.z.boolean(),
1381
+ error: zod.z.string().optional()
1382
+ });
1383
+ var RegisterTriggerBodySchemaV1 = zod.z.object({
1212
1384
  rule: EventRuleSchema,
1213
1385
  source: SourceMetadataV1Schema
1214
1386
  });
1215
- var RegisterTriggerBodySchemaV2 = import_zod11.z.object({
1387
+ var RegisterTriggerBodySchemaV2 = zod.z.object({
1216
1388
  rule: EventRuleSchema,
1217
- source: SourceMetadataV2Schema
1389
+ source: SourceMetadataV2Schema,
1390
+ accountId: zod.z.string().optional()
1218
1391
  });
1219
- var InitializeTriggerBodySchema = import_zod11.z.object({
1220
- id: import_zod11.z.string(),
1221
- params: import_zod11.z.any(),
1222
- accountId: import_zod11.z.string().optional(),
1223
- metadata: import_zod11.z.any().optional()
1392
+ var InitializeTriggerBodySchema = zod.z.object({
1393
+ id: zod.z.string(),
1394
+ params: zod.z.any(),
1395
+ accountId: zod.z.string().optional(),
1396
+ metadata: zod.z.any().optional()
1224
1397
  });
1225
- var RegisterCommonScheduleBodySchema = import_zod11.z.object({
1398
+ var RegisterCommonScheduleBodySchema = zod.z.object({
1226
1399
  /** A unique id for the schedule. This is used to identify and unregister the schedule later. */
1227
- id: import_zod11.z.string(),
1400
+ id: zod.z.string(),
1228
1401
  /** Any additional metadata about the schedule. */
1229
- metadata: import_zod11.z.any(),
1230
- /** This will be used by the Trigger.dev Connect feature, which is coming soon. */
1231
- accountId: import_zod11.z.string().optional()
1402
+ metadata: zod.z.any(),
1403
+ /** An optional Account ID to associate with runs triggered by this schedule */
1404
+ accountId: zod.z.string().optional()
1232
1405
  });
1233
1406
  var RegisterIntervalScheduleBodySchema = RegisterCommonScheduleBodySchema.merge(IntervalMetadataSchema);
1234
1407
  var InitializeCronScheduleBodySchema = RegisterCommonScheduleBodySchema.merge(CronMetadataSchema);
1235
- var RegisterScheduleBodySchema = import_zod11.z.discriminatedUnion("type", [
1408
+ var RegisterScheduleBodySchema = zod.z.discriminatedUnion("type", [
1236
1409
  RegisterIntervalScheduleBodySchema,
1237
1410
  InitializeCronScheduleBodySchema
1238
1411
  ]);
1239
- var RegisterScheduleResponseBodySchema = import_zod11.z.object({
1240
- id: import_zod11.z.string(),
1412
+ var RegisterScheduleResponseBodySchema = zod.z.object({
1413
+ id: zod.z.string(),
1241
1414
  schedule: ScheduleMetadataSchema,
1242
- metadata: import_zod11.z.any(),
1243
- active: import_zod11.z.boolean()
1415
+ metadata: zod.z.any(),
1416
+ active: zod.z.boolean()
1244
1417
  });
1245
- var CreateExternalConnectionBodySchema = import_zod11.z.object({
1246
- accessToken: import_zod11.z.string(),
1247
- type: import_zod11.z.enum([
1418
+ var CreateExternalConnectionBodySchema = zod.z.object({
1419
+ accessToken: zod.z.string(),
1420
+ type: zod.z.enum([
1248
1421
  "oauth2"
1249
1422
  ]),
1250
- scopes: import_zod11.z.array(import_zod11.z.string()).optional(),
1251
- metadata: import_zod11.z.any()
1423
+ scopes: zod.z.array(zod.z.string()).optional(),
1424
+ metadata: zod.z.any()
1252
1425
  });
1253
- var GetRunStatusesSchema = import_zod11.z.object({
1254
- run: import_zod11.z.object({
1255
- id: import_zod11.z.string(),
1426
+ var GetRunStatusesSchema = zod.z.object({
1427
+ run: zod.z.object({
1428
+ id: zod.z.string(),
1256
1429
  status: RunStatusSchema,
1257
- output: import_zod11.z.any().optional()
1430
+ output: zod.z.any().optional()
1258
1431
  }),
1259
- statuses: import_zod11.z.array(JobRunStatusRecordSchema)
1432
+ statuses: zod.z.array(JobRunStatusRecordSchema)
1260
1433
  });
1261
-
1262
- // src/schemas/notifications.ts
1263
- var import_zod12 = require("zod");
1434
+ var InvokeJobResponseSchema = zod.z.object({
1435
+ id: zod.z.string()
1436
+ });
1437
+ var InvokeJobRequestBodySchema = zod.z.object({
1438
+ payload: zod.z.any(),
1439
+ context: zod.z.any().optional(),
1440
+ options: zod.z.object({
1441
+ accountId: zod.z.string().optional(),
1442
+ callbackUrl: zod.z.string().optional()
1443
+ }).optional()
1444
+ });
1445
+ var InvokeOptionsSchema = zod.z.object({
1446
+ accountId: zod.z.string().optional(),
1447
+ idempotencyKey: zod.z.string().optional(),
1448
+ context: zod.z.any().optional(),
1449
+ callbackUrl: zod.z.string().optional()
1450
+ });
1451
+ var EphemeralEventDispatcherRequestBodySchema = zod.z.object({
1452
+ url: zod.z.string(),
1453
+ name: zod.z.string().or(zod.z.array(zod.z.string())),
1454
+ source: zod.z.string().optional(),
1455
+ filter: EventFilterSchema.optional(),
1456
+ contextFilter: EventFilterSchema.optional(),
1457
+ accountId: zod.z.string().optional(),
1458
+ timeoutInSeconds: zod.z.number().int().positive().min(10).max(60 * 60 * 24 * 365).default(3600)
1459
+ });
1460
+ var EphemeralEventDispatcherResponseBodySchema = zod.z.object({
1461
+ id: zod.z.string()
1462
+ });
1463
+ var KeyValueStoreResponseBodySchema = zod.z.discriminatedUnion("action", [
1464
+ zod.z.object({
1465
+ action: zod.z.literal("DELETE"),
1466
+ key: zod.z.string(),
1467
+ deleted: zod.z.boolean()
1468
+ }),
1469
+ zod.z.object({
1470
+ action: zod.z.literal("GET"),
1471
+ key: zod.z.string(),
1472
+ value: zod.z.string().optional()
1473
+ }),
1474
+ zod.z.object({
1475
+ action: zod.z.literal("HAS"),
1476
+ key: zod.z.string(),
1477
+ has: zod.z.boolean()
1478
+ }),
1479
+ zod.z.object({
1480
+ action: zod.z.literal("SET"),
1481
+ key: zod.z.string(),
1482
+ value: zod.z.string().optional()
1483
+ })
1484
+ ]);
1264
1485
  var MISSING_CONNECTION_NOTIFICATION = "dev.trigger.notifications.missingConnection";
1265
1486
  var MISSING_CONNECTION_RESOLVED_NOTIFICATION = "dev.trigger.notifications.missingConnectionResolved";
1266
- var CommonMissingConnectionNotificationPayloadSchema = import_zod12.z.object({
1267
- id: import_zod12.z.string(),
1268
- client: import_zod12.z.object({
1269
- id: import_zod12.z.string(),
1270
- title: import_zod12.z.string(),
1271
- scopes: import_zod12.z.array(import_zod12.z.string()),
1272
- createdAt: import_zod12.z.coerce.date(),
1273
- updatedAt: import_zod12.z.coerce.date()
1487
+ var CommonMissingConnectionNotificationPayloadSchema = zod.z.object({
1488
+ id: zod.z.string(),
1489
+ client: zod.z.object({
1490
+ id: zod.z.string(),
1491
+ title: zod.z.string(),
1492
+ scopes: zod.z.array(zod.z.string()),
1493
+ createdAt: zod.z.coerce.date(),
1494
+ updatedAt: zod.z.coerce.date()
1274
1495
  }),
1275
- authorizationUrl: import_zod12.z.string()
1496
+ authorizationUrl: zod.z.string()
1276
1497
  });
1277
1498
  var MissingDeveloperConnectionNotificationPayloadSchema = CommonMissingConnectionNotificationPayloadSchema.extend({
1278
- type: import_zod12.z.literal("DEVELOPER")
1499
+ type: zod.z.literal("DEVELOPER")
1279
1500
  });
1280
1501
  var MissingExternalConnectionNotificationPayloadSchema = CommonMissingConnectionNotificationPayloadSchema.extend({
1281
- type: import_zod12.z.literal("EXTERNAL"),
1282
- account: import_zod12.z.object({
1283
- id: import_zod12.z.string(),
1284
- metadata: import_zod12.z.any()
1502
+ type: zod.z.literal("EXTERNAL"),
1503
+ account: zod.z.object({
1504
+ id: zod.z.string(),
1505
+ metadata: zod.z.any()
1285
1506
  })
1286
1507
  });
1287
- var MissingConnectionNotificationPayloadSchema = import_zod12.z.discriminatedUnion("type", [
1508
+ var MissingConnectionNotificationPayloadSchema = zod.z.discriminatedUnion("type", [
1288
1509
  MissingDeveloperConnectionNotificationPayloadSchema,
1289
1510
  MissingExternalConnectionNotificationPayloadSchema
1290
1511
  ]);
1291
- var CommonMissingConnectionNotificationResolvedPayloadSchema = import_zod12.z.object({
1292
- id: import_zod12.z.string(),
1293
- client: import_zod12.z.object({
1294
- id: import_zod12.z.string(),
1295
- title: import_zod12.z.string(),
1296
- scopes: import_zod12.z.array(import_zod12.z.string()),
1297
- createdAt: import_zod12.z.coerce.date(),
1298
- updatedAt: import_zod12.z.coerce.date(),
1299
- integrationIdentifier: import_zod12.z.string(),
1300
- integrationAuthMethod: import_zod12.z.string()
1512
+ var CommonMissingConnectionNotificationResolvedPayloadSchema = zod.z.object({
1513
+ id: zod.z.string(),
1514
+ client: zod.z.object({
1515
+ id: zod.z.string(),
1516
+ title: zod.z.string(),
1517
+ scopes: zod.z.array(zod.z.string()),
1518
+ createdAt: zod.z.coerce.date(),
1519
+ updatedAt: zod.z.coerce.date(),
1520
+ integrationIdentifier: zod.z.string(),
1521
+ integrationAuthMethod: zod.z.string()
1301
1522
  }),
1302
- expiresAt: import_zod12.z.coerce.date()
1523
+ expiresAt: zod.z.coerce.date()
1303
1524
  });
1304
1525
  var MissingDeveloperConnectionResolvedNotificationPayloadSchema = CommonMissingConnectionNotificationResolvedPayloadSchema.extend({
1305
- type: import_zod12.z.literal("DEVELOPER")
1526
+ type: zod.z.literal("DEVELOPER")
1306
1527
  });
1307
1528
  var MissingExternalConnectionResolvedNotificationPayloadSchema = CommonMissingConnectionNotificationResolvedPayloadSchema.extend({
1308
- type: import_zod12.z.literal("EXTERNAL"),
1309
- account: import_zod12.z.object({
1310
- id: import_zod12.z.string(),
1311
- metadata: import_zod12.z.any()
1529
+ type: zod.z.literal("EXTERNAL"),
1530
+ account: zod.z.object({
1531
+ id: zod.z.string(),
1532
+ metadata: zod.z.any()
1312
1533
  })
1313
1534
  });
1314
- var MissingConnectionResolvedNotificationPayloadSchema = import_zod12.z.discriminatedUnion("type", [
1535
+ var MissingConnectionResolvedNotificationPayloadSchema = zod.z.discriminatedUnion("type", [
1315
1536
  MissingDeveloperConnectionResolvedNotificationPayloadSchema,
1316
1537
  MissingExternalConnectionResolvedNotificationPayloadSchema
1317
1538
  ]);
1318
-
1319
- // src/schemas/fetch.ts
1320
- var import_zod13 = require("zod");
1321
- var FetchRetryHeadersStrategySchema = import_zod13.z.object({
1539
+ var FetchRetryHeadersStrategySchema = zod.z.object({
1322
1540
  /** The `headers` strategy retries the request using info from the response headers. */
1323
- strategy: import_zod13.z.literal("headers"),
1541
+ strategy: zod.z.literal("headers"),
1324
1542
  /** The header to use to determine the maximum number of times to retry the request. */
1325
- limitHeader: import_zod13.z.string(),
1543
+ limitHeader: zod.z.string(),
1326
1544
  /** The header to use to determine the number of remaining retries. */
1327
- remainingHeader: import_zod13.z.string(),
1545
+ remainingHeader: zod.z.string(),
1328
1546
  /** The header to use to determine the time when the number of remaining retries will be reset. */
1329
- resetHeader: import_zod13.z.string()
1547
+ resetHeader: zod.z.string(),
1548
+ /** The event filter to use to determine if the request should be retried. */
1549
+ bodyFilter: EventFilterSchema.optional(),
1550
+ /** The format of the `resetHeader` value. */
1551
+ resetFormat: zod.z.enum([
1552
+ "unix_timestamp",
1553
+ "unix_timestamp_in_ms",
1554
+ "iso_8601",
1555
+ "iso_8601_duration_openai_variant"
1556
+ ]).default("unix_timestamp")
1330
1557
  });
1331
1558
  var FetchRetryBackoffStrategySchema = RetryOptionsSchema.extend({
1332
1559
  /** The `backoff` strategy retries the request with an exponential backoff. */
1333
- strategy: import_zod13.z.literal("backoff")
1560
+ strategy: zod.z.literal("backoff"),
1561
+ /** The event filter to use to determine if the request should be retried. */
1562
+ bodyFilter: EventFilterSchema.optional()
1334
1563
  });
1335
- var FetchRetryStrategySchema = import_zod13.z.discriminatedUnion("strategy", [
1564
+ var FetchRetryStrategySchema = zod.z.discriminatedUnion("strategy", [
1336
1565
  FetchRetryHeadersStrategySchema,
1337
1566
  FetchRetryBackoffStrategySchema
1338
1567
  ]);
1339
- var FetchRequestInitSchema = import_zod13.z.object({
1568
+ var FetchRequestInitSchema = zod.z.object({
1340
1569
  /** The HTTP method to use for the request. */
1341
- method: import_zod13.z.string().optional(),
1570
+ method: zod.z.string().optional(),
1342
1571
  /** Any headers to send with the request. Note that you can use [redactString](https://trigger.dev/docs/sdk/redactString) to prevent sensitive information from being stored (e.g. in the logs), like API keys and tokens. */
1343
- headers: import_zod13.z.record(import_zod13.z.union([
1344
- import_zod13.z.string(),
1572
+ headers: zod.z.record(zod.z.union([
1573
+ zod.z.string(),
1345
1574
  RedactStringSchema
1346
1575
  ])).optional(),
1347
1576
  /** The body of the request. */
1348
- body: import_zod13.z.union([
1349
- import_zod13.z.string(),
1350
- import_zod13.z.instanceof(ArrayBuffer)
1577
+ body: zod.z.union([
1578
+ zod.z.string(),
1579
+ zod.z.instanceof(ArrayBuffer)
1351
1580
  ]).optional()
1352
1581
  });
1353
- var FetchRetryOptionsSchema = import_zod13.z.record(FetchRetryStrategySchema);
1354
- var FetchOperationSchema = import_zod13.z.object({
1355
- url: import_zod13.z.string(),
1582
+ var FetchRetryOptionsSchema = zod.z.record(FetchRetryStrategySchema);
1583
+ var FetchTimeoutOptionsSchema = zod.z.object({
1584
+ durationInMs: zod.z.number(),
1585
+ retry: RetryOptionsSchema.optional()
1586
+ });
1587
+ var FetchOperationSchema = zod.z.object({
1588
+ url: zod.z.string(),
1589
+ requestInit: FetchRequestInitSchema.optional(),
1590
+ retry: zod.z.record(FetchRetryStrategySchema).optional(),
1591
+ timeout: FetchTimeoutOptionsSchema.optional()
1592
+ });
1593
+ var FetchPollOperationSchema = zod.z.object({
1594
+ url: zod.z.string(),
1595
+ interval: zod.z.number().int().positive().min(10).max(600).default(10),
1596
+ timeout: zod.z.number().int().positive().min(30).max(3600).default(600),
1597
+ responseFilter: ResponseFilterSchema,
1356
1598
  requestInit: FetchRequestInitSchema.optional(),
1357
- retry: import_zod13.z.record(FetchRetryStrategySchema).optional()
1599
+ requestTimeout: FetchTimeoutOptionsSchema.optional()
1358
1600
  });
1359
-
1360
- // src/schemas/events.ts
1361
- var import_zod14 = require("zod");
1362
- var GetEventSchema = import_zod14.z.object({
1601
+ var GetEventSchema = zod.z.object({
1363
1602
  /** The event id */
1364
- id: import_zod14.z.string(),
1603
+ id: zod.z.string(),
1365
1604
  /** The event name */
1366
- name: import_zod14.z.string(),
1605
+ name: zod.z.string(),
1367
1606
  /** When the event was created */
1368
- createdAt: import_zod14.z.coerce.date(),
1607
+ createdAt: zod.z.coerce.date(),
1369
1608
  /** When the event was last updated */
1370
- updatedAt: import_zod14.z.coerce.date(),
1609
+ updatedAt: zod.z.coerce.date(),
1371
1610
  /** The runs that were triggered by the event */
1372
- runs: import_zod14.z.array(import_zod14.z.object({
1611
+ runs: zod.z.array(zod.z.object({
1373
1612
  /** The Run id */
1374
- id: import_zod14.z.string(),
1613
+ id: zod.z.string(),
1375
1614
  /** The Run status */
1376
1615
  status: RunStatusSchema,
1377
1616
  /** When the run started */
1378
- startedAt: import_zod14.z.coerce.date().optional().nullable(),
1617
+ startedAt: zod.z.coerce.date().optional().nullable(),
1379
1618
  /** When the run completed */
1380
- completedAt: import_zod14.z.coerce.date().optional().nullable()
1619
+ completedAt: zod.z.coerce.date().optional().nullable()
1381
1620
  }))
1382
1621
  });
1622
+ var CancelRunsForEventSchema = zod.z.object({
1623
+ cancelledRunIds: zod.z.array(zod.z.string()),
1624
+ failedToCancelRunIds: zod.z.array(zod.z.string())
1625
+ });
1626
+ var RequestWithRawBodySchema = zod.z.object({
1627
+ url: zod.z.string(),
1628
+ method: zod.z.string(),
1629
+ headers: zod.z.record(zod.z.string()),
1630
+ rawBody: zod.z.string()
1631
+ });
1383
1632
 
1384
1633
  // src/utils.ts
1385
1634
  function deepMergeFilters(...filters) {
@@ -1400,6 +1649,10 @@ function deepMergeFilters(...filters) {
1400
1649
  return result;
1401
1650
  }
1402
1651
  __name(deepMergeFilters, "deepMergeFilters");
1652
+ function assertExhaustive(x) {
1653
+ throw new Error("Unexpected object: " + x);
1654
+ }
1655
+ __name(assertExhaustive, "assertExhaustive");
1403
1656
 
1404
1657
  // src/retry.ts
1405
1658
  var DEFAULT_RETRY_OPTIONS = {
@@ -1424,6 +1677,73 @@ function calculateRetryAt(retryOptions, attempts) {
1424
1677
  return new Date(Date.now() + timeoutInMs);
1425
1678
  }
1426
1679
  __name(calculateRetryAt, "calculateRetryAt");
1680
+ function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
1681
+ if (!resets)
1682
+ return;
1683
+ switch (format) {
1684
+ case "iso_8601_duration_openai_variant": {
1685
+ return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
1686
+ }
1687
+ case "iso_8601": {
1688
+ return calculateISO8601ResetAt(resets, now);
1689
+ }
1690
+ case "unix_timestamp": {
1691
+ return calculateUnixTimestampResetAt(resets, now);
1692
+ }
1693
+ case "unix_timestamp_in_ms": {
1694
+ return calculateUnixTimestampInMsResetAt(resets, now);
1695
+ }
1696
+ }
1697
+ }
1698
+ __name(calculateResetAt, "calculateResetAt");
1699
+ function calculateUnixTimestampResetAt(resets, now = /* @__PURE__ */ new Date()) {
1700
+ if (!resets)
1701
+ return void 0;
1702
+ const resetAt = parseInt(resets, 10);
1703
+ if (isNaN(resetAt))
1704
+ return void 0;
1705
+ return new Date(resetAt * 1e3);
1706
+ }
1707
+ __name(calculateUnixTimestampResetAt, "calculateUnixTimestampResetAt");
1708
+ function calculateUnixTimestampInMsResetAt(resets, now = /* @__PURE__ */ new Date()) {
1709
+ if (!resets)
1710
+ return void 0;
1711
+ const resetAt = parseInt(resets, 10);
1712
+ if (isNaN(resetAt))
1713
+ return void 0;
1714
+ return new Date(resetAt);
1715
+ }
1716
+ __name(calculateUnixTimestampInMsResetAt, "calculateUnixTimestampInMsResetAt");
1717
+ function calculateISO8601ResetAt(resets, now = /* @__PURE__ */ new Date()) {
1718
+ if (!resets)
1719
+ return void 0;
1720
+ const resetAt = new Date(resets);
1721
+ if (isNaN(resetAt.getTime()))
1722
+ return void 0;
1723
+ return resetAt;
1724
+ }
1725
+ __name(calculateISO8601ResetAt, "calculateISO8601ResetAt");
1726
+ function calculateISO8601DurationOpenAIVariantResetAt(resets, now = /* @__PURE__ */ new Date()) {
1727
+ if (!resets)
1728
+ return void 0;
1729
+ const pattern = /^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)ms)?$/;
1730
+ const match = resets.match(pattern);
1731
+ if (!match)
1732
+ return void 0;
1733
+ const days = parseInt(match[1], 10) || 0;
1734
+ const hours = parseInt(match[2], 10) || 0;
1735
+ const minutes = parseInt(match[3], 10) || 0;
1736
+ const seconds = parseFloat(match[4]) || 0;
1737
+ const milliseconds = parseInt(match[5], 10) || 0;
1738
+ const resetAt = new Date(now);
1739
+ resetAt.setDate(resetAt.getDate() + days);
1740
+ resetAt.setHours(resetAt.getHours() + hours);
1741
+ resetAt.setMinutes(resetAt.getMinutes() + minutes);
1742
+ resetAt.setSeconds(resetAt.getSeconds() + Math.floor(seconds));
1743
+ resetAt.setMilliseconds(resetAt.getMilliseconds() + (seconds - Math.floor(seconds)) * 1e3 + milliseconds);
1744
+ return resetAt;
1745
+ }
1746
+ __name(calculateISO8601DurationOpenAIVariantResetAt, "calculateISO8601DurationOpenAIVariantResetAt");
1427
1747
 
1428
1748
  // src/replacements.ts
1429
1749
  var currentDate = {
@@ -1465,6 +1785,13 @@ __name(urlWithSearchParams, "urlWithSearchParams");
1465
1785
 
1466
1786
  // src/eventFilterMatches.ts
1467
1787
  function eventFilterMatches(payload, filter) {
1788
+ if (payload === void 0 || payload === null) {
1789
+ if (Object.entries(filter).length === 0) {
1790
+ return true;
1791
+ } else {
1792
+ return false;
1793
+ }
1794
+ }
1468
1795
  for (const [patternKey, patternValue] of Object.entries(filter)) {
1469
1796
  const payloadValue = payload[patternKey];
1470
1797
  if (Array.isArray(patternValue)) {
@@ -1512,7 +1839,7 @@ __name(eventFilterMatches, "eventFilterMatches");
1512
1839
  function contentFiltersMatches(actualValue, contentFilters) {
1513
1840
  for (const contentFilter of contentFilters) {
1514
1841
  if (typeof contentFilter === "object") {
1515
- const [key, value] = Object.entries(contentFilter)[0];
1842
+ Object.entries(contentFilter)[0];
1516
1843
  if (!contentFilterMatches(actualValue, contentFilter)) {
1517
1844
  return false;
1518
1845
  }
@@ -1604,4 +1931,279 @@ function contentFilterMatches(actualValue, contentFilter) {
1604
1931
  return true;
1605
1932
  }
1606
1933
  __name(contentFilterMatches, "contentFilterMatches");
1934
+
1935
+ // src/requestFilterMatches.ts
1936
+ async function requestFilterMatches(request, filter) {
1937
+ const clonedRequest = request.clone();
1938
+ if (!requestMethodMatches(clonedRequest.method, filter.method)) {
1939
+ return false;
1940
+ }
1941
+ const headersObj = Object.fromEntries(clonedRequest.headers.entries());
1942
+ if (filter.headers && !eventFilterMatches(headersObj, filter.headers)) {
1943
+ return false;
1944
+ }
1945
+ const searchParams = new URL(clonedRequest.url).searchParams;
1946
+ const searchParamsObject = {};
1947
+ for (const [key, value] of searchParams.entries()) {
1948
+ searchParamsObject[key] = value;
1949
+ }
1950
+ if (filter.query && !eventFilterMatches(searchParamsObject, filter.query)) {
1951
+ return false;
1952
+ }
1953
+ try {
1954
+ const json = await clonedRequest.json();
1955
+ if (filter.body && !eventFilterMatches(json, filter.body)) {
1956
+ return false;
1957
+ }
1958
+ } catch (e) {
1959
+ if (filter.body) {
1960
+ return false;
1961
+ }
1962
+ }
1963
+ return true;
1964
+ }
1965
+ __name(requestFilterMatches, "requestFilterMatches");
1966
+ async function responseFilterMatches(response, filter) {
1967
+ if (filter.headers && !eventFilterMatches(response.headers, filter.headers)) {
1968
+ return {
1969
+ match: false
1970
+ };
1971
+ }
1972
+ try {
1973
+ const json = await response.json();
1974
+ if (filter.body && !eventFilterMatches(json, filter.body)) {
1975
+ return {
1976
+ match: false,
1977
+ body: json
1978
+ };
1979
+ } else {
1980
+ return {
1981
+ match: true,
1982
+ body: json
1983
+ };
1984
+ }
1985
+ } catch (e) {
1986
+ if (filter.body) {
1987
+ return {
1988
+ match: false,
1989
+ body: void 0
1990
+ };
1991
+ }
1992
+ }
1993
+ return {
1994
+ match: true,
1995
+ body: void 0
1996
+ };
1997
+ }
1998
+ __name(responseFilterMatches, "responseFilterMatches");
1999
+ function requestMethodMatches(method, filter) {
2000
+ if (!filter) {
2001
+ return true;
2002
+ }
2003
+ return filter.includes(method);
2004
+ }
2005
+ __name(requestMethodMatches, "requestMethodMatches");
2006
+
2007
+ // src/index.ts
2008
+ var API_VERSIONS = {
2009
+ LAZY_LOADED_CACHED_TASKS: "2023-09-29",
2010
+ SERIALIZED_TASK_OUTPUT: "2023-11-01"
2011
+ };
2012
+ var PLATFORM_FEATURES = {
2013
+ yieldExecution: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
2014
+ lazyLoadedCachedTasks: API_VERSIONS.LAZY_LOADED_CACHED_TASKS
2015
+ };
2016
+ function supportsFeature(featureName, version) {
2017
+ if (version === "unversioned" || version === "unknown") {
2018
+ return false;
2019
+ }
2020
+ const supportedVersion = PLATFORM_FEATURES[featureName];
2021
+ if (!supportedVersion) {
2022
+ return false;
2023
+ }
2024
+ return version >= supportedVersion;
2025
+ }
2026
+ __name(supportsFeature, "supportsFeature");
2027
+
2028
+ exports.API_VERSIONS = API_VERSIONS;
2029
+ exports.ApiEventLogSchema = ApiEventLogSchema;
2030
+ exports.AutoYieldConfigSchema = AutoYieldConfigSchema;
2031
+ exports.AutoYieldMetadataSchema = AutoYieldMetadataSchema;
2032
+ exports.CachedTaskSchema = CachedTaskSchema;
2033
+ exports.CancelRunsForEventSchema = CancelRunsForEventSchema;
2034
+ exports.CommonMissingConnectionNotificationPayloadSchema = CommonMissingConnectionNotificationPayloadSchema;
2035
+ exports.CommonMissingConnectionNotificationResolvedPayloadSchema = CommonMissingConnectionNotificationResolvedPayloadSchema;
2036
+ exports.CompleteTaskBodyInputSchema = CompleteTaskBodyInputSchema;
2037
+ exports.CompleteTaskBodyV2InputSchema = CompleteTaskBodyV2InputSchema;
2038
+ exports.ConcurrencyLimitOptionsSchema = ConcurrencyLimitOptionsSchema;
2039
+ exports.ConnectionAuthSchema = ConnectionAuthSchema;
2040
+ exports.CreateExternalConnectionBodySchema = CreateExternalConnectionBodySchema;
2041
+ exports.CreateRunResponseBodySchema = CreateRunResponseBodySchema;
2042
+ exports.CronMetadataSchema = CronMetadataSchema;
2043
+ exports.CronOptionsSchema = CronOptionsSchema;
2044
+ exports.DELIVER_WEBHOOK_REQUEST = DELIVER_WEBHOOK_REQUEST;
2045
+ exports.DeliverEventResponseSchema = DeliverEventResponseSchema;
2046
+ exports.DeserializedJsonSchema = DeserializedJsonSchema;
2047
+ exports.DisplayPropertiesSchema = DisplayPropertiesSchema;
2048
+ exports.DisplayPropertySchema = DisplayPropertySchema;
2049
+ exports.DynamicTriggerEndpointMetadataSchema = DynamicTriggerEndpointMetadataSchema;
2050
+ exports.DynamicTriggerMetadataSchema = DynamicTriggerMetadataSchema;
2051
+ exports.EndpointHeadersSchema = EndpointHeadersSchema;
2052
+ exports.EndpointIndexErrorSchema = EndpointIndexErrorSchema;
2053
+ exports.EphemeralEventDispatcherRequestBodySchema = EphemeralEventDispatcherRequestBodySchema;
2054
+ exports.EphemeralEventDispatcherResponseBodySchema = EphemeralEventDispatcherResponseBodySchema;
2055
+ exports.ErrorWithStackSchema = ErrorWithStackSchema;
2056
+ exports.EventExampleSchema = EventExampleSchema;
2057
+ exports.EventFilterSchema = EventFilterSchema;
2058
+ exports.EventRuleSchema = EventRuleSchema;
2059
+ exports.EventSpecificationSchema = EventSpecificationSchema;
2060
+ exports.ExecuteJobHeadersSchema = ExecuteJobHeadersSchema;
2061
+ exports.ExecuteJobRunMetadataSchema = ExecuteJobRunMetadataSchema;
2062
+ exports.FailTaskBodyInputSchema = FailTaskBodyInputSchema;
2063
+ exports.FetchOperationSchema = FetchOperationSchema;
2064
+ exports.FetchPollOperationSchema = FetchPollOperationSchema;
2065
+ exports.FetchRequestInitSchema = FetchRequestInitSchema;
2066
+ exports.FetchRetryBackoffStrategySchema = FetchRetryBackoffStrategySchema;
2067
+ exports.FetchRetryHeadersStrategySchema = FetchRetryHeadersStrategySchema;
2068
+ exports.FetchRetryOptionsSchema = FetchRetryOptionsSchema;
2069
+ exports.FetchRetryStrategySchema = FetchRetryStrategySchema;
2070
+ exports.FetchTimeoutOptionsSchema = FetchTimeoutOptionsSchema;
2071
+ exports.GetEndpointIndexResponseSchema = GetEndpointIndexResponseSchema;
2072
+ exports.GetEventSchema = GetEventSchema;
2073
+ exports.GetRunSchema = GetRunSchema;
2074
+ exports.GetRunStatusesSchema = GetRunStatusesSchema;
2075
+ exports.GetRunsSchema = GetRunsSchema;
2076
+ exports.HTTPMethodUnionSchema = HTTPMethodUnionSchema;
2077
+ exports.HandleTriggerSourceSchema = HandleTriggerSourceSchema;
2078
+ exports.HttpEndpointRequestHeadersSchema = HttpEndpointRequestHeadersSchema;
2079
+ exports.HttpSourceRequestHeadersSchema = HttpSourceRequestHeadersSchema;
2080
+ exports.HttpSourceResponseSchema = HttpSourceResponseSchema;
2081
+ exports.IndexEndpointResponseSchema = IndexEndpointResponseSchema;
2082
+ exports.InitializeCronScheduleBodySchema = InitializeCronScheduleBodySchema;
2083
+ exports.InitializeTriggerBodySchema = InitializeTriggerBodySchema;
2084
+ exports.IntegrationConfigSchema = IntegrationConfigSchema;
2085
+ exports.IntegrationMetadataSchema = IntegrationMetadataSchema;
2086
+ exports.IntervalMetadataSchema = IntervalMetadataSchema;
2087
+ exports.IntervalOptionsSchema = IntervalOptionsSchema;
2088
+ exports.InvokeJobRequestBodySchema = InvokeJobRequestBodySchema;
2089
+ exports.InvokeJobResponseSchema = InvokeJobResponseSchema;
2090
+ exports.InvokeOptionsSchema = InvokeOptionsSchema;
2091
+ exports.InvokeTriggerMetadataSchema = InvokeTriggerMetadataSchema;
2092
+ exports.JobMetadataSchema = JobMetadataSchema;
2093
+ exports.JobRunStatusRecordSchema = JobRunStatusRecordSchema;
2094
+ exports.KeyValueStoreResponseBodySchema = KeyValueStoreResponseBodySchema;
2095
+ exports.LogMessageSchema = LogMessageSchema;
2096
+ exports.Logger = Logger;
2097
+ exports.MISSING_CONNECTION_NOTIFICATION = MISSING_CONNECTION_NOTIFICATION;
2098
+ exports.MISSING_CONNECTION_RESOLVED_NOTIFICATION = MISSING_CONNECTION_RESOLVED_NOTIFICATION;
2099
+ exports.MissingConnectionNotificationPayloadSchema = MissingConnectionNotificationPayloadSchema;
2100
+ exports.MissingConnectionResolvedNotificationPayloadSchema = MissingConnectionResolvedNotificationPayloadSchema;
2101
+ exports.MissingDeveloperConnectionNotificationPayloadSchema = MissingDeveloperConnectionNotificationPayloadSchema;
2102
+ exports.MissingDeveloperConnectionResolvedNotificationPayloadSchema = MissingDeveloperConnectionResolvedNotificationPayloadSchema;
2103
+ exports.MissingExternalConnectionNotificationPayloadSchema = MissingExternalConnectionNotificationPayloadSchema;
2104
+ exports.MissingExternalConnectionResolvedNotificationPayloadSchema = MissingExternalConnectionResolvedNotificationPayloadSchema;
2105
+ exports.NormalizedRequestSchema = NormalizedRequestSchema;
2106
+ exports.NormalizedResponseSchema = NormalizedResponseSchema;
2107
+ exports.PLATFORM_FEATURES = PLATFORM_FEATURES;
2108
+ exports.PongErrorResponseSchema = PongErrorResponseSchema;
2109
+ exports.PongResponseSchema = PongResponseSchema;
2110
+ exports.PongSuccessResponseSchema = PongSuccessResponseSchema;
2111
+ exports.PreprocessRunBodySchema = PreprocessRunBodySchema;
2112
+ exports.PreprocessRunResponseSchema = PreprocessRunResponseSchema;
2113
+ exports.QueueOptionsSchema = QueueOptionsSchema;
2114
+ exports.REGISTER_SOURCE_EVENT_V1 = REGISTER_SOURCE_EVENT_V1;
2115
+ exports.REGISTER_SOURCE_EVENT_V2 = REGISTER_SOURCE_EVENT_V2;
2116
+ exports.REGISTER_WEBHOOK = REGISTER_WEBHOOK;
2117
+ exports.RawEventSchema = RawEventSchema;
2118
+ exports.RedactSchema = RedactSchema;
2119
+ exports.RedactStringSchema = RedactStringSchema;
2120
+ exports.RegisterDynamicSchedulePayloadSchema = RegisterDynamicSchedulePayloadSchema;
2121
+ exports.RegisterHTTPTriggerSourceBodySchema = RegisterHTTPTriggerSourceBodySchema;
2122
+ exports.RegisterIntervalScheduleBodySchema = RegisterIntervalScheduleBodySchema;
2123
+ exports.RegisterSMTPTriggerSourceBodySchema = RegisterSMTPTriggerSourceBodySchema;
2124
+ exports.RegisterSQSTriggerSourceBodySchema = RegisterSQSTriggerSourceBodySchema;
2125
+ exports.RegisterScheduleBodySchema = RegisterScheduleBodySchema;
2126
+ exports.RegisterScheduleResponseBodySchema = RegisterScheduleResponseBodySchema;
2127
+ exports.RegisterSourceChannelBodySchema = RegisterSourceChannelBodySchema;
2128
+ exports.RegisterSourceEventSchemaV1 = RegisterSourceEventSchemaV1;
2129
+ exports.RegisterSourceEventSchemaV2 = RegisterSourceEventSchemaV2;
2130
+ exports.RegisterTriggerBodySchemaV1 = RegisterTriggerBodySchemaV1;
2131
+ exports.RegisterTriggerBodySchemaV2 = RegisterTriggerBodySchemaV2;
2132
+ exports.RegisterTriggerSourceSchema = RegisterTriggerSourceSchema;
2133
+ exports.RegisterWebhookPayloadSchema = RegisterWebhookPayloadSchema;
2134
+ exports.RegisterWebhookSourceSchema = RegisterWebhookSourceSchema;
2135
+ exports.RequestFilterSchema = RequestFilterSchema;
2136
+ exports.RequestWithRawBodySchema = RequestWithRawBodySchema;
2137
+ exports.ResponseFilterSchema = ResponseFilterSchema;
2138
+ exports.RetryOptionsSchema = RetryOptionsSchema;
2139
+ exports.RunJobAutoYieldExecutionErrorSchema = RunJobAutoYieldExecutionErrorSchema;
2140
+ exports.RunJobAutoYieldWithCompletedTaskExecutionErrorSchema = RunJobAutoYieldWithCompletedTaskExecutionErrorSchema;
2141
+ exports.RunJobBodySchema = RunJobBodySchema;
2142
+ exports.RunJobCanceledWithTaskSchema = RunJobCanceledWithTaskSchema;
2143
+ exports.RunJobErrorResponseSchema = RunJobErrorResponseSchema;
2144
+ exports.RunJobErrorSchema = RunJobErrorSchema;
2145
+ exports.RunJobInvalidPayloadErrorSchema = RunJobInvalidPayloadErrorSchema;
2146
+ exports.RunJobResponseSchema = RunJobResponseSchema;
2147
+ exports.RunJobResumeWithParallelTaskSchema = RunJobResumeWithParallelTaskSchema;
2148
+ exports.RunJobResumeWithTaskSchema = RunJobResumeWithTaskSchema;
2149
+ exports.RunJobRetryWithTaskSchema = RunJobRetryWithTaskSchema;
2150
+ exports.RunJobSuccessSchema = RunJobSuccessSchema;
2151
+ exports.RunJobUnresolvedAuthErrorSchema = RunJobUnresolvedAuthErrorSchema;
2152
+ exports.RunJobYieldExecutionErrorSchema = RunJobYieldExecutionErrorSchema;
2153
+ exports.RunSourceContextSchema = RunSourceContextSchema;
2154
+ exports.RunStatusSchema = RunStatusSchema;
2155
+ exports.RunTaskBodyInputSchema = RunTaskBodyInputSchema;
2156
+ exports.RunTaskBodyOutputSchema = RunTaskBodyOutputSchema;
2157
+ exports.RunTaskOptionsSchema = RunTaskOptionsSchema;
2158
+ exports.RunTaskResponseWithCachedTasksBodySchema = RunTaskResponseWithCachedTasksBodySchema;
2159
+ exports.RunTaskSchema = RunTaskSchema;
2160
+ exports.RuntimeEnvironmentTypeSchema = RuntimeEnvironmentTypeSchema;
2161
+ exports.SCHEDULED_EVENT = SCHEDULED_EVENT;
2162
+ exports.ScheduleMetadataSchema = ScheduleMetadataSchema;
2163
+ exports.ScheduledPayloadSchema = ScheduledPayloadSchema;
2164
+ exports.ScheduledTriggerMetadataSchema = ScheduledTriggerMetadataSchema;
2165
+ exports.SchemaErrorSchema = SchemaErrorSchema;
2166
+ exports.SendBulkEventsBodySchema = SendBulkEventsBodySchema;
2167
+ exports.SendEventBodySchema = SendEventBodySchema;
2168
+ exports.SendEventOptionsSchema = SendEventOptionsSchema;
2169
+ exports.SerializableJsonSchema = SerializableJsonSchema;
2170
+ exports.ServerTaskSchema = ServerTaskSchema;
2171
+ exports.SourceMetadataV2Schema = SourceMetadataV2Schema;
2172
+ exports.StaticTriggerMetadataSchema = StaticTriggerMetadataSchema;
2173
+ exports.StatusHistorySchema = StatusHistorySchema;
2174
+ exports.StatusUpdateSchema = StatusUpdateSchema;
2175
+ exports.StatusUpdateStateSchema = StatusUpdateStateSchema;
2176
+ exports.StyleSchema = StyleSchema;
2177
+ exports.TaskSchema = TaskSchema;
2178
+ exports.TaskStatusSchema = TaskStatusSchema;
2179
+ exports.TriggerHelpSchema = TriggerHelpSchema;
2180
+ exports.TriggerMetadataSchema = TriggerMetadataSchema;
2181
+ exports.TriggerSourceSchema = TriggerSourceSchema;
2182
+ exports.UpdateTriggerSourceBodyV1Schema = UpdateTriggerSourceBodyV1Schema;
2183
+ exports.UpdateTriggerSourceBodyV2Schema = UpdateTriggerSourceBodyV2Schema;
2184
+ exports.UpdateWebhookBodySchema = UpdateWebhookBodySchema;
2185
+ exports.ValidateErrorResponseSchema = ValidateErrorResponseSchema;
2186
+ exports.ValidateResponseSchema = ValidateResponseSchema;
2187
+ exports.ValidateSuccessResponseSchema = ValidateSuccessResponseSchema;
2188
+ exports.WebhookContextMetadataSchema = WebhookContextMetadataSchema;
2189
+ exports.WebhookDeliveryResponseSchema = WebhookDeliveryResponseSchema;
2190
+ exports.WebhookMetadataSchema = WebhookMetadataSchema;
2191
+ exports.WebhookSourceRequestHeadersSchema = WebhookSourceRequestHeadersSchema;
2192
+ exports.addMissingVersionField = addMissingVersionField;
2193
+ exports.assertExhaustive = assertExhaustive;
2194
+ exports.calculateResetAt = calculateResetAt;
2195
+ exports.calculateRetryAt = calculateRetryAt;
2196
+ exports.currentDate = currentDate;
2197
+ exports.currentTimestampMilliseconds = currentTimestampMilliseconds;
2198
+ exports.currentTimestampSeconds = currentTimestampSeconds;
2199
+ exports.deepMergeFilters = deepMergeFilters;
2200
+ exports.eventFilterMatches = eventFilterMatches;
2201
+ exports.parseEndpointIndexStats = parseEndpointIndexStats;
2202
+ exports.replacements = replacements;
2203
+ exports.requestFilterMatches = requestFilterMatches;
2204
+ exports.responseFilterMatches = responseFilterMatches;
2205
+ exports.stringPatternMatchers = stringPatternMatchers;
2206
+ exports.supportsFeature = supportsFeature;
2207
+ exports.urlWithSearchParams = urlWithSearchParams;
2208
+ //# sourceMappingURL=out.js.map
1607
2209
  //# sourceMappingURL=index.js.map