@trigger.dev/sdk 2.0.0-next.1 → 2.0.0-next.2
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 +305 -133
- package/dist/index.js +218 -81
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
missingConnectionNotification: () => missingConnectionNotification,
|
|
65
65
|
missingConnectionResolvedNotification: () => missingConnectionResolvedNotification,
|
|
66
66
|
omit: () => omit,
|
|
67
|
-
|
|
67
|
+
redactString: () => redactString
|
|
68
68
|
});
|
|
69
69
|
module.exports = __toCommonJS(src_exports);
|
|
70
70
|
|
|
@@ -104,12 +104,11 @@ var Job = class {
|
|
|
104
104
|
get integrations() {
|
|
105
105
|
return Object.keys(this.options.integrations ?? {}).reduce((acc, key) => {
|
|
106
106
|
const integration = this.options.integrations[key];
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
107
|
+
acc[key] = {
|
|
108
|
+
id: integration.id,
|
|
109
|
+
metadata: integration.metadata,
|
|
110
|
+
authSource: integration.client.usesLocalAuth ? "LOCAL" : "HOSTED"
|
|
111
|
+
};
|
|
113
112
|
return acc;
|
|
114
113
|
}, {});
|
|
115
114
|
}
|
|
@@ -146,18 +145,20 @@ var logLevels = [
|
|
|
146
145
|
"info",
|
|
147
146
|
"debug"
|
|
148
147
|
];
|
|
149
|
-
var _name, _level, _filteredKeys;
|
|
148
|
+
var _name, _level, _filteredKeys, _jsonReplacer;
|
|
150
149
|
var _Logger = class {
|
|
151
|
-
constructor(name, level = "info", filteredKeys = []) {
|
|
150
|
+
constructor(name, level = "info", filteredKeys = [], jsonReplacer) {
|
|
152
151
|
__privateAdd(this, _name, void 0);
|
|
153
152
|
__privateAdd(this, _level, void 0);
|
|
154
153
|
__privateAdd(this, _filteredKeys, []);
|
|
154
|
+
__privateAdd(this, _jsonReplacer, void 0);
|
|
155
155
|
__privateSet(this, _name, name);
|
|
156
156
|
__privateSet(this, _level, logLevels.indexOf(process.env.TRIGGER_LOG_LEVEL ?? level));
|
|
157
157
|
__privateSet(this, _filteredKeys, filteredKeys);
|
|
158
|
+
__privateSet(this, _jsonReplacer, jsonReplacer);
|
|
158
159
|
}
|
|
159
160
|
filter(...keys) {
|
|
160
|
-
return new _Logger(__privateGet(this, _name), logLevels[__privateGet(this, _level)], keys);
|
|
161
|
+
return new _Logger(__privateGet(this, _name), logLevels[__privateGet(this, _level)], keys, __privateGet(this, _jsonReplacer));
|
|
161
162
|
}
|
|
162
163
|
log(...args) {
|
|
163
164
|
if (__privateGet(this, _level) < 0)
|
|
@@ -188,7 +189,7 @@ var _Logger = class {
|
|
|
188
189
|
message,
|
|
189
190
|
args: structureArgs(safeJsonClone(args), __privateGet(this, _filteredKeys))
|
|
190
191
|
};
|
|
191
|
-
console.debug(JSON.stringify(structuredLog,
|
|
192
|
+
console.debug(JSON.stringify(structuredLog, createReplacer(__privateGet(this, _jsonReplacer))));
|
|
192
193
|
}
|
|
193
194
|
};
|
|
194
195
|
var Logger = _Logger;
|
|
@@ -196,6 +197,19 @@ __name(Logger, "Logger");
|
|
|
196
197
|
_name = new WeakMap();
|
|
197
198
|
_level = new WeakMap();
|
|
198
199
|
_filteredKeys = new WeakMap();
|
|
200
|
+
_jsonReplacer = new WeakMap();
|
|
201
|
+
function createReplacer(replacer) {
|
|
202
|
+
return (key, value) => {
|
|
203
|
+
if (typeof value === "bigint") {
|
|
204
|
+
return value.toString();
|
|
205
|
+
}
|
|
206
|
+
if (replacer) {
|
|
207
|
+
return replacer(key, value);
|
|
208
|
+
}
|
|
209
|
+
return value;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
__name(createReplacer, "createReplacer");
|
|
199
213
|
function bigIntReplacer(_key, value) {
|
|
200
214
|
if (typeof value === "bigint") {
|
|
201
215
|
return value.toString();
|
|
@@ -293,13 +307,17 @@ var ConnectionAuthSchema = import_zod3.z.object({
|
|
|
293
307
|
additionalFields: import_zod3.z.record(import_zod3.z.string()).optional()
|
|
294
308
|
});
|
|
295
309
|
var IntegrationMetadataSchema = import_zod3.z.object({
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
310
|
+
id: import_zod3.z.string(),
|
|
311
|
+
name: import_zod3.z.string(),
|
|
312
|
+
instructions: import_zod3.z.string().optional()
|
|
299
313
|
});
|
|
300
314
|
var IntegrationConfigSchema = import_zod3.z.object({
|
|
301
315
|
id: import_zod3.z.string(),
|
|
302
|
-
metadata: IntegrationMetadataSchema
|
|
316
|
+
metadata: IntegrationMetadataSchema,
|
|
317
|
+
authSource: import_zod3.z.enum([
|
|
318
|
+
"HOSTED",
|
|
319
|
+
"LOCAL"
|
|
320
|
+
])
|
|
303
321
|
});
|
|
304
322
|
|
|
305
323
|
// ../internal/src/schemas/json.ts
|
|
@@ -404,7 +422,8 @@ var TaskSchema = import_zod7.z.object({
|
|
|
404
422
|
output: DeserializedJsonSchema.optional().nullable(),
|
|
405
423
|
error: import_zod7.z.string().optional().nullable(),
|
|
406
424
|
parentId: import_zod7.z.string().optional().nullable(),
|
|
407
|
-
style: StyleSchema.optional().nullable()
|
|
425
|
+
style: StyleSchema.optional().nullable(),
|
|
426
|
+
operation: import_zod7.z.string().optional().nullable()
|
|
408
427
|
});
|
|
409
428
|
var ServerTaskSchema = TaskSchema.extend({
|
|
410
429
|
idempotencyKey: import_zod7.z.string(),
|
|
@@ -527,9 +546,17 @@ var HttpSourceRequestHeadersSchema = import_zod9.z.object({
|
|
|
527
546
|
"x-ts-http-method": import_zod9.z.string(),
|
|
528
547
|
"x-ts-http-headers": import_zod9.z.string().transform((s) => import_zod9.z.record(import_zod9.z.string()).parse(JSON.parse(s)))
|
|
529
548
|
});
|
|
530
|
-
var
|
|
531
|
-
|
|
549
|
+
var PongSuccessResponseSchema = import_zod9.z.object({
|
|
550
|
+
ok: import_zod9.z.literal(true)
|
|
532
551
|
});
|
|
552
|
+
var PongErrorResponseSchema = import_zod9.z.object({
|
|
553
|
+
ok: import_zod9.z.literal(false),
|
|
554
|
+
error: import_zod9.z.string()
|
|
555
|
+
});
|
|
556
|
+
var PongResponseSchema = import_zod9.z.discriminatedUnion("ok", [
|
|
557
|
+
PongSuccessResponseSchema,
|
|
558
|
+
PongErrorResponseSchema
|
|
559
|
+
]);
|
|
533
560
|
var QueueOptionsSchema = import_zod9.z.object({
|
|
534
561
|
name: import_zod9.z.string(),
|
|
535
562
|
maxConcurrent: import_zod9.z.number().optional()
|
|
@@ -559,10 +586,10 @@ var SourceMetadataSchema = import_zod9.z.object({
|
|
|
559
586
|
"SQS",
|
|
560
587
|
"SMTP"
|
|
561
588
|
]),
|
|
589
|
+
integration: IntegrationConfigSchema,
|
|
562
590
|
key: import_zod9.z.string(),
|
|
563
591
|
params: import_zod9.z.any(),
|
|
564
|
-
events: import_zod9.z.array(import_zod9.z.string())
|
|
565
|
-
clientId: import_zod9.z.string().optional()
|
|
592
|
+
events: import_zod9.z.array(import_zod9.z.string())
|
|
566
593
|
});
|
|
567
594
|
var DynamicTriggerEndpointMetadataSchema = import_zod9.z.object({
|
|
568
595
|
id: import_zod9.z.string(),
|
|
@@ -571,7 +598,7 @@ var DynamicTriggerEndpointMetadataSchema = import_zod9.z.object({
|
|
|
571
598
|
version: true
|
|
572
599
|
}))
|
|
573
600
|
});
|
|
574
|
-
var
|
|
601
|
+
var IndexEndpointResponseSchema = import_zod9.z.object({
|
|
575
602
|
jobs: import_zod9.z.array(JobMetadataSchema),
|
|
576
603
|
sources: import_zod9.z.array(SourceMetadataSchema),
|
|
577
604
|
dynamicTriggers: import_zod9.z.array(DynamicTriggerEndpointMetadataSchema),
|
|
@@ -714,8 +741,8 @@ var CreateRunResponseBodySchema = import_zod9.z.discriminatedUnion("ok", [
|
|
|
714
741
|
CreateRunResponseOkSchema,
|
|
715
742
|
CreateRunResponseErrorSchema
|
|
716
743
|
]);
|
|
717
|
-
var
|
|
718
|
-
|
|
744
|
+
var RedactStringSchema = import_zod9.z.object({
|
|
745
|
+
__redactedString: import_zod9.z.literal(true),
|
|
719
746
|
strings: import_zod9.z.array(import_zod9.z.string()),
|
|
720
747
|
interpolations: import_zod9.z.array(import_zod9.z.string())
|
|
721
748
|
});
|
|
@@ -744,10 +771,13 @@ var RunTaskOptionsSchema = import_zod9.z.object({
|
|
|
744
771
|
icon: import_zod9.z.string().optional(),
|
|
745
772
|
displayKey: import_zod9.z.string().optional(),
|
|
746
773
|
noop: import_zod9.z.boolean().default(false),
|
|
774
|
+
operation: import_zod9.z.enum([
|
|
775
|
+
"fetch"
|
|
776
|
+
]).optional(),
|
|
747
777
|
delayUntil: import_zod9.z.coerce.date().optional(),
|
|
748
778
|
description: import_zod9.z.string().optional(),
|
|
749
779
|
properties: import_zod9.z.array(DisplayPropertySchema).optional(),
|
|
750
|
-
params:
|
|
780
|
+
params: import_zod9.z.any(),
|
|
751
781
|
trigger: TriggerMetadataSchema.optional(),
|
|
752
782
|
redact: RedactSchema.optional(),
|
|
753
783
|
connectionKey: import_zod9.z.string().optional(),
|
|
@@ -833,9 +863,7 @@ var CommonMissingConnectionNotificationPayloadSchema = import_zod10.z.object({
|
|
|
833
863
|
title: import_zod10.z.string(),
|
|
834
864
|
scopes: import_zod10.z.array(import_zod10.z.string()),
|
|
835
865
|
createdAt: import_zod10.z.coerce.date(),
|
|
836
|
-
updatedAt: import_zod10.z.coerce.date()
|
|
837
|
-
integrationIdentifier: import_zod10.z.string(),
|
|
838
|
-
integrationAuthMethod: import_zod10.z.string()
|
|
866
|
+
updatedAt: import_zod10.z.coerce.date()
|
|
839
867
|
}),
|
|
840
868
|
authorizationUrl: import_zod10.z.string()
|
|
841
869
|
});
|
|
@@ -881,6 +909,39 @@ var MissingConnectionResolvedNotificationPayloadSchema = import_zod10.z.discrimi
|
|
|
881
909
|
MissingExternalConnectionResolvedNotificationPayloadSchema
|
|
882
910
|
]);
|
|
883
911
|
|
|
912
|
+
// ../internal/src/schemas/fetch.ts
|
|
913
|
+
var import_zod11 = require("zod");
|
|
914
|
+
var FetchRetryHeadersStrategySchema = import_zod11.z.object({
|
|
915
|
+
strategy: import_zod11.z.literal("headers"),
|
|
916
|
+
limitHeader: import_zod11.z.string(),
|
|
917
|
+
remainingHeader: import_zod11.z.string(),
|
|
918
|
+
resetHeader: import_zod11.z.string()
|
|
919
|
+
});
|
|
920
|
+
var FetchRetryBackoffStrategySchema = RetryOptionsSchema.extend({
|
|
921
|
+
strategy: import_zod11.z.literal("backoff")
|
|
922
|
+
});
|
|
923
|
+
var FetchRetryStrategySchema = import_zod11.z.discriminatedUnion("strategy", [
|
|
924
|
+
FetchRetryHeadersStrategySchema,
|
|
925
|
+
FetchRetryBackoffStrategySchema
|
|
926
|
+
]);
|
|
927
|
+
var FetchRequestInitSchema = import_zod11.z.object({
|
|
928
|
+
method: import_zod11.z.string().optional(),
|
|
929
|
+
headers: import_zod11.z.record(import_zod11.z.union([
|
|
930
|
+
import_zod11.z.string(),
|
|
931
|
+
RedactStringSchema
|
|
932
|
+
])).optional(),
|
|
933
|
+
body: import_zod11.z.union([
|
|
934
|
+
import_zod11.z.string(),
|
|
935
|
+
import_zod11.z.instanceof(ArrayBuffer)
|
|
936
|
+
]).optional()
|
|
937
|
+
});
|
|
938
|
+
var FetchRetryOptionsSchema = import_zod11.z.record(FetchRetryStrategySchema);
|
|
939
|
+
var FetchOperationSchema = import_zod11.z.object({
|
|
940
|
+
url: import_zod11.z.string(),
|
|
941
|
+
requestInit: FetchRequestInitSchema.optional(),
|
|
942
|
+
retry: import_zod11.z.record(FetchRetryStrategySchema).optional()
|
|
943
|
+
});
|
|
944
|
+
|
|
884
945
|
// ../internal/src/utils.ts
|
|
885
946
|
function deepMergeFilters(filter, other) {
|
|
886
947
|
const result = {
|
|
@@ -907,8 +968,40 @@ function deepMergeFilters(filter, other) {
|
|
|
907
968
|
}
|
|
908
969
|
__name(deepMergeFilters, "deepMergeFilters");
|
|
909
970
|
|
|
971
|
+
// ../internal/src/retry.ts
|
|
972
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
973
|
+
limit: 5,
|
|
974
|
+
factor: 1.8,
|
|
975
|
+
minTimeoutInMs: 1e3,
|
|
976
|
+
maxTimeoutInMs: 6e4,
|
|
977
|
+
randomize: true
|
|
978
|
+
};
|
|
979
|
+
function calculateRetryAt(retryOptions, attempts) {
|
|
980
|
+
const options = {
|
|
981
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
982
|
+
...retryOptions
|
|
983
|
+
};
|
|
984
|
+
const retryCount = attempts + 1;
|
|
985
|
+
if (retryCount >= options.limit) {
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const random = options.randomize ? Math.random() + 1 : 1;
|
|
989
|
+
let timeoutInMs = Math.round(random * Math.max(options.minTimeoutInMs, 1) * Math.pow(options.factor, Math.max(attempts - 1, 0)));
|
|
990
|
+
timeoutInMs = Math.min(timeoutInMs, options.maxTimeoutInMs);
|
|
991
|
+
return new Date(Date.now() + timeoutInMs);
|
|
992
|
+
}
|
|
993
|
+
__name(calculateRetryAt, "calculateRetryAt");
|
|
994
|
+
|
|
995
|
+
// ../internal/src/replacements.ts
|
|
996
|
+
var currentDate = {
|
|
997
|
+
marker: "__CURRENT_DATE__",
|
|
998
|
+
replace({ data: { now } }) {
|
|
999
|
+
return now.toISOString();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
910
1003
|
// src/apiClient.ts
|
|
911
|
-
var
|
|
1004
|
+
var import_zod12 = require("zod");
|
|
912
1005
|
var _apiUrl, _options, _logger, _apiKey, apiKey_fn;
|
|
913
1006
|
var ApiClient = class {
|
|
914
1007
|
constructor(options) {
|
|
@@ -1077,8 +1170,8 @@ var ApiClient = class {
|
|
|
1077
1170
|
__privateGet(this, _logger).debug("unregistering schedule", {
|
|
1078
1171
|
id
|
|
1079
1172
|
});
|
|
1080
|
-
const response = await zodfetch(
|
|
1081
|
-
ok:
|
|
1173
|
+
const response = await zodfetch(import_zod12.z.object({
|
|
1174
|
+
ok: import_zod12.z.boolean()
|
|
1082
1175
|
}), `${__privateGet(this, _apiUrl)}/api/v1/${client}/schedules/${id}/registrations/${encodeURIComponent(key)}`, {
|
|
1083
1176
|
method: "DELETE",
|
|
1084
1177
|
headers: {
|
|
@@ -1186,11 +1279,12 @@ function createIOWithIntegrations(io, auths, integrations) {
|
|
|
1186
1279
|
return io;
|
|
1187
1280
|
}
|
|
1188
1281
|
const connections = Object.entries(integrations).reduce((acc, [connectionKey, integration]) => {
|
|
1189
|
-
|
|
1190
|
-
const client =
|
|
1282
|
+
let auth = auths?.[connectionKey];
|
|
1283
|
+
const client = integration.client.usesLocalAuth ? integration.client.client : auth ? integration.client.clientFactory?.(auth) : void 0;
|
|
1191
1284
|
if (!client) {
|
|
1192
1285
|
return acc;
|
|
1193
1286
|
}
|
|
1287
|
+
auth = integration.client.usesLocalAuth ? integration.client.auth : auth;
|
|
1194
1288
|
const ioConnection = {
|
|
1195
1289
|
client
|
|
1196
1290
|
};
|
|
@@ -1202,7 +1296,7 @@ function createIOWithIntegrations(io, auths, integrations) {
|
|
|
1202
1296
|
const options = authenticatedTask2.init(params);
|
|
1203
1297
|
options.connectionKey = connectionKey;
|
|
1204
1298
|
return await io.runTask(key, options, async (ioTask) => {
|
|
1205
|
-
return authenticatedTask2.run(params, client, ioTask, io);
|
|
1299
|
+
return authenticatedTask2.run(params, client, ioTask, io, auth);
|
|
1206
1300
|
}, authenticatedTask2.onError);
|
|
1207
1301
|
};
|
|
1208
1302
|
});
|
|
@@ -1225,30 +1319,6 @@ function createIOWithIntegrations(io, auths, integrations) {
|
|
|
1225
1319
|
}
|
|
1226
1320
|
__name(createIOWithIntegrations, "createIOWithIntegrations");
|
|
1227
1321
|
|
|
1228
|
-
// src/retry.ts
|
|
1229
|
-
var DEFAULT_RETRY_OPTIONS = {
|
|
1230
|
-
limit: 5,
|
|
1231
|
-
factor: 1.8,
|
|
1232
|
-
minTimeoutInMs: 1e3,
|
|
1233
|
-
maxTimeoutInMs: 6e4,
|
|
1234
|
-
randomize: true
|
|
1235
|
-
};
|
|
1236
|
-
function calculateRetryAt(retryOptions, attempts) {
|
|
1237
|
-
const options = {
|
|
1238
|
-
...DEFAULT_RETRY_OPTIONS,
|
|
1239
|
-
...retryOptions
|
|
1240
|
-
};
|
|
1241
|
-
const retryCount = attempts + 1;
|
|
1242
|
-
if (retryCount > options.limit) {
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1245
|
-
const random = options.randomize ? Math.random() + 1 : 1;
|
|
1246
|
-
let timeoutInMs = Math.round(random * Math.max(options.minTimeoutInMs, 1) * Math.pow(options.factor, Math.max(attempts - 1, 0)));
|
|
1247
|
-
timeoutInMs = Math.min(timeoutInMs, options.maxTimeoutInMs);
|
|
1248
|
-
return new Date(Date.now() + timeoutInMs);
|
|
1249
|
-
}
|
|
1250
|
-
__name(calculateRetryAt, "calculateRetryAt");
|
|
1251
|
-
|
|
1252
1322
|
// src/io.ts
|
|
1253
1323
|
var _addToCachedTasks, addToCachedTasks_fn;
|
|
1254
1324
|
var IO = class {
|
|
@@ -1325,6 +1395,37 @@ var IO = class {
|
|
|
1325
1395
|
}, async (task) => {
|
|
1326
1396
|
});
|
|
1327
1397
|
}
|
|
1398
|
+
async backgroundFetch(key, url, requestInit, retry) {
|
|
1399
|
+
const urlObject = new URL(url);
|
|
1400
|
+
return await this.runTask(key, {
|
|
1401
|
+
name: `fetch ${urlObject.hostname}${urlObject.pathname}`,
|
|
1402
|
+
params: {
|
|
1403
|
+
url,
|
|
1404
|
+
requestInit,
|
|
1405
|
+
retry
|
|
1406
|
+
},
|
|
1407
|
+
operation: "fetch",
|
|
1408
|
+
icon: "background",
|
|
1409
|
+
noop: false,
|
|
1410
|
+
properties: [
|
|
1411
|
+
{
|
|
1412
|
+
label: "url",
|
|
1413
|
+
text: url,
|
|
1414
|
+
url
|
|
1415
|
+
},
|
|
1416
|
+
{
|
|
1417
|
+
label: "method",
|
|
1418
|
+
text: requestInit?.method ?? "GET"
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
label: "background",
|
|
1422
|
+
text: "true"
|
|
1423
|
+
}
|
|
1424
|
+
]
|
|
1425
|
+
}, async (task) => {
|
|
1426
|
+
return task.output;
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1328
1429
|
async sendEvent(key, event, options) {
|
|
1329
1430
|
return await this.runTask(key, {
|
|
1330
1431
|
name: "sendEvent",
|
|
@@ -1540,6 +1641,13 @@ var IO = class {
|
|
|
1540
1641
|
});
|
|
1541
1642
|
throw new ResumeWithTaskError(task);
|
|
1542
1643
|
}
|
|
1644
|
+
if (task.status === "RUNNING" && typeof task.operation === "string") {
|
|
1645
|
+
this._logger.debug("Task running operation", {
|
|
1646
|
+
idempotencyKey,
|
|
1647
|
+
task
|
|
1648
|
+
});
|
|
1649
|
+
throw new ResumeWithTaskError(task);
|
|
1650
|
+
}
|
|
1543
1651
|
const executeTask = /* @__PURE__ */ __name(async () => {
|
|
1544
1652
|
try {
|
|
1545
1653
|
const result = await callback(task, this);
|
|
@@ -1552,6 +1660,9 @@ var IO = class {
|
|
|
1552
1660
|
});
|
|
1553
1661
|
return result;
|
|
1554
1662
|
} catch (error) {
|
|
1663
|
+
if (isTriggerError(error)) {
|
|
1664
|
+
throw error;
|
|
1665
|
+
}
|
|
1555
1666
|
if (onError) {
|
|
1556
1667
|
const onErrorResult = onError(error, task, this);
|
|
1557
1668
|
if (onErrorResult) {
|
|
@@ -1563,7 +1674,7 @@ var IO = class {
|
|
|
1563
1674
|
}
|
|
1564
1675
|
const parsedError = ErrorWithStackSchema.safeParse(error);
|
|
1565
1676
|
if (options.retry) {
|
|
1566
|
-
const retryAt = calculateRetryAt(options.retry, task.attempts);
|
|
1677
|
+
const retryAt = calculateRetryAt(options.retry, task.attempts - 1);
|
|
1567
1678
|
if (retryAt) {
|
|
1568
1679
|
throw new RetryWithTaskError(parsedError.success ? parsedError.data : {
|
|
1569
1680
|
message: "Unknown error"
|
|
@@ -1773,14 +1884,33 @@ var TriggerClient = class {
|
|
|
1773
1884
|
}
|
|
1774
1885
|
switch (action) {
|
|
1775
1886
|
case "PING": {
|
|
1887
|
+
const endpointId = request.headers.get("x-trigger-endpoint-id");
|
|
1888
|
+
if (!endpointId) {
|
|
1889
|
+
return {
|
|
1890
|
+
status: 200,
|
|
1891
|
+
body: {
|
|
1892
|
+
ok: false,
|
|
1893
|
+
message: "Missing endpoint ID"
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
if (this.id !== endpointId) {
|
|
1898
|
+
return {
|
|
1899
|
+
status: 200,
|
|
1900
|
+
body: {
|
|
1901
|
+
ok: false,
|
|
1902
|
+
message: `Endpoint ID mismatch error. Expected ${this.id}, got ${endpointId}`
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1776
1906
|
return {
|
|
1777
1907
|
status: 200,
|
|
1778
1908
|
body: {
|
|
1779
|
-
|
|
1909
|
+
ok: true
|
|
1780
1910
|
}
|
|
1781
1911
|
};
|
|
1782
1912
|
}
|
|
1783
|
-
case "
|
|
1913
|
+
case "INDEX_ENDPOINT": {
|
|
1784
1914
|
const jobId = request.headers.get("x-trigger-job-id");
|
|
1785
1915
|
if (jobId) {
|
|
1786
1916
|
const job = __privateGet(this, _registeredJobs)[jobId];
|
|
@@ -1814,15 +1944,6 @@ var TriggerClient = class {
|
|
|
1814
1944
|
body
|
|
1815
1945
|
};
|
|
1816
1946
|
}
|
|
1817
|
-
case "INITIALIZE": {
|
|
1818
|
-
await this.listen();
|
|
1819
|
-
return {
|
|
1820
|
-
status: 200,
|
|
1821
|
-
body: {
|
|
1822
|
-
message: "Initialized"
|
|
1823
|
-
}
|
|
1824
|
-
};
|
|
1825
|
-
}
|
|
1826
1947
|
case "INITIALIZE_TRIGGER": {
|
|
1827
1948
|
const json = await request.json();
|
|
1828
1949
|
const body = InitializeTriggerBodySchema.safeParse(json);
|
|
@@ -2003,7 +2124,11 @@ var TriggerClient = class {
|
|
|
2003
2124
|
key: options.key,
|
|
2004
2125
|
params: options.params,
|
|
2005
2126
|
events: [],
|
|
2006
|
-
|
|
2127
|
+
integration: {
|
|
2128
|
+
id: options.source.integration.id,
|
|
2129
|
+
metadata: options.source.integration.metadata,
|
|
2130
|
+
authSource: options.source.integration.client.usesLocalAuth ? "LOCAL" : "HOSTED"
|
|
2131
|
+
}
|
|
2007
2132
|
};
|
|
2008
2133
|
}
|
|
2009
2134
|
registeredSource.events = Array.from(/* @__PURE__ */ new Set([
|
|
@@ -2079,12 +2204,6 @@ var TriggerClient = class {
|
|
|
2079
2204
|
apiKey() {
|
|
2080
2205
|
return __privateGet(this, _options3).apiKey ?? process.env.TRIGGER_API_KEY;
|
|
2081
2206
|
}
|
|
2082
|
-
async listen() {
|
|
2083
|
-
await __privateGet(this, _client).registerEndpoint({
|
|
2084
|
-
url: this.url,
|
|
2085
|
-
name: this.id
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
2207
|
};
|
|
2089
2208
|
__name(TriggerClient, "TriggerClient");
|
|
2090
2209
|
_options3 = new WeakMap();
|
|
@@ -2454,7 +2573,11 @@ var DynamicTrigger = class {
|
|
|
2454
2573
|
events: [
|
|
2455
2574
|
this.event.name
|
|
2456
2575
|
],
|
|
2457
|
-
|
|
2576
|
+
integration: {
|
|
2577
|
+
id: this.source.integration.id,
|
|
2578
|
+
metadata: this.source.integration.metadata,
|
|
2579
|
+
authSource: this.source.integration.client.usesLocalAuth ? "LOCAL" : "HOSTED"
|
|
2580
|
+
}
|
|
2458
2581
|
}
|
|
2459
2582
|
};
|
|
2460
2583
|
}
|
|
@@ -2473,6 +2596,17 @@ _client2 = new WeakMap();
|
|
|
2473
2596
|
_options4 = new WeakMap();
|
|
2474
2597
|
|
|
2475
2598
|
// src/triggers/scheduled.ts
|
|
2599
|
+
var examples = [
|
|
2600
|
+
{
|
|
2601
|
+
id: "now",
|
|
2602
|
+
name: "Now",
|
|
2603
|
+
icon: "clock",
|
|
2604
|
+
payload: {
|
|
2605
|
+
ts: currentDate.marker,
|
|
2606
|
+
lastTimestamp: currentDate.marker
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
];
|
|
2476
2610
|
var IntervalTrigger = class {
|
|
2477
2611
|
constructor(options) {
|
|
2478
2612
|
this.options = options;
|
|
@@ -2483,6 +2617,7 @@ var IntervalTrigger = class {
|
|
|
2483
2617
|
title: "Schedule",
|
|
2484
2618
|
source: "trigger.dev",
|
|
2485
2619
|
icon: "schedule-interval",
|
|
2620
|
+
examples,
|
|
2486
2621
|
parsePayload: ScheduledPayloadSchema.parse,
|
|
2487
2622
|
properties: [
|
|
2488
2623
|
{
|
|
@@ -2524,6 +2659,7 @@ var CronTrigger = class {
|
|
|
2524
2659
|
title: "Cron Schedule",
|
|
2525
2660
|
source: "trigger.dev",
|
|
2526
2661
|
icon: "schedule-cron",
|
|
2662
|
+
examples,
|
|
2527
2663
|
parsePayload: ScheduledPayloadSchema.parse,
|
|
2528
2664
|
properties: [
|
|
2529
2665
|
{
|
|
@@ -2569,6 +2705,7 @@ var DynamicSchedule = class {
|
|
|
2569
2705
|
title: "Dynamic Schedule",
|
|
2570
2706
|
source: "trigger.dev",
|
|
2571
2707
|
icon: "schedule-dynamic",
|
|
2708
|
+
examples,
|
|
2572
2709
|
parsePayload: ScheduledPayloadSchema.parse
|
|
2573
2710
|
};
|
|
2574
2711
|
}
|
|
@@ -2690,14 +2827,14 @@ var MissingConnectionResolvedNotification = class {
|
|
|
2690
2827
|
__name(MissingConnectionResolvedNotification, "MissingConnectionResolvedNotification");
|
|
2691
2828
|
|
|
2692
2829
|
// src/index.ts
|
|
2693
|
-
function
|
|
2830
|
+
function redactString(strings, ...interpolations) {
|
|
2694
2831
|
return {
|
|
2695
|
-
|
|
2832
|
+
__redactedString: true,
|
|
2696
2833
|
strings: strings.raw,
|
|
2697
2834
|
interpolations
|
|
2698
2835
|
};
|
|
2699
2836
|
}
|
|
2700
|
-
__name(
|
|
2837
|
+
__name(redactString, "redactString");
|
|
2701
2838
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2702
2839
|
0 && (module.exports = {
|
|
2703
2840
|
CronTrigger,
|
|
@@ -2721,6 +2858,6 @@ __name(secureString, "secureString");
|
|
|
2721
2858
|
missingConnectionNotification,
|
|
2722
2859
|
missingConnectionResolvedNotification,
|
|
2723
2860
|
omit,
|
|
2724
|
-
|
|
2861
|
+
redactString
|
|
2725
2862
|
});
|
|
2726
2863
|
//# sourceMappingURL=index.js.map
|