@trigger.dev/sdk 0.0.0-prerelease-20240112134133 → 0.0.0-prerelease-20240219135254
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 +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +134 -0
- package/dist/v3/index.d.ts +134 -0
- package/dist/v3/index.js +153 -0
- package/dist/v3/index.js.map +1 -0
- package/dist/v3/index.mjs +147 -0
- package/dist/v3/index.mjs.map +1 -0
- package/package.json +21 -3
package/dist/index.js
CHANGED
|
@@ -266,7 +266,7 @@ __name(_Job, "Job");
|
|
|
266
266
|
var Job = _Job;
|
|
267
267
|
|
|
268
268
|
// package.json
|
|
269
|
-
var version = "0.0.0-prerelease-
|
|
269
|
+
var version = "0.0.0-prerelease-20240219135254";
|
|
270
270
|
|
|
271
271
|
// src/errors.ts
|
|
272
272
|
var _ResumeWithTaskError = class _ResumeWithTaskError {
|
|
@@ -643,6 +643,13 @@ var _IO = class _IO {
|
|
|
643
643
|
get logger() {
|
|
644
644
|
return new IOLogger(async (level, message, data) => {
|
|
645
645
|
let logLevel = "info";
|
|
646
|
+
if (data instanceof Error) {
|
|
647
|
+
data = {
|
|
648
|
+
name: data.name,
|
|
649
|
+
message: data.message,
|
|
650
|
+
stack: data.stack
|
|
651
|
+
};
|
|
652
|
+
}
|
|
646
653
|
if (coreBackend.Logger.satisfiesLogLevel(logLevel, this._jobLogLevel)) {
|
|
647
654
|
await this.runTask([
|
|
648
655
|
message,
|
|
@@ -1387,7 +1394,6 @@ var _IO = class _IO {
|
|
|
1387
1394
|
* @returns A Promise that resolves with the returned value of the callback.
|
|
1388
1395
|
*/
|
|
1389
1396
|
async runTask(cacheKey, callback, options, onError) {
|
|
1390
|
-
__privateMethod(this, _detectAutoYield, detectAutoYield_fn).call(this, "start_task", 500);
|
|
1391
1397
|
const parentId = this._taskStorage.getStore()?.taskId;
|
|
1392
1398
|
if (parentId) {
|
|
1393
1399
|
this._logger.debug("Using parent task", {
|
|
@@ -1396,6 +1402,10 @@ var _IO = class _IO {
|
|
|
1396
1402
|
options
|
|
1397
1403
|
});
|
|
1398
1404
|
}
|
|
1405
|
+
const isSubtaskNoop = options?.noop === true && parentId !== void 0;
|
|
1406
|
+
if (!isSubtaskNoop) {
|
|
1407
|
+
__privateMethod(this, _detectAutoYield, detectAutoYield_fn).call(this, "start_task", 500);
|
|
1408
|
+
}
|
|
1399
1409
|
const idempotencyKey = await generateIdempotencyKey([
|
|
1400
1410
|
this._id,
|
|
1401
1411
|
parentId ?? "",
|
|
@@ -1553,6 +1563,7 @@ var _IO = class _IO {
|
|
|
1553
1563
|
await this._apiClient.failTask(this._id, task.id, {
|
|
1554
1564
|
error: error.cause.output
|
|
1555
1565
|
});
|
|
1566
|
+
throw error;
|
|
1556
1567
|
}
|
|
1557
1568
|
const parsedError = core.ErrorWithStackSchema.safeParse(error);
|
|
1558
1569
|
if (options?.retry && !skipRetrying) {
|
|
@@ -2103,7 +2114,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2103
2114
|
__privateGet(this, _logger).debug("Getting Event", {
|
|
2104
2115
|
eventId
|
|
2105
2116
|
});
|
|
2106
|
-
return await zodfetch(core.GetEventSchema, `${__privateGet(this, _apiUrl)}/api/
|
|
2117
|
+
return await zodfetch(core.GetEventSchema, `${__privateGet(this, _apiUrl)}/api/v2/events/${eventId}`, {
|
|
2107
2118
|
method: "GET",
|
|
2108
2119
|
headers: {
|
|
2109
2120
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2115,7 +2126,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2115
2126
|
__privateGet(this, _logger).debug("Getting Run", {
|
|
2116
2127
|
runId
|
|
2117
2128
|
});
|
|
2118
|
-
return await zodfetch(core.GetRunSchema, core.urlWithSearchParams(`${__privateGet(this, _apiUrl)}/api/
|
|
2129
|
+
return await zodfetch(core.GetRunSchema, core.urlWithSearchParams(`${__privateGet(this, _apiUrl)}/api/v2/runs/${runId}`, options), {
|
|
2119
2130
|
method: "GET",
|
|
2120
2131
|
headers: {
|
|
2121
2132
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2140,7 +2151,7 @@ var _ApiClient = class _ApiClient {
|
|
|
2140
2151
|
__privateGet(this, _logger).debug("Getting Run statuses", {
|
|
2141
2152
|
runId
|
|
2142
2153
|
});
|
|
2143
|
-
return await zodfetch(core.GetRunStatusesSchema, `${__privateGet(this, _apiUrl)}/api/
|
|
2154
|
+
return await zodfetch(core.GetRunStatusesSchema, `${__privateGet(this, _apiUrl)}/api/v2/runs/${runId}/statuses`, {
|
|
2144
2155
|
method: "GET",
|
|
2145
2156
|
headers: {
|
|
2146
2157
|
Authorization: `Bearer ${apiKey}`
|
|
@@ -2729,6 +2740,7 @@ function eventTrigger(options) {
|
|
|
2729
2740
|
return new EventTrigger({
|
|
2730
2741
|
name: options.name,
|
|
2731
2742
|
filter: options.filter,
|
|
2743
|
+
source: options.source,
|
|
2732
2744
|
event: {
|
|
2733
2745
|
name: options.name,
|
|
2734
2746
|
title: "Event",
|
|
@@ -2815,7 +2827,7 @@ var _CronTrigger = class _CronTrigger {
|
|
|
2815
2827
|
get event() {
|
|
2816
2828
|
const humanReadable = cronstrue__default.default.toString(this.options.cron, {
|
|
2817
2829
|
throwExceptionOnParseError: false
|
|
2818
|
-
});
|
|
2830
|
+
}).concat(" (UTC)");
|
|
2819
2831
|
return {
|
|
2820
2832
|
name: "trigger.scheduled",
|
|
2821
2833
|
title: "Cron Schedule",
|
|
@@ -3403,7 +3415,7 @@ var _TriggerClient = class _TriggerClient {
|
|
|
3403
3415
|
}
|
|
3404
3416
|
defineJob(options) {
|
|
3405
3417
|
const existingRegisteredJob = __privateGet(this, _registeredJobs)[options.id];
|
|
3406
|
-
if (existingRegisteredJob) {
|
|
3418
|
+
if (existingRegisteredJob && options.__internal !== true) {
|
|
3407
3419
|
console.warn(`[@trigger.dev/sdk] Warning: The Job "${existingRegisteredJob.id}" you're attempting to define has already been defined. Please assign a different ID to the job.`);
|
|
3408
3420
|
}
|
|
3409
3421
|
const job = new Job(options);
|