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

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 (59) hide show
  1. package/dist/catalog-BUwiuDbt.d.mts +202 -0
  2. package/dist/catalog-eKgqBHUA.d.ts +202 -0
  3. package/dist/index.d.mts +60 -1
  4. package/dist/index.d.ts +60 -1
  5. package/dist/index.js +7 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +7 -1
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/{manager-WNMVbgHf.d.mts → manager-uPyMRN8k.d.mts} +24 -23
  10. package/dist/{manager-WNMVbgHf.d.ts → manager-uPyMRN8k.d.ts} +24 -23
  11. package/dist/{messages-vq7Bk4Ap.d.mts → messages-l9PdIyKF.d.mts} +4975 -1072
  12. package/dist/{messages-vq7Bk4Ap.d.ts → messages-l9PdIyKF.d.ts} +4975 -1072
  13. package/dist/{catalog-KbyTBoap.d.ts → schemas-b8tRw8dX.d.mts} +21 -186
  14. package/dist/{catalog-ck7x04PV.d.mts → schemas-b8tRw8dX.d.ts} +21 -186
  15. package/dist/v3/dev/index.d.mts +2 -2
  16. package/dist/v3/dev/index.d.ts +2 -2
  17. package/dist/v3/dev/index.js +4 -4
  18. package/dist/v3/dev/index.js.map +1 -1
  19. package/dist/v3/dev/index.mjs +4 -4
  20. package/dist/v3/dev/index.mjs.map +1 -1
  21. package/dist/v3/index.d.mts +121 -7
  22. package/dist/v3/index.d.ts +121 -7
  23. package/dist/v3/index.js +735 -352
  24. package/dist/v3/index.js.map +1 -1
  25. package/dist/v3/index.mjs +728 -353
  26. package/dist/v3/index.mjs.map +1 -1
  27. package/dist/v3/otel/index.js +5 -1
  28. package/dist/v3/otel/index.js.map +1 -1
  29. package/dist/v3/otel/index.mjs +5 -1
  30. package/dist/v3/otel/index.mjs.map +1 -1
  31. package/dist/v3/prod/index.d.mts +3 -3
  32. package/dist/v3/prod/index.d.ts +3 -3
  33. package/dist/v3/prod/index.js +90 -15
  34. package/dist/v3/prod/index.js.map +1 -1
  35. package/dist/v3/prod/index.mjs +90 -15
  36. package/dist/v3/prod/index.mjs.map +1 -1
  37. package/dist/v3/workers/index.d.mts +6 -5
  38. package/dist/v3/workers/index.d.ts +6 -5
  39. package/dist/v3/workers/index.js +204 -9
  40. package/dist/v3/workers/index.js.map +1 -1
  41. package/dist/v3/workers/index.mjs +204 -9
  42. package/dist/v3/workers/index.mjs.map +1 -1
  43. package/dist/v3/zodMessageHandler.d.mts +1 -1
  44. package/dist/v3/zodMessageHandler.d.ts +1 -1
  45. package/dist/v3/zodNamespace.js +16 -6
  46. package/dist/v3/zodNamespace.js.map +1 -1
  47. package/dist/v3/zodNamespace.mjs +17 -7
  48. package/dist/v3/zodNamespace.mjs.map +1 -1
  49. package/dist/v3/zodSocket.js +16 -6
  50. package/dist/v3/zodSocket.js.map +1 -1
  51. package/dist/v3/zodSocket.mjs +17 -7
  52. package/dist/v3/zodSocket.mjs.map +1 -1
  53. package/dist/v3/zodfetch.d.mts +78 -0
  54. package/dist/v3/zodfetch.d.ts +78 -0
  55. package/dist/v3/zodfetch.js +446 -0
  56. package/dist/v3/zodfetch.js.map +1 -0
  57. package/dist/v3/zodfetch.mjs +433 -0
  58. package/dist/v3/zodfetch.mjs.map +1 -0
  59. package/package.json +13 -4
@@ -11,6 +11,8 @@ var sdkTraceNode = require('@opentelemetry/sdk-trace-node');
11
11
  var semanticConventions = require('@opentelemetry/semantic-conventions');
12
12
  var zod = require('zod');
13
13
  var zodValidationError = require('zod-validation-error');
14
+ var formDataEncoder = require('form-data-encoder');
15
+ var stream = require('stream');
14
16
  var preciseDate = require('@google-cloud/precise-date');
15
17
  var util = require('util');
