@trigger.dev/core 3.0.0-beta.35 → 3.0.0-beta.36

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 (37) hide show
  1. package/dist/{catalog-BUwiuDbt.d.mts → catalog-XTlJQaMn.d.mts} +3 -3
  2. package/dist/{catalog-eKgqBHUA.d.ts → catalog-dRKTgwQ7.d.ts} +3 -3
  3. package/dist/{manager-uPyMRN8k.d.mts → manager-JkbddlcO.d.mts} +19 -19
  4. package/dist/{manager-uPyMRN8k.d.ts → manager-JkbddlcO.d.ts} +19 -19
  5. package/dist/{messages-l9PdIyKF.d.mts → messages-6_-q72KG.d.mts} +119 -119
  6. package/dist/{messages-l9PdIyKF.d.ts → messages-6_-q72KG.d.ts} +119 -119
  7. package/dist/{schemas-b8tRw8dX.d.mts → schemas-r4ZP9S-F.d.mts} +2 -2
  8. package/dist/{schemas-b8tRw8dX.d.ts → schemas-r4ZP9S-F.d.ts} +2 -2
  9. package/dist/v3/dev/index.d.mts +1 -1
  10. package/dist/v3/dev/index.d.ts +1 -1
  11. package/dist/v3/index.d.mts +579 -122
  12. package/dist/v3/index.d.ts +579 -122
  13. package/dist/v3/index.js +739 -319
  14. package/dist/v3/index.js.map +1 -1
  15. package/dist/v3/index.mjs +730 -318
  16. package/dist/v3/index.mjs.map +1 -1
  17. package/dist/v3/otel/index.js +1 -1
  18. package/dist/v3/otel/index.js.map +1 -1
  19. package/dist/v3/otel/index.mjs +1 -1
  20. package/dist/v3/otel/index.mjs.map +1 -1
  21. package/dist/v3/prod/index.d.mts +2 -2
  22. package/dist/v3/prod/index.d.ts +2 -2
  23. package/dist/v3/workers/index.d.mts +6 -6
  24. package/dist/v3/workers/index.d.ts +6 -6
  25. package/dist/v3/workers/index.js +463 -51
  26. package/dist/v3/workers/index.js.map +1 -1
  27. package/dist/v3/workers/index.mjs +463 -51
  28. package/dist/v3/workers/index.mjs.map +1 -1
  29. package/dist/v3/zodMessageHandler.d.mts +1 -1
  30. package/dist/v3/zodMessageHandler.d.ts +1 -1
  31. package/dist/v3/zodfetch.d.mts +194 -10
  32. package/dist/v3/zodfetch.d.ts +194 -10
  33. package/dist/v3/zodfetch.js +336 -38
  34. package/dist/v3/zodfetch.js.map +1 -1
  35. package/dist/v3/zodfetch.mjs +320 -37
  36. package/dist/v3/zodfetch.mjs.map +1 -1
  37. package/package.json +1 -1
package/dist/v3/index.js CHANGED
@@ -35,7 +35,7 @@ var __privateMethod = (obj, member, method) => {
35
35
  };
36
36
 
37
37
  // package.json
