@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
package/dist/v3/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// package.json
|
|
36
|
-
var version = "0.0.0-v3-prerelease-
|
|
36
|
+
var version = "0.0.0-v3-prerelease-20240708162325";
|
|
37
37
|
var dependencies = {
|
|
38
38
|
"@google-cloud/precise-date": "^4.0.0",
|
|
39
39
|
"@opentelemetry/api": "^1.8.0",
|
|
@@ -167,6 +167,7 @@ var TaskRun = zod.z.object({
|
|
|
167
167
|
createdAt: zod.z.coerce.date(),
|
|
168
168
|
startedAt: zod.z.coerce.date().default(() => /* @__PURE__ */ new Date()),
|
|
169
169
|
idempotencyKey: zod.z.string().optional(),
|
|
170
|
+
maxAttempts: zod.z.number().optional(),
|
|
170
171
|
durationMs: zod.z.number().default(0),
|
|
171
172
|
costInCents: zod.z.number().default(0),
|
|
172
173
|
baseCostInCents: zod.z.number().default(0)
|
|
@@ -485,6 +486,14 @@ var ImageDetailsMetadata = zod.z.object({
|
|
|
485
486
|
contentHash: zod.z.string(),
|
|
486
487
|
imageTag: zod.z.string()
|
|
487
488
|
});
|
|
489
|
+
var _AbortTaskRunError = class _AbortTaskRunError extends Error {
|
|
490
|
+
constructor(message) {
|
|
491
|
+
super(message);
|
|
492
|
+
this.name = "AbortTaskRunError";
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
__name(_AbortTaskRunError, "AbortTaskRunError");
|
|
496
|
+
var AbortTaskRunError = _AbortTaskRunError;
|
|
488
497
|
function parseError(error) {
|
|
489
498
|
if (error instanceof Error) {
|
|
490
499
|
return {
|
|
@@ -565,6 +574,39 @@ function createJsonErrorObject(error) {
|
|
|
565
574
|
}
|
|
566
575
|
}
|
|
567
576
|
__name(createJsonErrorObject, "createJsonErrorObject");
|
|
577
|
+
function sanitizeError(error) {
|
|
578
|
+
switch (error.type) {
|
|
579
|
+
case "BUILT_IN_ERROR": {
|
|
580
|
+
return {
|
|
581
|
+
type: "BUILT_IN_ERROR",
|
|
582
|
+
message: error.message?.replace(/\0/g, ""),
|
|
583
|
+
name: error.name?.replace(/\0/g, ""),
|
|
584
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
case "STRING_ERROR": {
|
|
588
|
+
return {
|
|
589
|
+
type: "STRING_ERROR",
|
|
590
|
+
raw: error.raw.replace(/\0/g, "")
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
case "CUSTOM_ERROR": {
|
|
594
|
+
return {
|
|
595
|
+
type: "CUSTOM_ERROR",
|
|
596
|
+
raw: error.raw.replace(/\0/g, "")
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
case "INTERNAL_ERROR": {
|
|
600
|
+
return {
|
|
601
|
+
type: "INTERNAL_ERROR",
|
|
602
|
+
code: error.code,
|
|
603
|
+
message: error.message?.replace(/\0/g, ""),
|
|
604
|
+
stackTrace: error.stackTrace?.replace(/\0/g, "")
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
__name(sanitizeError, "sanitizeError");
|
|
568
610
|
function correctErrorStackTrace(stackTrace, projectDir, options) {
|
|
569
611
|
const [errorLine, ...traceLines] = stackTrace.split("\n");
|
|
570
612
|
return [
|
|
@@ -680,7 +722,8 @@ var TriggerTaskRequestBody = zod.z.object({
|
|
|
680
722
|
test: zod.z.boolean().optional(),
|
|
681
723
|
payloadType: zod.z.string().optional(),
|
|
682
724
|
delay: zod.z.string().or(zod.z.coerce.date()).optional(),
|
|
683
|
-
ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional()
|
|
725
|
+
ttl: zod.z.string().or(zod.z.number().nonnegative().int()).optional(),
|
|
726
|
+
maxAttempts: zod.z.number().int().optional()
|
|
684
727
|
}).optional()
|
|
685
728
|
});
|
|
686
729
|
var TriggerTaskResponse = zod.z.object({
|
|
@@ -2144,7 +2187,10 @@ var SemanticInternalAttributes = {
|
|
|
2144
2187
|
LINK_TITLE: "$link.title",
|
|
2145
2188
|
IDEMPOTENCY_KEY: "ctx.run.idempotencyKey",
|
|
2146
2189
|
USAGE_DURATION_MS: "$usage.durationMs",
|
|
2147
|
-
USAGE_COST_IN_CENTS: "$usage.costInCents"
|
|
2190
|
+
USAGE_COST_IN_CENTS: "$usage.costInCents",
|
|
2191
|
+
RATE_LIMIT_LIMIT: "response.rateLimit.limit",
|
|
2192
|
+
RATE_LIMIT_REMAINING: "response.rateLimit.remaining",
|
|
2193
|
+
RATE_LIMIT_RESET: "response.rateLimit.reset"
|
|
2148
2194
|
};
|
|
2149
2195
|
|
|
2150
2196
|
// src/v3/taskContext/index.ts
|
|
@@ -2234,10 +2280,118 @@ var TaskContextAPI = _TaskContextAPI;
|
|
|
2234
2280
|
// src/v3/task-context-api.ts
|
|
2235
2281
|
var taskContext = TaskContextAPI.getInstance();
|
|
2236
2282
|
|
|
2283
|
+
// src/retry.ts
|
|
2284
|
+
function calculateResetAt(resets, format, now = /* @__PURE__ */ new Date()) {
|
|
2285
|
+
if (!resets)
|
|
2286
|
+
return;
|
|
2287
|
+
switch (format) {
|
|
2288
|
+
case "iso_8601_duration_openai_variant": {
|
|
2289
|
+
return calculateISO8601DurationOpenAIVariantResetAt(resets, now);
|
|
2290
|
+
}
|
|
2291
|
+
case "iso_8601": {
|
|
2292
|
+
return calculateISO8601ResetAt(resets, now);
|
|
2293
|
+
}
|
|
2294
|
+
case "unix_timestamp": {
|
|
2295
|
+
return calculateUnixTimestampResetAt(resets, now);
|
|
2296
|
+
}
|
|
2297
|
+
case "unix_timestamp_in_ms": {
|
|
2298
|
+
return calculateUnixTimestampInMsResetAt(resets, now);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
__name(calculateResetAt, "calculateResetAt");
|
|
2303
|
+
function calculateUnixTimestampResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2304
|
+
if (!resets)
|
|
2305
|
+
return void 0;
|
|
2306
|
+
const resetAt = parseInt(resets, 10);
|
|
2307
|
+
if (isNaN(resetAt))
|
|
2308
|
+
return void 0;
|
|
2309
|
+
return new Date(resetAt * 1e3);
|
|
2310
|
+
}
|
|
2311
|
+
__name(calculateUnixTimestampResetAt, "calculateUnixTimestampResetAt");
|
|
2312
|
+
function calculateUnixTimestampInMsResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2313
|
+
if (!resets)
|
|
2314
|
+
return void 0;
|
|
2315
|
+
const resetAt = parseInt(resets, 10);
|
|
2316
|
+
if (isNaN(resetAt))
|
|
2317
|
+
return void 0;
|
|
2318
|
+
return new Date(resetAt);
|
|
2319
|
+
}
|
|
2320
|
+
__name(calculateUnixTimestampInMsResetAt, "calculateUnixTimestampInMsResetAt");
|
|
2321
|
+
function calculateISO8601ResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2322
|
+
if (!resets)
|
|
2323
|
+
return void 0;
|
|
2324
|
+
const resetAt = new Date(resets);
|
|
2325
|
+
if (isNaN(resetAt.getTime()))
|
|
2326
|
+
return void 0;
|
|
2327
|
+
return resetAt;
|
|
2328
|
+
}
|
|
2329
|
+
__name(calculateISO8601ResetAt, "calculateISO8601ResetAt");
|
|
2330
|
+
function calculateISO8601DurationOpenAIVariantResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2331
|
+
if (!resets)
|
|
2332
|
+
return void 0;
|
|
2333
|
+
const pattern = /^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)ms)?$/;
|
|
2334
|
+
const match = resets.match(pattern);
|
|
2335
|
+
if (!match)
|
|
2336
|
+
return void 0;
|
|
2337
|
+
const days = parseInt(match[1], 10) || 0;
|
|
2338
|
+
const hours = parseInt(match[2], 10) || 0;
|
|
2339
|
+
const minutes = parseInt(match[3], 10) || 0;
|
|
2340
|
+
const seconds = parseFloat(match[4]) || 0;
|
|
2341
|
+
const milliseconds = parseInt(match[5], 10) || 0;
|
|
2342
|
+
const resetAt = new Date(now);
|
|
2343
|
+
resetAt.setDate(resetAt.getDate() + days);
|
|
2344
|
+
resetAt.setHours(resetAt.getHours() + hours);
|
|
2345
|
+
resetAt.setMinutes(resetAt.getMinutes() + minutes);
|
|
2346
|
+
resetAt.setSeconds(resetAt.getSeconds() + Math.floor(seconds));
|
|
2347
|
+
resetAt.setMilliseconds(resetAt.getMilliseconds() + (seconds - Math.floor(seconds)) * 1e3 + milliseconds);
|
|
2348
|
+
return resetAt;
|
|
2349
|
+
}
|
|
2350
|
+
__name(calculateISO8601DurationOpenAIVariantResetAt, "calculateISO8601DurationOpenAIVariantResetAt");
|
|
2351
|
+
|
|
2352
|
+
// src/v3/utils/retries.ts
|
|
2353
|
+
var defaultRetryOptions = {
|
|
2354
|
+
maxAttempts: 3,
|
|
2355
|
+
factor: 2,
|
|
2356
|
+
minTimeoutInMs: 1e3,
|
|
2357
|
+
maxTimeoutInMs: 6e4,
|
|
2358
|
+
randomize: true
|
|
2359
|
+
};
|
|
2360
|
+
var defaultFetchRetryOptions = {
|
|
2361
|
+
byStatus: {
|
|
2362
|
+
"429,408,409,5xx": {
|
|
2363
|
+
strategy: "backoff",
|
|
2364
|
+
...defaultRetryOptions
|
|
2365
|
+
}
|
|
2366
|
+
},
|
|
2367
|
+
connectionError: defaultRetryOptions,
|
|
2368
|
+
timeout: defaultRetryOptions
|
|
2369
|
+
};
|
|
2370
|
+
function calculateNextRetryDelay(options, attempt) {
|
|
2371
|
+
const opts = {
|
|
2372
|
+
...defaultRetryOptions,
|
|
2373
|
+
...options
|
|
2374
|
+
};
|
|
2375
|
+
if (attempt >= opts.maxAttempts) {
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
const { factor, minTimeoutInMs, maxTimeoutInMs, randomize } = opts;
|
|
2379
|
+
const random = randomize ? Math.random() + 1 : 1;
|
|
2380
|
+
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
2381
|
+
return Math.round(timeout);
|
|
2382
|
+
}
|
|
2383
|
+
__name(calculateNextRetryDelay, "calculateNextRetryDelay");
|
|
2384
|
+
function calculateResetAt2(resets, format, now = Date.now()) {
|
|
2385
|
+
const resetAt = calculateResetAt(resets, format, new Date(now));
|
|
2386
|
+
return resetAt?.getTime();
|
|
2387
|
+
}
|
|
2388
|
+
__name(calculateResetAt2, "calculateResetAt");
|
|
2389
|
+
|
|
2237
2390
|
// src/v3/apiClient/errors.ts
|
|
2238
2391
|
var _ApiError = class _ApiError extends Error {
|
|
2239
2392
|
constructor(status, error, message, headers) {
|
|
2240
2393
|
super(`${_ApiError.makeMessage(status, error, message)}`);
|
|
2394
|
+
this.name = "TriggerApiError";
|
|
2241
2395
|
this.status = status;
|
|
2242
2396
|
this.headers = headers;
|
|
2243
2397
|
const data = error;
|
|
@@ -2358,6 +2512,16 @@ var _RateLimitError = class _RateLimitError extends ApiError {
|
|
|
2358
2512
|
super(...arguments);
|
|
2359
2513
|
__publicField(this, "status", 429);
|
|
2360
2514
|
}
|
|
2515
|
+
get millisecondsUntilReset() {
|
|
2516
|
+
const resetAtUnixEpochMs = (this.headers ?? {})["x-ratelimit-reset"];
|
|
2517
|
+
if (typeof resetAtUnixEpochMs === "string") {
|
|
2518
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
2519
|
+
if (isNaN(resetAtUnixEpoch)) {
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
return Math.max(resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 2e3), 0);
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2361
2525
|
};
|
|
2362
2526
|
__name(_RateLimitError, "RateLimitError");
|
|
2363
2527
|
var RateLimitError = _RateLimitError;
|
|
@@ -2372,112 +2536,131 @@ function castToError(err) {
|
|
|
2372
2536
|
}
|
|
2373
2537
|
__name(castToError, "castToError");
|
|
2374
2538
|
|
|
2375
|
-
// src/
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2539
|
+
// src/v3/utils/flattenAttributes.ts
|
|
2540
|
+
var NULL_SENTINEL = "$@null((";
|
|
2541
|
+
function flattenAttributes(obj, prefix) {
|
|
2542
|
+
const result = {};
|
|
2543
|
+
if (obj === void 0) {
|
|
2544
|
+
return result;
|
|
2545
|
+
}
|
|
2546
|
+
if (obj === null) {
|
|
2547
|
+
result[prefix || ""] = NULL_SENTINEL;
|
|
2548
|
+
return result;
|
|
2549
|
+
}
|
|
2550
|
+
if (typeof obj === "string") {
|
|
2551
|
+
result[prefix || ""] = obj;
|
|
2552
|
+
return result;
|
|
2553
|
+
}
|
|
2554
|
+
if (typeof obj === "number") {
|
|
2555
|
+
result[prefix || ""] = obj;
|
|
2556
|
+
return result;
|
|
2557
|
+
}
|
|
2558
|
+
if (typeof obj === "boolean") {
|
|
2559
|
+
result[prefix || ""] = obj;
|
|
2560
|
+
return result;
|
|
2561
|
+
}
|
|
2562
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2563
|
+
const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
|
|
2564
|
+
if (Array.isArray(value)) {
|
|
2565
|
+
for (let i = 0; i < value.length; i++) {
|
|
2566
|
+
if (typeof value[i] === "object" && value[i] !== null) {
|
|
2567
|
+
Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
|
|
2568
|
+
} else {
|
|
2569
|
+
if (value[i] === null) {
|
|
2570
|
+
result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
|
|
2571
|
+
} else {
|
|
2572
|
+
result[`${newPrefix}.[${i}]`] = value[i];
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
} else if (isRecord(value)) {
|
|
2577
|
+
Object.assign(result, flattenAttributes(value, newPrefix));
|
|
2578
|
+
} else {
|
|
2579
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
|
|
2580
|
+
result[newPrefix] = value;
|
|
2581
|
+
} else if (value === null) {
|
|
2582
|
+
result[newPrefix] = NULL_SENTINEL;
|
|
2583
|
+
}
|
|
2385
2584
|
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2585
|
+
}
|
|
2586
|
+
return result;
|
|
2587
|
+
}
|
|
2588
|
+
__name(flattenAttributes, "flattenAttributes");
|
|
2589
|
+
function isRecord(value) {
|
|
2590
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2591
|
+
}
|
|
2592
|
+
__name(isRecord, "isRecord");
|
|
2593
|
+
function unflattenAttributes(obj) {
|
|
2594
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
|
|
2595
|
+
return obj;
|
|
2596
|
+
}
|
|
2597
|
+
if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
|
|
2598
|
+
return rehydrateNull(obj[""]);
|
|
2599
|
+
}
|
|
2600
|
+
if (Object.keys(obj).length === 0) {
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
const result = {};
|
|
2604
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2605
|
+
const parts = key.split(".").reduce((acc, part) => {
|
|
2606
|
+
if (part.includes("[")) {
|
|
2607
|
+
const subparts = part.split(/\[|\]/).filter((p) => p !== "");
|
|
2608
|
+
acc.push(...subparts);
|
|
2609
|
+
} else {
|
|
2610
|
+
acc.push(part);
|
|
2611
|
+
}
|
|
2612
|
+
return acc;
|
|
2613
|
+
}, []);
|
|
2614
|
+
let current = result;
|
|
2615
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2616
|
+
const part = parts[i];
|
|
2617
|
+
const nextPart = parts[i + 1];
|
|
2618
|
+
const isArray = /^\d+$/.test(nextPart);
|
|
2619
|
+
if (isArray && !Array.isArray(current[part])) {
|
|
2620
|
+
current[part] = [];
|
|
2621
|
+
} else if (!isArray && current[part] === void 0) {
|
|
2622
|
+
current[part] = {};
|
|
2623
|
+
}
|
|
2624
|
+
current = current[part];
|
|
2388
2625
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2626
|
+
const lastPart = parts[parts.length - 1];
|
|
2627
|
+
current[lastPart] = rehydrateNull(value);
|
|
2628
|
+
}
|
|
2629
|
+
if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
|
|
2630
|
+
const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
|
|
2631
|
+
const arrayResult = Array(maxIndex + 1);
|
|
2632
|
+
for (const key in result) {
|
|
2633
|
+
arrayResult[parseInt(key)] = result[key];
|
|
2391
2634
|
}
|
|
2635
|
+
return arrayResult;
|
|
2392
2636
|
}
|
|
2637
|
+
return result;
|
|
2393
2638
|
}
|
|
2394
|
-
__name(
|
|
2395
|
-
function
|
|
2396
|
-
if (
|
|
2397
|
-
return
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
function calculateUnixTimestampInMsResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2405
|
-
if (!resets)
|
|
2406
|
-
return void 0;
|
|
2407
|
-
const resetAt = parseInt(resets, 10);
|
|
2408
|
-
if (isNaN(resetAt))
|
|
2409
|
-
return void 0;
|
|
2410
|
-
return new Date(resetAt);
|
|
2411
|
-
}
|
|
2412
|
-
__name(calculateUnixTimestampInMsResetAt, "calculateUnixTimestampInMsResetAt");
|
|
2413
|
-
function calculateISO8601ResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2414
|
-
if (!resets)
|
|
2415
|
-
return void 0;
|
|
2416
|
-
const resetAt = new Date(resets);
|
|
2417
|
-
if (isNaN(resetAt.getTime()))
|
|
2418
|
-
return void 0;
|
|
2419
|
-
return resetAt;
|
|
2420
|
-
}
|
|
2421
|
-
__name(calculateISO8601ResetAt, "calculateISO8601ResetAt");
|
|
2422
|
-
function calculateISO8601DurationOpenAIVariantResetAt(resets, now = /* @__PURE__ */ new Date()) {
|
|
2423
|
-
if (!resets)
|
|
2424
|
-
return void 0;
|
|
2425
|
-
const pattern = /^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?(?:(\d+)ms)?$/;
|
|
2426
|
-
const match = resets.match(pattern);
|
|
2427
|
-
if (!match)
|
|
2428
|
-
return void 0;
|
|
2429
|
-
const days = parseInt(match[1], 10) || 0;
|
|
2430
|
-
const hours = parseInt(match[2], 10) || 0;
|
|
2431
|
-
const minutes = parseInt(match[3], 10) || 0;
|
|
2432
|
-
const seconds = parseFloat(match[4]) || 0;
|
|
2433
|
-
const milliseconds = parseInt(match[5], 10) || 0;
|
|
2434
|
-
const resetAt = new Date(now);
|
|
2435
|
-
resetAt.setDate(resetAt.getDate() + days);
|
|
2436
|
-
resetAt.setHours(resetAt.getHours() + hours);
|
|
2437
|
-
resetAt.setMinutes(resetAt.getMinutes() + minutes);
|
|
2438
|
-
resetAt.setSeconds(resetAt.getSeconds() + Math.floor(seconds));
|
|
2439
|
-
resetAt.setMilliseconds(resetAt.getMilliseconds() + (seconds - Math.floor(seconds)) * 1e3 + milliseconds);
|
|
2440
|
-
return resetAt;
|
|
2639
|
+
__name(unflattenAttributes, "unflattenAttributes");
|
|
2640
|
+
function primitiveValueOrflattenedAttributes(obj, prefix) {
|
|
2641
|
+
if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
|
|
2642
|
+
return obj;
|
|
2643
|
+
}
|
|
2644
|
+
const attributes = flattenAttributes(obj, prefix);
|
|
2645
|
+
if (prefix !== void 0 && typeof attributes[prefix] !== "undefined" && attributes[prefix] !== null) {
|
|
2646
|
+
return attributes[prefix];
|
|
2647
|
+
}
|
|
2648
|
+
return attributes;
|
|
2441
2649
|
}
|
|
2442
|
-
__name(
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
maxAttempts: 3,
|
|
2447
|
-
factor: 2,
|
|
2448
|
-
minTimeoutInMs: 1e3,
|
|
2449
|
-
maxTimeoutInMs: 6e4,
|
|
2450
|
-
randomize: true
|
|
2451
|
-
};
|
|
2452
|
-
var defaultFetchRetryOptions = {
|
|
2453
|
-
byStatus: {
|
|
2454
|
-
"429,408,409,5xx": {
|
|
2455
|
-
strategy: "backoff",
|
|
2456
|
-
...defaultRetryOptions
|
|
2457
|
-
}
|
|
2458
|
-
},
|
|
2459
|
-
connectionError: defaultRetryOptions,
|
|
2460
|
-
timeout: defaultRetryOptions
|
|
2461
|
-
};
|
|
2462
|
-
function calculateNextRetryDelay(options, attempt) {
|
|
2463
|
-
const opts = {
|
|
2464
|
-
...defaultRetryOptions,
|
|
2465
|
-
...options
|
|
2466
|
-
};
|
|
2467
|
-
if (attempt >= opts.maxAttempts) {
|
|
2468
|
-
return;
|
|
2650
|
+
__name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
|
|
2651
|
+
function rehydrateNull(value) {
|
|
2652
|
+
if (value === NULL_SENTINEL) {
|
|
2653
|
+
return null;
|
|
2469
2654
|
}
|
|
2470
|
-
|
|
2471
|
-
const random = randomize ? Math.random() + 1 : 1;
|
|
2472
|
-
const timeout = Math.min(maxTimeoutInMs, random * minTimeoutInMs * Math.pow(factor, attempt - 1));
|
|
2473
|
-
return Math.round(timeout);
|
|
2655
|
+
return value;
|
|
2474
2656
|
}
|
|
2475
|
-
__name(
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2657
|
+
__name(rehydrateNull, "rehydrateNull");
|
|
2658
|
+
|
|
2659
|
+
// src/v3/utils/styleAttributes.ts
|
|
2660
|
+
function accessoryAttributes(accessory) {
|
|
2661
|
+
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
2479
2662
|
}
|
|
2480
|
-
__name(
|
|
2663
|
+
__name(accessoryAttributes, "accessoryAttributes");
|
|
2481
2664
|
|
|
2482
2665
|
// src/v3/apiClient/pagination.ts
|
|
2483
2666
|
var _CursorPage = class _CursorPage {
|
|
@@ -2587,6 +2770,12 @@ var defaultRetryOptions2 = {
|
|
|
2587
2770
|
maxTimeoutInMs: 6e4,
|
|
2588
2771
|
randomize: false
|
|
2589
2772
|
};
|
|
2773
|
+
var requestOptionsKeys = {
|
|
2774
|
+
retry: true
|
|
2775
|
+
};
|
|
2776
|
+
var isRequestOptions = /* @__PURE__ */ __name((obj) => {
|
|
2777
|
+
return typeof obj === "object" && obj !== null && !isEmptyObj(obj) && Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k));
|
|
2778
|
+
}, "isRequestOptions");
|
|
2590
2779
|
function zodfetch(schema, url, requestInit, options) {
|
|
2591
2780
|
return new ApiPromise(_doZodFetch(schema, url, requestInit, options));
|
|
2592
2781
|
}
|
|
@@ -2637,16 +2826,43 @@ function zodfetchOffsetLimitPage(schema, url, params, requestInit, options) {
|
|
|
2637
2826
|
return new OffsetLimitPagePromise(fetchResult, schema, url, params, requestInit, options);
|
|
2638
2827
|
}
|
|
2639
2828
|
__name(zodfetchOffsetLimitPage, "zodfetchOffsetLimitPage");
|
|
2640
|
-
async function
|
|
2829
|
+
async function traceZodFetch(params, callback) {
|
|
2830
|
+
if (!params.options?.tracer) {
|
|
2831
|
+
return callback();
|
|
2832
|
+
}
|
|
2833
|
+
const url = new URL(params.url);
|
|
2834
|
+
const method = params.requestInit?.method ?? "GET";
|
|
2835
|
+
const name = params.options.name ?? `${method} ${url.pathname}`;
|
|
2836
|
+
return await params.options.tracer.startActiveSpan(name, async (span) => {
|
|
2837
|
+
return await callback(span);
|
|
2838
|
+
}, {
|
|
2839
|
+
attributes: {
|
|
2840
|
+
[SemanticInternalAttributes.STYLE_ICON]: params.options?.icon ?? "api",
|
|
2841
|
+
...params.options.attributes
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
__name(traceZodFetch, "traceZodFetch");
|
|
2846
|
+
async function _doZodFetch(schema, url, requestInit, options) {
|
|
2847
|
+
const $requestInit = await requestInit;
|
|
2848
|
+
return traceZodFetch({
|
|
2849
|
+
url,
|
|
2850
|
+
requestInit: $requestInit,
|
|
2851
|
+
options
|
|
2852
|
+
}, async (span) => {
|
|
2853
|
+
return await _doZodFetchWithRetries(schema, url, $requestInit, options);
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
__name(_doZodFetch, "_doZodFetch");
|
|
2857
|
+
async function _doZodFetchWithRetries(schema, url, requestInit, options, attempt = 1) {
|
|
2641
2858
|
try {
|
|
2642
|
-
const
|
|
2643
|
-
const response = await fetch(url, requestInitWithCache($requestInit));
|
|
2859
|
+
const response = await fetch(url, requestInitWithCache(requestInit));
|
|
2644
2860
|
const responseHeaders = createResponseHeaders(response.headers);
|
|
2645
2861
|
if (!response.ok) {
|
|
2646
2862
|
const retryResult = shouldRetry(response, attempt, options?.retry);
|
|
2647
2863
|
if (retryResult.retry) {
|
|
2648
|
-
await
|
|
2649
|
-
return await
|
|
2864
|
+
await waitForRetry(url, attempt + 1, retryResult.delay, options, requestInit, response);
|
|
2865
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
2650
2866
|
} else {
|
|
2651
2867
|
const errText = await response.text().catch((e) => castToError2(e).message);
|
|
2652
2868
|
const errJSON = safeJsonParse(errText);
|
|
@@ -2674,8 +2890,8 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
2674
2890
|
};
|
|
2675
2891
|
const delay = calculateNextRetryDelay(retry, attempt);
|
|
2676
2892
|
if (delay) {
|
|
2677
|
-
await
|
|
2678
|
-
return await
|
|
2893
|
+
await waitForRetry(url, attempt + 1, delay, options, requestInit);
|
|
2894
|
+
return await _doZodFetchWithRetries(schema, url, requestInit, options, attempt + 1);
|
|
2679
2895
|
}
|
|
2680
2896
|
}
|
|
2681
2897
|
throw new ApiConnectionError({
|
|
@@ -2683,7 +2899,7 @@ async function _doZodFetch(schema, url, requestInit, options, attempt = 1) {
|
|
|
2683
2899
|
});
|
|
2684
2900
|
}
|
|
2685
2901
|
}
|
|
2686
|
-
__name(
|
|
2902
|
+
__name(_doZodFetchWithRetries, "_doZodFetchWithRetries");
|
|
2687
2903
|
function castToError2(err) {
|
|
2688
2904
|
if (err instanceof Error)
|
|
2689
2905
|
return err;
|
|
@@ -2720,8 +2936,25 @@ function shouldRetry(response, attempt, retryOptions) {
|
|
|
2720
2936
|
return shouldRetryForOptions();
|
|
2721
2937
|
if (response.status === 409)
|
|
2722
2938
|
return shouldRetryForOptions();
|
|
2723
|
-
if (response.status === 429)
|
|
2939
|
+
if (response.status === 429) {
|
|
2940
|
+
if (attempt >= (typeof retryOptions?.maxAttempts === "number" ? retryOptions?.maxAttempts : 3)) {
|
|
2941
|
+
return {
|
|
2942
|
+
retry: false
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
const resetAtUnixEpochMs = response.headers.get("x-ratelimit-reset");
|
|
2946
|
+
if (resetAtUnixEpochMs) {
|
|
2947
|
+
const resetAtUnixEpoch = parseInt(resetAtUnixEpochMs, 10);
|
|
2948
|
+
const delay = resetAtUnixEpoch - Date.now() + Math.floor(Math.random() * 1e3);
|
|
2949
|
+
if (delay > 0) {
|
|
2950
|
+
return {
|
|
2951
|
+
retry: true,
|
|
2952
|
+
delay
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2724
2956
|
return shouldRetryForOptions();
|
|
2957
|
+
}
|
|
2725
2958
|
if (response.status >= 500)
|
|
2726
2959
|
return shouldRetryForOptions();
|
|
2727
2960
|
return {
|
|
@@ -2884,9 +3117,44 @@ fetchPage_fn2 = /* @__PURE__ */ __name(function(params1) {
|
|
|
2884
3117
|
}, "#fetchPage");
|
|
2885
3118
|
__name(_OffsetLimitPagePromise, "OffsetLimitPagePromise");
|
|
2886
3119
|
var OffsetLimitPagePromise = _OffsetLimitPagePromise;
|
|
3120
|
+
async function waitForRetry(url, attempt, delay, options, requestInit, response) {
|
|
3121
|
+
if (options?.tracer) {
|
|
3122
|
+
const method = requestInit?.method ?? "GET";
|
|
3123
|
+
return options.tracer.startActiveSpan(response ? `wait after ${response.status}` : `wait after error`, async (span) => {
|
|
3124
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3125
|
+
}, {
|
|
3126
|
+
attributes: {
|
|
3127
|
+
[SemanticInternalAttributes.STYLE_ICON]: "wait",
|
|
3128
|
+
...accessoryAttributes({
|
|
3129
|
+
items: [
|
|
3130
|
+
{
|
|
3131
|
+
text: `retrying ${options?.name ?? method.toUpperCase()} in ${delay}ms`,
|
|
3132
|
+
variant: "normal"
|
|
3133
|
+
}
|
|
3134
|
+
],
|
|
3135
|
+
style: "codepath"
|
|
3136
|
+
})
|
|
3137
|
+
}
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
3141
|
+
}
|
|
3142
|
+
__name(waitForRetry, "waitForRetry");
|
|
3143
|
+
function isEmptyObj(obj) {
|
|
3144
|
+
if (!obj)
|
|
3145
|
+
return true;
|
|
3146
|
+
for (const _k in obj)
|
|
3147
|
+
return false;
|
|
3148
|
+
return true;
|
|
3149
|
+
}
|
|
3150
|
+
__name(isEmptyObj, "isEmptyObj");
|
|
3151
|
+
function hasOwn(obj, key) {
|
|
3152
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
3153
|
+
}
|
|
3154
|
+
__name(hasOwn, "hasOwn");
|
|
2887
3155
|
|
|
2888
3156
|
// src/v3/apiClient/index.ts
|
|
2889
|
-
var
|
|
3157
|
+
var DEFAULT_ZOD_FETCH_OPTIONS = {
|
|
2890
3158
|
retry: {
|
|
2891
3159
|
maxAttempts: 3,
|
|
2892
3160
|
minTimeoutInMs: 1e3,
|
|
@@ -2897,17 +3165,18 @@ var zodFetchOptions = {
|
|
|
2897
3165
|
};
|
|
2898
3166
|
var _getHeaders, getHeaders_fn;
|
|
2899
3167
|
var _ApiClient = class _ApiClient {
|
|
2900
|
-
constructor(baseUrl, accessToken) {
|
|
3168
|
+
constructor(baseUrl, accessToken, requestOptions = {}) {
|
|
2901
3169
|
__privateAdd(this, _getHeaders);
|
|
2902
3170
|
this.accessToken = accessToken;
|
|
2903
3171
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
3172
|
+
this.defaultRequestOptions = mergeRequestOptions(DEFAULT_ZOD_FETCH_OPTIONS, requestOptions);
|
|
2904
3173
|
}
|
|
2905
|
-
async getRunResult(runId) {
|
|
3174
|
+
async getRunResult(runId, requestOptions) {
|
|
2906
3175
|
try {
|
|
2907
3176
|
return await zodfetch(TaskRunExecutionResult, `${this.baseUrl}/api/v1/runs/${runId}/result`, {
|
|
2908
3177
|
method: "GET",
|
|
2909
3178
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2910
|
-
},
|
|
3179
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2911
3180
|
} catch (error) {
|
|
2912
3181
|
if (error instanceof ApiError) {
|
|
2913
3182
|
if (error.status === 404) {
|
|
@@ -2917,47 +3186,47 @@ var _ApiClient = class _ApiClient {
|
|
|
2917
3186
|
throw error;
|
|
2918
3187
|
}
|
|
2919
3188
|
}
|
|
2920
|
-
async getBatchResults(batchId) {
|
|
3189
|
+
async getBatchResults(batchId, requestOptions) {
|
|
2921
3190
|
return await zodfetch(BatchTaskRunExecutionResult, `${this.baseUrl}/api/v1/batches/${batchId}/results`, {
|
|
2922
3191
|
method: "GET",
|
|
2923
3192
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2924
|
-
},
|
|
3193
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2925
3194
|
}
|
|
2926
|
-
triggerTask(taskId, body, options) {
|
|
3195
|
+
triggerTask(taskId, body, options, requestOptions) {
|
|
2927
3196
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
2928
3197
|
return zodfetch(TriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`, {
|
|
2929
3198
|
method: "POST",
|
|
2930
3199
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
2931
3200
|
body: JSON.stringify(body)
|
|
2932
|
-
},
|
|
3201
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2933
3202
|
}
|
|
2934
|
-
batchTriggerTask(taskId, body, options) {
|
|
3203
|
+
batchTriggerTask(taskId, body, options, requestOptions) {
|
|
2935
3204
|
const encodedTaskId = encodeURIComponent(taskId);
|
|
2936
3205
|
return zodfetch(BatchTriggerTaskResponse, `${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`, {
|
|
2937
3206
|
method: "POST",
|
|
2938
3207
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, options?.spanParentAsLink ?? false),
|
|
2939
3208
|
body: JSON.stringify(body)
|
|
2940
|
-
},
|
|
3209
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2941
3210
|
}
|
|
2942
|
-
createUploadPayloadUrl(filename) {
|
|
3211
|
+
createUploadPayloadUrl(filename, requestOptions) {
|
|
2943
3212
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
2944
3213
|
method: "PUT",
|
|
2945
3214
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2946
|
-
},
|
|
3215
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2947
3216
|
}
|
|
2948
|
-
getPayloadUrl(filename) {
|
|
3217
|
+
getPayloadUrl(filename, requestOptions) {
|
|
2949
3218
|
return zodfetch(CreateUploadPayloadUrlResponseBody, `${this.baseUrl}/api/v1/packets/${filename}`, {
|
|
2950
3219
|
method: "GET",
|
|
2951
3220
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2952
|
-
},
|
|
3221
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2953
3222
|
}
|
|
2954
|
-
retrieveRun(runId) {
|
|
3223
|
+
retrieveRun(runId, requestOptions) {
|
|
2955
3224
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v3/runs/${runId}`, {
|
|
2956
3225
|
method: "GET",
|
|
2957
3226
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2958
|
-
},
|
|
3227
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2959
3228
|
}
|
|
2960
|
-
listRuns(query) {
|
|
3229
|
+
listRuns(query, requestOptions) {
|
|
2961
3230
|
const searchParams = createSearchQueryForListRuns(query);
|
|
2962
3231
|
return zodfetchCursorPage(ListRunResponseItem, `${this.baseUrl}/api/v1/runs`, {
|
|
2963
3232
|
query: searchParams,
|
|
@@ -2967,9 +3236,9 @@ var _ApiClient = class _ApiClient {
|
|
|
2967
3236
|
}, {
|
|
2968
3237
|
method: "GET",
|
|
2969
3238
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2970
|
-
},
|
|
3239
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2971
3240
|
}
|
|
2972
|
-
listProjectRuns(projectRef, query) {
|
|
3241
|
+
listProjectRuns(projectRef, query, requestOptions) {
|
|
2973
3242
|
const searchParams = createSearchQueryForListRuns(query);
|
|
2974
3243
|
if (query?.env) {
|
|
2975
3244
|
searchParams.append("filter[env]", Array.isArray(query.env) ? query.env.join(",") : query.env);
|
|
@@ -2982,35 +3251,35 @@ var _ApiClient = class _ApiClient {
|
|
|
2982
3251
|
}, {
|
|
2983
3252
|
method: "GET",
|
|
2984
3253
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2985
|
-
},
|
|
3254
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2986
3255
|
}
|
|
2987
|
-
replayRun(runId) {
|
|
3256
|
+
replayRun(runId, requestOptions) {
|
|
2988
3257
|
return zodfetch(ReplayRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/replay`, {
|
|
2989
3258
|
method: "POST",
|
|
2990
3259
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2991
|
-
},
|
|
3260
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2992
3261
|
}
|
|
2993
|
-
cancelRun(runId) {
|
|
3262
|
+
cancelRun(runId, requestOptions) {
|
|
2994
3263
|
return zodfetch(CanceledRunResponse, `${this.baseUrl}/api/v2/runs/${runId}/cancel`, {
|
|
2995
3264
|
method: "POST",
|
|
2996
3265
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
2997
|
-
},
|
|
3266
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
2998
3267
|
}
|
|
2999
|
-
rescheduleRun(runId, body) {
|
|
3268
|
+
rescheduleRun(runId, body, requestOptions) {
|
|
3000
3269
|
return zodfetch(RetrieveRunResponse, `${this.baseUrl}/api/v1/runs/${runId}/reschedule`, {
|
|
3001
3270
|
method: "POST",
|
|
3002
3271
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3003
3272
|
body: JSON.stringify(body)
|
|
3004
|
-
},
|
|
3273
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3005
3274
|
}
|
|
3006
|
-
createSchedule(options) {
|
|
3275
|
+
createSchedule(options, requestOptions) {
|
|
3007
3276
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules`, {
|
|
3008
3277
|
method: "POST",
|
|
3009
3278
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3010
3279
|
body: JSON.stringify(options)
|
|
3011
|
-
});
|
|
3280
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3012
3281
|
}
|
|
3013
|
-
listSchedules(options) {
|
|
3282
|
+
listSchedules(options, requestOptions) {
|
|
3014
3283
|
const searchParams = new URLSearchParams();
|
|
3015
3284
|
if (options?.page) {
|
|
3016
3285
|
searchParams.append("page", options.page.toString());
|
|
@@ -3024,77 +3293,77 @@ var _ApiClient = class _ApiClient {
|
|
|
3024
3293
|
}, {
|
|
3025
3294
|
method: "GET",
|
|
3026
3295
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3027
|
-
});
|
|
3296
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3028
3297
|
}
|
|
3029
|
-
retrieveSchedule(scheduleId) {
|
|
3298
|
+
retrieveSchedule(scheduleId, requestOptions) {
|
|
3030
3299
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
3031
3300
|
method: "GET",
|
|
3032
3301
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3033
|
-
});
|
|
3302
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3034
3303
|
}
|
|
3035
|
-
updateSchedule(scheduleId, options) {
|
|
3304
|
+
updateSchedule(scheduleId, options, requestOptions) {
|
|
3036
3305
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
3037
3306
|
method: "PUT",
|
|
3038
3307
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3039
3308
|
body: JSON.stringify(options)
|
|
3040
|
-
});
|
|
3309
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3041
3310
|
}
|
|
3042
|
-
deactivateSchedule(scheduleId) {
|
|
3311
|
+
deactivateSchedule(scheduleId, requestOptions) {
|
|
3043
3312
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/deactivate`, {
|
|
3044
3313
|
method: "POST",
|
|
3045
3314
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3046
|
-
});
|
|
3315
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3047
3316
|
}
|
|
3048
|
-
activateSchedule(scheduleId) {
|
|
3317
|
+
activateSchedule(scheduleId, requestOptions) {
|
|
3049
3318
|
return zodfetch(ScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}/activate`, {
|
|
3050
3319
|
method: "POST",
|
|
3051
3320
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3052
|
-
});
|
|
3321
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3053
3322
|
}
|
|
3054
|
-
deleteSchedule(scheduleId) {
|
|
3323
|
+
deleteSchedule(scheduleId, requestOptions) {
|
|
3055
3324
|
return zodfetch(DeletedScheduleObject, `${this.baseUrl}/api/v1/schedules/${scheduleId}`, {
|
|
3056
3325
|
method: "DELETE",
|
|
3057
3326
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3058
|
-
});
|
|
3327
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3059
3328
|
}
|
|
3060
|
-
listEnvVars(projectRef, slug) {
|
|
3329
|
+
listEnvVars(projectRef, slug, requestOptions) {
|
|
3061
3330
|
return zodfetch(EnvironmentVariables, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
3062
3331
|
method: "GET",
|
|
3063
3332
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3064
|
-
});
|
|
3333
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3065
3334
|
}
|
|
3066
|
-
importEnvVars(projectRef, slug, body) {
|
|
3335
|
+
importEnvVars(projectRef, slug, body, requestOptions) {
|
|
3067
3336
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/import`, {
|
|
3068
3337
|
method: "POST",
|
|
3069
3338
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3070
3339
|
body: JSON.stringify(body)
|
|
3071
|
-
});
|
|
3340
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3072
3341
|
}
|
|
3073
|
-
retrieveEnvVar(projectRef, slug, key) {
|
|
3342
|
+
retrieveEnvVar(projectRef, slug, key, requestOptions) {
|
|
3074
3343
|
return zodfetch(EnvironmentVariableValue, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
3075
3344
|
method: "GET",
|
|
3076
3345
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3077
|
-
});
|
|
3346
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3078
3347
|
}
|
|
3079
|
-
createEnvVar(projectRef, slug, body) {
|
|
3348
|
+
createEnvVar(projectRef, slug, body, requestOptions) {
|
|
3080
3349
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}`, {
|
|
3081
3350
|
method: "POST",
|
|
3082
3351
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3083
3352
|
body: JSON.stringify(body)
|
|
3084
|
-
});
|
|
3353
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3085
3354
|
}
|
|
3086
|
-
updateEnvVar(projectRef, slug, key, body) {
|
|
3355
|
+
updateEnvVar(projectRef, slug, key, body, requestOptions) {
|
|
3087
3356
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
3088
3357
|
method: "PUT",
|
|
3089
3358
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false),
|
|
3090
3359
|
body: JSON.stringify(body)
|
|
3091
|
-
});
|
|
3360
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3092
3361
|
}
|
|
3093
|
-
deleteEnvVar(projectRef, slug, key) {
|
|
3362
|
+
deleteEnvVar(projectRef, slug, key, requestOptions) {
|
|
3094
3363
|
return zodfetch(EnvironmentVariableResponseBody, `${this.baseUrl}/api/v1/projects/${projectRef}/envvars/${slug}/${key}`, {
|
|
3095
3364
|
method: "DELETE",
|
|
3096
3365
|
headers: __privateMethod(this, _getHeaders, getHeaders_fn).call(this, false)
|
|
3097
|
-
});
|
|
3366
|
+
}, mergeRequestOptions(this.defaultRequestOptions, requestOptions));
|
|
3098
3367
|
}
|
|
3099
3368
|
};
|
|
3100
3369
|
_getHeaders = new WeakSet();
|
|
@@ -3149,6 +3418,20 @@ function createSearchQueryForListRuns(query) {
|
|
|
3149
3418
|
return searchParams;
|
|
3150
3419
|
}
|
|
3151
3420
|
__name(createSearchQueryForListRuns, "createSearchQueryForListRuns");
|
|
3421
|
+
function mergeRequestOptions(defaultOptions, options) {
|
|
3422
|
+
if (!options) {
|
|
3423
|
+
return defaultOptions;
|
|
3424
|
+
}
|
|
3425
|
+
return {
|
|
3426
|
+
...defaultOptions,
|
|
3427
|
+
...options,
|
|
3428
|
+
retry: {
|
|
3429
|
+
...defaultOptions.retry,
|
|
3430
|
+
...options.retry
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3434
|
+
__name(mergeRequestOptions, "mergeRequestOptions");
|
|
3152
3435
|
var _SimpleClock = class _SimpleClock {
|
|
3153
3436
|
preciseNow() {
|
|
3154
3437
|
const now = new preciseDate.PreciseDate();
|
|
@@ -3241,128 +3524,6 @@ function calculateAttributeValueLength(value) {
|
|
|
3241
3524
|
return 0;
|
|
3242
3525
|
}
|
|
3243
3526
|
__name(calculateAttributeValueLength, "calculateAttributeValueLength");
|
|
3244
|
-
|
|
3245
|
-
// src/v3/utils/flattenAttributes.ts
|
|
3246
|
-
var NULL_SENTINEL = "$@null((";
|
|
3247
|
-
function flattenAttributes(obj, prefix) {
|
|
3248
|
-
const result = {};
|
|
3249
|
-
if (obj === void 0) {
|
|
3250
|
-
return result;
|
|
3251
|
-
}
|
|
3252
|
-
if (obj === null) {
|
|
3253
|
-
result[prefix || ""] = NULL_SENTINEL;
|
|
3254
|
-
return result;
|
|
3255
|
-
}
|
|
3256
|
-
if (typeof obj === "string") {
|
|
3257
|
-
result[prefix || ""] = obj;
|
|
3258
|
-
return result;
|
|
3259
|
-
}
|
|
3260
|
-
if (typeof obj === "number") {
|
|
3261
|
-
result[prefix || ""] = obj;
|
|
3262
|
-
return result;
|
|
3263
|
-
}
|
|
3264
|
-
if (typeof obj === "boolean") {
|
|
3265
|
-
result[prefix || ""] = obj;
|
|
3266
|
-
return result;
|
|
3267
|
-
}
|
|
3268
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
3269
|
-
const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
|
|
3270
|
-
if (Array.isArray(value)) {
|
|
3271
|
-
for (let i = 0; i < value.length; i++) {
|
|
3272
|
-
if (typeof value[i] === "object" && value[i] !== null) {
|
|
3273
|
-
Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
|
|
3274
|
-
} else {
|
|
3275
|
-
if (value[i] === null) {
|
|
3276
|
-
result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
|
|
3277
|
-
} else {
|
|
3278
|
-
result[`${newPrefix}.[${i}]`] = value[i];
|
|
3279
|
-
}
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
} else if (isRecord(value)) {
|
|
3283
|
-
Object.assign(result, flattenAttributes(value, newPrefix));
|
|
3284
|
-
} else {
|
|
3285
|
-
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
|
|
3286
|
-
result[newPrefix] = value;
|
|
3287
|
-
} else if (value === null) {
|
|
3288
|
-
result[newPrefix] = NULL_SENTINEL;
|
|
3289
|
-
}
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
return result;
|
|
3293
|
-
}
|
|
3294
|
-
__name(flattenAttributes, "flattenAttributes");
|
|
3295
|
-
function isRecord(value) {
|
|
3296
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3297
|
-
}
|
|
3298
|
-
__name(isRecord, "isRecord");
|
|
3299
|
-
function unflattenAttributes(obj) {
|
|
3300
|
-
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
|
|
3301
|
-
return obj;
|
|
3302
|
-
}
|
|
3303
|
-
if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
|
|
3304
|
-
return rehydrateNull(obj[""]);
|
|
3305
|
-
}
|
|
3306
|
-
if (Object.keys(obj).length === 0) {
|
|
3307
|
-
return;
|
|
3308
|
-
}
|
|
3309
|
-
const result = {};
|
|
3310
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
3311
|
-
const parts = key.split(".").reduce((acc, part) => {
|
|
3312
|
-
if (part.includes("[")) {
|
|
3313
|
-
const subparts = part.split(/\[|\]/).filter((p) => p !== "");
|
|
3314
|
-
acc.push(...subparts);
|
|
3315
|
-
} else {
|
|
3316
|
-
acc.push(part);
|
|
3317
|
-
}
|
|
3318
|
-
return acc;
|
|
3319
|
-
}, []);
|
|
3320
|
-
let current = result;
|
|
3321
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
3322
|
-
const part = parts[i];
|
|
3323
|
-
const nextPart = parts[i + 1];
|
|
3324
|
-
const isArray = /^\d+$/.test(nextPart);
|
|
3325
|
-
if (isArray && !Array.isArray(current[part])) {
|
|
3326
|
-
current[part] = [];
|
|
3327
|
-
} else if (!isArray && current[part] === void 0) {
|
|
3328
|
-
current[part] = {};
|
|
3329
|
-
}
|
|
3330
|
-
current = current[part];
|
|
3331
|
-
}
|
|
3332
|
-
const lastPart = parts[parts.length - 1];
|
|
3333
|
-
current[lastPart] = rehydrateNull(value);
|
|
3334
|
-
}
|
|
3335
|
-
if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
|
|
3336
|
-
const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
|
|
3337
|
-
const arrayResult = Array(maxIndex + 1);
|
|
3338
|
-
for (const key in result) {
|
|
3339
|
-
arrayResult[parseInt(key)] = result[key];
|
|
3340
|
-
}
|
|
3341
|
-
return arrayResult;
|
|
3342
|
-
}
|
|
3343
|
-
return result;
|
|
3344
|
-
}
|
|
3345
|
-
__name(unflattenAttributes, "unflattenAttributes");
|
|
3346
|
-
function primitiveValueOrflattenedAttributes(obj, prefix) {
|
|
3347
|
-
if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
|
|
3348
|
-
return obj;
|
|
3349
|
-
}
|
|
3350
|
-
const attributes = flattenAttributes(obj, prefix);
|
|
3351
|
-
if (prefix !== void 0 && typeof attributes[prefix] !== "undefined" && attributes[prefix] !== null) {
|
|
3352
|
-
return attributes[prefix];
|
|
3353
|
-
}
|
|
3354
|
-
return attributes;
|
|
3355
|
-
}
|
|
3356
|
-
__name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
|
|
3357
|
-
function rehydrateNull(value) {
|
|
3358
|
-
if (value === NULL_SENTINEL) {
|
|
3359
|
-
return null;
|
|
3360
|
-
}
|
|
3361
|
-
return value;
|
|
3362
|
-
}
|
|
3363
|
-
__name(rehydrateNull, "rehydrateNull");
|
|
3364
|
-
|
|
3365
|
-
// src/v3/logger/taskLogger.ts
|
|
3366
3527
|
var _NoopTaskLogger = class _NoopTaskLogger {
|
|
3367
3528
|
debug() {
|
|
3368
3529
|
}
|
|
@@ -3807,14 +3968,16 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3807
3968
|
attributes,
|
|
3808
3969
|
startTime: clock.preciseNow()
|
|
3809
3970
|
}, parentContext, async (span) => {
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3971
|
+
if (taskContext.ctx) {
|
|
3972
|
+
this.tracer.startSpan(name, {
|
|
3973
|
+
...options,
|
|
3974
|
+
attributes: {
|
|
3975
|
+
...attributes,
|
|
3976
|
+
[SemanticInternalAttributes.SPAN_PARTIAL]: true,
|
|
3977
|
+
[SemanticInternalAttributes.SPAN_ID]: span.spanContext().spanId
|
|
3978
|
+
}
|
|
3979
|
+
}, parentContext).end();
|
|
3980
|
+
}
|
|
3818
3981
|
const usageMeasurement = usage.start();
|
|
3819
3982
|
try {
|
|
3820
3983
|
return await fn(span);
|
|
@@ -3827,12 +3990,14 @@ var _TriggerTracer = class _TriggerTracer {
|
|
|
3827
3990
|
});
|
|
3828
3991
|
throw e;
|
|
3829
3992
|
} finally {
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3993
|
+
if (taskContext.ctx) {
|
|
3994
|
+
const usageSample = usage.stop(usageMeasurement);
|
|
3995
|
+
const machine = taskContext.ctx.machine;
|
|
3996
|
+
span.setAttributes({
|
|
3997
|
+
[SemanticInternalAttributes.USAGE_DURATION_MS]: usageSample.cpuTime,
|
|
3998
|
+
[SemanticInternalAttributes.USAGE_COST_IN_CENTS]: machine?.centsPerMs ? usageSample.cpuTime * machine.centsPerMs : 0
|
|
3999
|
+
});
|
|
4000
|
+
}
|
|
3836
4001
|
span.end(clock.preciseNow());
|
|
3837
4002
|
}
|
|
3838
4003
|
});
|
|
@@ -4024,12 +4189,6 @@ function omit(obj, ...keys) {
|
|
|
4024
4189
|
}
|
|
4025
4190
|
__name(omit, "omit");
|
|
4026
4191
|
|
|
4027
|
-
// src/v3/utils/styleAttributes.ts
|
|
4028
|
-
function accessoryAttributes(accessory) {
|
|
4029
|
-
return flattenAttributes(accessory, SemanticInternalAttributes.STYLE_ACCESSORY);
|
|
4030
|
-
}
|
|
4031
|
-
__name(accessoryAttributes, "accessoryAttributes");
|
|
4032
|
-
|
|
4033
4192
|
// src/v3/utils/detectDependencyVersion.ts
|
|
4034
4193
|
function detectDependencyVersion(dependency) {
|
|
4035
4194
|
return dependencies[dependency];
|
|
@@ -4305,6 +4464,7 @@ function safeJsonParse2(value) {
|
|
|
4305
4464
|
}
|
|
4306
4465
|
__name(safeJsonParse2, "safeJsonParse");
|
|
4307
4466
|
|
|
4467
|
+
exports.AbortTaskRunError = AbortTaskRunError;
|
|
4308
4468
|
exports.ApiClient = ApiClient;
|
|
4309
4469
|
exports.ApiConnectionError = ApiConnectionError;
|
|
4310
4470
|
exports.ApiError = ApiError;
|
|
@@ -4487,7 +4647,9 @@ exports.groupTaskMetadataIssuesByTask = groupTaskMetadataIssuesByTask;
|
|
|
4487
4647
|
exports.imposeAttributeLimits = imposeAttributeLimits;
|
|
4488
4648
|
exports.isCancellationSpanEvent = isCancellationSpanEvent;
|
|
4489
4649
|
exports.isExceptionSpanEvent = isExceptionSpanEvent;
|
|
4650
|
+
exports.isRequestOptions = isRequestOptions;
|
|
4490
4651
|
exports.logger = logger;
|
|
4652
|
+
exports.mergeRequestOptions = mergeRequestOptions;
|
|
4491
4653
|
exports.millisecondsToNanoseconds = millisecondsToNanoseconds;
|
|
4492
4654
|
exports.nanosecondsToMilliseconds = nanosecondsToMilliseconds;
|
|
4493
4655
|
exports.omit = omit;
|
|
@@ -4497,6 +4659,7 @@ exports.parsePacket = parsePacket;
|
|
|
4497
4659
|
exports.prettyPrintPacket = prettyPrintPacket;
|
|
4498
4660
|
exports.primitiveValueOrflattenedAttributes = primitiveValueOrflattenedAttributes;
|
|
4499
4661
|
exports.runtime = runtime;
|
|
4662
|
+
exports.sanitizeError = sanitizeError;
|
|
4500
4663
|
exports.serverWebsocketMessages = serverWebsocketMessages;
|
|
4501
4664
|
exports.stringPatternMatchers = stringPatternMatchers;
|
|
4502
4665
|
exports.stringifyIO = stringifyIO;
|