@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
|
@@ -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.47";
|
|
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)
|
|
@@ -906,6 +950,7 @@ z.enum([
|
|
|
906
950
|
]);
|
|
907
951
|
z.object({
|
|
908
952
|
runId: z.string(),
|
|
953
|
+
attemptCount: z.number().optional(),
|
|
909
954
|
messageId: z.string(),
|
|
910
955
|
isTest: z.boolean(),
|
|
911
956
|
traceContext: z.record(z.unknown()),
|
|
@@ -981,7 +1026,8 @@ var TriggerTaskRequestBody = z.object({
|
|
|
981
1026
|
test: z.boolean().optional(),
|
|
982
1027
|
payloadType: z.string().optional(),
|
|
983
1028
|
delay: z.string().or(z.coerce.date()).optional(),
|
|
984
|
-
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()
|
|
985
1031
|
}).optional()
|
|
986
1032
|
});
|
|
987
1033
|
var TriggerTaskResponse = z.object({
|
|
@@ -1311,10 +1357,34 @@ var EnvironmentVariable = z.object({
|
|
|
1311
1357
|
});
|
|
1312
1358
|
var EnvironmentVariables = z.array(EnvironmentVariable);
|
|
1313
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
|
+
|
|
1314
1383
|
// src/v3/apiClient/errors.ts
|
|
1315
1384
|
var _ApiError = class _ApiError extends Error {
|
|
1316
1385
|
constructor(status, error, message, headers) {
|
|
1317
1386
|
super(`${_ApiError.makeMessage(status, error, message)}`);
|
|
1387
|
+
this.name = "TriggerApiError";
|
|
1318
1388
|
this.status = status;
|
|
1319
1389
|
this.headers = headers;
|
|
1320
1390
|
const data = error;
|
|
@@ -1435,6 +1505,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
|
|
|
1435
1505
|
super(...arguments);
|
|
1436
1506
|
__publicField(this, "status", 429);
|
|
1437
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
|
+
}
|
|
1438
1518
|
};
|
|
1439
1519
|
__name(_RateLimitError, "RateLimitError");
|
|
1440
1520
|
var RateLimitError = _RateLimitError;
|
|
@@ -1449,28 +1529,11 @@ function castToError(err) {
|
|
|
1449
1529
|
}
|
|
1450
1530
|
__name(castToError, "castToError");
|
|
1451
1531
|
|
|
1452
|
-
// src/v3/utils/
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
factor: 2,
|
|
1456
|
-
minTimeoutInMs: 1e3,
|
|
1457
|
-
maxTimeoutInMs: 6e4,
|
|
1458
|
-
randomize: true
|
|
1459
|
-
};
|
|
1460
|
-
function calculateNextRetryDelay(options, attempt) {
|
|
1461
|
-
const opts = {
|
|
1462
|
-
...defaultRetryOptions,
|
|
1463
|
-
...options
|
|
1464
|
-
};
|
|
1465
|
-
if (attempt >= opts.maxAttempts) {
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
1469
|
-
const random = randomize ? Math.random() + 1 : 1;
|
|
1470
|
-
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
1471
|
-
return Math.round(timeout);
|
|
1532
|
+
// src/v3/utils/styleAttributes.ts
|
|
1533
|
+
function accessoryAttributes(accessory) {
|
|
1534
|
+
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
1472
1535
|
}
|
|
1473
|
-
__name(
|
|
1536
|
+
__name(accessoryAttributes, "accessoryAttributes");
|
|
1474
1537
|
|
|
1475
1538
|
// src/v3/apiClient/pagination.ts
|
|
1476
1539
|
var _CursorPage = class _CursorPage {
|
|
@@ -1630,16 +1693,47 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
1630
1693
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
1631
1694
|
}
|
|
1632
1695
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
1633
|
-
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) {
|
|
1634
1729
|
try {
|
|
1635
|
-
const
|
|
1636
|
-
const response = await fetch(url, requestInitWithCache($requestInit));
|
|
1730
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
1637
1731
|
const responseHeaders = createResponseHeaders(response.headers);
|
|
1638
1732
|
if (!response.ok) {
|
|
1639
1733
|
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
1640
1734
|
if (retryResult.retry) {
|
|
1641
|
-
await
|
|
1642
|
-
return await
|
|
1735
|
+
await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
|
|
1736
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1643
1737
|
} else {
|
|
1644
1738
|
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
1645
1739
|
const errJSON = safeJsonParse(errText);
|
|
@@ -1667,8 +1761,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1667
1761
|
};
|
|
1668
1762
|
const delay = calculateNextRetryDelay(retry, attempt);
|
|
1669
1763
|
if (delay) {
|
|
1670
|
-
await
|
|
1671
|
-
return await
|
|
1764
|
+
await waitForRetry(url, attempt + 1, delay, options, requestInit);
|
|
1765
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
1672
1766
|
}
|
|
1673
1767
|
}
|
|
1674
1768
|
throw new ApiConnectionError({
|
|
@@ -1676,7 +1770,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
1676
1770
|
});
|
|
1677
1771
|
}
|
|
1678
1772
|
}
|
|
1679
|
-
__name(
|
|
1773
|
+
__name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
|
|
1680
1774
|
function castToError2(err) {
|
|
1681
1775
|
if (err instanceof Error)
|
|
1682
1776
|
return err;
|
|
@@ -1713,8 +1807,25 @@ function shouldRetry(response, attempt, retryOptions) {
|
|
|
1713
1807
|
return shouldRetryForOptions();
|
|
1714
1808
|
if (response.status === 409)
|
|
1715
1809
|
return shouldRetryForOptions();
|
|
1716
|
-
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
|
+
}
|
|
1717
1827
|
return shouldRetryForOptions();
|
|
1828
|
+
}
|
|
1718
1829
|
if (response.status >= 500)
|
|
1719
1830
|
return shouldRetryForOptions();
|
|
1720
1831
|
return {
|
|
@@ -1877,9 +1988,32 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
|
|
|
1877
1988
|
}, "#fetchPage");
|
|
1878
1989
|
__name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
|
|
1879
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");
|
|
1880
2014
|
|
|
1881
2015
|
// src/v3/apiClient/index.ts
|
|
1882
|
-
var
|
|
2016
|
+
var DEFAULT_ZOD_FETCH_OPTIONS = {
|
|
1883
2017
|
retry: {
|
|
1884
2018
|
maxAttempts: 3,
|
|
1885
2019
|
minTimeoutInMs: 1e3,
|
|
@@ -1890,17 +2024,18 @@ var zodFetchOptions = {
|
|
|
1890
2024
|
};
|
|
1891
2025
|
var _getHeaders, getHeaders_fn;
|
|
1892
2026
|
var _ApiClient = class _ApiClient {
|
|
1893
|
-
constructor(baseUrl, accessToken) {
|
|
2027
|
+
constructor(baseUrl, accessToken, requestOptions = {}) {
|
|
1894
2028
|
__privateAdd(this, _getHeaders);
|
|
1895
2029
|
this.accessToken = accessToken;
|
|
1896
2030
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2031
|
+
this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
|
|
1897
2032
|
}
|
|
1898
|
-
async getRunResult(runId) {
|
|
2033
|
+
async getRunResult(runId, requestOptions) {
|
|
1899
2034
|
try {
|
|
1900
2035
|
return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
|
|
1901
2036
|
method: "GET",
|
|
1902
2037
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1903
|
-
},
|
|
2038
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1904
2039
|
} catch (error) {
|
|
1905
2040
|
if (error instanceof ApiError) {
|
|
1906
2041
|
if (error.status === 404) {
|
|
@@ -1910,47 +2045,47 @@ var _ApiClient = class _ApiClient {
|
|
|
1910
2045
|
throw error;
|
|
1911
2046
|
}
|
|
1912
2047
|
}
|
|
1913
|
-
async getBatchResults(batchId) {
|
|
2048
|
+
async getBatchResults(batchId, requestOptions) {
|
|
1914
2049
|
return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
|
|
1915
2050
|
method: "GET",
|
|
1916
2051
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1917
|
-
},
|
|
2052
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1918
2053
|
}
|
|
1919
|
-
triggerTask(taskId, body, options) {
|
|
2054
|
+
triggerTask(taskId, body, options, requestOptions) {
|
|
1920
2055
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1921
2056
|
return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
|
|
1922
2057
|
method: "POST",
|
|
1923
2058
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1924
2059
|
body: JSON.stringify(body)
|
|
1925
|
-
},
|
|
2060
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1926
2061
|
}
|
|
1927
|
-
batchTriggerTask(taskId, body, options) {
|
|
2062
|
+
batchTriggerTask(taskId, body, options, requestOptions) {
|
|
1928
2063
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
1929
2064
|
return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
|
|
1930
2065
|
method: "POST",
|
|
1931
2066
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
1932
2067
|
body: JSON.stringify(body)
|
|
1933
|
-
},
|
|
2068
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1934
2069
|
}
|
|
1935
|
-
createUploadPayloadUrl(filename) {
|
|
2070
|
+
createUploadPayloadUrl(filename, requestOptions) {
|
|
1936
2071
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1937
2072
|
method: "PUT",
|
|
1938
2073
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1939
|
-
},
|
|
2074
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1940
2075
|
}
|
|
1941
|
-
getPayloadUrl(filename) {
|
|
2076
|
+
getPayloadUrl(filename, requestOptions) {
|
|
1942
2077
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
1943
2078
|
method: "GET",
|
|
1944
2079
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1945
|
-
},
|
|
2080
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1946
2081
|
}
|
|
1947
|
-
retrieveRun(runId) {
|
|
2082
|
+
retrieveRun(runId, requestOptions) {
|
|
1948
2083
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
|
|
1949
2084
|
method: "GET",
|
|
1950
2085
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1951
|
-
},
|
|
2086
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1952
2087
|
}
|
|
1953
|
-
listRuns(query) {
|
|
2088
|
+
listRuns(query, requestOptions) {
|
|
1954
2089
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1955
2090
|
return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
|
|
1956
2091
|
query: searchParams,
|
|
@@ -1960,9 +2095,9 @@ var _ApiClient = class _ApiClient {
|
|
|
1960
2095
|
}, {
|
|
1961
2096
|
method: "GET",
|
|
1962
2097
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1963
|
-
},
|
|
2098
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1964
2099
|
}
|
|
1965
|
-
listProjectRuns(projectRef, query) {
|
|
2100
|
+
listProjectRuns(projectRef, query, requestOptions) {
|
|
1966
2101
|
const searchParams = createSearchQueryForListRuns(query);
|
|
1967
2102
|
if (query?.env) {
|
|
1968
2103
|
searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
|
|
@@ -1975,35 +2110,35 @@ var _ApiClient = class _ApiClient {
|
|
|
1975
2110
|
}, {
|
|
1976
2111
|
method: "GET",
|
|
1977
2112
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1978
|
-
},
|
|
2113
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1979
2114
|
}
|
|
1980
|
-
replayRun(runId) {
|
|
2115
|
+
replayRun(runId, requestOptions) {
|
|
1981
2116
|
return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
|
|
1982
2117
|
method: "POST",
|
|
1983
2118
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1984
|
-
},
|
|
2119
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1985
2120
|
}
|
|
1986
|
-
cancelRun(runId) {
|
|
2121
|
+
cancelRun(runId, requestOptions) {
|
|
1987
2122
|
return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
|
|
1988
2123
|
method: "POST",
|
|
1989
2124
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
1990
|
-
},
|
|
2125
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1991
2126
|
}
|
|
1992
|
-
rescheduleRun(runId, body) {
|
|
2127
|
+
rescheduleRun(runId, body, requestOptions) {
|
|
1993
2128
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
|
|
1994
2129
|
method: "POST",
|
|
1995
2130
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
1996
2131
|
body: JSON.stringify(body)
|
|
1997
|
-
},
|
|
2132
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
1998
2133
|
}
|
|
1999
|
-
createSchedule(options) {
|
|
2134
|
+
createSchedule(options, requestOptions) {
|
|
2000
2135
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
|
|
2001
2136
|
method: "POST",
|
|
2002
2137
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2003
2138
|
body: JSON.stringify(options)
|
|
2004
|
-
});
|
|
2139
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2005
2140
|
}
|
|
2006
|
-
listSchedules(options) {
|
|
2141
|
+
listSchedules(options, requestOptions) {
|
|
2007
2142
|
const searchParams = new URLSearchParams();
|
|
2008
2143
|
if (options?.page) {
|
|
2009
2144
|
searchParams.append("page", options.page.toString());
|
|
@@ -2017,77 +2152,77 @@ var _ApiClient = class _ApiClient {
|
|
|
2017
2152
|
}, {
|
|
2018
2153
|
method: "GET",
|
|
2019
2154
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2020
|
-
});
|
|
2155
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2021
2156
|
}
|
|
2022
|
-
retrieveSchedule(scheduleId) {
|
|
2157
|
+
retrieveSchedule(scheduleId, requestOptions) {
|
|
2023
2158
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2024
2159
|
method: "GET",
|
|
2025
2160
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2026
|
-
});
|
|
2161
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2027
2162
|
}
|
|
2028
|
-
updateSchedule(scheduleId, options) {
|
|
2163
|
+
updateSchedule(scheduleId, options, requestOptions) {
|
|
2029
2164
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2030
2165
|
method: "PUT",
|
|
2031
2166
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2032
2167
|
body: JSON.stringify(options)
|
|
2033
|
-
});
|
|
2168
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2034
2169
|
}
|
|
2035
|
-
deactivateSchedule(scheduleId) {
|
|
2170
|
+
deactivateSchedule(scheduleId, requestOptions) {
|
|
2036
2171
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
|
|
2037
2172
|
method: "POST",
|
|
2038
2173
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2039
|
-
});
|
|
2174
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2040
2175
|
}
|
|
2041
|
-
activateSchedule(scheduleId) {
|
|
2176
|
+
activateSchedule(scheduleId, requestOptions) {
|
|
2042
2177
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
|
|
2043
2178
|
method: "POST",
|
|
2044
2179
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2045
|
-
});
|
|
2180
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2046
2181
|
}
|
|
2047
|
-
deleteSchedule(scheduleId) {
|
|
2182
|
+
deleteSchedule(scheduleId, requestOptions) {
|
|
2048
2183
|
return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
2049
2184
|
method: "DELETE",
|
|
2050
2185
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2051
|
-
});
|
|
2186
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2052
2187
|
}
|
|
2053
|
-
listEnvVars(projectRef, slug) {
|
|
2188
|
+
listEnvVars(projectRef, slug, requestOptions) {
|
|
2054
2189
|
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2055
2190
|
method: "GET",
|
|
2056
2191
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2057
|
-
});
|
|
2192
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2058
2193
|
}
|
|
2059
|
-
importEnvVars(projectRef, slug, body) {
|
|
2194
|
+
importEnvVars(projectRef, slug, body, requestOptions) {
|
|
2060
2195
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
2061
2196
|
method: "POST",
|
|
2062
2197
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2063
2198
|
body: JSON.stringify(body)
|
|
2064
|
-
});
|
|
2199
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2065
2200
|
}
|
|
2066
|
-
retrieveEnvVar(projectRef, slug, key) {
|
|
2201
|
+
retrieveEnvVar(projectRef, slug, key, requestOptions) {
|
|
2067
2202
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2068
2203
|
method: "GET",
|
|
2069
2204
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2070
|
-
});
|
|
2205
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2071
2206
|
}
|
|
2072
|
-
createEnvVar(projectRef, slug, body) {
|
|
2207
|
+
createEnvVar(projectRef, slug, body, requestOptions) {
|
|
2073
2208
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
2074
2209
|
method: "POST",
|
|
2075
2210
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2076
2211
|
body: JSON.stringify(body)
|
|
2077
|
-
});
|
|
2212
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2078
2213
|
}
|
|
2079
|
-
updateEnvVar(projectRef, slug, key, body) {
|
|
2214
|
+
updateEnvVar(projectRef, slug, key, body, requestOptions) {
|
|
2080
2215
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2081
2216
|
method: "PUT",
|
|
2082
2217
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
2083
2218
|
body: JSON.stringify(body)
|
|
2084
|
-
});
|
|
2219
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2085
2220
|
}
|
|
2086
|
-
deleteEnvVar(projectRef, slug, key) {
|
|
2221
|
+
deleteEnvVar(projectRef, slug, key, requestOptions) {
|
|
2087
2222
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
2088
2223
|
method: "DELETE",
|
|
2089
2224
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2090
|
-
});
|
|
2225
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2091
2226
|
}
|
|
2092
2227
|
};
|
|
2093
2228
|
_getHeaders = new WeakSet();
|
|
@@ -2142,6 +2277,20 @@ function createSearchQueryForListRuns(query) {
|
|
|
2142
2277
|
return searchParams;
|
|
2143
2278
|
}
|
|
2144
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");
|
|
2145
2294
|
|
|
2146
2295
|
// src/v3/apiClientManager/index.ts
|
|
2147
2296
|
var API_NAME2 = "api-client";
|
|
@@ -2406,12 +2555,6 @@ async function loadSuperJSON() {
|
|
|
2406
2555
|
}
|
|
2407
2556
|
__name(loadSuperJSON, "loadSuperJSON");
|
|
2408
2557
|
|
|
2409
|
-
// src/v3/utils/styleAttributes.ts
|
|
2410
|
-
function accessoryAttributes(accessory) {
|
|
2411
|
-
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
2412
|
-
}
|
|
2413
|
-
__name(accessoryAttributes, "accessoryAttributes");
|
|
2414
|
-
|
|
2415
2558
|
// src/v3/workers/taskExecutor.ts
|
|
2416
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;
|
|
2417
2560
|
var _TaskExecutor = class _TaskExecutor {
|
|
@@ -2499,7 +2642,7 @@ var _TaskExecutor = class _TaskExecutor {
|
|
|
2499
2642
|
return {
|
|
2500
2643
|
id: execution.run.id,
|
|
2501
2644
|
ok: false,
|
|
2502
|
-
error: handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError),
|
|
2645
|
+
error: sanitizeError(handleErrorResult.error ? parseError(handleErrorResult.error) : parseError(runError)),
|
|
2503
2646
|
retry: handleErrorResult.status === "retry" ? handleErrorResult.retry : void 0,
|
|
2504
2647
|
skippedRetrying: handleErrorResult.status === "skipped"
|
|
2505
2648
|
};
|
|
@@ -2688,7 +2831,19 @@ handleError_fn = /* @__PURE__ */ __name(async function(execution, error2, payloa
|
|
|
2688
2831
|
status: "noop"
|
|
2689
2832
|
};
|
|
2690
2833
|
}
|
|
2691
|
-
|
|
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
|
+
}
|
|
2692
2847
|
if (execution.environment.type === "DEVELOPMENT" && typeof retriesConfig?.enabledInDev === "boolean" && !retriesConfig.enabledInDev) {
|
|
2693
2848
|
return {
|
|
2694
2849
|
status: "skipped"
|