38
- var version = "3.0.0-beta.35";
38
+ var version = "3.0.0-beta.36";
39
39
  var dependencies = {
40
40
  "@google-cloud/precise-date": "^4.0.0",
41
41
  "@opentelemetry/api": "^1.8.0",
@@ -58,144 +58,6 @@ var dependencies = {
58
58
  "zod-error": "1.5.0",
59
59
  "zod-validation-error": "^1.5.0"
60
60
  };
61
-
62
- // src/v3/apiErrors.ts
63
- var _APIError = class _APIError extends Error {
64
- constructor(status, error, message, headers) {
65
- super(`${_APIError.makeMessage(status, error, message)}`);
66
- this.status = status;
67
- this.headers = headers;
68
- const data = error;
69
- this.error = data;
70
- this.code = data?.["code"];
71
- this.param = data?.["param"];
72
- this.type = data?.["type"];
73
- }
74
- static makeMessage(status, error, message) {
75
- const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
76
- if (status && msg) {
77
- return `${status} ${msg}`;
78
- }
79
- if (status) {
80
- return `${status} status code (no body)`;
81
- }
82
- if (msg) {
83
- return msg;
84
- }
85
- return "(no status code or body)";
86
- }
87
- static generate(status, errorResponse, message, headers) {
88
- if (!status) {
89
- return new APIConnectionError({
90
- cause: castToError(errorResponse)
91
- });
92
- }
93
- const error = errorResponse?.["error"];
94
- if (status === 400) {
95
- return new BadRequestError(status, error, message, headers);
96
- }
97
- if (status === 401) {
98
- return new AuthenticationError(status, error, message, headers);
99
- }
100
- if (status === 403) {
101
- return new PermissionDeniedError(status, error, message, headers);
102
- }
103
- if (status === 404) {
104
- return new NotFoundError(status, error, message, headers);
105
- }
106
- if (status === 409) {
107
- return new ConflictError(status, error, message, headers);
108
- }
109
- if (status === 422) {
110
- return new UnprocessableEntityError(status, error, message, headers);
111
- }
112
- if (status === 429) {
113
- return new RateLimitError(status, error, message, headers);
114
- }
115
- if (status >= 500) {
116
- return new InternalServerError(status, error, message, headers);
117
- }
118
- return new _APIError(status, error, message, headers);
119
- }
120
- };
121
- __name(_APIError, "APIError");
122
- var APIError = _APIError;
123
- var _APIConnectionError = class _APIConnectionError extends APIError {
124
- constructor({ message, cause }) {
125
- super(void 0, void 0, message || "Connection error.", void 0);
126
- __publicField(this, "status");
127
- if (cause)
128
- this.cause = cause;
129
- }
130
- };
131
- __name(_APIConnectionError, "APIConnectionError");
132
- var APIConnectionError = _APIConnectionError;
133
- var _BadRequestError = class _BadRequestError extends APIError {
134
- constructor() {
135
- super(...arguments);
136
- __publicField(this, "status", 400);
137
- }
138
- };
139
- __name(_BadRequestError, "BadRequestError");
140
- var BadRequestError = _BadRequestError;
141
- var _AuthenticationError = class _AuthenticationError extends APIError {
142
- constructor() {
143
- super(...arguments);
144
- __publicField(this, "status", 401);
145
- }
146
- };
147
- __name(_AuthenticationError, "AuthenticationError");
148
- var AuthenticationError = _AuthenticationError;
149
- var _PermissionDeniedError = class _PermissionDeniedError extends APIError {
150
- constructor() {
151
- super(...arguments);
152
- __publicField(this, "status", 403);
153
- }
154
- };
155
- __name(_PermissionDeniedError, "PermissionDeniedError");
156
- var PermissionDeniedError = _PermissionDeniedError;
157
- var _NotFoundError = class _NotFoundError extends APIError {
158
- constructor() {
159
- super(...arguments);
160
- __publicField(this, "status", 404);
161
- }
162
- };
163
- __name(_NotFoundError, "NotFoundError");
164
- var NotFoundError = _NotFoundError;
165
- var _ConflictError = class _ConflictError extends APIError {
166
- constructor() {
167
- super(...arguments);
168
- __publicField(this, "status", 409);
169
- }
170
- };
171
- __name(_ConflictError, "ConflictError");
172
- var ConflictError = _ConflictError;
173
- var _UnprocessableEntityError = class _UnprocessableEntityError extends APIError {
174
- constructor() {
175
- super(...arguments);
176
- __publicField(this, "status", 422);
177
- }
178
- };
179
- __name(_UnprocessableEntityError, "UnprocessableEntityError");
180
- var UnprocessableEntityError = _UnprocessableEntityError;
181
- var _RateLimitError = class _RateLimitError extends APIError {
182
- constructor() {
183
- super(...arguments);
184
- __publicField(this, "status", 429);
185
- }
186
- };
187
- __name(_RateLimitError, "RateLimitError");
188
- var RateLimitError = _RateLimitError;
189
- var _InternalServerError = class _InternalServerError extends APIError {
190
- };
191
- __name(_InternalServerError, "InternalServerError");
192
- var InternalServerError = _InternalServerError;
193
- function castToError(err) {
194
- if (err instanceof Error)
195
- return err;
196
- return new Error(err);
197
- }
198
- __name(castToError, "castToError");
199
61
  var CreateAuthorizationCodeResponseSchema = zod.z.object({
200
62
  url: zod.z.string().url(),
201
63
  authorizationCode: zod.z.string()
@@ -514,7 +376,16 @@ var TaskFileMetadata = zod.z.object({
514
376
  filePath: zod.z.string(),
515
377
  exportName: zod.z.string()
516
378
  });
517
- var TaskMetadataWithFilePath = TaskMetadata.merge(TaskFileMetadata);
379
+ var TaskMetadataWithFilePath = zod.z.object({
380
+ id: zod.z.string(),
381
+ packageVersion: zod.z.string(),
382
+ queue: QueueOptions.optional(),
383
+ retry: RetryOptions.optional(),
384
+ machine: Machine.partial().optional(),
385
+ triggerSource: zod.z.string().optional(),
386
+ filePath: zod.z.string(),
387
+ exportName: zod.z.string()
388
+ });
518
389
  var PostStartCauses = zod.z.enum([
519
390
  "index",
520
391
  "create",
@@ -583,6 +454,152 @@ var ImageDetailsMetadata = zod.z.object({
583
454
  contentHash: zod.z.string(),
584
455
  imageTag: zod.z.string()
585
456
  });
457
+ function parseError(error) {
458
+ if (error instanceof Error) {
459
+ return {
460
+ type: "BUILT_IN_ERROR",
461
+ name: error.name,
462
+ message: error.message,
463
+ stackTrace: error.stack ?? ""
464
+ };
465
+ }
466
+ if (typeof error === "string") {
467
+ return {
468
+ type: "STRING_ERROR",
469
+ raw: error
470
+ };
471
+ }
472
+ try {
473
+ return {
474
+ type: "CUSTOM_ERROR",
475
+ raw: JSON.stringify(error)
476
+ };
477
+ } catch (e) {
478
+ return {
479
+ type: "CUSTOM_ERROR",
480
+ raw: String(error)
481
+ };
482
+ }
483
+ }
484
+ __name(parseError, "parseError");
485
+ function createErrorTaskError(error) {
486
+ switch (error.type) {
487
+ case "BUILT_IN_ERROR": {
488
+ const e = new Error(error.message);
489
+ e.name = error.name;
490
+ e.stack = error.stackTrace;
491
+ return e;
492
+ }
493
+ case "STRING_ERROR": {
494
+ return error.raw;
495
+ }
496
+ case "CUSTOM_ERROR": {
497
+ return JSON.parse(error.raw);
498
+ }
499
+ case "INTERNAL_ERROR": {
500
+ return new Error(`trigger.dev internal error (${error.code})`);
501
+ }
502
+ }
503
+ }
504
+ __name(createErrorTaskError, "createErrorTaskError");
505
+ var SerializedError = zod.z.object({
506
+ message: zod.z.string(),
507
+ name: zod.z.string().optional(),
508
+ stackTrace: zod.z.string().optional()
509
+ });
510
+ function createJsonErrorObject(error) {
511
+ switch (error.type) {
512
+ case "BUILT_IN_ERROR": {
513
+ return {
514
+ name: error.name,
515
+ message: error.message,
516
+ stackTrace: error.stackTrace
517
+ };
518
+ }
519
+ case "STRING_ERROR": {
520
+ return {
521
+ message: error.raw
522
+ };
523
+ }
524
+ case "CUSTOM_ERROR": {
525
+ return {
526
+ message: error.raw
527
+ };
528
+ }
529
+ case "INTERNAL_ERROR": {
530
+ return {
531
+ message: `trigger.dev internal error (${error.code})`
532
+ };
533
+ }
534
+ }
535
+ }
536
+ __name(createJsonErrorObject, "createJsonErrorObject");
537
+ function correctErrorStackTrace(stackTrace, projectDir, options) {
538
+ const [errorLine, ...traceLines] = stackTrace.split("\n");
539
+ return [
540
+ options?.removeFirstLine ? void 0 : errorLine,
541
+ ...traceLines.map((line) => correctStackTraceLine(line, projectDir, options?.isDev))
542
+ ].filter(Boolean).join("\n");
543
+ }
544
+ __name(correctErrorStackTrace, "correctErrorStackTrace");
545
+ var LINES_TO_IGNORE = [
546
+ /ConsoleInterceptor/,
547
+ /TriggerTracer/,
548
+ /TaskExecutor/,
549
+ /EXECUTE_TASK_RUN/,
550
+ /@trigger.dev\/core/,
551
+ /packages\/core\/src\/v3/,
552
+ /safeJsonProcess/,
553
+ /__entryPoint.ts/,
554
+ /ZodIpc/,
555
+ /startActiveSpan/,
556
+ /processTicksAndRejections/
557
+ ];
558
+ function correctStackTraceLine(line, projectDir, isDev) {
559
+ if (LINES_TO_IGNORE.some((regex) => regex.test(line))) {
560
+ return;
561
+ }
562
+ if (isDev && projectDir && !line.includes(projectDir)) {
563
+ return;
564
+ }
565
+ return line.trim();
566
+ }
567
+ __name(correctStackTraceLine, "correctStackTraceLine");
568
+ function groupTaskMetadataIssuesByTask(tasks, issues) {
569
+ return issues.reduce((acc, issue) => {
570
+ if (issue.path.length === 0) {
571
+ return acc;
572
+ }
573
+ const taskIndex = issue.path[1];
574
+ if (typeof taskIndex !== "number") {
575
+ return acc;
576
+ }
577
+ const task = tasks[taskIndex];
578
+ if (!task) {
579
+ return acc;
580
+ }
581
+ const restOfPath = issue.path.slice(2);
582
+ const taskId = task.id;
583
+ const taskName = task.exportName;
584
+ const filePath = task.filePath;
585
+ const key = taskIndex;
586
+ const existing = acc[key] ?? {
587
+ id: taskId,
588
+ exportName: taskName,
589
+ filePath,
590
+ issues: []
591
+ };
592
+ existing.issues.push({
593
+ message: issue.message,
594
+ path: restOfPath.length === 0 ? void 0 : restOfPath.join(".")
595
+ });
596
+ return {
597
+ ...acc,
598
+ [key]: existing
599
+ };
600
+ }, {});
601
+ }
602
+ __name(groupTaskMetadataIssuesByTask, "groupTaskMetadataIssuesByTask");
586
603
 
587
604
  // src/v3/schemas/api.ts
588
605
  var WhoAmIResponseSchema = zod.z.object({
@@ -725,7 +742,7 @@ var ReplayRunResponse = zod.z.object({
725
742
  id: zod.z.string()
726
743
  });
727
744
  var CanceledRunResponse = zod.z.object({
728
- message: zod.z.string()
745
+ id: zod.z.string()
729
746
  });
730
747
  var ScheduledTaskPayload = zod.z.object({
731
748
  /** The schedule id associated with this run (you can have many schedules for the same task).
@@ -775,17 +792,18 @@ var CreateScheduleOptions = zod.z.object({
775
792
  externalId: zod.z.string().optional()
776
793
  });
777
794
  var UpdateScheduleOptions = CreateScheduleOptions;
795
+ var ScheduleGenerator = zod.z.object({
796
+ type: zod.z.literal("CRON"),
797
+ expression: zod.z.string(),
798
+ description: zod.z.string()
799
+ });
778
800
  var ScheduleObject = zod.z.object({
779
801
  id: zod.z.string(),
780
802
  task: zod.z.string(),
781
803
  active: zod.z.boolean(),
782
804
  deduplicationKey: zod.z.string().nullish(),
783
805
  externalId: zod.z.string().nullish(),
784
- generator: zod.z.object({
785
- type: zod.z.literal("CRON"),
786
- expression: zod.z.string(),
787
- description: zod.z.string()
788
- }),
806
+ generator: ScheduleGenerator,
789
807
  nextRun: zod.z.coerce.date().nullish(),
790
808
  environments: zod.z.array(zod.z.object({
791
809
  id: zod.z.string(),
@@ -809,12 +827,28 @@ var ListScheduleOptions = zod.z.object({
809
827
  perPage: zod.z.number().optional()
810
828
  });
811
829
  var RunStatus = zod.z.enum([
812
- "PENDING",
830
+ /// Task hasn't been deployed yet but is waiting to be executed
831
+ "WAITING_FOR_DEPLOY",
832
+ /// Task is waiting to be executed by a worker
833
+ "QUEUED",
834
+ /// Task is currently being executed by a worker
813
835
  "EXECUTING",
814
- "PAUSED",
836
+ /// Task has failed and is waiting to be retried
837
+ "REATTEMPTING",
838
+ /// Task has been paused by the system, and will be resumed by the system
839
+ "FROZEN",
840
+ /// Task has been completed successfully
815
841
  "COMPLETED",
842
+ /// Task has been canceled by the user
843
+ "CANCELED",
844
+ /// Task has been completed with errors
816
845
  "FAILED",
817
- "CANCELED"
846
+ /// Task has crashed and won't be retried, most likely the worker ran out of resources, e.g. memory or storage
847
+ "CRASHED",
848
+ /// Task was interrupted during execution, mostly this happens in development environments
849
+ "INTERRUPTED",
850
+ /// Task has failed to complete, due to an error in the system
851
+ "SYSTEM_FAILURE"
818
852
  ]);
819
853
  var AttemptStatus = zod.z.enum([
820
854
  "PENDING",
@@ -824,23 +858,61 @@ var AttemptStatus = zod.z.enum([
824
858
  "FAILED",
825
859
  "CANCELED"
826
860
  ]);
827
- var RetrieveRunResponse = zod.z.object({
861
+ var RunEnvironmentDetails = zod.z.object({
862
+ id: zod.z.string(),
863
+ name: zod.z.string(),
864
+ user: zod.z.string().optional()
865
+ });
866
+ var RunScheduleDetails = zod.z.object({
867
+ id: zod.z.string(),
868
+ externalId: zod.z.string().optional(),
869
+ deduplicationKey: zod.z.string().optional(),
870
+ generator: ScheduleGenerator
871
+ });
872
+ var CommonRunFields = {
828
873
  id: zod.z.string(),
829
874
  status: RunStatus,
830
875
  taskIdentifier: zod.z.string(),
831
876
  idempotencyKey: zod.z.string().optional(),
832
877
  version: zod.z.string().optional(),
878
+ isQueued: zod.z.boolean(),
879
+ isExecuting: zod.z.boolean(),
880
+ isCompleted: zod.z.boolean(),
881
+ isSuccess: zod.z.boolean(),
882
+ isFailed: zod.z.boolean(),
883
+ isCancelled: zod.z.boolean(),
884
+ isTest: zod.z.boolean(),
833
885
  createdAt: zod.z.coerce.date(),
834
886
  updatedAt: zod.z.coerce.date(),
887
+ startedAt: zod.z.coerce.date().optional(),
888
+ finishedAt: zod.z.coerce.date().optional()
889
+ };
890
+ var RetrieveRunResponse = zod.z.object({
891
+ ...CommonRunFields,
892
+ payload: zod.z.any().optional(),
893
+ output: zod.z.any().optional(),
894
+ schedule: RunScheduleDetails.optional(),
835
895
  attempts: zod.z.array(zod.z.object({
836
896
  id: zod.z.string(),
837
897
  status: AttemptStatus,
838
898
  createdAt: zod.z.coerce.date(),
839
899
  updatedAt: zod.z.coerce.date(),
840
900
  startedAt: zod.z.coerce.date().optional(),
841
- completedAt: zod.z.coerce.date().optional()
901
+ completedAt: zod.z.coerce.date().optional(),
902
+ error: SerializedError.optional()
842
903
  }).optional())
843
904
  });
905
+ var ListRunResponseItem = zod.z.object({
906
+ ...CommonRunFields,
907
+ env: RunEnvironmentDetails
908
+ });
909
+ var ListRunResponse = zod.z.object({
910
+ data: zod.z.array(ListRunResponseItem),
911
+ pagination: zod.z.object({
912
+ next: zod.z.string().optional(),
913
+ previous: zod.z.string().optional()
914
+ })
915
+ });
844
916
  var CreateEnvironmentVariableRequestBody = zod.z.object({
845
917
  name: zod.z.string(),
846
918
  value: zod.z.string()
@@ -2091,15 +2163,153 @@ var _TaskContextAPI = class _TaskContextAPI {
2091
2163
  return registerGlobal(API_NAME, taskContext2);
2092
2164
  }
2093
2165
  };
2094
- _getTaskContext = new WeakSet();
2095
- getTaskContext_fn = /* @__PURE__ */ __name(function() {
2096
- return getGlobal(API_NAME);
2097
- }, "#getTaskContext");
2098
- __name(_TaskContextAPI, "TaskContextAPI");
2099
- var TaskContextAPI = _TaskContextAPI;
2100
-
2101
- // src/v3/task-context-api.ts
2102
- var taskContext = TaskContextAPI.getInstance();
2166
+ _getTaskContext = new WeakSet();
2167
+ getTaskContext_fn = /* @__PURE__ */ __name(function() {
2168
+ return getGlobal(API_NAME);
2169
+ }, "#getTaskContext");
2170
+ __name(_TaskContextAPI, "TaskContextAPI");
2171
+ var TaskContextAPI = _TaskContextAPI;
2172
+
2173
+ // src/v3/task-context-api.ts
2174
+ var taskContext = TaskContextAPI.getInstance();
2175
+
2176
+ // src/v3/apiClient/errors.ts
2177
+ var _ApiError = class _ApiError extends Error {
2178
+ constructor(status, error, message, headers) {
2179
+ super(`${_ApiError.makeMessage(status, error, message)}`);
2180
+ this.status = status;
2181
+ this.headers = headers;
2182
+ const data = error;
2183
+ this.error = data;
2184
+ this.code = data?.["code"];
2185
+ this.param = data?.["param"];
2186
+ this.type = data?.["type"];
2187
+ }
2188
+ static makeMessage(status, error, message) {
2189
+ const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
2190
+ if (status && msg) {
2191
+ return `${status} ${msg}`;
2192
+ }
2193
+ if (status) {
2194
+ return `${status} status code (no body)`;
2195
+ }
2196
+ if (msg) {
2197
+ return msg;
2198
+ }
2199
+ return "(no status code or body)";
2200
+ }
2201
+ static generate(status, errorResponse, message, headers) {
2202
+ if (!status) {
2203
+ return new ApiConnectionError({
2204
+ cause: castToError(errorResponse)
2205
+ });
2206
+ }
2207
+ const error = errorResponse?.["error"];
2208
+ if (status === 400) {
2209
+ return new BadRequestError(status, error, message, headers);
2210
+ }
2211
+ if (status === 401) {
2212
+ return new AuthenticationError(status, error, message, headers);
2213
+ }
2214
+ if (status === 403) {
2215
+ return new PermissionDeniedError(status, error, message, headers);
2216
+ }
2217
+ if (status === 404) {
2218
+ return new NotFoundError(status, error, message, headers);
2219
+ }
2220
+ if (status === 409) {
2221
+ return new ConflictError(status, error, message, headers);
2222
+ }
2223
+ if (status === 422) {
2224
+ return new UnprocessableEntityError(status, error, message, headers);
2225
+ }
2226
+ if (status === 429) {
2227
+ return new RateLimitError(status, error, message, headers);
2228
+ }
2229
+ if (status >= 500) {
2230
+ return new InternalServerError(status, error, message, headers);
2231
+ }
2232
+ return new _ApiError(status, error, message, headers);
2233
+ }
2234
+ };
2235
+ __name(_ApiError, "ApiError");
2236
+ var ApiError = _ApiError;
2237
+ var _ApiConnectionError = class _ApiConnectionError extends ApiError {
2238
+ constructor({ message, cause }) {
2239
+ super(void 0, void 0, message || "Connection error.", void 0);
2240
+ __publicField(this, "status");
2241
+ if (cause)
2242
+ this.cause = cause;
2243
+ }
2244
+ };
2245
+ __name(_ApiConnectionError, "ApiConnectionError");
2246
+ var ApiConnectionError = _ApiConnectionError;
2247
+ var _BadRequestError = class _BadRequestError extends ApiError {
2248
+ constructor() {
2249
+ super(...arguments);
2250
+ __publicField(this, "status", 400);
2251
+ }
2252
+ };
2253
+ __name(_BadRequestError, "BadRequestError");
2254
+ var BadRequestError = _BadRequestError;
2255
+ var _AuthenticationError = class _AuthenticationError extends ApiError {
2256
+ constructor() {
2257
+ super(...arguments);
2258
+ __publicField(this, "status", 401);
2259
+ }
2260
+ };
2261
+ __name(_AuthenticationError, "AuthenticationError");
2262
+ var AuthenticationError = _AuthenticationError;
2263
+ var _PermissionDeniedError = class _PermissionDeniedError extends ApiError {
2264
+ constructor() {
2265
+ super(...arguments);
2266
+ __publicField(this, "status", 403);
2267
+ }
2268
+ };
2269
+ __name(_PermissionDeniedError, "PermissionDeniedError");
2270
+ var PermissionDeniedError = _PermissionDeniedError;
2271
+ var _NotFoundError = class _NotFoundError extends ApiError {
2272
+ constructor() {
2273
+ super(...arguments);
2274
+ __publicField(this, "status", 404);
2275
+ }
2276
+ };
2277
+ __name(_NotFoundError, "NotFoundError");
2278
+ var NotFoundError = _NotFoundError;
2279
+ var _ConflictError = class _ConflictError extends ApiError {
2280
+ constructor() {
2281
+ super(...arguments);
2282
+ __publicField(this, "status", 409);
2283
+ }
2284
+ };
2285
+ __name(_ConflictError, "ConflictError");
2286
+ var ConflictError = _ConflictError;
2287
+ var _UnprocessableEntityError = class _UnprocessableEntityError extends ApiError {
2288
+ constructor() {
2289
+ super(...arguments);
2290
+ __publicField(this, "status", 422);
2291
+ }
2292
+ };
2293
+ __name(_UnprocessableEntityError, "UnprocessableEntityError");
2294
+ var UnprocessableEntityError = _UnprocessableEntityError;
2295
+ var _RateLimitError = class _RateLimitError extends ApiError {
2296
+ constructor() {
2297
+ super(...arguments);
2298
+ __publicField(this, "status", 429);
2299
+ }
2300
+ };
2301
+ __name(_RateLimitError, "RateLimitError");
2302
+ var RateLimitError = _RateLimitError;
2303
+ var _InternalServerError = class _InternalServerError extends ApiError {
2304
+ };
2305
+ __name(_InternalServerError, "InternalServerError");
2306
+ var InternalServerError = _InternalServerError;
2307
+ function castToError(err) {
2308
+ if (err instanceof Error)
2309
+ return err;
2310
+ return new Error(err);
2311
+ }
2312
+ __name(castToError, "castToError");
2103
2313
 
2104
2314
  // src/retry.ts
2105
2315
  function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
@@ -2207,6 +2417,108 @@ function calculateResetAt2(resets, format, now = Date.now()) {
2207
2417
  return resetAt?.getTime();
2208
2418
  }
2209
2419
  __name(calculateResetAt2, "calculateResetAt");
2420
+
2421
+ // src/v3/apiClient/pagination.ts
2422
+ var _CursorPage = class _CursorPage {
2423
+ constructor(data, pagination, pageFetcher) {
2424
+ this.pageFetcher = pageFetcher;
2425
+ this.data = data;
2426
+ this.pagination = pagination;
2427
+ }
2428
+ getPaginatedItems() {
2429
+ return this.data ?? [];
2430
+ }
2431
+ hasNextPage() {
2432
+ return !!this.pagination.next;
2433
+ }
2434
+ hasPreviousPage() {
2435
+ return !!this.pagination.previous;
2436
+ }
2437
+ getNextPage() {
2438
+ if (!this.pagination.next) {
2439
+ throw new Error("No next page available");
2440
+ }
2441
+ return this.pageFetcher({
2442
+ after: this.pagination.next
2443
+ });
2444
+ }
2445
+ getPreviousPage() {
2446
+ if (!this.pagination.previous) {
2447
+ throw new Error("No previous page available");
2448
+ }
2449
+ return this.pageFetcher({
2450
+ before: this.pagination.previous
2451
+ });
2452
+ }
2453
+ async *iterPages() {
2454
+ let page = this;
2455
+ yield page;
2456
+ while (page.hasNextPage()) {
2457
+ page = await page.getNextPage();
2458
+ yield page;
2459
+ }
2460
+ }
2461
+ async *[Symbol.asyncIterator]() {
2462
+ for await (const page of this.iterPages()) {
2463
+ for (const item of page.getPaginatedItems()) {
2464
+ yield item;
2465
+ }
2466
+ }
2467
+ }
2468
+ };
2469
+ __name(_CursorPage, "CursorPage");
2470
+ var CursorPage = _CursorPage;
2471
+ var _OffsetLimitPage = class _OffsetLimitPage {
2472
+ constructor(data, pagination, pageFetcher) {
2473
+ this.pageFetcher = pageFetcher;
2474
+ this.data = data;
2475
+ this.pagination = pagination;
2476
+ }
2477
+ getPaginatedItems() {
2478
+ return this.data ?? [];
2479
+ }
2480
+ hasNextPage() {
2481
+ return this.pagination.currentPage < this.pagination.totalPages;
2482
+ }
2483
+ hasPreviousPage() {
2484
+ return this.pagination.currentPage > 1;
2485
+ }
2486
+ getNextPage() {
2487
+ if (!this.hasNextPage()) {
2488
+ throw new Error("No next page available");
2489
+ }
2490
+ return this.pageFetcher({
2491
+ page: this.pagination.currentPage + 1
2492
+ });
2493
+ }
2494
+ getPreviousPage() {
2495
+ if (!this.hasPreviousPage()) {
2496
+ throw new Error("No previous page available");
2497
+ }
2498
+ return this.pageFetcher({
2499
+ page: this.pagination.currentPage - 1
2500
+ });
2501
+ }
2502
+ async *iterPages() {
2503
+ let page = this;
2504
+ yield page;
2505
+ while (page.hasNextPage()) {
2506
+ page = await page.getNextPage();
2507
+ yield page;
2508
+ }
2509
+ }
2510
+ async *[Symbol.asyncIterator]() {
2511
+ for await (const page of this.iterPages()) {
2512
+ for (const item of page.getPaginatedItems()) {
2513
+ yield item;
2514
+ }
2515
+ }
2516
+ }
2517
+ };
2518
+ __name(_OffsetLimitPage, "OffsetLimitPage");
2519
+ var OffsetLimitPage = _OffsetLimitPage;
2520
+
2521
+ // src/v3/apiClient/core.ts
2210
2522
  var defaultRetryOptions2 = {
2211
2523
  maxAttempts: 3,
2212
2524
  factor: 2,
@@ -2214,11 +2526,62 @@ var defaultRetryOptions2 = {
2214
2526
  maxTimeoutInMs: 6e4,
2215
2527
  randomize: false
2216
2528
  };
2217
- async function zodfetch(schema, url, requestInit, options) {
2218
- return await _doZodFetch(schema, url, requestInit, options);
2529
+ function zodfetch(schema, url, requestInit, options) {
2530
+ return new ApiPromise(_doZodFetch(schema, url, requestInit, options));
2219
2531
  }
2220
2532
  __name(zodfetch, "zodfetch");
2221
- async function zodupload(schema, url, body, requestInit, options) {
2533
+ function zodfetchCursorPage(schema, url, params, requestInit, options) {
2534
+ const query = new URLSearchParams(params.query);
2535
+ if (params.limit) {
2536
+ query.set("page[size]", String(params.limit));
2537
+ }
2538
+ if (params.after) {
2539
+ query.set("page[after]", params.after);
2540
+ }
2541
+ if (params.before) {
2542
+ query.set("page[before]", params.before);
2543
+ }
2544
+ const cursorPageSchema = zod.z.object({
2545
+ data: zod.z.array(schema),
2546
+ pagination: zod.z.object({
2547
+ next: zod.z.string().optional(),
2548
+ previous: zod.z.string().optional()
2549
+ })
2550
+ });
2551
+ const $url = new URL(url);
2552
+ $url.search = query.toString();
2553
+ const fetchResult = _doZodFetch(cursorPageSchema, $url.href, requestInit, options);
2554
+ return new CursorPagePromise(fetchResult, schema, url, params, requestInit, options);
2555
+ }
2556
+ __name(zodfetchCursorPage, "zodfetchCursorPage");
2557
+ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
2558
+ const query = new URLSearchParams(params.query);
2559
+ if (params.limit) {
2560
+ query.set("perPage", String(params.limit));
2561
+ }
2562
+ if (params.page) {
2563
+ query.set("page", String(params.page));
2564
+ }
2565
+ const offsetLimitPageSchema = zod.z.object({
2566
+ data: zod.z.array(schema),
2567
+ pagination: zod.z.object({
2568
+ currentPage: zod.z.coerce.number(),
2569
+ totalPages: zod.z.coerce.number(),
2570
+ count: zod.z.coerce.number()
2571
+ })
2572
+ });
2573
+ const $url = new URL(url);
2574
+ $url.search = query.toString();
2575
+ const fetchResult = _doZodFetch(offsetLimitPageSchema, $url.href, requestInit, options);
2576
+ return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
2577
+ }
2578
+ __name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
2579
+ function zodupload(schema, url, body, requestInit, options) {
2580
+ const finalRequestInit = createMultipartFormRequestInit(body, requestInit);
2581
+ return new ApiPromise(_doZodFetch(schema, url, finalRequestInit, options));
2582
+ }
2583
+ __name(zodupload, "zodupload");
2584
+ async function createMultipartFormRequestInit(body, requestInit) {
2222
2585
  const form = await createForm(body);
2223
2586
  const encoder = new formDataEncoder.FormDataEncoder(form);
2224
2587
  const finalHeaders = {};
@@ -2236,9 +2599,9 @@ async function zodupload(schema, url, body, requestInit, options) {
2236
2599
  // @ts-expect-error
2237
2600
  duplex: "half"
2238
2601
  };
2239
- return await _doZodFetch(schema, url, finalRequestInit, options);
2602
+ return finalRequestInit;
2240
2603
  }
2241
- __name(zodupload, "zodupload");
2604
+ __name(createMultipartFormRequestInit, "createMultipartFormRequestInit");
2242
2605
  var createForm = /* @__PURE__ */ __name(async (body) => {
2243
2606
  const form = new FormData();
2244
2607
  await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
@@ -2246,7 +2609,8 @@ var createForm = /* @__PURE__ */ __name(async (body) => {
2246
2609
  }, "createForm");
2247
2610
  async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2248
2611
  try {
2249
- const response = await fetch(url, requestInitWithCache(requestInit));
2612
+ const $requestInit = await requestInit;
2613
+ const response = await fetch(url, requestInitWithCache($requestInit));
2250
2614
  const responseHeaders = createResponseHeaders(response.headers);
2251
2615
  if (!response.ok) {
2252
2616
  const retryResult = shouldRetry(response, attempt, options?.retry);
@@ -2257,17 +2621,20 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2257
2621
  const errText = await response.text().catch((e) => castToError2(e).message);
2258
2622
  const errJSON = safeJsonParse(errText);
2259
2623
  const errMessage = errJSON ? void 0 : errText;
2260
- throw APIError.generate(response.status, errJSON, errMessage, responseHeaders);
2624
+ throw ApiError.generate(response.status, errJSON, errMessage, responseHeaders);
2261
2625
  }
2262
2626
  }
2263
2627
  const jsonBody = await response.json();
2264
2628
  const parsedResult = schema.safeParse(jsonBody);
2265
2629
  if (parsedResult.success) {
2266
- return parsedResult.data;
2630
+ return {
2631
+ data: parsedResult.data,
2632
+ response
2633
+ };
2267
2634
  }
2268
2635
  throw zodValidationError.fromZodError(parsedResult.error);
2269
2636
  } catch (error) {
2270
- if (error instanceof APIError) {
2637
+ if (error instanceof ApiError) {
2271
2638
  throw error;
2272
2639
  }
2273
2640
  if (options?.retry) {
@@ -2281,7 +2648,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
2281
2648
  return await _doZodFetch(schema, url, requestInit, options, attempt + 1);
2282
2649
  }
2283
2650
  }
2284
- throw new APIConnectionError({
2651
+ throw new ApiConnectionError({
2285
2652
  cause: castToError2(error)
2286
2653
  });
2287
2654
  }
@@ -2454,6 +2821,128 @@ var isUploadable = /* @__PURE__ */ __name((value) => {
2454
2821
  return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
2455
2822
  }, "isUploadable");
2456
2823
  var isRecordLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => typeof key === "string" && typeof value[key] === "string"), "isRecordLike");
2824
+ var _ApiPromise = class _ApiPromise extends Promise {
2825
+ constructor(responsePromise) {
2826
+ super((resolve) => {
2827
+ resolve(null);
2828
+ });
2829
+ this.responsePromise = responsePromise;
2830
+ }
2831
+ /**
2832
+ * Gets the raw `Response` instance instead of parsing the response
2833
+ * data.
2834
+ *
2835
+ * If you want to parse the response body but still get the `Response`
2836
+ * instance, you can use {@link withResponse()}.
2837
+ */
2838
+ asResponse() {
2839
+ return this.responsePromise.then((p) => p.response);
2840
+ }
2841
+ /**
2842
+ * Gets the parsed response data and the raw `Response` instance.
2843
+ *
2844
+ * If you just want to get the raw `Response` instance without parsing it,
2845
+ * you can use {@link asResponse()}.
2846
+ */
2847
+ async withResponse() {
2848
+ const [data, response] = await Promise.all([
2849
+ this.parse(),
2850
+ this.asResponse()
2851
+ ]);
2852
+ return {
2853
+ data,
2854
+ response
2855
+ };
2856
+ }
2857
+ parse() {
2858
+ return this.responsePromise.then((result) => result.data);
2859
+ }
2860
+ then(onfulfilled, onrejected) {
2861
+ return this.parse().then(onfulfilled, onrejected);
2862
+ }
2863
+ catch(onrejected) {
2864
+ return this.parse().catch(onrejected);
2865
+ }
2866
+ finally(onfinally) {
2867
+ return this.parse().finally(onfinally);
2868
+ }
2869
+ };
2870
+ __name(_ApiPromise, "ApiPromise");
2871
+ var ApiPromise = _ApiPromise;
2872
+ var _fetchPage, fetchPage_fn;
2873
+ var _CursorPagePromise = class _CursorPagePromise extends ApiPromise {
2874
+ constructor(result, schema, url, params, requestInit, options) {
2875
+ super(result.then((result2) => ({
2876
+ data: new CursorPage(result2.data.data, result2.data.pagination, __privateMethod(this, _fetchPage, fetchPage_fn).bind(this)),
2877
+ response: result2.response
2878
+ })));
2879
+ __privateAdd(this, _fetchPage);
2880
+ this.schema = schema;
2881
+ this.url = url;
2882
+ this.params = params;
2883
+ this.requestInit = requestInit;
2884
+ this.options = options;
2885
+ }
2886
+ /**
2887
+ * Allow auto-paginating iteration on an unawaited list call, eg:
2888
+ *
2889
+ * for await (const item of client.items.list()) {
2890
+ * console.log(item)
2891
+ * }
2892
+ */
2893
+ async *[Symbol.asyncIterator]() {
2894
+ const page = await this;
2895
+ for await (const item of page) {
2896
+ yield item;
2897
+ }
2898
+ }
2899
+ };
2900
+ _fetchPage = new WeakSet();
2901
+ fetchPage_fn = /* @__PURE__ */ __name(function(params) {
2902
+ return zodfetchCursorPage(this.schema, this.url, {
2903
+ ...this.params,
2904
+ ...params
2905
+ }, this.requestInit, this.options);
2906
+ }, "#fetchPage");
2907
+ __name(_CursorPagePromise, "CursorPagePromise");
2908
+ var CursorPagePromise = _CursorPagePromise;
2909
+ var _fetchPage2, fetchPage_fn2;
2910
+ var _OffsetLimitPagePromise = class _OffsetLimitPagePromise extends ApiPromise {
2911
+ constructor(result, schema, url, params, requestInit, options) {
2912
+ super(result.then((result2) => ({
2913
+ data: new OffsetLimitPage(result2.data.data, result2.data.pagination, __privateMethod(this, _fetchPage2, fetchPage_fn2).bind(this)),
2914
+ response: result2.response
2915
+ })));
2916
+ __privateAdd(this, _fetchPage2);
2917
+ this.schema = schema;
2918
+ this.url = url;
2919
+ this.params = params;
2920
+ this.requestInit = requestInit;
2921
+ this.options = options;
2922
+ }
2923
+ /**
2924
+ * Allow auto-paginating iteration on an unawaited list call, eg:
2925
+ *
2926
+ * for await (const item of client.items.list()) {
2927
+ * console.log(item)
2928
+ * }
2929
+ */
2930
+ async *[Symbol.asyncIterator]() {
2931
+ const page = await this;
2932
+ for await (const item of page) {
2933
+ yield item;
2934
+ }
2935
+ }
2936
+ };
2937
+ _fetchPage2 = new WeakSet();
2938
+ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
2939
+ return zodfetchOffsetLimitPage(this.schema, this.url, {
2940
+ ...this.params,
2941
+ ...params1
2942
+ }, this.requestInit, this.options);
2943
+ }, "#fetchPage");
2944
+ __name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
2945
+ var OffsetLimitPagePromise = _OffsetLimitPagePromise;
2457
2946
 
2458
2947
  // src/v3/apiClient/index.ts
2459
2948
  var zodFetchOptions = {
@@ -2479,7 +2968,7 @@ var _ApiClient = class _ApiClient {
2479
2968
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2480
2969
  }, zodFetchOptions);
2481
2970
  } catch (error) {
2482
- if (error instanceof APIError) {
2971
+ if (error instanceof ApiError) {
2483
2972
  if (error.status === 404) {
2484
2973
  return void 0;
2485
2974
  }
@@ -2494,14 +2983,16 @@ var _ApiClient = class _ApiClient {
2494
2983
  }, zodFetchOptions);
2495
2984
  }
2496
2985
  triggerTask(taskId, body, options) {
2497
- return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${taskId}/trigger`, {
2986
+ const encodedTaskId = encodeURIComponent(taskId);
2987
+ return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
2498
2988
  method: "POST",
2499
2989
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2500
2990
  body: JSON.stringify(body)
2501
2991
  }, zodFetchOptions);
2502
2992
  }
2503
2993
  batchTriggerTask(taskId, body, options) {
2504
- return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${taskId}/batch`, {
2994
+ const encodedTaskId = encodeURIComponent(taskId);
2995
+ return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
2505
2996
  method: "POST",
2506
2997
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
2507
2998
  body: JSON.stringify(body)
@@ -2525,6 +3016,33 @@ var _ApiClient = class _ApiClient {
2525
3016
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2526
3017
  }, zodFetchOptions);
2527
3018
  }
3019
+ listRuns(query) {
3020
+ const searchParams = createSearchQueryForListRuns(query);
3021
+ return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
3022
+ query: searchParams,
3023
+ limit: query?.limit,
3024
+ after: query?.after,
3025
+ before: query?.before
3026
+ }, {
3027
+ method: "GET",
3028
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3029
+ }, zodFetchOptions);
3030
+ }
3031
+ listProjectRuns(projectRef, query) {
3032
+ const searchParams = createSearchQueryForListRuns(query);
3033
+ if (query?.env) {
3034
+ searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
3035
+ }
3036
+ return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/projects/${projectRef}/runs`, {
3037
+ query: searchParams,
3038
+ limit: query?.limit,
3039
+ after: query?.after,
3040
+ before: query?.before
3041
+ }, {
3042
+ method: "GET",
3043
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
3044
+ }, zodFetchOptions);
3045
+ }
2528
3046
  replayRun(runId) {
2529
3047
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
2530
3048
  method: "POST",
@@ -2552,7 +3070,10 @@ var _ApiClient = class _ApiClient {
2552
3070
  if (options?.perPage) {
2553
3071
  searchParams.append("perPage", options.perPage.toString());
2554
3072
  }
2555
- return zodfetch(ListSchedulesResult, `${this.baseUrl}/api/v1/schedules${searchParams.size > 0 ? `?${searchParams}` : ""}`, {
3073
+ return zodfetchOffsetLimitPage(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
3074
+ page: options?.page,
3075
+ limit: options?.perPage
3076
+ }, {
2556
3077
  method: "GET",
2557
3078
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
2558
3079
  });
@@ -2653,6 +3174,40 @@ getHeaders_fn = /* @__PURE__ */ __name(function(spanParentAsLink) {
2653
3174
  }, "#getHeaders");
2654
3175
  __name(_ApiClient, "ApiClient");
2655
3176
  var ApiClient = _ApiClient;
3177
+ function createSearchQueryForListRuns(query) {
3178
+ const searchParams = new URLSearchParams();
3179
+ if (query) {
3180
+ if (query.status) {
3181
+ searchParams.append("filter[status]", Array.isArray(query.status) ? query.status.join(",") : query.status);
3182
+ }
3183
+ if (query.taskIdentifier) {
3184
+ searchParams.append("filter[taskIdentifier]", Array.isArray(query.taskIdentifier) ? query.taskIdentifier.join(",") : query.taskIdentifier);
3185
+ }
3186
+ if (query.version) {
3187
+ searchParams.append("filter[version]", Array.isArray(query.version) ? query.version.join(",") : query.version);
3188
+ }
3189
+ if (query.bulkAction) {
3190
+ searchParams.append("filter[bulkAction]", query.bulkAction);
3191
+ }
3192
+ if (query.schedule) {
3193
+ searchParams.append("filter[schedule]", query.schedule);
3194
+ }
3195
+ if (typeof query.isTest === "boolean") {
3196
+ searchParams.append("filter[isTest]", String(query.isTest));
3197
+ }
3198
+ if (query.from) {
3199
+ searchParams.append("filter[createdAt][from]", query.from instanceof Date ? query.from.getTime().toString() : query.from.toString());
3200
+ }
3201
+ if (query.to) {
3202
+ searchParams.append("filter[createdAt][to]", query.to instanceof Date ? query.to.getTime().toString() : query.to.toString());
3203
+ }
3204
+ if (query.period) {
3205
+ searchParams.append("filter[createdAt][period]", query.period);
3206
+ }
3207
+ }
3208
+ return searchParams;
3209
+ }
3210
+ __name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
2656
3211
  var _SimpleClock = class _SimpleClock {
2657
3212
  preciseNow() {
2658
3213
  const now = new preciseDate.PreciseDate();
@@ -2702,149 +3257,6 @@ var ClockAPI = _ClockAPI;
2702
3257
  // src/v3/clock-api.ts
2703
3258
  var clock = ClockAPI.getInstance();
2704
3259
 
2705
- // src/v3/errors.ts
2706
- function parseError(error) {
2707
- if (error instanceof Error) {
2708
- return {
2709
- type: "BUILT_IN_ERROR",
2710
- name: error.name,
2711
- message: error.message,
2712
- stackTrace: error.stack ?? ""
2713
- };
2714
- }
2715
- if (typeof error === "string") {
2716
- return {
2717
- type: "STRING_ERROR",
2718
- raw: error
2719
- };
2720
- }
2721
- try {
2722
- return {
2723
- type: "CUSTOM_ERROR",
2724
- raw: JSON.stringify(error)
2725
- };
2726
- } catch (e) {
2727
- return {
2728
- type: "CUSTOM_ERROR",
2729
- raw: String(error)
2730
- };
2731
- }
2732
- }
2733
- __name(parseError, "parseError");
2734
- function createErrorTaskError(error) {
2735
- switch (error.type) {
2736
- case "BUILT_IN_ERROR": {
2737
- const e = new Error(error.message);
2738
- e.name = error.name;
2739
- e.stack = error.stackTrace;
2740
- return e;
2741
- }
2742
- case "STRING_ERROR": {
2743
- return error.raw;
2744
- }
2745
- case "CUSTOM_ERROR": {
2746
- return JSON.parse(error.raw);
2747
- }
2748
- case "INTERNAL_ERROR": {
2749
- return new Error(`trigger.dev internal error (${error.code})`);
2750
- }
2751
- }
2752
- }
2753
- __name(createErrorTaskError, "createErrorTaskError");
2754
- function createJsonErrorObject(error) {
2755
- switch (error.type) {
2756
- case "BUILT_IN_ERROR": {
2757
- return {
2758
- name: error.name,
2759
- message: error.message,
2760
- stackTrace: error.stackTrace
2761
- };
2762
- }
2763
- case "STRING_ERROR": {
2764
- return {
2765
- message: error.raw
2766
- };
2767
- }
2768
- case "CUSTOM_ERROR": {
2769
- return {
2770
- message: error.raw
2771
- };
2772
- }
2773
- case "INTERNAL_ERROR": {
2774
- return {
2775
- message: `trigger.dev internal error (${error.code})`
2776
- };
2777
- }
2778
- }
2779
- }
2780
- __name(createJsonErrorObject, "createJsonErrorObject");
2781
- function correctErrorStackTrace(stackTrace, projectDir, options) {
2782
- const [errorLine, ...traceLines] = stackTrace.split("\n");
2783
- return [
2784
- options?.removeFirstLine ? void 0 : errorLine,
2785
- ...traceLines.map((line) => correctStackTraceLine(line, projectDir, options?.isDev))
2786
- ].filter(Boolean).join("\n");
2787
- }
2788
- __name(correctErrorStackTrace, "correctErrorStackTrace");
2789
- var LINES_TO_IGNORE = [
2790
- /ConsoleInterceptor/,
2791
- /TriggerTracer/,
2792
- /TaskExecutor/,
2793
- /EXECUTE_TASK_RUN/,
2794
- /@trigger.dev\/core/,
2795
- /packages\/core\/src\/v3/,
2796
- /safeJsonProcess/,
2797
- /__entryPoint.ts/,
2798
- /ZodIpc/,
2799
- /startActiveSpan/,
2800
- /processTicksAndRejections/
2801
- ];
2802
- function correctStackTraceLine(line, projectDir, isDev) {
2803
- if (LINES_TO_IGNORE.some((regex) => regex.test(line))) {
2804
- return;
2805
- }
2806
- if (isDev && projectDir && !line.includes(projectDir)) {
2807
- return;
2808
- }
2809
- return line.trim();
2810
- }
2811
- __name(correctStackTraceLine, "correctStackTraceLine");
2812
- function groupTaskMetadataIssuesByTask(tasks, issues) {
2813
- return issues.reduce((acc, issue) => {
2814
- if (issue.path.length === 0) {
2815
- return acc;
2816
- }
2817
- const taskIndex = issue.path[1];
2818
- if (typeof taskIndex !== "number") {
2819
- return acc;
2820
- }
2821
- const task = tasks[taskIndex];
2822
- if (!task) {
2823
- return acc;
2824
- }
2825
- const restOfPath = issue.path.slice(2);
2826
- const taskId = task.id;
2827
- const taskName = task.exportName;
2828
- const filePath = task.filePath;
2829
- const key = taskIndex;
2830
- const existing = acc[key] ?? {
2831
- id: taskId,
2832
- exportName: taskName,
2833
- filePath,
2834
- issues: []
2835
- };
2836
- existing.issues.push({
2837
- message: issue.message,
2838
- path: restOfPath.length === 0 ? void 0 : restOfPath.join(".")
2839
- });
2840
- return {
2841
- ...acc,
2842
- [key]: existing
2843
- };
2844
- }, {});
2845
- }
2846
- __name(groupTaskMetadataIssuesByTask, "groupTaskMetadataIssuesByTask");
2847
-
2848
3260
  // src/v3/limits.ts
2849
3261
  var OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 256;
2850
3262
  var OTEL_LOG_ATTRIBUTE_COUNT_LIMIT = 256;
@@ -3876,9 +4288,9 @@ function safeJsonParse2(value) {
3876
4288
  }
3877
4289
  __name(safeJsonParse2, "safeJsonParse");
3878
4290
 
3879
- exports.APIConnectionError = APIConnectionError;
3880
- exports.APIError = APIError;
3881
4291
  exports.ApiClient = ApiClient;
4292
+ exports.ApiConnectionError = ApiConnectionError;
4293
+ exports.ApiError = ApiError;
3882
4294
  exports.AttemptStatus = AttemptStatus;
3883
4295
  exports.AuthenticationError = AuthenticationError;
3884
4296
  exports.BackgroundWorkerClientMessages = BackgroundWorkerClientMessages;
@@ -3902,6 +4314,7 @@ exports.CreateBackgroundWorkerResponse = CreateBackgroundWorkerResponse;
3902
4314
  exports.CreateEnvironmentVariableRequestBody = CreateEnvironmentVariableRequestBody;
3903
4315
  exports.CreateScheduleOptions = CreateScheduleOptions;
3904
4316
  exports.CreateUploadPayloadUrlResponseBody = CreateUploadPayloadUrlResponseBody;
4317
+ exports.CursorPage = CursorPage;
3905
4318
  exports.DeletedScheduleObject = DeletedScheduleObject;
3906
4319
  exports.DeploymentErrorData = DeploymentErrorData;
3907
4320
  exports.EnvironmentType = EnvironmentType;
@@ -3933,6 +4346,8 @@ exports.ImportEnvironmentVariablesRequestBody = ImportEnvironmentVariablesReques
3933
4346
  exports.InitializeDeploymentRequestBody = InitializeDeploymentRequestBody;
3934
4347
  exports.InitializeDeploymentResponseBody = InitializeDeploymentResponseBody;
3935
4348
  exports.InternalServerError = InternalServerError;
4349
+ exports.ListRunResponse = ListRunResponse;
4350
+ exports.ListRunResponseItem = ListRunResponseItem;
3936
4351
  exports.ListScheduleOptions = ListScheduleOptions;
3937
4352
  exports.ListSchedulesResult = ListSchedulesResult;
3938
4353
  exports.Machine = Machine;
@@ -3949,6 +4364,7 @@ exports.OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT = OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_
3949
4364
  exports.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT;
3950
4365
  exports.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT;
3951
4366
  exports.OTEL_SPAN_EVENT_COUNT_LIMIT = OTEL_SPAN_EVENT_COUNT_LIMIT;
4367
+ exports.OffsetLimitPage = OffsetLimitPage;
3952
4368
  exports.OtherSpanEvent = OtherSpanEvent;
3953
4369
  exports.PRIMARY_VARIANT = PRIMARY_VARIANT;
3954
4370
  exports.PermissionDeniedError = PermissionDeniedError;
@@ -3969,10 +4385,14 @@ exports.RateLimitOptions = RateLimitOptions;
3969
4385
  exports.ReplayRunResponse = ReplayRunResponse;
3970
4386
  exports.RetrieveRunResponse = RetrieveRunResponse;
3971
4387
  exports.RetryOptions = RetryOptions;
4388
+ exports.RunEnvironmentDetails = RunEnvironmentDetails;
4389
+ exports.RunScheduleDetails = RunScheduleDetails;
3972
4390
  exports.RunStatus = RunStatus;
4391
+ exports.ScheduleGenerator = ScheduleGenerator;
3973
4392
  exports.ScheduleObject = ScheduleObject;
3974
4393
  exports.ScheduledTaskPayload = ScheduledTaskPayload;
3975
4394
  exports.SemanticInternalAttributes = SemanticInternalAttributes;
4395
+ exports.SerializedError = SerializedError;
3976
4396
  exports.SharedQueueToClientMessages = SharedQueueToClientMessages;
3977
4397
  exports.SlidingWindowRateLimit = SlidingWindowRateLimit;
3978
4398
  exports.SpanEvent = SpanEvent;