@trigger.dev/core 3.0.0-beta.45 → 3.0.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{catalog-mlNxCacM.d.ts → catalog-N-X0Te3W.d.mts} +5 -23
- package/dist/{catalog-QcLmPVsr.d.mts → catalog-NxVZnWZh.d.ts} +5 -23
- package/dist/{common-55Mqj8JP.d.mts → common-fIyU5pmz.d.mts} +13 -0
- package/dist/{common-55Mqj8JP.d.ts → common-fIyU5pmz.d.ts} +13 -0
- package/dist/{manager-6NRInm7C.d.ts → manager-2ZQ3_twq.d.ts} +1 -1
- package/dist/{manager-2AqSY67c.d.mts → manager-X_HrWQ7_.d.mts} +1 -1
- package/dist/{messages-EJX0bMsF.d.mts → messages-Sggr4tid.d.mts} +233 -70
- package/dist/{messages-EJX0bMsF.d.ts → messages-Sggr4tid.d.ts} +233 -70
- package/dist/{schemas-Sb0sJcEt.d.mts → schemas-Zy7mGFgD.d.mts} +22 -0
- package/dist/{schemas-Sb0sJcEt.d.ts → schemas-Zy7mGFgD.d.ts} +22 -0
- package/dist/tracer-N0p2Fuuv.d.mts +23 -0
- package/dist/tracer-N0p2Fuuv.d.ts +23 -0
- package/dist/v3/dev/index.d.mts +2 -2
- package/dist/v3/dev/index.d.ts +2 -2
- package/dist/v3/dev/index.js.map +1 -1
- package/dist/v3/dev/index.mjs.map +1 -1
- package/dist/v3/index.d.mts +50 -38
- package/dist/v3/index.d.ts +50 -38
- package/dist/v3/index.js +503 -343
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +499 -344
- package/dist/v3/index.mjs.map +1 -1
- package/dist/v3/otel/index.js +15 -5
- package/dist/v3/otel/index.js.map +1 -1
- package/dist/v3/otel/index.mjs +15 -5
- package/dist/v3/otel/index.mjs.map +1 -1
- package/dist/v3/prod/index.d.mts +4 -4
- package/dist/v3/prod/index.d.ts +4 -4
- package/dist/v3/prod/index.js +7 -131
- package/dist/v3/prod/index.js.map +1 -1
- package/dist/v3/prod/index.mjs +7 -131
- package/dist/v3/prod/index.mjs.map +1 -1
- package/dist/v3/schemas/index.d.mts +16 -4
- package/dist/v3/schemas/index.d.ts +16 -4
- package/dist/v3/schemas/index.js +35 -40
- package/dist/v3/schemas/index.js.map +1 -1
- package/dist/v3/schemas/index.mjs +35 -41
- package/dist/v3/schemas/index.mjs.map +1 -1
- package/dist/v3/utils/timers.d.mts +6 -0
- package/dist/v3/utils/timers.d.ts +6 -0
- package/dist/v3/utils/timers.js +31 -0
- package/dist/v3/utils/timers.js.map +1 -0
- package/dist/v3/utils/timers.mjs +28 -0
- package/dist/v3/utils/timers.mjs.map +1 -0
- package/dist/v3/workers/index.d.mts +7 -6
- package/dist/v3/workers/index.d.ts +7 -6
- package/dist/v3/workers/index.js +251 -96
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +251 -96
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodNamespace.js +41 -18
- package/dist/v3/zodNamespace.js.map +1 -1
- package/dist/v3/zodNamespace.mjs +42 -19
- package/dist/v3/zodNamespace.mjs.map +1 -1
- package/dist/v3/zodSocket.d.mts +8 -3
- package/dist/v3/zodSocket.d.ts +8 -3
- package/dist/v3/zodSocket.js +56 -25
- package/dist/v3/zodSocket.js.map +1 -1
- package/dist/v3/zodSocket.mjs +57 -26
- package/dist/v3/zodSocket.mjs.map +1 -1
- package/dist/v3/zodfetch.d.mts +15 -2
- package/dist/v3/zodfetch.d.ts +15 -2
- package/dist/v3/zodfetch.js +248 -28
- package/dist/v3/zodfetch.js.map +1 -1
- package/dist/v3/zodfetch.mjs +246 -29
- package/dist/v3/zodfetch.mjs.map +1 -1
- package/package.json +10 -2
package/dist/v3/workers/index.js
CHANGED
|
@@ -76,6 +76,39 @@ var SerializedError = zod.z.object({
|
|
|
76
76
|
name: zod.z.string().optional(),
|
|
77
77
|
stackTrace: zod.z.string().optional()
|
|
78
78
|
});
|
|
79
|
+
function sanitizeError(error) {
|
|
80
|
+
switch (error.type) {
|
|
81
|
+
case "BUILT_IN_ERROR": {
|
|
82
|
+
return {
|
|
83
|
+
type: "BUILT_IN_ERROR",
|
|
84
|
+
message: error.message?.replace(/\0/g, ""),
|
|
85
|
+
name: error.name?.replace(/\0/g, ""),
|
|
86
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
case "STRING_ERROR": {
|
|
90
|
+
return {
|
|
91
|
+
type: "STRING_ERROR",
|
|
92
|
+
raw: error.raw.replace(/\0/g, "")
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
case "CUSTOM_ERROR": {
|
|
96
|
+
return {
|
|
97
|
+
type: "CUSTOM_ERROR",
|
|
98
|
+
raw: error.raw.replace(/\0/g, "")
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
case "INTERNAL_ERROR": {
|
|
102
|
+
return {
|
|
103
|
+
type: "INTERNAL_ERROR",
|
|
104
|
+
code: error.code,
|
|
105
|
+
message: error.message?.replace(/\0/g, ""),
|
|
106
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
__name(sanitizeError, "sanitizeError");
|
|
79
112
|
|
|
80
113
|
// src/v3/limits.ts
|
|
81
114
|
var OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 256;
|
|
@@ -138,7 +171,10 @@ var SemanticInternalAttributes = {
|
|
|
138
171
|
LINK_TITLE: "$link.title",
|
|
139
172
|
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
140
173
|
USAGE_DURATION_MS: "$usage.durationMs",
|
|
141
|
-
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
174
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents",
|
|
175
|
+
RATE_LIMIT_LIMIT: "response.rateLimit.limit",
|
|
176
|
+
RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
|
|
177
|
+
RATE_LIMIT_RESET: "response.rateLimit.reset"
|
|
142
178
|
};
|
|
143
179
|
|
|
144
180
|
// src/v3/utils/flattenAttributes.ts
|
|
@@ -370,7 +406,7 @@ function getEnvVar(name) {
|
|
|
370
406
|
__name(getEnvVar, "getEnvVar");
|
|
371
407
|
|
|
372
408
|
// package.json
|
|
373
|
-
var version = "3.0.0-beta.
|
|
409
|
+
var version = "3.0.0-beta.47";
|
|
374
410
|
|
|
375
411
|
// src/v3/otel/tracingSDK.ts
|
|
376
412
|
var _a;
|
|
@@ -511,17 +547,24 @@ __name(setLogLevel, "setLogLevel");
|
|
|
511
547
|
// src/v3/otel/index.ts
|
|
512
548
|
function recordSpanException(span, error) {
|
|
513
549
|
if (error instanceof Error) {
|
|
514
|
-
span.recordException(error);
|
|
550
|
+
span.recordException(sanitizeSpanError(error));
|
|
515
551
|
} else if (typeof error === "string") {
|
|
516
|
-
span.recordException(
|
|
552
|
+
span.recordException(error.replace(/\0/g, ""));
|
|
517
553
|
} else {
|
|
518
|
-
span.recordException(
|
|
554
|
+
span.recordException(JSON.stringify(error).replace(/\0/g, ""));
|
|
519
555
|
}
|
|
520
556
|
span.setStatus({
|
|
521
557
|
code: api.SpanStatusCode.ERROR
|
|
522
558
|
});
|
|
523
559
|
}
|
|
524
560
|
__name(recordSpanException, "recordSpanException");
|
|
561
|
+
function sanitizeSpanError(error) {
|
|
562
|
+
const sanitizedError = new Error(error.message.replace(/\0/g, ""));
|
|
563
|
+
sanitizedError.name = error.name.replace(/\0/g, "");
|
|
564
|
+
sanitizedError.stack = error.stack?.replace(/\0/g, "");
|
|
565
|
+
return sanitizedError;
|
|
566
|
+
}
|
|
567
|
+
__name(sanitizeSpanError, "sanitizeSpanError");
|
|
525
568
|
var MachineCpu = zod.z.union([
|
|
526
569
|
zod.z.literal(0.25),
|
|
527
570
|
zod.z.literal(0.5),
|
|
@@ -621,6 +664,7 @@ var TaskRun = zod.z.object({
|
|
|
621
664
|
createdAt: zod.z.coerce.date(),
|
|
622
665
|
startedAt: zod.z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
623
666
|
idempotencyKey: zod.z.string().optional(),
|
|
667
|
+
maxAttempts: zod.z.number().optional(),
|
|
624
668
|
durationMs: zod.z.number().default(0),
|
|
625
669
|
costInCents: zod.z.number().default(0),
|
|
626
670
|
baseCostInCents: zod.z.number().default(0)
|
|
@@ -912,6 +956,7 @@ zod.z.enum([
|
|
|
912
956
|
]);
|
|
913
957
|
zod.z.object({
|
|
914
958
|
runId: zod.z.string(),
|
|
959
|
+
attemptCount: zod.z.number().optional(),
|
|
915
960
|
messageId: zod.z.string(),
|
|
916
961
|
isTest: zod.z.boolean(),
|
|
917
962
|
traceContext: zod.z.record(zod.z.unknown()),
|
|
@@ -987,7 +1032,8 @@ var TriggerTaskRequestBody = zod.z.object({
|
|
|
987
1032
|
test: zod.z.boolean().optional(),
|
|
988
1033
|
payloadType: zod.z.string().optional(),
|
|
989
1034
|
delay: zod.z.string().or(zod.z.coerce.date()).optional(),
|
|
990
|
-
ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional()
|
|
1035
|
+
ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional(),
|
|
1036
|
+
maxAttempts: zod.z.number().int().optional()
|
|
991
1037
|
}).optional()
|
|
992
1038
|
});
|
|
993
1039
|
var TriggerTaskResponse = zod.z.object({
|
|
@@ -1317,10 +1363,34 @@ var EnvironmentVariable = zod.z.object({
|
|
|
1317
1363
|
});
|
|
1318
1364
|
var EnvironmentVariables = zod.z.array(EnvironmentVariable);
|
|
1319
1365
|
|
|
1366
|
+
// src/v3/utils/retries.ts
|
|
1367
|
+
var defaultRetryOptions = {
|
|
1368
|
+
maxAttempts: 3,
|
|
1369
|
+
factor: 2,
|
|
1370
|
+
minTimeoutInMs: 1e3,
|
|
1371
|
+
maxTimeoutInMs: 6e4,
|
|
1372
|
+
randomize: true
|
|
1373
|
+
};
|
|
1374
|
+
function calculateNextRetryDelay(options, attempt) {
|
|
1375
|
+
const opts = {
|
|
1376
|
+
...defaultRetryOptions,
|
|
1377
|
+
...options
|
|
1378
|
+
};
|
|
1379
|
+
if (attempt >= opts.maxAttempts) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
1383
|
+
const random = randomize ? Math.random() + 1 : 1;
|
|
1384
|
+
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
1385
|
+
return Math.round(timeout);
|
|
1386
|
+
}
|
|
1387
|
+
__name(calculateNextRetryDelay, "calculateNextRetryDelay");
|
|
1388
|
+
|
|
1320
1389
|
// src/v3/apiClient/errors.ts
|
|
1321
1390
|
var _ApiError = class _ApiError extends Error {
|
|
1322
1391
|
constructor(status, error, message, headers) {
|
|
1323
1392
|
super(`${_ApiError.makeMessage(status, error, message)}`);
|
|
1393
|
+
this.name = "TriggerApiError";
|
|
1324
1394
|
this.status = status;
|
|
1325
1395
|
this.headers = headers;
|
|
1326
1396
|
const data = error;
|
|
@@ -1441,6 +1511,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
|
|
|
1441
1511
|
super(...arguments);
|
|
1442
1512
|
__publicField(this, "status", 429);
|
|
1443
1513
|
}
|
|
1514
|
+
get millisecondsUntilReset() {
|
|
1515
|
+
const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
|
|
1516
|
+
if (typeof resetAtUnixEpochMs === "string") {
|
|
1517
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
1518
|
+
if (isNaN(resetAtUnixEpoch)) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1444
1524
|
};
|
|
1445
1525
|
__name(_RateLimitError, "RateLimitError");
|
|
1446
1526
|
var RateLimitError = _RateLimitError;
|
|
@@ -1455,28 +1535,11 @@ function castToError(err) {
|
|
|
1455
1535
|
}
|
|
1456
1536
|
__name(castToError, "castToError");
|
|
1457
1537
|
|
|
1458
|
-
// src/v3/utils/
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
factor: 2,
|
|
1462
|
-
minTimeoutInMs: 1e3,
|
|
1463
|
-
maxTimeoutInMs: 6e4,
|
|
1464
|
-
randomize: true
|
|
1465
|
-
};
|
|
1466
|
-
function calculateNextRetryDelay(options, attempt) {
|
|
1467
|
-
const opts = {
|
|
1468
|
-
...defaultRetryOptions,
|
|
1469
|
-
...options
|
|
1470
|
-
};
|
|
1471
|
-
if (attempt >= opts.maxAttempts) {
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
1475
|
-
const random = randomize ? Math.random() + 1 : 1;
|
|
1476
|
-
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
1477
|
-
return Math.round(timeout);
|
|
1538
|
+
// src/v3/utils/styleAttributes.ts
|
|
1539
|
+
function accessoryAttributes(accessory) {
|
|
1540
|
+
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
1478
1541
|
}
|
|
1479
|
-
__name(
|
|
1542
|
+
__name(accessoryAttributes, "accessoryAttributes");
|
|
1480
1543
|
|
|
1481
1544
|
// src/v3/apiClient/pagination.ts
|
|
1482
1545
|
var _CursorPage = class _CursorPage {
|
|
@@ -1636,16 +1699,47 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
1636
1699
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
1637
1700
|
}
|
|
1638
1701
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
1639
|
-
async function
|
|
1702
|
+
async function traceZodFetch(params, callback) {
|
|
1703
|
+
if (!params.options?.tracer) {
|
|
1704
|
+
return callback();
|
|
1705
|
+
}
|
|
1706
|
+
const url = new URL(params.url);
|
|
1707
|
+
const method = params.requestInit?.method ?? "GET";
|
|
1708
|
+
const name = params.options.name ?? `${method} ${url.pathname}`;
|
|
1709
|
+
return await params.options.tracer.startActiveSpan(name, async (span) => {
|
|
1710
|
+
return await callback(span);
|
|
1711
|
+
}, {
|
|
1712
|
+
attributes: {
|
|
1713
|
+
[SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
|
|
1714
|
+
...params.options.attributes
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
__name(traceZodFetch, "traceZodFetch");
|
|
1719
|
+
async function _doZodFetch(schema, url, requestInit, options) {
|
|
1720
|
+
const $requestInit = await requestInit;
|
|
1721
|
+
return traceZodFetch({
|
|
1722
|
+
url,
|
|
1723
|
+
requestInit: $requestInit,
|
|
1724
|
+
options
|
|
1725
|
+
}, async (span) => {
|
|
1726
|
+
const result = await _doZodFetchWithRetries(schema, url, $requestInit, options);
|
|
1727
|
+
if (options?.onResponseBody && span) {
|
|
1728
|
+
options.onResponseBody(result.data, span);
|
|
1729
|
+
}
|
|
1730
|
+
return result;
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
__name(_doZodFetch, "_doZodFetch");
|
|
1734
|
+
async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
|
|
1640
1735
|
try {
|
|
1641
|
-
const
|
|
1642
|
-
const response = await fetch(url, requestInitWithCache($requestInit));
|
|
1736
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
1643
1737
|
const responseHeaders = createResponseHeaders(response.headers);
|
|
1644
1738
|
if (!response.ok) {
|
|
1645
1739
|
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
1646
1740
|
if (retryResult.retry) {
|
|
1647
|
-
await
|
|
1648
|
-
return await
|
|
1741
|
+
await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
|
|
1742
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1649
1743
|
} else {
|
|
1650
1744
|
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
1651
1745
|
const errJSON = safeJsonParse(errText);
|
|
@@ -1673,8 +1767,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1673
1767
|
};
|
|
1674
1768
|
const delay = calculateNextRetryDelay(retry, attempt);
|
|
1675
1769
|
if (delay) {
|
|
1676
|
-
await
|
|
1677
|
-
return await
|
|
1770
|
+
await waitForRetry(url, attempt + 1, delay, options, requestInit);
|
|
1771
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1678
1772
|
}
|
|
1679
1773
|
}
|
|
1680
1774
|
throw new ApiConnectionError({
|
|
@@ -1682,7 +1776,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1682
1776
|
});
|
|
1683
1777
|
}
|
|
1684
1778
|
}
|
|
1685
|
-
__name(
|
|
1779
|
+
__name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
|
|
1686
1780
|
function castToError2(err) {
|
|
1687
1781
|
if (err instanceof Error)
|
|
1688
1782
|
return err;
|
|
@@ -1719,8 +1813,25 @@ function shouldRetry(response, attempt, retryOptions) {
|
|
|
1719
1813
|
return shouldRetryForOptions();
|
|
1720
1814
|
if (response.status === 409)
|
|
1721
1815
|
return shouldRetryForOptions();
|
|
1722
|
-
if (response.status === 429)
|
|
1816
|
+
if (response.status === 429) {
|
|
1817
|
+
if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
|
|
1818
|
+
return {
|
|
1819
|
+
retry: false
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
|
|
1823
|
+
if (resetAtUnixEpochMs) {
|
|
1824
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
1825
|
+
const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
|
|
1826
|
+
if (delay > 0) {
|
|
1827
|
+
return {
|
|
1828
|
+
retry: true,
|
|
1829
|
+
delay
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1723
1833
|
return shouldRetryForOptions();
|
|
1834
|
+
}
|
|
1724
1835
|
if (response.status >= 500)
|
|
1725
1836
|
return shouldRetryForOptions();
|
|
1726
1837
|
return {
|
|
@@ -1883,9 +1994,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
|
|
|
1883
1994
|
}, "#fetchPage");
|
|
1884
1995
|
__name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
|
|
1885
1996
|
var OffsetLimitPagePromise = _OffsetLimitPagePromise;
|
|
1997
|
+
async function waitForRetry(url, attempt, delay, options, requestInit, response) {
|
|
1998
|
+
if (options?.tracer) {
|
|
1999
|
+
const method = requestInit?.method ?? "GET";
|
|
2000
|
+
return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
|
|
2001
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2002
|
+
}, {
|
|
2003
|
+
attributes: {
|
|
2004
|
+
[SemanticInternalAttributes.STYLE_ICON]: "wait",
|
|
2005
|
+
...accessoryAttributes({
|
|
2006
|
+
items: [
|
|
2007
|
+
{
|
|
2008
|
+
text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
|
|
2009
|
+
variant: "normal"
|
|
2010
|
+
}
|
|
2011
|
+
],
|
|
2012
|
+
style: "codepath"
|
|
2013
|
+
})
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2018
|
+
}
|
|
2019
|
+
__name(waitForRetry, "waitForRetry");
|
|
1886
2020
|
|
|
1887
2021
|
// src/v3/apiClient/index.ts
|
|
1888
|
-
var
|
|
2022
|
+
var DEFAULT_ZOD_FETCH_OPTIONS = {
|
|
1889
2023
|
retry: {
|
|
1890
2024
|
maxAttempts: 3,
|
|
1891
2025
|
minTimeoutInMs: 1e3,
|
|
@@ -1896,17 +2030,18 @@ var zodFetchOptions = {
|
|
|
1896
2030
|
};
|
|
1897
2031
|
var _getHeaders, getHeaders_fn;
|
|
1898
2032
|
var _ApiClient = class _ApiClient {
|
|
1899
|
-
constructor(baseUrl, accessToken) {
|
|
2033
|
+
constructor(baseUrl, accessToken, requestOptions = {}) {
|
|
1900
2034
|
__privateAdd(this, _getHeaders);
|
|
1901
2035
|
this.accessToken = accessToken;
|
|
1902
2036
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2037
|
+
this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
|
|
1903
2038
|
}
|
|
1904
|
-
async getRunResult(runId) {
|
|
2039
|
+
async getRunResult(runId, requestOptions) {
|
|
1905
2040
|
try {
|
|
1906
2041
|
return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
|
|
1907
2042
|
method: "GET",
|
|
1908
2043
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1909
|
-
},
|
|
2044
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1910
2045
|
} catch (error) {
|
|
1911
2046
|
if (error instanceof ApiError) {
|
|
1912
2047
|
if (error.status === 404) {
|
|
@@ -1916,47 +2051,47 @@ var _ApiClient = class _ApiClient {
|
|
|
1916
2051
|
throw error;
|
|
1917
2052
|
}
|
|
1918
2053
|
}
|
|
1919
|
-
async getBatchResults(batchId) {
|
|
2054
|
+
async getBatchResults(batchId, requestOptions) {
|
|
1920
2055
|
return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
|
|
1921
2056
|
method: "GET",
|
|
1922
2057
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1923
|
-
},
|
|
2058
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1924
2059
|
}
|
|
1925
|
-
triggerTask(taskId, body, options) {
|
|
2060
|
+
triggerTask(taskId, body, options, requestOptions) {
|
|
1926
2061
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1927
2062
|
return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
|
|
1928
2063
|
method: "POST",
|
|
1929
2064
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1930
2065
|
body: JSON.stringify(body)
|
|
1931
|
-
},
|
|
2066
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1932
2067
|
}
|
|
1933
|
-
batchTriggerTask(taskId, body, options) {
|
|
2068
|
+
batchTriggerTask(taskId, body, options, requestOptions) {
|
|
1934
2069
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1935
2070
|
return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
|
|
1936
2071
|
method: "POST",
|
|
1937
2072
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1938
2073
|
body: JSON.stringify(body)
|
|
1939
|
-
},
|
|
2074
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1940
2075
|
}
|
|
1941
|
-
createUploadPayloadUrl(filename) {
|
|
2076
|
+
createUploadPayloadUrl(filename, requestOptions) {
|
|
1942
2077
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1943
2078
|
method: "PUT",
|
|
1944
2079
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1945
|
-
},
|
|
2080
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1946
2081
|
}
|
|
1947
|
-
getPayloadUrl(filename) {
|
|
2082
|
+
getPayloadUrl(filename, requestOptions) {
|
|
1948
2083
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1949
2084
|
method: "GET",
|
|
1950
2085
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1951
|
-
},
|
|
2086
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1952
2087
|
}
|
|
1953
|
-
retrieveRun(runId) {
|
|
2088
|
+
retrieveRun(runId, requestOptions) {
|
|
1954
2089
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
|
|
1955
2090
|
method: "GET",
|
|
1956
2091
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1957
|
-
},
|
|
2092
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1958
2093
|
}
|
|
1959
|
-
listRuns(query) {
|
|
2094
|
+
listRuns(query, requestOptions) {
|
|
1960
2095
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1961
2096
|
return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
|
|
1962
2097
|
query: searchParams,
|
|
@@ -1966,9 +2101,9 @@ var _ApiClient = class _ApiClient {
|
|
|
1966
2101
|
}, {
|
|
1967
2102
|
method: "GET",
|
|
1968
2103
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1969
|
-
},
|
|
2104
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1970
2105
|
}
|
|
1971
|
-
listProjectRuns(projectRef, query) {
|
|
2106
|
+
listProjectRuns(projectRef, query, requestOptions) {
|
|
1972
2107
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1973
2108
|
if (query?.env) {
|
|
1974
2109
|
searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
|
|
@@ -1981,35 +2116,35 @@ var _ApiClient = class _ApiClient {
|
|
|
1981
2116
|
}, {
|
|
1982
2117
|
method: "GET",
|
|
1983
2118
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1984
|
-
},
|
|
2119
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1985
2120
|
}
|
|
1986
|
-
replayRun(runId) {
|
|
2121
|
+
replayRun(runId, requestOptions) {
|
|
1987
2122
|
return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
|
|
1988
2123
|
method: "POST",
|
|
1989
2124
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1990
|
-
},
|
|
2125
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1991
2126
|
}
|
|
1992
|
-
cancelRun(runId) {
|
|
2127
|
+
cancelRun(runId, requestOptions) {
|
|
1993
2128
|
return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
|
|
1994
2129
|
method: "POST",
|
|
1995
2130
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1996
|
-
},
|
|
2131
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1997
2132
|
}
|
|
1998
|
-
rescheduleRun(runId, body) {
|
|
2133
|
+
rescheduleRun(runId, body, requestOptions) {
|
|
1999
2134
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
|
|
2000
2135
|
method: "POST",
|
|
2001
2136
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2002
2137
|
body: JSON.stringify(body)
|
|
2003
|
-
},
|
|
2138
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2004
2139
|
}
|
|
2005
|
-
createSchedule(options) {
|
|
2140
|
+
createSchedule(options, requestOptions) {
|
|
2006
2141
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
|
|
2007
2142
|
method: "POST",
|
|
2008
2143
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2009
2144
|
body: JSON.stringify(options)
|
|
2010
|
-
});
|
|
2145
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2011
2146
|
}
|
|
2012
|
-
listSchedules(options) {
|
|
2147
|
+
listSchedules(options, requestOptions) {
|
|
2013
2148
|
const searchParams = new URLSearchParams();
|
|
2014
2149
|
if (options?.page) {
|
|
2015
2150
|
searchParams.append("page", options.page.toString());
|
|
@@ -2023,77 +2158,77 @@ var _ApiClient = class _ApiClient {
|
|
|
2023
2158
|
}, {
|
|
2024
2159
|
method: "GET",
|
|
2025
2160
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2026
|
-
});
|
|
2161
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2027
2162
|
}
|
|
2028
|
-
retrieveSchedule(scheduleId) {
|
|
2163
|
+
retrieveSchedule(scheduleId, requestOptions) {
|
|
2029
2164
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2030
2165
|
method: "GET",
|
|
2031
2166
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2032
|
-
});
|
|
2167
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2033
2168
|
}
|
|
2034
|
-
updateSchedule(scheduleId, options) {
|
|
2169
|
+
updateSchedule(scheduleId, options, requestOptions) {
|
|
2035
2170
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2036
2171
|
method: "PUT",
|
|
2037
2172
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2038
2173
|
body: JSON.stringify(options)
|
|
2039
|
-
});
|
|
2174
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2040
2175
|
}
|
|
2041
|
-
deactivateSchedule(scheduleId) {
|
|
2176
|
+
deactivateSchedule(scheduleId, requestOptions) {
|
|
2042
2177
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
|
|
2043
2178
|
method: "POST",
|
|
2044
2179
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2045
|
-
});
|
|
2180
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2046
2181
|
}
|
|
2047
|
-
activateSchedule(scheduleId) {
|
|
2182
|
+
activateSchedule(scheduleId, requestOptions) {
|
|
2048
2183
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
|
|
2049
2184
|
method: "POST",
|
|
2050
2185
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2051
|
-
});
|
|
2186
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2052
2187
|
}
|
|
2053
|
-
deleteSchedule(scheduleId) {
|
|
2188
|
+
deleteSchedule(scheduleId, requestOptions) {
|
|
2054
2189
|
return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2055
2190
|
method: "DELETE",
|
|
2056
2191
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2057
|
-
});
|
|
2192
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2058
2193
|
}
|
|
2059
|
-
listEnvVars(projectRef, slug) {
|
|
2194
|
+
listEnvVars(projectRef, slug, requestOptions) {
|
|
2060
2195
|
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2061
2196
|
method: "GET",
|
|
2062
2197
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2063
|
-
});
|
|
2198
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2064
2199
|
}
|
|
2065
|
-
importEnvVars(projectRef, slug, body) {
|
|
2200
|
+
importEnvVars(projectRef, slug, body, requestOptions) {
|
|
2066
2201
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2067
2202
|
method: "POST",
|
|
2068
2203
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2069
2204
|
body: JSON.stringify(body)
|
|
2070
|
-
});
|
|
2205
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2071
2206
|
}
|
|
2072
|
-
retrieveEnvVar(projectRef, slug, key) {
|
|
2207
|
+
retrieveEnvVar(projectRef, slug, key, requestOptions) {
|
|
2073
2208
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2074
2209
|
method: "GET",
|
|
2075
2210
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2076
|
-
});
|
|
2211
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2077
2212
|
}
|
|
2078
|
-
createEnvVar(projectRef, slug, body) {
|
|
2213
|
+
createEnvVar(projectRef, slug, body, requestOptions) {
|
|
2079
2214
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2080
2215
|
method: "POST",
|
|
2081
2216
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2082
2217
|
body: JSON.stringify(body)
|
|
2083
|
-
});
|
|
2218
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2084
2219
|
}
|
|
2085
|
-
updateEnvVar(projectRef, slug, key, body) {
|
|
2220
|
+
updateEnvVar(projectRef, slug, key, body, requestOptions) {
|
|
2086
2221
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2087
2222
|
method: "PUT",
|
|
2088
2223
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2089
2224
|
body: JSON.stringify(body)
|
|
2090
|
-
});
|
|
2225
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2091
2226
|
}
|
|
2092
|
-
deleteEnvVar(projectRef, slug, key) {
|
|
2227
|
+
deleteEnvVar(projectRef, slug, key, requestOptions) {
|
|
2093
2228
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2094
2229
|
method: "DELETE",
|
|
2095
2230
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2096
|
-
});
|
|
2231
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2097
2232
|
}
|
|
2098
2233
|
};
|
|
2099
2234
|
_getHeaders = new WeakSet();
|
|
@@ -2148,6 +2283,20 @@ function createSearchQueryForListRuns(query) {
|
|
|
2148
2283
|
return searchParams;
|
|
2149
2284
|
}
|
|
2150
2285
|
__name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
|
|
2286
|
+
function mergeRequestOptions(defaultOptions, options) {
|
|
2287
|
+
if (!options) {
|
|
2288
|
+
return defaultOptions;
|
|
2289
|
+
}
|
|
2290
|
+
return {
|
|
2291
|
+
...defaultOptions,
|
|
2292
|
+
...options,
|
|
2293
|
+
retry: {
|
|
2294
|
+
...defaultOptions.retry,
|
|
2295
|
+
...options.retry
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
__name(mergeRequestOptions, "mergeRequestOptions");
|
|
2151
2300
|
|
|
2152
2301
|
// src/v3/apiClientManager/index.ts
|
|
2153
2302
|
var API_NAME2 = "api-client";
|
|
@@ -2412,12 +2561,6 @@ async function loadSuperJSON() {
|
|
|
2412
2561
|
}
|
|
2413
2562
|
__name(loadSuperJSON, "loadSuperJSON");
|
|
2414
2563
|
|
|
2415
|
-
// src/v3/utils/styleAttributes.ts
|
|
2416
|
-
function accessoryAttributes(accessory) {
|
|
2417
|
-
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
2418
|
-
}
|
|
2419
|
-
__name(accessoryAttributes, "accessoryAttributes");
|
|
2420
|
-
|
|
2421
2564
|
// src/v3/workers/taskExecutor.ts
|
|
2422
2565
|
var _callRun, callRun_fn, _callInitFunctions, callInitFunctions_fn, _callConfigInit, callConfigInit_fn, _callOnSuccessFunctions, callOnSuccessFunctions_fn, _callOnSuccessFunction, callOnSuccessFunction_fn, _callOnFailureFunctions, callOnFailureFunctions_fn, _callOnFailureFunction, callOnFailureFunction_fn, _callOnStartFunctions, callOnStartFunctions_fn, _callOnStartFunction, callOnStartFunction_fn, _callTaskCleanup, callTaskCleanup_fn, _handleError, handleError_fn;
|
|
2423
2566
|
var _TaskExecutor = class _TaskExecutor {
|
|
@@ -2505,7 +2648,7 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2505
2648
|
return {
|
|
2506
2649
|
id: execution.run.id,
|
|
2507
2650
|
ok: false,
|
|
2508
|
-
error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
|
|
2651
|
+
error: sanitizeError(handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError)),
|
|
2509
2652
|
retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
|
|
2510
2653
|
skippedRetrying: handleErrorResult.status === "skipped"
|
|
2511
2654
|
};
|
|
@@ -2694,7 +2837,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
|
|
|
2694
2837
|
status: "noop"
|
|
2695
2838
|
};
|
|
2696
2839
|
}
|
|
2697
|
-
|
|
2840
|
+
if (error2 instanceof Error && error2.name === "AbortTaskRunError") {
|
|
2841
|
+
return {
|
|
2842
|
+
status: "skipped"
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
if (execution.run.maxAttempts) {
|
|
2846
|
+
retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
|
|
2847
|
+
}
|
|
2848
|
+
let delay = calculateNextRetryDelay(retry, execution.attempt.number);
|
|
2849
|
+
if (delay && error2 instanceof Error && error2.name === "TriggerApiError" && error2.status === 429) {
|
|
2850
|
+
const rateLimitError = error2;
|
|
2851
|
+
delay = rateLimitError.millisecondsUntilReset;
|
|
2852
|
+
}
|
|
2698
2853
|
if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
|
|
2699
2854
|
return {
|
|
2700
2855
|
status: "skipped"
|