@trigger.dev/core 0.0.0-v3-prerelease-20240703181409 → 0.0.0-v3-prerelease-20240708162325
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 +466 -303
- package/dist/v3/index.js.map +1 -1
- package/dist/v3/index.mjs +463 -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 +246 -96
- package/dist/v3/workers/index.js.map +1 -1
- package/dist/v3/workers/index.mjs +246 -96
- package/dist/v3/workers/index.mjs.map +1 -1
- package/dist/v3/zodfetch.d.mts +14 -2
- package/dist/v3/zodfetch.d.ts +14 -2
- package/dist/v3/zodfetch.js +244 -28
- package/dist/v3/zodfetch.js.map +1 -1
- package/dist/v3/zodfetch.mjs +242 -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 = "0.0.0-v3-prerelease-
|
|
403
|
+
var version = "0.0.0-v3-prerelease-20240708162325";
|
|
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,43 @@ 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
|
+
return await _doZodFetchWithRetries(schema, url, $requestInit, options);
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
__name(_doZodFetch, "_doZodFetch");
|
|
1724
|
+
async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
|
|
1635
1725
|
try {
|
|
1636
|
-
const
|
|
1637
|
-
const response = await fetch(url, requestInitWithCache($requestInit));
|
|
1726
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
1638
1727
|
const responseHeaders = createResponseHeaders(response.headers);
|
|
1639
1728
|
if (!response.ok) {
|
|
1640
1729
|
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
1641
1730
|
if (retryResult.retry) {
|
|
1642
|
-
await
|
|
1643
|
-
return await
|
|
1731
|
+
await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
|
|
1732
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1644
1733
|
} else {
|
|
1645
1734
|
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
1646
1735
|
const errJSON = safeJsonParse(errText);
|
|
@@ -1668,8 +1757,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1668
1757
|
};
|
|
1669
1758
|
const delay = calculateNextRetryDelay(retry, attempt);
|
|
1670
1759
|
if (delay) {
|
|
1671
|
-
await
|
|
1672
|
-
return await
|
|
1760
|
+
await waitForRetry(url, attempt + 1, delay, options, requestInit);
|
|
1761
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1673
1762
|
}
|
|
1674
1763
|
}
|
|
1675
1764
|
throw new ApiConnectionError({
|
|
@@ -1677,7 +1766,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1677
1766
|
});
|
|
1678
1767
|
}
|
|
1679
1768
|
}
|
|
1680
|
-
__name(
|
|
1769
|
+
__name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
|
|
1681
1770
|
function castToError2(err) {
|
|
1682
1771
|
if (err instanceof Error)
|
|
1683
1772
|
return err;
|
|
@@ -1714,8 +1803,25 @@ function shouldRetry(response, attempt, retryOptions) {
|
|
|
1714
1803
|
return shouldRetryForOptions();
|
|
1715
1804
|
if (response.status === 409)
|
|
1716
1805
|
return shouldRetryForOptions();
|
|
1717
|
-
if (response.status === 429)
|
|
1806
|
+
if (response.status === 429) {
|
|
1807
|
+
if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
|
|
1808
|
+
return {
|
|
1809
|
+
retry: false
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
|
|
1813
|
+
if (resetAtUnixEpochMs) {
|
|
1814
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
1815
|
+
const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
|
|
1816
|
+
if (delay > 0) {
|
|
1817
|
+
return {
|
|
1818
|
+
retry: true,
|
|
1819
|
+
delay
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1718
1823
|
return shouldRetryForOptions();
|
|
1824
|
+
}
|
|
1719
1825
|
if (response.status >= 500)
|
|
1720
1826
|
return shouldRetryForOptions();
|
|
1721
1827
|
return {
|
|
@@ -1878,9 +1984,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
|
|
|
1878
1984
|
}, "#fetchPage");
|
|
1879
1985
|
__name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
|
|
1880
1986
|
var OffsetLimitPagePromise = _OffsetLimitPagePromise;
|
|
1987
|
+
async function waitForRetry(url, attempt, delay, options, requestInit, response) {
|
|
1988
|
+
if (options?.tracer) {
|
|
1989
|
+
const method = requestInit?.method ?? "GET";
|
|
1990
|
+
return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
|
|
1991
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1992
|
+
}, {
|
|
1993
|
+
attributes: {
|
|
1994
|
+
[SemanticInternalAttributes.STYLE_ICON]: "wait",
|
|
1995
|
+
...accessoryAttributes({
|
|
1996
|
+
items: [
|
|
1997
|
+
{
|
|
1998
|
+
text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
|
|
1999
|
+
variant: "normal"
|
|
2000
|
+
}
|
|
2001
|
+
],
|
|
2002
|
+
style: "codepath"
|
|
2003
|
+
})
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2008
|
+
}
|
|
2009
|
+
__name(waitForRetry, "waitForRetry");
|
|
1881
2010
|
|
|
1882
2011
|
// src/v3/apiClient/index.ts
|
|
1883
|
-
var
|
|
2012
|
+
var DEFAULT_ZOD_FETCH_OPTIONS = {
|
|
1884
2013
|
retry: {
|
|
1885
2014
|
maxAttempts: 3,
|
|
1886
2015
|
minTimeoutInMs: 1e3,
|
|
@@ -1891,17 +2020,18 @@ var zodFetchOptions = {
|
|
|
1891
2020
|
};
|
|
1892
2021
|
var _getHeaders, getHeaders_fn;
|
|
1893
2022
|
var _ApiClient = class _ApiClient {
|
|
1894
|
-
constructor(baseUrl, accessToken) {
|
|
2023
|
+
constructor(baseUrl, accessToken, requestOptions = {}) {
|
|
1895
2024
|
__privateAdd(this, _getHeaders);
|
|
1896
2025
|
this.accessToken = accessToken;
|
|
1897
2026
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2027
|
+
this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
|
|
1898
2028
|
}
|
|
1899
|
-
async getRunResult(runId) {
|
|
2029
|
+
async getRunResult(runId, requestOptions) {
|
|
1900
2030
|
try {
|
|
1901
2031
|
return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
|
|
1902
2032
|
method: "GET",
|
|
1903
2033
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1904
|
-
},
|
|
2034
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1905
2035
|
} catch (error) {
|
|
1906
2036
|
if (error instanceof ApiError) {
|
|
1907
2037
|
if (error.status === 404) {
|
|
@@ -1911,47 +2041,47 @@ var _ApiClient = class _ApiClient {
|
|
|
1911
2041
|
throw error;
|
|
1912
2042
|
}
|
|
1913
2043
|
}
|
|
1914
|
-
async getBatchResults(batchId) {
|
|
2044
|
+
async getBatchResults(batchId, requestOptions) {
|
|
1915
2045
|
return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
|
|
1916
2046
|
method: "GET",
|
|
1917
2047
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1918
|
-
},
|
|
2048
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1919
2049
|
}
|
|
1920
|
-
triggerTask(taskId, body, options) {
|
|
2050
|
+
triggerTask(taskId, body, options, requestOptions) {
|
|
1921
2051
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1922
2052
|
return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
|
|
1923
2053
|
method: "POST",
|
|
1924
2054
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1925
2055
|
body: JSON.stringify(body)
|
|
1926
|
-
},
|
|
2056
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1927
2057
|
}
|
|
1928
|
-
batchTriggerTask(taskId, body, options) {
|
|
2058
|
+
batchTriggerTask(taskId, body, options, requestOptions) {
|
|
1929
2059
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1930
2060
|
return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
|
|
1931
2061
|
method: "POST",
|
|
1932
2062
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1933
2063
|
body: JSON.stringify(body)
|
|
1934
|
-
},
|
|
2064
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1935
2065
|
}
|
|
1936
|
-
createUploadPayloadUrl(filename) {
|
|
2066
|
+
createUploadPayloadUrl(filename, requestOptions) {
|
|
1937
2067
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1938
2068
|
method: "PUT",
|
|
1939
2069
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1940
|
-
},
|
|
2070
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1941
2071
|
}
|
|
1942
|
-
getPayloadUrl(filename) {
|
|
2072
|
+
getPayloadUrl(filename, requestOptions) {
|
|
1943
2073
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1944
2074
|
method: "GET",
|
|
1945
2075
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1946
|
-
},
|
|
2076
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1947
2077
|
}
|
|
1948
|
-
retrieveRun(runId) {
|
|
2078
|
+
retrieveRun(runId, requestOptions) {
|
|
1949
2079
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
|
|
1950
2080
|
method: "GET",
|
|
1951
2081
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1952
|
-
},
|
|
2082
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1953
2083
|
}
|
|
1954
|
-
listRuns(query) {
|
|
2084
|
+
listRuns(query, requestOptions) {
|
|
1955
2085
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1956
2086
|
return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
|
|
1957
2087
|
query: searchParams,
|
|
@@ -1961,9 +2091,9 @@ var _ApiClient = class _ApiClient {
|
|
|
1961
2091
|
}, {
|
|
1962
2092
|
method: "GET",
|
|
1963
2093
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1964
|
-
},
|
|
2094
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1965
2095
|
}
|
|
1966
|
-
listProjectRuns(projectRef, query) {
|
|
2096
|
+
listProjectRuns(projectRef, query, requestOptions) {
|
|
1967
2097
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1968
2098
|
if (query?.env) {
|
|
1969
2099
|
searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
|
|
@@ -1976,35 +2106,35 @@ var _ApiClient = class _ApiClient {
|
|
|
1976
2106
|
}, {
|
|
1977
2107
|
method: "GET",
|
|
1978
2108
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1979
|
-
},
|
|
2109
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1980
2110
|
}
|
|
1981
|
-
replayRun(runId) {
|
|
2111
|
+
replayRun(runId, requestOptions) {
|
|
1982
2112
|
return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
|
|
1983
2113
|
method: "POST",
|
|
1984
2114
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1985
|
-
},
|
|
2115
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1986
2116
|
}
|
|
1987
|
-
cancelRun(runId) {
|
|
2117
|
+
cancelRun(runId, requestOptions) {
|
|
1988
2118
|
return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
|
|
1989
2119
|
method: "POST",
|
|
1990
2120
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1991
|
-
},
|
|
2121
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1992
2122
|
}
|
|
1993
|
-
rescheduleRun(runId, body) {
|
|
2123
|
+
rescheduleRun(runId, body, requestOptions) {
|
|
1994
2124
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
|
|
1995
2125
|
method: "POST",
|
|
1996
2126
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
1997
2127
|
body: JSON.stringify(body)
|
|
1998
|
-
},
|
|
2128
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1999
2129
|
}
|
|
2000
|
-
createSchedule(options) {
|
|
2130
|
+
createSchedule(options, requestOptions) {
|
|
2001
2131
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
|
|
2002
2132
|
method: "POST",
|
|
2003
2133
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2004
2134
|
body: JSON.stringify(options)
|
|
2005
|
-
});
|
|
2135
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2006
2136
|
}
|
|
2007
|
-
listSchedules(options) {
|
|
2137
|
+
listSchedules(options, requestOptions) {
|
|
2008
2138
|
const searchParams = new URLSearchParams();
|
|
2009
2139
|
if (options?.page) {
|
|
2010
2140
|
searchParams.append("page", options.page.toString());
|
|
@@ -2018,77 +2148,77 @@ var _ApiClient = class _ApiClient {
|
|
|
2018
2148
|
}, {
|
|
2019
2149
|
method: "GET",
|
|
2020
2150
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2021
|
-
});
|
|
2151
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2022
2152
|
}
|
|
2023
|
-
retrieveSchedule(scheduleId) {
|
|
2153
|
+
retrieveSchedule(scheduleId, requestOptions) {
|
|
2024
2154
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2025
2155
|
method: "GET",
|
|
2026
2156
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2027
|
-
});
|
|
2157
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2028
2158
|
}
|
|
2029
|
-
updateSchedule(scheduleId, options) {
|
|
2159
|
+
updateSchedule(scheduleId, options, requestOptions) {
|
|
2030
2160
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2031
2161
|
method: "PUT",
|
|
2032
2162
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2033
2163
|
body: JSON.stringify(options)
|
|
2034
|
-
});
|
|
2164
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2035
2165
|
}
|
|
2036
|
-
deactivateSchedule(scheduleId) {
|
|
2166
|
+
deactivateSchedule(scheduleId, requestOptions) {
|
|
2037
2167
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
|
|
2038
2168
|
method: "POST",
|
|
2039
2169
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2040
|
-
});
|
|
2170
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2041
2171
|
}
|
|
2042
|
-
activateSchedule(scheduleId) {
|
|
2172
|
+
activateSchedule(scheduleId, requestOptions) {
|
|
2043
2173
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
|
|
2044
2174
|
method: "POST",
|
|
2045
2175
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2046
|
-
});
|
|
2176
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2047
2177
|
}
|
|
2048
|
-
deleteSchedule(scheduleId) {
|
|
2178
|
+
deleteSchedule(scheduleId, requestOptions) {
|
|
2049
2179
|
return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2050
2180
|
method: "DELETE",
|
|
2051
2181
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2052
|
-
});
|
|
2182
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2053
2183
|
}
|
|
2054
|
-
listEnvVars(projectRef, slug) {
|
|
2184
|
+
listEnvVars(projectRef, slug, requestOptions) {
|
|
2055
2185
|
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2056
2186
|
method: "GET",
|
|
2057
2187
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2058
|
-
});
|
|
2188
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2059
2189
|
}
|
|
2060
|
-
importEnvVars(projectRef, slug, body) {
|
|
2190
|
+
importEnvVars(projectRef, slug, body, requestOptions) {
|
|
2061
2191
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2062
2192
|
method: "POST",
|
|
2063
2193
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2064
2194
|
body: JSON.stringify(body)
|
|
2065
|
-
});
|
|
2195
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2066
2196
|
}
|
|
2067
|
-
retrieveEnvVar(projectRef, slug, key) {
|
|
2197
|
+
retrieveEnvVar(projectRef, slug, key, requestOptions) {
|
|
2068
2198
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2069
2199
|
method: "GET",
|
|
2070
2200
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2071
|
-
});
|
|
2201
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2072
2202
|
}
|
|
2073
|
-
createEnvVar(projectRef, slug, body) {
|
|
2203
|
+
createEnvVar(projectRef, slug, body, requestOptions) {
|
|
2074
2204
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2075
2205
|
method: "POST",
|
|
2076
2206
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2077
2207
|
body: JSON.stringify(body)
|
|
2078
|
-
});
|
|
2208
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2079
2209
|
}
|
|
2080
|
-
updateEnvVar(projectRef, slug, key, body) {
|
|
2210
|
+
updateEnvVar(projectRef, slug, key, body, requestOptions) {
|
|
2081
2211
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2082
2212
|
method: "PUT",
|
|
2083
2213
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2084
2214
|
body: JSON.stringify(body)
|
|
2085
|
-
});
|
|
2215
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2086
2216
|
}
|
|
2087
|
-
deleteEnvVar(projectRef, slug, key) {
|
|
2217
|
+
deleteEnvVar(projectRef, slug, key, requestOptions) {
|
|
2088
2218
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2089
2219
|
method: "DELETE",
|
|
2090
2220
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2091
|
-
});
|
|
2221
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2092
2222
|
}
|
|
2093
2223
|
};
|
|
2094
2224
|
_getHeaders = new WeakSet();
|
|
@@ -2143,6 +2273,20 @@ function createSearchQueryForListRuns(query) {
|
|
|
2143
2273
|
return searchParams;
|
|
2144
2274
|
}
|
|
2145
2275
|
__name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
|
|
2276
|
+
function mergeRequestOptions(defaultOptions, options) {
|
|
2277
|
+
if (!options) {
|
|
2278
|
+
return defaultOptions;
|
|
2279
|
+
}
|
|
2280
|
+
return {
|
|
2281
|
+
...defaultOptions,
|
|
2282
|
+
...options,
|
|
2283
|
+
retry: {
|
|
2284
|
+
...defaultOptions.retry,
|
|
2285
|
+
...options.retry
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2289
|
+
__name(mergeRequestOptions, "mergeRequestOptions");
|
|
2146
2290
|
|
|
2147
2291
|
// src/v3/apiClientManager/index.ts
|
|
2148
2292
|
var API_NAME2 = "api-client";
|
|
@@ -2407,12 +2551,6 @@ async function loadSuperJSON() {
|
|
|
2407
2551
|
}
|
|
2408
2552
|
__name(loadSuperJSON, "loadSuperJSON");
|
|
2409
2553
|
|
|
2410
|
-
// src/v3/utils/styleAttributes.ts
|
|
2411
|
-
function accessoryAttributes(accessory) {
|
|
2412
|
-
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
2413
|
-
}
|
|
2414
|
-
__name(accessoryAttributes, "accessoryAttributes");
|
|
2415
|
-
|
|
2416
2554
|
// src/v3/workers/taskExecutor.ts
|
|
2417
2555
|
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
2556
|
var _TaskExecutor = class _TaskExecutor {
|
|
@@ -2500,7 +2638,7 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2500
2638
|
return {
|
|
2501
2639
|
id: execution.run.id,
|
|
2502
2640
|
ok: false,
|
|
2503
|
-
error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
|
|
2641
|
+
error: sanitizeError(handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError)),
|
|
2504
2642
|
retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
|
|
2505
2643
|
skippedRetrying: handleErrorResult.status === "skipped"
|
|
2506
2644
|
};
|
|
@@ -2689,7 +2827,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
|
|
|
2689
2827
|
status: "noop"
|
|
2690
2828
|
};
|
|
2691
2829
|
}
|
|
2692
|
-
|
|
2830
|
+
if (error2 instanceof Error && error2.name === "AbortTaskRunError") {
|
|
2831
|
+
return {
|
|
2832
|
+
status: "skipped"
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
if (execution.run.maxAttempts) {
|
|
2836
|
+
retry.maxAttempts = Math.max(execution.run.maxAttempts, 1);
|
|
2837
|
+
}
|
|
2838
|
+
let delay = calculateNextRetryDelay(retry, execution.attempt.number);
|
|
2839
|
+
if (delay && error2 instanceof Error && error2.name === "TriggerApiError" && error2.status === 429) {
|
|
2840
|
+
const rateLimitError = error2;
|
|
2841
|
+
delay = rateLimitError.millisecondsUntilReset;
|
|
2842
|
+
}
|
|
2693
2843
|
if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
|
|
2694
2844
|
return {
|
|
2695
2845
|
status: "skipped"
|