@trigger.dev/core 0.0.0-svelte-test-20231206141434 → 0.0.0-v2-prerelease-20240524135558
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.d.mts +224 -105
- package/dist/index.d.ts +224 -105
- package/dist/index.js +53 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -191
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,197 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var node_process = require('node:process');
|
|
4
|
-
var node_buffer = require('node:buffer');
|
|
5
3
|
var ulidx = require('ulidx');
|
|
6
4
|
var zod = require('zod');
|
|
7
5
|
|
|
8
6
|
var __defProp = Object.defineProperty;
|
|
9
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __accessCheck = (obj, member, msg) => {
|
|
11
|
-
if (!member.has(obj))
|
|
12
|
-
throw TypeError("Cannot " + msg);
|
|
13
|
-
};
|
|
14
|
-
var __privateGet = (obj, member, getter) => {
|
|
15
|
-
__accessCheck(obj, member, "read from private field");
|
|
16
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
17
|
-
};
|
|
18
|
-
var __privateAdd = (obj, member, value) => {
|
|
19
|
-
if (member.has(obj))
|
|
20
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
21
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
22
|
-
};
|
|
23
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
24
|
-
__accessCheck(obj, member, "write to private field");
|
|
25
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
26
|
-
return value;
|
|
27
|
-
};
|
|
28
|
-
var __privateMethod = (obj, member, method) => {
|
|
29
|
-
__accessCheck(obj, member, "access private method");
|
|
30
|
-
return method;
|
|
31
|
-
};
|
|
32
|
-
var logLevels = [
|
|
33
|
-
"log",
|
|
34
|
-
"error",
|
|
35
|
-
"warn",
|
|
36
|
-
"info",
|
|
37
|
-
"debug"
|
|
38
|
-
];
|
|
39
|
-
var _name, _level, _filteredKeys, _jsonReplacer, _additionalFields, _structuredLog, structuredLog_fn;
|
|
40
|
-
var _Logger = class _Logger {
|
|
41
|
-
constructor(name, level = "info", filteredKeys = [], jsonReplacer, additionalFields) {
|
|
42
|
-
__privateAdd(this, _structuredLog);
|
|
43
|
-
__privateAdd(this, _name, void 0);
|
|
44
|
-
__privateAdd(this, _level, void 0);
|
|
45
|
-
__privateAdd(this, _filteredKeys, []);
|
|
46
|
-
__privateAdd(this, _jsonReplacer, void 0);
|
|
47
|
-
__privateAdd(this, _additionalFields, void 0);
|
|
48
|
-
__privateSet(this, _name, name);
|
|
49
|
-
__privateSet(this, _level, logLevels.indexOf(node_process.env.TRIGGER_LOG_LEVEL ?? level));
|
|
50
|
-
__privateSet(this, _filteredKeys, filteredKeys);
|
|
51
|
-
__privateSet(this, _jsonReplacer, createReplacer(jsonReplacer));
|
|
52
|
-
__privateSet(this, _additionalFields, additionalFields ?? (() => ({})));
|
|
53
|
-
}
|
|
54
|
-
// Return a new Logger instance with the same name and a new log level
|
|
55
|
-
// but filter out the keys from the log messages (at any level)
|
|
56
|
-
filter(...keys) {
|
|
57
|
-
return new _Logger(__privateGet(this, _name), logLevels[__privateGet(this, _level)], keys, __privateGet(this, _jsonReplacer));
|
|
58
|
-
}
|
|
59
|
-
static satisfiesLogLevel(logLevel, setLevel) {
|
|
60
|
-
return logLevels.indexOf(logLevel) <= logLevels.indexOf(setLevel);
|
|
61
|
-
}
|
|
62
|
-
log(message, ...args) {
|
|
63
|
-
if (__privateGet(this, _level) < 0)
|
|
64
|
-
return;
|
|
65
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.log, message, "log", ...args);
|
|
66
|
-
}
|
|
67
|
-
error(message, ...args) {
|
|
68
|
-
if (__privateGet(this, _level) < 1)
|
|
69
|
-
return;
|
|
70
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.error, message, "error", ...args);
|
|
71
|
-
}
|
|
72
|
-
warn(message, ...args) {
|
|
73
|
-
if (__privateGet(this, _level) < 2)
|
|
74
|
-
return;
|
|
75
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.warn, message, "warn", ...args);
|
|
76
|
-
}
|
|
77
|
-
info(message, ...args) {
|
|
78
|
-
if (__privateGet(this, _level) < 3)
|
|
79
|
-
return;
|
|
80
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.info, message, "info", ...args);
|
|
81
|
-
}
|
|
82
|
-
debug(message, ...args) {
|
|
83
|
-
if (__privateGet(this, _level) < 4)
|
|
84
|
-
return;
|
|
85
|
-
__privateMethod(this, _structuredLog, structuredLog_fn).call(this, console.debug, message, "debug", ...args);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
_name = new WeakMap();
|
|
89
|
-
_level = new WeakMap();
|
|
90
|
-
_filteredKeys = new WeakMap();
|
|
91
|
-
_jsonReplacer = new WeakMap();
|
|
92
|
-
_additionalFields = new WeakMap();
|
|
93
|
-
_structuredLog = new WeakSet();
|
|
94
|
-
structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, level, ...args) {
|
|
95
|
-
const structuredLog = {
|
|
96
|
-
...structureArgs(safeJsonClone(args), __privateGet(this, _filteredKeys)),
|
|
97
|
-
...__privateGet(this, _additionalFields).call(this),
|
|
98
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
99
|
-
name: __privateGet(this, _name),
|
|
100
|
-
message,
|
|
101
|
-
level
|
|
102
|
-
};
|
|
103
|
-
loggerFunction(JSON.stringify(structuredLog, __privateGet(this, _jsonReplacer)));
|
|
104
|
-
}, "#structuredLog");
|
|
105
|
-
__name(_Logger, "Logger");
|
|
106
|
-
var Logger = _Logger;
|
|
107
|
-
function createReplacer(replacer) {
|
|
108
|
-
return (key, value) => {
|
|
109
|
-
if (typeof value === "bigint") {
|
|
110
|
-
return value.toString();
|
|
111
|
-
}
|
|
112
|
-
if (replacer) {
|
|
113
|
-
return replacer(key, value);
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
__name(createReplacer, "createReplacer");
|
|
119
|
-
function bigIntReplacer(_key, value) {
|
|
120
|
-
if (typeof value === "bigint") {
|
|
121
|
-
return value.toString();
|
|
122
|
-
}
|
|
123
|
-
return value;
|
|
124
|
-
}
|
|
125
|
-
__name(bigIntReplacer, "bigIntReplacer");
|
|
126
|
-
function safeJsonClone(obj) {
|
|
127
|
-
try {
|
|
128
|
-
return JSON.parse(JSON.stringify(obj, bigIntReplacer));
|
|
129
|
-
} catch (e) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
__name(safeJsonClone, "safeJsonClone");
|
|
134
|
-
function structureArgs(args, filteredKeys = []) {
|
|
135
|
-
if (!args) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (args.length === 0) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (args.length === 1 && typeof args[0] === "object") {
|
|
142
|
-
return filterKeys(JSON.parse(JSON.stringify(args[0], bigIntReplacer)), filteredKeys);
|
|
143
|
-
}
|
|
144
|
-
return args;
|
|
145
|
-
}
|
|
146
|
-
__name(structureArgs, "structureArgs");
|
|
147
|
-
function filterKeys(obj, keys) {
|
|
148
|
-
if (typeof obj !== "object" || obj === null) {
|
|
149
|
-
return obj;
|
|
150
|
-
}
|
|
151
|
-
if (Array.isArray(obj)) {
|
|
152
|
-
return obj.map((item) => filterKeys(item, keys));
|
|
153
|
-
}
|
|
154
|
-
const filteredObj = {};
|
|
155
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
156
|
-
if (keys.includes(key)) {
|
|
157
|
-
if (value) {
|
|
158
|
-
filteredObj[key] = `[filtered ${prettyPrintBytes(value)}]`;
|
|
159
|
-
} else {
|
|
160
|
-
filteredObj[key] = value;
|
|
161
|
-
}
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
filteredObj[key] = filterKeys(value, keys);
|
|
165
|
-
}
|
|
166
|
-
return filteredObj;
|
|
167
|
-
}
|
|
168
|
-
__name(filterKeys, "filterKeys");
|
|
169
|
-
function prettyPrintBytes(value) {
|
|
170
|
-
if (node_process.env.NODE_ENV === "production") {
|
|
171
|
-
return "skipped size";
|
|
172
|
-
}
|
|
173
|
-
const sizeInBytes = getSizeInBytes(value);
|
|
174
|
-
if (sizeInBytes < 1024) {
|
|
175
|
-
return `${sizeInBytes} bytes`;
|
|
176
|
-
}
|
|
177
|
-
if (sizeInBytes < 1024 * 1024) {
|
|
178
|
-
return `${(sizeInBytes / 1024).toFixed(2)} KB`;
|
|
179
|
-
}
|
|
180
|
-
if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
181
|
-
return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
182
|
-
}
|
|
183
|
-
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
184
|
-
}
|
|
185
|
-
__name(prettyPrintBytes, "prettyPrintBytes");
|
|
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");
|
|
195
8
|
|
|
196
9
|
// src/schemas/addMissingVersionField.ts
|
|
197
10
|
function addMissingVersionField(val) {
|
|
@@ -277,6 +90,13 @@ var EventMatcherSchema = zod.z.union([
|
|
|
277
90
|
zod.z.number(),
|
|
278
91
|
zod.z.boolean()
|
|
279
92
|
])
|
|
93
|
+
}),
|
|
94
|
+
zod.z.object({
|
|
95
|
+
$not: zod.z.union([
|
|
96
|
+
zod.z.string(),
|
|
97
|
+
zod.z.number(),
|
|
98
|
+
zod.z.boolean()
|
|
99
|
+
])
|
|
280
100
|
})
|
|
281
101
|
]))
|
|
282
102
|
]);
|
|
@@ -364,8 +184,8 @@ var ScheduledPayloadSchema = zod.z.object({
|
|
|
364
184
|
lastTimestamp: zod.z.coerce.date().optional()
|
|
365
185
|
});
|
|
366
186
|
var IntervalOptionsSchema = zod.z.object({
|
|
367
|
-
/** The number of seconds for the interval. Min =
|
|
368
|
-
seconds: zod.z.number().int().positive().min(
|
|
187
|
+
/** The number of seconds for the interval. Min = 20, Max = 2_592_000 (30 days) */
|
|
188
|
+
seconds: zod.z.number().int().positive().min(20).max(2592e3)
|
|
369
189
|
});
|
|
370
190
|
var CronOptionsSchema = zod.z.object({
|
|
371
191
|
/** A CRON expression that defines the schedule. A useful tool when writing CRON
|
|
@@ -1150,6 +970,10 @@ var RunJobAutoYieldWithCompletedTaskExecutionErrorSchema = zod.z.object({
|
|
|
1150
970
|
output: zod.z.string().optional(),
|
|
1151
971
|
data: AutoYieldMetadataSchema
|
|
1152
972
|
});
|
|
973
|
+
var RunJobAutoYieldRateLimitErrorSchema = zod.z.object({
|
|
974
|
+
status: zod.z.literal("AUTO_YIELD_RATE_LIMIT"),
|
|
975
|
+
reset: zod.z.coerce.number()
|
|
976
|
+
});
|
|
1153
977
|
var RunJobInvalidPayloadErrorSchema = zod.z.object({
|
|
1154
978
|
status: zod.z.literal("INVALID_PAYLOAD"),
|
|
1155
979
|
errors: zod.z.array(SchemaErrorSchema)
|
|
@@ -1183,6 +1007,7 @@ var RunJobErrorResponseSchema = zod.z.union([
|
|
|
1183
1007
|
RunJobAutoYieldExecutionErrorSchema,
|
|
1184
1008
|
RunJobAutoYieldWithCompletedTaskExecutionErrorSchema,
|
|
1185
1009
|
RunJobYieldExecutionErrorSchema,
|
|
1010
|
+
RunJobAutoYieldRateLimitErrorSchema,
|
|
1186
1011
|
RunJobErrorSchema,
|
|
1187
1012
|
RunJobUnresolvedAuthErrorSchema,
|
|
1188
1013
|
RunJobInvalidPayloadErrorSchema,
|
|
@@ -1199,6 +1024,7 @@ var RunJobResponseSchema = zod.z.discriminatedUnion("status", [
|
|
|
1199
1024
|
RunJobAutoYieldExecutionErrorSchema,
|
|
1200
1025
|
RunJobAutoYieldWithCompletedTaskExecutionErrorSchema,
|
|
1201
1026
|
RunJobYieldExecutionErrorSchema,
|
|
1027
|
+
RunJobAutoYieldRateLimitErrorSchema,
|
|
1202
1028
|
RunJobErrorSchema,
|
|
1203
1029
|
RunJobUnresolvedAuthErrorSchema,
|
|
1204
1030
|
RunJobInvalidPayloadErrorSchema,
|
|
@@ -1629,6 +1455,10 @@ var RequestWithRawBodySchema = zod.z.object({
|
|
|
1629
1455
|
headers: zod.z.record(zod.z.string()),
|
|
1630
1456
|
rawBody: zod.z.string()
|
|
1631
1457
|
});
|
|
1458
|
+
var CancelRunsForJobSchema = zod.z.object({
|
|
1459
|
+
cancelledRunIds: zod.z.array(zod.z.string()),
|
|
1460
|
+
failedToCancelRunIds: zod.z.array(zod.z.string())
|
|
1461
|
+
});
|
|
1632
1462
|
|
|
1633
1463
|
// src/utils.ts
|
|
1634
1464
|
function deepMergeFilters(...filters) {
|
|
@@ -1777,7 +1607,9 @@ function urlWithSearchParams(url, params) {
|
|
|
1777
1607
|
}
|
|
1778
1608
|
const urlObj = new URL(url);
|
|
1779
1609
|
for (const [key, value] of Object.entries(params)) {
|
|
1780
|
-
|
|
1610
|
+
if (value !== void 0) {
|
|
1611
|
+
urlObj.searchParams.append(key, String(value));
|
|
1612
|
+
}
|
|
1781
1613
|
}
|
|
1782
1614
|
return urlObj.toString();
|
|
1783
1615
|
}
|
|
@@ -1928,6 +1760,14 @@ function contentFilterMatches(actualValue, contentFilter) {
|
|
|
1928
1760
|
}
|
|
1929
1761
|
return actualValue !== null;
|
|
1930
1762
|
}
|
|
1763
|
+
if ("$not" in contentFilter) {
|
|
1764
|
+
if (Array.isArray(actualValue)) {
|
|
1765
|
+
return !actualValue.includes(contentFilter.$not);
|
|
1766
|
+
} else if (typeof actualValue === "number" || typeof actualValue === "boolean" || typeof actualValue === "string") {
|
|
1767
|
+
return actualValue !== contentFilter.$not;
|
|
1768
|
+
}
|
|
1769
|
+
return false;
|
|
1770
|
+
}
|
|
1931
1771
|
return true;
|
|
1932
1772
|
}
|
|
1933
1773
|
__name(contentFilterMatches, "contentFilterMatches");
|
|
@@ -2003,6 +1843,23 @@ function requestMethodMatches(method, filter) {
|
|
|
2003
1843
|
return filter.includes(method);
|
|
2004
1844
|
}
|
|
2005
1845
|
__name(requestMethodMatches, "requestMethodMatches");
|
|
1846
|
+
var CreateAuthorizationCodeResponseSchema = zod.z.object({
|
|
1847
|
+
url: zod.z.string().url(),
|
|
1848
|
+
authorizationCode: zod.z.string()
|
|
1849
|
+
});
|
|
1850
|
+
var GetPersonalAccessTokenRequestSchema = zod.z.object({
|
|
1851
|
+
authorizationCode: zod.z.string()
|
|
1852
|
+
});
|
|
1853
|
+
var GetPersonalAccessTokenResponseSchema = zod.z.object({
|
|
1854
|
+
token: zod.z.object({
|
|
1855
|
+
token: zod.z.string(),
|
|
1856
|
+
obfuscatedToken: zod.z.string()
|
|
1857
|
+
}).nullable()
|
|
1858
|
+
});
|
|
1859
|
+
var WhoAmIResponseSchema = zod.z.object({
|
|
1860
|
+
userId: zod.z.string(),
|
|
1861
|
+
email: zod.z.string().email()
|
|
1862
|
+
});
|
|
2006
1863
|
|
|
2007
1864
|
// src/index.ts
|
|
2008
1865
|
var API_VERSIONS = {
|
|
@@ -2031,12 +1888,14 @@ exports.AutoYieldConfigSchema = AutoYieldConfigSchema;
|
|
|
2031
1888
|
exports.AutoYieldMetadataSchema = AutoYieldMetadataSchema;
|
|
2032
1889
|
exports.CachedTaskSchema = CachedTaskSchema;
|
|
2033
1890
|
exports.CancelRunsForEventSchema = CancelRunsForEventSchema;
|
|
1891
|
+
exports.CancelRunsForJobSchema = CancelRunsForJobSchema;
|
|
2034
1892
|
exports.CommonMissingConnectionNotificationPayloadSchema = CommonMissingConnectionNotificationPayloadSchema;
|
|
2035
1893
|
exports.CommonMissingConnectionNotificationResolvedPayloadSchema = CommonMissingConnectionNotificationResolvedPayloadSchema;
|
|
2036
1894
|
exports.CompleteTaskBodyInputSchema = CompleteTaskBodyInputSchema;
|
|
2037
1895
|
exports.CompleteTaskBodyV2InputSchema = CompleteTaskBodyV2InputSchema;
|
|
2038
1896
|
exports.ConcurrencyLimitOptionsSchema = ConcurrencyLimitOptionsSchema;
|
|
2039
1897
|
exports.ConnectionAuthSchema = ConnectionAuthSchema;
|
|
1898
|
+
exports.CreateAuthorizationCodeResponseSchema = CreateAuthorizationCodeResponseSchema;
|
|
2040
1899
|
exports.CreateExternalConnectionBodySchema = CreateExternalConnectionBodySchema;
|
|
2041
1900
|
exports.CreateRunResponseBodySchema = CreateRunResponseBodySchema;
|
|
2042
1901
|
exports.CronMetadataSchema = CronMetadataSchema;
|
|
@@ -2070,6 +1929,8 @@ exports.FetchRetryStrategySchema = FetchRetryStrategySchema;
|
|
|
2070
1929
|
exports.FetchTimeoutOptionsSchema = FetchTimeoutOptionsSchema;
|
|
2071
1930
|
exports.GetEndpointIndexResponseSchema = GetEndpointIndexResponseSchema;
|
|
2072
1931
|
exports.GetEventSchema = GetEventSchema;
|
|
1932
|
+
exports.GetPersonalAccessTokenRequestSchema = GetPersonalAccessTokenRequestSchema;
|
|
1933
|
+
exports.GetPersonalAccessTokenResponseSchema = GetPersonalAccessTokenResponseSchema;
|
|
2073
1934
|
exports.GetRunSchema = GetRunSchema;
|
|
2074
1935
|
exports.GetRunStatusesSchema = GetRunStatusesSchema;
|
|
2075
1936
|
exports.GetRunsSchema = GetRunsSchema;
|
|
@@ -2093,7 +1954,6 @@ exports.JobMetadataSchema = JobMetadataSchema;
|
|
|
2093
1954
|
exports.JobRunStatusRecordSchema = JobRunStatusRecordSchema;
|
|
2094
1955
|
exports.KeyValueStoreResponseBodySchema = KeyValueStoreResponseBodySchema;
|
|
2095
1956
|
exports.LogMessageSchema = LogMessageSchema;
|
|
2096
|
-
exports.Logger = Logger;
|
|
2097
1957
|
exports.MISSING_CONNECTION_NOTIFICATION = MISSING_CONNECTION_NOTIFICATION;
|
|
2098
1958
|
exports.MISSING_CONNECTION_RESOLVED_NOTIFICATION = MISSING_CONNECTION_RESOLVED_NOTIFICATION;
|
|
2099
1959
|
exports.MissingConnectionNotificationPayloadSchema = MissingConnectionNotificationPayloadSchema;
|
|
@@ -2137,6 +1997,7 @@ exports.RequestWithRawBodySchema = RequestWithRawBodySchema;
|
|
|
2137
1997
|
exports.ResponseFilterSchema = ResponseFilterSchema;
|
|
2138
1998
|
exports.RetryOptionsSchema = RetryOptionsSchema;
|
|
2139
1999
|
exports.RunJobAutoYieldExecutionErrorSchema = RunJobAutoYieldExecutionErrorSchema;
|
|
2000
|
+
exports.RunJobAutoYieldRateLimitErrorSchema = RunJobAutoYieldRateLimitErrorSchema;
|
|
2140
2001
|
exports.RunJobAutoYieldWithCompletedTaskExecutionErrorSchema = RunJobAutoYieldWithCompletedTaskExecutionErrorSchema;
|
|
2141
2002
|
exports.RunJobBodySchema = RunJobBodySchema;
|
|
2142
2003
|
exports.RunJobCanceledWithTaskSchema = RunJobCanceledWithTaskSchema;
|
|
@@ -2189,6 +2050,7 @@ exports.WebhookContextMetadataSchema = WebhookContextMetadataSchema;
|
|
|
2189
2050
|
exports.WebhookDeliveryResponseSchema = WebhookDeliveryResponseSchema;
|
|
2190
2051
|
exports.WebhookMetadataSchema = WebhookMetadataSchema;
|
|
2191
2052
|
exports.WebhookSourceRequestHeadersSchema = WebhookSourceRequestHeadersSchema;
|
|
2053
|
+
exports.WhoAmIResponseSchema = WhoAmIResponseSchema;
|
|
2192
2054
|
exports.addMissingVersionField = addMissingVersionField;
|
|
2193
2055
|
exports.assertExhaustive = assertExhaustive;
|
|
2194
2056
|
exports.calculateResetAt = calculateResetAt;
|