@trigger.dev/core 0.0.0-prerelease-20230922203841 → 0.0.0-prerelease-20231005164702

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
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
@@ -17,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
17
18
  return to;
18
19
  };
19
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var __publicField = (obj, key, value) => {
22
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
+ return value;
24
+ };
20
25
  var __accessCheck = (obj, member, msg) => {
21
26
  if (!member.has(obj))
22
27
  throw TypeError("Cannot " + msg);
@@ -43,7 +48,9 @@ var __privateMethod = (obj, member, method) => {
43
48
  // src/index.ts
44
49
  var src_exports = {};
45
50
  __export(src_exports, {
51
+ API_VERSIONS: () => API_VERSIONS,
46
52
  ApiEventLogSchema: () => ApiEventLogSchema,
53
+ BloomFilter: () => BloomFilter,
47
54
  CachedTaskSchema: () => CachedTaskSchema,
48
55
  CommonMissingConnectionNotificationPayloadSchema: () => CommonMissingConnectionNotificationPayloadSchema,
49
56
  CommonMissingConnectionNotificationResolvedPayloadSchema: () => CommonMissingConnectionNotificationResolvedPayloadSchema,
@@ -59,6 +66,7 @@ __export(src_exports, {
59
66
  DisplayPropertySchema: () => DisplayPropertySchema,
60
67
  DynamicTriggerEndpointMetadataSchema: () => DynamicTriggerEndpointMetadataSchema,
61
68
  DynamicTriggerMetadataSchema: () => DynamicTriggerMetadataSchema,
69
+ EndpointHeadersSchema: () => EndpointHeadersSchema,
62
70
  ErrorWithStackSchema: () => ErrorWithStackSchema,
63
71
  EventExampleSchema: () => EventExampleSchema,
64
72
  EventFilterSchema: () => EventFilterSchema,
@@ -100,6 +108,7 @@ __export(src_exports, {
100
108
  MissingExternalConnectionResolvedNotificationPayloadSchema: () => MissingExternalConnectionResolvedNotificationPayloadSchema,
101
109
  NormalizedRequestSchema: () => NormalizedRequestSchema,
102
110
  NormalizedResponseSchema: () => NormalizedResponseSchema,
111
+ PLATFORM_FEATURES: () => PLATFORM_FEATURES,
103
112
  PongErrorResponseSchema: () => PongErrorResponseSchema,
104
113
  PongResponseSchema: () => PongResponseSchema,
105
114
  PongSuccessResponseSchema: () => PongSuccessResponseSchema,
@@ -128,22 +137,26 @@ __export(src_exports, {
128
137
  RunJobBodySchema: () => RunJobBodySchema,
129
138
  RunJobCanceledWithTaskSchema: () => RunJobCanceledWithTaskSchema,
130
139
  RunJobErrorSchema: () => RunJobErrorSchema,
140
+ RunJobInvalidPayloadErrorSchema: () => RunJobInvalidPayloadErrorSchema,
131
141
  RunJobResponseSchema: () => RunJobResponseSchema,
132
142
  RunJobResumeWithTaskSchema: () => RunJobResumeWithTaskSchema,
133
143
  RunJobRetryWithTaskSchema: () => RunJobRetryWithTaskSchema,
134
144
  RunJobSuccessSchema: () => RunJobSuccessSchema,
135
145
  RunJobUnresolvedAuthErrorSchema: () => RunJobUnresolvedAuthErrorSchema,
146
+ RunJobYieldExecutionErrorSchema: () => RunJobYieldExecutionErrorSchema,
136
147
  RunSourceContextSchema: () => RunSourceContextSchema,
137
148
  RunStatusSchema: () => RunStatusSchema,
138
149
  RunTaskBodyInputSchema: () => RunTaskBodyInputSchema,
139
150
  RunTaskBodyOutputSchema: () => RunTaskBodyOutputSchema,
140
151
  RunTaskOptionsSchema: () => RunTaskOptionsSchema,
152
+ RunTaskResponseWithCachedTasksBodySchema: () => RunTaskResponseWithCachedTasksBodySchema,
141
153
  RunTaskSchema: () => RunTaskSchema,
142
154
  RuntimeEnvironmentTypeSchema: () => RuntimeEnvironmentTypeSchema,
143
155
  SCHEDULED_EVENT: () => SCHEDULED_EVENT,
144
156
  ScheduleMetadataSchema: () => ScheduleMetadataSchema,
145
157
  ScheduledPayloadSchema: () => ScheduledPayloadSchema,
146
158
  ScheduledTriggerMetadataSchema: () => ScheduledTriggerMetadataSchema,
159
+ SchemaErrorSchema: () => SchemaErrorSchema,
147
160
  SendEventBodySchema: () => SendEventBodySchema,
148
161
  SendEventOptionsSchema: () => SendEventOptionsSchema,
149
162
  SerializableJsonSchema: () => SerializableJsonSchema,
@@ -171,6 +184,7 @@ __export(src_exports, {
171
184
  deepMergeFilters: () => deepMergeFilters,
172
185
  eventFilterMatches: () => eventFilterMatches,
173
186
  replacements: () => replacements,
187
+ supportsFeature: () => supportsFeature,
174
188
  urlWithSearchParams: () => urlWithSearchParams
175
189
  });
176
190
  module.exports = __toCommonJS(src_exports);
@@ -346,6 +360,10 @@ var ErrorWithStackSchema = import_zod.z.object({
346
360
  name: import_zod.z.string().optional(),
347
361
  stack: import_zod.z.string().optional()
348
362
  });
363
+ var SchemaErrorSchema = import_zod.z.object({
364
+ path: import_zod.z.array(import_zod.z.string()),
365
+ message: import_zod.z.string()
366
+ });
349
367
 
350
368
  // src/schemas/eventFilter.ts
351
369
  var import_zod2 = require("zod");
@@ -507,8 +525,8 @@ var ScheduledPayloadSchema = import_zod6.z.object({
507
525
  lastTimestamp: import_zod6.z.coerce.date().optional()
508
526
  });
509
527
  var IntervalOptionsSchema = import_zod6.z.object({
510
- /** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
511
- seconds: import_zod6.z.number().int().positive().min(60).max(86400)
528
+ /** The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days) */
529
+ seconds: import_zod6.z.number().int().positive().min(60).max(2592e3)
512
530
  });
513
531
  var CronOptionsSchema = import_zod6.z.object({
514
532
  /** A CRON expression that defines the schedule. A useful tool when writing CRON
@@ -572,7 +590,8 @@ var TaskSchema = import_zod7.z.object({
572
590
  error: import_zod7.z.string().optional().nullable(),
573
591
  parentId: import_zod7.z.string().optional().nullable(),
574
592
  style: StyleSchema.optional().nullable(),
575
- operation: import_zod7.z.string().optional().nullable()
593
+ operation: import_zod7.z.string().optional().nullable(),
594
+ callbackUrl: import_zod7.z.string().optional().nullable()
576
595
  });
577
596
  var ServerTaskSchema = TaskSchema.extend({
578
597
  idempotencyKey: import_zod7.z.string(),
@@ -665,7 +684,8 @@ var RunStatusSchema = import_zod10.z.union([
665
684
  import_zod10.z.literal("TIMED_OUT"),
666
685
  import_zod10.z.literal("ABORTED"),
667
686
  import_zod10.z.literal("CANCELED"),
668
- import_zod10.z.literal("UNRESOLVED_AUTH")
687
+ import_zod10.z.literal("UNRESOLVED_AUTH"),
688
+ import_zod10.z.literal("INVALID_PAYLOAD")
669
689
  ]);
670
690
  var RunTaskSchema = import_zod10.z.object({
671
691
  /** The Task id */
@@ -844,11 +864,13 @@ var HttpSourceRequestHeadersSchema = import_zod11.z.object({
844
864
  })
845
865
  });
846
866
  var PongSuccessResponseSchema = import_zod11.z.object({
847
- ok: import_zod11.z.literal(true)
867
+ ok: import_zod11.z.literal(true),
868
+ triggerVersion: import_zod11.z.string().optional()
848
869
  });
849
870
  var PongErrorResponseSchema = import_zod11.z.object({
850
871
  ok: import_zod11.z.literal(false),
851
- error: import_zod11.z.string()
872
+ error: import_zod11.z.string(),
873
+ triggerVersion: import_zod11.z.string().optional()
852
874
  });
853
875
  var PongResponseSchema = import_zod11.z.discriminatedUnion("ok", [
854
876
  PongSuccessResponseSchema,
@@ -856,11 +878,13 @@ var PongResponseSchema = import_zod11.z.discriminatedUnion("ok", [
856
878
  ]);
857
879
  var ValidateSuccessResponseSchema = import_zod11.z.object({
858
880
  ok: import_zod11.z.literal(true),
859
- endpointId: import_zod11.z.string()
881
+ endpointId: import_zod11.z.string(),
882
+ triggerVersion: import_zod11.z.string().optional()
860
883
  });
861
884
  var ValidateErrorResponseSchema = import_zod11.z.object({
862
885
  ok: import_zod11.z.literal(false),
863
- error: import_zod11.z.string()
886
+ error: import_zod11.z.string(),
887
+ triggerVersion: import_zod11.z.string().optional()
864
888
  });
865
889
  var ValidateResponseSchema = import_zod11.z.discriminatedUnion("ok", [
866
890
  ValidateSuccessResponseSchema,
@@ -938,6 +962,9 @@ var IndexEndpointResponseSchema = import_zod11.z.object({
938
962
  dynamicTriggers: import_zod11.z.array(DynamicTriggerEndpointMetadataSchema),
939
963
  dynamicSchedules: import_zod11.z.array(RegisterDynamicSchedulePayloadSchema)
940
964
  });
965
+ var EndpointHeadersSchema = import_zod11.z.object({
966
+ "trigger-version": import_zod11.z.string().optional()
967
+ });
941
968
  var RawEventSchema = import_zod11.z.object({
942
969
  /** The `name` property must exactly match any subscriptions you want to
943
970
  trigger. */
@@ -1045,13 +1072,24 @@ var RunJobBodySchema = import_zod11.z.object({
1045
1072
  }).optional(),
1046
1073
  source: RunSourceContextSchema.optional(),
1047
1074
  tasks: import_zod11.z.array(CachedTaskSchema).optional(),
1048
- connections: import_zod11.z.record(ConnectionAuthSchema).optional()
1075
+ cachedTaskCursor: import_zod11.z.string().optional(),
1076
+ noopTasksSet: import_zod11.z.string().optional(),
1077
+ connections: import_zod11.z.record(ConnectionAuthSchema).optional(),
1078
+ yieldedExecutions: import_zod11.z.string().array().optional()
1049
1079
  });
1050
1080
  var RunJobErrorSchema = import_zod11.z.object({
1051
1081
  status: import_zod11.z.literal("ERROR"),
1052
1082
  error: ErrorWithStackSchema,
1053
1083
  task: TaskSchema.optional()
1054
1084
  });
1085
+ var RunJobYieldExecutionErrorSchema = import_zod11.z.object({
1086
+ status: import_zod11.z.literal("YIELD_EXECUTION"),
1087
+ key: import_zod11.z.string()
1088
+ });
1089
+ var RunJobInvalidPayloadErrorSchema = import_zod11.z.object({
1090
+ status: import_zod11.z.literal("INVALID_PAYLOAD"),
1091
+ errors: import_zod11.z.array(SchemaErrorSchema)
1092
+ });
1055
1093
  var RunJobUnresolvedAuthErrorSchema = import_zod11.z.object({
1056
1094
  status: import_zod11.z.literal("UNRESOLVED_AUTH_ERROR"),
1057
1095
  issues: import_zod11.z.record(import_zod11.z.object({
@@ -1078,8 +1116,10 @@ var RunJobSuccessSchema = import_zod11.z.object({
1078
1116
  output: DeserializedJsonSchema.optional()
1079
1117
  });
1080
1118
  var RunJobResponseSchema = import_zod11.z.discriminatedUnion("status", [
1119
+ RunJobYieldExecutionErrorSchema,
1081
1120
  RunJobErrorSchema,
1082
1121
  RunJobUnresolvedAuthErrorSchema,
1122
+ RunJobInvalidPayloadErrorSchema,
1083
1123
  RunJobResumeWithTaskSchema,
1084
1124
  RunJobRetryWithTaskSchema,
1085
1125
  RunJobCanceledWithTaskSchema,
@@ -1179,6 +1219,13 @@ var RunTaskOptionsSchema = import_zod11.z.object({
1179
1219
  params: import_zod11.z.any(),
1180
1220
  /** The style of the log entry. */
1181
1221
  style: StyleSchema.optional(),
1222
+ /** 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. */
1223
+ callback: import_zod11.z.object({
1224
+ /** Causes the task to wait for and return the data of the first request sent to `task.callbackUrl`. */
1225
+ enabled: import_zod11.z.boolean(),
1226
+ /** Time to wait for the first request to `task.callbackUrl`. Default: One hour. */
1227
+ timeoutInSeconds: import_zod11.z.number()
1228
+ }).partial().optional(),
1182
1229
  /** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
1183
1230
  connectionKey: import_zod11.z.string().optional(),
1184
1231
  /** 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. */
@@ -1195,7 +1242,18 @@ var RunTaskBodyInputSchema = RunTaskOptionsSchema.extend({
1195
1242
  parentId: import_zod11.z.string().optional()
1196
1243
  });
1197
1244
  var RunTaskBodyOutputSchema = RunTaskBodyInputSchema.extend({
1198
- params: DeserializedJsonSchema.optional().nullable()
1245
+ params: DeserializedJsonSchema.optional().nullable(),
1246
+ callback: import_zod11.z.object({
1247
+ enabled: import_zod11.z.boolean(),
1248
+ timeoutInSeconds: import_zod11.z.number().default(3600)
1249
+ }).optional()
1250
+ });
1251
+ var RunTaskResponseWithCachedTasksBodySchema = import_zod11.z.object({
1252
+ task: ServerTaskSchema,
1253
+ cachedTasks: import_zod11.z.object({
1254
+ tasks: import_zod11.z.array(CachedTaskSchema),
1255
+ cursor: import_zod11.z.string().optional()
1256
+ }).optional()
1199
1257
  });
1200
1258
  var CompleteTaskBodyInputSchema = RunTaskBodyInputSchema.pick({
1201
1259
  properties: true,
@@ -1621,4 +1679,76 @@ function contentFilterMatches(actualValue, contentFilter) {
1621
1679
  return true;
1622
1680
  }
1623
1681
  __name(contentFilterMatches, "contentFilterMatches");
1682
+
1683
+ // src/bloom.ts
1684
+ var import_node_buffer = require("buffer");
1685
+ var _BloomFilter = class _BloomFilter {
1686
+ constructor(size) {
1687
+ this.size = size;
1688
+ this.bitArray = new Uint8Array(Math.ceil(size / 8));
1689
+ }
1690
+ add(item) {
1691
+ const index = murmurHash3(item) % this.size;
1692
+ this.bitArray[Math.floor(index / 8)] |= 1 << index % 8;
1693
+ }
1694
+ test(item) {
1695
+ const index = murmurHash3(item) % this.size;
1696
+ return (this.bitArray[Math.floor(index / 8)] & 1 << index % 8) !== 0;
1697
+ }
1698
+ // Serialize to a Base64 string
1699
+ serialize() {
1700
+ return import_node_buffer.Buffer.from(this.bitArray).toString("base64");
1701
+ }
1702
+ // Deserialize from a Base64 string
1703
+ static deserialize(str, size) {
1704
+ const filter = new _BloomFilter(size);
1705
+ filter.bitArray = Uint8Array.from(import_node_buffer.Buffer.from(str, "base64"));
1706
+ return filter;
1707
+ }
1708
+ };
1709
+ __name(_BloomFilter, "BloomFilter");
1710
+ __publicField(_BloomFilter, "NOOP_TASK_SET_SIZE", 32768);
1711
+ var BloomFilter = _BloomFilter;
1712
+ function murmurHash3(str, seed = 0) {
1713
+ let h1 = 3735928559 ^ seed, h2 = 1103547991 ^ seed;
1714
+ for (let i = 0, ch; i < str.length; i++) {
1715
+ ch = str.charCodeAt(i);
1716
+ h1 = Math.imul(h1 ^ ch, 3432918353);
1717
+ h1 = h1 << 15 | h1 >>> 17;
1718
+ h1 = Math.imul(h1, 461845907);
1719
+ h2 = Math.imul(h2 ^ ch, 2246822507);
1720
+ h2 = h2 << 13 | h2 >>> 19;
1721
+ h2 = Math.imul(h2, 3266489909);
1722
+ }
1723
+ h1 ^= str.length;
1724
+ h2 ^= str.length;
1725
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
1726
+ h1 = Math.imul(h1 ^ h1 >>> 13, 3266489909);
1727
+ h1 ^= h1 >>> 16;
1728
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
1729
+ h2 = Math.imul(h2 ^ h2 >>> 13, 3266489909);
1730
+ h2 ^= h2 >>> 16;
1731
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
1732
+ }
1733
+ __name(murmurHash3, "murmurHash3");
1734
+
1735
+ // src/index.ts
1736
+ var API_VERSIONS = {
1737
+ LAZY_LOADED_CACHED_TASKS: "2023-09-29"
1738
+ };
1739
+ var PLATFORM_FEATURES = {
1740
+ yieldExecution: API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
1741
+ lazyLoadedCachedTasks: API_VERSIONS.LAZY_LOADED_CACHED_TASKS
1742
+ };
1743
+ function supportsFeature(featureName, version) {
1744
+ if (version === "unversioned" || version === "unknown") {
1745
+ return false;
1746
+ }
1747
+ const supportedVersion = PLATFORM_FEATURES[featureName];
1748
+ if (!supportedVersion) {
1749
+ return false;
1750
+ }
1751
+ return version >= supportedVersion;
1752
+ }
1753
+ __name(supportsFeature, "supportsFeature");
1624
1754
  //# sourceMappingURL=index.js.map