16
18
 
@@ -355,6 +357,9 @@ function getEnvVar(name) {
355
357
  }
356
358
  __name(getEnvVar, "getEnvVar");
357
359
 
360
+ // package.json
361
+ var version = "3.0.0-beta.35";
362
+
358
363
  // src/v3/otel/tracingSDK.ts
359
364
  var _a;
360
365
  var AsyncResourceDetector = (_a = class {
@@ -392,7 +397,8 @@ var _TracingSDK = class _TracingSDK {
392
397
  ]
393
398
  }).merge(new resources.Resource({
394
399
  [semanticConventions.SemanticResourceAttributes.CLOUD_PROVIDER]: "trigger.dev",
395
- [SemanticInternalAttributes.TRIGGER]: true
400
+ [SemanticInternalAttributes.TRIGGER]: true,
401
+ [SemanticInternalAttributes.CLI_VERSION]: version
396
402
  })).merge(config.resource ?? new resources.Resource({})).merge(new resources.Resource(envResourceAttributes));
397
403
  const traceProvider = new sdkTraceNode.NodeTracerProvider({
398
404
  forceFlushTimeoutMillis: config.forceFlushTimeoutMillis ?? 500,
@@ -522,6 +528,7 @@ var TaskRunErrorCodes = {
522
528
  TASK_EXECUTION_FAILED: "TASK_EXECUTION_FAILED",
523
529
  TASK_EXECUTION_ABORTED: "TASK_EXECUTION_ABORTED",
524
530
  TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE: "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
531
+ TASK_PROCESS_SIGKILL_TIMEOUT: "TASK_PROCESS_SIGKILL_TIMEOUT",
525
532
  TASK_RUN_CANCELLED: "TASK_RUN_CANCELLED",
526
533
  TASK_OUTPUT_ERROR: "TASK_OUTPUT_ERROR",
527
534
  HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR",
@@ -537,10 +544,12 @@ var TaskRunInternalError = zod.z.object({
537
544
  "TASK_EXECUTION_FAILED",
538
545
  "TASK_EXECUTION_ABORTED",
539
546
  "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
547
+ "TASK_PROCESS_SIGKILL_TIMEOUT",
540
548
  "TASK_RUN_CANCELLED",
541
549
  "TASK_OUTPUT_ERROR",
542
550
  "HANDLE_ERROR_ERROR",
543
- "GRACEFUL_EXIT_TIMEOUT"
551
+ "GRACEFUL_EXIT_TIMEOUT",
552
+ "TASK_RUN_HEARTBEAT_TIMEOUT"
544
553
  ]),
545
554
  message: zod.z.string().optional()
546
555
  });
@@ -843,6 +852,13 @@ zod.z.enum([
843
852
  "WAIT_FOR_TASK",
844
853
  "WAIT_FOR_BATCH"
845
854
  ]);
855
+ zod.z.object({
856
+ runId: zod.z.string(),
857
+ messageId: zod.z.string(),
858
+ isTest: zod.z.boolean(),
859
+ traceContext: zod.z.record(zod.z.unknown()),
860
+ environment: zod.z.record(zod.z.string()).optional()
861
+ });
846
862
 
847
863
  // src/v3/schemas/resources.ts
848
864
  var TaskResource = zod.z.object({
@@ -892,7 +908,8 @@ zod.z.object({
892
908
  });
893
909
  zod.z.object({
894
910
  localOnly: zod.z.boolean(),
895
- metadata: BackgroundWorkerMetadata
911
+ metadata: BackgroundWorkerMetadata,
912
+ supportsLazyAttempts: zod.z.boolean().optional()
896
913
  });
897
914
  zod.z.object({
898
915
  id: zod.z.string(),
@@ -1120,6 +1137,28 @@ var RetrieveRunResponse = zod.z.object({
1120
1137
  completedAt: zod.z.coerce.date().optional()
1121
1138
  }).optional())
1122
1139
  });
1140
+ zod.z.object({
1141
+ name: zod.z.string(),
1142
+ value: zod.z.string()
1143
+ });
1144
+ zod.z.object({
1145
+ value: zod.z.string()
1146
+ });
1147
+ zod.z.object({
1148
+ variables: zod.z.record(zod.z.string()),
1149
+ override: zod.z.boolean().optional()
1150
+ });
1151
+ var EnvironmentVariableResponseBody = zod.z.object({
1152
+ success: zod.z.boolean()
1153
+ });
1154
+ var EnvironmentVariableValue = zod.z.object({
1155
+ value: zod.z.string()
1156
+ });
1157
+ var EnvironmentVariable = zod.z.object({
1158
+ name: zod.z.string(),
1159
+ value: zod.z.string()
1160
+ });
1161
+ var EnvironmentVariables = zod.z.array(EnvironmentVariable);
1123
1162
 
1124
1163
  // src/v3/apiErrors.ts
1125
1164
  var _APIError = class _APIError extends Error {
@@ -1281,8 +1320,6 @@ function calculateNextRetryDelay(options, attempt) {
1281
1320
  return Math.round(timeout);
1282
1321
  }
1283
1322
  __name(calculateNextRetryDelay, "calculateNextRetryDelay");
1284
-
1285
- // src/v3/zodfetch.ts
1286
1323
  var defaultRetryOptions2 = {
1287
1324
  maxAttempts: 3,
1288
1325
  factor: 2,
@@ -1294,6 +1331,32 @@ async function zodfetch(schema, url, requestInit, options) {
1294
1331
  return await _doZodFetch(schema, url, requestInit, options);
1295
1332
  }
1296
1333
  __name(zodfetch, "zodfetch");
1334
+ async function zodupload(schema, url, body, requestInit, options) {
1335
+ const form = await createForm(body);
1336
+ const encoder = new formDataEncoder.FormDataEncoder(form);
1337
+ const finalHeaders = {};
1338
+ for (const [key, value] of Object.entries(requestInit?.headers || {})) {
1339
+ finalHeaders[key] = value;
1340
+ }
1341
+ for (const [key, value] of Object.entries(encoder.headers)) {
1342
+ finalHeaders[key] = value;
1343
+ }
1344
+ finalHeaders["Content-Length"] = String(encoder.contentLength);
1345
+ const finalRequestInit = {
1346
+ ...requestInit,
1347
+ headers: finalHeaders,
1348
+ body: stream.Readable.from(encoder),
1349
+ // @ts-expect-error
1350
+ duplex: "half"
1351
+ };
1352
+ return await _doZodFetch(schema, url, finalRequestInit, options);
1353
+ }
1354
+ __name(zodupload, "zodupload");
1355
+ var createForm = /* @__PURE__ */ __name(async (body) => {
1356
+ const form = new FormData();
1357
+ await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
1358
+ return form;
1359
+ }, "createForm");
1297
1360
  async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
1298
1361
  try {
1299
1362
  const response = await fetch(url, requestInitWithCache(requestInit));
@@ -1415,9 +1478,95 @@ function requestInitWithCache(requestInit) {
1415
1478
  }
1416
1479
  }
1417
1480
  __name(requestInitWithCache, "requestInitWithCache");
1418
-
1419
- // package.json
1420
- var version = "3.0.0-beta.33";
1481
+ var addFormValue = /* @__PURE__ */ __name(async (form, key, value) => {
1482
+ if (value === void 0)
1483
+ return;
1484
+ if (value == null) {
1485
+ throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
1486
+ }
1487
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1488
+ form.append(key, String(value));
1489
+ } else if (isUploadable(value) || isBlobLike(value) || value instanceof Buffer || value instanceof ArrayBuffer) {
1490
+ const file = await toFile(value);
1491
+ form.append(key, file);
1492
+ } else if (Array.isArray(value)) {
1493
+ await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
1494
+ } else if (typeof value === "object") {
1495
+ await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
1496
+ } else {
1497
+ throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
1498
+ }
1499
+ }, "addFormValue");
1500
+ async function toFile(value, name, options) {
1501
+ value = await value;
1502
+ options ??= isFileLike(value) ? {
1503
+ lastModified: value.lastModified,
1504
+ type: value.type
1505
+ } : {};
1506
+ if (isResponseLike(value)) {
1507
+ const blob = await value.blob();
1508
+ name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file";
1509
+ return new File([
1510
+ blob
1511
+ ], name, options);
1512
+ }
1513
+ const bits = await getBytes(value);
1514
+ name ||= getName(value) ?? "unknown_file";
1515
+ if (!options.type) {
1516
+ const type = bits[0]?.type;
1517
+ if (typeof type === "string") {
1518
+ options = {
1519
+ ...options,
1520
+ type
1521
+ };
1522
+ }
1523
+ }
1524
+ return new File(bits, name, options);
1525
+ }
1526
+ __name(toFile, "toFile");
1527
+ function getName(value) {
1528
+ return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || // For fs.ReadStream
1529
+ getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
1530
+ }
1531
+ __name(getName, "getName");
1532
+ var getStringFromMaybeBuffer = /* @__PURE__ */ __name((x) => {
1533
+ if (typeof x === "string")
1534
+ return x;
1535
+ if (typeof Buffer !== "undefined" && x instanceof Buffer)
1536
+ return String(x);
1537
+ return void 0;
1538
+ }, "getStringFromMaybeBuffer");
1539
+ async function getBytes(value) {
1540
+ let parts = [];
1541
+ if (typeof value === "string" || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
1542
+ value instanceof ArrayBuffer) {
1543
+ parts.push(value);
1544
+ } else if (isBlobLike(value)) {
1545
+ parts.push(await value.arrayBuffer());
1546
+ } else if (isAsyncIterableIterator(value)) {
1547
+ for await (const chunk of value) {
1548
+ parts.push(chunk);
1549
+ }
1550
+ } else {
1551
+ throw new Error(`Unexpected data type: ${typeof value}; constructor: ${value?.constructor?.name}; props: ${propsForError(value)}`);
1552
+ }
1553
+ return parts;
1554
+ }
1555
+ __name(getBytes, "getBytes");
1556
+ function propsForError(value) {
1557
+ const props = Object.getOwnPropertyNames(value);
1558
+ return `[${props.map((p) => `"${p}"`).join(", ")}]`;
1559
+ }
1560
+ __name(propsForError, "propsForError");
1561
+ var isAsyncIterableIterator = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function", "isAsyncIterableIterator");
1562
+ var isResponseLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function", "isResponseLike");
1563
+ var isFileLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value), "isFileLike");
1564
+ var isBlobLike = /* @__PURE__ */ __name((value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function", "isBlobLike");
1565
+ var isFsReadStream = /* @__PURE__ */ __name((value) => value instanceof stream.Readable, "isFsReadStream");
1566
+ var isUploadable = /* @__PURE__ */ __name((value) => {
1567
+ return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
1568
+ }, "isUploadable");
1569
+ 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");
1421
1570
 
1422
1571
  // src/v3/apiClient/index.ts
1423
1572
  var zodFetchOptions = {
@@ -1552,6 +1701,52 @@ var _ApiClient = class _ApiClient {
1552
1701
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1553
1702
  });
1554
1703
  }
1704
+ listEnvVars(projectRef, slug) {
1705
+ return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
1706
+ method: "GET",
1707
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1708
+ });
1709
+ }
1710
+ importEnvVars(projectRef, slug, body) {
1711
+ if (isRecordLike(body.variables)) {
1712
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
1713
+ method: "POST",
1714
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
1715
+ body: JSON.stringify(body)
1716
+ });
1717
+ } else {
1718
+ return zodupload(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, body, {
1719
+ method: "POST",
1720
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1721
+ });
1722
+ }
1723
+ }
1724
+ retrieveEnvVar(projectRef, slug, key) {
1725
+ return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
1726
+ method: "GET",
1727
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1728
+ });
1729
+ }
1730
+ createEnvVar(projectRef, slug, body) {
1731
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
1732
+ method: "POST",
1733
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
1734
+ body: JSON.stringify(body)
1735
+ });
1736
+ }
1737
+ updateEnvVar(projectRef, slug, key, body) {
1738
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
1739
+ method: "PUT",
1740
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
1741
+ body: JSON.stringify(body)
1742
+ });
1743
+ }
1744
+ deleteEnvVar(projectRef, slug, key) {
1745
+ return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
1746
+ method: "DELETE",
1747
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1748
+ });
1749
+ }
1555
1750
  };
1556
1751
  _getHeaders = new WeakSet();
1557
1752
  getHeaders_fn = /* @__PURE__ */ __name(function(spanParentAsLink) {
@@ -1597,7 +1792,7 @@ var _APIClientManagerAPI = class _APIClientManagerAPI {
1597
1792
  }
1598
1793
  get accessToken() {
1599
1794
  const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
1600
- return store?.secretKey ?? getEnvVar("TRIGGER_SECRET_KEY");
1795
+ return store?.secretKey ?? getEnvVar("TRIGGER_SECRET_KEY") ?? getEnvVar("TRIGGER_ACCESS_TOKEN");
1601
1796
  }
1602
1797
  get client() {
1603
1798
  if (!this.baseURL || !this.accessToken) {