@trigger.dev/core 3.0.0-beta.26 → 3.0.0-beta.28

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.
@@ -11,7 +11,6 @@ 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 async_hooks = require('async_hooks');
15
14
  var preciseDate = require('@google-cloud/precise-date');
16
15
  var util = require('util');
17
16
 
@@ -1087,6 +1086,39 @@ zod.z.object({
1087
1086
  page: zod.z.number().optional(),
1088
1087
  perPage: zod.z.number().optional()
1089
1088
  });
1089
+ var RunStatus = zod.z.enum([
1090
+ "PENDING",
1091
+ "EXECUTING",
1092
+ "PAUSED",
1093
+ "COMPLETED",
1094
+ "FAILED",
1095
+ "CANCELED"
1096
+ ]);
1097
+ var AttemptStatus = zod.z.enum([
1098
+ "PENDING",
1099
+ "EXECUTING",
1100
+ "PAUSED",
1101
+ "COMPLETED",
1102
+ "FAILED",
1103
+ "CANCELED"
1104
+ ]);
1105
+ var RetrieveRunResponse = zod.z.object({
1106
+ id: zod.z.string(),
1107
+ status: RunStatus,
1108
+ taskIdentifier: zod.z.string(),
1109
+ idempotencyKey: zod.z.string().optional(),
1110
+ version: zod.z.string().optional(),
1111
+ createdAt: zod.z.coerce.date(),
1112
+ updatedAt: zod.z.coerce.date(),
1113
+ attempts: zod.z.array(zod.z.object({
1114
+ id: zod.z.string(),
1115
+ status: AttemptStatus,
1116
+ createdAt: zod.z.coerce.date(),
1117
+ updatedAt: zod.z.coerce.date(),
1118
+ startedAt: zod.z.coerce.date().optional(),
1119
+ completedAt: zod.z.coerce.date().optional()
1120
+ }).optional())
1121
+ });
1090
1122
 
1091
1123
  // src/v3/apiErrors.ts
1092
1124
  var _APIError = class _APIError extends Error {
@@ -1382,19 +1414,6 @@ function requestInitWithCache(requestInit) {
1382
1414
  }
1383
1415
  }
1384
1416
  __name(requestInitWithCache, "requestInitWithCache");
1385
- var _SafeAsyncLocalStorage = class _SafeAsyncLocalStorage {
1386
- constructor() {
1387
- this.storage = new async_hooks.AsyncLocalStorage();
1388
- }
1389
- runWith(context2, fn) {
1390
- return this.storage.run(context2, fn);
1391
- }
1392
- getStore() {
1393
- return this.storage.getStore();
1394
- }
1395
- };
1396
- __name(_SafeAsyncLocalStorage, "SafeAsyncLocalStorage");
1397
- var SafeAsyncLocalStorage = _SafeAsyncLocalStorage;
1398
1417
 
1399
1418
  // src/v3/apiClient/index.ts
1400
1419
  var zodFetchOptions = {
@@ -1460,6 +1479,12 @@ var _ApiClient = class _ApiClient {
1460
1479
  headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1461
1480
  }, zodFetchOptions);
1462
1481
  }
