@trigger.dev/sdk 0.0.0-cross-runtime-20231204083620 → 0.0.0-cross-runtime-20231204115010
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 +147 -254
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -118
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_async_hooks = require('node:async_hooks');
|
|
4
|
+
var core = require('@trigger.dev/core');
|
|
5
|
+
var node_process = require('node:process');
|
|
6
|
+
var zod = require('zod');
|
|
7
|
+
var coreBackend = require('@trigger.dev/core-backend');
|
|
8
|
+
var crypto = require('node:crypto');
|
|
9
|
+
var node_buffer = require('node:buffer');
|
|
10
|
+
var cronstrue = require('cronstrue');
|
|
11
|
+
var EventEmitter = require('node:events');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
16
|
+
var cronstrue__default = /*#__PURE__*/_interopDefault(cronstrue);
|
|
17
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefault(EventEmitter);
|
|
18
|
+
|
|
3
19
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
20
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
21
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
22
|
var __publicField = (obj, key, value) => {
|
|
32
23
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
33
24
|
return value;
|
|
@@ -55,44 +46,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
55
46
|
return method;
|
|
56
47
|
};
|
|
57
48
|
|
|
58
|
-
// src/index.ts
|
|
59
|
-
var src_exports = {};
|
|
60
|
-
__export(src_exports, {
|
|
61
|
-
CronTrigger: () => CronTrigger,
|
|
62
|
-
DynamicSchedule: () => DynamicSchedule,
|
|
63
|
-
DynamicTrigger: () => DynamicTrigger,
|
|
64
|
-
EventSpecificationExampleSchema: () => EventSpecificationExampleSchema,
|
|
65
|
-
EventTrigger: () => EventTrigger,
|
|
66
|
-
ExternalSource: () => ExternalSource,
|
|
67
|
-
ExternalSourceTrigger: () => ExternalSourceTrigger,
|
|
68
|
-
IO: () => IO,
|
|
69
|
-
IOLogger: () => IOLogger,
|
|
70
|
-
IntervalTrigger: () => IntervalTrigger,
|
|
71
|
-
InvokeTrigger: () => InvokeTrigger,
|
|
72
|
-
JSONOutputSerializer: () => JSONOutputSerializer,
|
|
73
|
-
Job: () => Job,
|
|
74
|
-
MissingConnectionNotification: () => MissingConnectionNotification,
|
|
75
|
-
MissingConnectionResolvedNotification: () => MissingConnectionResolvedNotification,
|
|
76
|
-
TriggerClient: () => TriggerClient,
|
|
77
|
-
WebhookSource: () => WebhookSource,
|
|
78
|
-
WebhookTrigger: () => WebhookTrigger,
|
|
79
|
-
cronTrigger: () => cronTrigger,
|
|
80
|
-
eventTrigger: () => eventTrigger,
|
|
81
|
-
intervalTrigger: () => intervalTrigger,
|
|
82
|
-
invokeTrigger: () => invokeTrigger,
|
|
83
|
-
isTriggerError: () => isTriggerError,
|
|
84
|
-
missingConnectionNotification: () => missingConnectionNotification,
|
|
85
|
-
missingConnectionResolvedNotification: () => missingConnectionResolvedNotification,
|
|
86
|
-
omit: () => omit,
|
|
87
|
-
redactString: () => redactString,
|
|
88
|
-
retry: () => retry,
|
|
89
|
-
slugifyId: () => slugifyId,
|
|
90
|
-
verifyHmacSha256: () => verifyHmacSha256,
|
|
91
|
-
verifyRequestSignature: () => verifyRequestSignature,
|
|
92
|
-
waitForEventSchema: () => waitForEventSchema
|
|
93
|
-
});
|
|
94
|
-
module.exports = __toCommonJS(src_exports);
|
|
95
|
-
|
|
96
49
|
// src/utils.ts
|
|
97
50
|
function slugifyId(input) {
|
|
98
51
|
const replaceSpacesWithDash = input.toLowerCase().replace(/\s+/g, "-");
|
|
@@ -100,12 +53,9 @@ function slugifyId(input) {
|
|
|
100
53
|
return removeNonUrlSafeChars;
|
|
101
54
|
}
|
|
102
55
|
__name(slugifyId, "slugifyId");
|
|
103
|
-
|
|
104
|
-
// src/utils/typedAsyncLocalStorage.ts
|
|
105
|
-
var import_node_async_hooks = require("node:async_hooks");
|
|
106
56
|
var _TypedAsyncLocalStorage = class _TypedAsyncLocalStorage {
|
|
107
57
|
constructor() {
|
|
108
|
-
this.storage = new
|
|
58
|
+
this.storage = new node_async_hooks.AsyncLocalStorage();
|
|
109
59
|
}
|
|
110
60
|
runWith(context, fn) {
|
|
111
61
|
return this.storage.run(context, fn);
|
|
@@ -302,21 +252,6 @@ validate_fn = /* @__PURE__ */ __name(function() {
|
|
|
302
252
|
__name(_Job, "Job");
|
|
303
253
|
var Job = _Job;
|
|
304
254
|
|
|
305
|
-
// src/triggerClient.ts
|
|
306
|
-
var import_core8 = require("@trigger.dev/core");
|
|
307
|
-
var import_node_process2 = require("node:process");
|
|
308
|
-
|
|
309
|
-
// src/apiClient.ts
|
|
310
|
-
var import_core3 = require("@trigger.dev/core");
|
|
311
|
-
var import_node_process = require("node:process");
|
|
312
|
-
var import_zod3 = require("zod");
|
|
313
|
-
|
|
314
|
-
// src/io.ts
|
|
315
|
-
var import_core2 = require("@trigger.dev/core");
|
|
316
|
-
var import_core_backend = require("@trigger.dev/core-backend");
|
|
317
|
-
var import_node_async_hooks2 = require("node:async_hooks");
|
|
318
|
-
var import_node_crypto = require("node:crypto");
|
|
319
|
-
|
|
320
255
|
// src/errors.ts
|
|
321
256
|
var _ResumeWithTaskError = class _ResumeWithTaskError {
|
|
322
257
|
constructor(task) {
|
|
@@ -394,9 +329,6 @@ var _ErrorWithTask = class _ErrorWithTask extends Error {
|
|
|
394
329
|
};
|
|
395
330
|
__name(_ErrorWithTask, "ErrorWithTask");
|
|
396
331
|
var ErrorWithTask = _ErrorWithTask;
|
|
397
|
-
|
|
398
|
-
// src/retry.ts
|
|
399
|
-
var import_core = require("@trigger.dev/core");
|
|
400
332
|
var retry = {
|
|
401
333
|
standardBackoff: {
|
|
402
334
|
limit: 8,
|
|
@@ -448,31 +380,25 @@ var _TriggerStatus = class _TriggerStatus {
|
|
|
448
380
|
};
|
|
449
381
|
__name(_TriggerStatus, "TriggerStatus");
|
|
450
382
|
var TriggerStatus = _TriggerStatus;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
name: import_zod.z.string(),
|
|
457
|
-
icon: import_zod.z.string().optional(),
|
|
458
|
-
payload: import_zod.z.any()
|
|
383
|
+
var EventSpecificationExampleSchema = zod.z.object({
|
|
384
|
+
id: zod.z.string(),
|
|
385
|
+
name: zod.z.string(),
|
|
386
|
+
icon: zod.z.string().optional(),
|
|
387
|
+
payload: zod.z.any()
|
|
459
388
|
});
|
|
460
389
|
function waitForEventSchema(schema) {
|
|
461
|
-
return
|
|
462
|
-
id:
|
|
463
|
-
name:
|
|
464
|
-
source:
|
|
390
|
+
return zod.z.object({
|
|
391
|
+
id: zod.z.string(),
|
|
392
|
+
name: zod.z.string(),
|
|
393
|
+
source: zod.z.string(),
|
|
465
394
|
payload: schema,
|
|
466
|
-
timestamp:
|
|
467
|
-
context:
|
|
468
|
-
accountId:
|
|
395
|
+
timestamp: zod.z.coerce.date(),
|
|
396
|
+
context: zod.z.any().optional(),
|
|
397
|
+
accountId: zod.z.string().optional()
|
|
469
398
|
});
|
|
470
399
|
}
|
|
471
400
|
__name(waitForEventSchema, "waitForEventSchema");
|
|
472
401
|
|
|
473
|
-
// src/io.ts
|
|
474
|
-
var import_zod2 = require("zod");
|
|
475
|
-
|
|
476
402
|
// src/store/keyValueStore.ts
|
|
477
403
|
var _namespacedKey, namespacedKey_fn, _sharedProperties, sharedProperties_fn;
|
|
478
404
|
var _KeyValueStore = class _KeyValueStore {
|
|
@@ -625,9 +551,6 @@ sharedProperties_fn = /* @__PURE__ */ __name(function(key1) {
|
|
|
625
551
|
}, "#sharedProperties");
|
|
626
552
|
__name(_KeyValueStore, "KeyValueStore");
|
|
627
553
|
var KeyValueStore = _KeyValueStore;
|
|
628
|
-
|
|
629
|
-
// src/io.ts
|
|
630
|
-
var import_node_buffer = require("node:buffer");
|
|
631
554
|
var _JSONOutputSerializer = class _JSONOutputSerializer {
|
|
632
555
|
serialize(value) {
|
|
633
556
|
return JSON.stringify(value);
|
|
@@ -656,7 +579,7 @@ var _IO = class _IO {
|
|
|
656
579
|
this._jobId = options.jobId;
|
|
657
580
|
this._apiClient = options.apiClient;
|
|
658
581
|
this._triggerClient = options.client;
|
|
659
|
-
this._logger = options.logger ?? new
|
|
582
|
+
this._logger = options.logger ?? new core.Logger("trigger.dev", options.logLevel);
|
|
660
583
|
this._cachedTasks = /* @__PURE__ */ new Map();
|
|
661
584
|
this._jobLogger = options.jobLogger;
|
|
662
585
|
this._jobLogLevel = options.jobLogLevel;
|
|
@@ -680,11 +603,11 @@ var _IO = class _IO {
|
|
|
680
603
|
});
|
|
681
604
|
this._stats.initialCachedTasks = options.cachedTasks.length;
|
|
682
605
|
}
|
|
683
|
-
this._taskStorage = new
|
|
606
|
+
this._taskStorage = new node_async_hooks.AsyncLocalStorage();
|
|
684
607
|
this._context = options.context;
|
|
685
608
|
this._yieldedExecutions = options.yieldedExecutions ?? [];
|
|
686
609
|
if (options.noopTasksSet) {
|
|
687
|
-
this._noopTasksBloomFilter =
|
|
610
|
+
this._noopTasksBloomFilter = coreBackend.BloomFilter.deserialize(options.noopTasksSet, coreBackend.BloomFilter.NOOP_TASK_SET_SIZE);
|
|
688
611
|
}
|
|
689
612
|
this._cachedTasksCursor = options.cachedTasksCursor;
|
|
690
613
|
this._serverVersion = options.serverVersion ?? "unversioned";
|
|
@@ -704,7 +627,7 @@ var _IO = class _IO {
|
|
|
704
627
|
get logger() {
|
|
705
628
|
return new IOLogger(async (level, message, data) => {
|
|
706
629
|
let logLevel = "info";
|
|
707
|
-
if (
|
|
630
|
+
if (core.Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
|
|
708
631
|
await this.runTask([
|
|
709
632
|
message,
|
|
710
633
|
level
|
|
@@ -884,7 +807,7 @@ var _IO = class _IO {
|
|
|
884
807
|
] : []
|
|
885
808
|
],
|
|
886
809
|
parseOutput: (output) => {
|
|
887
|
-
return waitForEventSchema(event.schema ??
|
|
810
|
+
return waitForEventSchema(event.schema ?? zod.z.any()).parse(output);
|
|
888
811
|
}
|
|
889
812
|
});
|
|
890
813
|
}
|
|
@@ -1500,14 +1423,14 @@ var _IO = class _IO {
|
|
|
1500
1423
|
}, {
|
|
1501
1424
|
cachedTasksCursor: this._cachedTasksCursor
|
|
1502
1425
|
});
|
|
1503
|
-
const task = response.version ===
|
|
1426
|
+
const task = response.version === core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS ? response.body.task : response.body;
|
|
1504
1427
|
if (task.forceYield) {
|
|
1505
1428
|
this._logger.debug("Forcing yield after run task", {
|
|
1506
1429
|
idempotencyKey
|
|
1507
1430
|
});
|
|
1508
1431
|
__privateMethod(this, _forceYield, forceYield_fn).call(this, "after_run_task");
|
|
1509
1432
|
}
|
|
1510
|
-
if (response.version ===
|
|
1433
|
+
if (response.version === core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS) {
|
|
1511
1434
|
this._cachedTasksCursor = response.body.cachedTasks?.cursor;
|
|
1512
1435
|
for (const cachedTask2 of response.body.cachedTasks?.tasks ?? []) {
|
|
1513
1436
|
if (!this._cachedTasks.has(cachedTask2.idempotencyKey)) {
|
|
@@ -1596,7 +1519,7 @@ var _IO = class _IO {
|
|
|
1596
1519
|
} else {
|
|
1597
1520
|
skipRetrying = !!onErrorResult.skipRetrying;
|
|
1598
1521
|
if (onErrorResult.retryAt && !skipRetrying) {
|
|
1599
|
-
const parsedError2 =
|
|
1522
|
+
const parsedError2 = core.ErrorWithStackSchema.safeParse(onErrorResult.error);
|
|
1600
1523
|
throw new RetryWithTaskError(parsedError2.success ? parsedError2.data : {
|
|
1601
1524
|
message: "Unknown error"
|
|
1602
1525
|
}, task, onErrorResult.retryAt);
|
|
@@ -1615,9 +1538,9 @@ var _IO = class _IO {
|
|
|
1615
1538
|
error: error.cause.output
|
|
1616
1539
|
});
|
|
1617
1540
|
}
|
|
1618
|
-
const parsedError =
|
|
1541
|
+
const parsedError = core.ErrorWithStackSchema.safeParse(error);
|
|
1619
1542
|
if (options?.retry && !skipRetrying) {
|
|
1620
|
-
const retryAt =
|
|
1543
|
+
const retryAt = core.calculateRetryAt(options.retry, task.attempts - 1);
|
|
1621
1544
|
if (retryAt) {
|
|
1622
1545
|
throw new RetryWithTaskError(parsedError.success ? parsedError.data : {
|
|
1623
1546
|
message: "Unknown error"
|
|
@@ -1667,7 +1590,7 @@ var _IO = class _IO {
|
|
|
1667
1590
|
* `io.yield()` allows you to yield execution of the current run and resume it in a new function execution. Similar to `io.wait()` but does not create a task and resumes execution immediately.
|
|
1668
1591
|
*/
|
|
1669
1592
|
yield(cacheKey) {
|
|
1670
|
-
if (!
|
|
1593
|
+
if (!core.supportsFeature("yieldExecution", this._serverVersion)) {
|
|
1671
1594
|
console.warn("[trigger.dev] io.yield() is not support by the version of the Trigger.dev server you are using, you will need to upgrade your self-hosted Trigger.dev instance.");
|
|
1672
1595
|
return;
|
|
1673
1596
|
}
|
|
@@ -1747,8 +1670,8 @@ async function generateIdempotencyKey(keyMaterial) {
|
|
|
1747
1670
|
return stableStringify(key2);
|
|
1748
1671
|
});
|
|
1749
1672
|
const key = keys.join(":");
|
|
1750
|
-
const hash = await
|
|
1751
|
-
return
|
|
1673
|
+
const hash = await crypto.webcrypto.subtle.digest("SHA-256", node_buffer.Buffer.from(key));
|
|
1674
|
+
return node_buffer.Buffer.from(hash).toString("hex");
|
|
1752
1675
|
}
|
|
1753
1676
|
__name(generateIdempotencyKey, "generateIdempotencyKey");
|
|
1754
1677
|
function stableStringify(obj) {
|
|
@@ -1903,8 +1826,8 @@ var _ApiClient = class _ApiClient {
|
|
|
1903
1826
|
__privateAdd(this, _logger, void 0);
|
|
1904
1827
|
__privateAdd(this, _storeClient, void 0);
|
|
1905
1828
|
__privateSet(this, _options, options);
|
|
1906
|
-
__privateSet(this, _apiUrl, __privateGet(this, _options).apiUrl ??
|
|
1907
|
-
__privateSet(this, _logger, new
|
|
1829
|
+
__privateSet(this, _apiUrl, __privateGet(this, _options).apiUrl ?? node_process.env.TRIGGER_API_URL ?? "https://api.trigger.dev");
|
|
1830
|
+
__privateSet(this, _logger, new core.Logger("trigger.dev", __privateGet(this, _options).logLevel));
|
|
1908
1831
|
__privateSet(this, _storeClient, new KeyValueStoreClient(__privateMethod(this, _queryKeyValueStore, queryKeyValueStore_fn).bind(this)));
|
|
1909
1832
|
}
|
|
1910
1833
|
async registerEndpoint(options) {
|
|
@@ -1939,15 +1862,15 @@ var _ApiClient = class _ApiClient {
|
|
|
1939
1862
|
task
|
|
1940
1863
|
});
|
|
1941
1864
|
return await zodfetchWithVersions({
|
|
1942
|
-
[
|
|
1943
|
-
},
|
|
1865
|
+
[core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS]: core.RunTaskResponseWithCachedTasksBodySchema
|
|
1866
|
+
}, core.ServerTaskSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/tasks`, {
|
|
1944
1867
|
method: "POST",
|
|
1945
1868
|
headers: {
|
|
1946
1869
|
"Content-Type": "application/json",
|
|
1947
1870
|
Authorization: `Bearer ${apiKey}`,
|
|
1948
1871
|
"Idempotency-Key": task.idempotencyKey,
|
|
1949
1872
|
"X-Cached-Tasks-Cursor": options.cachedTasksCursor ?? "",
|
|
1950
|
-
"Trigger-Version":
|
|
1873
|
+
"Trigger-Version": core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS
|
|
1951
1874
|
},
|
|
1952
1875
|
body: JSON.stringify(task)
|
|
1953
1876
|
});
|
|
@@ -1957,12 +1880,12 @@ var _ApiClient = class _ApiClient {
|
|
|
1957
1880
|
__privateGet(this, _logger).debug("Complete Task", {
|
|
1958
1881
|
task
|
|
1959
1882
|
});
|
|
1960
|
-
return await zodfetch(
|
|
1883
|
+
return await zodfetch(core.ServerTaskSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/tasks/${id}/complete`, {
|
|
1961
1884
|
method: "POST",
|
|
1962
1885
|
headers: {
|
|
1963
1886
|
"Content-Type": "application/json",
|
|
1964
1887
|
Authorization: `Bearer ${apiKey}`,
|
|
1965
|
-
"Trigger-Version":
|
|
1888
|
+
"Trigger-Version": core.API_VERSIONS.SERIALIZED_TASK_OUTPUT
|
|
1966
1889
|
},
|
|
1967
1890
|
body: JSON.stringify(task)
|
|
1968
1891
|
});
|
|
@@ -1974,7 +1897,7 @@ var _ApiClient = class _ApiClient {
|
|
|
1974
1897
|
runId,
|
|
1975
1898
|
body
|
|
1976
1899
|
});
|
|
1977
|
-
return await zodfetch(
|
|
1900
|
+
return await zodfetch(core.ServerTaskSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/tasks/${id}/fail`, {
|
|
1978
1901
|
method: "POST",
|
|
1979
1902
|
headers: {
|
|
1980
1903
|
"Content-Type": "application/json",
|
|
@@ -1988,7 +1911,7 @@ var _ApiClient = class _ApiClient {
|
|
|
1988
1911
|
__privateGet(this, _logger).debug("Sending event", {
|
|
1989
1912
|
event
|
|
1990
1913
|
});
|
|
1991
|
-
return await zodfetch(
|
|
1914
|
+
return await zodfetch(core.ApiEventLogSchema, `${__privateGet(this, _apiUrl)}/api/v1/events`, {
|
|
1992
1915
|
method: "POST",
|
|
1993
1916
|
headers: {
|
|
1994
1917
|
"Content-Type": "application/json",
|
|
@@ -2005,7 +1928,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2005
1928
|
__privateGet(this, _logger).debug("Sending multiple events", {
|
|
2006
1929
|
events
|
|
2007
1930
|
});
|
|
2008
|
-
return await zodfetch(
|
|
1931
|
+
return await zodfetch(core.ApiEventLogSchema.array(), `${__privateGet(this, _apiUrl)}/api/v1/events/bulk`, {
|
|
2009
1932
|
method: "POST",
|
|
2010
1933
|
headers: {
|
|
2011
1934
|
"Content-Type": "application/json",
|
|
@@ -2022,7 +1945,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2022
1945
|
__privateGet(this, _logger).debug("Cancelling event", {
|
|
2023
1946
|
eventId
|
|
2024
1947
|
});
|
|
2025
|
-
return await zodfetch(
|
|
1948
|
+
return await zodfetch(core.ApiEventLogSchema, `${__privateGet(this, _apiUrl)}/api/v1/events/${eventId}/cancel`, {
|
|
2026
1949
|
method: "POST",
|
|
2027
1950
|
headers: {
|
|
2028
1951
|
"Content-Type": "application/json",
|
|
@@ -2035,7 +1958,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2035
1958
|
__privateGet(this, _logger).debug("Cancelling runs for event", {
|
|
2036
1959
|
eventId
|
|
2037
1960
|
});
|
|
2038
|
-
return await zodfetch(
|
|
1961
|
+
return await zodfetch(core.CancelRunsForEventSchema, `${__privateGet(this, _apiUrl)}/api/v1/events/${eventId}/cancel-runs`, {
|
|
2039
1962
|
method: "POST",
|
|
2040
1963
|
headers: {
|
|
2041
1964
|
"Content-Type": "application/json",
|
|
@@ -2049,7 +1972,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2049
1972
|
id,
|
|
2050
1973
|
status
|
|
2051
1974
|
});
|
|
2052
|
-
return await zodfetch(
|
|
1975
|
+
return await zodfetch(core.JobRunStatusRecordSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/statuses/${id}`, {
|
|
2053
1976
|
method: "PUT",
|
|
2054
1977
|
headers: {
|
|
2055
1978
|
"Content-Type": "application/json",
|
|
@@ -2063,7 +1986,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2063
1986
|
__privateGet(this, _logger).debug("activating http source", {
|
|
2064
1987
|
source
|
|
2065
1988
|
});
|
|
2066
|
-
const response = await zodfetch(
|
|
1989
|
+
const response = await zodfetch(core.TriggerSourceSchema, `${__privateGet(this, _apiUrl)}/api/v2/${client}/sources/${key}`, {
|
|
2067
1990
|
method: "PUT",
|
|
2068
1991
|
headers: {
|
|
2069
1992
|
"Content-Type": "application/json",
|
|
@@ -2078,7 +2001,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2078
2001
|
__privateGet(this, _logger).debug("activating webhook", {
|
|
2079
2002
|
webhookData
|
|
2080
2003
|
});
|
|
2081
|
-
const response = await zodfetch(
|
|
2004
|
+
const response = await zodfetch(core.TriggerSourceSchema, `${__privateGet(this, _apiUrl)}/api/v1/webhooks/${key}`, {
|
|
2082
2005
|
method: "PUT",
|
|
2083
2006
|
headers: {
|
|
2084
2007
|
"Content-Type": "application/json",
|
|
@@ -2101,7 +2024,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2101
2024
|
if (idempotencyKey) {
|
|
2102
2025
|
headers["Idempotency-Key"] = idempotencyKey;
|
|
2103
2026
|
}
|
|
2104
|
-
const response = await zodfetch(
|
|
2027
|
+
const response = await zodfetch(core.RegisterSourceEventSchemaV2, `${__privateGet(this, _apiUrl)}/api/v2/${client}/triggers/${id}/registrations/${key}`, {
|
|
2105
2028
|
method: "PUT",
|
|
2106
2029
|
headers,
|
|
2107
2030
|
body: JSON.stringify(payload)
|
|
@@ -2114,7 +2037,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2114
2037
|
id,
|
|
2115
2038
|
payload
|
|
2116
2039
|
});
|
|
2117
|
-
const response = await zodfetch(
|
|
2040
|
+
const response = await zodfetch(core.RegisterScheduleResponseBodySchema, `${__privateGet(this, _apiUrl)}/api/v1/${client}/schedules/${id}/registrations`, {
|
|
2118
2041
|
method: "POST",
|
|
2119
2042
|
headers: {
|
|
2120
2043
|
"Content-Type": "application/json",
|
|
@@ -2132,8 +2055,8 @@ var _ApiClient = class _ApiClient {
|
|
|
2132
2055
|
__privateGet(this, _logger).debug("unregistering schedule", {
|
|
2133
2056
|
id
|
|
2134
2057
|
});
|
|
2135
|
-
const response = await zodfetch(
|
|
2136
|
-
ok:
|
|
2058
|
+
const response = await zodfetch(zod.z.object({
|
|
2059
|
+
ok: zod.z.boolean()
|
|
2137
2060
|
}), `${__privateGet(this, _apiUrl)}/api/v1/${client}/schedules/${id}/registrations/${encodeURIComponent(key)}`, {
|
|
2138
2061
|
method: "DELETE",
|
|
2139
2062
|
headers: {
|
|
@@ -2148,7 +2071,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2148
2071
|
__privateGet(this, _logger).debug("getting auth", {
|
|
2149
2072
|
id
|
|
2150
2073
|
});
|
|
2151
|
-
const response = await zodfetch(
|
|
2074
|
+
const response = await zodfetch(core.ConnectionAuthSchema, `${__privateGet(this, _apiUrl)}/api/v1/${client}/auth/${id}`, {
|
|
2152
2075
|
method: "GET",
|
|
2153
2076
|
headers: {
|
|
2154
2077
|
Accept: "application/json",
|
|
@@ -2164,7 +2087,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2164
2087
|
__privateGet(this, _logger).debug("Getting Event", {
|
|
2165
2088
|
eventId
|
|
2166
2089
|
});
|
|
2167
|
-
return await zodfetch(
|
|
2090
|
+
return await zodfetch(core.GetEventSchema, `${__privateGet(this, _apiUrl)}/api/v1/events/${eventId}`, {
|
|
2168
2091
|
method: "GET",
|
|
2169
2092
|
headers: {
|
|
2170
2093
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2176,7 +2099,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2176
2099
|
__privateGet(this, _logger).debug("Getting Run", {
|
|
2177
2100
|
runId
|
|
2178
2101
|
});
|
|
2179
|
-
return await zodfetch(
|
|
2102
|
+
return await zodfetch(core.GetRunSchema, core.urlWithSearchParams(`${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}`, options), {
|
|
2180
2103
|
method: "GET",
|
|
2181
2104
|
headers: {
|
|
2182
2105
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2188,7 +2111,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2188
2111
|
__privateGet(this, _logger).debug("Cancelling Run", {
|
|
2189
2112
|
runId
|
|
2190
2113
|
});
|
|
2191
|
-
return await zodfetch(
|
|
2114
|
+
return await zodfetch(core.GetRunSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/cancel`, {
|
|
2192
2115
|
method: "POST",
|
|
2193
2116
|
headers: {
|
|
2194
2117
|
"Content-Type": "application/json",
|
|
@@ -2201,7 +2124,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2201
2124
|
__privateGet(this, _logger).debug("Getting Run statuses", {
|
|
2202
2125
|
runId
|
|
2203
2126
|
});
|
|
2204
|
-
return await zodfetch(
|
|
2127
|
+
return await zodfetch(core.GetRunStatusesSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/statuses`, {
|
|
2205
2128
|
method: "GET",
|
|
2206
2129
|
headers: {
|
|
2207
2130
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2213,7 +2136,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2213
2136
|
__privateGet(this, _logger).debug("Getting Runs", {
|
|
2214
2137
|
jobSlug
|
|
2215
2138
|
});
|
|
2216
|
-
return await zodfetch(
|
|
2139
|
+
return await zodfetch(core.GetRunsSchema, core.urlWithSearchParams(`${__privateGet(this, _apiUrl)}/api/v1/jobs/${jobSlug}/runs`, options), {
|
|
2217
2140
|
method: "GET",
|
|
2218
2141
|
headers: {
|
|
2219
2142
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2233,7 +2156,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2233
2156
|
callbackUrl: options.callbackUrl
|
|
2234
2157
|
}
|
|
2235
2158
|
};
|
|
2236
|
-
return await zodfetch(
|
|
2159
|
+
return await zodfetch(core.InvokeJobResponseSchema, `${__privateGet(this, _apiUrl)}/api/v1/jobs/${jobId}/invoke`, {
|
|
2237
2160
|
method: "POST",
|
|
2238
2161
|
headers: {
|
|
2239
2162
|
"Content-Type": "application/json",
|
|
@@ -2250,7 +2173,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2250
2173
|
__privateGet(this, _logger).debug("Creating ephemeral event dispatcher", {
|
|
2251
2174
|
payload
|
|
2252
2175
|
});
|
|
2253
|
-
const response = await zodfetch(
|
|
2176
|
+
const response = await zodfetch(core.EphemeralEventDispatcherResponseBodySchema, `${__privateGet(this, _apiUrl)}/api/v1/event-dispatchers/ephemeral`, {
|
|
2254
2177
|
method: "POST",
|
|
2255
2178
|
headers: {
|
|
2256
2179
|
"Content-Type": "application/json",
|
|
@@ -2322,10 +2245,10 @@ queryKeyValueStore_fn = /* @__PURE__ */ __name(async function(action, data) {
|
|
|
2322
2245
|
break;
|
|
2323
2246
|
}
|
|
2324
2247
|
default: {
|
|
2325
|
-
|
|
2248
|
+
core.assertExhaustive(action);
|
|
2326
2249
|
}
|
|
2327
2250
|
}
|
|
2328
|
-
const response = await zodfetch(
|
|
2251
|
+
const response = await zodfetch(core.KeyValueStoreResponseBodySchema, STORE_URL, requestInit);
|
|
2329
2252
|
return response;
|
|
2330
2253
|
}, "#queryKeyValueStore");
|
|
2331
2254
|
_apiKey = new WeakSet();
|
|
@@ -2341,7 +2264,7 @@ apiKey_fn = /* @__PURE__ */ __name(async function() {
|
|
|
2341
2264
|
__name(_ApiClient, "ApiClient");
|
|
2342
2265
|
var ApiClient = _ApiClient;
|
|
2343
2266
|
function getApiKey(key) {
|
|
2344
|
-
const apiKey = key ??
|
|
2267
|
+
const apiKey = key ?? node_process.env.TRIGGER_API_KEY;
|
|
2345
2268
|
if (!apiKey) {
|
|
2346
2269
|
return {
|
|
2347
2270
|
status: "missing"
|
|
@@ -2450,9 +2373,6 @@ function exponentialBackoff(retryCount, exponential, minDelay, maxDelay, jitter)
|
|
|
2450
2373
|
}
|
|
2451
2374
|
__name(exponentialBackoff, "exponentialBackoff");
|
|
2452
2375
|
|
|
2453
|
-
// src/httpEndpoint.ts
|
|
2454
|
-
var import_core4 = require("@trigger.dev/core");
|
|
2455
|
-
|
|
2456
2376
|
// src/utils/formatSchemaErrors.ts
|
|
2457
2377
|
function formatSchemaErrors(errors) {
|
|
2458
2378
|
return errors.map((error) => {
|
|
@@ -2573,7 +2493,7 @@ function httpEndpoint(options) {
|
|
|
2573
2493
|
}
|
|
2574
2494
|
],
|
|
2575
2495
|
parsePayload: (rawPayload) => {
|
|
2576
|
-
const result =
|
|
2496
|
+
const result = core.RequestWithRawBodySchema.safeParse(rawPayload);
|
|
2577
2497
|
if (!result.success) {
|
|
2578
2498
|
throw new ParsedPayloadSchemaError(formatSchemaErrors(result.error.issues));
|
|
2579
2499
|
}
|
|
@@ -2616,9 +2536,6 @@ function createIOWithIntegrations(io, auths, integrations) {
|
|
|
2616
2536
|
});
|
|
2617
2537
|
}
|
|
2618
2538
|
__name(createIOWithIntegrations, "createIOWithIntegrations");
|
|
2619
|
-
|
|
2620
|
-
// src/triggers/dynamic.ts
|
|
2621
|
-
var import_core5 = require("@trigger.dev/core");
|
|
2622
2539
|
var _client, _options2;
|
|
2623
2540
|
var _DynamicTrigger = class _DynamicTrigger {
|
|
2624
2541
|
/** `DynamicTrigger` allows you to define a trigger that can be configured dynamically at runtime.
|
|
@@ -2652,7 +2569,7 @@ var _DynamicTrigger = class _DynamicTrigger {
|
|
|
2652
2569
|
rule: {
|
|
2653
2570
|
event: this.event.name,
|
|
2654
2571
|
source: this.event.source,
|
|
2655
|
-
payload:
|
|
2572
|
+
payload: core.deepMergeFilters(this.source.filter(params), this.event.filter ?? {}, options.filter ?? {})
|
|
2656
2573
|
},
|
|
2657
2574
|
source: {
|
|
2658
2575
|
version: "2",
|
|
@@ -2724,9 +2641,6 @@ _client = new WeakMap();
|
|
|
2724
2641
|
_options2 = new WeakMap();
|
|
2725
2642
|
__name(_DynamicTrigger, "DynamicTrigger");
|
|
2726
2643
|
var DynamicTrigger = _DynamicTrigger;
|
|
2727
|
-
|
|
2728
|
-
// src/triggers/eventTrigger.ts
|
|
2729
|
-
var import_core6 = require("@trigger.dev/core");
|
|
2730
2644
|
var _options3;
|
|
2731
2645
|
var _EventTrigger = class _EventTrigger {
|
|
2732
2646
|
constructor(options) {
|
|
@@ -2740,7 +2654,7 @@ var _EventTrigger = class _EventTrigger {
|
|
|
2740
2654
|
rule: {
|
|
2741
2655
|
event: __privateGet(this, _options3).name ?? __privateGet(this, _options3).event.name,
|
|
2742
2656
|
source: __privateGet(this, _options3).source ?? "trigger.dev",
|
|
2743
|
-
payload:
|
|
2657
|
+
payload: core.deepMergeFilters(__privateGet(this, _options3).filter ?? {}, __privateGet(this, _options3).event.filter ?? {})
|
|
2744
2658
|
}
|
|
2745
2659
|
};
|
|
2746
2660
|
}
|
|
@@ -2791,18 +2705,14 @@ function eventTrigger(options) {
|
|
|
2791
2705
|
});
|
|
2792
2706
|
}
|
|
2793
2707
|
__name(eventTrigger, "eventTrigger");
|
|
2794
|
-
|
|
2795
|
-
// src/triggers/scheduled.ts
|
|
2796
|
-
var import_core7 = require("@trigger.dev/core");
|
|
2797
|
-
var import_cronstrue = __toESM(require("cronstrue"));
|
|
2798
2708
|
var examples = [
|
|
2799
2709
|
{
|
|
2800
2710
|
id: "now",
|
|
2801
2711
|
name: "Now",
|
|
2802
2712
|
icon: "clock",
|
|
2803
2713
|
payload: {
|
|
2804
|
-
ts:
|
|
2805
|
-
lastTimestamp:
|
|
2714
|
+
ts: core.currentDate.marker,
|
|
2715
|
+
lastTimestamp: core.currentDate.marker
|
|
2806
2716
|
}
|
|
2807
2717
|
}
|
|
2808
2718
|
];
|
|
@@ -2817,7 +2727,7 @@ var _IntervalTrigger = class _IntervalTrigger {
|
|
|
2817
2727
|
source: "trigger.dev",
|
|
2818
2728
|
icon: "schedule-interval",
|
|
2819
2729
|
examples,
|
|
2820
|
-
parsePayload:
|
|
2730
|
+
parsePayload: core.ScheduledPayloadSchema.parse,
|
|
2821
2731
|
properties: [
|
|
2822
2732
|
{
|
|
2823
2733
|
label: "Interval",
|
|
@@ -2859,7 +2769,7 @@ var _CronTrigger = class _CronTrigger {
|
|
|
2859
2769
|
this.options = options;
|
|
2860
2770
|
}
|
|
2861
2771
|
get event() {
|
|
2862
|
-
const humanReadable =
|
|
2772
|
+
const humanReadable = cronstrue__default.default.toString(this.options.cron, {
|
|
2863
2773
|
throwExceptionOnParseError: false
|
|
2864
2774
|
});
|
|
2865
2775
|
return {
|
|
@@ -2868,7 +2778,7 @@ var _CronTrigger = class _CronTrigger {
|
|
|
2868
2778
|
source: "trigger.dev",
|
|
2869
2779
|
icon: "schedule-cron",
|
|
2870
2780
|
examples,
|
|
2871
|
-
parsePayload:
|
|
2781
|
+
parsePayload: core.ScheduledPayloadSchema.parse,
|
|
2872
2782
|
properties: [
|
|
2873
2783
|
{
|
|
2874
2784
|
label: "cron",
|
|
@@ -2929,7 +2839,7 @@ var _DynamicSchedule = class _DynamicSchedule {
|
|
|
2929
2839
|
source: "trigger.dev",
|
|
2930
2840
|
icon: "schedule-dynamic",
|
|
2931
2841
|
examples,
|
|
2932
|
-
parsePayload:
|
|
2842
|
+
parsePayload: core.ScheduledPayloadSchema.parse
|
|
2933
2843
|
};
|
|
2934
2844
|
}
|
|
2935
2845
|
async register(key, metadata) {
|
|
@@ -3006,11 +2916,8 @@ var _DynamicSchedule = class _DynamicSchedule {
|
|
|
3006
2916
|
__name(_DynamicSchedule, "DynamicSchedule");
|
|
3007
2917
|
var DynamicSchedule = _DynamicSchedule;
|
|
3008
2918
|
|
|
3009
|
-
// src/triggerClient.ts
|
|
3010
|
-
var import_node_events = __toESM(require("node:events"));
|
|
3011
|
-
|
|
3012
2919
|
// package.json
|
|
3013
|
-
var version = "0.0.0-cross-runtime-
|
|
2920
|
+
var version = "0.0.0-cross-runtime-20231204115010";
|
|
3014
2921
|
|
|
3015
2922
|
// src/concurrencyLimit.ts
|
|
3016
2923
|
var _ConcurrencyLimit = class _ConcurrencyLimit {
|
|
@@ -3029,18 +2936,18 @@ var ConcurrencyLimit = _ConcurrencyLimit;
|
|
|
3029
2936
|
|
|
3030
2937
|
// src/triggerClient.ts
|
|
3031
2938
|
var registerWebhookEvent = /* @__PURE__ */ __name((key) => ({
|
|
3032
|
-
name: `${
|
|
2939
|
+
name: `${core.REGISTER_WEBHOOK}.${key}`,
|
|
3033
2940
|
title: "Register Webhook",
|
|
3034
2941
|
source: "internal",
|
|
3035
2942
|
icon: "webhook",
|
|
3036
|
-
parsePayload:
|
|
2943
|
+
parsePayload: core.RegisterWebhookPayloadSchema.parse
|
|
3037
2944
|
}), "registerWebhookEvent");
|
|
3038
2945
|
var registerSourceEvent = {
|
|
3039
|
-
name:
|
|
2946
|
+
name: core.REGISTER_SOURCE_EVENT_V2,
|
|
3040
2947
|
title: "Register Source",
|
|
3041
2948
|
source: "internal",
|
|
3042
2949
|
icon: "register-source",
|
|
3043
|
-
parsePayload:
|
|
2950
|
+
parsePayload: core.RegisterSourceEventSchemaV2.parse
|
|
3044
2951
|
};
|
|
3045
2952
|
var _options4, _registeredJobs, _registeredSources, _registeredWebhooks, _registeredHttpSourceHandlers, _registeredWebhookSourceHandlers, _registeredDynamicTriggers, _jobMetadataByDynamicTriggers, _registeredSchedules, _registeredHttpEndpoints, _authResolvers, _envStore, _eventEmitter, _client2, _internalLogger, _preprocessRun, preprocessRun_fn, _executeJob, executeJob_fn, _convertErrorToExecutionResponse, convertErrorToExecutionResponse_fn, _createRunContext, createRunContext_fn, _createPreprocessRunContext, createPreprocessRunContext_fn, _handleHttpSourceRequest, handleHttpSourceRequest_fn, _handleHttpEndpointRequestForResponse, handleHttpEndpointRequestForResponse_fn, _handleWebhookRequest, handleWebhookRequest_fn, _resolveConnections, resolveConnections_fn, _resolveConnection, resolveConnection_fn, _buildJobsIndex, buildJobsIndex_fn, _buildJobIndex, buildJobIndex_fn, _buildJobIntegrations, buildJobIntegrations_fn, _buildJobIntegration, buildJobIntegration_fn, _logIOStats, logIOStats_fn, _standardResponseHeaders, standardResponseHeaders_fn, _serializeRunMetadata, serializeRunMetadata_fn, _deliverSuccessfulRunNotification, deliverSuccessfulRunNotification_fn, _deliverFailedRunNotification, deliverFailedRunNotification_fn;
|
|
3046
2953
|
var _TriggerClient = class _TriggerClient {
|
|
@@ -3076,14 +2983,14 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3076
2983
|
__privateAdd(this, _registeredHttpEndpoints, {});
|
|
3077
2984
|
__privateAdd(this, _authResolvers, {});
|
|
3078
2985
|
__privateAdd(this, _envStore, void 0);
|
|
3079
|
-
__privateAdd(this, _eventEmitter, new
|
|
2986
|
+
__privateAdd(this, _eventEmitter, new EventEmitter__default.default());
|
|
3080
2987
|
__privateAdd(this, _client2, void 0);
|
|
3081
2988
|
__privateAdd(this, _internalLogger, void 0);
|
|
3082
2989
|
__publicField(this, "on", __privateGet(this, _eventEmitter).on.bind(__privateGet(this, _eventEmitter)));
|
|
3083
2990
|
this.id = options.id;
|
|
3084
2991
|
__privateSet(this, _options4, options);
|
|
3085
2992
|
__privateSet(this, _client2, new ApiClient(__privateGet(this, _options4)));
|
|
3086
|
-
__privateSet(this, _internalLogger, new
|
|
2993
|
+
__privateSet(this, _internalLogger, new core.Logger("trigger.dev", __privateGet(this, _options4).verbose ? "debug" : "log", [
|
|
3087
2994
|
"output",
|
|
3088
2995
|
"noopTasksSet"
|
|
3089
2996
|
]));
|
|
@@ -3207,7 +3114,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3207
3114
|
}
|
|
3208
3115
|
case "INITIALIZE_TRIGGER": {
|
|
3209
3116
|
const json = await request.json();
|
|
3210
|
-
const body =
|
|
3117
|
+
const body = core.InitializeTriggerBodySchema.safeParse(json);
|
|
3211
3118
|
if (!body.success) {
|
|
3212
3119
|
return {
|
|
3213
3120
|
status: 400,
|
|
@@ -3233,7 +3140,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3233
3140
|
}
|
|
3234
3141
|
case "EXECUTE_JOB": {
|
|
3235
3142
|
const json = await request.json();
|
|
3236
|
-
const execution =
|
|
3143
|
+
const execution = core.RunJobBodySchema.safeParse(json);
|
|
3237
3144
|
if (!execution.success) {
|
|
3238
3145
|
return {
|
|
3239
3146
|
status: 400,
|
|
@@ -3268,7 +3175,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3268
3175
|
}
|
|
3269
3176
|
case "PREPROCESS_RUN": {
|
|
3270
3177
|
const json = await request.json();
|
|
3271
|
-
const body =
|
|
3178
|
+
const body = core.PreprocessRunBodySchema.safeParse(json);
|
|
3272
3179
|
if (!body.success) {
|
|
3273
3180
|
return {
|
|
3274
3181
|
status: 400,
|
|
@@ -3297,7 +3204,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3297
3204
|
};
|
|
3298
3205
|
}
|
|
3299
3206
|
case "DELIVER_HTTP_SOURCE_REQUEST": {
|
|
3300
|
-
const headers =
|
|
3207
|
+
const headers = core.HttpSourceRequestHeadersSchema.safeParse(Object.fromEntries(request.headers.entries()));
|
|
3301
3208
|
if (!headers.success) {
|
|
3302
3209
|
return {
|
|
3303
3210
|
status: 400,
|
|
@@ -3347,7 +3254,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3347
3254
|
};
|
|
3348
3255
|
}
|
|
3349
3256
|
case "DELIVER_HTTP_ENDPOINT_REQUEST_FOR_RESPONSE": {
|
|
3350
|
-
const headers =
|
|
3257
|
+
const headers = core.HttpEndpointRequestHeadersSchema.safeParse(Object.fromEntries(request.headers.entries()));
|
|
3351
3258
|
if (!headers.success) {
|
|
3352
3259
|
return {
|
|
3353
3260
|
status: 400,
|
|
@@ -3380,7 +3287,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3380
3287
|
};
|
|
3381
3288
|
}
|
|
3382
3289
|
case "DELIVER_WEBHOOK_REQUEST": {
|
|
3383
|
-
const headers =
|
|
3290
|
+
const headers = core.WebhookSourceRequestHeadersSchema.safeParse(Object.fromEntries(request.headers.entries()));
|
|
3384
3291
|
if (!headers.success) {
|
|
3385
3292
|
return {
|
|
3386
3293
|
status: 400,
|
|
@@ -3773,14 +3680,14 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3773
3680
|
if (typeof apiKey !== "string") {
|
|
3774
3681
|
return "missing-header";
|
|
3775
3682
|
}
|
|
3776
|
-
const localApiKey = __privateGet(this, _options4).apiKey ??
|
|
3683
|
+
const localApiKey = __privateGet(this, _options4).apiKey ?? node_process.env.TRIGGER_API_KEY;
|
|
3777
3684
|
if (!localApiKey) {
|
|
3778
3685
|
return "missing-client";
|
|
3779
3686
|
}
|
|
3780
3687
|
return apiKey === localApiKey ? "authorized" : "unauthorized";
|
|
3781
3688
|
}
|
|
3782
3689
|
apiKey() {
|
|
3783
|
-
return __privateGet(this, _options4).apiKey ??
|
|
3690
|
+
return __privateGet(this, _options4).apiKey ?? node_process.env.TRIGGER_API_KEY;
|
|
3784
3691
|
}
|
|
3785
3692
|
};
|
|
3786
3693
|
_options4 = new WeakMap();
|
|
@@ -3800,7 +3707,7 @@ _client2 = new WeakMap();
|
|
|
3800
3707
|
_internalLogger = new WeakMap();
|
|
3801
3708
|
_preprocessRun = new WeakSet();
|
|
3802
3709
|
preprocessRun_fn = /* @__PURE__ */ __name(async function(body, job) {
|
|
3803
|
-
|
|
3710
|
+
__privateMethod(this, _createPreprocessRunContext, createPreprocessRunContext_fn).call(this, body);
|
|
3804
3711
|
const parsedPayload = job.trigger.event.parsePayload(body.event.payload ?? {});
|
|
3805
3712
|
const properties = job.trigger.event.runProperties?.(parsedPayload) ?? [];
|
|
3806
3713
|
return {
|
|
@@ -3829,7 +3736,7 @@ executeJob_fn = /* @__PURE__ */ __name(async function(body1, job1, timeOrigin, t
|
|
|
3829
3736
|
client: this,
|
|
3830
3737
|
context,
|
|
3831
3738
|
jobLogLevel: job1.logLevel ?? __privateGet(this, _options4).logLevel ?? "info",
|
|
3832
|
-
jobLogger: __privateGet(this, _options4).ioLogLocalEnabled ? new
|
|
3739
|
+
jobLogger: __privateGet(this, _options4).ioLogLocalEnabled ? new core.Logger(job1.id, job1.logLevel ?? __privateGet(this, _options4).logLevel ?? "info") : void 0,
|
|
3833
3740
|
serverVersion: triggerVersion,
|
|
3834
3741
|
timeOrigin,
|
|
3835
3742
|
executionTimeout: body1.runChunkExecutionLimit
|
|
@@ -3940,7 +3847,7 @@ convertErrorToExecutionResponse_fn = /* @__PURE__ */ __name(function(error, body
|
|
|
3940
3847
|
};
|
|
3941
3848
|
}
|
|
3942
3849
|
if (error instanceof ErrorWithTask) {
|
|
3943
|
-
const errorWithStack2 =
|
|
3850
|
+
const errorWithStack2 = core.ErrorWithStackSchema.safeParse(error.cause.output);
|
|
3944
3851
|
if (errorWithStack2.success) {
|
|
3945
3852
|
return {
|
|
3946
3853
|
status: "ERROR",
|
|
@@ -3957,7 +3864,7 @@ convertErrorToExecutionResponse_fn = /* @__PURE__ */ __name(function(error, body
|
|
|
3957
3864
|
};
|
|
3958
3865
|
}
|
|
3959
3866
|
if (error instanceof RetryWithTaskError) {
|
|
3960
|
-
const errorWithStack2 =
|
|
3867
|
+
const errorWithStack2 = core.ErrorWithStackSchema.safeParse(error.cause);
|
|
3961
3868
|
if (errorWithStack2.success) {
|
|
3962
3869
|
return {
|
|
3963
3870
|
status: "ERROR",
|
|
@@ -3973,7 +3880,7 @@ convertErrorToExecutionResponse_fn = /* @__PURE__ */ __name(function(error, body
|
|
|
3973
3880
|
task: error.task
|
|
3974
3881
|
};
|
|
3975
3882
|
}
|
|
3976
|
-
const errorWithStack =
|
|
3883
|
+
const errorWithStack = core.ErrorWithStackSchema.safeParse(error);
|
|
3977
3884
|
if (errorWithStack.success) {
|
|
3978
3885
|
return {
|
|
3979
3886
|
status: "ERROR",
|
|
@@ -4361,7 +4268,7 @@ logIOStats_fn = /* @__PURE__ */ __name(function(stats) {
|
|
|
4361
4268
|
_standardResponseHeaders = new WeakSet();
|
|
4362
4269
|
standardResponseHeaders_fn = /* @__PURE__ */ __name(function(start) {
|
|
4363
4270
|
return {
|
|
4364
|
-
"Trigger-Version":
|
|
4271
|
+
"Trigger-Version": core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS,
|
|
4365
4272
|
"Trigger-SDK-Version": version,
|
|
4366
4273
|
"X-Trigger-Request-Timing": `dur=${performance.now() - start / 1e3}`
|
|
4367
4274
|
};
|
|
@@ -4430,9 +4337,6 @@ function deepMergeOptions(obj1, obj2) {
|
|
|
4430
4337
|
return mergedOptions;
|
|
4431
4338
|
}
|
|
4432
4339
|
__name(deepMergeOptions, "deepMergeOptions");
|
|
4433
|
-
|
|
4434
|
-
// src/triggers/externalSource.ts
|
|
4435
|
-
var import_core9 = require("@trigger.dev/core");
|
|
4436
4340
|
var _ExternalSource = class _ExternalSource {
|
|
4437
4341
|
constructor(channel, options) {
|
|
4438
4342
|
this.options = options;
|
|
@@ -4507,7 +4411,7 @@ var _ExternalSourceTrigger = class _ExternalSourceTrigger {
|
|
|
4507
4411
|
title: "External Source",
|
|
4508
4412
|
rule: {
|
|
4509
4413
|
event: this.event.name,
|
|
4510
|
-
payload:
|
|
4414
|
+
payload: core.deepMergeFilters(this.options.source.filter(this.options.params, this.options.options), this.event.filter ?? {}, this.options.params.filter ?? {}),
|
|
4511
4415
|
source: this.event.source
|
|
4512
4416
|
},
|
|
4513
4417
|
properties: this.options.source.properties(this.options.params)
|
|
@@ -4546,9 +4450,6 @@ function omit(obj, key) {
|
|
|
4546
4450
|
};
|
|
4547
4451
|
}
|
|
4548
4452
|
__name(omit, "omit");
|
|
4549
|
-
|
|
4550
|
-
// src/triggers/notifications.ts
|
|
4551
|
-
var import_core10 = require("@trigger.dev/core");
|
|
4552
4453
|
function missingConnectionNotification(integrations) {
|
|
4553
4454
|
return new MissingConnectionNotification({
|
|
4554
4455
|
integrations
|
|
@@ -4567,11 +4468,11 @@ var _MissingConnectionNotification = class _MissingConnectionNotification {
|
|
|
4567
4468
|
}
|
|
4568
4469
|
get event() {
|
|
4569
4470
|
return {
|
|
4570
|
-
name:
|
|
4471
|
+
name: core.MISSING_CONNECTION_NOTIFICATION,
|
|
4571
4472
|
title: "Missing Connection Notification",
|
|
4572
4473
|
source: "trigger.dev",
|
|
4573
4474
|
icon: "connection-alert",
|
|
4574
|
-
parsePayload:
|
|
4475
|
+
parsePayload: core.MissingConnectionNotificationPayloadSchema.parse,
|
|
4575
4476
|
properties: [
|
|
4576
4477
|
{
|
|
4577
4478
|
label: "Integrations",
|
|
@@ -4614,11 +4515,11 @@ var _MissingConnectionResolvedNotification = class _MissingConnectionResolvedNot
|
|
|
4614
4515
|
}
|
|
4615
4516
|
get event() {
|
|
4616
4517
|
return {
|
|
4617
|
-
name:
|
|
4518
|
+
name: core.MISSING_CONNECTION_RESOLVED_NOTIFICATION,
|
|
4618
4519
|
title: "Missing Connection Resolved Notification",
|
|
4619
4520
|
source: "trigger.dev",
|
|
4620
4521
|
icon: "connection-alert",
|
|
4621
|
-
parsePayload:
|
|
4522
|
+
parsePayload: core.MissingConnectionResolvedNotificationPayloadSchema.parse,
|
|
4622
4523
|
properties: [
|
|
4623
4524
|
{
|
|
4624
4525
|
label: "Integrations",
|
|
@@ -4715,10 +4616,6 @@ function invokeTrigger(options) {
|
|
|
4715
4616
|
return new InvokeTrigger(options ?? {});
|
|
4716
4617
|
}
|
|
4717
4618
|
__name(invokeTrigger, "invokeTrigger");
|
|
4718
|
-
|
|
4719
|
-
// src/triggers/webhook.ts
|
|
4720
|
-
var import_core11 = require("@trigger.dev/core");
|
|
4721
|
-
var import_node_crypto2 = require("node:crypto");
|
|
4722
4619
|
var _shortHash, shortHash_fn;
|
|
4723
4620
|
var _WebhookSource = class _WebhookSource {
|
|
4724
4621
|
constructor(options) {
|
|
@@ -4790,7 +4687,7 @@ var _WebhookSource = class _WebhookSource {
|
|
|
4790
4687
|
};
|
|
4791
4688
|
_shortHash = new WeakSet();
|
|
4792
4689
|
shortHash_fn = /* @__PURE__ */ __name(function(str) {
|
|
4793
|
-
const hash =
|
|
4690
|
+
const hash = crypto.createHash("sha1").update(str).digest("hex");
|
|
4794
4691
|
return hash.slice(0, 7);
|
|
4795
4692
|
}, "#shortHash");
|
|
4796
4693
|
__name(_WebhookSource, "WebhookSource");
|
|
@@ -4814,7 +4711,7 @@ var _WebhookTrigger = class _WebhookTrigger {
|
|
|
4814
4711
|
title: "Webhook",
|
|
4815
4712
|
rule: {
|
|
4816
4713
|
event: this.event.name,
|
|
4817
|
-
payload:
|
|
4714
|
+
payload: core.deepMergeFilters(this.options.source.filter(this.options.params, this.options.config), this.event.filter ?? {}),
|
|
4818
4715
|
source: this.event.source
|
|
4819
4716
|
},
|
|
4820
4717
|
properties: this.options.source.properties(this.options.params),
|
|
@@ -4828,7 +4725,7 @@ var _WebhookTrigger = class _WebhookTrigger {
|
|
|
4828
4725
|
...optionsWithoutEvent,
|
|
4829
4726
|
event: {
|
|
4830
4727
|
...eventWithoutFilter,
|
|
4831
|
-
filter:
|
|
4728
|
+
filter: core.deepMergeFilters(filter ?? {}, eventFilter)
|
|
4832
4729
|
}
|
|
4833
4730
|
});
|
|
4834
4731
|
}
|
|
@@ -4860,9 +4757,6 @@ var _WebhookTrigger = class _WebhookTrigger {
|
|
|
4860
4757
|
};
|
|
4861
4758
|
__name(_WebhookTrigger, "WebhookTrigger");
|
|
4862
4759
|
var WebhookTrigger = _WebhookTrigger;
|
|
4863
|
-
|
|
4864
|
-
// src/security.ts
|
|
4865
|
-
var import_node_crypto3 = __toESM(require("node:crypto"));
|
|
4866
4760
|
async function verifyRequestSignature({ request, headerName, headerEncoding = "hex", secret, algorithm }) {
|
|
4867
4761
|
if (!secret) {
|
|
4868
4762
|
return {
|
|
@@ -4896,7 +4790,7 @@ async function verifyRequestSignature({ request, headerName, headerEncoding = "h
|
|
|
4896
4790
|
}
|
|
4897
4791
|
__name(verifyRequestSignature, "verifyRequestSignature");
|
|
4898
4792
|
function verifyHmacSha256(headerValue, headerEncoding, secret, body) {
|
|
4899
|
-
const bodyDigest =
|
|
4793
|
+
const bodyDigest = crypto__default.default.createHmac("sha256", secret).update(body).digest(headerEncoding);
|
|
4900
4794
|
const signature = headerValue?.replace("hmac-sha256=", "").replace("sha256=", "") ?? "";
|
|
4901
4795
|
return signature === bodyDigest;
|
|
4902
4796
|
}
|
|
@@ -4911,39 +4805,38 @@ function redactString(strings, ...interpolations) {
|
|
|
4911
4805
|
};
|
|
4912
4806
|
}
|
|
4913
4807
|
__name(redactString, "redactString");
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
});
|
|
4808
|
+
|
|
4809
|
+
exports.CronTrigger = CronTrigger;
|
|
4810
|
+
exports.DynamicSchedule = DynamicSchedule;
|
|
4811
|
+
exports.DynamicTrigger = DynamicTrigger;
|
|
4812
|
+
exports.EventSpecificationExampleSchema = EventSpecificationExampleSchema;
|
|
4813
|
+
exports.EventTrigger = EventTrigger;
|
|
4814
|
+
exports.ExternalSource = ExternalSource;
|
|
4815
|
+
exports.ExternalSourceTrigger = ExternalSourceTrigger;
|
|
4816
|
+
exports.IO = IO;
|
|
4817
|
+
exports.IOLogger = IOLogger;
|
|
4818
|
+
exports.IntervalTrigger = IntervalTrigger;
|
|
4819
|
+
exports.InvokeTrigger = InvokeTrigger;
|
|
4820
|
+
exports.JSONOutputSerializer = JSONOutputSerializer;
|
|
4821
|
+
exports.Job = Job;
|
|
4822
|
+
exports.MissingConnectionNotification = MissingConnectionNotification;
|
|
4823
|
+
exports.MissingConnectionResolvedNotification = MissingConnectionResolvedNotification;
|
|
4824
|
+
exports.TriggerClient = TriggerClient;
|
|
4825
|
+
exports.WebhookSource = WebhookSource;
|
|
4826
|
+
exports.WebhookTrigger = WebhookTrigger;
|
|
4827
|
+
exports.cronTrigger = cronTrigger;
|
|
4828
|
+
exports.eventTrigger = eventTrigger;
|
|
4829
|
+
exports.intervalTrigger = intervalTrigger;
|
|
4830
|
+
exports.invokeTrigger = invokeTrigger;
|
|
4831
|
+
exports.isTriggerError = isTriggerError;
|
|
4832
|
+
exports.missingConnectionNotification = missingConnectionNotification;
|
|
4833
|
+
exports.missingConnectionResolvedNotification = missingConnectionResolvedNotification;
|
|
4834
|
+
exports.omit = omit;
|
|
4835
|
+
exports.redactString = redactString;
|
|
4836
|
+
exports.retry = retry;
|
|
4837
|
+
exports.slugifyId = slugifyId;
|
|
4838
|
+
exports.verifyHmacSha256 = verifyHmacSha256;
|
|
4839
|
+
exports.verifyRequestSignature = verifyRequestSignature;
|
|
4840
|
+
exports.waitForEventSchema = waitForEventSchema;
|
|
4841
|
+
//# sourceMappingURL=out.js.map
|
|
4949
4842
|
//# sourceMappingURL=index.js.map
|