@bedrock-rbx/ocale 0.2.3 → 0.3.1

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.
Files changed (52) hide show
  1. package/dist/badges.d.mts +1 -1
  2. package/dist/badges.mjs +3 -3
  3. package/dist/developer-products.d.mts +1 -1
  4. package/dist/developer-products.mjs +4 -4
  5. package/dist/game-passes.d.mts +1 -1
  6. package/dist/game-passes.mjs +4 -4
  7. package/dist/index.d.mts +109 -4
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +70 -5
  10. package/dist/index.mjs.map +1 -0
  11. package/dist/luau-execution.d.mts +2 -2
  12. package/dist/luau-execution.mjs +4 -4
  13. package/dist/{rate-limit-Dp39sH83.mjs → network-error-DmNy_j-u.mjs} +85 -34
  14. package/dist/network-error-DmNy_j-u.mjs.map +1 -0
  15. package/dist/places.d.mts +2 -2
  16. package/dist/places.mjs +5 -5
  17. package/dist/{poll-timeout-tg2HS2_e.mjs → poll-timeout-wrPTnGl_.mjs} +2 -2
  18. package/dist/{poll-timeout-tg2HS2_e.mjs.map → poll-timeout-wrPTnGl_.mjs.map} +1 -1
  19. package/dist/{polling-CG12rHaz.d.mts → polling-0t1wQyVY.d.mts} +20 -13
  20. package/dist/polling-0t1wQyVY.d.mts.map +1 -0
  21. package/dist/{polling-helpers-C77TA67-.mjs → polling-helpers-CzdT2FS5.mjs} +32 -52
  22. package/dist/polling-helpers-CzdT2FS5.mjs.map +1 -0
  23. package/dist/{price-information-CGV241_0.mjs → price-information-Czs5cWR1.mjs} +2 -2
  24. package/dist/{price-information-CGV241_0.mjs.map → price-information-Czs5cWR1.mjs.map} +1 -1
  25. package/dist/resource-client-aqk_V4TD.mjs +717 -0
  26. package/dist/resource-client-aqk_V4TD.mjs.map +1 -0
  27. package/dist/{retry-VPpaLes3.d.mts → retry-Cj5OXCdL.d.mts} +8 -11
  28. package/dist/retry-Cj5OXCdL.d.mts.map +1 -0
  29. package/dist/retry-DIK_T_oF.mjs +1322 -0
  30. package/dist/retry-DIK_T_oF.mjs.map +1 -0
  31. package/dist/storage.d.mts +3 -2
  32. package/dist/storage.d.mts.map +1 -1
  33. package/dist/storage.mjs +3 -3
  34. package/dist/testing.d.mts +9 -17
  35. package/dist/testing.d.mts.map +1 -1
  36. package/dist/testing.mjs +1 -1
  37. package/dist/{types-DXai6-hU.d.mts → types-D_njb3qW.d.mts} +118 -4
  38. package/dist/types-D_njb3qW.d.mts.map +1 -0
  39. package/dist/universes.d.mts +1 -1
  40. package/dist/universes.mjs +4 -4
  41. package/dist/{validation-C9cn_EjP.mjs → validation-BwjwOJPD.mjs} +2 -2
  42. package/dist/{validation-C9cn_EjP.mjs.map → validation-BwjwOJPD.mjs.map} +1 -1
  43. package/package.json +1 -1
  44. package/dist/polling-CG12rHaz.d.mts.map +0 -1
  45. package/dist/polling-helpers-C77TA67-.mjs.map +0 -1
  46. package/dist/rate-limit-Dp39sH83.mjs.map +0 -1
  47. package/dist/resource-client-Du-FELhL.mjs +0 -1170
  48. package/dist/resource-client-Du-FELhL.mjs.map +0 -1
  49. package/dist/retry-VPpaLes3.d.mts.map +0 -1
  50. package/dist/retry-zrzlnJ-m.mjs +0 -458
  51. package/dist/retry-zrzlnJ-m.mjs.map +0 -1
  52. package/dist/types-DXai6-hU.d.mts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry-zrzlnJ-m.mjs","names":["exhaustive"],"sources":["../src/errors/permission-error.ts","../src/internal/utils/find-error-code.ts","../src/internal/http/retry.ts"],"sourcesContent":["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","/**\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 { 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 the server's\n * suggested delay when the error is a {@link RateLimitError} with a positive\n * `retryAfterSeconds`; 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 && error.retryAfterSeconds > 0) {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,kBAAb,cAAqC,SAAS;CAC7C,OAAwC;CACxC;CACA;;;;;;;;CASA,YAAY,SAAiB,SAAiC;EAC7D,MAAM,SAAS,OAAO;EACtB,KAAK,eAAe,QAAQ;EAC5B,KAAK,iBAAiB,QAAQ;CAC/B;AACD;;;;;;;;;AC9DA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;AAyBlB,SAAgB,cAAc,OAAoC;CACjE,IAAI,UAAmB;CACvB,KAAK,IAAI,QAAQ,GAAG,QAAQ,aAAa,mBAAmB,OAAO,SAAS,GAAG;EAC9E,MAAM,OAAO,SAAS,OAAO;EAC7B,IAAI,SAAS,KAAA,GACZ,OAAO;EAGR,UAAU,QAAQ;CACnB;AAGD;AAEA,SAAS,SAAS,OAAkC;CACnD,MAAM,OAAO,QAAQ,IAAI,OAAO,MAAM;CACtC,OAAO,OAAO,SAAS,WAAW,OAAO,KAAA;AAC1C;;;;;;;AAQA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;AAyB3B,SAAgB,eAAe,OAAyB;CACvD,IAAI,UAAmB;CACvB,KAAK,IAAI,QAAQ,GAAG,QAAQ,aAAa,mBAAmB,OAAO,SAAS,GAAG;EAC9E,IAAI,QAAQ,IAAI,SAAS,MAAM,MAAM,oB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