@trigger.dev/core 0.0.0-svelte-test-20231206141434 → 0.0.0-v3-canary-20240321105132

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.mjs CHANGED
@@ -1,195 +1,8 @@
1
- import { env } from 'node:process';
2
- import { Buffer } from 'node:buffer';
3
1
  import { ulid } from 'ulidx';
4
2
  import { z } from 'zod';
5
3
 
6
4
  var __defProp = Object.defineProperty;
7
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __accessCheck = (obj, member, msg) => {
9
- if (!member.has(obj))
10
- throw TypeError("Cannot " + msg);
11
- };
12
- var __privateGet = (obj, member, getter) => {
13
- __accessCheck(obj, member, "read from private field");
14
- return getter ? getter.call(obj) : member.get(obj);
15
- };
16
- var __privateAdd = (obj, member, value) => {
17
- if (member.has(obj))
18
- throw TypeError("Cannot add the same private member more than once");
19
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
20
- };
21
- var __privateSet = (obj, member, value, setter) => {
22
- __accessCheck(obj, member, "write to private field");
23
- setter ? setter.call(obj, value) : member.set(obj, value);
24
- return value;
25
- };
26
- var __privateMethod = (obj, member, method) => {
27
- __accessCheck(obj, member, "access private method");
28
- return method;
29
- };
30
- var logLevels = [
31
- "log",
32
- "error",
33
- "warn",
34
- "info",
35
- "debug"
36
- ];
37
- var _name, _level, _filteredKeys, _jsonReplacer, _additionalFields, _structuredLog, structuredLog_fn;
38
- var _Logger = class _Logger {
39
- constructor(name, level = "info", filteredKeys = [], jsonReplacer, additionalFields) {
40
- __privateAdd(this, _structuredLog);
41
- __privateAdd(this, _name, void 0);
42
- __privateAdd(this, _level, void 0);
43
- __privateAdd(this, _filteredKeys, []);
44
- __privateAdd(this, _jsonReplacer, void 0);
45
- __privateAdd(this, _additionalFields, void 0);
46
- __privateSet(this, _name, name);
47
- __privateSet(this, _level, logLevels.indexOf(env.TRIGGER_LOG_LEVEL ?? level));
48
- __privateSet(this, _filteredKeys, filteredKeys);
49
- __privateSet(this, _jsonReplacer, createReplacer(jsonReplacer));
50
- __privateSet(this, _additionalFields, additionalFields ?? (() => ({})));
51
- }
52
- // Return a new Logger instance with the same name and a new log level
53
- // but filter out the keys from the log messages (at any level)
54
- filter(...keys) {
55
- return new _Logger(__privateGet(this, _name), logLevels[__privateGet(this, _level)], keys, __privateGet(this, _jsonReplacer));
56
- }
57
- static satisfiesLogLevel(logLevel, setLevel) {
58
- return logLevels.indexOf(logLevel) <= logLevels.indexOf(setLevel);
59
- }
60
- log(message, ...args) {
61
- if (__privateGet(this, _level) < 0)
62
- return;
63
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.log, message, "log", ...args);
64
- }
65
- error(message, ...args) {
66
- if (__privateGet(this, _level) < 1)
67
- return;
68
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.error, message, "error", ...args);
69
- }
70
- warn(message, ...args) {
71
- if (__privateGet(this, _level) < 2)
72
- return;
73
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.warn, message, "warn", ...args);
74
- }
75
- info(message, ...args) {
76
- if (__privateGet(this, _level) < 3)
77
- return;
78
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.info, message, "info", ...args);
79
- }
80
- debug(message, ...args) {
81
- if (__privateGet(this, _level) < 4)
82
- return;
83
- __privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.debug, message, "debug", ...args);
84
- }
85
- };
86
- _name = new WeakMap();
87
- _level = new WeakMap();
88
- _filteredKeys = new WeakMap();
89
- _jsonReplacer = new WeakMap();
90
- _additionalFields = new WeakMap();
91
- _structuredLog = new WeakSet();
92
- structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, level, ...args) {
93
- const structuredLog = {
94
- ...structureArgs(safeJsonClone(args), __privateGet(this, _filteredKeys)),
95
- ...__privateGet(this, _additionalFields).call(this),
96
- timestamp: /* @__PURE__ */ new Date(),
97
- name: __privateGet(this, _name),
98
- message,
99
- level
100
- };
101
- loggerFunction(JSON.stringify(structuredLog, __privateGet(this, _jsonReplacer)));
102
- }, "#structuredLog");
103
- __name(_Logger, "Logger");
104
- var Logger = _Logger;
105
- function createReplacer(replacer) {
106
- return (key, value) => {
107
- if (typeof value === "bigint") {
108
- return value.toString();
109
- }
110
- if (replacer) {
111
- return replacer(key, value);
112
- }
113
- return value;
114
- };
115
- }
116
- __name(createReplacer, "createReplacer");
117
- function bigIntReplacer(_key, value) {
118
- if (typeof value === "bigint") {
119
- return value.toString();
120
- }
121
- return value;
122
- }
123
- __name(bigIntReplacer, "bigIntReplacer");
124
- function safeJsonClone(obj) {
125
- try {
126
- return JSON.parse(JSON.stringify(obj, bigIntReplacer));
127
- } catch (e) {
128
- return;
129
- }
130
- }
131
- __name(safeJsonClone, "safeJsonClone");
132
- function structureArgs(args, filteredKeys = []) {
133
- if (!args) {
134
- return;
135
- }
136
- if (args.length === 0) {
137
- return;
138
- }
139
- if (args.length === 1 && typeof args[0] === "object") {
140
- return filterKeys(JSON.parse(JSON.stringify(args[0], bigIntReplacer)), filteredKeys);
141
- }
142
- return args;
143
- }
144
- __name(structureArgs, "structureArgs");
145
- function filterKeys(obj, keys) {
146
- if (typeof obj !== "object" || obj === null) {
147
- return obj;
148
- }
149
- if (Array.isArray(obj)) {
150
- return obj.map((item) => filterKeys(item, keys));
151
- }
152
- const filteredObj = {};
153
- for (const [key, value] of Object.entries(obj)) {
154
- if (keys.includes(key)) {
155
- if (value) {
156
- filteredObj[key] = `[filtered ${prettyPrintBytes(value)}]`;
157
- } else {
158
- filteredObj[key] = value;
159
- }
160
- continue;
161
- }
162
- filteredObj[key] = filterKeys(value, keys);
163
- }
164
- return filteredObj;
165
- }
166
- __name(filterKeys, "filterKeys");
167
- function prettyPrintBytes(value) {
168
- if (env.NODE_ENV === "production") {
169
- return "skipped size";
170
- }
171
- const sizeInBytes = getSizeInBytes(value);
172
- if (sizeInBytes < 1024) {
173
- return `${sizeInBytes} bytes`;
174
- }
175
- if (sizeInBytes < 1024 * 1024) {
176
- return `${(sizeInBytes / 1024).toFixed(2)} KB`;
177
- }
178
- if (sizeInBytes < 1024 * 1024 * 1024) {
179
- return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;
180
- }
181
- return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
182
- }
183
- __name(prettyPrintBytes, "prettyPrintBytes");
184
- function getSizeInBytes(value) {
185
- const jsonString = JSON.stringify(value);
186
- if (typeof window === "undefined") {
187
- return Buffer.byteLength(jsonString, "utf8");
188
- } else {
189
- return new TextEncoder().encode(jsonString).length;
190
- }
191
- }
192
- __name(getSizeInBytes, "getSizeInBytes");
193
6
 
