@trigger.dev/core 0.0.0-v3-prerelease-20240427071154 → 0.0.0-v3-prerelease-20240501131706

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.
Files changed (35) hide show
  1. package/dist/catalog-XNyNDUOF.d.ts +2496 -0
  2. package/dist/catalog-g2Qc0Ukb.d.mts +2496 -0
  3. package/dist/{catalog-KJXg8k3W.d.ts → messages-vq7Bk4Ap.d.mts} +6725 -554
  4. package/dist/{catalog-PA64uhhi.d.mts → messages-vq7Bk4Ap.d.ts} +6725 -554
  5. package/dist/v3/dev/index.d.mts +1 -1
  6. package/dist/v3/dev/index.d.ts +1 -1
  7. package/dist/v3/dev/index.js.map +1 -1
  8. package/dist/v3/dev/index.mjs.map +1 -1
  9. package/dist/v3/index.d.mts +35 -44
  10. package/dist/v3/index.d.ts +35 -44
  11. package/dist/v3/index.js +367 -341
  12. package/dist/v3/index.js.map +1 -1
  13. package/dist/v3/index.mjs +367 -341
  14. package/dist/v3/index.mjs.map +1 -1
  15. package/dist/v3/otel/index.js +14 -3
  16. package/dist/v3/otel/index.js.map +1 -1
  17. package/dist/v3/otel/index.mjs +14 -3
  18. package/dist/v3/otel/index.mjs.map +1 -1
  19. package/dist/v3/prod/index.d.mts +5 -5
  20. package/dist/v3/prod/index.d.ts +5 -5
  21. package/dist/v3/prod/index.js +36 -12
  22. package/dist/v3/prod/index.js.map +1 -1
  23. package/dist/v3/prod/index.mjs +37 -13
  24. package/dist/v3/prod/index.mjs.map +1 -1
  25. package/dist/v3/workers/index.d.mts +5 -5
  26. package/dist/v3/workers/index.d.ts +5 -5
  27. package/dist/v3/workers/index.js +60 -238
  28. package/dist/v3/workers/index.js.map +1 -1
  29. package/dist/v3/workers/index.mjs +60 -238
  30. package/dist/v3/workers/index.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/messages-AriaDDm0.d.mts +0 -8696
  33. package/dist/messages-AriaDDm0.d.ts +0 -8696
  34. package/dist/{manager-M9GLDnhJ.d.mts → manager-WNMVbgHf.d.mts} +40 -40
  35. package/dist/{manager-M9GLDnhJ.d.ts → manager-WNMVbgHf.d.ts} +40 -40
package/dist/v3/index.js CHANGED
@@ -578,7 +578,7 @@ var BatchTaskRunExecutionResult = zod.z.object({
578
578
  items: TaskRunExecutionResult.array()
579
579
  });
580
580
 