1482
+ retrieveRun(runId) {
1483
+ return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
1484
+ method: "GET",
1485
+ headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
1486
+ }, zodFetchOptions);
1487
+ }
1463
1488
  replayRun(runId) {
1464
1489
  return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
1465
1490
  method: "POST",
@@ -1540,19 +1565,33 @@ getHeaders_fn = /* @__PURE__ */ __name(function(spanParentAsLink) {
1540
1565
  }, "#getHeaders");
1541
1566
  __name(_ApiClient, "ApiClient");
1542
1567
  var ApiClient = _ApiClient;
1543
- var _getStore, getStore_fn;
1544
- var _ApiClientManager = class _ApiClientManager {
1568
+
1569
+ // src/v3/apiClientManager/index.ts
1570
+ var API_NAME2 = "api-client";
1571
+ var _getConfig, getConfig_fn;
1572
+ var _APIClientManagerAPI = class _APIClientManagerAPI {
1545
1573
  constructor() {
1546
- __privateAdd(this, _getStore);
1547
- __publicField(this, "_storage", new SafeAsyncLocalStorage());
1574
+ __privateAdd(this, _getConfig);
1575
+ }
1576
+ static getInstance() {
1577
+ if (!this._instance) {
1578
+ this._instance = new _APIClientManagerAPI();
1579
+ }
1580
+ return this._instance;
1581
+ }
1582
+ disable() {
1583
+ unregisterGlobal(API_NAME2);
1584
+ }
1585
+ setGlobalAPIClientConfiguration(config) {
1586
+ return registerGlobal(API_NAME2, config);
1548
1587
  }
1549
1588
  get baseURL() {
1550
- const store = __privateMethod(this, _getStore, getStore_fn).call(this);
1589
+ const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
1551
1590
  return store?.baseURL ?? getEnvVar("TRIGGER_API_URL") ?? "https://api.trigger.dev";
1552
1591
  }
1553
1592
  get accessToken() {
1554
- const store = __privateMethod(this, _getStore, getStore_fn).call(this);
1555
- return store?.accessToken ?? getEnvVar("TRIGGER_SECRET_KEY");
1593
+ const store = __privateMethod(this, _getConfig, getConfig_fn).call(this);
1594
+ return store?.secretKey ?? getEnvVar("TRIGGER_SECRET_KEY");
1556
1595
  }
1557
1596
  get client() {
1558
1597
  if (!this.baseURL || !this.accessToken) {
@@ -1560,17 +1599,16 @@ var _ApiClientManager = class _ApiClientManager {
1560
1599
  }
1561
1600
  return new ApiClient(this.baseURL, this.accessToken);
1562
1601
  }
1563
- runWith(context2, fn) {
1564
- return this._storage.runWith(context2, fn);
1565
- }
1566
1602
  };
1567
- _getStore = new WeakSet();
1568
- getStore_fn = /* @__PURE__ */ __name(function() {
1569
- return this._storage.getStore();
1570
- }, "#getStore");
1571
- __name(_ApiClientManager, "ApiClientManager");
1572
- var ApiClientManager = _ApiClientManager;
1573
- var apiClientManager = new ApiClientManager();
1603
+ _getConfig = new WeakSet();
1604
+ getConfig_fn = /* @__PURE__ */ __name(function() {
1605
+ return getGlobal(API_NAME2);
1606
+ }, "#getConfig");
1607
+ __name(_APIClientManagerAPI, "APIClientManagerAPI");
1608
+ var APIClientManagerAPI = _APIClientManagerAPI;
1609
+
1610
+ // src/v3/apiClientManager-api.ts
1611
+ var apiClientManager = APIClientManagerAPI.getInstance();
1574
1612
 
1575
1613
  // src/v3/utils/ioSerialization.ts
1576
1614
  async function parsePacket(value) {
@@ -2241,7 +2279,7 @@ __name(_SimpleClock, "SimpleClock");
2241
2279
  var SimpleClock = _SimpleClock;
2242
2280
 
2243
2281
  // src/v3/clock/index.ts
2244
- var API_NAME2 = "clock";
2282
+ var API_NAME3 = "clock";
2245
2283
  var SIMPLE_CLOCK = new SimpleClock();
2246
2284
  var _getClock, getClock_fn;
2247
2285
  var _ClockAPI = class _ClockAPI {
@@ -2255,7 +2293,7 @@ var _ClockAPI = class _ClockAPI {
2255
2293
  return this._instance;
2256
2294
  }
2257
2295
  setGlobalClock(clock2) {
2258
- return registerGlobal(API_NAME2, clock2);
2296
+ return registerGlobal(API_NAME3, clock2);
2259
2297
  }
2260
2298
  preciseNow() {
2261
2299
  return __privateMethod(this, _getClock, getClock_fn).call(this).preciseNow();
@@ -2266,7 +2304,7 @@ var _ClockAPI = class _ClockAPI {
2266
2304
  };
2267
2305
  _getClock = new WeakSet();
2268
2306
  getClock_fn = /* @__PURE__ */ __name(function() {
2269
- return getGlobal(API_NAME2) ?? SIMPLE_CLOCK;
2307
+ return getGlobal(API_NAME3) ?? SIMPLE_CLOCK;
2270
2308
  }, "#getClock");
2271
2309
  __name(_ClockAPI, "ClockAPI");
2272
2310
  var ClockAPI = _ClockAPI;
@@ -2279,7 +2317,6 @@ var logLevels = [
2279
2317
  "none",
2280
2318
  "error",
2281
2319
  "warn",
2282
- "log",
2283
2320
  "info",
2284
2321
  "debug"
2285
2322
  ];
@@ -2292,7 +2329,7 @@ var _OtelTaskLogger = class _OtelTaskLogger {
2292
2329
  this._level = logLevels.indexOf(_config.level);
2293
2330
  }
2294
2331
  debug(message, properties) {
2295
- if (this._level < 5)
2332
+ if (this._level < 4)
2296
2333
  return;
2297
2334
  __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "debug", apiLogs.SeverityNumber.DEBUG, properties);
2298
2335
  }
@@ -2302,7 +2339,7 @@ var _OtelTaskLogger = class _OtelTaskLogger {
2302
2339
  __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "log", apiLogs.SeverityNumber.INFO, properties);
2303
2340
  }
2304
2341
  info(message, properties) {
2305
- if (this._level < 4)
2342
+ if (this._level < 3)
2306
2343
  return;
2307
2344
  __privateMethod(this, _emitLog, emitLog_fn).call(this, message, __privateMethod(this, _getTimestampInHrTime, getTimestampInHrTime_fn).call(this), "info", apiLogs.SeverityNumber.INFO, properties);
2308
2345
  }