@trigger.dev/core 3.0.0-beta.46 → 3.0.0-beta.48
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-9G8AqnI9.d.ts → catalog-N-X0Te3W.d.mts} +5 -23
- package/dist/{catalog-Y0mRLMtJ.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-nXkzt5CT.d.mts → messages-Sggr4tid.d.mts} +162 -0
- package/dist/{messages-nXkzt5CT.d.ts → messages-Sggr4tid.d.ts} +162 -0
- package/dist/{schemas-CeAee_C2.d.mts → schemas-Zy7mGFgD.d.mts} +19 -0
- package/dist/{schemas-CeAee_C2.d.ts → schemas-Zy7mGFgD.d.ts} +19 -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/index.d.mts +50 -38
- package/dist/v3/index.d.ts +50 -38
- package/dist/v3/index.js +470 -303
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +467 -304
- 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 +3 -3
- package/dist/v3/prod/index.d.ts +3 -3
- package/dist/v3/schemas/index.d.mts +16 -4
- package/dist/v3/schemas/index.d.ts +16 -4
- package/dist/v3/schemas/index.js +3 -1
- package/dist/v3/schemas/index.js.map +1 -1
- package/dist/v3/schemas/index.mjs +3 -1
- package/dist/v3/schemas/index.mjs.map +1 -1
- package/dist/v3/workers/index.d.mts +7 -6
- package/dist/v3/workers/index.d.ts +7 -6
- package/dist/v3/workers/index.js +250 -96
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +250 -96
- package/dist/v3/workers/index.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 +1 -1
|
@@ -70,6 +70,39 @@ var SerializedError = z.object({
|
|
|
70
70
|
name: z.string().optional(),
|
|
71
71
|
stackTrace: z.string().optional()
|
|
72
72
|
});
|
|
73
|
+
function sanitizeError(error) {
|
|
74
|
+
switch (error.type) {
|
|
75
|
+
case "BUILT_IN_ERROR": {
|
|
76
|
+
return {
|
|
77
|
+
type: "BUILT_IN_ERROR",
|
|
78
|
+
message: error.message?.replace(/\0/g, ""),
|
|
79
|
+
name: error.name?.replace(/\0/g, ""),
|
|
80
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
case "STRING_ERROR": {
|
|
84
|
+
return {
|
|
85
|
+
type: "STRING_ERROR",
|
|
86
|
+
raw: error.raw.replace(/\0/g, "")
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
case "CUSTOM_ERROR": {
|
|
90
|
+
return {
|
|
91
|
+
type: "CUSTOM_ERROR",
|
|
92
|
+
raw: error.raw.replace(/\0/g, "")
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
case "INTERNAL_ERROR": {
|
|
96
|
+
return {
|
|
97
|
+
type: "INTERNAL_ERROR",
|
|
98
|
+
code: error.code,
|
|
99
|
+
message: error.message?.replace(/\0/g, ""),
|
|
100
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
__name(sanitizeError, "sanitizeError");
|
|
73
106
|
|
|
74
107
|
// src/v3/limits.ts
|
|
75
108
|
var OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 256;
|
|
@@ -132,7 +165,10 @@ var SemanticInternalAttributes = {
|
|
|
132
165
|
LINK_TITLE: "$link.title",
|
|
133
166
|
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
134
167
|
USAGE_DURATION_MS: "$usage.durationMs",
|
|
135
|
-
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
168
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents",
|
|
169
|
+
RATE_LIMIT_LIMIT: "response.rateLimit.limit",
|
|
170
|
+
RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
|
|
171
|
+
RATE_LIMIT_RESET: "response.rateLimit.reset"
|
|
136
172
|
};
|
|
137
173
|
|
|
138
174
|
// src/v3/utils/flattenAttributes.ts
|
|
@@ -364,7 +400,7 @@ function getEnvVar(name) {
|
|
|
364
400
|
__name(getEnvVar, "getEnvVar");
|
|
365
401
|
|
|
366
402
|
// package.json
|
|
367
|
-
var version = "3.0.0-beta.
|
|
403
|
+
var version = "3.0.0-beta.48";
|
|
368
404
|
|
|
369
405
|
// src/v3/otel/tracingSDK.ts
|
|
370
406
|
var _a;
|
|
@@ -505,17 +541,24 @@ __name(setLogLevel, "setLogLevel");
|
|
|
505
541
|
// src/v3/otel/index.ts
|
|
506
542
|
function recordSpanException(span, error) {
|
|
507
543
|
if (error instanceof Error) {
|
|
508
|
-
span.recordException(error);
|
|
544
|
+
span.recordException(sanitizeSpanError(error));
|
|
509
545
|
} else if (typeof error === "string") {
|
|
510
|
-
span.recordException(
|
|
546
|
+
span.recordException(error.replace(/\0/g, ""));
|
|
511
547
|
} else {
|
|
512
|
-
span.recordException(
|
|
548
|
+
span.recordException(JSON.stringify(error).replace(/\0/g, ""));
|
|
513
549
|
}
|
|
514
550
|
span.setStatus({
|
|
515
551
|
code: SpanStatusCode.ERROR
|
|
516
552
|
});
|
|
517
553
|
}
|
|
518
554
|
__name(recordSpanException, "recordSpanException");
|
|
555
|
+
function sanitizeSpanError(error) {
|
|
556
|
+
const sanitizedError = new Error(error.message.replace(/\0/g, ""));
|
|
557
|
+
sanitizedError.name = error.name.replace(/\0/g, "");
|
|
558
|
+
sanitizedError.stack = error.stack?.replace(/\0/g, "");
|
|
559
|
+
return sanitizedError;
|
|
560
|
+
}
|
|
561
|
+
__name(sanitizeSpanError, "sanitizeSpanError");
|
|
519
562
|
var MachineCpu = z.union([
|
|
520
563
|
z.literal(0.25),
|
|
521
564
|
z.literal(0.5),
|
|
@@ -615,6 +658,7 @@ var TaskRun = z.object({
|
|
|
615
658
|
createdAt: z.coerce.date(),
|
|
616
659
|
startedAt: z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
617
660
|
idempotencyKey: z.string().optional(),
|
|
661
|
+
maxAttempts: z.number().optional(),
|
|
618
662
|
durationMs: z.number().default(0),
|
|
619
663
|
costInCents: z.number().default(0),
|
|
620
664
|
baseCostInCents: z.number().default(0)
|
|
@@ -982,7 +1026,8 @@ var TriggerTaskRequestBody = z.object({
|
|
|
982
1026
|
test: z.boolean().optional(),
|
|
983
1027
|
payloadType: z.string().optional(),
|
|
984
1028
|
delay: z.string().or(z.coerce.date()).optional(),
|
|
985
|
-
ttl: z.string().or(z.number().nonnegative().int()).optional()
|
|
1029
|
+
ttl: z.string().or(z.number().nonnegative().int()).optional(),
|
|
1030
|
+
maxAttempts: z.number().int().optional()
|
|
986
1031
|
}).optional()
|
|
987
1032
|
});
|
|
988
1033
|
var TriggerTaskResponse = z.object({
|
|
@@ -1312,10 +1357,34 @@ var EnvironmentVariable = z.object({
|
|
|
1312
1357
|
});
|
|
1313
1358
|
var EnvironmentVariables = z.array(EnvironmentVariable);
|
|
1314
1359
|
|
|
1360
|
+
// src/v3/utils/retries.ts
|
|
1361
|
+
var defaultRetryOptions = {
|
|
1362
|
+
maxAttempts: 3,
|
|
1363
|
+
factor: 2,
|
|
1364
|
+
minTimeoutInMs: 1e3,
|
|
1365
|
+
maxTimeoutInMs: 6e4,
|
|
1366
|
+
randomize: true
|
|
1367
|
+
};
|
|
1368
|
+
function calculateNextRetryDelay(options, attempt) {
|
|
1369
|
+
const opts = {
|
|
1370
|
+
...defaultRetryOptions,
|
|
1371
|
+
...options
|
|
1372
|
+
};
|
|
1373
|
+
if (attempt >= opts.maxAttempts) {
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
1377
|
+
const random = randomize ? Math.random() + 1 : 1;
|
|
1378
|
+
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
1379
|
+
return Math.round(timeout);
|
|
1380
|
+
}
|
|
1381
|
+
__name(calculateNextRetryDelay, "calculateNextRetryDelay");
|
|
1382
|
+
|
|
1315
1383
|
// src/v3/apiClient/errors.ts
|
|
1316
1384
|
var _ApiError = class _ApiError extends Error {
|
|
1317
1385
|
constructor(status, error, message, headers) {
|
|
1318
1386
|
super(`${_ApiError.makeMessage(status, error, message)}`);
|
|
1387
|
+
this.name = "TriggerApiError";
|
|
1319
1388
|
this.status = status;
|
|
1320
1389
|
this.headers = headers;
|
|
1321
1390
|
const data = error;
|
|
@@ -1436,6 +1505,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
|
|
|
1436
1505
|
super(...arguments);
|
|
1437
1506
|
__publicField(this, "status", 429);
|
|
1438
1507
|
}
|
|
1508
|
+
get millisecondsUntilReset() {
|
|
1509
|
+
const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
|
|
1510
|
+
if (typeof resetAtUnixEpochMs === "string") {
|
|
1511
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
1512
|
+
if (isNaN(resetAtUnixEpoch)) {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1439
1518
|
};
|
|
1440
1519
|
__name(_RateLimitError, "RateLimitError");
|
|
1441
1520
|
var RateLimitError = _RateLimitError;
|
|
@@ -1450,28 +1529,11 @@ function castToError(err) {
|
|
|
1450
1529
|
}
|
|
1451
1530
|
__name(castToError, "castToError");
|
|
1452
1531
|
|
|
1453
|
-
// src/v3/utils/
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
factor: 2,
|
|
1457
|
-
minTimeoutInMs: 1e3,
|
|
1458
|
-
maxTimeoutInMs: 6e4,
|
|
1459
|
-
randomize: true
|
|
1460
|
-
};
|
|
1461
|
-
function calculateNextRetryDelay(options, attempt) {
|
|
1462
|
-
const opts = {
|
|
1463
|
-
...defaultRetryOptions,
|
|
1464
|
-
...options
|
|
1465
|
-
};
|
|
1466
|
-
if (attempt >= opts.maxAttempts) {
|
|
1467
|
-
return;
|
|
1468
|
-
}
|
|
1469
|
-
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
1470
|
-
const random = randomize ? Math.random() + 1 : 1;
|
|
1471
|
-
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
1472
|
-
return Math.round(timeout);
|
|
1532
|
+
// src/v3/utils/styleAttributes.ts
|
|
1533
|
+
function accessoryAttributes(accessory) {
|
|
1534
|
+
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
1473
1535
|
}
|
|
1474
|
-
__name(
|
|
1536
|
+
__name(accessoryAttributes, "accessoryAttributes");
|
|
1475
1537
|
|
|
1476
1538
|
// src/v3/apiClient/pagination.ts
|
|
1477
1539
|
var _CursorPage = class _CursorPage {
|
|
@@ -1631,16 +1693,47 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
1631
1693
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
1632
1694
|
}
|
|
1633
1695
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
1634
|
-
async function
|
|
1696
|
+
async function traceZodFetch(params, callback) {
|
|
1697
|
+
if (!params.options?.tracer) {
|
|
1698
|
+
return callback();
|
|
1699
|
+
}
|
|
1700
|
+
const url = new URL(params.url);
|
|
1701
|
+
const method = params.requestInit?.method ?? "GET";
|
|
1702
|
+
const name = params.options.name ?? `${method} ${url.pathname}`;
|
|
1703
|
+
return await params.options.tracer.startActiveSpan(name, async (span) => {
|
|
1704
|
+
return await callback(span);
|
|
1705
|
+
}, {
|
|
1706
|
+
attributes: {
|
|
1707
|
+
[SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
|
|
1708
|
+
...params.options.attributes
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
__name(traceZodFetch, "traceZodFetch");
|
|
1713
|
+
async function _doZodFetch(schema, url, requestInit, options) {
|
|
1714
|
+
const $requestInit = await requestInit;
|
|
1715
|
+
return traceZodFetch({
|
|
1716
|
+
url,
|
|
1717
|
+
requestInit: $requestInit,
|
|
1718
|
+
options
|
|
1719
|
+
}, async (span) => {
|
|
1720
|
+
const result = await _doZodFetchWithRetries(schema, url, $requestInit, options);
|
|
1721
|
+
if (options?.onResponseBody && span) {
|
|
1722
|
+
options.onResponseBody(result.data, span);
|
|
1723
|
+
}
|
|
1724
|
+
return result;
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
__name(_doZodFetch, "_doZodFetch");
|
|
1728
|
+
async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
|
|
1635
1729
|
try {
|
|
1636
|
-
const
|
|
1637
|
-
const response = await fetch(url, requestInitWithCache($requestInit));
|
|
1730
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
1638
1731
|
const responseHeaders = createResponseHeaders(response.headers);
|
|
1639
1732
|
if (!response.ok) {
|
|
1640
1733
|
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
1641
1734
|
if (retryResult.retry) {
|
|
1642
|
-
await
|
|
1643
|
-
return await
|
|
1735
|
+
await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
|
|
1736
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1644
1737
|
} else {
|
|
1645
1738
|
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
1646
1739
|
const errJSON = safeJsonParse(errText);
|
|
@@ -1668,8 +1761,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1668
1761
|
};
|
|
1669
1762
|
const delay = calculateNextRetryDelay(retry, attempt);
|
|
1670
1763
|
if (delay) {
|
|
1671
|
-
await
|
|
1672
|
-
return await
|
|
1764
|
+
await waitForRetry(url, attempt + 1, delay, options, requestInit);
|
|
1765
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1673
1766
|
}
|
|
1674
1767
|
}
|
|
1675
1768
|
throw new ApiConnectionError({
|
|
@@ -1677,7 +1770,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1677
1770
|
});
|
|
1678
1771
|
}
|
|
1679
1772
|
}
|
|
1680
|
-
__name(
|
|
1773
|
+
__name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
|
|
1681
1774
|
function castToError2(err) {
|
|
1682
1775
|
if (err instanceof Error)
|
|
1683
1776
|
return err;
|
|
@@ -1714,8 +1807,25 @@ function shouldRetry(response, attempt, retryOptions) {
|
|
|
1714
1807
|
return shouldRetryForOptions();
|
|
1715
1808
|
if (response.status === 409)
|
|
1716
1809
|
return shouldRetryForOptions();
|
|
1717
|
-
if (response.status === 429)
|
|
1810
|
+
if (response.status === 429) {
|
|
1811
|
+
if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
|
|
1812
|
+
return {
|
|
1813
|
+
retry: false
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
|
|
1817
|
+
if (resetAtUnixEpochMs) {
|
|
1818
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
1819
|
+
const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
|
|
1820
|
+
if (delay > 0) {
|
|
1821
|
+
return {
|
|
1822
|
+
retry: true,
|
|
1823
|
+
delay
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1718
1827
|
return shouldRetryForOptions();
|
|
1828
|
+
}
|
|
1719
1829
|
if (response.status >= 500)
|
|
1720
1830
|
return shouldRetryForOptions();
|
|
1721
1831
|
return {
|
|
@@ -1878,9 +1988,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
|
|
|
1878
1988
|
}, "#fetchPage");
|
|
1879
1989
|
__name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
|
|
1880
1990
|
var OffsetLimitPagePromise = _OffsetLimitPagePromise;
|
|
1991
|
+
async function waitForRetry(url, attempt, delay, options, requestInit, response) {
|
|
1992
|
+
if (options?.tracer) {
|
|
1993
|
+
const method = requestInit?.method ?? "GET";
|
|
1994
|
+
return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
|
|
1995
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1996
|
+
}, {
|
|
1997
|
+
attributes: {
|
|
1998
|
+
[SemanticInternalAttributes.STYLE_ICON]: "wait",
|
|
1999
|
+
...accessoryAttributes({
|
|
2000
|
+
items: [
|
|
2001
|
+
{
|
|
2002
|
+
text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
|
|
2003
|
+
variant: "normal"
|
|
2004
|
+
}
|
|
2005
|
+
],
|
|
2006
|
+
style: "codepath"
|
|
2007
|
+
})
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2012
|
+
}
|
|
2013
|
+
__name(waitForRetry, "waitForRetry");
|
|
1881
2014
|
|
|
1882
2015
|
// src/v3/apiClient/index.ts
|
|
1883
|
-
var
|
|
2016
|
+
var DEFAULT_ZOD_FETCH_OPTIONS = {
|
|
1884
2017
|
retry: {
|
|
1885
2018
|
maxAttempts: 3,
|
|
1886
2019
|
minTimeoutInMs: 1e3,
|
|
@@ -1891,17 +2024,18 @@ var zodFetchOptions = {
|
|
|
1891
2024
|
};
|
|
1892
2025
|
var _getHeaders, getHeaders_fn;
|
|
1893
2026
|
var _ApiClient = class _ApiClient {
|
|
1894
|
-
constructor(baseUrl, accessToken) {
|
|
2027
|
+
constructor(baseUrl, accessToken, requestOptions = {}) {
|
|
1895
2028
|
__privateAdd(this, _getHeaders);
|
|
1896
2029
|
this.accessToken = accessToken;
|
|
1897
2030
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2031
|
+
this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
|
|
1898
2032
|
}
|
|
1899
|
-
async getRunResult(runId) {
|
|
2033
|
+
async getRunResult(runId, requestOptions) {
|
|
1900
2034
|
try {
|
|
1901
2035
|
return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
|
|
1902
2036
|
method: "GET",
|
|
1903
2037
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1904
|
-
},
|
|
2038
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1905
2039
|
} catch (error) {
|
|
1906
2040
|
if (error instanceof ApiError) {
|
|
1907
2041
|
if (error.status === 404) {
|
|
@@ -1911,47 +2045,47 @@ var _ApiClient = class _ApiClient {
|
|
|
1911
2045
|
throw error;
|
|
1912
2046
|
}
|
|
1913
2047
|
}
|
|
1914
|
-
async getBatchResults(batchId) {
|
|
2048
|
+
async getBatchResults(batchId, requestOptions) {
|
|
1915
2049
|
return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
|
|
1916
2050
|
method: "GET",
|
|
1917
2051
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1918
|
-
},
|
|
2052
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1919
2053
|
}
|
|
1920
|
-
triggerTask(taskId, body, options) {
|
|
2054
|
+
triggerTask(taskId, body, options, requestOptions) {
|
|
1921
2055
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1922
2056
|
return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
|
|
1923
2057
|
method: "POST",
|
|
1924
2058
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1925
2059
|
body: JSON.stringify(body)
|
|
1926
|
-
},
|
|
2060
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1927
2061
|
}
|
|
1928
|
-
batchTriggerTask(taskId, body, options) {
|
|
2062
|
+
batchTriggerTask(taskId, body, options, requestOptions) {
|
|
1929
2063
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1930
2064
|
return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
|
|
1931
2065
|
method: "POST",
|
|
1932
2066
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1933
2067
|
body: JSON.stringify(body)
|
|
1934
|
-
},
|
|
2068
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1935
2069
|
}
|
|
1936
|
-
createUploadPayloadUrl(filename) {
|
|
2070
|
+
createUploadPayloadUrl(filename, requestOptions) {
|
|
1937
2071
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1938
2072
|
method: "PUT",
|
|
1939
2073
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1940
|
-
},
|
|
2074
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1941
2075
|
}
|
|
1942
|
-
getPayloadUrl(filename) {
|
|
2076
|
+
getPayloadUrl(filename, requestOptions) {
|
|
1943
2077
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1944
2078
|
method: "GET",
|
|
1945
2079
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1946
|
-
},
|
|
2080
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1947
2081
|
}
|
|
1948
|
-
retrieveRun(runId) {
|
|
2082
|
+
retrieveRun(runId, requestOptions) {
|
|
1949
2083
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
|
|
1950
2084
|
method: "GET",
|
|
1951
2085
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1952
|
-
},
|
|
2086
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1953
2087
|
}
|
|
1954
|
-
listRuns(query) {
|
|
2088
|
+
listRuns(query, requestOptions) {
|
|
1955
2089
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1956
2090
|
return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
|
|
1957
2091
|
query: searchParams,
|
|
@@ -1961,9 +2095,9 @@ var _ApiClient = class _ApiClient {
|
|
|
1961
2095
|
}, {
|
|
1962
2096
|
method: "GET",
|
|
1963
2097
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1964
|
-
},
|
|
2098
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1965
2099
|
}
|
|
1966
|
-
listProjectRuns(projectRef, query) {
|
|
2100
|
+
listProjectRuns(projectRef, query, requestOptions) {
|
|
1967
2101
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1968
2102
|
if (query?.env) {
|
|
1969
2103
|
searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
|
|
@@ -1976,35 +2110,35 @@ var _ApiClient = class _ApiClient {
|
|
|
1976
2110
|
}, {
|
|
1977
2111
|
method: "GET",
|
|
1978
2112
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1979
|
-
},
|
|
2113
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1980
2114
|
}
|
|
1981
|
-
replayRun(runId) {
|
|
2115
|
+
replayRun(runId, requestOptions) {
|
|
1982
2116
|
return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
|
|
1983
2117
|
method: "POST",
|
|
1984
2118
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1985
|
-
},
|
|
2119
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1986
2120
|
}
|
|
1987
|
-
cancelRun(runId) {
|
|
2121
|
+
cancelRun(runId, requestOptions) {
|
|
1988
2122
|
return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
|
|
1989
2123
|
method: "POST",
|
|
1990
2124
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1991
|
-
},
|
|
2125
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1992
2126
|
}
|
|
1993
|
-
rescheduleRun(runId, body) {
|
|
2127
|
+
rescheduleRun(runId, body, requestOptions) {
|
|
1994
2128
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
|
|
1995
2129
|
method: "POST",
|
|
1996
2130
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
1997
2131
|
body: JSON.stringify(body)
|
|
1998
|
-
},
|
|
2132
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1999
2133
|
}
|
|
2000
|
-
createSchedule(options) {
|
|
2134
|
+
createSchedule(options, requestOptions) {
|
|
2001
2135
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
|
|
2002
2136
|
method: "POST",
|
|
2003
2137
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2004
2138
|
body: JSON.stringify(options)
|
|
2005
|
-
});
|
|
2139
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2006
2140
|
}
|
|
2007
|
-
listSchedules(options) {
|
|
2141
|
+
listSchedules(options, requestOptions) {
|
|
2008
2142
|
const searchParams = new URLSearchParams();
|
|
2009
2143
|
if (options?.page) {
|
|
2010
2144
|
searchParams.append("page", options.page.toString());
|
|
@@ -2018,77 +2152,77 @@ var _ApiClient = class _ApiClient {
|
|
|
2018
2152
|
}, {
|
|
2019
2153
|
method: "GET",
|
|
2020
2154
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2021
|
-
});
|
|
2155
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2022
2156
|
}
|
|
2023
|
-
retrieveSchedule(scheduleId) {
|
|
2157
|
+
retrieveSchedule(scheduleId, requestOptions) {
|
|
2024
2158
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2025
2159
|
method: "GET",
|
|
2026
2160
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2027
|
-
});
|
|
2161
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2028
2162
|
}
|
|
2029
|
-
updateSchedule(scheduleId, options) {
|
|
2163
|
+
updateSchedule(scheduleId, options, requestOptions) {
|
|
2030
2164
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2031
2165
|
method: "PUT",
|
|
2032
2166
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2033
2167
|
body: JSON.stringify(options)
|
|
2034
|
-
});
|
|
2168
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2035
2169
|
}
|
|
2036
|
-
deactivateSchedule(scheduleId) {
|
|
2170
|
+
deactivateSchedule(scheduleId, requestOptions) {
|
|
2037
2171
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
|
|
2038
2172
|
method: "POST",
|
|
2039
2173
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2040
|
-
});
|
|
2174
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2041
2175
|
}
|
|
2042
|
-
activateSchedule(scheduleId) {
|
|
2176
|
+
activateSchedule(scheduleId, requestOptions) {
|
|
2043
2177
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
|
|
2044
2178
|
method: "POST",
|
|
2045
2179
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2046
|
-
});
|
|
2180
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2047
2181
|
}
|
|
2048
|
-
deleteSchedule(scheduleId) {
|
|
2182
|
+
deleteSchedule(scheduleId, requestOptions) {
|
|
2049
2183
|
return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2050
2184
|
method: "DELETE",
|
|
2051
2185
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2052
|
-
});
|
|
2186
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2053
2187
|
}
|
|
2054
|
-
listEnvVars(projectRef, slug) {
|
|
2188
|
+
listEnvVars(projectRef, slug, requestOptions) {
|
|
2055
2189
|
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2056
2190
|
method: "GET",
|
|
2057
2191
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2058
|
-
});
|
|
2192
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2059
2193
|
}
|
|
2060
|
-
importEnvVars(projectRef, slug, body) {
|
|
2194
|
+
importEnvVars(projectRef, slug, body, requestOptions) {
|
|
2061
2195
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2062
2196
|
method: "POST",
|
|
2063
2197
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2064
2198
|
body: JSON.stringify(body)
|
|
2065
|
-
});
|
|
2199
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2066
2200
|
}
|
|
2067
|
-
retrieveEnvVar(projectRef, slug, key) {
|
|
2201
|
+
retrieveEnvVar(projectRef, slug, key, requestOptions) {
|
|
2068
2202
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2069
2203
|
method: "GET",
|
|
2070
2204
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2071
|
-
});
|
|
2205
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2072
2206
|
}
|
|
2073
|
-
createEnvVar(projectRef, slug, body) {
|
|
2207
|
+
createEnvVar(projectRef, slug, body, requestOptions) {
|
|
2074
2208
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2075
2209
|
method: "POST",
|
|
2076
2210
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2077
2211
|
body: JSON.stringify(body)
|
|
2078
|
-
});
|
|
2212
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2079
2213
|
}
|
|
2080
|
-
updateEnvVar(projectRef, slug, key, body) {
|
|
2214
|
+
updateEnvVar(projectRef, slug, key, body, requestOptions) {
|
|
2081
2215
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2082
2216
|
method: "PUT",
|
|
2083
2217
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2084
2218
|
body: JSON.stringify(body)
|
|
2085
|
-
});
|
|
2219
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2086
2220
|
}
|
|
2087
|
-
deleteEnvVar(projectRef, slug, key) {
|
|
2221
|
+
deleteEnvVar(projectRef, slug, key, requestOptions) {
|
|
2088
2222
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2089
2223
|
method: "DELETE",
|
|
2090
2224
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2091
|
-
});
|
|
2225
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2092
2226
|
}
|
|
2093
2227
|
};
|
|
2094
2228
|
_getHeaders = new WeakSet();
|
|
@@ -2143,6 +2277,20 @@ function createSearchQueryForListRuns(query) {
|
|
|
2143
2277
|
return searchParams;
|
|
2144
2278
|
}
|
|
2145
2279
|
__name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
|
|
2280
|
+
function mergeRequestOptions(defaultOptions, options) {
|
|
2281
|
+
if (!options) {
|
|
2282
|
+
return defaultOptions;
|
|
2283
|
+
}
|
|
2284
|
+
return {
|
|
2285
|
+
...defaultOptions,
|
|
2286
|
+
...options,
|
|
2287
|
+
retry: {
|
|
2288
|
+
...defaultOptions.retry,
|
|
2289
|
+
...options.retry
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
__name(mergeRequestOptions, "mergeRequestOptions");
|
|
2146
2294
|
|
|
2147
2295
|
// src/v3/apiClientManager/index.ts
|
|
2148
2296
|
var API_NAME2 = "api-client";
|
|
@@ -2407,12 +2555,6 @@ async function loadSuperJSON() {
|
|
|
2407
2555
|
}
|
|
2408
2556
|
__name(loadSuperJSON, "loadSuperJSON");
|
|
2409
2557
|
|
|
2410
|
-
// src/v3/utils/styleAttributes.ts
|
|
2411
|
-
function accessoryAttributes(accessory) {
|
|
2412
|
-
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
2413
|
-
}
|
|
2414
|
-
__name(accessoryAttributes, "accessoryAttributes");
|
|
2415
|
-
|
|
2416
2558
|
// src/v3/workers/taskExecutor.ts
|
|
2417
2559
|
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;
|
|
2418
2560
|
var _TaskExecutor = class _TaskExecutor {
|
|
@@ -2500,7 +2642,7 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2500
2642
|
return {
|
|
2501
2643
|
id: execution.run.id,
|
|
2502
2644
|
ok: false,
|
|
2503
|
-
error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
|
|
2645
|
+
error: sanitizeError(handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError)),
|
|
2504
2646
|
retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
|
|
2505
2647
|
skippedRetrying: handleErrorResult.status === "skipped"
|
|
2506
2648
|
};
|
|
@@ -2689,7 +2831,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
|
|
|
2689
2831
|
status: "noop"
|
|
2690
2832
|
};
|
|
2691
2833
|
}
|
|
2692
|
-
|
|
2834
|
+
if (error2 instanceof Error && error2.name === "AbortTaskRunError") {
|
|
2835
|
+
return {
|
|
2836
|
+
status: "skipped"
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
if (execution.run.maxAttempts) {
|
|
2840
|
+
retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
|
|
2841
|
+
}
|
|
2842
|
+
let delay = calculateNextRetryDelay(retry, execution.attempt.number);
|
|
2843
|
+
if (delay && error2 instanceof Error && error2.name === "TriggerApiError" && error2.status === 429) {
|
|
2844
|
+
const rateLimitError = error2;
|
|
2845
|
+
delay = rateLimitError.millisecondsUntilReset;
|
|
2846
|
+
}
|
|
2693
2847
|
if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
|
|
2694
2848
|
return {
|
|
2695
2849
|
status: "skipped"
|