581
- // src/v3/schemas/messages.ts
581
+ // src/v3/schemas/schemas.ts
582
582
  var EnvironmentType = zod.z.enum([
583
583
  "PRODUCTION",
584
584
  "STAGING",
@@ -622,92 +622,6 @@ var ProdTaskRunExecutionPayload = zod.z.object({
622
622
  traceContext: zod.z.record(zod.z.unknown()),
623
623
  environment: zod.z.record(zod.z.string()).optional()
624
624
  });
625
- var BackgroundWorkerServerMessages = zod.z.discriminatedUnion("type", [
626
- zod.z.object({
627
- type: zod.z.literal("EXECUTE_RUNS"),
628
- payloads: zod.z.array(TaskRunExecutionPayload)
629
- }),
630
- zod.z.object({
631
- type: zod.z.literal("CANCEL_ATTEMPT"),
632
- taskAttemptId: zod.z.string(),
633
- taskRunId: zod.z.string()
634
- }),
635
- zod.z.object({
636
- type: zod.z.literal("SCHEDULE_ATTEMPT"),
637
- image: zod.z.string(),
638
- version: zod.z.string(),
639
- machine: Machine,
640
- // identifiers
641
- id: zod.z.string(),
642
- envId: zod.z.string(),
643
- envType: EnvironmentType,
644
- orgId: zod.z.string(),
645
- projectId: zod.z.string(),
646
- runId: zod.z.string()
647
- })
648
- ]);
649
- var serverWebsocketMessages = {
650
- SERVER_READY: zod.z.object({
651
- version: zod.z.literal("v1").default("v1"),
652
- id: zod.z.string()
653
- }),
654
- BACKGROUND_WORKER_MESSAGE: zod.z.object({
655
- version: zod.z.literal("v1").default("v1"),
656
- backgroundWorkerId: zod.z.string(),
657
- data: BackgroundWorkerServerMessages
658
- })
659
- };
660
- var BackgroundWorkerClientMessages = zod.z.discriminatedUnion("type", [
661
- zod.z.object({
662
- version: zod.z.literal("v1").default("v1"),
663
- type: zod.z.literal("TASK_RUN_COMPLETED"),
664
- completion: TaskRunExecutionResult,
665
- execution: TaskRunExecution
666
- }),
667
- zod.z.object({
668
- version: zod.z.literal("v1").default("v1"),
669
- type: zod.z.literal("TASK_HEARTBEAT"),
670
- id: zod.z.string()
671
- })
672
- ]);
673
- var BackgroundWorkerProperties = zod.z.object({
674
- id: zod.z.string(),
675
- version: zod.z.string(),
676
- contentHash: zod.z.string()
677
- });
678
- var clientWebsocketMessages = {
679
- READY_FOR_TASKS: zod.z.object({
680
- version: zod.z.literal("v1").default("v1"),
681
- backgroundWorkerId: zod.z.string()
682
- }),
683
- BACKGROUND_WORKER_DEPRECATED: zod.z.object({
684
- version: zod.z.literal("v1").default("v1"),
685
- backgroundWorkerId: zod.z.string()
686
- }),
687
- BACKGROUND_WORKER_MESSAGE: zod.z.object({
688
- version: zod.z.literal("v1").default("v1"),
689
- backgroundWorkerId: zod.z.string(),
690
- data: BackgroundWorkerClientMessages
691
- })
692
- };
693
- var workerToChildMessages = {
694
- EXECUTE_TASK_RUN: zod.z.object({
695
- version: zod.z.literal("v1").default("v1"),
696
- execution: TaskRunExecution,
697
- traceContext: zod.z.record(zod.z.unknown()),
698
- metadata: BackgroundWorkerProperties
699
- }),
700
- TASK_RUN_COMPLETED_NOTIFICATION: zod.z.object({
701
- version: zod.z.literal("v1").default("v1"),
702
- completion: TaskRunExecutionResult,
703
- execution: TaskRunExecution
704
- }),
705
- CLEANUP: zod.z.object({
706
- version: zod.z.literal("v1").default("v1"),
707
- flush: zod.z.boolean().default(false),
708
- kill: zod.z.boolean().default(true)
709
- })
710
- };
711
625
  var FixedWindowRateLimit = zod.z.object({
712
626
  type: zod.z.literal("fixed-window"),
713
627
  limit: zod.z.number(),
@@ -813,149 +727,46 @@ var TaskFileMetadata = zod.z.object({
813
727
  exportName: zod.z.string()
814
728
  });
815
729
  var TaskMetadataWithFilePath = TaskMetadata.merge(TaskFileMetadata);
816
- var UncaughtExceptionMessage = zod.z.object({
817
- version: zod.z.literal("v1").default("v1"),
818
- error: zod.z.object({
819
- name: zod.z.string(),
820
- message: zod.z.string(),
821
- stack: zod.z.string().optional()
822
- }),
823
- origin: zod.z.enum([
824
- "uncaughtException",
825
- "unhandledRejection"
826
- ])
730
+ var PostStartCauses = zod.z.enum([
731
+ "index",
732
+ "create",
733
+ "restore"
734
+ ]);
735
+ var PreStopCauses = zod.z.enum([
736
+ "terminate"
737
+ ]);
738
+ var RegexSchema = zod.z.custom((val) => {
739
+ try {
740
+ return typeof val.test === "function";
741
+ } catch {
742
+ return false;
743
+ }
827
744
  });
828
- var TaskMetadataFailedToParseData = zod.z.object({
829
- version: zod.z.literal("v1").default("v1"),
830
- tasks: zod.z.unknown(),
831
- zodIssues: zod.z.custom((v) => {
832
- return Array.isArray(v) && v.every((issue) => typeof issue === "object" && "message" in issue);
833
- })
745
+ var Config = zod.z.object({
746
+ project: zod.z.string(),
747
+ triggerDirectories: zod.z.string().array().optional(),
748
+ triggerUrl: zod.z.string().optional(),
749
+ projectDir: zod.z.string().optional(),
750
+ tsconfigPath: zod.z.string().optional(),
751
+ retries: zod.z.object({
752
+ enabledInDev: zod.z.boolean().default(true),
753
+ default: RetryOptions.optional()
754
+ }).optional(),
755
+ additionalPackages: zod.z.string().array().optional(),
756
+ additionalFiles: zod.z.string().array().optional(),
757
+ dependenciesToBundle: zod.z.array(zod.z.union([
758
+ zod.z.string(),
759
+ RegexSchema
760
+ ])).optional(),
761
+ logLevel: zod.z.string().optional(),
762
+ enableConsoleLogging: zod.z.boolean().optional(),
763
+ postInstall: zod.z.string().optional()
834
764
  });
835
- var childToWorkerMessages = {
836
- TASK_RUN_COMPLETED: zod.z.object({
837
- version: zod.z.literal("v1").default("v1"),
838
- execution: TaskRunExecution,
839
- result: TaskRunExecutionResult
840
- }),
841
- TASKS_READY: zod.z.object({
842
- version: zod.z.literal("v1").default("v1"),
843
- tasks: TaskMetadataWithFilePath.array()
844
- }),
845
- TASKS_FAILED_TO_PARSE: TaskMetadataFailedToParseData,
846
- TASK_HEARTBEAT: zod.z.object({
847
- version: zod.z.literal("v1").default("v1"),
848
- id: zod.z.string()
849
- }),
850
- READY_TO_DISPOSE: zod.z.undefined(),
851
- WAIT_FOR_DURATION: zod.z.object({
852
- version: zod.z.literal("v1").default("v1"),
853
- ms: zod.z.number()
854
- }),
855
- WAIT_FOR_TASK: zod.z.object({
856
- version: zod.z.literal("v1").default("v1"),
857
- id: zod.z.string()
858
- }),
859
- WAIT_FOR_BATCH: zod.z.object({
860
- version: zod.z.literal("v1").default("v1"),
861
- id: zod.z.string(),
862
- runs: zod.z.string().array()
863
- }),
864
- UNCAUGHT_EXCEPTION: UncaughtExceptionMessage
865
- };
866
- var ProdChildToWorkerMessages = {
867
- TASK_RUN_COMPLETED: {
868
- message: zod.z.object({
869
- version: zod.z.literal("v1").default("v1"),
870
- execution: TaskRunExecution,
871
- result: TaskRunExecutionResult
872
- })
873
- },
874
- TASKS_READY: {
875
- message: zod.z.object({
876
- version: zod.z.literal("v1").default("v1"),
877
- tasks: TaskMetadataWithFilePath.array()
878
- })
879
- },
880
- TASKS_FAILED_TO_PARSE: {
881
- message: TaskMetadataFailedToParseData
882
- },
883
- TASK_HEARTBEAT: {
884
- message: zod.z.object({
885
- version: zod.z.literal("v1").default("v1"),
886
- id: zod.z.string()
887
- })
888
- },
889
- READY_TO_DISPOSE: {
890
- message: zod.z.undefined()
891
- },
892
- READY_FOR_CHECKPOINT: {
893
- message: zod.z.object({
894
- version: zod.z.literal("v1").default("v1")
895
- })
896
- },
897
- CANCEL_CHECKPOINT: {
898
- message: zod.z.object({
899
- version: zod.z.literal("v1").default("v1")
900
- })
901
- },
902
- WAIT_FOR_DURATION: {
903
- message: zod.z.object({
904
- version: zod.z.literal("v1").default("v1"),
905
- ms: zod.z.number(),
906
- now: zod.z.number()
907
- }),
908
- callback: zod.z.object({
909
- willCheckpointAndRestore: zod.z.boolean()
910
- })
911
- },
912
- WAIT_FOR_TASK: {
913
- message: zod.z.object({
914
- version: zod.z.literal("v1").default("v1"),
915
- friendlyId: zod.z.string()
916
- })
917
- },
918
- WAIT_FOR_BATCH: {
919
- message: zod.z.object({
920
- version: zod.z.literal("v1").default("v1"),
921
- batchFriendlyId: zod.z.string(),
922
- runFriendlyIds: zod.z.string().array()
923
- })
924
- },
925
- UNCAUGHT_EXCEPTION: {
926
- message: UncaughtExceptionMessage
927
- }
928
- };
929
- var ProdWorkerToChildMessages = {
930
- EXECUTE_TASK_RUN: {
931
- message: zod.z.object({
932
- version: zod.z.literal("v1").default("v1"),
933
- execution: TaskRunExecution,
934
- traceContext: zod.z.record(zod.z.unknown()),
935
- metadata: BackgroundWorkerProperties
936
- })
937
- },
938
- TASK_RUN_COMPLETED_NOTIFICATION: {
939
- message: zod.z.object({
940
- version: zod.z.literal("v1").default("v1"),
941
- completion: TaskRunExecutionResult,
942
- execution: TaskRunExecution
943
- })
944
- },
945
- CLEANUP: {
946
- message: zod.z.object({
947
- version: zod.z.literal("v1").default("v1"),
948
- flush: zod.z.boolean().default(false),
949
- kill: zod.z.boolean().default(true)
950
- }),
951
- callback: zod.z.void()
952
- },
953
- WAIT_COMPLETED_NOTIFICATION: {
954
- message: zod.z.object({
955
- version: zod.z.literal("v1").default("v1")
956
- })
957
- }
958
- };
765
+ var WaitReason = zod.z.enum([
766
+ "WAIT_FOR_DURATION",
767
+ "WAIT_FOR_TASK",
768
+ "WAIT_FOR_BATCH"
769
+ ]);
959
770
 
960
771
  // src/v3/schemas/resources.ts
961
772
  var TaskResource = zod.z.object({
@@ -1054,8 +865,7 @@ var GetEnvironmentVariablesResponseBody = zod.z.object({
1054
865
  variables: zod.z.record(zod.z.string())
1055
866
  });
1056
867
  var StartDeploymentIndexingRequestBody = zod.z.object({
1057
- imageReference: zod.z.string(),
1058
- selfHosted: zod.z.boolean().optional()
868
+ imageReference: zod.z.string()
1059
869
  });
1060
870
  var StartDeploymentIndexingResponseBody = zod.z.object({
1061
871
  id: zod.z.string(),
@@ -1179,67 +989,271 @@ var ScheduleObject = zod.z.object({
1179
989
  expression: zod.z.string(),
1180
990
  description: zod.z.string()
1181
991
  }),
1182
- nextRun: zod.z.coerce.date().nullish(),
1183
- environments: zod.z.array(zod.z.object({
1184
- id: zod.z.string(),
1185
- type: zod.z.string(),
1186
- userName: zod.z.string().nullish()
1187
- }))
1188
- });
1189
- var DeletedScheduleObject = zod.z.object({
1190
- id: zod.z.string()
1191
- });
1192
- var ListSchedulesResult = zod.z.object({
1193
- data: zod.z.array(ScheduleObject),
1194
- pagination: zod.z.object({
1195
- currentPage: zod.z.number(),
1196
- totalPages: zod.z.number(),
1197
- count: zod.z.number()
992
+ nextRun: zod.z.coerce.date().nullish(),
993
+ environments: zod.z.array(zod.z.object({
994
+ id: zod.z.string(),
995
+ type: zod.z.string(),
996
+ userName: zod.z.string().nullish()
997
+ }))
998
+ });
999
+ var DeletedScheduleObject = zod.z.object({
1000
+ id: zod.z.string()
1001
+ });
1002
+ var ListSchedulesResult = zod.z.object({
1003
+ data: zod.z.array(ScheduleObject),
1004
+ pagination: zod.z.object({
1005
+ currentPage: zod.z.number(),
1006
+ totalPages: zod.z.number(),
1007
+ count: zod.z.number()
1008
+ })
1009
+ });
1010
+ var ListScheduleOptions = zod.z.object({
1011
+ page: zod.z.number().optional(),
1012
+ perPage: zod.z.number().optional()
1013
+ });
1014
+ var BackgroundWorkerServerMessages = zod.z.discriminatedUnion("type", [
1015
+ zod.z.object({
1016
+ type: zod.z.literal("EXECUTE_RUNS"),
1017
+ payloads: zod.z.array(TaskRunExecutionPayload)
1018
+ }),
1019
+ zod.z.object({
1020
+ type: zod.z.literal("CANCEL_ATTEMPT"),
1021
+ taskAttemptId: zod.z.string(),
1022
+ taskRunId: zod.z.string()
1023
+ }),
1024
+ zod.z.object({
1025
+ type: zod.z.literal("SCHEDULE_ATTEMPT"),
1026
+ image: zod.z.string(),
1027
+ version: zod.z.string(),
1028
+ machine: Machine,
1029
+ // identifiers
1030
+ id: zod.z.string(),
1031
+ envId: zod.z.string(),
1032
+ envType: EnvironmentType,
1033
+ orgId: zod.z.string(),
1034
+ projectId: zod.z.string(),
1035
+ runId: zod.z.string()
1036
+ })
1037
+ ]);
1038
+ var serverWebsocketMessages = {
1039
+ SERVER_READY: zod.z.object({
1040
+ version: zod.z.literal("v1").default("v1"),
1041
+ id: zod.z.string()
1042
+ }),
1043
+ BACKGROUND_WORKER_MESSAGE: zod.z.object({
1044
+ version: zod.z.literal("v1").default("v1"),
1045
+ backgroundWorkerId: zod.z.string(),
1046
+ data: BackgroundWorkerServerMessages
1047
+ })
1048
+ };
1049
+ var BackgroundWorkerClientMessages = zod.z.discriminatedUnion("type", [
1050
+ zod.z.object({
1051
+ version: zod.z.literal("v1").default("v1"),
1052
+ type: zod.z.literal("TASK_RUN_COMPLETED"),
1053
+ completion: TaskRunExecutionResult,
1054
+ execution: TaskRunExecution
1055
+ }),
1056
+ zod.z.object({
1057
+ version: zod.z.literal("v1").default("v1"),
1058
+ type: zod.z.literal("TASK_HEARTBEAT"),
1059
+ id: zod.z.string()
1060
+ })
1061
+ ]);
1062
+ var BackgroundWorkerProperties = zod.z.object({
1063
+ id: zod.z.string(),
1064
+ version: zod.z.string(),
1065
+ contentHash: zod.z.string()
1066
+ });
1067
+ var clientWebsocketMessages = {
1068
+ READY_FOR_TASKS: zod.z.object({
1069
+ version: zod.z.literal("v1").default("v1"),
1070
+ backgroundWorkerId: zod.z.string()
1071
+ }),
1072
+ BACKGROUND_WORKER_DEPRECATED: zod.z.object({
1073
+ version: zod.z.literal("v1").default("v1"),
1074
+ backgroundWorkerId: zod.z.string()
1075
+ }),
1076
+ BACKGROUND_WORKER_MESSAGE: zod.z.object({
1077
+ version: zod.z.literal("v1").default("v1"),
1078
+ backgroundWorkerId: zod.z.string(),
1079
+ data: BackgroundWorkerClientMessages
1080
+ })
1081
+ };
1082
+ var workerToChildMessages = {
1083
+ EXECUTE_TASK_RUN: zod.z.object({
1084
+ version: zod.z.literal("v1").default("v1"),
1085
+ execution: TaskRunExecution,
1086
+ traceContext: zod.z.record(zod.z.unknown()),
1087
+ metadata: BackgroundWorkerProperties
1088
+ }),
1089
+ TASK_RUN_COMPLETED_NOTIFICATION: zod.z.object({
1090
+ version: zod.z.literal("v1").default("v1"),
1091
+ completion: TaskRunExecutionResult,
1092
+ execution: TaskRunExecution
1093
+ }),
1094
+ CLEANUP: zod.z.object({
1095
+ version: zod.z.literal("v1").default("v1"),
1096
+ flush: zod.z.boolean().default(false),
1097
+ kill: zod.z.boolean().default(true)
1198
1098
  })
1099
+ };
1100
+ var UncaughtExceptionMessage = zod.z.object({
1101
+ version: zod.z.literal("v1").default("v1"),
1102
+ error: zod.z.object({
1103
+ name: zod.z.string(),
1104
+ message: zod.z.string(),
1105
+ stack: zod.z.string().optional()
1106
+ }),
1107
+ origin: zod.z.enum([
1108
+ "uncaughtException",
1109
+ "unhandledRejection"
1110
+ ])
1199
1111
  });
1200
- var ListScheduleOptions = zod.z.object({
1201
- page: zod.z.number().optional(),
1202
- perPage: zod.z.number().optional()
1112
+ var TaskMetadataFailedToParseData = zod.z.object({
1113
+ version: zod.z.literal("v1").default("v1"),
1114
+ tasks: zod.z.unknown(),
1115
+ zodIssues: zod.z.custom((v) => {
1116
+ return Array.isArray(v) && v.every((issue) => typeof issue === "object" && "message" in issue);
1117
+ })
1203
1118
  });
1204
- var PostStartCauses = zod.z.enum([
1205
- "index",
1206
- "create",
1207
- "restore"
1208
- ]);
1209
- var PreStopCauses = zod.z.enum([
1210
- "terminate"
1211
- ]);
1212
- var RegexSchema = zod.z.custom((val) => {
1213
- try {
1214
- return typeof val.test === "function";
1215
- } catch {
1216
- return false;
1119
+ var childToWorkerMessages = {
1120
+ TASK_RUN_COMPLETED: zod.z.object({
1121
+ version: zod.z.literal("v1").default("v1"),
1122
+ execution: TaskRunExecution,
1123
+ result: TaskRunExecutionResult
1124
+ }),
1125
+ TASKS_READY: zod.z.object({
1126
+ version: zod.z.literal("v1").default("v1"),
1127
+ tasks: TaskMetadataWithFilePath.array()
1128
+ }),
1129
+ TASKS_FAILED_TO_PARSE: TaskMetadataFailedToParseData,
1130
+ TASK_HEARTBEAT: zod.z.object({
1131
+ version: zod.z.literal("v1").default("v1"),
1132
+ id: zod.z.string()
1133
+ }),
1134
+ READY_TO_DISPOSE: zod.z.undefined(),
1135
+ WAIT_FOR_DURATION: zod.z.object({
1136
+ version: zod.z.literal("v1").default("v1"),
1137
+ ms: zod.z.number()
1138
+ }),
1139
+ WAIT_FOR_TASK: zod.z.object({
1140
+ version: zod.z.literal("v1").default("v1"),
1141
+ id: zod.z.string()
1142
+ }),
1143
+ WAIT_FOR_BATCH: zod.z.object({
1144
+ version: zod.z.literal("v1").default("v1"),
1145
+ id: zod.z.string(),
1146
+ runs: zod.z.string().array()
1147
+ }),
1148
+ UNCAUGHT_EXCEPTION: UncaughtExceptionMessage
1149
+ };
1150
+ var ProdChildToWorkerMessages = {
1151
+ TASK_RUN_COMPLETED: {
1152
+ message: zod.z.object({
1153
+ version: zod.z.literal("v1").default("v1"),
1154
+ execution: TaskRunExecution,
1155
+ result: TaskRunExecutionResult
1156
+ })
1157
+ },
1158
+ TASKS_READY: {
1159
+ message: zod.z.object({
1160
+ version: zod.z.literal("v1").default("v1"),
1161
+ tasks: TaskMetadataWithFilePath.array()
1162
+ })
1163
+ },
1164
+ TASKS_FAILED_TO_PARSE: {
1165
+ message: TaskMetadataFailedToParseData
1166
+ },
1167
+ TASK_HEARTBEAT: {
1168
+ message: zod.z.object({
1169
+ version: zod.z.literal("v1").default("v1"),
1170
+ id: zod.z.string()
1171
+ })
1172
+ },
1173
+ READY_TO_DISPOSE: {
1174
+ message: zod.z.undefined()
1175
+ },
1176
+ READY_FOR_CHECKPOINT: {
1177
+ message: zod.z.object({
1178
+ version: zod.z.literal("v1").default("v1")
1179
+ })
1180
+ },
1181
+ CANCEL_CHECKPOINT: {
1182
+ message: zod.z.discriminatedUnion("version", [
1183
+ zod.z.object({
1184
+ version: zod.z.literal("v1")
1185
+ }),
1186
+ zod.z.object({
1187
+ version: zod.z.literal("v2"),
1188
+ reason: WaitReason.optional()
1189
+ })
1190
+ ]).default({
1191
+ version: "v1"
1192
+ }),
1193
+ callback: zod.z.object({
1194
+ // TODO: Figure out how best to handle callback schema parsing in zod IPC
1195
+ version: zod.z.literal("v2"),
1196
+ checkpointCanceled: zod.z.boolean(),
1197
+ reason: WaitReason.optional()
1198
+ })
1199
+ },
1200
+ WAIT_FOR_DURATION: {
1201
+ message: zod.z.object({
1202
+ version: zod.z.literal("v1").default("v1"),
1203
+ ms: zod.z.number(),
1204
+ now: zod.z.number()
1205
+ }),
1206
+ callback: zod.z.object({
1207
+ willCheckpointAndRestore: zod.z.boolean()
1208
+ })
1209
+ },
1210
+ WAIT_FOR_TASK: {
1211
+ message: zod.z.object({
1212
+ version: zod.z.literal("v1").default("v1"),
1213
+ friendlyId: zod.z.string()
1214
+ })
1215
+ },
1216
+ WAIT_FOR_BATCH: {
1217
+ message: zod.z.object({
1218
+ version: zod.z.literal("v1").default("v1"),
1219
+ batchFriendlyId: zod.z.string(),
1220
+ runFriendlyIds: zod.z.string().array()
1221
+ })
1222
+ },
1223
+ UNCAUGHT_EXCEPTION: {
1224
+ message: UncaughtExceptionMessage
1217
1225
  }
1218
- });
1219
- var Config = zod.z.object({
1220
- project: zod.z.string(),
1221
- triggerDirectories: zod.z.string().array().optional(),
1222
- triggerUrl: zod.z.string().optional(),
1223
- projectDir: zod.z.string().optional(),
1224
- tsconfigPath: zod.z.string().optional(),
1225
- retries: zod.z.object({
1226
- enabledInDev: zod.z.boolean().default(true),
1227
- default: RetryOptions.optional()
1228
- }).optional(),
1229
- additionalPackages: zod.z.string().array().optional(),
1230
- additionalFiles: zod.z.string().array().optional(),
1231
- dependenciesToBundle: zod.z.array(zod.z.union([
1232
- zod.z.string(),
1233
- RegexSchema
1234
- ])).optional(),
1235
- logLevel: zod.z.string().optional(),
1236
- enableConsoleLogging: zod.z.boolean().optional()
1237
- });
1238
- var WaitReason = zod.z.enum([
1239
- "WAIT_FOR_DURATION",
1240
- "WAIT_FOR_TASK",
1241
- "WAIT_FOR_BATCH"
1242
- ]);
1226
+ };
1227
+ var ProdWorkerToChildMessages = {
1228
+ EXECUTE_TASK_RUN: {
1229
+ message: zod.z.object({
1230
+ version: zod.z.literal("v1").default("v1"),
1231
+ execution: TaskRunExecution,
1232
+ traceContext: zod.z.record(zod.z.unknown()),
1233
+ metadata: BackgroundWorkerProperties
1234
+ })
1235
+ },
1236
+ TASK_RUN_COMPLETED_NOTIFICATION: {
1237
+ message: zod.z.object({
1238
+ version: zod.z.literal("v1").default("v1"),
1239
+ completion: TaskRunExecutionResult,
1240
+ execution: TaskRunExecution
1241
+ })
1242
+ },
1243
+ CLEANUP: {
1244
+ message: zod.z.object({
1245
+ version: zod.z.literal("v1").default("v1"),
1246
+ flush: zod.z.boolean().default(false),
1247
+ kill: zod.z.boolean().default(true)
1248
+ }),
1249
+ callback: zod.z.void()
1250
+ },
1251
+ WAIT_COMPLETED_NOTIFICATION: {
1252
+ message: zod.z.object({
1253
+ version: zod.z.literal("v1").default("v1")
1254
+ })
1255
+ }
1256
+ };
1243
1257
  var ProviderToPlatformMessages = {
1244
1258
  LOG: {
1245
1259
  message: zod.z.object({
@@ -1574,8 +1588,21 @@ var ProdWorkerToCoordinatorMessages = {
1574
1588
  })
1575
1589
  },
1576
1590
  CANCEL_CHECKPOINT: {
1577
- message: zod.z.object({
1578
- version: zod.z.literal("v1").default("v1")
1591
+ message: zod.z.discriminatedUnion("version", [
1592
+ zod.z.object({
1593
+ version: zod.z.literal("v1")
1594
+ }),
1595
+ zod.z.object({
1596
+ version: zod.z.literal("v2"),
1597
+ reason: WaitReason.optional()
1598
+ })
1599
+ ]).default({
1600
+ version: "v1"
1601
+ }),
1602
+ callback: zod.z.object({
1603
+ version: zod.z.literal("v2").default("v2"),
1604
+ checkpointCanceled: zod.z.boolean(),
1605
+ reason: WaitReason.optional()
1579
1606
  })
1580
1607
  },
1581
1608
  TASK_HEARTBEAT: {
@@ -2340,33 +2367,6 @@ function createErrorTaskError(error) {
2340
2367
  }
2341
2368
  }
2342
2369
  __name(createErrorTaskError, "createErrorTaskError");
2343
- function createJsonErrorObject(error) {
2344
- switch (error.type) {
2345
- case "BUILT_IN_ERROR": {
2346
- return {
2347
- name: error.name,
2348
- message: error.message,
2349
- stackTrace: error.stackTrace
2350
- };
2351
- }
2352
- case "STRING_ERROR": {
2353
- return {
2354
- message: error.raw
2355
- };
2356
- }
2357
- case "CUSTOM_ERROR": {
2358
- return {
2359
- message: error.raw
2360
- };
2361
- }
2362
- case "INTERNAL_ERROR": {
2363
- return {
2364
- message: `trigger.dev internal error (${error.code})`
2365
- };
2366
- }
2367
- }
2368
- }
2369
- __name(createJsonErrorObject, "createJsonErrorObject");
2370
2370
  function correctErrorStackTrace(stackTrace, projectDir, options) {
2371
2371
  const [errorLine, ...traceLines] = stackTrace.split("\n");
2372
2372
  return [
@@ -2475,9 +2475,14 @@ function calculateAttributeValueLength(value) {
2475
2475
  __name(calculateAttributeValueLength, "calculateAttributeValueLength");
2476
2476
 
2477
2477
  // src/v3/utils/flattenAttributes.ts
2478
+ var NULL_SENTINEL = "$@null((";
2478
2479
  function flattenAttributes(obj, prefix) {
2479
2480
  const result = {};
2480
- if (!obj) {
2481
+ if (obj === void 0) {
2482
+ return result;
2483
+ }
2484
+ if (obj === null) {
2485
+ result[prefix || ""] = NULL_SENTINEL;
2481
2486
  return result;
2482
2487
  }
2483
2488
  if (typeof obj === "string") {
@@ -2493,13 +2498,17 @@ function flattenAttributes(obj, prefix) {
2493
2498
  return result;
2494
2499
  }
2495
2500
  for (const [key, value] of Object.entries(obj)) {
2496
- const newPrefix = `${prefix ? `${prefix}.` : ""}${key}`;
2501
+ const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
2497
2502
  if (Array.isArray(value)) {
2498
2503
  for (let i = 0; i < value.length; i++) {
2499
2504
  if (typeof value[i] === "object" && value[i] !== null) {
2500
2505
  Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
2501
2506
  } else {
2502
- result[`${newPrefix}.[${i}]`] = value[i];
2507
+ if (value[i] === null) {
2508
+ result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
2509
+ } else {
2510
+ result[`${newPrefix}.[${i}]`] = value[i];
2511
+ }
2503
2512
  }
2504
2513
  }
2505
2514
  } else if (isRecord(value)) {
@@ -2507,6 +2516,8 @@ function flattenAttributes(obj, prefix) {
2507
2516
  } else {
2508
2517
  if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
2509
2518
  result[newPrefix] = value;
2519
+ } else if (value === null) {
2520
+ result[newPrefix] = NULL_SENTINEL;
2510
2521
  }
2511
2522
  }
2512
2523
  }
@@ -2521,42 +2532,49 @@ function unflattenAttributes(obj) {
2521
2532
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
2522
2533
  return obj;
2523
2534
  }
2535
+ if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
2536
+ return rehydrateNull(obj[""]);
2537
+ }
2538
+ if (Object.keys(obj).length === 0) {
2539
+ return;
2540
+ }
2524
2541
  const result = {};
2525
2542
  for (const [key, value] of Object.entries(obj)) {
2526
2543
  const parts = key.split(".").reduce((acc, part) => {
2527
- if (detectIsArrayIndex(part)) {
2528
- acc.push(part);
2544
+ if (part.includes("[")) {
2545
+ const subparts = part.split(/\[|\]/).filter((p) => p !== "");
2546
+ acc.push(...subparts);
2529
2547
  } else {
2530
- acc.push(...part.split(/\.\[(.*?)\]/).filter(Boolean));
2548
+ acc.push(part);
2531
2549
  }
2532
2550
  return acc;
2533
2551
  }, []);
2534
2552
  let current = result;
2535
2553
  for (let i = 0; i < parts.length - 1; i++) {
2536
2554
  const part = parts[i];
2537
- const isArray = detectIsArrayIndex(part);
2538
- const cleanPart = isArray ? part.substring(1, part.length - 1) : part;
2539
- const nextIsArray = detectIsArrayIndex(parts[i + 1]);
2540
- if (!current[cleanPart]) {
2541
- current[cleanPart] = nextIsArray ? [] : {};
2555
+ const nextPart = parts[i + 1];
2556
+ const isArray = /^\d+$/.test(nextPart);
2557
+ if (isArray && !Array.isArray(current[part])) {
2558
+ current[part] = [];
2559
+ } else if (!isArray && current[part] === void 0) {
2560
+ current[part] = {};
2542
2561
  }
2543
- current = current[cleanPart];
2562
+ current = current[part];
2544
2563
  }
2545
2564
  const lastPart = parts[parts.length - 1];
2546
- const cleanLastPart = detectIsArrayIndex(lastPart) ? parseInt(lastPart.substring(1, lastPart.length - 1), 10) : lastPart;
2547
- current[cleanLastPart] = value;
2565
+ current[lastPart] = rehydrateNull(value);
2566
+ }
2567
+ if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
2568
+ const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
2569
+ const arrayResult = Array(maxIndex + 1);
2570
+ for (const key in result) {
2571
+ arrayResult[parseInt(key)] = result[key];
2572
+ }
2573
+ return arrayResult;
2548
2574
  }
2549
2575
  return result;
2550
2576
  }
2551
2577
  __name(unflattenAttributes, "unflattenAttributes");
2552
- function detectIsArrayIndex(key) {
2553
- const match = key.match(/^\[(\d+)\]$/);
2554
- if (match) {
2555
- return true;
2556
- }
2557
- return false;
2558
- }
2559
- __name(detectIsArrayIndex, "detectIsArrayIndex");
2560
2578
  function primitiveValueOrflattenedAttributes(obj, prefix) {
2561
2579
  if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
2562
2580
  return obj;
@@ -2568,6 +2586,13 @@ function primitiveValueOrflattenedAttributes(obj, prefix) {
2568
2586
  return attributes;
2569
2587
  }
2570
2588
  __name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
2589
+ function rehydrateNull(value) {
2590
+ if (value === NULL_SENTINEL) {
2591
+ return null;
2592
+ }
2593
+ return value;
2594
+ }
2595
+ __name(rehydrateNull, "rehydrateNull");
2571
2596
 
2572
2597
  // src/v3/logger/taskLogger.ts
2573
2598
  var _NoopTaskLogger = class _NoopTaskLogger {
@@ -3296,11 +3321,12 @@ async function createPacketAttributes(packet, dataKey, dataTypeKey) {
3296
3321
  try {
3297
3322
  const parsed = parse(packet.data);
3298
3323
  const jsonified = JSON.parse(JSON.stringify(parsed, safeReplacer));
3299
- return {
3324
+ const result = {
3300
3325
  ...flattenAttributes(jsonified, dataKey),
3301
3326
  [dataTypeKey]: "application/json"
3302
3327
  };
3303
- } catch {
3328
+ return result;
3329
+ } catch (e) {
3304
3330
  return;
3305
3331
  }
3306
3332
  case "application/store":
@@ -3462,6 +3488,7 @@ exports.ListSchedulesResult = ListSchedulesResult;
3462
3488
  exports.Machine = Machine;
3463
3489
  exports.MachineCpu = MachineCpu;
3464
3490
  exports.MachineMemory = MachineMemory;
3491
+ exports.NULL_SENTINEL = NULL_SENTINEL;
3465
3492
  exports.NotFoundError = NotFoundError;
3466
3493
  exports.OFFLOAD_IO_PACKET_LENGTH_LIMIT = OFFLOAD_IO_PACKET_LENGTH_LIMIT;
3467
3494
  exports.OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT = OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT;
@@ -3547,7 +3574,6 @@ exports.conditionallyExportPacket = conditionallyExportPacket;
3547
3574
  exports.conditionallyImportPacket = conditionallyImportPacket;
3548
3575
  exports.correctErrorStackTrace = correctErrorStackTrace;
3549
3576
  exports.createErrorTaskError = createErrorTaskError;
3550
- exports.createJsonErrorObject = createJsonErrorObject;
3551
3577
  exports.createPacketAttributes = createPacketAttributes;
3552
3578
  exports.createPacketAttributesAsJson = createPacketAttributesAsJson;
3553
3579
  exports.defaultFetchRetryOptions = defaultFetchRetryOptions;