@trigger.dev/core 0.0.0-svelte-test-20231206141434 → 0.0.0-v3-canary-20240321115026
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/eventFilterMatches-2kHImluE.d.mts +133 -0
- package/dist/eventFilterMatches-2kHImluE.d.ts +133 -0
- package/dist/index.d.mts +106 -229
- package/dist/index.d.ts +106 -229
- package/dist/index.js +25 -191
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -191
- package/dist/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +19374 -0
- package/dist/v3/index.d.ts +19374 -0
- package/dist/v3/index.js +3910 -0
- package/dist/v3/index.js.map +1 -0
- package/dist/v3/index.mjs +3761 -0
- package/dist/v3/index.mjs.map +1 -0
- package/dist/v3/otel/index.d.mts +39 -0
- package/dist/v3/otel/index.d.ts +39 -0
- package/dist/v3/otel/index.js +423 -0
- package/dist/v3/otel/index.js.map +1 -0
- package/dist/v3/otel/index.mjs +412 -0
- package/dist/v3/otel/index.mjs.map +1 -0
- package/package.json +48 -2
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
|
|
@@ -1629,6 +1449,10 @@ var RequestWithRawBodySchema = zod.z.object({
|
|
|
1629
1449
|
headers: zod.z.record(zod.z.string()),
|
|
1630
1450
|
rawBody: zod.z.string()
|
|
1631
1451
|
});
|
|
1452
|
+
var CancelRunsForJobSchema = zod.z.object({
|
|
1453
|
+
cancelledRunIds: zod.z.array(zod.z.string()),
|
|
1454
|
+
failedToCancelRunIds: zod.z.array(zod.z.string())
|
|
1455
|
+
});
|
|
1632
1456
|
|
|
1633
1457
|
// src/utils.ts
|
|
1634
1458
|
function deepMergeFilters(...filters) {
|
|
@@ -1777,7 +1601,9 @@ function urlWithSearchParams(url, params) {
|
|
|
1777
1601
|
}
|
|
1778
1602
|
const urlObj = new URL(url);
|
|
1779
1603
|
for (const [key, value] of Object.entries(params)) {
|
|
1780
|
-
|
|
1604
|
+
if (value !== void 0) {
|
|
1605
|
+
urlObj.searchParams.append(key, String(value));
|
|
1606
|
+
}
|
|
1781
1607
|
}
|
|
1782
1608
|
return urlObj.toString();
|
|
1783
1609
|
}
|
|
@@ -1928,6 +1754,14 @@ function contentFilterMatches(actualValue, contentFilter) {
|
|
|
1928
1754
|
}
|
|
1929
1755
|
return actualValue !== null;
|
|
1930
1756
|
}
|
|
1757
|
+
if ("$not" in contentFilter) {
|
|
1758
|
+
if (Array.isArray(actualValue)) {
|
|
1759
|
+
return !actualValue.includes(contentFilter.$not);
|
|
1760
|
+
} else if (typeof actualValue === "number" || typeof actualValue === "boolean" || typeof actualValue === "string") {
|
|
1761
|
+
return actualValue !== contentFilter.$not;
|
|
1762
|
+
}
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1931
1765
|
return true;
|
|
1932
1766
|
}
|
|
1933
1767
|
__name(contentFilterMatches, "contentFilterMatches");
|
|
@@ -2031,6 +1865,7 @@ exports.AutoYieldConfigSchema = AutoYieldConfigSchema;
|
|
|
2031
1865
|
exports.AutoYieldMetadataSchema = AutoYieldMetadataSchema;
|
|
2032
1866
|
exports.CachedTaskSchema = CachedTaskSchema;
|
|
2033
1867
|
exports.CancelRunsForEventSchema = CancelRunsForEventSchema;
|
|
1868
|
+
exports.CancelRunsForJobSchema = CancelRunsForJobSchema;
|
|
2034
1869
|
exports.CommonMissingConnectionNotificationPayloadSchema = CommonMissingConnectionNotificationPayloadSchema;
|
|
2035
1870
|
exports.CommonMissingConnectionNotificationResolvedPayloadSchema = CommonMissingConnectionNotificationResolvedPayloadSchema;
|
|
2036
1871
|
exports.CompleteTaskBodyInputSchema = CompleteTaskBodyInputSchema;
|
|
@@ -2093,7 +1928,6 @@ exports.JobMetadataSchema = JobMetadataSchema;
|
|
|
2093
1928
|
exports.JobRunStatusRecordSchema = JobRunStatusRecordSchema;
|
|
2094
1929
|
exports.KeyValueStoreResponseBodySchema = KeyValueStoreResponseBodySchema;
|
|
2095
1930
|
exports.LogMessageSchema = LogMessageSchema;
|
|
2096
|
-
exports.Logger = Logger;
|
|
2097
1931
|
exports.MISSING_CONNECTION_NOTIFICATION = MISSING_CONNECTION_NOTIFICATION;
|
|
2098
1932
|
exports.MISSING_CONNECTION_RESOLVED_NOTIFICATION = MISSING_CONNECTION_RESOLVED_NOTIFICATION;
|
|
2099
1933
|
exports.MissingConnectionNotificationPayloadSchema = MissingConnectionNotificationPayloadSchema;
|