@trigger.dev/sdk 0.0.0-auto-yield-20231020151736 → 0.0.0-buffer-import-20231031121649
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.ts +29 -20
- package/dist/index.js +63 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -503,6 +503,10 @@ declare class ApiClient {
|
|
|
503
503
|
deliveredAt?: Date | null | undefined;
|
|
504
504
|
cancelledAt?: Date | null | undefined;
|
|
505
505
|
}>;
|
|
506
|
+
cancelRunsForEvent(eventId: string): Promise<{
|
|
507
|
+
cancelledRunIds: string[];
|
|
508
|
+
failedToCancelRunIds: string[];
|
|
509
|
+
}>;
|
|
506
510
|
updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
|
|
507
511
|
label: string;
|
|
508
512
|
key: string;
|
|
@@ -515,7 +519,7 @@ declare class ApiClient {
|
|
|
515
519
|
state?: "loading" | "success" | "failure" | undefined;
|
|
516
520
|
}>;
|
|
517
521
|
updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
|
|
518
|
-
registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2): Promise<RegisterSourceEventV2>;
|
|
522
|
+
registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
|
|
519
523
|
registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
|
|
520
524
|
id: string;
|
|
521
525
|
schedule: {
|
|
@@ -641,6 +645,23 @@ type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversio
|
|
|
641
645
|
body: z.infer<TUnversioned>;
|
|
642
646
|
};
|
|
643
647
|
|
|
648
|
+
declare class TriggerStatus {
|
|
649
|
+
private id;
|
|
650
|
+
private io;
|
|
651
|
+
constructor(id: string, io: IO);
|
|
652
|
+
update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
|
|
653
|
+
label: string;
|
|
654
|
+
key: string;
|
|
655
|
+
history: {
|
|
656
|
+
label?: string | undefined;
|
|
657
|
+
state?: "loading" | "success" | "failure" | undefined;
|
|
658
|
+
data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
|
|
659
|
+
}[];
|
|
660
|
+
data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
|
|
661
|
+
state?: "loading" | "success" | "failure" | undefined;
|
|
662
|
+
}>;
|
|
663
|
+
}
|
|
664
|
+
|
|
644
665
|
interface TriggerContext {
|
|
645
666
|
/** Job metadata */
|
|
646
667
|
job: {
|
|
@@ -1143,7 +1164,7 @@ declare class TriggerClient {
|
|
|
1143
1164
|
}): void;
|
|
1144
1165
|
attachDynamicSchedule(key: string): void;
|
|
1145
1166
|
attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
|
|
1146
|
-
registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2): Promise<{
|
|
1167
|
+
registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
|
|
1147
1168
|
id: string;
|
|
1148
1169
|
options: {
|
|
1149
1170
|
event: {
|
|
@@ -1213,6 +1234,10 @@ declare class TriggerClient {
|
|
|
1213
1234
|
deliveredAt?: Date | null | undefined;
|
|
1214
1235
|
cancelledAt?: Date | null | undefined;
|
|
1215
1236
|
}>;
|
|
1237
|
+
cancelRunsForEvent(eventId: string): Promise<{
|
|
1238
|
+
cancelledRunIds: string[];
|
|
1239
|
+
failedToCancelRunIds: string[];
|
|
1240
|
+
}>;
|
|
1216
1241
|
updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
|
|
1217
1242
|
label: string;
|
|
1218
1243
|
key: string;
|
|
@@ -1333,23 +1358,6 @@ declare class TriggerClient {
|
|
|
1333
1358
|
apiKey(): string | undefined;
|
|
1334
1359
|
}
|
|
1335
1360
|
|
|
1336
|
-
declare class TriggerStatus {
|
|
1337
|
-
private id;
|
|
1338
|
-
private io;
|
|
1339
|
-
constructor(id: string, io: IO);
|
|
1340
|
-
update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
|
|
1341
|
-
label: string;
|
|
1342
|
-
key: string;
|
|
1343
|
-
history: {
|
|
1344
|
-
label?: string | undefined;
|
|
1345
|
-
state?: "loading" | "success" | "failure" | undefined;
|
|
1346
|
-
data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
|
|
1347
|
-
}[];
|
|
1348
|
-
data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
|
|
1349
|
-
state?: "loading" | "success" | "failure" | undefined;
|
|
1350
|
-
}>;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
1361
|
type IOTask = ServerTask;
|
|
1354
1362
|
type IOOptions = {
|
|
1355
1363
|
id: string;
|
|
@@ -1402,7 +1410,8 @@ declare class IO {
|
|
|
1402
1410
|
private _cachedTasksCursor?;
|
|
1403
1411
|
private _context;
|
|
1404
1412
|
private _yieldedExecutions;
|
|
1405
|
-
private
|
|
1413
|
+
private _noopTasksRawData;
|
|
1414
|
+
private __noopTasksBloomFilter;
|
|
1406
1415
|
private _stats;
|
|
1407
1416
|
private _serverVersion;
|
|
1408
1417
|
private _timeOrigin;
|
package/dist/index.js
CHANGED
|
@@ -272,6 +272,19 @@ var ApiClient = class {
|
|
|
272
272
|
}
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
+
async cancelRunsForEvent(eventId) {
|
|
276
|
+
const apiKey = await __privateMethod(this, _apiKey, apiKey_fn).call(this);
|
|
277
|
+
__privateGet(this, _logger).debug("Cancelling runs for event", {
|
|
278
|
+
eventId
|
|
279
|
+
});
|
|
280
|
+
return await zodfetch(import_core.CancelRunsForEventSchema, `${__privateGet(this, _apiUrl)}/api/v1/events/${eventId}/cancel-runs`, {
|
|
281
|
+
method: "POST",
|
|
282
|
+
headers: {
|
|
283
|
+
"Content-Type": "application/json",
|
|
284
|
+
Authorization: `Bearer ${apiKey}`
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
275
288
|
async updateStatus(runId, id, status) {
|
|
276
289
|
const apiKey = await __privateMethod(this, _apiKey, apiKey_fn).call(this);
|
|
277
290
|
__privateGet(this, _logger).debug("Update status", {
|
|
@@ -302,18 +315,22 @@ var ApiClient = class {
|
|
|
302
315
|
});
|
|
303
316
|
return response;
|
|
304
317
|
}
|
|
305
|
-
async registerTrigger(client, id, key, payload) {
|
|
318
|
+
async registerTrigger(client, id, key, payload, idempotencyKey) {
|
|
306
319
|
const apiKey = await __privateMethod(this, _apiKey, apiKey_fn).call(this);
|
|
307
320
|
__privateGet(this, _logger).debug("registering trigger", {
|
|
308
321
|
id,
|
|
309
322
|
payload
|
|
310
323
|
});
|
|
324
|
+
const headers = {
|
|
325
|
+
"Content-Type": "application/json",
|
|
326
|
+
Authorization: `Bearer ${apiKey}`
|
|
327
|
+
};
|
|
328
|
+
if (idempotencyKey) {
|
|
329
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
330
|
+
}
|
|
311
331
|
const response = await zodfetch(import_core.RegisterSourceEventSchemaV2, `${__privateGet(this, _apiUrl)}/api/v2/${client}/triggers/${id}/registrations/${key}`, {
|
|
312
332
|
method: "PUT",
|
|
313
|
-
headers
|
|
314
|
-
"Content-Type": "application/json",
|
|
315
|
-
Authorization: `Bearer ${apiKey}`
|
|
316
|
-
},
|
|
333
|
+
headers,
|
|
317
334
|
body: JSON.stringify(payload)
|
|
318
335
|
});
|
|
319
336
|
return response;
|
|
@@ -619,7 +636,7 @@ var TriggerStatus = class {
|
|
|
619
636
|
__name(TriggerStatus, "TriggerStatus");
|
|
620
637
|
|
|
621
638
|
// src/io.ts
|
|
622
|
-
var _addToCachedTasks, addToCachedTasks_fn, _detectAutoYield, detectAutoYield_fn, _forceYield, forceYield_fn, _getTimeElapsed, getTimeElapsed_fn, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn;
|
|
639
|
+
var _addToCachedTasks, addToCachedTasks_fn, _detectAutoYield, detectAutoYield_fn, _forceYield, forceYield_fn, _getTimeElapsed, getTimeElapsed_fn, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn, _testNoopTaskBloomFilter, testNoopTaskBloomFilter_fn, _addNoopTaskBloomFilter, addNoopTaskBloomFilter_fn;
|
|
623
640
|
var IO = class {
|
|
624
641
|
constructor(options) {
|
|
625
642
|
__privateAdd(this, _addToCachedTasks);
|
|
@@ -627,6 +644,8 @@ var IO = class {
|
|
|
627
644
|
__privateAdd(this, _forceYield);
|
|
628
645
|
__privateAdd(this, _getTimeElapsed);
|
|
629
646
|
__privateAdd(this, _getRemainingTimeInMillis);
|
|
647
|
+
__privateAdd(this, _testNoopTaskBloomFilter);
|
|
648
|
+
__privateAdd(this, _addNoopTaskBloomFilter);
|
|
630
649
|
__publicField(this, "brb", this.yield.bind(this));
|
|
631
650
|
this._id = options.id;
|
|
632
651
|
this._apiClient = options.apiClient;
|
|
@@ -656,7 +675,7 @@ var IO = class {
|
|
|
656
675
|
this._context = options.context;
|
|
657
676
|
this._yieldedExecutions = options.yieldedExecutions ?? [];
|
|
658
677
|
if (options.noopTasksSet) {
|
|
659
|
-
this.
|
|
678
|
+
this._noopTasksRawData = options.noopTasksSet;
|
|
660
679
|
}
|
|
661
680
|
this._cachedTasksCursor = options.cachedTasksCursor;
|
|
662
681
|
this._serverVersion = options.serverVersion ?? "unversioned";
|
|
@@ -995,8 +1014,9 @@ var IO = class {
|
|
|
995
1014
|
this._stats.cachedTaskHits++;
|
|
996
1015
|
return cachedTask.output;
|
|
997
1016
|
}
|
|
998
|
-
if (options?.noop && this.
|
|
999
|
-
|
|
1017
|
+
if (options?.noop && this._noopTasksRawData) {
|
|
1018
|
+
const exists = await __privateMethod(this, _testNoopTaskBloomFilter, testNoopTaskBloomFilter_fn).call(this, idempotencyKey);
|
|
1019
|
+
if (exists) {
|
|
1000
1020
|
this._logger.debug("task idempotency key exists in noopTasksBloomFilter", {
|
|
1001
1021
|
idempotencyKey
|
|
1002
1022
|
});
|
|
@@ -1044,7 +1064,7 @@ var IO = class {
|
|
|
1044
1064
|
this._logger.debug("Noop Task completed", {
|
|
1045
1065
|
idempotencyKey
|
|
1046
1066
|
});
|
|
1047
|
-
this.
|
|
1067
|
+
await __privateMethod(this, _addNoopTaskBloomFilter, addNoopTaskBloomFilter_fn).call(this, task.idempotencyKey);
|
|
1048
1068
|
} else {
|
|
1049
1069
|
this._logger.debug("Cache miss", {
|
|
1050
1070
|
idempotencyKey
|
|
@@ -1136,10 +1156,11 @@ var IO = class {
|
|
|
1136
1156
|
error: parsedError.data
|
|
1137
1157
|
});
|
|
1138
1158
|
} else {
|
|
1159
|
+
const message = typeof error === "string" ? error : JSON.stringify(error);
|
|
1139
1160
|
await this._apiClient.failTask(this._id, task.id, {
|
|
1140
1161
|
error: {
|
|
1141
|
-
|
|
1142
|
-
|
|
1162
|
+
name: "Unknown error",
|
|
1163
|
+
message
|
|
1143
1164
|
}
|
|
1144
1165
|
});
|
|
1145
1166
|
}
|
|
@@ -1228,6 +1249,26 @@ getRemainingTimeInMillis_fn = /* @__PURE__ */ __name(function() {
|
|
|
1228
1249
|
}
|
|
1229
1250
|
return void 0;
|
|
1230
1251
|
}, "#getRemainingTimeInMillis");
|
|
1252
|
+
_testNoopTaskBloomFilter = new WeakSet();
|
|
1253
|
+
testNoopTaskBloomFilter_fn = /* @__PURE__ */ __name(async function(key) {
|
|
1254
|
+
if (!this.__noopTasksBloomFilter && this._noopTasksRawData) {
|
|
1255
|
+
this.__noopTasksBloomFilter = await import_core3.BloomFilter.deserialize(this._noopTasksRawData, import_core3.BloomFilter.NOOP_TASK_SET_SIZE);
|
|
1256
|
+
}
|
|
1257
|
+
if (!this.__noopTasksBloomFilter) {
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1260
|
+
return this.__noopTasksBloomFilter.test(key);
|
|
1261
|
+
}, "#testNoopTaskBloomFilter");
|
|
1262
|
+
_addNoopTaskBloomFilter = new WeakSet();
|
|
1263
|
+
addNoopTaskBloomFilter_fn = /* @__PURE__ */ __name(async function(key1) {
|
|
1264
|
+
if (!this.__noopTasksBloomFilter && this._noopTasksRawData) {
|
|
1265
|
+
this.__noopTasksBloomFilter = await import_core3.BloomFilter.deserialize(this._noopTasksRawData, import_core3.BloomFilter.NOOP_TASK_SET_SIZE);
|
|
1266
|
+
}
|
|
1267
|
+
if (!this.__noopTasksBloomFilter) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
return this.__noopTasksBloomFilter.add(key1);
|
|
1271
|
+
}, "#addNoopTaskBloomFilter");
|
|
1231
1272
|
async function generateIdempotencyKey(keyMaterial) {
|
|
1232
1273
|
const keys = keyMaterial.map((key2) => {
|
|
1233
1274
|
if (typeof key2 === "string") {
|
|
@@ -1390,7 +1431,7 @@ var DynamicTrigger = class {
|
|
|
1390
1431
|
key,
|
|
1391
1432
|
"register"
|
|
1392
1433
|
], async (task) => {
|
|
1393
|
-
return __privateGet(this, _client).registerTrigger(this.id, key, this.registeredTriggerForParams(params, options));
|
|
1434
|
+
return __privateGet(this, _client).registerTrigger(this.id, key, this.registeredTriggerForParams(params, options), task.idempotencyKey);
|
|
1394
1435
|
}, {
|
|
1395
1436
|
name: "Register Dynamic Trigger",
|
|
1396
1437
|
properties: [
|
|
@@ -1679,7 +1720,7 @@ var DynamicSchedule = class {
|
|
|
1679
1720
|
__name(DynamicSchedule, "DynamicSchedule");
|
|
1680
1721
|
|
|
1681
1722
|
// package.json
|
|
1682
|
-
var version = "0.0.0-
|
|
1723
|
+
var version = "0.0.0-buffer-import-20231031121649";
|
|
1683
1724
|
|
|
1684
1725
|
// src/triggerClient.ts
|
|
1685
1726
|
var registerSourceEvent = {
|
|
@@ -2128,8 +2169,8 @@ var TriggerClient = class {
|
|
|
2128
2169
|
});
|
|
2129
2170
|
__privateGet(this, _registeredSchedules)[key] = jobs;
|
|
2130
2171
|
}
|
|
2131
|
-
async registerTrigger(id, key, options) {
|
|
2132
|
-
return __privateGet(this, _client2).registerTrigger(this.id, id, key, options);
|
|
2172
|
+
async registerTrigger(id, key, options, idempotencyKey) {
|
|
2173
|
+
return __privateGet(this, _client2).registerTrigger(this.id, id, key, options, idempotencyKey);
|
|
2133
2174
|
}
|
|
2134
2175
|
async getAuth(id) {
|
|
2135
2176
|
return __privateGet(this, _client2).getAuth(this.id, id);
|
|
@@ -2140,6 +2181,9 @@ var TriggerClient = class {
|
|
|
2140
2181
|
async cancelEvent(eventId) {
|
|
2141
2182
|
return __privateGet(this, _client2).cancelEvent(eventId);
|
|
2142
2183
|
}
|
|
2184
|
+
async cancelRunsForEvent(eventId) {
|
|
2185
|
+
return __privateGet(this, _client2).cancelRunsForEvent(eventId);
|
|
2186
|
+
}
|
|
2143
2187
|
async updateStatus(runId, id, status) {
|
|
2144
2188
|
return __privateGet(this, _client2).updateStatus(runId, id, status);
|
|
2145
2189
|
}
|
|
@@ -2327,10 +2371,12 @@ executeJob_fn = /* @__PURE__ */ __name(async function(body1, job1, timeOrigin, t
|
|
|
2327
2371
|
error: errorWithStack.data
|
|
2328
2372
|
};
|
|
2329
2373
|
}
|
|
2374
|
+
const message = typeof error === "string" ? error : JSON.stringify(error);
|
|
2330
2375
|
return {
|
|
2331
2376
|
status: "ERROR",
|
|
2332
2377
|
error: {
|
|
2333
|
-
|
|
2378
|
+
name: "Unknown error",
|
|
2379
|
+
message
|
|
2334
2380
|
}
|
|
2335
2381
|
};
|
|
2336
2382
|
}
|