@trigger.dev/core 2.2.6 → 2.2.8
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 +519 -34
- package/dist/index.js +116 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ __export(src_exports, {
|
|
|
58
58
|
CreateRunResponseBodySchema: () => CreateRunResponseBodySchema,
|
|
59
59
|
CronMetadataSchema: () => CronMetadataSchema,
|
|
60
60
|
CronOptionsSchema: () => CronOptionsSchema,
|
|
61
|
+
DELIVER_WEBHOOK_REQUEST: () => DELIVER_WEBHOOK_REQUEST,
|
|
61
62
|
DeliverEventResponseSchema: () => DeliverEventResponseSchema,
|
|
62
63
|
DeserializedJsonSchema: () => DeserializedJsonSchema,
|
|
63
64
|
DisplayPropertiesSchema: () => DisplayPropertiesSchema,
|
|
@@ -73,6 +74,8 @@ __export(src_exports, {
|
|
|
73
74
|
EventFilterSchema: () => EventFilterSchema,
|
|
74
75
|
EventRuleSchema: () => EventRuleSchema,
|
|
75
76
|
EventSpecificationSchema: () => EventSpecificationSchema,
|
|
77
|
+
ExecuteJobHeadersSchema: () => ExecuteJobHeadersSchema,
|
|
78
|
+
ExecuteJobRunMetadataSchema: () => ExecuteJobRunMetadataSchema,
|
|
76
79
|
FailTaskBodyInputSchema: () => FailTaskBodyInputSchema,
|
|
77
80
|
FetchOperationSchema: () => FetchOperationSchema,
|
|
78
81
|
FetchPollOperationSchema: () => FetchPollOperationSchema,
|
|
@@ -105,6 +108,7 @@ __export(src_exports, {
|
|
|
105
108
|
InvokeTriggerMetadataSchema: () => InvokeTriggerMetadataSchema,
|
|
106
109
|
JobMetadataSchema: () => JobMetadataSchema,
|
|
107
110
|
JobRunStatusRecordSchema: () => JobRunStatusRecordSchema,
|
|
111
|
+
KeyValueStoreResponseBodySchema: () => KeyValueStoreResponseBodySchema,
|
|
108
112
|
LogMessageSchema: () => LogMessageSchema,
|
|
109
113
|
Logger: () => Logger,
|
|
110
114
|
MISSING_CONNECTION_NOTIFICATION: () => MISSING_CONNECTION_NOTIFICATION,
|
|
@@ -126,6 +130,7 @@ __export(src_exports, {
|
|
|
126
130
|
QueueOptionsSchema: () => QueueOptionsSchema,
|
|
127
131
|
REGISTER_SOURCE_EVENT_V1: () => REGISTER_SOURCE_EVENT_V1,
|
|
128
132
|
REGISTER_SOURCE_EVENT_V2: () => REGISTER_SOURCE_EVENT_V2,
|
|
133
|
+
REGISTER_WEBHOOK: () => REGISTER_WEBHOOK,
|
|
129
134
|
RawEventSchema: () => RawEventSchema,
|
|
130
135
|
RedactSchema: () => RedactSchema,
|
|
131
136
|
RedactStringSchema: () => RedactStringSchema,
|
|
@@ -142,6 +147,8 @@ __export(src_exports, {
|
|
|
142
147
|
RegisterTriggerBodySchemaV1: () => RegisterTriggerBodySchemaV1,
|
|
143
148
|
RegisterTriggerBodySchemaV2: () => RegisterTriggerBodySchemaV2,
|
|
144
149
|
RegisterTriggerSourceSchema: () => RegisterTriggerSourceSchema,
|
|
150
|
+
RegisterWebhookPayloadSchema: () => RegisterWebhookPayloadSchema,
|
|
151
|
+
RegisterWebhookSourceSchema: () => RegisterWebhookSourceSchema,
|
|
145
152
|
RequestFilterSchema: () => RequestFilterSchema,
|
|
146
153
|
RequestWithRawBodySchema: () => RequestWithRawBodySchema,
|
|
147
154
|
ResponseFilterSchema: () => ResponseFilterSchema,
|
|
@@ -191,10 +198,16 @@ __export(src_exports, {
|
|
|
191
198
|
TriggerSourceSchema: () => TriggerSourceSchema,
|
|
192
199
|
UpdateTriggerSourceBodyV1Schema: () => UpdateTriggerSourceBodyV1Schema,
|
|
193
200
|
UpdateTriggerSourceBodyV2Schema: () => UpdateTriggerSourceBodyV2Schema,
|
|
201
|
+
UpdateWebhookBodySchema: () => UpdateWebhookBodySchema,
|
|
194
202
|
ValidateErrorResponseSchema: () => ValidateErrorResponseSchema,
|
|
195
203
|
ValidateResponseSchema: () => ValidateResponseSchema,
|
|
196
204
|
ValidateSuccessResponseSchema: () => ValidateSuccessResponseSchema,
|
|
205
|
+
WebhookContextMetadataSchema: () => WebhookContextMetadataSchema,
|
|
206
|
+
WebhookDeliveryResponseSchema: () => WebhookDeliveryResponseSchema,
|
|
207
|
+
WebhookMetadataSchema: () => WebhookMetadataSchema,
|
|
208
|
+
WebhookSourceRequestHeadersSchema: () => WebhookSourceRequestHeadersSchema,
|
|
197
209
|
addMissingVersionField: () => addMissingVersionField,
|
|
210
|
+
assertExhaustive: () => assertExhaustive,
|
|
198
211
|
calculateResetAt: () => calculateResetAt,
|
|
199
212
|
calculateRetryAt: () => calculateRetryAt,
|
|
200
213
|
currentDate: () => currentDate,
|
|
@@ -220,18 +233,20 @@ var logLevels = [
|
|
|
220
233
|
"info",
|
|
221
234
|
"debug"
|
|
222
235
|
];
|
|
223
|
-
var _name, _level, _filteredKeys, _jsonReplacer, _structuredLog, structuredLog_fn;
|
|
236
|
+
var _name, _level, _filteredKeys, _jsonReplacer, _additionalFields, _structuredLog, structuredLog_fn;
|
|
224
237
|
var _Logger = class _Logger {
|
|
225
|
-
constructor(name, level = "info", filteredKeys = [], jsonReplacer) {
|
|
238
|
+
constructor(name, level = "info", filteredKeys = [], jsonReplacer, additionalFields) {
|
|
226
239
|
__privateAdd(this, _structuredLog);
|
|
227
240
|
__privateAdd(this, _name, void 0);
|
|
228
241
|
__privateAdd(this, _level, void 0);
|
|
229
242
|
__privateAdd(this, _filteredKeys, []);
|
|
230
243
|
__privateAdd(this, _jsonReplacer, void 0);
|
|
244
|
+
__privateAdd(this, _additionalFields, void 0);
|
|
231
245
|
__privateSet(this, _name, name);
|
|
232
246
|
__privateSet(this, _level, logLevels.indexOf(process.env.TRIGGER_LOG_LEVEL ?? level));
|
|
233
247
|
__privateSet(this, _filteredKeys, filteredKeys);
|
|
234
248
|
__privateSet(this, _jsonReplacer, createReplacer(jsonReplacer));
|
|
249
|
+
__privateSet(this, _additionalFields, additionalFields ?? (() => ({})));
|
|
235
250
|
}
|
|
236
251
|
// Return a new Logger instance with the same name and a new log level
|
|
237
252
|
// but filter out the keys from the log messages (at any level)
|
|
@@ -271,10 +286,12 @@ _name = new WeakMap();
|
|
|
271
286
|
_level = new WeakMap();
|
|
272
287
|
_filteredKeys = new WeakMap();
|
|
273
288
|
_jsonReplacer = new WeakMap();
|
|
289
|
+
_additionalFields = new WeakMap();
|
|
274
290
|
_structuredLog = new WeakSet();
|
|
275
291
|
structuredLog_fn = /* @__PURE__ */ __name(function(loggerFunction, message, level, ...args) {
|
|
276
292
|
const structuredLog = {
|
|
277
293
|
...structureArgs(safeJsonClone(args), __privateGet(this, _filteredKeys)),
|
|
294
|
+
...__privateGet(this, _additionalFields).call(this),
|
|
278
295
|
timestamp: /* @__PURE__ */ new Date(),
|
|
279
296
|
name: __privateGet(this, _name),
|
|
280
297
|
message,
|
|
@@ -374,7 +391,7 @@ function getSizeInBytes(value) {
|
|
|
374
391
|
__name(getSizeInBytes, "getSizeInBytes");
|
|
375
392
|
|
|
376
393
|
// src/schemas/api.ts
|
|
377
|
-
var
|
|
394
|
+
var import_ulidx = require("ulidx");
|
|
378
395
|
var import_zod12 = require("zod");
|
|
379
396
|
|
|
380
397
|
// src/schemas/addMissingVersionField.ts
|
|
@@ -883,6 +900,15 @@ var UpdateTriggerSourceBodyV2Schema = import_zod12.z.object({
|
|
|
883
900
|
event: import_zod12.z.array(import_zod12.z.string())
|
|
884
901
|
}).and(import_zod12.z.record(import_zod12.z.string(), import_zod12.z.array(import_zod12.z.string())).optional())
|
|
885
902
|
});
|
|
903
|
+
var UpdateWebhookBodySchema = import_zod12.z.discriminatedUnion("active", [
|
|
904
|
+
import_zod12.z.object({
|
|
905
|
+
active: import_zod12.z.literal(false)
|
|
906
|
+
}),
|
|
907
|
+
import_zod12.z.object({
|
|
908
|
+
active: import_zod12.z.literal(true),
|
|
909
|
+
config: import_zod12.z.record(import_zod12.z.string().array())
|
|
910
|
+
})
|
|
911
|
+
]);
|
|
886
912
|
var RegisterHTTPTriggerSourceBodySchema = import_zod12.z.object({
|
|
887
913
|
type: import_zod12.z.literal("HTTP"),
|
|
888
914
|
url: import_zod12.z.string().url()
|
|
@@ -898,6 +924,29 @@ var RegisterSourceChannelBodySchema = import_zod12.z.discriminatedUnion("type",
|
|
|
898
924
|
RegisterSMTPTriggerSourceBodySchema,
|
|
899
925
|
RegisterSQSTriggerSourceBodySchema
|
|
900
926
|
]);
|
|
927
|
+
var REGISTER_WEBHOOK = "dev.trigger.webhook.register";
|
|
928
|
+
var DELIVER_WEBHOOK_REQUEST = "dev.trigger.webhook.deliver";
|
|
929
|
+
var RegisterWebhookSourceSchema = import_zod12.z.object({
|
|
930
|
+
key: import_zod12.z.string(),
|
|
931
|
+
params: import_zod12.z.any(),
|
|
932
|
+
config: import_zod12.z.any(),
|
|
933
|
+
active: import_zod12.z.boolean(),
|
|
934
|
+
secret: import_zod12.z.string(),
|
|
935
|
+
url: import_zod12.z.string(),
|
|
936
|
+
data: DeserializedJsonSchema.optional(),
|
|
937
|
+
clientId: import_zod12.z.string().optional()
|
|
938
|
+
});
|
|
939
|
+
var RegisterWebhookPayloadSchema = import_zod12.z.object({
|
|
940
|
+
active: import_zod12.z.boolean(),
|
|
941
|
+
params: import_zod12.z.any().optional(),
|
|
942
|
+
config: import_zod12.z.object({
|
|
943
|
+
current: import_zod12.z.record(import_zod12.z.string().array()),
|
|
944
|
+
desired: import_zod12.z.record(import_zod12.z.string().array())
|
|
945
|
+
}),
|
|
946
|
+
// from HTTP Endpoint
|
|
947
|
+
url: import_zod12.z.string(),
|
|
948
|
+
secret: import_zod12.z.string()
|
|
949
|
+
});
|
|
901
950
|
var REGISTER_SOURCE_EVENT_V1 = "dev.trigger.source.register";
|
|
902
951
|
var REGISTER_SOURCE_EVENT_V2 = "dev.trigger.source.register.v2";
|
|
903
952
|
var RegisterTriggerSourceSchema = import_zod12.z.object({
|
|
@@ -978,6 +1027,15 @@ var HttpEndpointRequestHeadersSchema = import_zod12.z.object({
|
|
|
978
1027
|
"x-ts-http-method": import_zod12.z.string(),
|
|
979
1028
|
"x-ts-http-headers": import_zod12.z.string().transform((s) => import_zod12.z.record(import_zod12.z.string()).parse(JSON.parse(s)))
|
|
980
1029
|
});
|
|
1030
|
+
var WebhookSourceRequestHeadersSchema = import_zod12.z.object({
|
|
1031
|
+
"x-ts-key": import_zod12.z.string(),
|
|
1032
|
+
"x-ts-dynamic-id": import_zod12.z.string().optional(),
|
|
1033
|
+
"x-ts-secret": import_zod12.z.string(),
|
|
1034
|
+
"x-ts-params": import_zod12.z.string().transform((s) => JSON.parse(s)),
|
|
1035
|
+
"x-ts-http-url": import_zod12.z.string(),
|
|
1036
|
+
"x-ts-http-method": import_zod12.z.string(),
|
|
1037
|
+
"x-ts-http-headers": import_zod12.z.string().transform((s) => import_zod12.z.record(import_zod12.z.string()).parse(JSON.parse(s)))
|
|
1038
|
+
});
|
|
981
1039
|
var PongSuccessResponseSchema = import_zod12.z.object({
|
|
982
1040
|
ok: import_zod12.z.literal(true),
|
|
983
1041
|
triggerVersion: import_zod12.z.string().optional(),
|
|
@@ -1062,6 +1120,20 @@ var SourceMetadataSchema = import_zod12.z.preprocess(addMissingVersionField, imp
|
|
|
1062
1120
|
SourceMetadataV1Schema,
|
|
1063
1121
|
SourceMetadataV2Schema
|
|
1064
1122
|
]));
|
|
1123
|
+
var WebhookMetadataSchema = import_zod12.z.object({
|
|
1124
|
+
key: import_zod12.z.string(),
|
|
1125
|
+
params: import_zod12.z.any(),
|
|
1126
|
+
config: import_zod12.z.record(import_zod12.z.array(import_zod12.z.string())),
|
|
1127
|
+
integration: IntegrationConfigSchema,
|
|
1128
|
+
httpEndpoint: import_zod12.z.object({
|
|
1129
|
+
id: import_zod12.z.string()
|
|
1130
|
+
})
|
|
1131
|
+
});
|
|
1132
|
+
var WebhookContextMetadataSchema = import_zod12.z.object({
|
|
1133
|
+
params: import_zod12.z.any(),
|
|
1134
|
+
config: import_zod12.z.record(import_zod12.z.string().array()),
|
|
1135
|
+
secret: import_zod12.z.string()
|
|
1136
|
+
});
|
|
1065
1137
|
var DynamicTriggerEndpointMetadataSchema = import_zod12.z.object({
|
|
1066
1138
|
id: import_zod12.z.string(),
|
|
1067
1139
|
jobs: import_zod12.z.array(JobMetadataSchema.pick({
|
|
@@ -1088,6 +1160,7 @@ var HttpEndpointMetadataSchema = import_zod12.z.object({
|
|
|
1088
1160
|
var IndexEndpointResponseSchema = import_zod12.z.object({
|
|
1089
1161
|
jobs: import_zod12.z.array(JobMetadataSchema),
|
|
1090
1162
|
sources: import_zod12.z.array(SourceMetadataSchema),
|
|
1163
|
+
webhooks: import_zod12.z.array(WebhookMetadataSchema).optional(),
|
|
1091
1164
|
dynamicTriggers: import_zod12.z.array(DynamicTriggerEndpointMetadataSchema),
|
|
1092
1165
|
dynamicSchedules: import_zod12.z.array(RegisterDynamicSchedulePayloadSchema),
|
|
1093
1166
|
httpEndpoints: import_zod12.z.array(HttpEndpointMetadataSchema).optional()
|
|
@@ -1099,6 +1172,7 @@ var EndpointIndexErrorSchema = import_zod12.z.object({
|
|
|
1099
1172
|
var IndexEndpointStatsSchema = import_zod12.z.object({
|
|
1100
1173
|
jobs: import_zod12.z.number(),
|
|
1101
1174
|
sources: import_zod12.z.number(),
|
|
1175
|
+
webhooks: import_zod12.z.number(),
|
|
1102
1176
|
dynamicTriggers: import_zod12.z.number(),
|
|
1103
1177
|
dynamicSchedules: import_zod12.z.number(),
|
|
1104
1178
|
disabledJobs: import_zod12.z.number().default(0),
|
|
@@ -1135,6 +1209,13 @@ var EndpointHeadersSchema = import_zod12.z.object({
|
|
|
1135
1209
|
"trigger-version": import_zod12.z.string().optional(),
|
|
1136
1210
|
"trigger-sdk-version": import_zod12.z.string().optional()
|
|
1137
1211
|
});
|
|
1212
|
+
var ExecuteJobRunMetadataSchema = import_zod12.z.object({
|
|
1213
|
+
successSubscription: import_zod12.z.boolean().optional(),
|
|
1214
|
+
failedSubscription: import_zod12.z.boolean().optional()
|
|
1215
|
+
});
|
|
1216
|
+
var ExecuteJobHeadersSchema = EndpointHeadersSchema.extend({
|
|
1217
|
+
"x-trigger-run-metadata": import_zod12.z.preprocess((val) => typeof val === "string" && JSON.parse(val), ExecuteJobRunMetadataSchema).optional()
|
|
1218
|
+
});
|
|
1138
1219
|
var RawEventSchema = import_zod12.z.object({
|
|
1139
1220
|
/** The `name` property must exactly match any subscriptions you want to
|
|
1140
1221
|
trigger. */
|
|
@@ -1150,7 +1231,7 @@ var RawEventSchema = import_zod12.z.object({
|
|
|
1150
1231
|
context: import_zod12.z.any().optional(),
|
|
1151
1232
|
/** The `id` property uniquely identify this particular event. If unset it
|
|
1152
1233
|
will be set automatically using `ulid`. */
|
|
1153
|
-
id: import_zod12.z.string().default(() => (0,
|
|
1234
|
+
id: import_zod12.z.string().default(() => (0, import_ulidx.ulid)()),
|
|
1154
1235
|
/** This is optional, it defaults to the current timestamp. Usually you would
|
|
1155
1236
|
only set this if you have a timestamp that you wish to pass through, e.g.
|
|
1156
1237
|
you receive a timestamp from a service and you want the same timestamp to
|
|
@@ -1521,6 +1602,11 @@ var HttpSourceResponseSchema = import_zod12.z.object({
|
|
|
1521
1602
|
events: import_zod12.z.array(RawEventSchema),
|
|
1522
1603
|
metadata: HttpSourceResponseMetadataSchema.optional()
|
|
1523
1604
|
});
|
|
1605
|
+
var WebhookDeliveryResponseSchema = import_zod12.z.object({
|
|
1606
|
+
response: NormalizedResponseSchema,
|
|
1607
|
+
verified: import_zod12.z.boolean(),
|
|
1608
|
+
error: import_zod12.z.string().optional()
|
|
1609
|
+
});
|
|
1524
1610
|
var RegisterTriggerBodySchemaV1 = import_zod12.z.object({
|
|
1525
1611
|
rule: EventRuleSchema,
|
|
1526
1612
|
source: SourceMetadataV1Schema
|
|
@@ -1601,6 +1687,28 @@ var EphemeralEventDispatcherRequestBodySchema = import_zod12.z.object({
|
|
|
1601
1687
|
var EphemeralEventDispatcherResponseBodySchema = import_zod12.z.object({
|
|
1602
1688
|
id: import_zod12.z.string()
|
|
1603
1689
|
});
|
|
1690
|
+
var KeyValueStoreResponseBodySchema = import_zod12.z.discriminatedUnion("action", [
|
|
1691
|
+
import_zod12.z.object({
|
|
1692
|
+
action: import_zod12.z.literal("DELETE"),
|
|
1693
|
+
key: import_zod12.z.string(),
|
|
1694
|
+
deleted: import_zod12.z.boolean()
|
|
1695
|
+
}),
|
|
1696
|
+
import_zod12.z.object({
|
|
1697
|
+
action: import_zod12.z.literal("GET"),
|
|
1698
|
+
key: import_zod12.z.string(),
|
|
1699
|
+
value: import_zod12.z.string().optional()
|
|
1700
|
+
}),
|
|
1701
|
+
import_zod12.z.object({
|
|
1702
|
+
action: import_zod12.z.literal("HAS"),
|
|
1703
|
+
key: import_zod12.z.string(),
|
|
1704
|
+
has: import_zod12.z.boolean()
|
|
1705
|
+
}),
|
|
1706
|
+
import_zod12.z.object({
|
|
1707
|
+
action: import_zod12.z.literal("SET"),
|
|
1708
|
+
key: import_zod12.z.string(),
|
|
1709
|
+
value: import_zod12.z.string().optional()
|
|
1710
|
+
})
|
|
1711
|
+
]);
|
|
1604
1712
|
|
|
1605
1713
|
// src/schemas/notifications.ts
|
|
1606
1714
|
var import_zod13 = require("zod");
|
|
@@ -1780,6 +1888,10 @@ function deepMergeFilters(...filters) {
|
|
|
1780
1888
|
return result;
|
|
1781
1889
|
}
|
|
1782
1890
|
__name(deepMergeFilters, "deepMergeFilters");
|
|
1891
|
+
function assertExhaustive(x) {
|
|
1892
|
+
throw new Error("Unexpected object: " + x);
|
|
1893
|
+
}
|
|
1894
|
+
__name(assertExhaustive, "assertExhaustive");
|
|
1783
1895
|
|
|
1784
1896
|
// src/retry.ts
|
|
1785
1897
|
var DEFAULT_RETRY_OPTIONS = {
|