@bedrock-rbx/ocale 0.3.1 → 0.3.2
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/README.md +13 -1
- package/dist/badges.d.mts +1 -1
- package/dist/badges.mjs +3 -3
- package/dist/{polling-0t1wQyVY.d.mts → capacity-admission-BvnJjY0S.d.mts} +35 -3
- package/dist/capacity-admission-BvnJjY0S.d.mts.map +1 -0
- package/dist/developer-products.d.mts +1 -1
- package/dist/developer-products.mjs +4 -4
- package/dist/game-passes.d.mts +1 -1
- package/dist/game-passes.mjs +4 -4
- package/dist/index.d.mts +112 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/luau-execution.d.mts +39 -5
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +8 -13
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{network-error-DmNy_j-u.mjs → network-error-DR9FX5hb.mjs} +32 -7
- package/dist/network-error-DR9FX5hb.mjs.map +1 -0
- package/dist/places.d.mts +4 -4
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +8 -13
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-wrPTnGl_.mjs → poll-timeout-3PXLsabj.mjs} +2 -2
- package/dist/{poll-timeout-wrPTnGl_.mjs.map → poll-timeout-3PXLsabj.mjs.map} +1 -1
- package/dist/{polling-helpers-CzdT2FS5.mjs → polling-helpers-CFuSt2O5.mjs} +323 -21
- package/dist/polling-helpers-CFuSt2O5.mjs.map +1 -0
- package/dist/{price-information-Czs5cWR1.mjs → price-information-D8BxwgTS.mjs} +2 -2
- package/dist/{price-information-Czs5cWR1.mjs.map → price-information-D8BxwgTS.mjs.map} +1 -1
- package/dist/{resource-client-aqk_V4TD.mjs → resource-client--yYybltk.mjs} +254 -72
- package/dist/resource-client--yYybltk.mjs.map +1 -0
- package/dist/resource-client-BivRq3JZ.d.mts +164 -0
- package/dist/resource-client-BivRq3JZ.d.mts.map +1 -0
- package/dist/{retry-DIK_T_oF.mjs → retry-Cc4LcXYZ.mjs} +266 -132
- package/dist/retry-Cc4LcXYZ.mjs.map +1 -0
- package/dist/{retry-Cj5OXCdL.d.mts → retry-DXEklFrt.d.mts} +51 -16
- package/dist/{retry-Cj5OXCdL.d.mts.map → retry-DXEklFrt.d.mts.map} +1 -1
- package/dist/storage.d.mts +2 -158
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +3 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/{types-D_njb3qW.d.mts → types-C3Egi37J.d.mts} +14 -8
- package/dist/types-C3Egi37J.d.mts.map +1 -0
- package/dist/universes.d.mts +1 -1
- package/dist/universes.mjs +4 -4
- package/dist/{validation-BwjwOJPD.mjs → validation-B_Zs1So2.mjs} +2 -2
- package/dist/{validation-BwjwOJPD.mjs.map → validation-B_Zs1So2.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/network-error-DmNy_j-u.mjs.map +0 -1
- package/dist/polling-0t1wQyVY.d.mts.map +0 -1
- package/dist/polling-helpers-CzdT2FS5.mjs.map +0 -1
- package/dist/resource-client-aqk_V4TD.mjs.map +0 -1
- package/dist/retry-DIK_T_oF.mjs.map +0 -1
- package/dist/types-D_njb3qW.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ApiError, i as markServerRetryGuidance, n as RateLimitError, r as hasServerRetryGuidance, s as OpenCloudError, t as NetworkError } from "./network-error-
|
|
1
|
+
import { a as ApiError, i as markServerRetryGuidance, n as RateLimitError, r as hasServerRetryGuidance, s as OpenCloudError, t as NetworkError } from "./network-error-DR9FX5hb.mjs";
|
|
2
2
|
//#region src/internal/utils/try-catch.ts
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a promise into a {@link Result}, catching rejections.
|
|
@@ -31,6 +31,15 @@ const DIAGNOSTIC_HEADER_ALLOWLIST = new Set([
|
|
|
31
31
|
"x-request-id"
|
|
32
32
|
]);
|
|
33
33
|
const DIAGNOSTIC_HEADER_PREFIX = "x-roblox-";
|
|
34
|
+
const RATE_LIMIT_HEADER_ALLOWLIST = new Set([
|
|
35
|
+
"date",
|
|
36
|
+
"retry-after",
|
|
37
|
+
"x-envoy-ratelimited",
|
|
38
|
+
"x-ratelimit-limit",
|
|
39
|
+
"x-ratelimit-remaining",
|
|
40
|
+
"x-ratelimit-reset",
|
|
41
|
+
"x-retry-after-coverage"
|
|
42
|
+
]);
|
|
34
43
|
const TITLE_OPEN_PATTERN = /<title[^>]*>/i;
|
|
35
44
|
const H1_OPEN_PATTERN = /<h1[^>]*>/i;
|
|
36
45
|
const TAG_PATTERN = /<[^<>]*>/g;
|
|
@@ -69,9 +78,18 @@ function extractGatewaySummary(contentType, rawText) {
|
|
|
69
78
|
* @returns A record containing only the allowlisted headers that were present.
|
|
70
79
|
*/
|
|
71
80
|
function pickDiagnosticHeaders(headers) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
return pickHeaders(headers);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Filters a lowercased header record to the raw evidence useful for diagnosing
|
|
85
|
+
* a 429: the general diagnostic headers plus rate-limit guidance and counters.
|
|
86
|
+
* Values are copied without parsing so comma-joined windows remain available.
|
|
87
|
+
*
|
|
88
|
+
* @param headers - The full header record (lowercased keys).
|
|
89
|
+
* @returns Only allowlisted diagnostic and rate-limit headers.
|
|
90
|
+
*/
|
|
91
|
+
function pickRateLimitHeaders(headers) {
|
|
92
|
+
return pickHeaders(headers, RATE_LIMIT_HEADER_ALLOWLIST);
|
|
75
93
|
}
|
|
76
94
|
/**
|
|
77
95
|
* Converts a `Headers` object to a plain record with lowercased keys.
|
|
@@ -135,6 +153,11 @@ function isHtmlBody(contentType, rawText) {
|
|
|
135
153
|
const head = rawText.trimStart().toLowerCase();
|
|
136
154
|
return head.startsWith("<html") || head.startsWith("<!doctype html");
|
|
137
155
|
}
|
|
156
|
+
function pickHeaders(headers, additionalAllowlist) {
|
|
157
|
+
const picked = {};
|
|
158
|
+
for (const [name, value] of Object.entries(headers)) if (DIAGNOSTIC_HEADER_ALLOWLIST.has(name) || name.startsWith(DIAGNOSTIC_HEADER_PREFIX) || additionalAllowlist?.has(name) === true) picked[name] = value;
|
|
159
|
+
return picked;
|
|
160
|
+
}
|
|
138
161
|
//#endregion
|
|
139
162
|
//#region src/internal/http/http1-dispatcher.ts
|
|
140
163
|
/**
|
|
@@ -258,112 +281,6 @@ function parseRateLimitHeaders(headers) {
|
|
|
258
281
|
};
|
|
259
282
|
}
|
|
260
283
|
//#endregion
|
|
261
|
-
//#region src/errors/request-aborted.ts
|
|
262
|
-
/**
|
|
263
|
-
* Returned when a caller's `AbortSignal` cancels an Open Cloud request.
|
|
264
|
-
* The reason is preserved so intentional cancellation can be distinguished
|
|
265
|
-
* from transport failures and SDK-owned request timeouts.
|
|
266
|
-
*
|
|
267
|
-
* @since 0.3.1
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
*
|
|
271
|
-
* ```ts
|
|
272
|
-
* import { RequestAbortedError } from "@bedrock-rbx/ocale";
|
|
273
|
-
*
|
|
274
|
-
* const error = new RequestAbortedError("Request was aborted", {
|
|
275
|
-
* reason: "superseded",
|
|
276
|
-
* });
|
|
277
|
-
*
|
|
278
|
-
* expect(error).toBeInstanceOf(RequestAbortedError);
|
|
279
|
-
* expect(error.reason).toBe("superseded");
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
var RequestAbortedError = class extends OpenCloudError {
|
|
283
|
-
name = "RequestAbortedError";
|
|
284
|
-
reason;
|
|
285
|
-
/**
|
|
286
|
-
* Creates a new RequestAbortedError.
|
|
287
|
-
*
|
|
288
|
-
* @param message - Human-readable description of the cancellation.
|
|
289
|
-
* @param options - Error options including the caller's abort reason.
|
|
290
|
-
*/
|
|
291
|
-
constructor(message, options = {}) {
|
|
292
|
-
super(message, options);
|
|
293
|
-
this.reason = options.reason;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/internal/utils/abort.ts
|
|
298
|
-
/**
|
|
299
|
-
* Sentinel returned when an asynchronous operation loses a race with a signal.
|
|
300
|
-
*/
|
|
301
|
-
const ABORTED = Symbol("aborted");
|
|
302
|
-
/**
|
|
303
|
-
* Runs an asynchronous operation and resolves with {@link ABORTED} when the
|
|
304
|
-
* supplied signal fires first. The underlying operation still receives the
|
|
305
|
-
* signal separately so cancellable implementations can release their work.
|
|
306
|
-
*
|
|
307
|
-
* @template T - Value produced by the operation.
|
|
308
|
-
* @param operation - Operation to start after the abort observer is installed.
|
|
309
|
-
* @param signal - Optional caller cancellation signal.
|
|
310
|
-
* @returns The operation's value, or {@link ABORTED} when cancellation wins.
|
|
311
|
-
* @rejects The operation's error when it fails before cancellation.
|
|
312
|
-
*/
|
|
313
|
-
async function raceWithAbortAsync(operation, signal) {
|
|
314
|
-
if (signal === void 0) return operation();
|
|
315
|
-
if (signal.aborted) return ABORTED;
|
|
316
|
-
const { promise, resolve } = Promise.withResolvers();
|
|
317
|
-
function onAbort() {
|
|
318
|
-
resolve(ABORTED);
|
|
319
|
-
}
|
|
320
|
-
signal.addEventListener("abort", onAbort);
|
|
321
|
-
try {
|
|
322
|
-
return await Promise.race([operation(), promise]);
|
|
323
|
-
} finally {
|
|
324
|
-
signal.removeEventListener("abort", onAbort);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Creates the canonical typed failure for caller-request cancellation.
|
|
329
|
-
*
|
|
330
|
-
* @param signal - The caller signal whose reason should be preserved.
|
|
331
|
-
* @returns A cancellation error carrying the signal's reason.
|
|
332
|
-
*/
|
|
333
|
-
function requestAbortedError(signal) {
|
|
334
|
-
return new RequestAbortedError("Request was aborted", { reason: signal?.reason });
|
|
335
|
-
}
|
|
336
|
-
//#endregion
|
|
337
|
-
//#region src/internal/http/request-signal.ts
|
|
338
|
-
/**
|
|
339
|
-
* Composes caller cancellation with Ocale's request deadline. The winning
|
|
340
|
-
* signal's reason is retained by `AbortSignal.any`, allowing failure
|
|
341
|
-
* classification to distinguish cancellation from timeout.
|
|
342
|
-
*
|
|
343
|
-
* @param config - Transport configuration for one request.
|
|
344
|
-
* @returns A caller signal, timeout signal, their composition, or `undefined`.
|
|
345
|
-
*/
|
|
346
|
-
function requestSignal(config) {
|
|
347
|
-
if (config.timeout === void 0) return config.signal;
|
|
348
|
-
const timeout = AbortSignal.timeout(config.timeout);
|
|
349
|
-
return config.signal === void 0 ? timeout : AbortSignal.any([config.signal, timeout]);
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Classifies a fetch rejection without confusing a caller abort with the
|
|
353
|
-
* transport's own timeout.
|
|
354
|
-
*
|
|
355
|
-
* @param args - Failure, target, request config, and effective fetch signal.
|
|
356
|
-
* @returns A typed caller cancellation or network failure.
|
|
357
|
-
*/
|
|
358
|
-
function requestFailure({ cause, config, effectiveSignal, target }) {
|
|
359
|
-
if (config.signal?.aborted === true && effectiveSignal?.aborted === true && Object.is(effectiveSignal.reason, config.signal.reason)) return requestAbortedError(config.signal);
|
|
360
|
-
return new NetworkError("Network request failed", {
|
|
361
|
-
cause,
|
|
362
|
-
method: target.method,
|
|
363
|
-
url: target.url
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
//#endregion
|
|
367
284
|
//#region src/internal/http/retry-guidance.ts
|
|
368
285
|
const ABBREVIATED_WEEKDAYS = [
|
|
369
286
|
"Sun",
|
|
@@ -494,6 +411,146 @@ function parseHttpDate(value, nowMs) {
|
|
|
494
411
|
return parseFixedDate(value) ?? parseObsoleteDate(value, nowMs) ?? parseAnsiDate(value);
|
|
495
412
|
}
|
|
496
413
|
//#endregion
|
|
414
|
+
//#region src/internal/http/rate-limit-response.ts
|
|
415
|
+
/**
|
|
416
|
+
* Builds a public rate-limit error from a 429 response and its already-read
|
|
417
|
+
* body, retaining safe raw evidence alongside the existing parsed guidance.
|
|
418
|
+
*
|
|
419
|
+
* @param response - The 429 response to classify.
|
|
420
|
+
* @param details - The parsed or safely truncated response body.
|
|
421
|
+
* @returns A rate-limit error carrying the response evidence.
|
|
422
|
+
*/
|
|
423
|
+
function createRateLimitError(response, details) {
|
|
424
|
+
const headers = headersToRecord(response.headers);
|
|
425
|
+
const remaining = reduceRateLimitTokens(headers["x-ratelimit-remaining"], (a, b) => {
|
|
426
|
+
return Math.min(a, b);
|
|
427
|
+
});
|
|
428
|
+
const guidedRetrySeconds = resolveRetryGuidance({
|
|
429
|
+
headers,
|
|
430
|
+
remaining
|
|
431
|
+
});
|
|
432
|
+
const error = new RateLimitError("Rate limited", {
|
|
433
|
+
code: extractRateLimitErrorCode(details),
|
|
434
|
+
details,
|
|
435
|
+
remaining,
|
|
436
|
+
responseHeaders: pickRateLimitHeaders(headers),
|
|
437
|
+
retryAfterSeconds: guidedRetrySeconds ?? 0,
|
|
438
|
+
statusCode: response.status
|
|
439
|
+
});
|
|
440
|
+
return guidedRetrySeconds === void 0 ? error : markServerRetryGuidance(error);
|
|
441
|
+
}
|
|
442
|
+
function extractRateLimitErrorCode(body) {
|
|
443
|
+
if (body === null || typeof body !== "object") return;
|
|
444
|
+
const code = Reflect.get(body, "code");
|
|
445
|
+
return typeof code === "string" && code.trim() ? code : void 0;
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/errors/request-aborted.ts
|
|
449
|
+
/**
|
|
450
|
+
* Returned when a caller's `AbortSignal` cancels an Open Cloud request.
|
|
451
|
+
* The reason is preserved so intentional cancellation can be distinguished
|
|
452
|
+
* from transport failures and SDK-owned request timeouts.
|
|
453
|
+
*
|
|
454
|
+
* @since 0.3.1
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
*
|
|
458
|
+
* ```ts
|
|
459
|
+
* import { RequestAbortedError } from "@bedrock-rbx/ocale";
|
|
460
|
+
*
|
|
461
|
+
* const error = new RequestAbortedError("Request was aborted", {
|
|
462
|
+
* reason: "superseded",
|
|
463
|
+
* });
|
|
464
|
+
*
|
|
465
|
+
* expect(error).toBeInstanceOf(RequestAbortedError);
|
|
466
|
+
* expect(error.reason).toBe("superseded");
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
var RequestAbortedError = class extends OpenCloudError {
|
|
470
|
+
name = "RequestAbortedError";
|
|
471
|
+
reason;
|
|
472
|
+
/**
|
|
473
|
+
* Creates a new RequestAbortedError.
|
|
474
|
+
*
|
|
475
|
+
* @param message - Human-readable description of the cancellation.
|
|
476
|
+
* @param options - Error options including the caller's abort reason.
|
|
477
|
+
*/
|
|
478
|
+
constructor(message, options = {}) {
|
|
479
|
+
super(message, options);
|
|
480
|
+
this.reason = options.reason;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/internal/utils/abort.ts
|
|
485
|
+
/**
|
|
486
|
+
* Sentinel returned when an asynchronous operation loses a race with a signal.
|
|
487
|
+
*/
|
|
488
|
+
const ABORTED = Symbol("aborted");
|
|
489
|
+
/**
|
|
490
|
+
* Runs an asynchronous operation and resolves with {@link ABORTED} when the
|
|
491
|
+
* supplied signal fires first. The underlying operation still receives the
|
|
492
|
+
* signal separately so cancellable implementations can release their work.
|
|
493
|
+
*
|
|
494
|
+
* @template T - Value produced by the operation.
|
|
495
|
+
* @param operation - Operation to start after the abort observer is installed.
|
|
496
|
+
* @param signal - Optional caller cancellation signal.
|
|
497
|
+
* @returns The operation's value, or {@link ABORTED} when cancellation wins.
|
|
498
|
+
* @rejects The operation's error when it fails before cancellation.
|
|
499
|
+
*/
|
|
500
|
+
async function raceWithAbortAsync(operation, signal) {
|
|
501
|
+
if (signal === void 0) return operation();
|
|
502
|
+
if (signal.aborted) return ABORTED;
|
|
503
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
504
|
+
function onAbort() {
|
|
505
|
+
resolve(ABORTED);
|
|
506
|
+
}
|
|
507
|
+
signal.addEventListener("abort", onAbort);
|
|
508
|
+
try {
|
|
509
|
+
return await Promise.race([operation(), promise]);
|
|
510
|
+
} finally {
|
|
511
|
+
signal.removeEventListener("abort", onAbort);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Creates the canonical typed failure for caller-request cancellation.
|
|
516
|
+
*
|
|
517
|
+
* @param signal - The caller signal whose reason should be preserved.
|
|
518
|
+
* @returns A cancellation error carrying the signal's reason.
|
|
519
|
+
*/
|
|
520
|
+
function requestAbortedError(signal) {
|
|
521
|
+
return new RequestAbortedError("Request was aborted", { reason: signal?.reason });
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/internal/http/request-signal.ts
|
|
525
|
+
/**
|
|
526
|
+
* Composes caller cancellation with Ocale's transport-attempt timeout. The
|
|
527
|
+
* winning signal's reason is retained by `AbortSignal.any`, allowing failure
|
|
528
|
+
* classification to distinguish cancellation from timeout.
|
|
529
|
+
*
|
|
530
|
+
* @param config - Transport configuration for one request.
|
|
531
|
+
* @returns A caller signal, timeout signal, their composition, or `undefined`.
|
|
532
|
+
*/
|
|
533
|
+
function requestSignal(config) {
|
|
534
|
+
if (config.timeout === void 0) return config.signal;
|
|
535
|
+
const timeout = AbortSignal.timeout(config.timeout);
|
|
536
|
+
return config.signal === void 0 ? timeout : AbortSignal.any([config.signal, timeout]);
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Classifies a fetch rejection without confusing a caller abort with the
|
|
540
|
+
* transport's own timeout.
|
|
541
|
+
*
|
|
542
|
+
* @param args - Failure, target, request config, and effective fetch signal.
|
|
543
|
+
* @returns A typed caller cancellation or network failure.
|
|
544
|
+
*/
|
|
545
|
+
function requestFailure({ cause, config, effectiveSignal, target }) {
|
|
546
|
+
if (config.signal?.aborted === true && effectiveSignal?.aborted === true && Object.is(effectiveSignal.reason, config.signal.reason)) return requestAbortedError(config.signal);
|
|
547
|
+
return new NetworkError("Network request failed", {
|
|
548
|
+
cause,
|
|
549
|
+
method: target.method,
|
|
550
|
+
url: target.url
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
497
554
|
//#region src/internal/http/upload-request.ts
|
|
498
555
|
/**
|
|
499
556
|
* Reports whether a request is an upload: its body is `FormData`
|
|
@@ -744,24 +801,6 @@ async function readResponseBodyAsync(response) {
|
|
|
744
801
|
text
|
|
745
802
|
};
|
|
746
803
|
}
|
|
747
|
-
async function createRateLimitErrorAsync(response) {
|
|
748
|
-
const headers = headersToRecord(response.headers);
|
|
749
|
-
const { parsed, text } = await readResponseBodyAsync(response);
|
|
750
|
-
const remaining = reduceRateLimitTokens(headers["x-ratelimit-remaining"], (a, b) => {
|
|
751
|
-
return Math.min(a, b);
|
|
752
|
-
});
|
|
753
|
-
const guidedRetrySeconds = resolveRetryGuidance({
|
|
754
|
-
headers,
|
|
755
|
-
remaining
|
|
756
|
-
});
|
|
757
|
-
const error = new RateLimitError("Rate limited", {
|
|
758
|
-
details: bodyDetail(text, parsed),
|
|
759
|
-
remaining,
|
|
760
|
-
retryAfterSeconds: guidedRetrySeconds ?? 0,
|
|
761
|
-
statusCode: response.status
|
|
762
|
-
});
|
|
763
|
-
return guidedRetrySeconds === void 0 ? error : markServerRetryGuidance(error);
|
|
764
|
-
}
|
|
765
804
|
/**
|
|
766
805
|
* Classifies a fetch `Response` into a typed `Result`.
|
|
767
806
|
*
|
|
@@ -778,11 +817,11 @@ async function createRateLimitErrorAsync(response) {
|
|
|
778
817
|
* @returns A Result containing an HttpResponse on success or an OpenCloudError on failure.
|
|
779
818
|
*/
|
|
780
819
|
async function classifyResponseAsync(response, context) {
|
|
820
|
+
const { parsed, text } = await readResponseBodyAsync(response);
|
|
781
821
|
if (response.status === 429) return {
|
|
782
|
-
err:
|
|
822
|
+
err: createRateLimitError(response, bodyDetail(text, parsed)),
|
|
783
823
|
success: false
|
|
784
824
|
};
|
|
785
|
-
const { parsed, text } = await readResponseBodyAsync(response);
|
|
786
825
|
if (response.status >= 300) return {
|
|
787
826
|
err: createApiError({
|
|
788
827
|
context,
|
|
@@ -911,6 +950,101 @@ var PermissionError = class extends ApiError {
|
|
|
911
950
|
}
|
|
912
951
|
};
|
|
913
952
|
//#endregion
|
|
953
|
+
//#region src/errors/request-deadline-exceeded.ts
|
|
954
|
+
/**
|
|
955
|
+
* Returned when a logical request cannot complete by its absolute deadline.
|
|
956
|
+
* Optional wait details identify an SDK-managed admission wait that was
|
|
957
|
+
* refused. This is distinct from caller cancellation so consumers can report
|
|
958
|
+
* exhausted wall-clock budget accurately.
|
|
959
|
+
*
|
|
960
|
+
* @since 0.3.2
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
*
|
|
964
|
+
* ```ts
|
|
965
|
+
* import { RequestDeadlineExceededError } from "@bedrock-rbx/ocale";
|
|
966
|
+
*
|
|
967
|
+
* const error = new RequestDeadlineExceededError("Request deadline elapsed", {
|
|
968
|
+
* deadlineMs: 1_000_000,
|
|
969
|
+
* remainingMs: 0,
|
|
970
|
+
* waitReason: "operation-queue",
|
|
971
|
+
* });
|
|
972
|
+
*
|
|
973
|
+
* expect(error.remainingMs).toBe(0);
|
|
974
|
+
* expect(error.waitReason).toBe("operation-queue");
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
var RequestDeadlineExceededError = class extends OpenCloudError {
|
|
978
|
+
/** Absolute caller-supplied deadline, as Unix epoch milliseconds. */
|
|
979
|
+
deadlineMs;
|
|
980
|
+
name = "RequestDeadlineExceededError";
|
|
981
|
+
/** Time left when the SDK refused or ended the wait. */
|
|
982
|
+
remainingMs;
|
|
983
|
+
/** Intended wait duration, when known. */
|
|
984
|
+
waitMs;
|
|
985
|
+
/** SDK admission mechanism whose wait could not meet the deadline. */
|
|
986
|
+
waitReason;
|
|
987
|
+
/**
|
|
988
|
+
* Creates a new RequestDeadlineExceededError.
|
|
989
|
+
*
|
|
990
|
+
* @param message - Human-readable description of the exhausted deadline.
|
|
991
|
+
* @param options - Deadline, remaining budget, and optional wait details.
|
|
992
|
+
*/
|
|
993
|
+
constructor(message, options) {
|
|
994
|
+
super(message, options);
|
|
995
|
+
this.deadlineMs = options.deadlineMs;
|
|
996
|
+
this.remainingMs = options.remainingMs;
|
|
997
|
+
this.waitMs = options.waitMs;
|
|
998
|
+
this.waitReason = options.waitReason;
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region src/errors/retry-delay-exceeded.ts
|
|
1003
|
+
/**
|
|
1004
|
+
* Returned when the SDK refuses a retry delay that cannot complete before the
|
|
1005
|
+
* request deadline. This is distinct from cancellation so consumers can
|
|
1006
|
+
* report the server's stated retry time without waiting for it.
|
|
1007
|
+
*
|
|
1008
|
+
* @since 0.3.2
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
*
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* import { RetryDelayExceededError } from "@bedrock-rbx/ocale";
|
|
1014
|
+
*
|
|
1015
|
+
* const error = new RetryDelayExceededError("Retry delay exceeds the request deadline", {
|
|
1016
|
+
* deadlineMs: 1_000_000,
|
|
1017
|
+
* remainingMs: 495_000,
|
|
1018
|
+
* retryAfterMs: 1_856_000,
|
|
1019
|
+
* });
|
|
1020
|
+
*
|
|
1021
|
+
* expect(error.retryAfterMs).toBe(1_856_000);
|
|
1022
|
+
* expect(error.remainingMs).toBe(495_000);
|
|
1023
|
+
* ```
|
|
1024
|
+
*/
|
|
1025
|
+
var RetryDelayExceededError = class extends RequestDeadlineExceededError {
|
|
1026
|
+
name = "RetryDelayExceededError";
|
|
1027
|
+
/** Computed retry delay refused by the SDK, in milliseconds. */
|
|
1028
|
+
retryAfterMs;
|
|
1029
|
+
/** Computed retry delay refused by the SDK, in seconds. */
|
|
1030
|
+
retryAfterSeconds;
|
|
1031
|
+
/**
|
|
1032
|
+
* Creates a new RetryDelayExceededError.
|
|
1033
|
+
*
|
|
1034
|
+
* @param message - Human-readable description of the refused retry delay.
|
|
1035
|
+
* @param options - Refused delay, deadline budget, and original failure.
|
|
1036
|
+
*/
|
|
1037
|
+
constructor(message, options) {
|
|
1038
|
+
super(message, {
|
|
1039
|
+
...options,
|
|
1040
|
+
waitMs: options.retryAfterMs,
|
|
1041
|
+
waitReason: "retry-delay"
|
|
1042
|
+
});
|
|
1043
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
1044
|
+
this.retryAfterSeconds = options.retryAfterMs / 1e3;
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
//#endregion
|
|
914
1048
|
//#region src/internal/utils/find-error-code.ts
|
|
915
1049
|
/**
|
|
916
1050
|
* Maximum cause-chain depth walked by {@link findErrorCode}. Caps pathological
|
|
@@ -1317,6 +1451,6 @@ function mergeConfig(clientConfig, { methodDefaults, methodKind, requestOptions
|
|
|
1317
1451
|
}
|
|
1318
1452
|
}
|
|
1319
1453
|
//#endregion
|
|
1320
|
-
export {
|
|
1454
|
+
export { ABORTED as _, TRANSIENT_TRANSPORT_CODES as a, RequestAbortedError as b, defaultRetryDelay as c, findErrorCode as d, RetryDelayExceededError as f, isUploadRequest as g, createFetchHttpClient as h, RESPONSE_UNPARSEABLE as i, mergeConfig as l, PermissionError as m, GATEWAY_REJECTED as n, UPLOAD_METHOD_DEFAULTS as o, RequestDeadlineExceededError as p, IDEMPOTENT_METHOD_DEFAULTS as r, computeRetryWaitMs as s, CREATE_METHOD_DEFAULTS as t, shouldRetry as u, raceWithAbortAsync as v, parseRateLimitHeaders as x, requestAbortedError as y };
|
|
1321
1455
|
|
|
1322
|
-
//# sourceMappingURL=retry-
|
|
1456
|
+
//# sourceMappingURL=retry-Cc4LcXYZ.mjs.map
|