@trigger.dev/core 2.0.14 → 2.1.0-beta.0
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 +797 -118
- package/dist/index.js +99 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75,7 +75,6 @@ __export(src_exports, {
|
|
|
75
75
|
GetRunSchema: () => GetRunSchema,
|
|
76
76
|
GetRunsSchema: () => GetRunsSchema,
|
|
77
77
|
HandleTriggerSourceSchema: () => HandleTriggerSourceSchema,
|
|
78
|
-
HttpEventSourceSchema: () => HttpEventSourceSchema,
|
|
79
78
|
HttpSourceRequestHeadersSchema: () => HttpSourceRequestHeadersSchema,
|
|
80
79
|
HttpSourceRequestSchema: () => HttpSourceRequestSchema,
|
|
81
80
|
HttpSourceResponseSchema: () => HttpSourceResponseSchema,
|
|
@@ -105,7 +104,8 @@ __export(src_exports, {
|
|
|
105
104
|
PreprocessRunBodySchema: () => PreprocessRunBodySchema,
|
|
106
105
|
PreprocessRunResponseSchema: () => PreprocessRunResponseSchema,
|
|
107
106
|
QueueOptionsSchema: () => QueueOptionsSchema,
|
|
108
|
-
|
|
107
|
+
REGISTER_SOURCE_EVENT_V1: () => REGISTER_SOURCE_EVENT_V1,
|
|
108
|
+
REGISTER_SOURCE_EVENT_V2: () => REGISTER_SOURCE_EVENT_V2,
|
|
109
109
|
RawEventSchema: () => RawEventSchema,
|
|
110
110
|
RedactSchema: () => RedactSchema,
|
|
111
111
|
RedactStringSchema: () => RedactStringSchema,
|
|
@@ -117,8 +117,10 @@ __export(src_exports, {
|
|
|
117
117
|
RegisterScheduleBodySchema: () => RegisterScheduleBodySchema,
|
|
118
118
|
RegisterScheduleResponseBodySchema: () => RegisterScheduleResponseBodySchema,
|
|
119
119
|
RegisterSourceChannelBodySchema: () => RegisterSourceChannelBodySchema,
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
RegisterSourceEventSchemaV1: () => RegisterSourceEventSchemaV1,
|
|
121
|
+
RegisterSourceEventSchemaV2: () => RegisterSourceEventSchemaV2,
|
|
122
|
+
RegisterTriggerBodySchemaV1: () => RegisterTriggerBodySchemaV1,
|
|
123
|
+
RegisterTriggerBodySchemaV2: () => RegisterTriggerBodySchemaV2,
|
|
122
124
|
RegisterTriggerSourceSchema: () => RegisterTriggerSourceSchema,
|
|
123
125
|
RetryOptionsSchema: () => RetryOptionsSchema,
|
|
124
126
|
RunJobBodySchema: () => RunJobBodySchema,
|
|
@@ -143,17 +145,19 @@ __export(src_exports, {
|
|
|
143
145
|
SendEventOptionsSchema: () => SendEventOptionsSchema,
|
|
144
146
|
SerializableJsonSchema: () => SerializableJsonSchema,
|
|
145
147
|
ServerTaskSchema: () => ServerTaskSchema,
|
|
146
|
-
|
|
148
|
+
SourceMetadataV2Schema: () => SourceMetadataV2Schema,
|
|
147
149
|
StaticTriggerMetadataSchema: () => StaticTriggerMetadataSchema,
|
|
148
150
|
StyleSchema: () => StyleSchema,
|
|
149
151
|
TaskSchema: () => TaskSchema,
|
|
150
152
|
TaskStatusSchema: () => TaskStatusSchema,
|
|
151
153
|
TriggerMetadataSchema: () => TriggerMetadataSchema,
|
|
152
154
|
TriggerSourceSchema: () => TriggerSourceSchema,
|
|
153
|
-
|
|
155
|
+
UpdateTriggerSourceBodyV1Schema: () => UpdateTriggerSourceBodyV1Schema,
|
|
156
|
+
UpdateTriggerSourceBodyV2Schema: () => UpdateTriggerSourceBodyV2Schema,
|
|
154
157
|
ValidateErrorResponseSchema: () => ValidateErrorResponseSchema,
|
|
155
158
|
ValidateResponseSchema: () => ValidateResponseSchema,
|
|
156
159
|
ValidateSuccessResponseSchema: () => ValidateSuccessResponseSchema,
|
|
160
|
+
addMissingVersionField: () => addMissingVersionField,
|
|
157
161
|
calculateRetryAt: () => calculateRetryAt,
|
|
158
162
|
currentDate: () => currentDate,
|
|
159
163
|
currentTimestampMilliseconds: () => currentTimestampMilliseconds,
|
|
@@ -317,6 +321,18 @@ __name(prettyPrintBytes, "prettyPrintBytes");
|
|
|
317
321
|
var import_ulid = require("ulid");
|
|
318
322
|
var import_zod9 = require("zod");
|
|
319
323
|
|
|
324
|
+
// src/schemas/addMissingVersionField.ts
|
|
325
|
+
function addMissingVersionField(val) {
|
|
326
|
+
if (val !== null && typeof val === "object" && !("version" in val)) {
|
|
327
|
+
return {
|
|
328
|
+
...val,
|
|
329
|
+
version: "1"
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
return val;
|
|
333
|
+
}
|
|
334
|
+
__name(addMissingVersionField, "addMissingVersionField");
|
|
335
|
+
|
|
320
336
|
// src/schemas/errors.ts
|
|
321
337
|
var import_zod = require("zod");
|
|
322
338
|
var ErrorWithStackSchema = import_zod.z.object({
|
|
@@ -601,15 +617,17 @@ var TriggerMetadataSchema = import_zod8.z.discriminatedUnion("type", [
|
|
|
601
617
|
]);
|
|
602
618
|
|
|
603
619
|
// src/schemas/api.ts
|
|
604
|
-
var
|
|
620
|
+
var UpdateTriggerSourceBodyV1Schema = import_zod9.z.object({
|
|
605
621
|
registeredEvents: import_zod9.z.array(import_zod9.z.string()),
|
|
606
622
|
secret: import_zod9.z.string().optional(),
|
|
607
623
|
data: SerializableJsonSchema.optional()
|
|
608
624
|
});
|
|
609
|
-
var
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
625
|
+
var UpdateTriggerSourceBodyV2Schema = import_zod9.z.object({
|
|
626
|
+
secret: import_zod9.z.string().optional(),
|
|
627
|
+
data: SerializableJsonSchema.optional(),
|
|
628
|
+
options: import_zod9.z.object({
|
|
629
|
+
event: import_zod9.z.array(import_zod9.z.string())
|
|
630
|
+
}).and(import_zod9.z.record(import_zod9.z.string(), import_zod9.z.array(import_zod9.z.string())).optional())
|
|
613
631
|
});
|
|
614
632
|
var RegisterHTTPTriggerSourceBodySchema = import_zod9.z.object({
|
|
615
633
|
type: import_zod9.z.literal("HTTP"),
|
|
@@ -626,7 +644,8 @@ var RegisterSourceChannelBodySchema = import_zod9.z.discriminatedUnion("type", [
|
|
|
626
644
|
RegisterSMTPTriggerSourceBodySchema,
|
|
627
645
|
RegisterSQSTriggerSourceBodySchema
|
|
628
646
|
]);
|
|
629
|
-
var
|
|
647
|
+
var REGISTER_SOURCE_EVENT_V1 = "dev.trigger.source.register";
|
|
648
|
+
var REGISTER_SOURCE_EVENT_V2 = "dev.trigger.source.register.v2";
|
|
630
649
|
var RegisterTriggerSourceSchema = import_zod9.z.object({
|
|
631
650
|
key: import_zod9.z.string(),
|
|
632
651
|
params: import_zod9.z.any(),
|
|
@@ -636,7 +655,11 @@ var RegisterTriggerSourceSchema = import_zod9.z.object({
|
|
|
636
655
|
channel: RegisterSourceChannelBodySchema,
|
|
637
656
|
clientId: import_zod9.z.string().optional()
|
|
638
657
|
});
|
|
639
|
-
var
|
|
658
|
+
var SourceEventOptionSchema = import_zod9.z.object({
|
|
659
|
+
name: import_zod9.z.string(),
|
|
660
|
+
value: import_zod9.z.string()
|
|
661
|
+
});
|
|
662
|
+
var RegisterSourceEventSchemaV1 = import_zod9.z.object({
|
|
640
663
|
/** The id of the source */
|
|
641
664
|
id: import_zod9.z.string(),
|
|
642
665
|
source: RegisterTriggerSourceSchema,
|
|
@@ -645,15 +668,33 @@ var RegisterSourceEventSchema = import_zod9.z.object({
|
|
|
645
668
|
orphanedEvents: import_zod9.z.array(import_zod9.z.string()),
|
|
646
669
|
dynamicTriggerId: import_zod9.z.string().optional()
|
|
647
670
|
});
|
|
671
|
+
var RegisteredOptionsDiffSchema = import_zod9.z.object({
|
|
672
|
+
desired: import_zod9.z.array(import_zod9.z.string()),
|
|
673
|
+
missing: import_zod9.z.array(import_zod9.z.string()),
|
|
674
|
+
orphaned: import_zod9.z.array(import_zod9.z.string())
|
|
675
|
+
});
|
|
676
|
+
var RegisterSourceEventOptionsSchema = import_zod9.z.object({
|
|
677
|
+
event: RegisteredOptionsDiffSchema
|
|
678
|
+
}).and(import_zod9.z.record(import_zod9.z.string(), RegisteredOptionsDiffSchema));
|
|
679
|
+
var RegisterSourceEventSchemaV2 = import_zod9.z.object({
|
|
680
|
+
/** The id of the source */
|
|
681
|
+
id: import_zod9.z.string(),
|
|
682
|
+
source: RegisterTriggerSourceSchema,
|
|
683
|
+
options: RegisterSourceEventOptionsSchema,
|
|
684
|
+
dynamicTriggerId: import_zod9.z.string().optional()
|
|
685
|
+
});
|
|
648
686
|
var TriggerSourceSchema = import_zod9.z.object({
|
|
649
687
|
id: import_zod9.z.string(),
|
|
650
688
|
key: import_zod9.z.string()
|
|
651
689
|
});
|
|
690
|
+
var HttpSourceResponseMetadataSchema = DeserializedJsonSchema;
|
|
652
691
|
var HandleTriggerSourceSchema = import_zod9.z.object({
|
|
653
692
|
key: import_zod9.z.string(),
|
|
654
693
|
secret: import_zod9.z.string(),
|
|
655
694
|
data: import_zod9.z.any(),
|
|
656
|
-
params: import_zod9.z.any()
|
|
695
|
+
params: import_zod9.z.any(),
|
|
696
|
+
auth: ConnectionAuthSchema.optional(),
|
|
697
|
+
metadata: HttpSourceResponseMetadataSchema.optional()
|
|
657
698
|
});
|
|
658
699
|
var HttpSourceRequestSchema = import_zod9.z.object({
|
|
659
700
|
url: import_zod9.z.string().url(),
|
|
@@ -669,7 +710,19 @@ var HttpSourceRequestHeadersSchema = import_zod9.z.object({
|
|
|
669
710
|
"x-ts-params": import_zod9.z.string().transform((s) => JSON.parse(s)),
|
|
670
711
|
"x-ts-http-url": import_zod9.z.string(),
|
|
671
712
|
"x-ts-http-method": import_zod9.z.string(),
|
|
672
|
-
"x-ts-http-headers": import_zod9.z.string().transform((s) => import_zod9.z.record(import_zod9.z.string()).parse(JSON.parse(s)))
|
|
713
|
+
"x-ts-http-headers": import_zod9.z.string().transform((s) => import_zod9.z.record(import_zod9.z.string()).parse(JSON.parse(s))),
|
|
714
|
+
"x-ts-auth": import_zod9.z.string().optional().transform((s) => {
|
|
715
|
+
if (s === void 0)
|
|
716
|
+
return;
|
|
717
|
+
const json = JSON.parse(s);
|
|
718
|
+
return ConnectionAuthSchema.parse(json);
|
|
719
|
+
}),
|
|
720
|
+
"x-ts-metadata": import_zod9.z.string().optional().transform((s) => {
|
|
721
|
+
if (s === void 0)
|
|
722
|
+
return;
|
|
723
|
+
const json = JSON.parse(s);
|
|
724
|
+
return DeserializedJsonSchema.parse(json);
|
|
725
|
+
})
|
|
673
726
|
});
|
|
674
727
|
var PongSuccessResponseSchema = import_zod9.z.object({
|
|
675
728
|
ok: import_zod9.z.literal(true)
|
|
@@ -713,7 +766,8 @@ var JobMetadataSchema = import_zod9.z.object({
|
|
|
713
766
|
]),
|
|
714
767
|
preprocessRuns: import_zod9.z.boolean()
|
|
715
768
|
});
|
|
716
|
-
var
|
|
769
|
+
var SourceMetadataV1Schema = import_zod9.z.object({
|
|
770
|
+
version: import_zod9.z.literal("1"),
|
|
717
771
|
channel: import_zod9.z.enum([
|
|
718
772
|
"HTTP",
|
|
719
773
|
"SQS",
|
|
@@ -728,6 +782,26 @@ var SourceMetadataSchema = import_zod9.z.object({
|
|
|
728
782
|
version: import_zod9.z.string()
|
|
729
783
|
}).optional()
|
|
730
784
|
});
|
|
785
|
+
var SourceMetadataV2Schema = import_zod9.z.object({
|
|
786
|
+
version: import_zod9.z.literal("2"),
|
|
787
|
+
channel: import_zod9.z.enum([
|
|
788
|
+
"HTTP",
|
|
789
|
+
"SQS",
|
|
790
|
+
"SMTP"
|
|
791
|
+
]),
|
|
792
|
+
integration: IntegrationConfigSchema,
|
|
793
|
+
key: import_zod9.z.string(),
|
|
794
|
+
params: import_zod9.z.any(),
|
|
795
|
+
options: import_zod9.z.record(import_zod9.z.array(import_zod9.z.string())),
|
|
796
|
+
registerSourceJob: import_zod9.z.object({
|
|
797
|
+
id: import_zod9.z.string(),
|
|
798
|
+
version: import_zod9.z.string()
|
|
799
|
+
}).optional()
|
|
800
|
+
});
|
|
801
|
+
var SourceMetadataSchema = import_zod9.z.preprocess(addMissingVersionField, import_zod9.z.discriminatedUnion("version", [
|
|
802
|
+
SourceMetadataV1Schema,
|
|
803
|
+
SourceMetadataV2Schema
|
|
804
|
+
]));
|
|
731
805
|
var DynamicTriggerEndpointMetadataSchema = import_zod9.z.object({
|
|
732
806
|
id: import_zod9.z.string(),
|
|
733
807
|
jobs: import_zod9.z.array(JobMetadataSchema.pick({
|
|
@@ -959,7 +1033,7 @@ var RetryOptionsSchema = import_zod9.z.object({
|
|
|
959
1033
|
});
|
|
960
1034
|
var RunTaskOptionsSchema = import_zod9.z.object({
|
|
961
1035
|
/** The name of the Task is required. This is displayed on the Task in the logs. */
|
|
962
|
-
name: import_zod9.z.string(),
|
|
1036
|
+
name: import_zod9.z.string().optional(),
|
|
963
1037
|
/** The Task will wait and only start at the specified Date */
|
|
964
1038
|
delayUntil: import_zod9.z.coerce.date().optional(),
|
|
965
1039
|
/** Retry options */
|
|
@@ -1020,11 +1094,16 @@ var NormalizedResponseSchema = import_zod9.z.object({
|
|
|
1020
1094
|
});
|
|
1021
1095
|
var HttpSourceResponseSchema = import_zod9.z.object({
|
|
1022
1096
|
response: NormalizedResponseSchema,
|
|
1023
|
-
events: import_zod9.z.array(RawEventSchema)
|
|
1097
|
+
events: import_zod9.z.array(RawEventSchema),
|
|
1098
|
+
metadata: HttpSourceResponseMetadataSchema.optional()
|
|
1099
|
+
});
|
|
1100
|
+
var RegisterTriggerBodySchemaV1 = import_zod9.z.object({
|
|
1101
|
+
rule: EventRuleSchema,
|
|
1102
|
+
source: SourceMetadataV1Schema
|
|
1024
1103
|
});
|
|
1025
|
-
var
|
|
1104
|
+
var RegisterTriggerBodySchemaV2 = import_zod9.z.object({
|
|
1026
1105
|
rule: EventRuleSchema,
|
|
1027
|
-
source:
|
|
1106
|
+
source: SourceMetadataV2Schema
|
|
1028
1107
|
});
|
|
1029
1108
|
var InitializeTriggerBodySchema = import_zod9.z.object({
|
|
1030
1109
|
id: import_zod9.z.string(),
|