194
7
  // src/schemas/addMissingVersionField.ts
195
8
  function addMissingVersionField(val) {
@@ -275,6 +88,13 @@ var EventMatcherSchema = z.union([
275
88
  z.number(),
276
89
  z.boolean()
277
90
  ])
91
+ }),
92
+ z.object({
93
+ $not: z.union([
94
+ z.string(),
95
+ z.number(),
96
+ z.boolean()
97
+ ])
278
98
  })
279
99
  ]))
280
100
  ]);
@@ -362,8 +182,8 @@ var ScheduledPayloadSchema = z.object({
362
182
  lastTimestamp: z.coerce.date().optional()
363
183
  });
364
184
  var IntervalOptionsSchema = z.object({
365
- /** The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days) */
366
- seconds: z.number().int().positive().min(60).max(2592e3)
185
+ /** The number of seconds for the interval. Min = 20, Max = 2_592_000 (30 days) */
186
+ seconds: z.number().int().positive().min(20).max(2592e3)
367
187
  });
368
188
  var CronOptionsSchema = z.object({
369
189
  /** A CRON expression that defines the schedule. A useful tool when writing CRON
@@ -1627,6 +1447,10 @@ var RequestWithRawBodySchema = z.object({
1627
1447
  headers: z.record(z.string()),
1628
1448
  rawBody: z.string()
1629
1449
  });
1450
+ var CancelRunsForJobSchema = z.object({
1451
+ cancelledRunIds: z.array(z.string()),
1452
+ failedToCancelRunIds: z.array(z.string())
1453
+ });
1630
1454
 
1631
1455
  // src/utils.ts
1632
1456
  function deepMergeFilters(...filters) {
@@ -1775,7 +1599,9 @@ function urlWithSearchParams(url, params) {
1775
1599
  }
1776
1600
  const urlObj = new URL(url);
1777
1601
  for (const [key, value] of Object.entries(params)) {
1778
- urlObj.searchParams.append(key, String(value));
1602
+ if (value !== void 0) {
1603
+ urlObj.searchParams.append(key, String(value));
1604
+ }
1779
1605
  }
1780
1606
  return urlObj.toString();
1781
1607
  }
@@ -1926,6 +1752,14 @@ function contentFilterMatches(actualValue, contentFilter) {
1926
1752
  }
1927
1753
  return actualValue !== null;
1928
1754
  }
1755
+ if ("$not" in contentFilter) {
1756
+ if (Array.isArray(actualValue)) {
1757
+ return !actualValue.includes(contentFilter.$not);
1758
+ } else if (typeof actualValue === "number" || typeof actualValue === "boolean" || typeof actualValue === "string") {
1759
+ return actualValue !== contentFilter.$not;
1760
+ }
1761
+ return false;
1762
+ }
1929
1763
  return true;
1930
1764
  }
1931
1765
  __name(contentFilterMatches, "contentFilterMatches");
@@ -2023,6 +1857,6 @@ function supportsFeature(featureName, version) {
2023
1857
  }
2024
1858
  __name(supportsFeature, "supportsFeature");
2025
1859
 
2026
- export { API_VERSIONS, ApiEventLogSchema, AutoYieldConfigSchema, AutoYieldMetadataSchema, CachedTaskSchema, CancelRunsForEventSchema, CommonMissingConnectionNotificationPayloadSchema, CommonMissingConnectionNotificationResolvedPayloadSchema, CompleteTaskBodyInputSchema, CompleteTaskBodyV2InputSchema, ConcurrencyLimitOptionsSchema, ConnectionAuthSchema, CreateExternalConnectionBodySchema, CreateRunResponseBodySchema, CronMetadataSchema, CronOptionsSchema, DELIVER_WEBHOOK_REQUEST, DeliverEventResponseSchema, DeserializedJsonSchema, DisplayPropertiesSchema, DisplayPropertySchema, DynamicTriggerEndpointMetadataSchema, DynamicTriggerMetadataSchema, EndpointHeadersSchema, EndpointIndexErrorSchema, EphemeralEventDispatcherRequestBodySchema, EphemeralEventDispatcherResponseBodySchema, ErrorWithStackSchema, EventExampleSchema, EventFilterSchema, EventRuleSchema, EventSpecificationSchema, ExecuteJobHeadersSchema, ExecuteJobRunMetadataSchema, FailTaskBodyInputSchema, FetchOperationSchema, FetchPollOperationSchema, FetchRequestInitSchema, FetchRetryBackoffStrategySchema, FetchRetryHeadersStrategySchema, FetchRetryOptionsSchema, FetchRetryStrategySchema, FetchTimeoutOptionsSchema, GetEndpointIndexResponseSchema, GetEventSchema, GetRunSchema, GetRunStatusesSchema, GetRunsSchema, HTTPMethodUnionSchema, HandleTriggerSourceSchema, HttpEndpointRequestHeadersSchema, HttpSourceRequestHeadersSchema, HttpSourceResponseSchema, IndexEndpointResponseSchema, InitializeCronScheduleBodySchema, InitializeTriggerBodySchema, IntegrationConfigSchema, IntegrationMetadataSchema, IntervalMetadataSchema, IntervalOptionsSchema, InvokeJobRequestBodySchema, InvokeJobResponseSchema, InvokeOptionsSchema, InvokeTriggerMetadataSchema, JobMetadataSchema, JobRunStatusRecordSchema, KeyValueStoreResponseBodySchema, LogMessageSchema, Logger, MISSING_CONNECTION_NOTIFICATION, MISSING_CONNECTION_RESOLVED_NOTIFICATION, MissingConnectionNotificationPayloadSchema, MissingConnectionResolvedNotificationPayloadSchema, MissingDeveloperConnectionNotificationPayloadSchema, MissingDeveloperConnectionResolvedNotificationPayloadSchema, MissingExternalConnectionNotificationPayloadSchema, MissingExternalConnectionResolvedNotificationPayloadSchema, NormalizedRequestSchema, NormalizedResponseSchema, PLATFORM_FEATURES, PongErrorResponseSchema, PongResponseSchema, PongSuccessResponseSchema, PreprocessRunBodySchema, PreprocessRunResponseSchema, QueueOptionsSchema, REGISTER_SOURCE_EVENT_V1, REGISTER_SOURCE_EVENT_V2, REGISTER_WEBHOOK, RawEventSchema, RedactSchema, RedactStringSchema, RegisterDynamicSchedulePayloadSchema, RegisterHTTPTriggerSourceBodySchema, RegisterIntervalScheduleBodySchema, RegisterSMTPTriggerSourceBodySchema, RegisterSQSTriggerSourceBodySchema, RegisterScheduleBodySchema, RegisterScheduleResponseBodySchema, RegisterSourceChannelBodySchema, RegisterSourceEventSchemaV1, RegisterSourceEventSchemaV2, RegisterTriggerBodySchemaV1, RegisterTriggerBodySchemaV2, RegisterTriggerSourceSchema, RegisterWebhookPayloadSchema, RegisterWebhookSourceSchema, RequestFilterSchema, RequestWithRawBodySchema, ResponseFilterSchema, RetryOptionsSchema, RunJobAutoYieldExecutionErrorSchema, RunJobAutoYieldWithCompletedTaskExecutionErrorSchema, RunJobBodySchema, RunJobCanceledWithTaskSchema, RunJobErrorResponseSchema, RunJobErrorSchema, RunJobInvalidPayloadErrorSchema, RunJobResponseSchema, RunJobResumeWithParallelTaskSchema, RunJobResumeWithTaskSchema, RunJobRetryWithTaskSchema, RunJobSuccessSchema, RunJobUnresolvedAuthErrorSchema, RunJobYieldExecutionErrorSchema, RunSourceContextSchema, RunStatusSchema, RunTaskBodyInputSchema, RunTaskBodyOutputSchema, RunTaskOptionsSchema, RunTaskResponseWithCachedTasksBodySchema, RunTaskSchema, RuntimeEnvironmentTypeSchema, SCHEDULED_EVENT, ScheduleMetadataSchema, ScheduledPayloadSchema, ScheduledTriggerMetadataSchema, SchemaErrorSchema, SendBulkEventsBodySchema, SendEventBodySchema, SendEventOptionsSchema, SerializableJsonSchema, ServerTaskSchema, SourceMetadataV2Schema, StaticTriggerMetadataSchema, StatusHistorySchema, StatusUpdateSchema, StatusUpdateStateSchema, StyleSchema, TaskSchema, TaskStatusSchema, TriggerHelpSchema, TriggerMetadataSchema, TriggerSourceSchema, UpdateTriggerSourceBodyV1Schema, UpdateTriggerSourceBodyV2Schema, UpdateWebhookBodySchema, ValidateErrorResponseSchema, ValidateResponseSchema, ValidateSuccessResponseSchema, WebhookContextMetadataSchema, WebhookDeliveryResponseSchema, WebhookMetadataSchema, WebhookSourceRequestHeadersSchema, addMissingVersionField, assertExhaustive, calculateResetAt, calculateRetryAt, currentDate, currentTimestampMilliseconds, currentTimestampSeconds, deepMergeFilters, eventFilterMatches, parseEndpointIndexStats, replacements, requestFilterMatches, responseFilterMatches, stringPatternMatchers, supportsFeature, urlWithSearchParams };
1860
+ export { API_VERSIONS, ApiEventLogSchema, AutoYieldConfigSchema, AutoYieldMetadataSchema, CachedTaskSchema, CancelRunsForEventSchema, CancelRunsForJobSchema, CommonMissingConnectionNotificationPayloadSchema, CommonMissingConnectionNotificationResolvedPayloadSchema, CompleteTaskBodyInputSchema, CompleteTaskBodyV2InputSchema, ConcurrencyLimitOptionsSchema, ConnectionAuthSchema, CreateExternalConnectionBodySchema, CreateRunResponseBodySchema, CronMetadataSchema, CronOptionsSchema, DELIVER_WEBHOOK_REQUEST, DeliverEventResponseSchema, DeserializedJsonSchema, DisplayPropertiesSchema, DisplayPropertySchema, DynamicTriggerEndpointMetadataSchema, DynamicTriggerMetadataSchema, EndpointHeadersSchema, EndpointIndexErrorSchema, EphemeralEventDispatcherRequestBodySchema, EphemeralEventDispatcherResponseBodySchema, ErrorWithStackSchema, EventExampleSchema, EventFilterSchema, EventRuleSchema, EventSpecificationSchema, ExecuteJobHeadersSchema, ExecuteJobRunMetadataSchema, FailTaskBodyInputSchema, FetchOperationSchema, FetchPollOperationSchema, FetchRequestInitSchema, FetchRetryBackoffStrategySchema, FetchRetryHeadersStrategySchema, FetchRetryOptionsSchema, FetchRetryStrategySchema, FetchTimeoutOptionsSchema, GetEndpointIndexResponseSchema, GetEventSchema, GetRunSchema, GetRunStatusesSchema, GetRunsSchema, HTTPMethodUnionSchema, HandleTriggerSourceSchema, HttpEndpointRequestHeadersSchema, HttpSourceRequestHeadersSchema, HttpSourceResponseSchema, IndexEndpointResponseSchema, InitializeCronScheduleBodySchema, InitializeTriggerBodySchema, IntegrationConfigSchema, IntegrationMetadataSchema, IntervalMetadataSchema, IntervalOptionsSchema, InvokeJobRequestBodySchema, InvokeJobResponseSchema, InvokeOptionsSchema, InvokeTriggerMetadataSchema, JobMetadataSchema, JobRunStatusRecordSchema, KeyValueStoreResponseBodySchema, LogMessageSchema, MISSING_CONNECTION_NOTIFICATION, MISSING_CONNECTION_RESOLVED_NOTIFICATION, MissingConnectionNotificationPayloadSchema, MissingConnectionResolvedNotificationPayloadSchema, MissingDeveloperConnectionNotificationPayloadSchema, MissingDeveloperConnectionResolvedNotificationPayloadSchema, MissingExternalConnectionNotificationPayloadSchema, MissingExternalConnectionResolvedNotificationPayloadSchema, NormalizedRequestSchema, NormalizedResponseSchema, PLATFORM_FEATURES, PongErrorResponseSchema, PongResponseSchema, PongSuccessResponseSchema, PreprocessRunBodySchema, PreprocessRunResponseSchema, QueueOptionsSchema, REGISTER_SOURCE_EVENT_V1, REGISTER_SOURCE_EVENT_V2, REGISTER_WEBHOOK, RawEventSchema, RedactSchema, RedactStringSchema, RegisterDynamicSchedulePayloadSchema, RegisterHTTPTriggerSourceBodySchema, RegisterIntervalScheduleBodySchema, RegisterSMTPTriggerSourceBodySchema, RegisterSQSTriggerSourceBodySchema, RegisterScheduleBodySchema, RegisterScheduleResponseBodySchema, RegisterSourceChannelBodySchema, RegisterSourceEventSchemaV1, RegisterSourceEventSchemaV2, RegisterTriggerBodySchemaV1, RegisterTriggerBodySchemaV2, RegisterTriggerSourceSchema, RegisterWebhookPayloadSchema, RegisterWebhookSourceSchema, RequestFilterSchema, RequestWithRawBodySchema, ResponseFilterSchema, RetryOptionsSchema, RunJobAutoYieldExecutionErrorSchema, RunJobAutoYieldWithCompletedTaskExecutionErrorSchema, RunJobBodySchema, RunJobCanceledWithTaskSchema, RunJobErrorResponseSchema, RunJobErrorSchema, RunJobInvalidPayloadErrorSchema, RunJobResponseSchema, RunJobResumeWithParallelTaskSchema, RunJobResumeWithTaskSchema, RunJobRetryWithTaskSchema, RunJobSuccessSchema, RunJobUnresolvedAuthErrorSchema, RunJobYieldExecutionErrorSchema, RunSourceContextSchema, RunStatusSchema, RunTaskBodyInputSchema, RunTaskBodyOutputSchema, RunTaskOptionsSchema, RunTaskResponseWithCachedTasksBodySchema, RunTaskSchema, RuntimeEnvironmentTypeSchema, SCHEDULED_EVENT, ScheduleMetadataSchema, ScheduledPayloadSchema, ScheduledTriggerMetadataSchema, SchemaErrorSchema, SendBulkEventsBodySchema, SendEventBodySchema, SendEventOptionsSchema, SerializableJsonSchema, ServerTaskSchema, SourceMetadataV2Schema, StaticTriggerMetadataSchema, StatusHistorySchema, StatusUpdateSchema, StatusUpdateStateSchema, StyleSchema, TaskSchema, TaskStatusSchema, TriggerHelpSchema, TriggerMetadataSchema, TriggerSourceSchema, UpdateTriggerSourceBodyV1Schema, UpdateTriggerSourceBodyV2Schema, UpdateWebhookBodySchema, ValidateErrorResponseSchema, ValidateResponseSchema, ValidateSuccessResponseSchema, WebhookContextMetadataSchema, WebhookDeliveryResponseSchema, WebhookMetadataSchema, WebhookSourceRequestHeadersSchema, addMissingVersionField, assertExhaustive, calculateResetAt, calculateRetryAt, currentDate, currentTimestampMilliseconds, currentTimestampSeconds, deepMergeFilters, eventFilterMatches, parseEndpointIndexStats, replacements, requestFilterMatches, responseFilterMatches, stringPatternMatchers, supportsFeature, urlWithSearchParams };
2027
1861
  //# sourceMappingURL=out.js.map
2028
1862
  //# sourceMappingURL=index.mjs.map