@bedrock-rbx/ocale 0.3.4-beta.1 → 0.3.4
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/badges.d.mts +1 -1
- package/dist/badges.mjs +2 -2
- package/dist/{capacity-admission-BvnJjY0S.d.mts → capacity-admission-IDO3fcUC.d.mts} +2 -2
- package/dist/{capacity-admission-BvnJjY0S.d.mts.map → capacity-admission-IDO3fcUC.d.mts.map} +1 -1
- package/dist/developer-products.d.mts +1 -1
- package/dist/developer-products.mjs +3 -3
- package/dist/game-passes.d.mts +1 -1
- package/dist/game-passes.mjs +3 -3
- package/dist/index.d.mts +59 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/luau-execution.d.mts +2 -2
- package/dist/luau-execution.mjs +3 -3
- package/dist/places.d.mts +2 -2
- package/dist/places.mjs +3 -3
- package/dist/{polling-helpers-sKTsqEc1.mjs → polling-helpers-CoVhsC33.mjs} +3 -3
- package/dist/{polling-helpers-sKTsqEc1.mjs.map → polling-helpers-CoVhsC33.mjs.map} +1 -1
- package/dist/{price-information-hWXV6DAI.mjs → price-information-B0tkOoAX.mjs} +2 -2
- package/dist/{price-information-hWXV6DAI.mjs.map → price-information-B0tkOoAX.mjs.map} +1 -1
- package/dist/{resource-client-BivRq3JZ.d.mts → resource-client-B6NeFXUv.d.mts} +3 -3
- package/dist/{resource-client-BivRq3JZ.d.mts.map → resource-client-B6NeFXUv.d.mts.map} +1 -1
- package/dist/{resource-client-3cOhqZpX.mjs → resource-client-rqTMkBeR.mjs} +144 -52
- package/dist/resource-client-rqTMkBeR.mjs.map +1 -0
- package/dist/{retry-vpHMIwaU.mjs → retry-BlX4tUnT.mjs} +114 -4
- package/dist/retry-BlX4tUnT.mjs.map +1 -0
- package/dist/{retry-DXEklFrt.d.mts → retry-war_-9tb.d.mts} +2 -2
- package/dist/{retry-DXEklFrt.d.mts.map → retry-war_-9tb.d.mts.map} +1 -1
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/{types-C3Egi37J.d.mts → types-CvYh4SPC.d.mts} +11 -3
- package/dist/{types-C3Egi37J.d.mts.map → types-CvYh4SPC.d.mts.map} +1 -1
- package/dist/universes.d.mts +2 -2
- package/dist/universes.mjs +2 -2
- package/package.json +1 -1
- package/dist/resource-client-3cOhqZpX.mjs.map +0 -1
- package/dist/retry-vpHMIwaU.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-client-3cOhqZpX.mjs","names":["#window","#lastAllowedAt","#chains","#pendingGates","#sleep","#trackers","ignoreRejection","#gateOnce","#tracker","#waitAsync","#hooks","#intervalMs","#maxBucketLevel","#sleep","#pendingAcquisitions","#waitForToken","#chain","#waitAsync","#bucketLevel","#lastCheck","#budgets","#config","#hooks","#httpClient","#queues","#sleep","#dispatchAsync","#getQueue","#gatedSend"],"sources":["../src/internal/utils/is-date-time-string.ts","../src/internal/utils/is-record.ts","../src/internal/utils/to-json-details.ts","../src/internal/http/admission-wait.ts","../src/internal/http/budget-tracker.ts","../src/internal/http/request-deadline.ts","../src/internal/http/budget-gate.ts","../src/internal/http/execute.ts","../src/internal/http/rate-limit-observation.ts","../src/internal/http/rate-limit-queue.ts","../src/internal/utils/sleep.ts","../src/internal/http/resolve-dependencies.ts","../src/internal/resource-client.ts"],"sourcesContent":["/**\n * Narrows `value` to a string that parses to a real {@link Date} via the\n * `Date(string)` constructor. Used by resource parsers to gate\n * `format: date-time` wire fields before handing them to `new Date(...)`,\n * which silently produces an `Invalid Date` for invalid input.\n *\n * @param value - The unknown wire value to validate.\n * @returns `true` when `value` is a string and `new Date(value).getTime()`\n * is not `NaN`.\n */\nexport function isDateTimeString(value: unknown): value is string {\n\tif (typeof value !== \"string\") {\n\t\treturn false;\n\t}\n\n\tconst parsed = new Date(value);\n\treturn !Number.isNaN(parsed.getTime());\n}\n","/**\n * Narrows `value` to a plain JSON-style record. Excludes arrays, class\n * instances, primitives, and `null`/`undefined`. Used by resource\n * parsers to gate property access on wire bodies whose shape isn't\n * known at compile time.\n *\n * @param value - The unknown value to narrow.\n * @returns `true` when `value` is a plain `[object Object]`.\n */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n}\n","import { isRecord } from \"./is-record.ts\";\n\n/**\n * Narrows an untyped response body to the `JSONValue` accepted by\n * `ApiError.details`. `HttpResponse.body` is `unknown` because a transport may\n * hand back anything, but only a JSON graph is safe to retain on an error for\n * diagnostics. Anything else — functions, symbols, bigints, class instances,\n * or a cyclic graph — is dropped rather than asserted through.\n *\n * @param value - The parsed response body, or `undefined` for an empty body.\n * @returns The value as a `JSONValue`, or `undefined` when it is absent or not\n * JSON-representable.\n */\nexport function toJsonDetails(value: unknown): JSONValue | undefined {\n\treturn asJsonValue(value, new Set());\n}\n\nfunction asJsonValue(value: unknown, seen: Set<object>): JSONValue | undefined {\n\tif (value === null) {\n\t\t// eslint-disable-next-line unicorn/no-null -- JSON null is a JSONValue; the repo's undefined-only rule stops at this wire boundary\n\t\treturn null;\n\t}\n\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n\t\treturn value;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn asJsonArray(value, seen);\n\t}\n\n\tif (isRecord(value)) {\n\t\treturn asJsonObject(value, seen);\n\t}\n\n\treturn undefined;\n}\n\nfunction asJsonArray(value: ReadonlyArray<unknown>, seen: Set<object>): JSONValue | undefined {\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\tconst items: Array<JSONValue> = [];\n\tfor (const item of value) {\n\t\tconst converted = asJsonValue(item, seen);\n\t\tif (converted === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\titems.push(converted);\n\t}\n\n\tseen.delete(value);\n\treturn items;\n}\n\nfunction asJsonObject(value: Record<string, unknown>, seen: Set<object>): JSONValue | undefined {\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\tconst entries: Array<[string, JSONValue]> = [];\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tconst converted = asJsonValue(item, seen);\n\t\tif (converted === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tentries.push([key, converted]);\n\t}\n\n\tseen.delete(value);\n\treturn Object.fromEntries(entries);\n}\n","import type {\n\tAdmissionWaitEvent,\n\tAdmissionWaitObserver,\n\tAdmissionWaitReason,\n} from \"../../client/types.ts\";\n\n/** Request-local controls shared by SDK admission mechanisms. */\nexport interface AdmissionWaitContext {\n\t/**\n\t * Absolute deadline for the logical request, as Unix epoch milliseconds.\n\t */\n\treadonly deadlineMs?: number | undefined;\n\t/** Observer for this request's admission waits. */\n\treadonly observer?: AdmissionWaitObserver | undefined;\n\t/** Optional caller cancellation signal. */\n\treadonly signal?: AbortSignal | undefined;\n}\n\ninterface ObserveAdmissionWaitOptions<T> {\n\t/** Intended wait duration, when the scheduler can determine one. */\n\treadonly durationMs?: number;\n\t/** Request-scoped notification callback. */\n\treadonly observer?: AdmissionWaitObserver | undefined;\n\t/** SDK admission mechanism responsible for the wait. */\n\treadonly reason: AdmissionWaitReason;\n\t/** The actual wait to perform. */\n\treadonly waitAsync: () => Promise<T>;\n}\n\n/**\n * Performs one SDK-managed wait and emits a balanced request-scoped lifecycle.\n * Observer failures are deliberately ignored: observation cannot become part\n * of admission control.\n *\n * @template T - Value produced by the observed wait.\n * @param options - Wait metadata, observer, and the wait operation itself.\n * @returns The value produced by the wait.\n */\nexport async function observeAdmissionWaitAsync<T>({\n\tdurationMs,\n\tobserver,\n\treason,\n\twaitAsync,\n}: ObserveAdmissionWaitOptions<T>): Promise<T> {\n\tconst details = {\n\t\t...(durationMs === undefined ? {} : { durationMs }),\n\t\treason,\n\t};\n\tnotify(observer, { ...details, phase: \"started\" });\n\ttry {\n\t\treturn await waitAsync();\n\t} finally {\n\t\tnotify(observer, { ...details, phase: \"ended\" });\n\t}\n}\n\nfunction notify(observer: AdmissionWaitObserver | undefined, event: AdmissionWaitEvent): void {\n\ttry {\n\t\tconst notification = observer?.(event);\n\t\tif (notification !== undefined) {\n\t\t\t// `Boolean` consumes every rejection without throwing; the returned\n\t\t\t// promise and its boolean fulfillment are deliberately ignored.\n\t\t\tvoid Promise.resolve(notification).catch(Boolean);\n\t\t}\n\t} catch {\n\t\t// Admission observers are notification-only and cannot alter control\n\t\t// flow.\n\t}\n}\n","import type { RateLimitSample } from \"./rate-limit-sample.ts\";\n\nconst MS_PER_SECOND = 1000;\n\n/** Live window state for one scope: budget left and when it resets. */\ninterface WindowState {\n\t/** Best estimate of requests still allowed before the window resets. */\n\treadonly predictedRemaining: number;\n\t/** Absolute time (ms) the window resets to full. */\n\treadonly resetAt: number;\n}\n\n/**\n * Tracks the live rate-limit budget for a single scope. Primed by `observe`\n * from response headers and drawn down by `reserve` as requests leave, so\n * `waitMs` can pace requests across the window.\n *\n * Pacing has two regimes. While budget remains, requests are spread evenly over\n * the time left in the window (`timeLeft / remaining`), so a burst does not\n * spend the whole window's budget up front and then stall. Once the budget is\n * spent, requests hold until the window resets. Budget and reset time move\n * together as one window, so the tracker is either unprimed or fully primed,\n * never half-known.\n */\nexport class BudgetTracker {\n\t/** Time (ms) the most recent request was allowed out, for spacing. */\n\t#lastAllowedAt: number | undefined = undefined;\n\t#window: undefined | WindowState = undefined;\n\n\t/**\n\t * Folds a fresh server reading in, replacing any prior window. The latest\n\t * reading wins: observe time is monotonic, so the most recently resolved\n\t * response is the best current estimate. The spacing reference is left\n\t * untouched so a window refresh does not reset pacing mid-stream.\n\t *\n\t * @param sample - Parsed `remaining`/`resetSeconds` from a response.\n\t * @param now - The current time in ms.\n\t */\n\tpublic observe(sample: RateLimitSample, now: number): void {\n\t\tthis.#window = {\n\t\t\tpredictedRemaining: sample.remaining,\n\t\t\tresetAt: now + sample.resetSeconds * MS_PER_SECOND,\n\t\t};\n\t}\n\n\t/**\n\t * Accounts for one request leaving at `now`: records the spacing reference\n\t * and decrements the prediction. A no-op on the prediction while unprimed.\n\t *\n\t * @param now - The time the request was allowed out, in ms.\n\t */\n\tpublic reserve(now: number): void {\n\t\tthis.#lastAllowedAt = now;\n\t\tif (this.#window !== undefined) {\n\t\t\tthis.#window = {\n\t\t\t\t...this.#window,\n\t\t\t\tpredictedRemaining: this.#window.predictedRemaining - 1,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Milliseconds to wait before the next request is allowed.\n\t *\n\t * @param now - The current time in ms.\n\t * @returns `0` when a request may go now (unprimed, or the first paced send);\n\t * the time until reset when the budget is spent; otherwise the time until\n\t * this request's evenly-spaced slot.\n\t */\n\tpublic waitMs(now: number): number {\n\t\tif (this.#window === undefined) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst { predictedRemaining, resetAt } = this.#window;\n\t\tif (predictedRemaining <= 0) {\n\t\t\treturn Math.max(0, resetAt - now);\n\t\t}\n\n\t\tif (this.#lastAllowedAt === undefined) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst interval = (resetAt - now) / predictedRemaining;\n\t\treturn Math.max(0, this.#lastAllowedAt + interval - now);\n\t}\n}\n","import type { AdmissionWaitReason } from \"../../client/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { RequestAbortedError } from \"../../errors/request-aborted.ts\";\nimport {\n\tRequestDeadlineExceededError,\n\ttype RequestDeadlineExceededErrorOptions,\n} from \"../../errors/request-deadline-exceeded.ts\";\n\nconst DEADLINE_ELAPSED = Symbol(\"request deadline elapsed\");\nconst MAX_ABORT_TIMEOUT_MS = 2_147_483_647;\n\n/**\n * Request-lifecycle signals derived from caller cancellation and a deadline.\n */\nexport interface RequestLifecycle {\n\t/** Caller-supplied absolute deadline, as Unix epoch milliseconds. */\n\treadonly deadlineMs: number | undefined;\n\t/** Signal owned by the deadline, used to classify its expiry. */\n\treadonly deadlineSignal: AbortSignal | undefined;\n\t/** Caller and deadline signals composed for every stage of the request. */\n\treadonly signal: AbortSignal | undefined;\n}\n\ninterface WaitDeadlineInputs {\n\treadonly cause?: Error | undefined;\n\treadonly deadlineMs: number | undefined;\n\treadonly waitMs: number;\n\treadonly waitReason: AdmissionWaitReason;\n}\n\n/**\n * Resolves one signal that spans the whole logical request.\n *\n * @param deadlineMs - Absolute deadline, as Unix epoch milliseconds.\n * @param callerSignal - Optional caller cancellation signal.\n * @returns Signals that span and classify the logical request.\n */\nexport function requestLifecycle(\n\tdeadlineMs: number | undefined,\n\tcallerSignal: AbortSignal | undefined,\n): RequestLifecycle {\n\tif (deadlineMs === undefined) {\n\t\treturn { deadlineMs, deadlineSignal: undefined, signal: callerSignal };\n\t}\n\n\tconst deadlineSignal = deadlineTimeout(deadlineMs);\n\tconst signal =\n\t\tcallerSignal === undefined\n\t\t\t? deadlineSignal\n\t\t\t: AbortSignal.any([callerSignal, deadlineSignal]);\n\treturn { deadlineMs, deadlineSignal, signal };\n}\n\n/**\n * Returns a typed failure when the deadline signal ended the request.\n *\n * @param lifecycle - Signals and timestamp for the logical request.\n * @returns A deadline failure, or `undefined` when another signal won.\n */\nexport function elapsedDeadlineFailure({\n\tdeadlineMs,\n\tdeadlineSignal,\n\tsignal,\n}: RequestLifecycle): RequestDeadlineExceededError | undefined {\n\tif (\n\t\tdeadlineMs === undefined ||\n\t\tdeadlineSignal?.aborted !== true ||\n\t\t!Object.is(signal?.reason, deadlineSignal.reason)\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn new RequestDeadlineExceededError(\"Request deadline elapsed\", {\n\t\tdeadlineMs,\n\t\tremainingMs: 0,\n\t});\n}\n\n/**\n * Reclassifies an internal abort when the request deadline supplied its signal.\n *\n * @param error - Error returned by the request pipeline.\n * @param lifecycle - Signals and timestamp for the logical request.\n * @returns A deadline failure, or `undefined` for other failures.\n */\nexport function deadlineFailureFromError(\n\terror: OpenCloudError,\n\tlifecycle: RequestLifecycle,\n): RequestDeadlineExceededError | undefined {\n\treturn error instanceof RequestAbortedError ? elapsedDeadlineFailure(lifecycle) : undefined;\n}\n\n/**\n * Refuses a known admission wait that cannot fit before the deadline.\n *\n * @param inputs - Deadline, wait duration, reason, and optional cause.\n * @returns A typed refusal, or `undefined` when the wait fits.\n */\nexport function waitDeadlineFailure({\n\tcause,\n\tdeadlineMs,\n\twaitMs,\n\twaitReason,\n}: WaitDeadlineInputs): RequestDeadlineExceededError | undefined {\n\tif (deadlineMs === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst now = Date.now();\n\tconst remainingMs = Math.max(0, deadlineMs - now);\n\tif (now < deadlineMs && waitMs <= remainingMs) {\n\t\treturn undefined;\n\t}\n\n\tconst options: RequestDeadlineExceededErrorOptions = {\n\t\tcause,\n\t\tdeadlineMs,\n\t\tremainingMs,\n\t\twaitMs,\n\t\twaitReason,\n\t};\n\treturn new RequestDeadlineExceededError(waitMessage(waitMs, remainingMs), options);\n}\n\nfunction armDeadlineTimeout(controller: AbortController, deadlineMs: number): void {\n\tconst remainingMs = deadlineMs - Date.now();\n\tif (remainingMs <= 0) {\n\t\tcontroller.abort(DEADLINE_ELAPSED);\n\t\treturn;\n\t}\n\n\tconst timeout = AbortSignal.timeout(Math.min(Math.ceil(remainingMs), MAX_ABORT_TIMEOUT_MS));\n\ttimeout.addEventListener(\"abort\", () => {\n\t\tarmDeadlineTimeout(controller, deadlineMs);\n\t});\n}\n\nfunction deadlineTimeout(deadlineMs: number): AbortSignal {\n\tconst controller = new AbortController();\n\tif (Number.isFinite(deadlineMs)) {\n\t\tarmDeadlineTimeout(controller, deadlineMs);\n\t} else {\n\t\tcontroller.abort(DEADLINE_ELAPSED);\n\t}\n\n\treturn controller.signal;\n}\n\nfunction waitMessage(waitMs: number, remainingMs: number): string {\n\treturn `Admission wait would take ${waitMs / 1000}s; ${remainingMs / 1000}s remain before the request deadline`;\n}\n","import { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { type AdmissionWaitContext, observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport { BudgetTracker } from \"./budget-tracker.ts\";\nimport type { RateLimitSample } from \"./rate-limit-sample.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\n\nconst REPORTED_BUDGET_REASON = \"reported-budget\";\n\n/**\n * Identifies the rate-limit bucket one request draws on: Roblox meters each\n * operation in its own per-API-key bucket.\n */\nexport interface BudgetScope {\n\t/** The effective API key the request authenticates with. */\n\treadonly apiKey: string;\n\t/** The operation the request belongs to. */\n\treadonly operationKey: string;\n}\n\n/**\n * Header-primed rate-limit gate shared across a client. Holds one\n * {@link BudgetTracker} per {@link BudgetScope}. Before each request the caller\n * gates on the request's scope (sleeping if that budget is spent), and after\n * each response folds the parsed sample back in, so a later call on the same\n * scope can head off a 429 the static per-operation token bucket cannot\n * foresee.\n *\n * Gating is serialized per scope through a promise chain so concurrent\n * requests on one scope cannot read the same budget and reserve the same slot;\n * each waits for the prior gate's reserve before computing its own.\n */\nexport class BudgetGate {\n\treadonly #chains = new Map<string, Promise<void>>();\n\treadonly #pendingGates = new Map<string, number>();\n\treadonly #sleep: SleepFunc;\n\treadonly #trackers = new Map<string, BudgetTracker>();\n\n\t/**\n\t * Creates a gate bound to an injectable sleep.\n\t *\n\t * @param sleep - Injectable sleep (tests pass a fake clock).\n\t */\n\tconstructor(sleep: SleepFunc) {\n\t\tthis.#sleep = sleep;\n\t}\n\n\t/**\n\t * Holds until the scope's budget permits a send, then reserves one slot.\n\t * Runs after the prior gate on the same scope settles, whether it resolved\n\t * or rejected, so one failed attempt cannot poison later gates on the\n\t * scope.\n\t *\n\t * @param scope - The API key and operation to gate on.\n\t * @param context - Request-local observer and cancellation signal.\n\t * @rejects {@link RequestAbortedError} when the caller cancels while waiting.\n\t */\n\tpublic async gateAsync(\n\t\tscope: BudgetScope,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext = {},\n\t): Promise<void> {\n\t\tconst key = scopeKey(scope);\n\t\tconst pendingGates = this.#pendingGates.get(key) ?? 0;\n\t\tconst waitsForEarlierGate = pendingGates > 0;\n\t\tthis.#pendingGates.set(key, pendingGates + 1);\n\t\tconst previous = this.#chains.get(key) ?? Promise.resolve();\n\t\tconst recovered = previous.catch(ignoreRejection);\n\t\tconst mine = recovered.then(async () => {\n\t\t\treturn this.#gateOnce(key, {\n\t\t\t\tdeadlineMs,\n\t\t\t\tobserver: waitsForEarlierGate ? undefined : observer,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t});\n\t\tconst completed = mine.finally(() => {\n\t\t\tconst remainingGates = (this.#pendingGates.get(key) ?? 1) - 1;\n\t\t\tthis.#pendingGates.set(key, remainingGates);\n\t\t});\n\t\tthis.#chains.set(key, completed.catch(ignoreRejection));\n\t\tif (waitsForEarlierGate) {\n\t\t\tawait observeAdmissionWaitAsync({\n\t\t\t\tobserver,\n\t\t\t\treason: REPORTED_BUDGET_REASON,\n\t\t\t\twaitAsync: async () => waitForGateAsync(completed, signal),\n\t\t\t});\n\t\t} else {\n\t\t\tawait waitForGateAsync(completed, signal);\n\t\t}\n\t}\n\n\t/**\n\t * Folds a response's parsed budget back onto the scope. A `undefined`\n\t * sample (headers absent or non-numeric) is ignored, leaving the scope on\n\t * static pacing.\n\t *\n\t * @param scope - The same scope passed to {@link gateAsync}.\n\t * @param sample - Parsed sample, or `undefined` when none was reported.\n\t */\n\tpublic observe(scope: BudgetScope, sample: RateLimitSample | undefined): void {\n\t\tif (sample === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#tracker(scopeKey(scope)).observe(sample, Date.now());\n\t}\n\n\tasync #gateOnce(\n\t\tkey: string,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext,\n\t): Promise<void> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow requestAbortedError(signal);\n\t\t}\n\n\t\tconst tracker = this.#tracker(key);\n\t\tconst waitMs = tracker.waitMs(Date.now());\n\t\tif (waitMs > 0) {\n\t\t\tawait this.#waitAsync(waitMs, { deadlineMs, observer, signal });\n\t\t}\n\n\t\ttracker.reserve(Date.now());\n\t}\n\n\t#tracker(key: string): BudgetTracker {\n\t\tconst existing = this.#trackers.get(key);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst tracker = new BudgetTracker();\n\t\tthis.#trackers.set(key, tracker);\n\t\treturn tracker;\n\t}\n\n\tasync #waitAsync(\n\t\twaitMs: number,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext,\n\t): Promise<void> {\n\t\tconst refusal = waitDeadlineFailure({\n\t\t\tdeadlineMs,\n\t\t\twaitMs,\n\t\t\twaitReason: REPORTED_BUDGET_REASON,\n\t\t});\n\t\tif (refusal !== undefined) {\n\t\t\tthrow refusal;\n\t\t}\n\n\t\tawait observeAdmissionWaitAsync({\n\t\t\tdurationMs: waitMs,\n\t\t\tobserver,\n\t\t\treason: REPORTED_BUDGET_REASON,\n\t\t\twaitAsync: async () => {\n\t\t\t\tconst sleepResult = await raceWithAbortAsync(\n\t\t\t\t\tasync () => this.#sleep(waitMs, signal),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (sleepResult === ABORTED) {\n\t\t\t\t\tthrow requestAbortedError(signal);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n}\n\nfunction ignoreRejection(): void {\n\t// A failed or cancelled gate must not poison the next caller's chain.\n}\n\nasync function waitForGateAsync(\n\tgate: Promise<void>,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tconst gateResult = await raceWithAbortAsync(async () => gate, signal);\n\tif (gateResult === ABORTED) {\n\t\tthrow requestAbortedError(signal);\n\t}\n}\n\n/**\n * Composes the map key one budget window is tracked under.\n *\n * @param scope - The API key and operation naming the window.\n * @returns The key for the tracker and chain maps.\n */\nfunction scopeKey({ apiKey, operationKey }: BudgetScope): string {\n\treturn `${apiKey}::${operationKey}`;\n}\n","import type { OpenCloudError } from \"../../errors/base.ts\";\nimport { RetryDelayExceededError } from \"../../errors/retry-delay-exceeded.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\nimport { computeRetryWaitMs, type RetryResolvable, shouldRetry } from \"./retry.ts\";\nimport type { AdmissionWaitObserver, HttpRequest, HttpResponse, OpenCloudHooks } from \"./types.ts\";\n\n/** A transport callback: takes a request, returns a classified Result. */\ntype SendFunc = (request: HttpRequest) => Promise<Result<HttpResponse, OpenCloudError>>;\n\ninterface RetryLimit {\n\treadonly cause: OpenCloudError;\n\treadonly deadlineMs: number | undefined;\n\treadonly retryAfterMs: number;\n}\n\ninterface RetryNotification {\n\treadonly attempt: number;\n\treadonly error: OpenCloudError;\n\treadonly hooks: OpenCloudHooks;\n\treadonly waitMs: number;\n}\n\n/**\n * Inputs to {@link executeWithRetryAsync} bundled as an options object to keep\n * the function signature narrow.\n */\ninterface ExecuteOptions {\n\t/** Request-scoped admission-wait observer. */\n\treadonly admissionWaitObserver?: AdmissionWaitObserver | undefined;\n\t/** Fully-resolved retry config (post-merge). */\n\treadonly config: RetryResolvable;\n\t/**\n\t * Absolute deadline for the logical request, as Unix epoch milliseconds.\n\t */\n\treadonly deadlineMs?: number | undefined;\n\t/** Client-level observability hooks. */\n\treadonly hooks: OpenCloudHooks;\n\t/** Transport callback. May be pre-wrapped by a rate-limit queue. */\n\treadonly send: SendFunc;\n\t/** Optional caller cancellation signal. */\n\treadonly signal?: AbortSignal | undefined;\n\t/** Injectable sleep (tests pass a fake). */\n\treadonly sleep: SleepFunc;\n}\n\n/**\n * Retry-aware orchestration loop. Coordinates a single logical request,\n * looping over `options.send` until it succeeds, the error is non-retryable,\n * or `options.config.maxRetries` is exhausted. Fires observability hooks\n * at each transition. Domain- and queue-agnostic: `send` may be any\n * callback, including one wrapped by a rate-limit queue.\n *\n * @param request - The immutable request to send.\n * @param options - The transport callback, resolved config, hooks, and sleep.\n * @returns The first success, or the final error after retries are exhausted.\n */\nexport async function executeWithRetryAsync(\n\trequest: HttpRequest,\n\toptions: ExecuteOptions,\n): Promise<Result<HttpResponse, OpenCloudError>> {\n\tconst { admissionWaitObserver, config, deadlineMs, hooks, signal, sleep } = options;\n\tif (signal?.aborted === true) {\n\t\treturn abortedResult(signal);\n\t}\n\n\tlet result = await attemptAsync(request, options);\n\n\tfor (let retry = 0; retry < config.maxRetries; retry++) {\n\t\tif (result.success || !shouldRetry(result.err, config)) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst { err } = result;\n\t\tconst waitMs = computeRetryWaitMs(err, { attempt: retry, retryDelay: config.retryDelay });\n\t\tconst refusal = retryRefusal({ cause: err, deadlineMs, retryAfterMs: waitMs });\n\t\tif (refusal !== undefined) {\n\t\t\treturn { err: refusal, success: false };\n\t\t}\n\n\t\tannounceRetry({ attempt: retry + 1, error: err, hooks, waitMs });\n\t\tconst sleepResult = await observeAdmissionWaitAsync({\n\t\t\tdurationMs: waitMs,\n\t\t\tobserver: admissionWaitObserver,\n\t\t\treason: \"retry-delay\",\n\t\t\twaitAsync: async () => raceWithAbortAsync(async () => sleep(waitMs, signal), signal),\n\t\t});\n\t\tif (sleepResult === ABORTED) {\n\t\t\treturn abortedResult(signal);\n\t\t}\n\n\t\tresult = await attemptAsync(request, options);\n\t}\n\n\treturn result;\n}\n\nfunction announceRetry({ attempt, error, hooks, waitMs }: RetryNotification): void {\n\thooks.onRetry?.(attempt, error);\n\thooks.onRateLimit?.(waitMs);\n}\n\nfunction retryRefusal({\n\tcause,\n\tdeadlineMs,\n\tretryAfterMs,\n}: RetryLimit): RetryDelayExceededError | undefined {\n\tif (deadlineMs === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst refusal = waitDeadlineFailure({\n\t\tcause,\n\t\tdeadlineMs,\n\t\twaitMs: retryAfterMs,\n\t\twaitReason: \"retry-delay\",\n\t});\n\tif (refusal === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst { remainingMs } = refusal;\n\treturn new RetryDelayExceededError(\n\t\t`Retry delay would wait ${retryAfterMs / 1000}s; ${remainingMs / 1000}s remain before the request deadline`,\n\t\t{ cause, deadlineMs, remainingMs, retryAfterMs },\n\t);\n}\n\nfunction abortedResult(signal: AbortSignal | undefined): Result<never, OpenCloudError> {\n\treturn { err: requestAbortedError(signal), success: false };\n}\n\nasync function attemptAsync(\n\trequest: HttpRequest,\n\t{ hooks, send, signal }: ExecuteOptions,\n): Promise<Result<HttpResponse, OpenCloudError>> {\n\thooks.onRequest?.(request);\n\tconst attempt = await raceWithAbortAsync(async () => send(request), signal);\n\treturn attempt === ABORTED ? abortedResult(signal) : attempt;\n}\n","import type { OpenCloudError } from \"../../errors/base.ts\";\nimport { hasServerRetryGuidance, RateLimitError } from \"../../errors/rate-limit.ts\";\nimport type { Result } from \"../../types.ts\";\nimport type { RateLimitSample } from \"./rate-limit-sample.ts\";\nimport { parseRateLimitHeaders } from \"./rate-limit-sample.ts\";\nimport type { HttpResponse } from \"./types.ts\";\n\n/**\n * Extracts a {@link RateLimitSample} from a transport result so the budget gate\n * can be fed from every attempt. A 2xx carries the budget in its headers. A 429\n * only primes the gate when it reports zero remaining and valid guidance. This\n * is a conservative scheduling condition, not a semantic classification of the\n * 429. Any other error yields `undefined`.\n *\n * @param result - The classified transport result for one attempt.\n * @returns The parsed sample, or `undefined` when none was reported.\n */\nexport function rateLimitSampleFromResult(\n\tresult: Result<HttpResponse, OpenCloudError>,\n): RateLimitSample | undefined {\n\tif (result.success) {\n\t\treturn parseRateLimitHeaders(result.data.headers);\n\t}\n\n\tconst { err } = result;\n\tif (err instanceof RateLimitError && err.remaining === 0 && hasServerRetryGuidance(err)) {\n\t\treturn { remaining: err.remaining, resetSeconds: err.retryAfterSeconds };\n\t}\n\n\treturn undefined;\n}\n","import { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { type AdmissionWaitContext, observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\nimport type { OpenCloudHooks } from \"./types.ts\";\n\nconst OPERATION_QUEUE_REASON = \"operation-queue\";\n\n/**\n * Identifies and bounds a single Roblox Open Cloud operation for rate\n * limiting, e.g. `{ operationKey: \"game-passes.create\", maxPerSecond: 5 }`.\n */\nexport interface OperationLimit {\n\t/**\n\t * How many requests may be issued back to back before pacing begins,\n\t * as a whole number of requests. Defaults to `max(1, maxPerSecond)`,\n\t * which leaves operations at or above 1/s paced exactly as their\n\t * sustained rate allows while still granting a slower operation one\n\t * request after it has idled. Set this to the allowance the schema\n\t * documents (e.g. 5 per minute) to grant the burst the server permits.\n\t */\n\treadonly burstCapacity?: number;\n\t/** Maximum sustained request rate in requests per second. */\n\treadonly maxPerSecond: number;\n\t/**\n\t * Stable identifier for the operation (e.g. \"game-passes.create\"). Not\n\t * consumed by the queue itself; callers use it to key per-operation\n\t * queues in a registry (see GamePassesClient).\n\t */\n\treadonly operationKey: string;\n}\n\ninterface QueueWait extends AdmissionWaitContext {\n\treadonly now: number;\n\treadonly waitMs: number;\n}\n\n/**\n * Token-bucket rate limiter for a single `(apiKey, operation)` pair. Every\n * call to `acquire` consumes one token; when the bucket is empty the call\n * waits until a token regenerates before invoking the task. Tokens refill at\n * `maxPerSecond` per second, up to the operation's `burstCapacity`.\n *\n * Implemented as a leaky bucket tracking drain debt in ms. `#lastCheck`\n * advances by `waitMs` after every sleep so the algorithm stays correct\n * whether or not the injected sleep moves `Date.now()` forward. `#bucketLevel`\n * and `#maxBucketLevel` are both ms of drain debt, so the ceiling is the burst\n * expressed in that unit: `burstCapacity` refill intervals. Deriving it any\n * other way (notably `maxPerSecond * intervalMs`, whose units cancel to a\n * constant 1000) starves every operation slower than one request per second.\n */\nexport class RateLimitQueue {\n\treadonly #hooks: OpenCloudHooks;\n\treadonly #intervalMs: number;\n\treadonly #maxBucketLevel: number;\n\treadonly #sleep: SleepFunc;\n\n\t#bucketLevel = 0;\n\t#chain: Promise<void> = Promise.resolve();\n\t#lastCheck: number = Date.now();\n\t#pendingAcquisitions = 0;\n\n\t/**\n\t * Creates a rate-limit queue bound to a single operation.\n\t *\n\t * @param limit - The operation key and its per-second request ceiling.\n\t * @param hooks - Observability callbacks; `onRateLimit` fires when the\n\t * bucket is empty and a sleep is about to start.\n\t * @param sleep - Injectable sleep (tests pass a fake).\n\t */\n\tconstructor(limit: OperationLimit, hooks: OpenCloudHooks, sleep: SleepFunc) {\n\t\tthis.#intervalMs = 1000 / limit.maxPerSecond;\n\t\tconst burstCapacity = limit.burstCapacity ?? Math.max(1, limit.maxPerSecond);\n\t\tthis.#maxBucketLevel = burstCapacity * this.#intervalMs;\n\t\tthis.#hooks = hooks;\n\t\tthis.#sleep = sleep;\n\t}\n\n\t/**\n\t * Waits for a token — sleeping and firing `hooks.onRateLimit` if the\n\t * bucket is empty — then executes `task`. Concurrent callers are\n\t * serialized at token acquisition; tasks themselves run independently\n\t * once their token is secured.\n\t *\n\t * @param task - The request to run once a token is available.\n\t * @param context - Request-local observer and cancellation signal.\n\t * @returns The value produced by `task`.\n\t * @rejects {@link RequestAbortedError} when the caller cancels while queued.\n\t */\n\tpublic async acquireAsync<T>(\n\t\ttask: () => Promise<T>,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext = {},\n\t): Promise<T> {\n\t\tconst waitsForEarlierAcquisition = this.#pendingAcquisitions > 0;\n\t\tthis.#pendingAcquisitions++;\n\t\tconst waitForTokenAsync = async (): Promise<void> => {\n\t\t\treturn this.#waitForToken({\n\t\t\t\tdeadlineMs,\n\t\t\t\tobserver: waitsForEarlierAcquisition ? undefined : observer,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t};\n\n\t\tconst myTurn = this.#chain.catch(ignoreRejection).then(waitForTokenAsync);\n\t\tconst completed = myTurn.finally(() => {\n\t\t\tthis.#pendingAcquisitions--;\n\t\t});\n\t\tthis.#chain = completed.catch(ignoreRejection);\n\t\tif (waitsForEarlierAcquisition) {\n\t\t\tawait observeAdmissionWaitAsync({\n\t\t\t\tobserver,\n\t\t\t\treason: OPERATION_QUEUE_REASON,\n\t\t\t\twaitAsync: async () => waitForTurnAsync(completed, signal),\n\t\t\t});\n\t\t} else {\n\t\t\tawait waitForTurnAsync(completed, signal);\n\t\t}\n\n\t\treturn task();\n\t}\n\n\tasync #waitAsync({ deadlineMs, now, observer, signal, waitMs }: QueueWait): Promise<void> {\n\t\tconst refusal = waitDeadlineFailure({\n\t\t\tdeadlineMs,\n\t\t\twaitMs,\n\t\t\twaitReason: OPERATION_QUEUE_REASON,\n\t\t});\n\t\tif (refusal !== undefined) {\n\t\t\tthrow refusal;\n\t\t}\n\n\t\tthis.#hooks.onRateLimit?.(waitMs);\n\t\tawait observeAdmissionWaitAsync({\n\t\t\tdurationMs: waitMs,\n\t\t\tobserver,\n\t\t\treason: OPERATION_QUEUE_REASON,\n\t\t\twaitAsync: async () => {\n\t\t\t\tconst sleepResult = await raceWithAbortAsync(\n\t\t\t\t\tasync () => this.#sleep(waitMs, signal),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (sleepResult === ABORTED) {\n\t\t\t\t\tthrow requestAbortedError(signal);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tthis.#bucketLevel = this.#maxBucketLevel;\n\t\tthis.#lastCheck = now + waitMs;\n\t}\n\n\tasync #waitForToken({ deadlineMs, observer, signal }: AdmissionWaitContext): Promise<void> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow requestAbortedError(signal);\n\t\t}\n\n\t\tconst now = Math.max(Date.now(), this.#lastCheck);\n\t\tconst drained = Math.max(0, this.#bucketLevel - (now - this.#lastCheck));\n\t\tthis.#lastCheck = now;\n\n\t\tif (drained + this.#intervalMs <= this.#maxBucketLevel) {\n\t\t\tthis.#bucketLevel = drained + this.#intervalMs;\n\t\t\treturn;\n\t\t}\n\n\t\tconst waitMs = drained + this.#intervalMs - this.#maxBucketLevel;\n\t\tawait this.#waitAsync({ deadlineMs, now, observer, signal, waitMs });\n\t}\n}\n\nfunction ignoreRejection(): void {\n\t// A failed or cancelled acquire must not poison the next caller's chain.\n}\n\nasync function waitForTurnAsync(\n\tturn: Promise<void>,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tconst turnResult = await raceWithAbortAsync(async () => turn, signal);\n\tif (turnResult === ABORTED) {\n\t\tthrow requestAbortedError(signal);\n\t}\n}\n","import { setTimeout } from \"node:timers/promises\";\n\n/**\n * Injectable sleep function signature for testing.\n *\n * @since 0.1.0\n */\nexport type SleepFunc = (ms: number, signal?: AbortSignal) => Promise<void>;\n\n/**\n * Timer-backed production sleep that releases its timer on cancellation.\n *\n * @param ms - Duration to wait in milliseconds.\n * @param signal - Optional caller cancellation signal.\n */\nexport async function defaultSleepAsync(ms: number, signal?: AbortSignal): Promise<void> {\n\tawait setTimeout(ms, undefined, { signal });\n}\n","import type { HttpClient, SleepFunc } from \"../../client/types.ts\";\nimport { defaultSleepAsync } from \"../utils/sleep.ts\";\nimport { createFetchHttpClient } from \"./fetch-client.ts\";\n\n/**\n * Options accepted by {@link resolveDependencies}. Mirrors the test-seam\n * subset of the public client options.\n */\ninterface ResolveDependenciesOptions {\n\t/**\n\t * Test seam: custom {@link HttpClient}. Defaults to a fetch-backed client.\n\t */\n\treadonly httpClient?: HttpClient | undefined;\n\t/**\n\t * Test seam: custom {@link SleepFunc}. Defaults to a `setTimeout`-backed\n\t * sleep.\n\t */\n\treadonly sleep?: SleepFunc | undefined;\n}\n\n/**\n * Fully-populated dependency set consumed by resource client constructors.\n */\ninterface ResolvedDependencies {\n\t/** Concrete {@link HttpClient} implementation. */\n\treadonly httpClient: HttpClient;\n\t/** Concrete {@link SleepFunc} implementation. */\n\treadonly sleep: SleepFunc;\n}\n\n/**\n * Resolves the concrete HTTP client and sleep implementation a resource\n * client should use. Falls back to the fetch-backed HTTP client and the\n * default `setTimeout`-based sleep when the caller omits the test seams.\n *\n * Extracted so resource client constructors can keep their dependency\n * resolution logic in a single, unit-testable place; this makes the\n * default branches easy to cover without stubbing globals like `fetch`.\n *\n * @param options - Optional {@link HttpClient} and {@link SleepFunc} test seams.\n * @returns A {@link ResolvedDependencies} with defaults applied.\n */\nexport function resolveDependencies(options: ResolveDependenciesOptions): ResolvedDependencies {\n\treturn {\n\t\thttpClient: options.httpClient ?? createFetchHttpClient(),\n\t\tsleep: options.sleep ?? defaultSleepAsync,\n\t};\n}\n","import type { Except } from \"type-fest\";\n\nimport type {\n\tHttpClient,\n\tHttpRequest,\n\tHttpResponse,\n\tOpenCloudClientOptions,\n\tOpenCloudHooks,\n\tRequestConfig,\n\tRequestOptions,\n\tSleepFunc,\n} from \"../client/types.ts\";\nimport { ApiError, requestContextOf } from \"../errors/api-error.ts\";\nimport type { OpenCloudError } from \"../errors/base.ts\";\nimport { PermissionError } from \"../errors/permission-error.ts\";\nimport { RequestAbortedError } from \"../errors/request-aborted.ts\";\nimport { RequestDeadlineExceededError } from \"../errors/request-deadline-exceeded.ts\";\nimport type { Result } from \"../types.ts\";\nimport type { AdmissionWaitContext } from \"./http/admission-wait.ts\";\nimport { BudgetGate, type BudgetScope } from \"./http/budget-gate.ts\";\nimport { executeWithRetryAsync } from \"./http/execute.ts\";\nimport { rateLimitSampleFromResult } from \"./http/rate-limit-observation.ts\";\nimport { type OperationLimit, RateLimitQueue } from \"./http/rate-limit-queue.ts\";\nimport {\n\tdeadlineFailureFromError,\n\telapsedDeadlineFailure,\n\trequestLifecycle,\n\ttype RequestLifecycle,\n} from \"./http/request-deadline.ts\";\nimport { resolveDependencies } from \"./http/resolve-dependencies.ts\";\nimport {\n\tdefaultRetryDelay,\n\tIDEMPOTENT_METHOD_DEFAULTS,\n\tmergeConfig,\n\ttype MethodKind,\n\ttype RetryResolvable,\n} from \"./http/retry.ts\";\nimport { isUploadRequest } from \"./http/upload-request.ts\";\nimport { requestAbortedError } from \"./utils/abort.ts\";\n\n/**\n * Describes a single resource method's shape for dispatch through\n * `ResourceClient.execute`. Each resource client declares one module-level\n * constant per public method; that constant binds the four resource-specific\n * values (request builder, response parser, retry-policy method kind,\n * operation-level rate limit) and flows through `execute` uniformly.\n *\n * @template P - The resource-specific parameter shape the builder\n * accepts.\n * @template T - The resource-specific parsed success type the parser\n * produces.\n */\nexport interface ResourceMethodSpec<P, T> {\n\t/**\n\t * Builds the pure {@link HttpRequest} for a single call. Returns a\n\t * {@link Result} so a builder can short-circuit with a local error\n\t * (typically a {@link OpenCloudError} subclass such as `ValidationError`)\n\t * before any HTTP, queue, or retry work happens. Builders that cannot\n\t * fail wrap their return as `{ data: request, success: true }`.\n\t */\n\treadonly buildRequest: (parameters: P) => Result<HttpRequest, OpenCloudError>;\n\t/** Method-level retry defaults merged into the resolved config. */\n\treadonly methodDefaults: Partial<RetryResolvable>;\n\t/**\n\t * Method kind, controlling merge precedence: `\"create\"` lets method\n\t * defaults win over client config so create safety cannot be relaxed\n\t * silently; `\"idempotent\"` lets client config win over method defaults\n\t * so consumers can loosen retry globally.\n\t */\n\treadonly methodKind: MethodKind;\n\t/**\n\t * Operation-level rate limit, keyed into the client's per-key queue map.\n\t */\n\treadonly operationLimit: OperationLimit;\n\t/**\n\t * Converts the full {@link HttpResponse} into the resource-specific\n\t * parsed shape. Takes the whole response (body, status, headers) so\n\t * future parsers can read headers without widening the signature.\n\t */\n\treadonly parse: (response: HttpResponse) => Result<T, OpenCloudError>;\n\t/**\n\t * Open Cloud scopes the API key or OAuth token must carry for this\n\t * method, sourced from the vendored OpenAPI schema's `x-roblox-scopes`.\n\t * When set, a 401 or 403 ApiError from the upstream call is upgraded to\n\t * a {@link PermissionError} carrying these scopes alongside\n\t * {@link OperationLimit.operationKey}, so callers can name the missing\n\t * scope instead of just the HTTP status. Optional so test specs and\n\t * not-yet-wired resources can opt out.\n\t */\n\treadonly requiredScopes?: ReadonlyArray<string>;\n}\n\n/**\n * Single-argument bundle consumed by `ResourceClient.execute`: the per-method\n * spec, the resource-specific parameters, and optional per-request config\n * overrides.\n *\n * @template P - The resource-specific parameter shape the builder accepts.\n * @template T - The resource-specific parsed success type the parser produces.\n */\ninterface ExecuteCall<P, T> {\n\t/** Optional per-request config overrides. */\n\treadonly options?: RequestOptions | undefined;\n\t/** Resource-specific request parameters. */\n\treadonly parameters: P;\n\t/** Optionally refines a transport error with resource-specific evidence. */\n\treadonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\t/**\n\t * Per-method binding of builder, parser, method kind, and operation limit.\n\t */\n\treadonly spec: ResourceMethodSpec<P, T>;\n}\n\n/**\n * Wraps an infallible request build as a {@link Result}-returning\n * `buildRequest` callback compatible with {@link ResourceMethodSpec}.\n * Use from a resource client whose builder cannot fail; resource clients\n * with local validation should construct the {@link Result} directly.\n *\n * @param request - The pre-built {@link HttpRequest}.\n * @returns A success Result wrapping the request.\n */\nexport function okRequest(request: HttpRequest): Result<HttpRequest, OpenCloudError> {\n\treturn { data: request, success: true };\n}\n\n/**\n * A {@link ResourceMethodSpec.parse} implementation for endpoints that return\n * no business payload on success (such as `DELETE` and reorder operations).\n * Surfaces `undefined` data and never inspects the response body.\n *\n * @returns A success Result with `undefined` data.\n */\nexport function parseEmptyResponse(): Result<undefined, OpenCloudError> {\n\treturn { data: undefined, success: true };\n}\n\nconst CLIENT_DEFAULTS = Object.freeze({\n\tbaseUrl: \"https://apis.roblox.com\",\n\tmaxRetries: 3,\n\tretryableStatuses: IDEMPOTENT_METHOD_DEFAULTS.retryableStatuses,\n\tretryableTransportCodes: IDEMPOTENT_METHOD_DEFAULTS.retryableTransportCodes,\n\tretryDelay: defaultRetryDelay,\n\ttimeout: 30_000,\n} satisfies Except<RetryResolvable, \"apiKey\">);\n\n/**\n * Inputs to {@link buildRequestConfig}, bundled to keep the signature narrow.\n */\ninterface RequestConfigInputs {\n\t/** The resolved config for this call. */\n\treadonly merged: RetryResolvable;\n\t/** The caller's per-request overrides, if any. */\n\treadonly options: RequestOptions | undefined;\n\t/** The built request, inspected for an upload body. */\n\treadonly request: HttpRequest;\n\t/** Caller and deadline signal composed for the whole logical request. */\n\treadonly signal: AbortSignal | undefined;\n}\n\ninterface DispatchInputs {\n\treadonly admission: AdmissionWaitContext;\n\treadonly merged: RetryResolvable;\n\treadonly operationLimit: OperationLimit;\n\treadonly refineError: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\treadonly request: HttpRequest;\n\treadonly requestConfig: RequestConfig;\n}\n\n/** Inputs to the request-scoped budget-gated transport callback. */\ninterface GatedSendInputs {\n\treadonly admission: AdmissionWaitContext;\n\treadonly refineError: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\treadonly requestConfig: RequestConfig;\n\treadonly scope: BudgetScope;\n}\n\n/** Request-only controls resolved before request construction. */\ninterface RequestStart {\n\treadonly admission: AdmissionWaitContext;\n\treadonly lifecycle: RequestLifecycle;\n\treadonly requestOptions: Partial<RetryResolvable>;\n}\n\ninterface FinishRequestInputs<P, T> {\n\treadonly httpResult: Result<HttpResponse, OpenCloudError>;\n\treadonly lifecycle: RequestLifecycle;\n\treadonly spec: ResourceMethodSpec<P, T>;\n}\n\n/**\n * Internal orchestrator shared by every Open Cloud resource client. Holds\n * the frozen client config, observability hooks, injected HTTP client and\n * sleep, and the per-effective-key rate-limit queue registry. Resource\n * classes compose one instance and dispatch every public method through\n * {@link ResourceClient.executeAsync} with a per-method {@link ResourceMethodSpec}.\n * Not exported from any package subpath; reachable only via sibling\n * `src/resources/**` modules in this package.\n */\nexport class ResourceClient {\n\treadonly #budgets: BudgetGate;\n\treadonly #config: Readonly<RetryResolvable>;\n\treadonly #hooks: OpenCloudHooks;\n\treadonly #httpClient: HttpClient;\n\treadonly #queues = new Map<string, RateLimitQueue>();\n\treadonly #sleep: SleepFunc;\n\n\t/**\n\t * Creates a new {@link ResourceClient}. Resolves the injected HTTP\n\t * client and sleep (defaulting to fetch + `setTimeout`) and freezes the\n\t * merged client config so subsequent calls cannot mutate it.\n\t *\n\t * @param options - Client-level configuration including the API key\n\t * and optional construction-time test seams.\n\t */\n\tconstructor({ apiKey, hooks, httpClient, sleep, ...overrides }: OpenCloudClientOptions) {\n\t\tconst resolved = resolveDependencies({ httpClient, sleep });\n\t\tthis.#httpClient = resolved.httpClient;\n\t\tthis.#sleep = resolved.sleep;\n\t\tthis.#budgets = new BudgetGate(this.#sleep);\n\t\tthis.#hooks = hooks ?? {};\n\t\tthis.#config = Object.freeze({\n\t\t\t...CLIENT_DEFAULTS,\n\t\t\tapiKey,\n\t\t\t...overrides,\n\t\t});\n\t}\n\n\t/**\n\t * Dispatches a single resource-method call. Merges the frozen client\n\t * config with the method's `methodDefaults` and the caller's optional\n\t * per-request `options`, routes through the effective-apiKey rate-limit\n\t * queue, runs the retry loop, and finally parses the response with the\n\t * spec's parser.\n\t *\n\t * @param call - The per-method spec, resource-specific parameters, and\n\t * optional per-request overrides.\n\t * @returns The parsed success payload or the {@link OpenCloudError} that\n\t * caused the request to fail. Never throws.\n\t * @rejects An unexpected collaborator failure unrelated to caller cancellation.\n\t */\n\tpublic async executeAsync<P, T>({\n\t\toptions,\n\t\tparameters,\n\t\trefineError,\n\t\tspec,\n\t}: ExecuteCall<P, T>): Promise<Result<T, OpenCloudError>> {\n\t\tconst start = startRequest(options);\n\t\tif (!start.success) {\n\t\t\treturn start;\n\t\t}\n\n\t\tconst { admission, lifecycle, requestOptions } = start.data;\n\t\tconst merged = mergeConfig(this.#config, {\n\t\t\tmethodDefaults: spec.methodDefaults,\n\t\t\tmethodKind: spec.methodKind,\n\t\t\trequestOptions,\n\t\t});\n\t\tconst requestResult = spec.buildRequest(parameters);\n\t\tif (!requestResult.success) {\n\t\t\treturn requestResult;\n\t\t}\n\n\t\tconst request = requestResult.data;\n\t\tconst { signal } = admission;\n\t\tconst requestConfig = buildRequestConfig({ merged, options, request, signal });\n\t\tconst httpResult = await this.#dispatchAsync({\n\t\t\tadmission,\n\t\t\tmerged,\n\t\t\toperationLimit: spec.operationLimit,\n\t\t\trefineError,\n\t\t\trequest,\n\t\t\trequestConfig,\n\t\t});\n\t\treturn finishRequest({ httpResult, lifecycle, spec });\n\t}\n\n\t/**\n\t * Returns the sleep function used by this client instance.\n\t *\n\t * @returns The sleep function injected at construction time.\n\t */\n\tpublic get sleep(): SleepFunc {\n\t\treturn this.#sleep;\n\t}\n\n\tasync #dispatchAsync({\n\t\tadmission,\n\t\tmerged,\n\t\toperationLimit,\n\t\trefineError,\n\t\trequest,\n\t\trequestConfig,\n\t}: DispatchInputs): Promise<Result<HttpResponse, OpenCloudError>> {\n\t\tconst queue = this.#getQueue(merged.apiKey, operationLimit);\n\t\ttry {\n\t\t\treturn await queue.acquireAsync(async () => {\n\t\t\t\treturn executeWithRetryAsync(request, {\n\t\t\t\t\tadmissionWaitObserver: admission.observer,\n\t\t\t\t\tconfig: merged,\n\t\t\t\t\tdeadlineMs: admission.deadlineMs,\n\t\t\t\t\thooks: this.#hooks,\n\t\t\t\t\tsend: this.#gatedSend({\n\t\t\t\t\t\tadmission,\n\t\t\t\t\t\trefineError,\n\t\t\t\t\t\trequestConfig,\n\t\t\t\t\t\tscope: {\n\t\t\t\t\t\t\tapiKey: merged.apiKey,\n\t\t\t\t\t\t\toperationKey: operationLimit.operationKey,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t\tsignal: admission.signal,\n\t\t\t\t\tsleep: this.#sleep,\n\t\t\t\t});\n\t\t\t}, admission);\n\t\t} catch (err) {\n\t\t\treturn dispatchFailure(err);\n\t\t}\n\t}\n\n\t/**\n\t * Builds the transport callback for one logical call, wrapping the HTTP\n\t * client with the budget gate: each attempt waits on the scope's budget\n\t * before sending, then folds the response's reported budget back in so the\n\t * next attempt (or a later call on the same scope) can head off a 429.\n\t *\n\t * @param inputs - Budget scope, transport config, observer, and caller signal.\n\t * @returns A send callback for {@link executeWithRetryAsync}.\n\t */\n\t#gatedSend({\n\t\tadmission,\n\t\trefineError,\n\t\trequestConfig,\n\t\tscope,\n\t}: GatedSendInputs): (request: HttpRequest) => Promise<Result<HttpResponse, OpenCloudError>> {\n\t\treturn async (toSend) => {\n\t\t\tawait this.#budgets.gateAsync(scope, admission);\n\t\t\tconst transportResult = await this.#httpClient.request(toSend, requestConfig);\n\t\t\tconst sendResult =\n\t\t\t\trefineError === undefined || transportResult.success\n\t\t\t\t\t? transportResult\n\t\t\t\t\t: { err: refineError(transportResult.err), success: false as const };\n\t\t\tthis.#budgets.observe(scope, rateLimitSampleFromResult(transportResult));\n\t\t\treturn sendResult;\n\t\t};\n\t}\n\n\t#getQueue(apiKey: string, limit: OperationLimit): RateLimitQueue {\n\t\tconst key = `${apiKey}::${limit.operationKey}`;\n\t\tconst existing = this.#queues.get(key);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst queue = new RateLimitQueue(limit, this.#hooks, this.#sleep);\n\t\tthis.#queues.set(key, queue);\n\t\treturn queue;\n\t}\n}\n\nfunction startRequest(options: RequestOptions | undefined): Result<RequestStart, OpenCloudError> {\n\tconst callerSignal = options?.signal;\n\tif (callerSignal?.aborted === true) {\n\t\treturn { err: requestAbortedError(callerSignal), success: false };\n\t}\n\n\tconst lifecycle = requestLifecycle(options?.deadlineMs, callerSignal);\n\tconst deadlineFailure = elapsedDeadlineFailure(lifecycle);\n\tif (deadlineFailure !== undefined) {\n\t\treturn { err: deadlineFailure, success: false };\n\t}\n\n\tconst { deadlineMs, onAdmissionWait, signal: _signal, ...requestOptions } = options ?? {};\n\treturn {\n\t\tdata: {\n\t\t\tadmission: { deadlineMs, observer: onAdmissionWait, signal: lifecycle.signal },\n\t\t\tlifecycle,\n\t\t\trequestOptions,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction dispatchFailure(err: unknown): Result<never, OpenCloudError> {\n\tif (err instanceof RequestAbortedError || err instanceof RequestDeadlineExceededError) {\n\t\treturn { err, success: false };\n\t}\n\n\tthrow err;\n}\n\n/**\n * Resolves the per-request {@link RequestConfig}. Upload requests\n * ({@link isUploadRequest}) carry no default timeout: a multi-megabyte place\n * file over a slow link is bandwidth-bound, so a transport-attempt timeout only\n * fires spuriously. An explicit `options.timeout` still applies to any\n * request; every non-upload request keeps the merged default.\n *\n * @param inputs - The merged config, the built request, and per-request overrides.\n * @returns The config to hand to the transport, with `timeout` omitted when\n * no transport-attempt timeout should apply.\n */\nfunction buildRequestConfig({\n\tmerged,\n\toptions,\n\trequest,\n\tsignal,\n}: RequestConfigInputs): RequestConfig {\n\tconst shouldOmitDefaultTimeout = options?.timeout === undefined && isUploadRequest(request);\n\treturn {\n\t\tapiKey: merged.apiKey,\n\t\tbaseUrl: merged.baseUrl,\n\t\t...(signal === undefined ? {} : { signal }),\n\t\t...(shouldOmitDefaultTimeout ? {} : { timeout: merged.timeout }),\n\t};\n}\n\nfunction enrichPermissionError<P, T>(\n\terr: OpenCloudError,\n\tspec: ResourceMethodSpec<P, T>,\n): OpenCloudError {\n\tif (spec.requiredScopes === undefined) {\n\t\treturn err;\n\t}\n\n\tif (err instanceof PermissionError) {\n\t\treturn err;\n\t}\n\n\tif (!(err instanceof ApiError)) {\n\t\treturn err;\n\t}\n\n\tif (err.statusCode !== 401 && err.statusCode !== 403) {\n\t\treturn err;\n\t}\n\n\t// An edge gateway answers 401 and 403 for its own reasons, and the request\n\t// never reached the operation whose scopes these are.\n\tif (err.gatewaySummary !== undefined) {\n\t\treturn err;\n\t}\n\n\treturn new PermissionError(err.message, {\n\t\t...requestContextOf(err),\n\t\tcause: err.cause,\n\t\tcode: err.code,\n\t\tdetails: err.details,\n\t\toperationKey: spec.operationLimit.operationKey,\n\t\trequiredScopes: spec.requiredScopes,\n\t\tstatusCode: err.statusCode,\n\t});\n}\n\nfunction finishRequest<P, T>({\n\thttpResult,\n\tlifecycle,\n\tspec,\n}: FinishRequestInputs<P, T>): Result<T, OpenCloudError> {\n\tif (httpResult.success) {\n\t\treturn spec.parse(httpResult.data);\n\t}\n\n\tconst deadlineFailure = deadlineFailureFromError(httpResult.err, lifecycle);\n\treturn {\n\t\terr: deadlineFailure ?? enrichPermissionError(httpResult.err, spec),\n\t\tsuccess: false,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAgB,iBAAiB,OAAiC;CACjE,IAAI,OAAO,UAAU,UACpB,OAAO;CAGR,MAAM,SAAS,IAAI,KAAK,KAAK;CAC7B,OAAO,CAAC,OAAO,MAAM,OAAO,QAAQ,CAAC;AACtC;;;;;;;;;;;;ACRA,SAAgB,SAAS,OAAkD;CAC1E,OAAO,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AAClD;;;;;;;;;;;;;;ACEA,SAAgB,cAAc,OAAuC;CACpE,OAAO,YAAY,uBAAO,IAAI,IAAI,CAAC;AACpC;AAEA,SAAS,YAAY,OAAgB,MAA0C;CAC9E,IAAI,UAAU,MAEb,OAAO;CAGR,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC9E,OAAO;CAGR,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,YAAY,OAAO,IAAI;CAG/B,IAAI,SAAS,KAAK,GACjB,OAAO,aAAa,OAAO,IAAI;AAIjC;AAEA,SAAS,YAAY,OAA+B,MAA0C;CAC7F,IAAI,KAAK,IAAI,KAAK,GACjB;CAGD,KAAK,IAAI,KAAK;CACd,MAAM,QAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,YAAY,YAAY,MAAM,IAAI;EACxC,IAAI,cAAc,KAAA,GACjB;EAGD,MAAM,KAAK,SAAS;CACrB;CAEA,KAAK,OAAO,KAAK;CACjB,OAAO;AACR;AAEA,SAAS,aAAa,OAAgC,MAA0C;CAC/F,IAAI,KAAK,IAAI,KAAK,GACjB;CAGD,KAAK,IAAI,KAAK;CACd,MAAM,UAAsC,CAAC;CAC7C,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QA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,OAAO;EAChB,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC,GAAI,2BAA2B,CAAC,IAAI,EAAE,SAAS,OAAO,QAAQ;CAC/D;AACD;AAEA,SAAS,sBACR,KACA,MACiB;CACjB,IAAI,KAAK,mBAAmB,KAAA,GAC3B,OAAO;CAGR,IAAI,eAAe,iBAClB,OAAO;CAGR,IAAI,EAAE,eAAe,WACpB,OAAO;CAGR,IAAI,IAAI,eAAe,OAAO,IAAI,eAAe,KAChD,OAAO;CAKR,IAAI,IAAI,mBAAmB,KAAA,GAC1B,OAAO;CAGR,OAAO,IAAI,gBAAgB,IAAI,SAAS;EACvC,GAAG,iBAAiB,GAAG;EACvB,OAAO,IAAI;EACX,MAAM,IAAI;EACV,SAAS,IAAI;EACb,cAAc,KAAK,eAAe;EAClC,gBAAgB,KAAK;EACrB,YAAY,IAAI;CACjB,CAAC;AACF;AAEA,SAAS,cAAoB,EAC5B,YACA,WACA,QACwD;CACxD,IAAI,WAAW,SACd,OAAO,KAAK,MAAM,WAAW,IAAI;CAIlC,OAAO;EACN,KAFuB,yBAAyB,WAAW,KAAK,SAE7C,KAAK,sBAAsB,WAAW,KAAK,IAAI;EAClE,SAAS;CACV;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry-vpHMIwaU.mjs","names":["CONTENT_TYPE_HEADER","exhaustive"],"sources":["../src/internal/utils/try-catch.ts","../src/internal/http/diagnostics.ts","../src/internal/http/error-body.ts","../src/internal/http/http1-dispatcher.ts","../src/internal/http/rate-limit-sample.ts","../src/internal/http/retry-guidance.ts","../src/internal/http/rate-limit-response.ts","../src/errors/request-aborted.ts","../src/internal/utils/abort.ts","../src/internal/http/request-signal.ts","../src/internal/http/upload-request.ts","../src/internal/http/fetch-client.ts","../src/errors/permission-error.ts","../src/errors/request-deadline-exceeded.ts","../src/errors/retry-delay-exceeded.ts","../src/internal/utils/find-error-code.ts","../src/internal/http/retry.ts"],"sourcesContent":["import type { Result } from \"../../types.ts\";\n\n/**\n * Wraps a promise into a {@link Result}, catching rejections.\n *\n * @template T - The resolved value type.\n * @param promise - The promise to wrap.\n * @returns A Result containing the resolved value or the rejection error.\n */\nexport async function tryCatchAsync<T>(promise: Promise<T>): Promise<Result<T>> {\n\ttry {\n\t\tconst data = await promise;\n\t\treturn { data, success: true };\n\t} catch (err) {\n\t\treturn { err: err instanceof Error ? err : new Error(String(err)), success: false };\n\t}\n}\n","import { ApiError } from \"../../errors/api-error.ts\";\nimport type { Result } from \"../../types.ts\";\n\n// Caps the raw body retained when a response cannot be parsed, so a multi-KB\n// HTML error page is not surfaced or logged whole.\nconst MAX_DETAIL_LENGTH = 500;\n\nconst CONTENT_TYPE_HEADER = \"content-type\";\n\n/**\n * The request-level context threaded from the transport into error\n * construction: which call failed and how long it was in flight.\n */\nexport interface RequestContext {\n\t/** Wall-clock time the request was in flight, in milliseconds. */\n\treadonly elapsedMs: number;\n\t/** HTTP method of the request. */\n\treadonly method: string;\n\t/** Fully-qualified URL of the request. */\n\treadonly url: string;\n}\n\n/** Inputs to {@link parseFailureError}. */\nexport interface ParseFailureArgs {\n\t/** The `SyntaxError` thrown by the failed `JSON.parse`. */\n\treadonly cause: Error;\n\t/** The request that produced the unusable response. */\n\treadonly context: RequestContext;\n\t/** The 2xx response whose body would not parse. */\n\treadonly response: Response;\n\t/** The raw body text, read once by the transport. */\n\treadonly text: string;\n}\n\n// A small allowlist of response headers worth retaining on an ApiError for\n// diagnosis and escalation to Roblox. apis.roblox.com returns `server` (e.g.\n// `public-gateway`, or `haproxy` on a load-balancer error page) and\n// `x-roblox-edge` on every response; `via`, `x-request-id`, and `cf-ray` are\n// standard proxy/CDN request-id headers kept in case an edge adds them. The\n// full header set is never retained, to avoid surfacing anything sensitive.\nconst DIAGNOSTIC_HEADER_ALLOWLIST: ReadonlySet<string> = new Set([\n\t\"cf-ray\",\n\t\"server\",\n\t\"via\",\n\t\"x-request-id\",\n]);\n\nconst DIAGNOSTIC_HEADER_PREFIX = \"x-roblox-\";\n\nconst RATE_LIMIT_HEADER_ALLOWLIST: ReadonlySet<string> = new Set([\n\t\"date\",\n\t\"retry-after\",\n\t\"x-envoy-ratelimited\",\n\t\"x-ratelimit-limit\",\n\t\"x-ratelimit-remaining\",\n\t\"x-ratelimit-reset\",\n\t\"x-retry-after-coverage\",\n]);\n\n// Only the opening tag is matched; the closing tag is located with indexOf so\n// the inner text needs no unbounded pattern, which would backtrack\n// super-linearly on a hostile error page.\nconst TITLE_OPEN_PATTERN = /<title[^>]*>/i;\nconst H1_OPEN_PATTERN = /<h1[^>]*>/i;\nconst TAG_PATTERN = /<[^<>]*>/g;\nconst WHITESPACE_PATTERN = /\\s+/g;\n\n/**\n * Extracts a one-line human summary from an HTML gateway error page, or returns\n * `undefined` when the body is not such a page. A load balancer (HAProxy-style)\n * rejects a request before it reaches Open Cloud and answers with an HTML page,\n * not a JSON Open Cloud error; dumping that HTML whole is noise. The body is\n * treated as HTML when the content-type is `text/html` or the trimmed body is\n * tag-led (`<html`/`<!doctype html`), and the summary is taken from the\n * `<title>` (falling back to the first `<h1>`), tags stripped and whitespace\n * collapsed.\n *\n * @param contentType - The response `content-type` header, if present.\n * @param rawText - The raw response body text.\n * @returns The extracted summary, or `undefined` when the body is not an HTML\n * gateway page (or carries no title/h1 text).\n */\nexport function extractGatewaySummary(\n\tcontentType: string | undefined,\n\trawText: string,\n): string | undefined {\n\tif (!isHtmlBody(contentType, rawText)) {\n\t\treturn undefined;\n\t}\n\n\treturn (\n\t\tfirstTagText(rawText, { close: \"</title>\", open: TITLE_OPEN_PATTERN }) ??\n\t\tfirstTagText(rawText, { close: \"</h1>\", open: H1_OPEN_PATTERN })\n\t);\n}\n\n/**\n * Filters a lowercased header record down to the diagnostic allowlist: a few\n * named escalation headers plus any `x-roblox-*` header. Keeps errors light and\n * avoids retaining anything sensitive from the full response header set.\n *\n * @param headers - The full header record (lowercased keys).\n * @returns A record containing only the allowlisted headers that were present.\n */\nexport function pickDiagnosticHeaders(\n\theaders: Record<string, string>,\n): Readonly<Record<string, string>> {\n\treturn pickHeaders(headers);\n}\n\n/**\n * Filters a lowercased header record to the raw evidence useful for diagnosing\n * a 429: the general diagnostic headers plus rate-limit guidance and counters.\n * Values are copied without parsing so comma-joined windows remain available.\n *\n * @param headers - The full header record (lowercased keys).\n * @returns Only allowlisted diagnostic and rate-limit headers.\n */\nexport function pickRateLimitHeaders(\n\theaders: Record<string, string>,\n): Readonly<Record<string, string>> {\n\treturn pickHeaders(headers, RATE_LIMIT_HEADER_ALLOWLIST);\n}\n\n/**\n * Converts a `Headers` object to a plain record with lowercased keys.\n *\n * @param headers - The `Headers` instance to convert.\n * @returns A record mapping lowercased header names to their values.\n */\nexport function headersToRecord(headers: Headers): Record<string, string> {\n\treturn Object.fromEntries(headers);\n}\n\n/**\n * Projects a read body to the detail carried on an error: the parsed JSON when\n * it parsed, otherwise the raw text truncated to {@link MAX_DETAIL_LENGTH}.\n *\n * @param text - The raw response body text.\n * @param parsed - The best-effort parse result from the transport's body read.\n * @returns The parsed body, or the truncated raw text on a parse failure.\n */\nexport function bodyDetail(\n\ttext: string,\n\tparsed: Result<JSONValue | undefined>,\n): JSONValue | undefined {\n\treturn parsed.success ? parsed.data : text.slice(0, MAX_DETAIL_LENGTH);\n}\n\n/**\n * Builds the error for a 2xx response whose body could not be parsed as JSON,\n * preserving the parse `cause`, the (truncated) raw body, the declared\n * content-type, and the request that produced it so the failure can be\n * diagnosed after the fact.\n *\n * The received length is on the message rather than only on the error, because\n * `details` retains just the first {@link MAX_DETAIL_LENGTH} characters: for a\n * body that stopped mid-token the head says nothing and the length says\n * everything. A `SyntaxError` position equal to this number is a body the edge\n * cut short, not one the API mis-serialized.\n *\n * @param args - The Response, raw body text, request context, and underlying\n * parse error.\n * @returns An ApiError carrying the diagnostic context.\n */\nexport function parseFailureError({ cause, context, response, text }: ParseFailureArgs): ApiError {\n\tconst contentType = response.headers.get(CONTENT_TYPE_HEADER) ?? \"unknown\";\n\treturn new ApiError(\n\t\t`Failed to parse response body (content-type: ${contentType}, ${String(text.length)} chars read)`,\n\t\t{\n\t\t\tcause,\n\t\t\tdetails: text.slice(0, MAX_DETAIL_LENGTH),\n\t\t\telapsedMs: context.elapsedMs,\n\t\t\tmethod: context.method,\n\t\t\tresponseHeaders: pickDiagnosticHeaders(headersToRecord(response.headers)),\n\t\t\tstatusCode: response.status,\n\t\t\tunparsedBodyLength: text.length,\n\t\t\turl: context.url,\n\t\t},\n\t);\n}\n\nfunction firstTagText(html: string, tag: { close: string; open: RegExp }): string | undefined {\n\tconst open = tag.open.exec(html);\n\tif (open === null) {\n\t\treturn undefined;\n\t}\n\n\tconst start = open.index + open[0].length;\n\tconst end = html.toLowerCase().indexOf(tag.close, start);\n\tif (end === -1) {\n\t\treturn undefined;\n\t}\n\n\tconst inner = html.slice(start, end);\n\n\tconst text = inner.replace(TAG_PATTERN, \" \").replace(WHITESPACE_PATTERN, \" \").trim();\n\treturn text === \"\" ? undefined : text;\n}\n\nfunction isHtmlBody(contentType: string | undefined, rawText: string): boolean {\n\tif (contentType?.toLowerCase().includes(\"text/html\") === true) {\n\t\treturn true;\n\t}\n\n\tconst head = rawText.trimStart().toLowerCase();\n\treturn head.startsWith(\"<html\") || head.startsWith(\"<!doctype html\");\n}\n\nfunction pickHeaders(\n\theaders: Record<string, string>,\n\tadditionalAllowlist?: ReadonlySet<string>,\n): Record<string, string> {\n\tconst picked: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (\n\t\t\tDIAGNOSTIC_HEADER_ALLOWLIST.has(name) ||\n\t\t\tname.startsWith(DIAGNOSTIC_HEADER_PREFIX) ||\n\t\t\tadditionalAllowlist?.has(name) === true\n\t\t) {\n\t\t\tpicked[name] = value;\n\t\t}\n\t}\n\n\treturn picked;\n}\n","const CANONICAL_STATUS = /^[A-Z][A-Z0-9_]*$/;\n\n/**\n * Permissively extracts a machine-readable error code from a response body.\n *\n * Four shapes are checked, in precedence order. Modern Open Cloud responses\n * use `{ errorCode: string, message: string }`; Cloud v2 resource endpoints\n * carry the canonical status in `code` (`{ code: \"INVALID_ARGUMENT\", message:\n * string }`); other v2 endpoints, such as memory-store queues, carry it in\n * `error` (`{ error: \"NOT_FOUND\", message: string }`); the legacy\n * game-internationalization endpoints use\n * `{ errors: [{ code: number, message: string }, ...] }`. Numeric legacy codes\n * are returned as strings so callers see one consistent type.\n *\n * `error` is read only when it holds an upper-snake-case token. A Google-style\n * nested envelope (`{ error: { code, message, status } }`) puts an object\n * there, and coercing that to a string would hand callers `\"[object Object]\"`\n * as a status. The server-management API puts a sentence there (`{ error:\n * \"Place 1 does not belong to universe 2\" }`), which\n * {@link extractErrorMessage} reads instead.\n *\n * @param body - The parsed response body (unknown shape).\n * @returns The error code if present, otherwise `undefined`.\n */\nexport function extractErrorCode(body: unknown): string | undefined {\n\tif (body === null || typeof body !== \"object\") {\n\t\treturn undefined;\n\t}\n\n\tconst errorCode = Reflect.get(body, \"errorCode\");\n\tif (typeof errorCode === \"string\") {\n\t\treturn errorCode;\n\t}\n\n\tconst v2Code = Reflect.get(body, \"code\");\n\tif (typeof v2Code === \"string\") {\n\t\treturn v2Code;\n\t}\n\n\tconst v2Error = readErrorField(body);\n\tif (v2Error !== undefined && CANONICAL_STATUS.test(v2Error)) {\n\t\treturn v2Error;\n\t}\n\n\treturn extractLegacyCode(body);\n}\n\n/**\n * Permissively extracts a human-readable error message from a response body.\n *\n * Modern Open Cloud responses expose `message` at the top level;\n * server-management business-rule errors put a sentence in `error`, and its\n * validation errors are ASP.NET ProblemDetails, read as the `title` followed\n * by the first field error in `errors`; the legacy game-internationalization\n * endpoints nest it under `errors[0].message`.\n *\n * @param body - The parsed response body (unknown shape).\n * @returns The message if present, otherwise `undefined`.\n */\nexport function extractErrorMessage(body: unknown): string | undefined {\n\tif (body === null || typeof body !== \"object\") {\n\t\treturn undefined;\n\t}\n\n\tconst message = Reflect.get(body, \"message\");\n\tif (typeof message === \"string\") {\n\t\treturn message;\n\t}\n\n\tconst errorSentence = readErrorField(body);\n\tif (errorSentence !== undefined && !CANONICAL_STATUS.test(errorSentence)) {\n\t\treturn errorSentence;\n\t}\n\n\treturn extractProblemDetailsMessage(body) ?? extractLegacyMessage(body);\n}\n\nfunction readErrorField(body: object): string | undefined {\n\tconst error = Reflect.get(body, \"error\");\n\treturn typeof error === \"string\" ? error : undefined;\n}\n\nfunction readLegacyErrorEntry(body: object): object | undefined {\n\tconst errors = Reflect.get(body, \"errors\");\n\tif (!Array.isArray(errors)) {\n\t\treturn undefined;\n\t}\n\n\tconst [first] = errors;\n\tif (typeof first !== \"object\" || first === null) {\n\t\treturn undefined;\n\t}\n\n\treturn first;\n}\n\nfunction extractLegacyCode(body: object): string | undefined {\n\tconst first = readLegacyErrorEntry(body);\n\tif (first === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst code = Reflect.get(first, \"code\");\n\tif (typeof code === \"string\") {\n\t\treturn code;\n\t}\n\n\treturn typeof code === \"number\" ? String(code) : undefined;\n}\n\nfunction readFirstFieldError(body: object): string | undefined {\n\tconst errors = Reflect.get(body, \"errors\");\n\tif (typeof errors !== \"object\" || errors === null) {\n\t\treturn undefined;\n\t}\n\n\tconst [fieldErrors] = Object.values(errors);\n\tif (!Array.isArray(fieldErrors)) {\n\t\treturn undefined;\n\t}\n\n\tconst [first] = fieldErrors;\n\treturn typeof first === \"string\" ? first : undefined;\n}\n\nfunction extractProblemDetailsMessage(body: object): string | undefined {\n\tconst title = Reflect.get(body, \"title\");\n\tconst fieldError = readFirstFieldError(body);\n\tif (typeof title !== \"string\") {\n\t\treturn fieldError;\n\t}\n\n\treturn fieldError === undefined ? title : `${title} ${fieldError}`;\n}\n\nfunction extractLegacyMessage(body: object): string | undefined {\n\tconst first = readLegacyErrorEntry(body);\n\tif (first === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst message = Reflect.get(first, \"message\");\n\treturn typeof message === \"string\" ? message : undefined;\n}\n","/** The shape the global dispatcher's class is assumed to have. */\ntype AgentConstructor = new (options: { allowH2: boolean }) => object;\n\n/**\n * Well-known globals under which undici publishes its global dispatcher,\n * newest first. The suffix is undici's own contract version: it moved from\n * `.1` to `.2` in undici 8, so a future major may move it again. Both are\n * probed, and {@link createHttp1Dispatcher} degrades to `undefined` when\n * neither is present — which is also the Bun path, since Bun's `fetch` is not\n * undici-backed and never publishes these.\n */\nconst GLOBAL_DISPATCHER_KEYS: ReadonlyArray<string> = Object.freeze([\n\t\"undici.globalDispatcher.2\",\n\t\"undici.globalDispatcher.1\",\n]);\n\n/**\n * Narrow a value read off the global dispatcher to something\n * `Reflect.construct` accepts. Exported so the narrowing is unit-testable: at\n * the call site every rejected shape funnels into the same `undefined`, which\n * makes the branch unobservable from `createHttp1Dispatcher` alone.\n *\n * @param value - The candidate `constructor` read off the global dispatcher.\n * @returns Whether the value can be constructed.\n */\nexport function isAgentConstructor(value: unknown): value is AgentConstructor {\n\treturn typeof value === \"function\";\n}\n\n/**\n * Builds a request dispatcher that negotiates HTTP/1.1 only, by reusing the\n * class of the runtime's own global dispatcher.\n *\n * From Node 26 (undici 8) `fetch` offers h2 in ALPN, which defeats the\n * `connection: close` an upload sets: `connection` is a connection-specific\n * header, so an h2 transport drops it before the wire and pools every upload\n * onto one multiplexed session. One session death then fails every upload in\n * flight. Constructing the same agent with `allowH2: false` restores the\n * per-upload connection the directive was written for.\n *\n * There is no standard `fetch` option for this, so the agent is reached\n * through undici's versioned global symbol and its class rather than through\n * an import — which keeps the package dependency-free. The contract is\n * internal, so every step is guarded: an absent symbol, a non-constructible\n * value, or a constructor that throws all yield `undefined`, and the caller\n * sends the request unmodified.\n *\n * @param scope - The object to read the global dispatcher from. Defaults to\n * `globalThis`; injectable so tests need not mutate the real global.\n * @returns A dispatcher restricted to HTTP/1.1, or `undefined` when this\n * runtime offers no reachable one.\n */\nexport function createHttp1Dispatcher(scope: object = globalThis): object | undefined {\n\tfor (const key of GLOBAL_DISPATCHER_KEYS) {\n\t\tconst dispatcher = constructHttp1(Reflect.get(scope, Symbol.for(key)));\n\t\tif (dispatcher !== undefined) {\n\t\t\treturn dispatcher;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Reconstructs `agent`'s class with h2 disabled.\n *\n * Most ways `agent` can be wrong already throw: `Reflect.get` rejects a\n * primitive, `null`, and an absent key, and `Reflect.construct` rejects a\n * `constructor` that is not one, or that refuses the options. One shape gets\n * through — a plain object, whose `constructor` is `Object`, so constructing\n * it hands back the options bag. The result is therefore checked against the\n * one part of undici's surface that is public and stable: a `Dispatcher`\n * exposes `dispatch`.\n *\n * @param agent - The candidate global dispatcher; any value, since it comes\n * from an undocumented global.\n * @returns The new dispatcher, or `undefined` when `agent` is not an object\n * whose constructor accepts undici's agent options.\n */\nfunction constructHttp1(agent: unknown): object | undefined {\n\ttry {\n\t\t// No shape guard ahead of this: `Reflect.get` already rejects a\n\t\t// primitive, `null`, and an absent key, so every malformed value lands\n\t\t// in the same catch.\n\t\tconst agentClass = Reflect.get(agent, \"constructor\");\n\t\tif (!isAgentConstructor(agentClass)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst dispatcher = Reflect.construct(agentClass, [{ allowH2: false }]);\n\t\treturn typeof Reflect.get(dispatcher, \"dispatch\") === \"function\" ? dispatcher : undefined;\n\t} catch {\n\t\t// An internal contract that moved under us is not worth failing a\n\t\t// deploy over: fall back to the runtime's default transport.\n\t\treturn undefined;\n\t}\n}\n","/**\n * A point-in-time rate-limit budget reading parsed from Roblox Open Cloud\n * response headers. Both fields are non-negative integers.\n */\nexport interface RateLimitSample {\n\t/**\n\t * Requests still allowed in the current window (the most-constrained one).\n\t */\n\treadonly remaining: number;\n\t/** Seconds until the most-constrained window resets to full. */\n\treadonly resetSeconds: number;\n}\n\nconst NON_NEGATIVE_INTEGER_PATTERN = /^\\d+$/;\n\n/**\n * Reduces a comma-separated rate-limit header value (e.g. `\"0, 70000\"`) to a\n * single non-negative integer via `combine`. Tokens are trimmed; blank,\n * fractional, negative, and non-finite tokens are dropped so a stray value\n * cannot corrupt the result. Returns `undefined` when the header is absent or\n * has no valid tokens.\n *\n * @param headerValue - The raw header value, or `undefined` if missing.\n * @param combine - Pairwise reducer, `Math.min` for remaining, `Math.max` for reset.\n * @returns The reduced value, or `undefined`.\n */\nexport function reduceRateLimitTokens(\n\theaderValue: string | undefined,\n\tcombine: (a: number, b: number) => number,\n): number | undefined {\n\tif (headerValue === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst tokens = headerValue\n\t\t.split(\",\")\n\t\t.map((part) => part.trim())\n\t\t.filter((part) => NON_NEGATIVE_INTEGER_PATTERN.test(part))\n\t\t.map((part) => Number(part))\n\t\t.filter((value) => Number.isInteger(value));\n\tif (tokens.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn tokens.reduce(combine);\n}\n\n/**\n * Parses the `x-ratelimit-remaining` and `x-ratelimit-reset` response headers\n * into a {@link RateLimitSample}. Each header may carry a comma-separated list\n * of per-window values; `remaining` takes the smallest (most constrained) and\n * `resetSeconds` takes the largest (longest wait). Returns `undefined` when\n * either header is missing or has no valid non-negative integer tokens, so a\n * caller can fall back to static pacing.\n *\n * @param headers - Response headers with lowercased keys.\n * @returns The parsed sample, or `undefined` when the budget cannot be read.\n */\nexport function parseRateLimitHeaders(\n\theaders: Readonly<Record<string, string>>,\n): RateLimitSample | undefined {\n\tconst remaining = reduceRateLimitTokens(headers[\"x-ratelimit-remaining\"], (a, b) => {\n\t\treturn Math.min(a, b);\n\t});\n\tconst resetSeconds = reduceRateLimitTokens(headers[\"x-ratelimit-reset\"], (a, b) => {\n\t\treturn Math.max(a, b);\n\t});\n\tif (remaining === undefined || resetSeconds === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn { remaining, resetSeconds };\n}\n","import { reduceRateLimitTokens } from \"./rate-limit-sample.ts\";\n\nconst ABBREVIATED_WEEKDAYS: ReadonlyArray<string> = [\n\t\"Sun\",\n\t\"Mon\",\n\t\"Tue\",\n\t\"Wed\",\n\t\"Thu\",\n\t\"Fri\",\n\t\"Sat\",\n];\nconst ANSI_DATE_PATTERN =\n\t/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \\d|\\d{2}) (\\d{2}):(\\d{2}):(\\d{2}) (\\d{4})$/;\nconst DELAY_SECONDS_PATTERN = /^\\d+$/;\nconst FIXED_DATE_PATTERN =\n\t/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\\d{4}) (\\d{2}):(\\d{2}):(\\d{2}) GMT$/;\nconst FULL_WEEKDAY_TO_ABBREVIATED: Readonly<Record<string, string>> = {\n\tFriday: \"Fri\",\n\tMonday: \"Mon\",\n\tSaturday: \"Sat\",\n\tSunday: \"Sun\",\n\tThursday: \"Thu\",\n\tTuesday: \"Tue\",\n\tWednesday: \"Wed\",\n};\nconst MONTHS: ReadonlyArray<string> = [\n\t\"Jan\",\n\t\"Feb\",\n\t\"Mar\",\n\t\"Apr\",\n\t\"May\",\n\t\"Jun\",\n\t\"Jul\",\n\t\"Aug\",\n\t\"Sep\",\n\t\"Oct\",\n\t\"Nov\",\n\t\"Dec\",\n];\nconst OBSOLETE_DATE_PATTERN =\n\t/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2}) GMT$/;\n\ninterface HttpDateParts {\n\treadonly day: number;\n\treadonly hour: number;\n\treadonly minute: number;\n\treadonly month: number;\n\treadonly second: number;\n\treadonly weekday: string;\n\treadonly year: number;\n}\n\ninterface ResolveRetryGuidanceOptions {\n\treadonly headers: Readonly<Record<string, string>>;\n\treadonly nowMs?: number;\n\treadonly remaining: number | undefined;\n}\n\n/**\n * Parses `x-ratelimit-reset` as seconds until quota replenishment. Roblox can\n * report multiple comma-separated windows; the longest valid window is the\n * earliest safe quota retry.\n *\n * @param headerValue - The raw reset value, or `undefined` if missing.\n * @returns The longest reset delay, or `undefined` when absent or invalid.\n */\nexport function parseQuotaResetSeconds(headerValue: string | undefined): number | undefined {\n\treturn reduceRateLimitTokens(headerValue, (a, b) => Math.max(a, b));\n}\n\n/**\n * Parses the standard `Retry-After` header. RFC 9110 permits either a\n * non-negative integer number of seconds or any HTTP-date form. A date is\n * rounded up so a retry never starts before the server's stated instant.\n *\n * @param headerValue - The raw `Retry-After` value, or `undefined` if missing.\n * @param nowMs - Current Unix time in milliseconds, injectable for tests.\n * @returns The delay in seconds, or `undefined` when absent or invalid.\n */\nexport function parseRetryAfterSeconds(\n\theaderValue: string | undefined,\n\tnowMs = Date.now(),\n): number | undefined {\n\tif (headerValue === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst value = headerValue.trim();\n\tif (DELAY_SECONDS_PATTERN.test(value)) {\n\t\tconst seconds = Number(value);\n\t\treturn Number.isFinite(seconds) ? seconds : undefined;\n\t}\n\n\tconst retryAt = parseHttpDate(value, nowMs);\n\treturn retryAt === undefined ? undefined : Math.max(0, Math.ceil((retryAt - nowMs) / 1000));\n}\n\n/**\n * Chooses the applicable server-directed delay for one 429 response.\n *\n * @param options - Response headers, remaining quota, and optional clock.\n * @returns The delay in seconds, or `undefined` when caller backoff applies.\n */\nexport function resolveRetryGuidance({\n\theaders,\n\tnowMs,\n\tremaining,\n}: ResolveRetryGuidanceOptions): number | undefined {\n\tconst retryAfter = parseRetryAfterSeconds(headers[\"retry-after\"], nowMs);\n\tif (remaining !== 0) {\n\t\treturn retryAfter;\n\t}\n\n\tconst quotaReset = parseQuotaResetSeconds(headers[\"x-ratelimit-reset\"]);\n\treturn quotaReset === undefined ? retryAfter : Math.max(retryAfter ?? 0, quotaReset);\n}\n\nfunction httpDateTimestamp(parts: HttpDateParts): number | undefined {\n\tif (parts.minute > 59 || parts.second > 59) {\n\t\treturn undefined;\n\t}\n\n\tconst date = new Date(0);\n\tdate.setUTCFullYear(parts.year, parts.month, parts.day);\n\tdate.setUTCHours(parts.hour, parts.minute, parts.second, 0);\n\n\tconst isExactDate =\n\t\tdate.getUTCDate() === parts.day && ABBREVIATED_WEEKDAYS[date.getUTCDay()] === parts.weekday;\n\treturn isExactDate ? date.getTime() : undefined;\n}\n\nfunction parseAnsiDate(value: string): number | undefined {\n\tconst match = ANSI_DATE_PATTERN.exec(value);\n\treturn match === null\n\t\t? undefined\n\t\t: httpDateTimestamp({\n\t\t\t\tday: Number(match[3]),\n\t\t\t\thour: Number(match[4]),\n\t\t\t\tminute: Number(match[5]),\n\t\t\t\tmonth: MONTHS.indexOf(String(match[2])),\n\t\t\t\tsecond: Number(match[6]),\n\t\t\t\tweekday: String(match[1]),\n\t\t\t\tyear: Number(match[7]),\n\t\t\t});\n}\n\nfunction parseFixedDate(value: string): number | undefined {\n\tconst match = FIXED_DATE_PATTERN.exec(value);\n\treturn match === null\n\t\t? undefined\n\t\t: httpDateTimestamp({\n\t\t\t\tday: Number(match[2]),\n\t\t\t\thour: Number(match[5]),\n\t\t\t\tminute: Number(match[6]),\n\t\t\t\tmonth: MONTHS.indexOf(String(match[3])),\n\t\t\t\tsecond: Number(match[7]),\n\t\t\t\tweekday: String(match[1]),\n\t\t\t\tyear: Number(match[4]),\n\t\t\t});\n}\n\nfunction parseObsoleteDate(value: string, nowMs: number): number | undefined {\n\tconst match = OBSOLETE_DATE_PATTERN.exec(value);\n\tif (match === null) {\n\t\treturn undefined;\n\t}\n\n\tconst currentDate = new Date(nowMs);\n\tconst currentYear = currentDate.getUTCFullYear();\n\tlet year = Math.floor(currentYear / 100) * 100 + Number(match[4]);\n\tif (year > currentYear + 50) {\n\t\tyear -= 100;\n\t}\n\n\treturn httpDateTimestamp({\n\t\tday: Number(match[2]),\n\t\thour: Number(match[5]),\n\t\tminute: Number(match[6]),\n\t\tmonth: MONTHS.indexOf(String(match[3])),\n\t\tsecond: Number(match[7]),\n\t\tweekday: String(FULL_WEEKDAY_TO_ABBREVIATED[String(match[1])]),\n\t\tyear,\n\t});\n}\n\nfunction parseHttpDate(value: string, nowMs: number): number | undefined {\n\treturn parseFixedDate(value) ?? parseObsoleteDate(value, nowMs) ?? parseAnsiDate(value);\n}\n","import { markServerRetryGuidance, RateLimitError } from \"../../errors/rate-limit.ts\";\nimport { headersToRecord, pickRateLimitHeaders } from \"./diagnostics.ts\";\nimport { reduceRateLimitTokens } from \"./rate-limit-sample.ts\";\nimport { resolveRetryGuidance } from \"./retry-guidance.ts\";\n\n/**\n * Builds a public rate-limit error from a 429 response and its already-read\n * body, retaining safe raw evidence alongside the existing parsed guidance.\n *\n * @param response - The 429 response to classify.\n * @param details - The parsed or safely truncated response body.\n * @returns A rate-limit error carrying the response evidence.\n */\nexport function createRateLimitError(\n\tresponse: Response,\n\tdetails: JSONValue | undefined,\n): RateLimitError {\n\tconst headers = headersToRecord(response.headers);\n\tconst remaining = reduceRateLimitTokens(headers[\"x-ratelimit-remaining\"], (a, b) => {\n\t\treturn Math.min(a, b);\n\t});\n\tconst guidedRetrySeconds = resolveRetryGuidance({ headers, remaining });\n\tconst error = new RateLimitError(\"Rate limited\", {\n\t\tcode: extractRateLimitErrorCode(details),\n\t\tdetails,\n\t\tremaining,\n\t\tresponseHeaders: pickRateLimitHeaders(headers),\n\t\tretryAfterSeconds: guidedRetrySeconds ?? 0,\n\t\tstatusCode: response.status,\n\t});\n\treturn guidedRetrySeconds === undefined ? error : markServerRetryGuidance(error);\n}\n\nfunction extractRateLimitErrorCode(body: unknown): string | undefined {\n\tif (body === null || typeof body !== \"object\") {\n\t\treturn undefined;\n\t}\n\n\tconst code = Reflect.get(body, \"code\");\n\treturn typeof code === \"string\" && code.trim() ? code : undefined;\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RequestAbortedError}.\n *\n * @since 0.3.1\n */\nexport interface RequestAbortedErrorOptions extends ErrorOptions {\n\t/** Whatever `AbortSignal.reason` was at the moment of cancellation. */\n\treadonly reason?: unknown;\n}\n\n/**\n * Returned when a caller's `AbortSignal` cancels an Open Cloud request.\n * The reason is preserved so intentional cancellation can be distinguished\n * from transport failures and SDK-owned request timeouts.\n *\n * @since 0.3.1\n *\n * @example\n *\n * ```ts\n * import { RequestAbortedError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new RequestAbortedError(\"Request was aborted\", {\n * reason: \"superseded\",\n * });\n *\n * expect(error).toBeInstanceOf(RequestAbortedError);\n * expect(error.reason).toBe(\"superseded\");\n * ```\n */\nexport class RequestAbortedError extends OpenCloudError {\n\tpublic override readonly name: string = \"RequestAbortedError\";\n\tpublic readonly reason?: unknown;\n\n\t/**\n\t * Creates a new RequestAbortedError.\n\t *\n\t * @param message - Human-readable description of the cancellation.\n\t * @param options - Error options including the caller's abort reason.\n\t */\n\tconstructor(message: string, options: RequestAbortedErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.reason = options.reason;\n\t}\n}\n","import { RequestAbortedError } from \"../../errors/request-aborted.ts\";\n\n/**\n * Sentinel returned when an asynchronous operation loses a race with a signal.\n */\nexport const ABORTED = Symbol(\"aborted\");\n\n/**\n * Result of an operation raced against an optional caller signal.\n *\n * @template T - Value produced when the operation wins the race.\n */\nexport type AbortableResult<T> = T | typeof ABORTED;\n\n/**\n * Runs an asynchronous operation and resolves with {@link ABORTED} when the\n * supplied signal fires first. The underlying operation still receives the\n * signal separately so cancellable implementations can release their work.\n *\n * @template T - Value produced by the operation.\n * @param operation - Operation to start after the abort observer is installed.\n * @param signal - Optional caller cancellation signal.\n * @returns The operation's value, or {@link ABORTED} when cancellation wins.\n * @rejects The operation's error when it fails before cancellation.\n */\nexport async function raceWithAbortAsync<T>(\n\toperation: () => Promise<T>,\n\tsignal: AbortSignal | undefined,\n): Promise<AbortableResult<T>> {\n\tif (signal === undefined) {\n\t\treturn operation();\n\t}\n\n\tif (signal.aborted) {\n\t\treturn ABORTED;\n\t}\n\n\tconst { promise, resolve } = Promise.withResolvers<typeof ABORTED>();\n\tfunction onAbort(): void {\n\t\tresolve(ABORTED);\n\t}\n\n\tsignal.addEventListener(\"abort\", onAbort);\n\ttry {\n\t\treturn await Promise.race([operation(), promise]);\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\n/**\n * Creates the canonical typed failure for caller-request cancellation.\n *\n * @param signal - The caller signal whose reason should be preserved.\n * @returns A cancellation error carrying the signal's reason.\n */\nexport function requestAbortedError(signal: AbortSignal | undefined): RequestAbortedError {\n\treturn new RequestAbortedError(\"Request was aborted\", { reason: signal?.reason });\n}\n","import { NetworkError } from \"../../errors/network-error.ts\";\nimport type { RequestAbortedError } from \"../../errors/request-aborted.ts\";\nimport { requestAbortedError } from \"../utils/abort.ts\";\nimport type { RequestConfig } from \"./types.ts\";\n\ninterface RequestFailureArgs {\n\treadonly cause: Error;\n\treadonly config: RequestConfig;\n\treadonly effectiveSignal: AbortSignal | null | undefined;\n\treadonly target: { readonly method: string; readonly url: string };\n}\n\n/**\n * Composes caller cancellation with Ocale's transport-attempt timeout. The\n * winning signal's reason is retained by `AbortSignal.any`, allowing failure\n * classification to distinguish cancellation from timeout.\n *\n * @param config - Transport configuration for one request.\n * @returns A caller signal, timeout signal, their composition, or `undefined`.\n */\nexport function requestSignal(config: RequestConfig): AbortSignal | undefined {\n\tif (config.timeout === undefined) {\n\t\treturn config.signal;\n\t}\n\n\tconst timeout = AbortSignal.timeout(config.timeout);\n\treturn config.signal === undefined ? timeout : AbortSignal.any([config.signal, timeout]);\n}\n\n/**\n * Classifies a fetch rejection without confusing a caller abort with the\n * transport's own timeout.\n *\n * @param args - Failure, target, request config, and effective fetch signal.\n * @returns A typed caller cancellation or network failure.\n */\nexport function requestFailure({\n\tcause,\n\tconfig,\n\teffectiveSignal,\n\ttarget,\n}: RequestFailureArgs): NetworkError | RequestAbortedError {\n\tif (\n\t\tconfig.signal?.aborted === true &&\n\t\teffectiveSignal?.aborted === true &&\n\t\tObject.is(effectiveSignal.reason, config.signal.reason)\n\t) {\n\t\treturn requestAbortedError(config.signal);\n\t}\n\n\treturn new NetworkError(\"Network request failed\", {\n\t\tcause,\n\t\tmethod: target.method,\n\t\turl: target.url,\n\t});\n}\n","import type { HttpRequest } from \"../../client/types.ts\";\n\n/**\n * Reports whether a request is an upload: its body is `FormData`\n * (multipart) or `Uint8Array` (raw binary). Upload latency is\n * bandwidth-bound rather than compute-bound, so the SDK applies no default\n * request timeout to these requests; a sensible wall-clock budget depends on\n * payload size and link quality the SDK cannot know.\n *\n * @param request - The built request to classify.\n * @returns `true` when the body is `FormData` or `Uint8Array`.\n */\nexport function isUploadRequest(request: HttpRequest): boolean {\n\treturn request.body instanceof FormData || request.body instanceof Uint8Array;\n}\n","import { ApiError } from \"../../errors/api-error.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { tryCatchAsync } from \"../utils/try-catch.ts\";\nimport {\n\tbodyDetail,\n\textractGatewaySummary,\n\theadersToRecord,\n\tparseFailureError,\n\tpickDiagnosticHeaders,\n\ttype RequestContext,\n} from \"./diagnostics.ts\";\nimport { extractErrorCode, extractErrorMessage } from \"./error-body.ts\";\nimport { createHttp1Dispatcher } from \"./http1-dispatcher.ts\";\nimport { createRateLimitError } from \"./rate-limit-response.ts\";\nimport { requestFailure, requestSignal } from \"./request-signal.ts\";\nimport type { HttpClient, HttpRequest, HttpResponse, RequestConfig } from \"./types.ts\";\nimport { isUploadRequest } from \"./upload-request.ts\";\n\nconst CONTENT_TYPE_HEADER = \"content-type\";\n\n// Uploads opt out of keep-alive reuse. Roblox's edge gateway discards idle\n// pooled connections faster than a pooling `fetch` expects, and a request\n// written into a discarded connection never reaches Open Cloud: it surfaces as\n// a gateway error page or a socket reset, minutes later, having done nothing.\n// An upload holds a connection far longer than a JSON call, so it is the shape\n// that loses this race. The cost is a fresh handshake and a cold congestion\n// window per upload (real for a multi-megabyte body, and paid again on each\n// retry), but cheaper than a lost write. Small, frequent calls keep pooling.\nconst CONNECTION_HEADER = \"connection\";\n\n/**\n * `RequestInit` plus undici's non-standard `dispatcher`, the only way to\n * select a transport from `fetch`. Declared locally because it is absent from\n * the DOM lib and runtimes that do not understand it ignore it.\n */\ninterface FetchOptions extends RequestInit {\n\tdispatcher?: object | undefined;\n}\n\n/**\n * Collaborators of {@link createFetchHttpClient}, bundled so the factory keeps\n * a two-argument signature as they accumulate. Both have production defaults;\n * both are overridable, which is also what makes them testable.\n */\ninterface FetchHttpClientSeams {\n\t/**\n\t * Builds the HTTP/1.1-only transport uploads use, so the\n\t * `connection: close` directive is not dropped by an h2 transport.\n\t */\n\treadonly createDispatcher?: () => object | undefined;\n\t/** Monotonic-ish clock used to measure request elapsed time. */\n\treadonly now?: () => number;\n}\n\ninterface SendRequestArgs {\n\treadonly config: RequestConfig;\n\treadonly dispatcherFor: (request: HttpRequest) => object | undefined;\n\treadonly fetchFunc: (url: string, init: RequestInit) => Promise<Response>;\n\treadonly httpRequest: HttpRequest;\n\treadonly now: () => number;\n}\n\ninterface ErrorResponseArgs {\n\treadonly context: RequestContext;\n\treadonly parsed: Result<JSONValue | undefined>;\n\treadonly rawText: string;\n\treadonly response: Response;\n}\n\ninterface ApiErrorMessageParts {\n\treadonly code: string | undefined;\n\treadonly message: string | undefined;\n\treadonly status: number;\n}\n\n/**\n * Joins the base URL from config with the relative path from the request.\n *\n * @param request - The HTTP request containing the relative URL.\n * @param config - The request config containing the base URL.\n * @returns The fully-qualified URL string.\n */\nexport function buildUrl(request: HttpRequest, config: RequestConfig): string {\n\tconst base = config.baseUrl.endsWith(\"/\") ? config.baseUrl.slice(0, -1) : config.baseUrl;\n\treturn `${base}${request.url}`;\n}\n\n/**\n * Constructs the `RequestInit` options for a `fetch` call.\n *\n * @param request - The HTTP request to build options for.\n * @param config - The request config containing API key and timeout.\n * @returns A `RequestInit` object ready for `fetch`.\n */\nexport function buildFetchOptions(request: HttpRequest, config: RequestConfig): FetchOptions {\n\tconst headers = new Headers({\n\t\t\"x-api-key\": config.apiKey,\n\t});\n\n\tconst options: FetchOptions = {\n\t\theaders,\n\t\tmethod: request.method,\n\t};\n\n\tif (request.body instanceof FormData) {\n\t\toptions.body = request.body;\n\t} else if (request.body instanceof Uint8Array) {\n\t\theaders.set(CONTENT_TYPE_HEADER, \"application/octet-stream\");\n\t\toptions.body = request.body;\n\t} else if (request.body !== undefined) {\n\t\theaders.set(CONTENT_TYPE_HEADER, \"application/json\");\n\t\toptions.body = JSON.stringify(request.body);\n\t}\n\n\tapplyRequestHeaders(headers, request);\n\n\tconst signal = requestSignal(config);\n\tif (signal !== undefined) {\n\t\toptions.signal = signal;\n\t}\n\n\treturn options;\n}\n\n/**\n * Creates an {@link HttpClient} backed by the Fetch API.\n *\n * @param fetchFunc - The fetch implementation to use. Defaults to `globalThis.fetch`.\n * @param seams - Injectable clock and dispatcher factory, so tests need not\n * depend on wall-clock time or on the runtime's global dispatcher.\n * @returns An HttpClient that classifies responses into typed Results.\n */\nexport function createFetchHttpClient(\n\tfetchFunc: (url: string, init: RequestInit) => Promise<Response> = fetch,\n\t{ createDispatcher = createHttp1Dispatcher, now = Date.now }: FetchHttpClientSeams = {},\n): HttpClient {\n\tconst dispatcherFor = createUploadDispatcherCache(createDispatcher);\n\n\treturn {\n\t\tasync request(httpRequest, config) {\n\t\t\treturn sendRequestAsync({ config, dispatcherFor, fetchFunc, httpRequest, now });\n\t\t},\n\t};\n}\n\n/**\n * Merges the request's own headers onto the transport's, then applies the\n * transport-owned connection directive. `x-api-key` is skipped so a request\n * cannot override the configured credential, and the upload directive is set\n * last so a request header cannot silently re-enable pooling for an upload.\n *\n * @param headers - The headers being built for the fetch call. Mutated.\n * @param request - The request whose headers and body shape drive the merge.\n */\nfunction applyRequestHeaders(headers: Headers, request: HttpRequest): void {\n\tconst requestHeaders = request.headers ?? {};\n\tfor (const [name, value] of Object.entries(requestHeaders)) {\n\t\tif (name.toLowerCase() === \"x-api-key\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\theaders.set(name, value);\n\t}\n\n\tif (isUploadRequest(request)) {\n\t\theaders.set(CONNECTION_HEADER, \"close\");\n\t}\n}\n\nfunction failureResult(args: Parameters<typeof requestFailure>[0]): Result<never, OpenCloudError> {\n\treturn { err: requestFailure(args), success: false };\n}\n\n/**\n * Runs `send` and reports both its Result and how long it was in flight,\n * measured with `now`. Isolated so the timing start need not sit in the request\n * body ahead of the transport-failure early return.\n *\n * @param now - The clock used to bound the call.\n * @param send - A thunk that issues the fetch.\n * @returns The fetch Result and the elapsed milliseconds.\n */\nasync function timedFetchAsync(\n\tnow: () => number,\n\tsend: () => Promise<Response>,\n): Promise<{ elapsedMs: number; fetchResult: Result<Response> }> {\n\tconst start = now();\n\tconst fetchResult = await tryCatchAsync(send());\n\t// Clamp to zero: `Date.now` is wall-clock, so an NTP adjustment mid-request\n\t// could otherwise report a negative \"after -0.1s\".\n\treturn { elapsedMs: Math.max(0, now() - start), fetchResult };\n}\n\nfunction formatApiErrorMessage({ code, message, status }: ApiErrorMessageParts): string {\n\tconst base = `HTTP ${status}`;\n\tif (message === undefined && code === undefined) {\n\t\treturn base;\n\t}\n\n\tif (message === undefined) {\n\t\treturn `${base} (code ${code})`;\n\t}\n\n\tif (code === undefined) {\n\t\treturn `${base}: ${message}`;\n\t}\n\n\treturn `${base}: ${message} (code ${code})`;\n}\n\nfunction createApiError(args: ErrorResponseArgs): ApiError {\n\tconst { context, rawText, response } = args;\n\tconst { status } = response;\n\tconst headers = headersToRecord(response.headers);\n\tconst requestContext = {\n\t\telapsedMs: context.elapsedMs,\n\t\tmethod: context.method,\n\t\tresponseHeaders: pickDiagnosticHeaders(headers),\n\t\tstatusCode: status,\n\t\turl: context.url,\n\t};\n\n\t// An HTML body is a load-balancer error page, not an Open Cloud response;\n\t// summarize it rather than retaining the raw HTML on `details`.\n\tconst gatewaySummary = extractGatewaySummary(headers[CONTENT_TYPE_HEADER], rawText);\n\tif (gatewaySummary !== undefined) {\n\t\treturn new ApiError(`HTTP ${status}`, { ...requestContext, gatewaySummary });\n\t}\n\n\tconst body = bodyDetail(rawText, args.parsed);\n\tconst code = extractErrorCode(body);\n\tconst message = extractErrorMessage(body);\n\treturn new ApiError(formatApiErrorMessage({ code, message, status }), {\n\t\t...requestContext,\n\t\tcode,\n\t\tdetails: body,\n\t});\n}\n\n/**\n * Parses response text as JSON, returning the underlying `SyntaxError` on\n * failure rather than throwing. The synchronous sibling of {@link\n * tryCatchAsync}.\n *\n * @param text - The raw response body text.\n * @returns A Result wrapping the parsed value, or the parse error.\n */\nfunction parseJson(text: string): Result<JSONValue> {\n\ttry {\n\t\treturn { data: JSON.parse(text), success: true };\n\t} catch (err) {\n\t\treturn { err: err instanceof Error ? err : new Error(String(err)), success: false };\n\t}\n}\n\n/**\n * Reads a response body once and parses it best-effort: an empty body is a\n * successful `undefined`, otherwise the JSON parse result (which carries the\n * `SyntaxError` on failure). Returns the raw `text` alongside so callers that\n * need the original bytes (parse-failure diagnostics) do not re-read the\n * consumed stream.\n *\n * @param response - The Response whose body to read.\n * @returns The parse result and the raw text.\n */\nasync function readResponseBodyAsync(\n\tresponse: Response,\n): Promise<{ parsed: Result<JSONValue | undefined>; text: string }> {\n\tconst text = await response.text();\n\treturn {\n\t\tparsed: text === \"\" ? { data: undefined, success: true } : parseJson(text),\n\t\ttext,\n\t};\n}\n\n/**\n * Classifies a fetch `Response` into a typed `Result`.\n *\n * The body is read once and parsed best-effort. Error responses (status >= 300)\n * never require valid JSON: an error body that is not valid JSON degrades to a\n * status-based {@link ApiError} carrying the raw text, and an HTML gateway page\n * is summarized rather than dumped. A parse failure is only fatal on a 2xx,\n * where a parseable body is part of the contract.\n *\n * @param response - The raw fetch Response to classify.\n * @param context - The request context (method, url, elapsed time) threaded\n * onto every {@link ApiError} built here, whether for an error response or\n * for a 2xx whose body would not parse.\n * @returns A Result containing an HttpResponse on success or an OpenCloudError on failure.\n */\nasync function classifyResponseAsync(\n\tresponse: Response,\n\tcontext: RequestContext,\n): Promise<Result<HttpResponse, OpenCloudError>> {\n\tconst { parsed, text } = await readResponseBodyAsync(response);\n\n\tif (response.status === 429) {\n\t\treturn { err: createRateLimitError(response, bodyDetail(text, parsed)), success: false };\n\t}\n\n\tif (response.status >= 300) {\n\t\treturn {\n\t\t\terr: createApiError({ context, parsed, rawText: text, response }),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tif (!parsed.success) {\n\t\treturn {\n\t\t\terr: parseFailureError({ cause: parsed.err, context, response, text }),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbody: parsed.data,\n\t\t\theaders: headersToRecord(response.headers),\n\t\t\tstatus: response.status,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nasync function sendRequestAsync({\n\tconfig,\n\tdispatcherFor,\n\tfetchFunc,\n\thttpRequest,\n\tnow,\n}: SendRequestArgs): Promise<Result<HttpResponse, OpenCloudError>> {\n\tconst url = buildUrl(httpRequest, config);\n\tconst options = buildFetchOptions(httpRequest, config);\n\toptions.dispatcher = dispatcherFor(httpRequest);\n\tconst target = { method: httpRequest.method, url };\n\tconst { elapsedMs, fetchResult } = await timedFetchAsync(now, async () => {\n\t\treturn fetchFunc(url, options);\n\t});\n\tif (!fetchResult.success) {\n\t\treturn failureResult({\n\t\t\tcause: fetchResult.err,\n\t\t\tconfig,\n\t\t\teffectiveSignal: options.signal,\n\t\t\ttarget,\n\t\t});\n\t}\n\n\tconst context: RequestContext = { elapsedMs, method: target.method, url: target.url };\n\tconst classified = await tryCatchAsync(classifyResponseAsync(fetchResult.data, context));\n\treturn classified.success\n\t\t? classified.data\n\t\t: failureResult({ cause: classified.err, config, effectiveSignal: options.signal, target });\n}\n\n/**\n * Wraps a dispatcher factory in the caching policy uploads need.\n *\n * Resolution happens on the first upload rather than at construction: undici\n * publishes its global dispatcher lazily, so before a process's first `fetch`\n * there is nothing to read. A resolved dispatcher is kept, and an unresolved\n * one is retried on the next upload — so a runtime that publishes late is\n * still picked up, and the first request of a process, which has no pooled\n * connection to lose, is safe either way.\n *\n * @param createDispatcher - Builds the HTTP/1.1-only transport.\n * @returns A function yielding the dispatcher for a request, or `undefined`\n * when the request is not an upload or no dispatcher is available.\n */\nfunction createUploadDispatcherCache(\n\tcreateDispatcher: () => object | undefined,\n): (request: HttpRequest) => object | undefined {\n\tlet cached: object | undefined;\n\treturn (request) => {\n\t\tif (!isUploadRequest(request)) {\n\t\t\treturn;\n\t\t}\n\n\t\tcached ??= createDispatcher();\n\t\treturn cached;\n\t};\n}\n","import { ApiError, type ApiErrorOptions } from \"./api-error.ts\";\n\n/**\n * Options for constructing a {@link PermissionError}.\n *\n * @since 0.1.0\n */\nexport interface PermissionErrorOptions extends ApiErrorOptions {\n\t/**\n\t * Stable identifier of the Open Cloud operation that returned the\n\t * permission failure (matches `OperationLimit.operationKey`, e.g.\n\t * `\"developer-products.create\"`).\n\t */\n\toperationKey: string;\n\t/**\n\t * Scope strings the API key or OAuth token must carry for the failing\n\t * operation, sourced from the vendored OpenAPI schema's `x-roblox-scopes`\n\t * for that operationId.\n\t */\n\trequiredScopes: ReadonlyArray<string>;\n}\n\n/**\n * Thrown when the Roblox Open Cloud API returns a 401 or 403 for an operation\n * whose required scopes are known. Subclass of {@link ApiError} carrying the\n * scope strings the operation requires plus the operation key, so a consumer\n * can name them when guiding the user to their API key settings.\n *\n * The scopes are what the operation needs, not a diagnosis of what the\n * credential lacks: a 403 does mean the scopes fall short, but Roblox also\n * answers 401 for a key that is invalid, disabled, or expired. Check\n * {@link ApiError.statusCode} before wording the failure as a missing scope.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { PermissionError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new PermissionError(\"HTTP 403\", {\n * operationKey: \"developer-products.create\",\n * requiredScopes: [\"creator-store-product:write\"],\n * statusCode: 403,\n * });\n *\n * expect(error).toBeInstanceOf(PermissionError);\n * expect(error.requiredScopes).toStrictEqual([\"creator-store-product:write\"]);\n * expect(error.operationKey).toBe(\"developer-products.create\");\n * ```\n */\nexport class PermissionError extends ApiError {\n\tpublic override readonly name: string = \"PermissionError\";\n\tpublic readonly operationKey: string;\n\tpublic readonly requiredScopes: ReadonlyArray<string>;\n\n\t/**\n\t * Creates a new PermissionError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including status code, the operation key,\n\t * and the scopes the caller's credential must carry.\n\t */\n\tconstructor(message: string, options: PermissionErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.operationKey = options.operationKey;\n\t\tthis.requiredScopes = options.requiredScopes;\n\t}\n}\n","import type { AdmissionWaitReason } from \"../client/types.ts\";\nimport { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RequestDeadlineExceededError}.\n *\n * @since 0.3.2\n */\nexport interface RequestDeadlineExceededErrorOptions extends ErrorOptions {\n\t/** Absolute caller-supplied deadline, as Unix epoch milliseconds. */\n\treadonly deadlineMs: number;\n\t/** Time left when the SDK refused or ended the wait. */\n\treadonly remainingMs: number;\n\t/** Intended wait duration, when it was known before waiting. */\n\treadonly waitMs?: number | undefined;\n\t/** SDK admission mechanism whose wait could not meet the deadline. */\n\treadonly waitReason?: AdmissionWaitReason | undefined;\n}\n\n/**\n * Returned when a logical request cannot complete by its absolute deadline.\n * Optional wait details identify an SDK-managed admission wait that was\n * refused. This is distinct from caller cancellation so consumers can report\n * exhausted wall-clock budget accurately.\n *\n * @since 0.3.2\n *\n * @example\n *\n * ```ts\n * import { RequestDeadlineExceededError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new RequestDeadlineExceededError(\"Request deadline elapsed\", {\n * deadlineMs: 1_000_000,\n * remainingMs: 0,\n * waitReason: \"operation-queue\",\n * });\n *\n * expect(error.remainingMs).toBe(0);\n * expect(error.waitReason).toBe(\"operation-queue\");\n * ```\n */\nexport class RequestDeadlineExceededError extends OpenCloudError {\n\t/** Absolute caller-supplied deadline, as Unix epoch milliseconds. */\n\tpublic readonly deadlineMs: number;\n\tpublic override readonly name: string = \"RequestDeadlineExceededError\";\n\t/** Time left when the SDK refused or ended the wait. */\n\tpublic readonly remainingMs: number;\n\t/** Intended wait duration, when known. */\n\tpublic readonly waitMs: number | undefined;\n\t/** SDK admission mechanism whose wait could not meet the deadline. */\n\tpublic readonly waitReason: AdmissionWaitReason | undefined;\n\n\t/**\n\t * Creates a new RequestDeadlineExceededError.\n\t *\n\t * @param message - Human-readable description of the exhausted deadline.\n\t * @param options - Deadline, remaining budget, and optional wait details.\n\t */\n\tconstructor(message: string, options: RequestDeadlineExceededErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.deadlineMs = options.deadlineMs;\n\t\tthis.remainingMs = options.remainingMs;\n\t\tthis.waitMs = options.waitMs;\n\t\tthis.waitReason = options.waitReason;\n\t}\n}\n","import { RequestDeadlineExceededError } from \"./request-deadline-exceeded.ts\";\n\n/**\n * Options for constructing a {@link RetryDelayExceededError}.\n *\n * @since 0.3.2\n */\nexport interface RetryDelayExceededErrorOptions extends ErrorOptions {\n\t/** Absolute caller-supplied deadline, as Unix epoch milliseconds. */\n\treadonly deadlineMs: number;\n\t/** Time left when the SDK refused the retry delay. */\n\treadonly remainingMs: number;\n\t/** Computed retry delay that could not fit before the deadline. */\n\treadonly retryAfterMs: number;\n}\n\n/**\n * Returned when the SDK refuses a retry delay that cannot complete before the\n * request deadline. This is distinct from cancellation so consumers can\n * report the server's stated retry time without waiting for it.\n *\n * @since 0.3.2\n *\n * @example\n *\n * ```ts\n * import { RetryDelayExceededError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new RetryDelayExceededError(\"Retry delay exceeds the request deadline\", {\n * deadlineMs: 1_000_000,\n * remainingMs: 495_000,\n * retryAfterMs: 1_856_000,\n * });\n *\n * expect(error.retryAfterMs).toBe(1_856_000);\n * expect(error.remainingMs).toBe(495_000);\n * ```\n */\nexport class RetryDelayExceededError extends RequestDeadlineExceededError {\n\tpublic override readonly name: string = \"RetryDelayExceededError\";\n\t/** Computed retry delay refused by the SDK, in milliseconds. */\n\tpublic readonly retryAfterMs: number;\n\t/** Computed retry delay refused by the SDK, in seconds. */\n\tpublic readonly retryAfterSeconds: number;\n\n\t/**\n\t * Creates a new RetryDelayExceededError.\n\t *\n\t * @param message - Human-readable description of the refused retry delay.\n\t * @param options - Refused delay, deadline budget, and original failure.\n\t */\n\tconstructor(message: string, options: RetryDelayExceededErrorOptions) {\n\t\tsuper(message, {\n\t\t\t...options,\n\t\t\twaitMs: options.retryAfterMs,\n\t\t\twaitReason: \"retry-delay\",\n\t\t});\n\t\tthis.retryAfterMs = options.retryAfterMs;\n\t\tthis.retryAfterSeconds = options.retryAfterMs / 1000;\n\t}\n}\n","/**\n * Maximum cause-chain depth walked by {@link findErrorCode}. Caps pathological\n * self-referential or deeply nested chains; transport failures surface as\n * `NetworkError → TypeError(\"fetch failed\") → OS Error{code}`, so three\n * levels is the expected shape and five leaves headroom.\n */\nconst MAX_DEPTH = 5;\n\n/**\n * Walks an error's `cause` chain and returns the first node-style string\n * `code` it finds (for example `\"ECONNRESET\"`, `\"ETIMEDOUT\"`). Native `fetch`\n * surfaces a transport reset as a `NetworkError` wrapping a\n * `TypeError(\"fetch failed\")` whose own cause carries the OS-level `code`, so\n * the code lives several links down the chain.\n *\n * @example\n *\n * ```ts\n * import { findErrorCode } from \"./find-error-code\";\n *\n * const root = Object.assign(new Error(\"read ECONNRESET\"), { code: \"ECONNRESET\" });\n * const outer = new Error(\"Network request failed\", {\n * cause: new TypeError(\"fetch failed\", { cause: root }),\n * });\n *\n * expect(findErrorCode(outer)).toBe(\"ECONNRESET\");\n * ```\n *\n * @param error - The error to inspect; typically a `NetworkError`.\n * @returns The first string `code` in the chain, or `undefined` if none.\n */\nexport function findErrorCode(error: unknown): string | undefined {\n\tlet current: unknown = error;\n\tfor (let depth = 0; depth < MAX_DEPTH && current instanceof Error; depth += 1) {\n\t\tconst code = readCode(current);\n\t\tif (code !== undefined) {\n\t\t\treturn code;\n\t\t}\n\n\t\tcurrent = current.cause;\n\t}\n\n\treturn undefined;\n}\n\nfunction readCode(error: Error): string | undefined {\n\tconst code = Reflect.get(error, \"code\");\n\treturn typeof code === \"string\" ? code : undefined;\n}\n\n/**\n * `DOMException.name` produced when an `AbortSignal.timeout` fires. This is the\n * web-standard discriminator (stable across Node and Bun, unlike the\n * runtime-specific message) and distinguishes the SDK's own request timeout\n * from a caller-supplied cancellation, which surfaces as `\"AbortError\"`.\n */\nconst TIMEOUT_ABORT_NAME = \"TimeoutError\";\n\n/**\n * Reports whether an error chain was produced by the SDK's own\n * `AbortSignal.timeout` self-abort. Such a `DOMException` carries a numeric\n * `code` (23), so {@link findErrorCode} (which only reads string codes)\n * cannot classify it; this walk keys on `name` instead. A caller-supplied\n * abort (`\"AbortError\"`) is deliberately not matched.\n *\n * @example\n *\n * ```ts\n * import { isTimeoutAbort } from \"./find-error-code\";\n *\n * const error = new Error(\"Network request failed\", {\n * cause: new DOMException(\"timed out\", \"TimeoutError\"),\n * });\n *\n * expect(isTimeoutAbort(error)).toBe(true);\n * expect(isTimeoutAbort(new DOMException(\"cancelled\", \"AbortError\"))).toBe(false);\n * ```\n *\n * @param error - The error to inspect; typically a `NetworkError`.\n * @returns `true` when a `TimeoutError` abort sits within the cause chain.\n */\nexport function isTimeoutAbort(error: unknown): boolean {\n\tlet current: unknown = error;\n\tfor (let depth = 0; depth < MAX_DEPTH && current instanceof Error; depth += 1) {\n\t\tif (Reflect.get(current, \"name\") === TIMEOUT_ABORT_NAME) {\n\t\t\treturn true;\n\t\t}\n\n\t\tcurrent = current.cause;\n\t}\n\n\treturn false;\n}\n","import { ApiError } from \"../../errors/api-error.ts\";\nimport { NetworkError } from \"../../errors/network-error.ts\";\nimport { hasServerRetryGuidance, RateLimitError } from \"../../errors/rate-limit.ts\";\nimport { findErrorCode, isTimeoutAbort } from \"../utils/find-error-code.ts\";\n\n/**\n * Fully-resolved retry config shape that {@link mergeConfig} and\n * {@link shouldRetry} operate on. Fields are required because this represents\n * the post-defaulting, internal view; callers should supply every field (or\n * resolve them via a test factory / client constructor). The partial,\n * user-facing type lives on client construction options; method defaults and\n * per-request overrides use `Partial<RetryResolvable>`.\n */\nexport interface RetryResolvable {\n\t/** Roblox Open Cloud API key. */\n\treadonly apiKey: string;\n\t/** Base URL for the Open Cloud API. */\n\treadonly baseUrl: string;\n\t/** Maximum retry attempts before giving up. */\n\treadonly maxRetries: number;\n\t/** Status codes that are eligible for retry. */\n\treadonly retryableStatuses: ReadonlyArray<number>;\n\t/**\n\t * Codes for transport-level failures eligible for retry: node-style\n\t * transport codes ({@link findErrorCode}) surfaced as a\n\t * {@link NetworkError}, plus the synthetic {@link GATEWAY_REJECTED} for a\n\t * response served by an edge gateway. Not all of them prove the request\n\t * went unprocessed — see {@link TRANSIENT_TRANSPORT_CODES}. Empty for\n\t * create operations by default; consumers opt a create in via a per-request\n\t * override.\n\t */\n\treadonly retryableTransportCodes: ReadonlyArray<string>;\n\t/** Fallback delay function when no server hint is available. */\n\treadonly retryDelay: (attempt: number) => number;\n\t/** Per-request timeout in milliseconds. */\n\treadonly timeout: number;\n}\n\n/**\n * Transient transport error codes that are safe to retry for idempotent\n * operations. Connection resets, timeouts, and DNS hiccups are recoverable on\n * a retry. A self-aborted request timeout carries no OS-level `code`, so\n * {@link shouldRetry} folds it into this set as `ETIMEDOUT` (via\n * {@link isTimeoutAbort}) for idempotent methods; create methods retry no\n * transport codes and so still never re-issue a timed-out write.\n *\n * `ERR_HTTP2_STREAM_ERROR`, `ERR_HTTP2_SESSION_ERROR`, and `UND_ERR_INFO` are\n * the same deaths as spelled by a runtime whose `fetch` negotiates HTTP/2\n * (Node 26 and later). They differ from the socket codes in one way that\n * matters: they do not prove the request went unprocessed. `UND_ERR_INFO`\n * covers both a `GOAWAY` declaring a stream was never started and a stream\n * that was fully sent, and `UND_ERR_SOCKET` can fire once a response is\n * already streaming. Retrying them is therefore justified by the operation\n * being safe to repeat, never by the request having gone unseen — which is\n * why {@link UPLOAD_METHOD_DEFAULTS}, the one write policy that includes\n * them, documents its own grounds.\n *\n * @since 0.1.0\n */\nexport const TRANSIENT_TRANSPORT_CODES: ReadonlyArray<string> = Object.freeze([\n\t\"ECONNRESET\",\n\t\"ECONNREFUSED\",\n\t\"ETIMEDOUT\",\n\t\"EPIPE\",\n\t\"ENETUNREACH\",\n\t\"EHOSTDOWN\",\n\t\"EAI_AGAIN\",\n\t\"UND_ERR_SOCKET\",\n\t\"ERR_HTTP2_STREAM_ERROR\",\n\t\"ERR_HTTP2_SESSION_ERROR\",\n\t\"UND_ERR_INFO\",\n]);\n\n/**\n * Synthetic transport code for a response that came from an edge gateway\n * rather than Open Cloud ({@link ApiError.gatewaySummary}). Such a response\n * proves the request was rejected before any Open Cloud handler saw it, so it\n * is classified alongside {@link TRANSIENT_TRANSPORT_CODES} rather than by its\n * HTTP status: the status belongs to the gateway, not to the API, and a\n * gateway `400` says nothing about the validity of the request.\n *\n * Name it in a per-request `retryableTransportCodes` override to opt an\n * operation into (or out of) gateway-rejection retry.\n *\n * @since 0.1.2\n */\nexport const GATEWAY_REJECTED = \"GATEWAY_REJECTED\";\n\n/**\n * Synthetic transport code for a 2xx whose body could not be parsed as JSON\n * ({@link ApiError.unparsedBodyLength}). Open Cloud does not answer a success\n * status with a malformed document; what this failure describes in practice is\n * a body the edge delivered short, ending mid-token at exactly the length that\n * arrived. The next read is a fresh body and usually a whole one.\n *\n * Classifying it by transport code rather than by HTTP status is what makes it\n * recoverable at all: the status is a 200, which no `retryableStatuses` list\n * contains, so a status-keyed decision could only ever say \"do not retry\".\n *\n * Retrying is justified by the operation being safe to repeat, never by the\n * request having gone unprocessed — a 200 proves it was processed. So this code\n * is in {@link IDEMPOTENT_METHOD_DEFAULTS} only. Creates and uploads leave it\n * out: their write landed, and re-issuing it to re-read the answer would risk a\n * second resource for a response body, which is the wrong trade. A consumer who\n * can tolerate that duplicate names this code in a per-request\n * `retryableTransportCodes` override.\n *\n * @since 0.1.5\n */\nexport const RESPONSE_UNPARSEABLE = \"RESPONSE_UNPARSEABLE\";\n\n/** Method-level retry defaults, keyed by {@link MethodKind}. */\ntype MethodDefaults = Readonly<\n\tPick<RetryResolvable, \"retryableStatuses\" | \"retryableTransportCodes\">\n>;\n\n/**\n * Default retry policy for idempotent operations (read, list, update,\n * delete). Safe to retry on rate limits, transient server errors, and\n * transient transport failures.\n */\nexport const IDEMPOTENT_METHOD_DEFAULTS: MethodDefaults = Object.freeze({\n\tretryableStatuses: Object.freeze([429, 500, 502, 503, 504] as const),\n\tretryableTransportCodes: Object.freeze([...TRANSIENT_TRANSPORT_CODES, RESPONSE_UNPARSEABLE]),\n});\n\n/**\n * Default retry policy for create operations. Retries rate limits only (no\n * 5xx and no transport-error retries) to prevent duplicate resources, since\n * Roblox Open Cloud has no idempotency-key support. Consumers who can tolerate\n * a duplicate opt in per request.\n */\nexport const CREATE_METHOD_DEFAULTS: MethodDefaults = Object.freeze({\n\tretryableStatuses: Object.freeze([429] as const),\n\tretryableTransportCodes: Object.freeze([] as const),\n});\n\n/**\n * Default retry policy for upload operations (place publish and save). Keeps\n * {@link CREATE_METHOD_DEFAULTS}'s 5xx guard (a 5xx comes from Open Cloud and\n * may describe a write that partly landed), but retries transport failures:\n * {@link TRANSIENT_TRANSPORT_CODES} and {@link GATEWAY_REJECTED}.\n *\n * This is the one write policy that retries codes which do not prove the\n * request went unprocessed, and the grounds are specific to a place version:\n * Roblox dedupes identical place content, so a retry that races a publish\n * which did land returns that same version rather than creating a second one.\n * That is load-bearing, not incidental — an upload operation without content\n * dedupe would need its own allowlist.\n */\nexport const UPLOAD_METHOD_DEFAULTS: MethodDefaults = Object.freeze({\n\t...CREATE_METHOD_DEFAULTS,\n\tretryableTransportCodes: Object.freeze([...TRANSIENT_TRANSPORT_CODES, GATEWAY_REJECTED]),\n});\n\n/** Kind of HTTP method the merge is being performed for. */\nexport type MethodKind = \"create\" | \"idempotent\";\n\n/**\n * Options for {@link mergeConfig}.\n *\n * @template T - Concrete `RetryResolvable` subtype being merged.\n */\ninterface MergeConfigOptions<T> {\n\t/** Method-level defaults (e.g. {@link CREATE_METHOD_DEFAULTS}). */\n\treadonly methodDefaults: Partial<T>;\n\t/** Whether the method is a create or idempotent operation. */\n\treadonly methodKind: MethodKind;\n\t/** Optional per-request overrides; always win when provided. */\n\treadonly requestOptions?: Partial<T>;\n}\n\n/**\n * Options for {@link computeRetryWaitMs}.\n */\ninterface ComputeRetryWaitMsOptions {\n\t/** Zero-indexed retry attempt number. */\n\treadonly attempt: number;\n\t/** Fallback delay function when no server hint is available. */\n\treadonly retryDelay: (attempt: number) => number;\n}\n\n/**\n * Default exponential backoff: 1s → 2s → 4s → 8s → 16s → 30s (capped).\n *\n * @example\n *\n * ```ts\n * import { defaultRetryDelay } from \"./retry\";\n *\n * expect(defaultRetryDelay(0)).toBe(1000);\n * expect(defaultRetryDelay(4)).toBe(16_000);\n * expect(defaultRetryDelay(10)).toBe(30_000);\n * ```\n *\n * @param attempt - Zero-indexed retry attempt number.\n * @returns Wait duration in milliseconds.\n */\nexport function defaultRetryDelay(attempt: number): number {\n\treturn Math.min(1000 * 2 ** attempt, 30_000);\n}\n\n/**\n * Computes how long to wait before the next retry. Prefers valid server\n * guidance on a {@link RateLimitError}, including an explicit zero-second\n * delay; otherwise falls through to `retryDelay(attempt)`.\n *\n * @example\n *\n * ```ts\n * import { RateLimitError } from \"../../errors/rate-limit.ts\";\n * import { computeRetryWaitMs, defaultRetryDelay } from \"./retry\";\n *\n * const error = new RateLimitError(\"slow down\", { retryAfterSeconds: 3 });\n *\n * expect(computeRetryWaitMs(error, { attempt: 0, retryDelay: defaultRetryDelay })).toBe(\n * 3000,\n * );\n * ```\n *\n * @example\n *\n * ```ts\n * import { ApiError } from \"../../errors/api-error.ts\";\n * import { computeRetryWaitMs, defaultRetryDelay } from \"./retry\";\n *\n * const error = new ApiError(\"server error\", { statusCode: 503 });\n *\n * expect(computeRetryWaitMs(error, { attempt: 2, retryDelay: defaultRetryDelay })).toBe(\n * 4000,\n * );\n * ```\n *\n * @param error - The error returned by the failing request.\n * @param options - Retry attempt index and fallback delay function.\n * @returns Wait duration in milliseconds before the next attempt.\n */\nexport function computeRetryWaitMs(\n\terror: ApiError | NetworkError | RateLimitError,\n\toptions: ComputeRetryWaitMsOptions,\n): number {\n\tif (error instanceof RateLimitError && hasServerRetryGuidance(error)) {\n\t\treturn error.retryAfterSeconds * 1000;\n\t}\n\n\treturn options.retryDelay(options.attempt);\n}\n\n/**\n * Decides whether a failed request is eligible for retry. {@link\n * RateLimitError} (checked against 429) and {@link ApiError} (checked against\n * its `statusCode`) are retryable when their status is in `retryableStatuses`.\n * Two {@link ApiError} shapes are the exception, both checked against\n * `retryableTransportCodes` with their status never consulted: one carrying a\n * `gatewaySummary` is checked against {@link GATEWAY_REJECTED}, and one\n * carrying an `unparsedBodyLength` — a 2xx whose body would not parse —\n * against {@link RESPONSE_UNPARSEABLE}. A {@link NetworkError} is\n * retryable when its transport code ({@link findErrorCode}) is in\n * `retryableTransportCodes`. This is how transient connection resets recover.\n * A self-aborted request timeout ({@link isTimeoutAbort}) carries no transport\n * code, so it is classified as `ETIMEDOUT`: recovered for idempotent methods,\n * never for creates (whose list is empty). All other failures return `false`.\n *\n * @example\n *\n * ```ts\n * import { RateLimitError } from \"../../errors/rate-limit.ts\";\n * import { shouldRetry } from \"./retry\";\n *\n * const error = new RateLimitError(\"\", { retryAfterSeconds: 1 });\n *\n * expect(shouldRetry(error, { retryableStatuses: [429], retryableTransportCodes: [] })).toBe(\n * true,\n * );\n * ```\n *\n * @example\n *\n * ```ts\n * import { NetworkError } from \"../../errors/network-error.ts\";\n * import { shouldRetry } from \"./retry\";\n *\n * const reset = Object.assign(new Error(\"read ECONNRESET\"), { code: \"ECONNRESET\" });\n * const error = new NetworkError(\"Network request failed\", { cause: reset });\n *\n * expect(\n * shouldRetry(error, { retryableStatuses: [], retryableTransportCodes: [\"ECONNRESET\"] }),\n * ).toBe(true);\n * ```\n *\n * @param error - The error returned by the failing request.\n * @param config - Object carrying the retry-eligible status and transport-code lists.\n * @returns `true` if the error should be retried, `false` otherwise.\n */\nexport function shouldRetry(\n\terror: unknown,\n\tconfig: {\n\t\treadonly retryableStatuses: ReadonlyArray<number>;\n\t\treadonly retryableTransportCodes: ReadonlyArray<string>;\n\t},\n): error is ApiError | NetworkError | RateLimitError {\n\tif (error instanceof RateLimitError) {\n\t\treturn config.retryableStatuses.includes(429);\n\t}\n\n\tif (error instanceof ApiError) {\n\t\tif (error.gatewaySummary !== undefined) {\n\t\t\treturn config.retryableTransportCodes.includes(GATEWAY_REJECTED);\n\t\t}\n\n\t\tif (error.unparsedBodyLength !== undefined) {\n\t\t\treturn config.retryableTransportCodes.includes(RESPONSE_UNPARSEABLE);\n\t\t}\n\n\t\treturn config.retryableStatuses.includes(error.statusCode);\n\t}\n\n\tif (error instanceof NetworkError) {\n\t\tconst code = findErrorCode(error) ?? (isTimeoutAbort(error) ? \"ETIMEDOUT\" : undefined);\n\t\treturn code !== undefined && config.retryableTransportCodes.includes(code);\n\t}\n\n\treturn false;\n}\n\n/**\n * Resolves the effective config for a single request by shallow-merging the\n * client config, method defaults, and per-request options. Precedence depends\n * on `methodKind`:\n *\n * - `\"create\"`: method defaults override client config, so client-level\n * settings cannot silently relax create-method safety. Only explicit\n * per-request `requestOptions` can.\n * - `\"idempotent\"`: client config overrides method defaults, so consumers\n * can loosen or tighten retry policy globally. `requestOptions` still wins\n * when provided.\n *\n * Array-valued fields like `retryableStatuses` are *replaced*, not extended.\n *\n * @template T - Concrete `RetryResolvable` subtype being merged.\n *\n * @example\n *\n * ```ts\n * import {\n * CREATE_METHOD_DEFAULTS,\n * defaultRetryDelay,\n * mergeConfig,\n * type RetryResolvable,\n * } from \"./retry\";\n *\n * const clientConfig: RetryResolvable = {\n * apiKey: \"k\",\n * baseUrl: \"https://apis.roblox.com\",\n * maxRetries: 3,\n * retryableStatuses: [429, 500],\n * retryableTransportCodes: [],\n * retryDelay: defaultRetryDelay,\n * timeout: 30_000,\n * };\n *\n * const merged = mergeConfig(clientConfig, {\n * methodDefaults: CREATE_METHOD_DEFAULTS,\n * methodKind: \"create\",\n * });\n *\n * expect(merged.retryableStatuses).toStrictEqual([429]);\n * ```\n *\n * @example\n *\n * ```ts\n * import {\n * defaultRetryDelay,\n * IDEMPOTENT_METHOD_DEFAULTS,\n * mergeConfig,\n * type RetryResolvable,\n * } from \"./retry\";\n *\n * const clientConfig: RetryResolvable = {\n * apiKey: \"k\",\n * baseUrl: \"https://apis.roblox.com\",\n * maxRetries: 3,\n * retryableStatuses: [429],\n * retryableTransportCodes: [],\n * retryDelay: defaultRetryDelay,\n * timeout: 30_000,\n * };\n *\n * const merged = mergeConfig(clientConfig, {\n * methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n * methodKind: \"idempotent\",\n * requestOptions: { timeout: 10_000 },\n * });\n *\n * expect(merged.retryableStatuses).toStrictEqual([429]);\n * expect(merged.timeout).toBe(10_000);\n * ```\n *\n * @param clientConfig - Config frozen at client construction.\n * @param options - Method defaults, method kind, and optional per-request overrides.\n * @returns A new merged config object. Inputs are not mutated.\n */\nexport function mergeConfig<T extends RetryResolvable>(\n\tclientConfig: T,\n\t{ methodDefaults, methodKind, requestOptions }: MergeConfigOptions<T>,\n): T {\n\tswitch (methodKind) {\n\t\tcase \"create\": {\n\t\t\treturn { ...clientConfig, ...methodDefaults, ...requestOptions };\n\t\t}\n\t\tcase \"idempotent\": {\n\t\t\treturn { ...methodDefaults, ...clientConfig, ...requestOptions };\n\t\t}\n\t\tdefault: {\n\t\t\tconst exhaustive: never = methodKind;\n\t\t\tthrow new Error(`Unexpected methodKind: ${String(exhaustive)}`);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,cAAiB,SAAyC;CAC/E,IAAI;EAEH,OAAO;GAAE,MAAA,MADU;GACJ,SAAS;EAAK;CAC9B,SAAS,KA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