@bedrock-rbx/ocale 0.3.4-beta.1 → 0.4.0

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 (86) hide show
  1. package/README.md +9 -5
  2. package/dist/badge-cost-mismatch-DrlvhlQc.mjs +47 -0
  3. package/dist/badge-cost-mismatch-DrlvhlQc.mjs.map +1 -0
  4. package/dist/badges.d.mts +228 -184
  5. package/dist/badges.d.mts.map +1 -1
  6. package/dist/badges.mjs +176 -18
  7. package/dist/badges.mjs.map +1 -1
  8. package/dist/capacity-admission-hycCFkTo.d.mts +355 -0
  9. package/dist/capacity-admission-hycCFkTo.d.mts.map +1 -0
  10. package/dist/{data.generated-B2ceLfSn.d.mts → data.generated-D_vpa5-g.d.mts} +23 -23
  11. package/dist/data.generated-D_vpa5-g.d.mts.map +1 -0
  12. package/dist/developer-products.d.mts +181 -186
  13. package/dist/developer-products.d.mts.map +1 -1
  14. package/dist/developer-products.mjs +24 -24
  15. package/dist/developer-products.mjs.map +1 -1
  16. package/dist/game-passes.d.mts +206 -203
  17. package/dist/game-passes.d.mts.map +1 -1
  18. package/dist/game-passes.mjs +26 -21
  19. package/dist/game-passes.mjs.map +1 -1
  20. package/dist/index.d.mts +924 -306
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +325 -10
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/locales.d.mts +30 -2
  25. package/dist/locales.d.mts.map +1 -0
  26. package/dist/locales.mjs +24 -1
  27. package/dist/locales.mjs.map +1 -1
  28. package/dist/luau-execution.d.mts +154 -151
  29. package/dist/luau-execution.d.mts.map +1 -1
  30. package/dist/luau-execution.mjs +11 -8
  31. package/dist/luau-execution.mjs.map +1 -1
  32. package/dist/{network-error-DR9FX5hb.mjs → network-error-iVSng5MT.mjs} +44 -6
  33. package/dist/network-error-iVSng5MT.mjs.map +1 -0
  34. package/dist/places.d.mts +204 -180
  35. package/dist/places.d.mts.map +1 -1
  36. package/dist/places.mjs +66 -20
  37. package/dist/places.mjs.map +1 -1
  38. package/dist/{poll-timeout-3PXLsabj.mjs → poll-timeout-DzztDymd.mjs} +2 -2
  39. package/dist/{poll-timeout-3PXLsabj.mjs.map → poll-timeout-DzztDymd.mjs.map} +1 -1
  40. package/dist/{polling-helpers-sKTsqEc1.mjs → polling-helpers-DfF5dspc.mjs} +249 -83
  41. package/dist/polling-helpers-DfF5dspc.mjs.map +1 -0
  42. package/dist/{price-information-hWXV6DAI.mjs → price-information-DEkEQ8Pq.mjs} +2 -2
  43. package/dist/{price-information-hWXV6DAI.mjs.map → price-information-DEkEQ8Pq.mjs.map} +1 -1
  44. package/dist/resource-client-BCKukheG.d.mts +168 -0
  45. package/dist/resource-client-BCKukheG.d.mts.map +1 -0
  46. package/dist/resource-client-CaIVr-go.mjs +1419 -0
  47. package/dist/resource-client-CaIVr-go.mjs.map +1 -0
  48. package/dist/retry-C2oHesDx.d.mts +229 -0
  49. package/dist/retry-C2oHesDx.d.mts.map +1 -0
  50. package/dist/{retry-vpHMIwaU.mjs → retry-CMRDvAR4.mjs} +390 -20
  51. package/dist/retry-CMRDvAR4.mjs.map +1 -0
  52. package/dist/storage.d.mts +333 -334
  53. package/dist/storage.d.mts.map +1 -1
  54. package/dist/storage.mjs +29 -22
  55. package/dist/storage.mjs.map +1 -1
  56. package/dist/testing.d.mts +347 -360
  57. package/dist/testing.d.mts.map +1 -1
  58. package/dist/testing.mjs +3 -4
  59. package/dist/testing.mjs.map +1 -1
  60. package/dist/types-CdMr_J1M.d.mts +509 -0
  61. package/dist/types-CdMr_J1M.d.mts.map +1 -0
  62. package/dist/universes.d.mts +619 -422
  63. package/dist/universes.d.mts.map +1 -1
  64. package/dist/universes.mjs +421 -48
  65. package/dist/universes.mjs.map +1 -1
  66. package/dist/{validation-B_Zs1So2.mjs → validation-964VNlbp.mjs} +2 -2
  67. package/dist/{validation-B_Zs1So2.mjs.map → validation-964VNlbp.mjs.map} +1 -1
  68. package/dist/wire-DJqupefn.d.mts +41 -0
  69. package/dist/wire-DJqupefn.d.mts.map +1 -0
  70. package/package.json +14 -14
  71. package/dist/capacity-admission-BvnJjY0S.d.mts +0 -369
  72. package/dist/capacity-admission-BvnJjY0S.d.mts.map +0 -1
  73. package/dist/data.generated-B2ceLfSn.d.mts.map +0 -1
  74. package/dist/network-error-DR9FX5hb.mjs.map +0 -1
  75. package/dist/polling-helpers-sKTsqEc1.mjs.map +0 -1
  76. package/dist/resource-client-3cOhqZpX.mjs +0 -899
  77. package/dist/resource-client-3cOhqZpX.mjs.map +0 -1
  78. package/dist/resource-client-BivRq3JZ.d.mts +0 -164
  79. package/dist/resource-client-BivRq3JZ.d.mts.map +0 -1
  80. package/dist/retry-DXEklFrt.d.mts +0 -373
  81. package/dist/retry-DXEklFrt.d.mts.map +0 -1
  82. package/dist/retry-vpHMIwaU.mjs.map +0 -1
  83. package/dist/types-C3Egi37J.d.mts +0 -378
  84. package/dist/types-C3Egi37J.d.mts.map +0 -1
  85. package/dist/wire-D3K-a-UP.d.mts +0 -37
  86. package/dist/wire-D3K-a-UP.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-helpers-DfF5dspc.mjs","names":["SECONDS_PER_MINUTE","malformed","makeSpec"],"sources":["../src/resources/luau-execution/capacity-error.ts","../src/domains/cloud-v2/luau-execution-task-logs/builders.ts","../src/domains/cloud-v2/luau-execution-task-logs/operations.ts","../src/domains/cloud-v2/luau-execution-task-logs/parsers.ts","../src/domains/cloud-v2/luau-execution-task-logs/specs.ts","../src/domains/cloud-v2/luau-execution-tasks/builders.ts","../src/domains/cloud-v2/luau-execution-tasks/operations.ts","../src/domains/cloud-v2/luau-execution-tasks/parsers.ts","../src/domains/cloud-v2/luau-execution-tasks/specs.ts","../src/resources/luau-execution/polling.ts","../src/resources/luau-execution/submit-once.ts","../src/resources/luau-execution/capacity-admission.ts","../src/resources/luau-execution/polling-helpers.ts"],"sourcesContent":["import type {\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport { OpenCloudError } from \"../../errors/base.ts\";\nimport { RateLimitError } from \"../../errors/rate-limit.ts\";\n\nconst UUID_PATTERN = \"[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\";\n\n/**\n * A Luau task submission refused because validated tasks occupy the target\n * place's execution capacity.\n *\n * @example\n *\n * ```ts\n * import { LuauExecutionCapacityError } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const error = new LuauExecutionCapacityError([{\n * placeId: \"456\",\n * sessionId: \"11111111-1111-4111-8111-111111111111\",\n * taskId: \"22222222-2222-4222-8222-222222222222\",\n * universeId: \"123\",\n * versionId: \"789\",\n * }]);\n * expect(error.blockers).toHaveLength(1);\n * ```\n *\n * @since 0.3.2\n */\nexport class LuauExecutionCapacityError extends OpenCloudError {\n\t/** Validated task references reported as occupying the target place. */\n\tpublic readonly blockers: ReadonlyArray<LuauExecutionTaskRef>;\n\tpublic override readonly name = \"LuauExecutionCapacityError\";\n\n\t/**\n\t * Creates a capacity failure from validated blocker references.\n\t *\n\t * @param blockers - Tasks reported as occupying the submitted place.\n\t */\n\tconstructor(blockers: ReadonlyArray<LuauExecutionTaskRef>) {\n\t\tsuper(\"Luau execution capacity is occupied\", { code: \"RESOURCE_EXHAUSTED\" });\n\t\tthis.blockers = Object.freeze(blockers.map((blocker) => Object.freeze({ ...blocker })));\n\t}\n}\n\n/**\n * Builds the identity key shared by capacity blocker collections.\n *\n * @param ref - Luau task reference to identify.\n * @returns The version, session, and task identity components.\n */\nexport function luauTaskRefKey(ref: LuauExecutionTaskRef): string {\n\treturn `${ref.versionId}/${ref.sessionId}/${ref.taskId}`;\n}\n\n/**\n * Converts a positively identified Luau capacity response into its typed\n * error.\n *\n * @param error - The response error to inspect.\n * @param parameters - The submitted target used to validate blocker refs.\n * @returns A typed capacity error, or `undefined` without positive evidence.\n */\nexport function capacityErrorFrom(\n\terror: OpenCloudError,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): LuauExecutionCapacityError | undefined {\n\tconst blockers = capacityBlockersFrom(error, parameters);\n\treturn blockers.length === 0 ? undefined : new LuauExecutionCapacityError(blockers);\n}\n\n/**\n * Checks whether a response error positively names tasks occupying the\n * submitted place. Such a 429 clears when those tasks end, not at its\n * guided wait, so it never locks the submit operation out.\n *\n * @param error - The response error to inspect.\n * @param parameters - The submitted target used to validate blocker refs.\n * @returns Whether the error names at least one validated blocker.\n */\nexport function namesCapacityBlockers(\n\terror: OpenCloudError,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): boolean {\n\treturn capacityBlockersFrom(error, parameters).length > 0;\n}\n\nfunction capacityMessage(details: JSONValue | undefined): string | undefined {\n\tif (details === null || typeof details !== \"object\" || Array.isArray(details)) {\n\t\treturn undefined;\n\t}\n\n\tconst code = Reflect.get(details, \"code\");\n\tconst message = Reflect.get(details, \"message\");\n\treturn code === \"RESOURCE_EXHAUSTED\" && typeof message === \"string\" ? message : undefined;\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/gu, \"\\\\$&\");\n}\n\nfunction compareTaskRefs(left: LuauExecutionTaskRef, right: LuauExecutionTaskRef): number {\n\treturn luauTaskRefKey(left).localeCompare(luauTaskRefKey(right));\n}\n\nfunction blockerRefsFrom(\n\tmessage: string,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): ReadonlyArray<LuauExecutionTaskRef> {\n\tconst universeId = escapeRegExp(parameters.universeId);\n\tconst placeId = escapeRegExp(parameters.placeId);\n\tconst pattern = new RegExp(\n\t\t`universes/(${universeId})/places/(${placeId})/versions/([1-9][0-9]*)/luau-execution-sessions/(${UUID_PATTERN})/tasks/(${UUID_PATTERN})(?=$|[^A-Za-z0-9_-])`,\n\t\t\"giu\",\n\t);\n\tconst unique = new Map<string, LuauExecutionTaskRef>();\n\tfor (const match of message.matchAll(pattern)) {\n\t\tconst matchedUniverseId = String(match[1]);\n\t\tconst matchedPlaceId = String(match[2]);\n\t\tconst versionId = String(match[3]);\n\t\tconst sessionId = String(match[4]);\n\t\tconst taskId = String(match[5]);\n\n\t\tconst ref = Object.freeze({\n\t\t\tplaceId: matchedPlaceId,\n\t\t\tsessionId,\n\t\t\ttaskId,\n\t\t\tuniverseId: matchedUniverseId,\n\t\t\tversionId,\n\t\t});\n\t\tunique.set(luauTaskRefKey(ref), ref);\n\t}\n\n\treturn Object.freeze([...unique.values()].toSorted(compareTaskRefs));\n}\n\nfunction capacityBlockersFrom(\n\terror: OpenCloudError,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): ReadonlyArray<LuauExecutionTaskRef> {\n\tif (!(error instanceof RateLimitError) || error.code !== \"RESOURCE_EXHAUSTED\") {\n\t\treturn [];\n\t}\n\n\tconst message = capacityMessage(error.details);\n\treturn message === undefined ? [] : blockerRefsFrom(message, parameters);\n}\n","import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { ListLogsParameters } from \"./types.ts\";\n\n/**\n * Builds a `GET` request for the Open Cloud \"list Luau execution session\n * task logs\" endpoint. The endpoint requires the maximal x-aep-resource\n * path shape (universe, place, version, session, task), so the supplied\n * ref must include `versionId` and `sessionId`; refs extracted from the\n * narrower path formats are rejected with a {@link ValidationError}.\n *\n * The `view` query parameter is hard-coded to `STRUCTURED` so callers\n * always receive typed structured messages. No public `view` parameter\n * is exposed.\n *\n * @param parameters - Task ref, and optional `pageSize` and `pageToken`\n * pagination controls.\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when the ref is missing `versionId` or\n * `sessionId`.\n */\nexport function buildListLogsRequest({\n\tpageSize,\n\tpageToken,\n\tref,\n}: ListLogsParameters): Result<HttpRequest, ValidationError> {\n\tconst { placeId, sessionId, taskId, universeId, versionId } = ref;\n\n\tif (versionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing versionId; cannot list logs\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tif (sessionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing sessionId; cannot list logs\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst base = `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-sessions/${sessionId}/tasks/${taskId}/logs`;\n\tconst url = `${base}?${buildQuery(pageSize, pageToken).toString()}`;\n\treturn { data: { method: \"GET\", url }, success: true };\n}\n\nfunction buildQuery(pageSize: number | undefined, pageToken: string | undefined): URLSearchParams {\n\tconst query = new URLSearchParams({ view: \"STRUCTURED\" });\n\n\tif (pageSize !== undefined) {\n\t\tquery.append(\"maxPageSize\", String(pageSize));\n\t}\n\n\tif (pageToken !== undefined) {\n\t\tquery.append(\"pageToken\", pageToken);\n\t}\n\n\treturn query;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst LIST_LOGS_PER_MINUTE = 45;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for listing Luau execution task logs,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_ListLuauExecutionSessionTaskLogs` operation (45 requests per\n * minute per API key owner), which is also the burst the server allows.\n */\nexport const LIST_LOGS_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: LIST_LOGS_PER_MINUTE,\n\tmaxPerSecond: LIST_LOGS_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-task-logs.list\",\n});\n\n/**\n * Scopes required to list Luau execution task logs, sourced from\n * `x-roblox-scopes` on the list-logs operation in the vendored OpenAPI\n * schema. Surfaced via the `requiredScopes` field of the per-method\n * spec so a 401 or 403 ApiError is upgraded to a `PermissionError`\n * naming the missing scope. Only `:read` is required as the\n * minimum-privilege scope for this read-only operation.\n */\nexport const LIST_LOGS_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:read\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { LogMessage, LogPage } from \"./types.ts\";\nimport type { LogChunkWire, LogMessageWire } from \"./wire.ts\";\n\nconst MALFORMED_LOGS_MESSAGE = \"Malformed list-luau-execution-task-logs response\";\n\n/**\n * Parses a successful Open Cloud list-luau-execution-task-logs response\n * body into the public {@link LogPage} shape. Chunks are flattened into\n * a single ordered array of {@link LogMessage} values.\n *\n * The SDK requests STRUCTURED view, so both the chunk list and each\n * chunk's message array must be present. Explicit empty arrays are valid;\n * missing arrays reject the page rather than silently losing log output.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link LogPage}, or an\n * {@link UnexpectedResponseError} when the body does not match a supported\n * shape.\n */\nexport function parseListLogsResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LogPage, UnexpectedResponseError> {\n\tif (!isRecord(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst rawChunks = body[\"luauExecutionSessionTaskLogs\"];\n\tif (!isLogChunks(rawChunks)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst rawToken = body[\"nextPageToken\"];\n\tif (rawToken !== undefined && typeof rawToken !== \"string\") {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst messages: Array<LogMessage> = [];\n\tfor (const chunk of rawChunks) {\n\t\tfor (const wireMessage of chunk.structuredMessages) {\n\t\t\tmessages.push({\n\t\t\t\tcreateTime: wireMessage.createTime,\n\t\t\t\tmessage: wireMessage.message,\n\t\t\t\tmessageType: wireMessage.messageType,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn {\n\t\tdata: { messages, nextPageToken: rawToken },\n\t\tsuccess: true,\n\t};\n}\n\nfunction isAcceptedMessageType(value: unknown): value is LogMessageWire[\"messageType\"] {\n\treturn (\n\t\tvalue === \"MESSAGE_TYPE_UNSPECIFIED\" ||\n\t\tvalue === \"OUTPUT\" ||\n\t\tvalue === \"INFO\" ||\n\t\tvalue === \"WARNING\" ||\n\t\tvalue === \"ERROR\"\n\t);\n}\n\nfunction isLogMessageWire(value: unknown): value is LogMessageWire {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value[\"createTime\"] === \"string\" &&\n\t\ttypeof value[\"message\"] === \"string\" &&\n\t\tisAcceptedMessageType(value[\"messageType\"])\n\t);\n}\n\n/**\n * Requires an explicit message array: captured no-print tasks return `[]`.\n * Missing or null messages do not establish that a chunk has no output.\n *\n * @param value - The chunk's untrusted `structuredMessages` field.\n * @returns Whether the field is an array containing only valid messages.\n */\nfunction isStructuredMessages(value: unknown): value is ReadonlyArray<LogMessageWire> {\n\treturn Array.isArray(value) && value.every((item: unknown) => isLogMessageWire(item));\n}\n\n/**\n * Validates a chunk for the STRUCTURED view always requested by the SDK.\n * The schema also describes FLAT chunks that omit `structuredMessages`;\n * accepting those here would silently discard their output.\n *\n * @param value - An untrusted entry in the response's chunk list.\n * @returns Whether the chunk contains a valid structured message array.\n */\nfunction isLogChunkWire(value: unknown): value is LogChunkWire {\n\treturn isRecord(value) && isStructuredMessages(value[\"structuredMessages\"]);\n}\n\n/**\n * Requires an explicit chunk list, including `[]` for an empty page.\n * Validates every chunk before flattening so one malformed chunk rejects\n * the whole page instead of returning a partial log list.\n *\n * @param value - The untrusted `luauExecutionSessionTaskLogs` field.\n * @returns Whether the field is an array containing only valid chunks.\n */\nfunction isLogChunks(value: unknown): value is ReadonlyArray<LogChunkWire> {\n\treturn Array.isArray(value) && value.every((item: unknown) => isLogChunkWire(item));\n}\n\nfunction malformed(statusCode: number, body: unknown): Result<LogPage, UnexpectedResponseError> {\n\treturn {\n\t\terr: new UnexpectedResponseError(MALFORMED_LOGS_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n","import { IDEMPOTENT_METHOD_DEFAULTS } from \"../../../internal/http/retry.ts\";\nimport type { ResourceMethodSpec } from \"../../../internal/resource-client.ts\";\nimport { buildListLogsRequest } from \"./builders.ts\";\nimport { LIST_LOGS_OPERATION_LIMIT, LIST_LOGS_REQUIRED_SCOPES } from \"./operations.ts\";\nimport { parseListLogsResponse } from \"./parsers.ts\";\nimport type { ListLogsParameters, LogPage } from \"./types.ts\";\n\nfunction makeSpec<P>(spec: ResourceMethodSpec<P, LogPage>): ResourceMethodSpec<P, LogPage> {\n\treturn Object.freeze({ ...spec, apiKeyOnly: true });\n}\n\n/**\n * Per-method dispatch spec for listing the structured log messages\n * produced by a Luau execution task. Frozen at module scope so both\n * the top-level `LuauExecutionClient` and the `luauExecution` Operation\n * Group on `PlacesClient` share the same instance reference.\n */\nexport const LIST_LOGS_SPEC = makeSpec<ListLogsParameters>({\n\tbuildRequest: buildListLogsRequest,\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: LIST_LOGS_OPERATION_LIMIT,\n\tparse: parseListLogsResponse,\n\trequiredScopes: LIST_LOGS_REQUIRED_SCOPES,\n});\n","import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { GetParameters, SubmitAtHeadParameters, SubmitAtVersionParameters } from \"./types.ts\";\n\ninterface SubmitBodyInput {\n\treadonly binaryInput?: string | undefined;\n\treadonly enableBinaryOutput?: boolean | undefined;\n\treadonly script: string;\n\treadonly timeoutSeconds?: number;\n}\n\nconst JSON_HEADERS: Readonly<Record<string, string>> = { \"content-type\": \"application/json\" };\n\n/**\n * Builds a `POST` request for the Open Cloud \"create Luau execution\n * session task\" endpoint, targeting the place's head version. Serializes\n * `timeoutSeconds` into the wire's duration string format (`\"<n>s\"`)\n * when supplied.\n *\n * @param parameters - Universe and place identifiers, the script body,\n * and an optional `timeoutSeconds`.\n * @returns A pure {@link HttpRequest} describing the submit call.\n */\nexport function buildSubmitAtHeadRequest(parameters: SubmitAtHeadParameters): HttpRequest {\n\tconst { placeId, universeId } = parameters;\n\treturn {\n\t\tbody: buildSubmitBody(parameters),\n\t\theaders: JSON_HEADERS,\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}/luau-execution-session-tasks`,\n\t};\n}\n\n/**\n * Builds a `POST` request for the Open Cloud \"create Luau execution\n * session task\" endpoint, targeting a specific place version. Differs\n * from {@link buildSubmitAtHeadRequest} only in URL shape: the path\n * includes the `versions/{versionId}` segment so the script runs\n * against that exact place version instead of the live head.\n *\n * @param parameters - Universe, place, and version identifiers, the\n * script body, and an optional `timeoutSeconds`.\n * @returns A pure {@link HttpRequest} describing the submit call.\n */\nexport function buildSubmitAtVersionRequest(parameters: SubmitAtVersionParameters): HttpRequest {\n\tconst { placeId, universeId, versionId } = parameters;\n\treturn {\n\t\tbody: buildSubmitBody(parameters),\n\t\theaders: JSON_HEADERS,\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-session-tasks`,\n\t};\n}\n\n/**\n * Builds a `GET` request for the Open Cloud \"read Luau execution session\n * task\" endpoint. The endpoint accepts only the maximal x-aep-resource\n * path shape (universe, place, version, session, task), so the supplied\n * ref must include `versionId` and `sessionId`; refs extracted from the\n * narrower path formats are rejected with a {@link ValidationError}.\n *\n * @param parameters - Task ref and optional view selector. When `view`\n * is omitted, no `?view=` query is sent and the server applies its\n * own default (`BASIC`).\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when the ref is missing `versionId` or\n * `sessionId`.\n */\nexport function buildGetRequest({\n\tref,\n\tview,\n}: GetParameters): Result<HttpRequest, ValidationError> {\n\tconst { placeId, sessionId, taskId, universeId, versionId } = ref;\n\n\tif (versionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing versionId; cannot GET\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tif (sessionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing sessionId; cannot GET\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst base = `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-sessions/${sessionId}/tasks/${taskId}`;\n\tconst url = view === undefined ? base : `${base}?view=${view}`;\n\treturn { data: { method: \"GET\", url }, success: true };\n}\n\nfunction buildSubmitBody({\n\tbinaryInput,\n\tenableBinaryOutput: shouldEnableBinaryOutput,\n\tscript,\n\ttimeoutSeconds,\n}: SubmitBodyInput): Record<string, unknown> {\n\tconst body: Record<string, unknown> = { script };\n\tif (timeoutSeconds !== undefined) {\n\t\tbody[\"timeout\"] = `${timeoutSeconds}s`;\n\t}\n\n\tif (binaryInput !== undefined) {\n\t\tbody[\"binaryInput\"] = binaryInput;\n\t}\n\n\tif (shouldEnableBinaryOutput !== undefined) {\n\t\tbody[\"enableBinaryOutput\"] = shouldEnableBinaryOutput;\n\t}\n\n\treturn body;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst SUBMIT_AT_HEAD_PER_MINUTE = 5;\nconst SUBMIT_AT_VERSION_PER_MINUTE = 5;\nconst GET_PER_MINUTE = 200;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for submitting a Luau execution task at a\n * place's head version, sourced from\n * `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTask__Using_Universes` operation\n * (5 requests per minute per API key owner), which is also the burst\n * the server allows.\n */\nexport const SUBMIT_HEAD_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: SUBMIT_AT_HEAD_PER_MINUTE,\n\tmaxPerSecond: SUBMIT_AT_HEAD_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.submit\",\n});\n\n/**\n * Per-second request ceiling for submitting a Luau execution task at a\n * specific place version, sourced from\n * `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTask__Using_Universes_Places`\n * operation (5 requests per minute per API key owner), which is also\n * the burst the server allows. Carries its own operation key so the\n * version-pinned URL shape is paced from its own quota: the server\n * meters the two shapes in separate buckets whose ceilings are\n * additive, and pinned traffic does not consume head budget. The two\n * ceilings are equal (5 each), but equal is not shared.\n */\nexport const SUBMIT_VERSION_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: SUBMIT_AT_VERSION_PER_MINUTE,\n\tmaxPerSecond: SUBMIT_AT_VERSION_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.submit-at-version\",\n});\n\n/**\n * Per-second request ceiling for fetching a Luau execution task,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_GetLuauExecutionSessionTask` operation (200 requests per\n * minute per API key owner).\n */\nexport const GET_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: GET_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.get\",\n});\n\n/**\n * Scopes required to submit a Luau execution task, sourced from\n * `x-roblox-scopes` on the create operation in the vendored OpenAPI\n * schema. Surfaced via the `requiredScopes` field of the per-method\n * spec so a 401 or 403 ApiError is upgraded to a `PermissionError`\n * naming the missing scope.\n */\nexport const SUBMIT_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:write\",\n]);\n\n/**\n * Scopes required to fetch a Luau execution task, sourced from\n * `x-roblox-scopes` on the get operation. The `:write` scope also\n * grants read in upstream auth, but we surface only `:read` here as\n * the minimum-privilege requirement for this method.\n */\nexport const GET_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:read\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport { isDateTimeString } from \"../../../internal/utils/is-date-time-string.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { LuauExecutionTask, LuauExecutionTaskRef } from \"./types.ts\";\nimport type {\n\tLuauExecutionTaskErrorWire,\n\tLuauExecutionTaskOutputWire,\n\tLuauExecutionTaskWire,\n} from \"./wire.ts\";\n\nconst MALFORMED_TASK_MESSAGE = \"Malformed luau-execution-session-task response\";\n\n// Matches any of the four x-aep-resource path formats for a luau\n// execution session task.\n//\n// Capture groups:\n// 1. universeId\n// 2. placeId\n// 3. versionId (when `/versions/{v}/` segment is present, else undefined)\n// 4. sessionId (when `/luau-execution-sessions/{s}/tasks/...` branch matched)\n// 5. taskId (when `/luau-execution-sessions/.../tasks/{t}` branch matched)\n// 6. taskId (when `/luau-execution-session-tasks/{t}` branch matched)\nconst PATH_PATTERN =\n\t/^universes\\/(\\d+)\\/places\\/(\\d+)(?:\\/versions\\/(\\d+))?(?:\\/luau-execution-sessions\\/([^/]+)\\/tasks\\/([^/]+)|\\/luau-execution-session-tasks\\/([^/]+))$/;\n\ntype InProgressWireState = Exclude<LuauExecutionTaskWire[\"state\"], \"COMPLETE\" | \"FAILED\">;\n\ninterface ParseVariantArgs {\n\treadonly body: LuauExecutionTaskWire;\n\treadonly createdAt: Date | undefined;\n\treadonly ref: LuauExecutionTaskRef;\n\treadonly statusCode: number;\n\treadonly timeoutSeconds: number | undefined;\n\treadonly updatedAt: Date | undefined;\n}\n\n/**\n * Parses a successful Open Cloud `LuauExecutionSessionTask` response\n * body into the public {@link LuauExecutionTask} discriminated union.\n * Handles every supported task state (in-progress, COMPLETE, FAILED)\n * across all four x-aep-resource path shapes the server returns.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud\n * API.\n * @returns A success result wrapping the parsed task, or an\n * {@link UnexpectedResponseError} when the body or path do not match a\n * supported shape.\n */\nexport function parseLuauExecutionTaskResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LuauExecutionTask, UnexpectedResponseError> {\n\tif (!isLuauExecutionTaskWire(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst ref = parseTaskRef(body.path);\n\tif (ref === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst timeoutSeconds = parseTimeoutSeconds(body.timeout);\n\tconst createdAt = parseOptionalDate(body.createTime);\n\tconst updatedAt = parseOptionalDate(body.updateTime);\n\n\tif (body.state === \"COMPLETE\") {\n\t\treturn parseCompleteTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt });\n\t}\n\n\tif (body.state === \"FAILED\") {\n\t\treturn parseFailedTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt });\n\t}\n\n\treturn parseInProgressTask({\n\t\tbody,\n\t\tcreatedAt,\n\t\tref,\n\t\tstate: body.state,\n\t\tstatusCode,\n\t\ttimeoutSeconds,\n\t\tupdatedAt,\n\t});\n}\n\nfunction isAcceptedWireState(state: unknown): state is LuauExecutionTaskWire[\"state\"] {\n\treturn (\n\t\tstate === \"STATE_UNSPECIFIED\" ||\n\t\tstate === \"QUEUED\" ||\n\t\tstate === \"PROCESSING\" ||\n\t\tstate === \"CANCELLED\" ||\n\t\tstate === \"COMPLETE\" ||\n\t\tstate === \"FAILED\"\n\t);\n}\n\nfunction isErrorWireCode(code: unknown): code is LuauExecutionTaskErrorWire[\"code\"] {\n\treturn (\n\t\tcode === \"ERROR_CODE_UNSPECIFIED\" ||\n\t\tcode === \"SCRIPT_ERROR\" ||\n\t\tcode === \"DEADLINE_EXCEEDED\" ||\n\t\tcode === \"OUTPUT_SIZE_LIMIT_EXCEEDED\" ||\n\t\tcode === \"INTERNAL_ERROR\"\n\t);\n}\n\nfunction isErrorWire(value: unknown): value is LuauExecutionTaskErrorWire {\n\treturn (\n\t\tisRecord(value) && isErrorWireCode(value[\"code\"]) && typeof value[\"message\"] === \"string\"\n\t);\n}\n\nfunction isOptionalErrorWire(value: unknown): value is LuauExecutionTaskErrorWire | undefined {\n\treturn value === undefined || isErrorWire(value);\n}\n\nfunction isOutputWire(value: unknown): value is LuauExecutionTaskOutputWire {\n\treturn isRecord(value) && Array.isArray(value[\"results\"]);\n}\n\nfunction isOptionalOutputWire(value: unknown): value is LuauExecutionTaskOutputWire | undefined {\n\treturn value === undefined || isOutputWire(value);\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n\treturn value === undefined || typeof value === \"string\";\n}\n\nfunction isOptionalBoolean(value: unknown): value is boolean | undefined {\n\treturn value === undefined || typeof value === \"boolean\";\n}\n\nfunction isOptionalDateTimeString(value: unknown): value is string | undefined {\n\treturn value === undefined || isDateTimeString(value);\n}\n\nfunction isLuauExecutionTaskWire(body: unknown): body is LuauExecutionTaskWire {\n\treturn (\n\t\tisRecord(body) &&\n\t\ttypeof body[\"path\"] === \"string\" &&\n\t\tisOptionalDateTimeString(body[\"createTime\"]) &&\n\t\tisOptionalDateTimeString(body[\"updateTime\"]) &&\n\t\tisAcceptedWireState(body[\"state\"]) &&\n\t\ttypeof body[\"user\"] === \"string\" &&\n\t\tisOptionalOutputWire(body[\"output\"]) &&\n\t\tisOptionalErrorWire(body[\"error\"]) &&\n\t\tisOptionalDurationWire(body[\"timeout\"]) &&\n\t\tisOptionalString(body[\"binaryInput\"]) &&\n\t\tisOptionalBoolean(body[\"enableBinaryOutput\"]) &&\n\t\tisOptionalString(body[\"binaryOutputUri\"])\n\t);\n}\n\nfunction parseOptionalDate(value: string | undefined): Date | undefined {\n\treturn value === undefined ? undefined : new Date(value);\n}\n\nconst DURATION_PATTERN = /^(\\d+)s$/;\n\nfunction isOptionalDurationWire(value: unknown): value is string | undefined {\n\treturn value === undefined || (typeof value === \"string\" && DURATION_PATTERN.test(value));\n}\n\nfunction parseTimeoutSeconds(value: string | undefined): number | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst match = DURATION_PATTERN.exec(value);\n\tconst seconds = match?.[1];\n\tif (seconds === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn Number.parseInt(seconds, 10);\n}\n\nfunction malformed(\n\tstatusCode: number,\n\tbody: unknown,\n): Result<LuauExecutionTask, UnexpectedResponseError> {\n\treturn {\n\t\terr: new UnexpectedResponseError(MALFORMED_TASK_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n\nfunction parseInProgressTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstate,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs & { readonly state: InProgressWireState }): Result<\n\tLuauExecutionTask,\n\tUnexpectedResponseError\n> {\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\tref,\n\t\t\tstate,\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseCompleteTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstatusCode,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs): Result<LuauExecutionTask, UnexpectedResponseError> {\n\tif (body.output === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\toutput: { results: body.output.results },\n\t\t\tref,\n\t\t\tstate: \"COMPLETE\",\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseFailedTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstatusCode,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs): Result<LuauExecutionTask, UnexpectedResponseError> {\n\tif (body.error === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\terror: { code: body.error.code, message: body.error.message },\n\t\t\tref,\n\t\t\tstate: \"FAILED\",\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseTaskRef(path: string): LuauExecutionTaskRef | undefined {\n\tconst match = PATH_PATTERN.exec(path);\n\tif (match === null) {\n\t\treturn undefined;\n\t}\n\n\tconst [, universeId, placeId, versionId, sessionId, sessionTaskId, plainTaskId] = match;\n\tconst taskId = sessionTaskId ?? plainTaskId;\n\tif (universeId === undefined || placeId === undefined || taskId === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn { placeId, sessionId, taskId, universeId, versionId };\n}\n","import {\n\tCREATE_METHOD_DEFAULTS,\n\tIDEMPOTENT_METHOD_DEFAULTS,\n} from \"../../../internal/http/retry.ts\";\nimport { okRequest, type ResourceMethodSpec } from \"../../../internal/resource-client.ts\";\nimport {\n\tbuildGetRequest,\n\tbuildSubmitAtHeadRequest,\n\tbuildSubmitAtVersionRequest,\n} from \"./builders.ts\";\nimport {\n\tGET_OPERATION_LIMIT,\n\tGET_REQUIRED_SCOPES,\n\tSUBMIT_HEAD_OPERATION_LIMIT,\n\tSUBMIT_REQUIRED_SCOPES,\n\tSUBMIT_VERSION_OPERATION_LIMIT,\n} from \"./operations.ts\";\nimport { parseLuauExecutionTaskResponse } from \"./parsers.ts\";\nimport type {\n\tGetParameters,\n\tLuauExecutionTask,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"./types.ts\";\n\nfunction makeSpec<P>(\n\tspec: ResourceMethodSpec<P, LuauExecutionTask>,\n): ResourceMethodSpec<P, LuauExecutionTask> {\n\treturn Object.freeze({ ...spec, apiKeyOnly: true });\n}\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * place's head version. Frozen at module scope so both the top-level\n * `LuauExecutionClient` and the `luauExecution` Operation Group on\n * `PlacesClient` share the same instance reference.\n */\nexport const SUBMIT_HEAD_SPEC = makeSpec<SubmitAtHeadParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtHeadRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_HEAD_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * specific place version. Shares the required scope set with {@link\n * SUBMIT_HEAD_SPEC} but carries its own rate-limit queue: the server\n * meters the version-pinned URL shape in a bucket separate from the\n * head shape's.\n */\nexport const SUBMIT_VERSION_SPEC = makeSpec<SubmitAtVersionParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtVersionRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_VERSION_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for fetching a Luau execution task. Uses\n * idempotent retry semantics (429 and 5xx both retried) so reads\n * recover transparently from transient server errors.\n */\nexport const GET_SPEC = makeSpec<GetParameters>({\n\tbuildRequest: buildGetRequest,\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: GET_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: GET_REQUIRED_SCOPES,\n});\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport type { LuauExecutionTask } from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { NetworkError } from \"../../errors/network-error.ts\";\nimport { PollAbortedError } from \"../../errors/poll-aborted.ts\";\nimport { PollTimeoutError } from \"../../errors/poll-timeout.ts\";\nimport { RequestDeadlineExceededError } from \"../../errors/request-deadline-exceeded.ts\";\nimport { MAX_ABORT_TIMEOUT_MS } from \"../../internal/http/request-deadline.ts\";\nimport { TRANSIENT_TRANSPORT_CODES } from \"../../internal/http/retry.ts\";\nimport { ABORTED, raceWithAbortAsync } from \"../../internal/utils/abort.ts\";\nimport { findErrorCode } from \"../../internal/utils/find-error-code.ts\";\nimport type { SleepFunc } from \"../../internal/utils/sleep.ts\";\nimport type { Result } from \"../../types.ts\";\n\n/** Default total polling budget in milliseconds (5 minutes). */\nexport const DEFAULT_POLL_TIMEOUT_MS = 300_000;\n\n/** One step of the default poll-cadence schedule. */\ninterface PollDelayTier {\n\t/** Delay in ms to wait between polls while within this tier. */\n\treadonly delayMs: number;\n\t/**\n\t * Upper elapsed-time bound (exclusive) at which this tier stops applying.\n\t */\n\treadonly untilMs: number;\n}\n\n/** Steady-state delay once elapsed time reaches the final tier bound. */\nconst STEADY_POLL_DELAY_MS = 5_000;\n\n/**\n * Fast-to-slow poll-cadence tiers keyed on elapsed wall-clock time. Elapsed\n * times at or beyond the last `untilMs` fall through to\n * {@link STEADY_POLL_DELAY_MS}.\n */\nconst DEFAULT_POLL_TIERS: ReadonlyArray<PollDelayTier> = [\n\t{ delayMs: 500, untilMs: 20_000 },\n\t{ delayMs: 1_000, untilMs: 60_000 },\n];\n\n/**\n * Default poll cadence as a function of elapsed wall-clock time since\n * polling began. Polls quickly while a task is young so short runs resolve\n * snappily, then eases off so a long run leaves rate-limit headroom for\n * newer tasks: 0-20s is 500ms, 20-60s is 1000ms, 60s+ is 5000ms.\n *\n * @since 0.1.0\n *\n * @example\n * ```ts\n * import { defaultPollDelay } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * expect(defaultPollDelay(0)).toBe(500);\n * expect(defaultPollDelay(30_000)).toBe(1000);\n * expect(defaultPollDelay(120_000)).toBe(5000);\n * ```\n *\n * @param elapsedMs - Milliseconds elapsed since polling started.\n * @returns The delay in milliseconds to wait before the next poll.\n */\nexport function defaultPollDelay(elapsedMs: number): number {\n\tconst tier = DEFAULT_POLL_TIERS.find((candidate) => elapsedMs < candidate.untilMs);\n\treturn tier?.delayMs ?? STEADY_POLL_DELAY_MS;\n}\n\n/**\n * Default number of consecutive transport failures tolerated before the poll\n * loop gives up. With per-request retries already absorbing isolated blips,\n * three consecutive loop-level failures signals a genuinely unreachable\n * endpoint, so it bails in seconds rather than spinning out the wall-clock\n * budget.\n */\nexport const DEFAULT_POLL_FAILURE_CAP = 3;\n\n/**\n * Injected dependencies for the deep-module polling loop. The `fetch`\n * callback is pre-bound by the wiring layer and closes over the task ref\n * and request options, keeping the core loop narrow.\n */\nexport interface PollDependencies {\n\t/**\n\t * Returns the current task or an error. Called on each loop iteration with\n\t * the absolute request deadline (epoch ms) that bounds the request, or\n\t * `undefined` when nothing bounds it.\n\t */\n\treadonly fetch: (\n\t\tdeadlineMs: number | undefined,\n\t) => Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/** Returns the current wall-clock time in ms. */\n\treadonly now: () => number;\n\t/** Injectable sleep for deterministic tests. */\n\treadonly sleep: SleepFunc;\n\t/**\n\t * Time the budget opened, when an earlier step (a submit) already spent\n\t * part of it. Defaults to `now()` at loop start.\n\t */\n\treadonly startedAt?: number;\n}\n\n/** The opened poll budget: its window and the deadline each request gets. */\nexport interface PollBudget {\n\t/** Absolute end of the budget, as epoch ms. May be infinite. */\n\treadonly budgetDeadlineMs: number;\n\t/** Deadline to pass to each request, or `undefined` when unbounded. */\n\treadonly requestDeadlineMs: number | undefined;\n\t/** Total budget in ms. */\n\treadonly timeoutMs: number;\n}\n\n/**\n * Public options accepted by `pollUntilDone` and `runUntilDone` on both client\n * surfaces.\n *\n * @since 0.1.0\n */\nexport type PollUntilDoneOptions = PollOptions & RequestOptions;\n\n/** Caller-supplied polling-loop options; all fields optional. */\ninterface PollOptions {\n\t/**\n\t * Consecutive transient transport failures tolerated before the loop gives\n\t * up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll\n\t * resets the count.\n\t */\n\treadonly maxConsecutivePollFailures?: number;\n\t/**\n\t * Returns the sleep duration given ms elapsed since polling started.\n\t * Defaults to {@link defaultPollDelay}.\n\t */\n\treadonly pollDelay?: (elapsedMs: number) => number;\n\t/**\n\t * When aborted, the loop returns {@link PollAbortedError} rather than\n\t * continuing.\n\t */\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Total wall-clock budget in ms before the loop returns {@link\n\t * PollTimeoutError}. It also bounds each in-flight request through the\n\t * request deadline (the earlier of the budget end and any `deadlineMs`),\n\t * so a hanging request ends at the budget. For `runUntilDone` the budget\n\t * opens before the submit and covers it too.\n\t */\n\treadonly timeoutMs?: number;\n}\n\n/** Core loop options: the poll options plus the caller's request deadline. */\ntype CorePollOptions = Pick<RequestOptions, \"deadlineMs\"> & PollOptions;\n\ninterface ResolvedPollOptions {\n\treadonly maxFailures: number;\n\treadonly pollDelay: (elapsedMs: number) => number;\n\treadonly signal: AbortSignal | undefined;\n}\n\ninterface SleepWithAbortOptions {\n\treadonly ms: number;\n\treadonly signal: AbortSignal | undefined;\n\treadonly sleep: SleepFunc;\n}\n\ntype FetchOutcome =\n\t| { readonly error: NetworkError; readonly kind: \"transient\" }\n\t| { readonly error: OpenCloudError; readonly kind: \"failed\" }\n\t| { readonly kind: \"aborted\" }\n\t| { readonly kind: \"pending\"; readonly task: LuauExecutionTask }\n\t| { readonly kind: \"terminal\"; readonly task: LuauExecutionTask };\n\n/** Mutable-per-iteration loop state threaded through {@link applyOutcome}. */\ninterface LoopState {\n\treadonly consecutiveFailures: number;\n\treadonly lastTask: LuauExecutionTask | undefined;\n}\n\ntype LoopAction =\n\t| { readonly kind: \"continue\"; readonly state: LoopState }\n\t| { readonly kind: \"return\"; readonly result: Result<LuauExecutionTask, OpenCloudError> };\n\n/** Per-iteration inputs to {@link applyOutcome}. */\ninterface OutcomeContext {\n\treadonly budget: PollBudget;\n\treadonly maxFailures: number;\n\treadonly signal: AbortSignal | undefined;\n\treadonly state: LoopState;\n}\n\n/**\n * Opens the poll budget at `startedAt`. Each request gets the earlier of the\n * budget deadline and the caller's own `deadlineMs`. A non-finite budget\n * passes only the caller's deadline, since the transport rejects a\n * non-finite one.\n *\n * @param startedAt - Time the budget opened, as epoch ms.\n * @param options - The caller's `timeoutMs` and `deadlineMs`.\n * @returns The budget window and the per-request deadline.\n */\nexport function openPollBudget(\n\tstartedAt: number,\n\toptions: Pick<PollUntilDoneOptions, \"deadlineMs\" | \"timeoutMs\">,\n): PollBudget {\n\tconst timeoutMs = options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n\tconst budgetDeadlineMs = startedAt + timeoutMs;\n\tconst callerDeadlineMs = options.deadlineMs;\n\tif (!Number.isFinite(budgetDeadlineMs)) {\n\t\treturn { budgetDeadlineMs, requestDeadlineMs: callerDeadlineMs, timeoutMs };\n\t}\n\n\tconst requestDeadlineMs =\n\t\tcallerDeadlineMs === undefined\n\t\t\t? budgetDeadlineMs\n\t\t\t: Math.min(callerDeadlineMs, budgetDeadlineMs);\n\treturn { budgetDeadlineMs, requestDeadlineMs, timeoutMs };\n}\n\n/**\n * Maps a request failure caused by the budget deadline to\n * {@link PollTimeoutError}. Any other failure, including one from the\n * caller's own earlier deadline, is returned unchanged. A caller abort wins\n * over the budget, so the failure is also returned unchanged when the\n * caller's signal has fired.\n *\n * @param error - The failure a submit or poll request returned.\n * @param context - The opened budget, the last task observed, if any, and\n * the caller's signal.\n * @returns The poll timeout, or the original error.\n */\nexport function budgetFailure(\n\terror: OpenCloudError,\n\tcontext: {\n\t\tbudget: PollBudget;\n\t\tlastTask: LuauExecutionTask | undefined;\n\t\tsignal: AbortSignal | undefined;\n\t},\n): OpenCloudError {\n\tif (!isBudgetDeadline(error, context.budget) || context.signal?.aborted === true) {\n\t\treturn error;\n\t}\n\n\treturn makeTimeout(context.lastTask, { cause: error, timeoutMs: context.budget.timeoutMs });\n}\n\n/**\n * Defaults the per-request `timeout` to the effective poll budget when the\n * caller has not set one. A luau-execution submit and each poll `get` normally\n * answer in well under a second (the submit endpoint enqueues the task without\n * waiting for it to run), so the only job of a per-request deadline here is to\n * bound a black-hole connection. Leaving these requests on the client-wide 30s\n * default (tuned for snappy CRUD) turns a slow-but-alive backend into a\n * self-abort, an error the retry layer never retries by construction, before\n * the loop's wall-clock budget is ever consulted. Deriving the deadline from\n * `timeoutMs` keeps a single request alive exactly as long as the caller\n * already agreed to wait for the whole operation, so the backend can answer or\n * surface a retryable status instead. A budget longer than a timer can hold,\n * such as `Infinity`, is capped at the longest delay the transport accepts.\n *\n * @template TOptions - The concrete polling option shape to preserve.\n * @param options - The caller's poll and per-request options.\n * @returns The options with `timeout` filled from the budget when it was unset.\n */\nexport function withBudgetRequestTimeout<TOptions extends PollUntilDoneOptions>(\n\toptions: TOptions,\n): TOptions & { readonly timeout: number } {\n\tconst budgetMs = options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n\tconst timeout = options.timeout ?? Math.min(budgetMs, MAX_ABORT_TIMEOUT_MS);\n\treturn { ...options, timeout };\n}\n\n/**\n * Reports whether a Luau task can no longer change execution state.\n *\n * @param task - Task whose state should be classified.\n * @returns Whether the task is complete, failed, or cancelled.\n */\nexport function isTerminalTask(task: LuauExecutionTask): boolean {\n\treturn task.state === \"COMPLETE\" || task.state === \"FAILED\" || task.state === \"CANCELLED\";\n}\n\n/**\n * Core polling loop. Calls `deps.fetch()` repeatedly, sleeping\n * `pollDelay(elapsedMs)` ms between iterations, until a terminal state\n * is observed, the wall-clock budget is exhausted, or an `AbortSignal`\n * fires. A transient transport failure ({@link NetworkError}) is tolerated\n * and the loop continues, giving up only after `maxConsecutivePollFailures`\n * consecutive failures; any other failure aborts immediately, since an API\n * response (a 404 for a vanished task, a 403) means there is nothing left to\n * poll. A successful poll resets the failure count.\n *\n * @param deps - Injected fetch, now, and sleep callbacks.\n * @param options - Optional poll delay, timeout, failure cap, and abort signal.\n * @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.\n */\nexport async function pollUntilDoneCoreAsync(\n\tdeps: PollDependencies,\n\toptions: CorePollOptions = {},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst { maxFailures, pollDelay, signal } = resolvePollOptions(options);\n\tif (signal?.aborted === true) {\n\t\treturn abortedResult(signal);\n\t}\n\n\tconst startedAt = deps.startedAt ?? deps.now();\n\tconst budget = openPollBudget(startedAt, options);\n\tlet state: LoopState = { consecutiveFailures: 0, lastTask: undefined };\n\tfor (;;) {\n\t\tconst elapsedMs = deps.now() - startedAt;\n\t\tif (elapsedMs >= budget.timeoutMs) {\n\t\t\treturn { err: makeTimeout(state.lastTask, budget), success: false };\n\t\t}\n\n\t\tconst outcome = await fetchOnceAsync(deps, { budget, signal });\n\t\tconst action = applyOutcome(outcome, { budget, maxFailures, signal, state });\n\t\tif (action.kind === \"return\") {\n\t\t\treturn action.result;\n\t\t}\n\n\t\t({ state } = action);\n\t\tconst sleepWasAborted = await sleepWithAbortAsync({\n\t\t\tms: pollDelay(elapsedMs),\n\t\t\tsignal,\n\t\t\tsleep: deps.sleep,\n\t\t});\n\t\tif (sleepWasAborted) {\n\t\t\treturn abortedResult(signal);\n\t\t}\n\t}\n}\n\n/**\n * Describes why the budget ended. A wait the transport refused up front\n * (one that carries `waitMs`) ends the poll before `timeoutMs` has elapsed,\n * so its message reports the budget left rather than an elapsed timeout.\n *\n * @param cause - The budget deadline failure, if a request reported one.\n * @param timeoutMs - The total poll budget in ms.\n * @returns The elapsed-timeout wording, or the budget left and the refused wait.\n */\nfunction timeoutMessage(\n\tcause: RequestDeadlineExceededError | undefined,\n\ttimeoutMs: number,\n): string {\n\tif (cause?.waitMs === undefined) {\n\t\treturn `Polling timed out after ${timeoutMs} ms`;\n\t}\n\n\treturn `Polling stopped with ${cause.remainingMs} ms of the ${timeoutMs} ms budget left: a required ${cause.waitMs} ms wait would exceed it`;\n}\n\nfunction makeTimeout(\n\ttask: LuauExecutionTask | undefined,\n\t{ cause, timeoutMs }: { cause?: RequestDeadlineExceededError; timeoutMs: number },\n): PollTimeoutError<LuauExecutionTask> {\n\treturn new PollTimeoutError(timeoutMessage(cause, timeoutMs), {\n\t\t...(cause === undefined ? {} : { cause }),\n\t\tlastObservedTask: task,\n\t\ttimeoutMs,\n\t});\n}\n\nfunction isBudgetDeadline(\n\terror: OpenCloudError,\n\tbudget: PollBudget,\n): error is RequestDeadlineExceededError {\n\treturn (\n\t\terror instanceof RequestDeadlineExceededError &&\n\t\terror.deadlineMs === budget.budgetDeadlineMs\n\t);\n}\n\nfunction resolvePollOptions(options: PollOptions): ResolvedPollOptions {\n\treturn {\n\t\tmaxFailures: options.maxConsecutivePollFailures ?? DEFAULT_POLL_FAILURE_CAP,\n\t\tpollDelay: options.pollDelay ?? defaultPollDelay,\n\t\tsignal: options.signal,\n\t};\n}\n\nfunction makeAborted(signal: AbortSignal | undefined): PollAbortedError {\n\treturn new PollAbortedError(\"Polling was aborted\", { reason: signal?.reason });\n}\n\nfunction abortedResult(signal: AbortSignal | undefined): Result<LuauExecutionTask, OpenCloudError> {\n\treturn { err: makeAborted(signal), success: false };\n}\n\n/**\n * Maps a single fetch outcome to the next loop action. Terminal, failed, and\n * aborted outcomes return immediately; a transient transport failure advances\n * the consecutive-failure count and returns once it reaches `maxFailures`; a\n * pending task resets the count and continues.\n *\n * @param outcome - The classified result of one poll fetch.\n * @param context - The loop state, failure cap, and abort signal.\n * @returns Whether to return a final Result or continue with updated state.\n */\nfunction applyOutcome(\n\toutcome: FetchOutcome,\n\t{ budget, maxFailures, signal, state }: OutcomeContext,\n): LoopAction {\n\tswitch (outcome.kind) {\n\t\tcase \"aborted\": {\n\t\t\treturn { kind: \"return\", result: abortedResult(signal) };\n\t\t}\n\t\tcase \"failed\": {\n\t\t\tif (signal?.aborted === true && isBudgetDeadline(outcome.error, budget)) {\n\t\t\t\treturn { kind: \"return\", result: abortedResult(signal) };\n\t\t\t}\n\n\t\t\tconst err = budgetFailure(outcome.error, { budget, lastTask: state.lastTask, signal });\n\t\t\treturn { kind: \"return\", result: { err, success: false } };\n\t\t}\n\t\tcase \"pending\": {\n\t\t\treturn { kind: \"continue\", state: { consecutiveFailures: 0, lastTask: outcome.task } };\n\t\t}\n\t\tcase \"terminal\": {\n\t\t\treturn { kind: \"return\", result: { data: outcome.task, success: true } };\n\t\t}\n\t\tcase \"transient\": {\n\t\t\tconst consecutiveFailures = state.consecutiveFailures + 1;\n\t\t\tif (consecutiveFailures >= maxFailures) {\n\t\t\t\treturn { kind: \"return\", result: { err: outcome.error, success: false } };\n\t\t\t}\n\n\t\t\treturn { kind: \"continue\", state: { consecutiveFailures, lastTask: state.lastTask } };\n\t\t}\n\t}\n}\n\nasync function sleepWithAbortAsync({ ms, signal, sleep }: SleepWithAbortOptions): Promise<boolean> {\n\treturn (await raceWithAbortAsync(async () => sleep(ms, signal), signal)) === ABORTED;\n}\n\n/**\n * A failed poll is worth re-polling only when it is a `NetworkError` carrying\n * a known transient transport code. A self-aborted request timeout has no\n * `code`, and an API response (4xx/5xx) is authoritative, so both abort the\n * loop rather than being re-polled. Transient-ness is classified against the\n * canonical `TRANSIENT_TRANSPORT_CODES` set; this is the loop's own tolerance\n * dimension, distinct from the per-request `retryableTransportCodes` override\n * (which governs request-level retries inside each poll). Loop tolerance is\n * bounded separately by `maxConsecutivePollFailures`.\n *\n * A 2xx whose body would not parse is deliberately not re-polled here: it is\n * recovered a layer down, by the request-level retry that\n * `RESPONSE_UNPARSEABLE` puts in every idempotent policy. Reaching this\n * function means that retry budget is already spent, and a fourth read of the\n * same body is not a different answer.\n *\n * @param error - The error returned by a failed poll.\n * @returns `true` when the loop should tolerate and re-poll.\n */\nfunction isTransientTransport(error: OpenCloudError): error is NetworkError {\n\tif (!(error instanceof NetworkError)) {\n\t\treturn false;\n\t}\n\n\tconst code = findErrorCode(error);\n\treturn code !== undefined && TRANSIENT_TRANSPORT_CODES.includes(code);\n}\n\nasync function fetchOnceAsync(\n\tdependencies: PollDependencies,\n\t{ budget, signal }: { budget: PollBudget; signal: AbortSignal | undefined },\n): Promise<FetchOutcome> {\n\tconst fetchResult = await raceWithAbortAsync(\n\t\tasync () => dependencies.fetch(budget.requestDeadlineMs),\n\t\tsignal,\n\t);\n\tif (fetchResult === ABORTED) {\n\t\treturn { kind: \"aborted\" };\n\t}\n\n\tif (!fetchResult.success) {\n\t\treturn isTransientTransport(fetchResult.err)\n\t\t\t? { error: fetchResult.err, kind: \"transient\" }\n\t\t\t: { error: fetchResult.err, kind: \"failed\" };\n\t}\n\n\treturn isTerminalTask(fetchResult.data)\n\t\t? { kind: \"terminal\", task: fetchResult.data }\n\t\t: { kind: \"pending\", task: fetchResult.data };\n}\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport {\n\tSUBMIT_HEAD_SPEC,\n\tSUBMIT_VERSION_SPEC,\n} from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tLuauExecutionTask,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { namesCapacityBlockers } from \"./capacity-error.ts\";\n\n/** One Luau task submission attempt through the resource client. */\nexport interface SubmitOnceCall {\n\t/** The resource client the submit runs through. */\n\treadonly inner: ResourceClient;\n\t/** Per-request options for the attempt. */\n\treadonly options: RequestOptions;\n\t/** The submitted target. */\n\treadonly parameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n\t/** Optionally refines a transport error with capacity evidence. */\n\treadonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;\n}\n\n/**\n * Submits a Luau task once. A 429 naming tasks that occupy the place never\n * locks the submit operation out, whether or not the caller opted into\n * capacity admission: it clears when those tasks end.\n *\n * @param call - Resource client, submit parameters, options, and refinement.\n * @returns The submitted task or the failure the attempt produced.\n */\nexport async function submitOnceAsync({\n\tinner,\n\toptions,\n\tparameters,\n\trefineError,\n}: SubmitOnceCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tfunction exemptsLockout(error: OpenCloudError): boolean {\n\t\treturn namesCapacityBlockers(error, parameters);\n\t}\n\n\tconst call = { exemptsLockout, options, refineError };\n\treturn \"versionId\" in parameters\n\t\t? inner.executeAsync({ ...call, parameters, spec: SUBMIT_VERSION_SPEC })\n\t\t: inner.executeAsync({ ...call, parameters, spec: SUBMIT_HEAD_SPEC });\n}\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport { GET_SPEC } from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { observeAdmissionWaitAsync } from \"../../internal/http/admission-wait.ts\";\nimport { waitDeadlineFailure } from \"../../internal/http/request-deadline.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport { raceWithAbortAsync } from \"../../internal/utils/abort.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { capacityErrorFrom, LuauExecutionCapacityError, luauTaskRefKey } from \"./capacity-error.ts\";\nimport { defaultPollDelay, isTerminalTask, type PollUntilDoneOptions } from \"./polling.ts\";\nimport { submitOnceAsync, type SubmitOnceCall } from \"./submit-once.ts\";\n\nconst MAX_CAPACITY_WAIT_MS = 2_147_483_647;\n\n/**\n * Per-request options for submitting a Luau execution task.\n *\n * @example\n *\n * ```ts\n * import type { LuauExecutionSubmitOptions } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const options: LuauExecutionSubmitOptions = { capacityWaitMs: 60_000 };\n * expect(options.capacityWaitMs).toBe(60_000);\n * ```\n *\n * @since 0.3.2\n */\nexport interface LuauExecutionSubmitOptions extends RequestOptions {\n\t/**\n\t * Maximum milliseconds to spend waiting for occupied place capacity, from 1\n\t * through 2,147,483,647. Supplying this value opts the submission into\n\t * capacity-aware admission.\n\t */\n\treadonly capacityWaitMs?: number;\n}\n\n/**\n * Per-request capacity and polling options for submitting and awaiting a Luau\n * execution task.\n *\n * @since 0.3.2\n */\nexport type LuauExecutionRunOptions = LuauExecutionSubmitOptions & PollUntilDoneOptions;\n\ninterface CapacitySubmitCall {\n\treadonly inner: ResourceClient;\n\treadonly options: LuauExecutionSubmitOptions | undefined;\n\treadonly parameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n}\n\ninterface ObserveBlockersCall {\n\treadonly blockers: ReadonlyArray<LuauExecutionTaskRef>;\n\treadonly inner: ResourceClient;\n\treadonly options: RequestOptions;\n}\n\ninterface CapacityWaitCall extends ObserveBlockersCall {\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly deadlineAt: number;\n\treadonly startedAt: number;\n}\n\ninterface CapacityAdmissionCall {\n\treadonly callerSignal: AbortSignal | undefined;\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly deadlineAt: number;\n\treadonly options: RequestOptions;\n\treadonly startedAt: number;\n\treadonly submitCall: SubmitOnceCall;\n}\n\ninterface CapacitySleepCall {\n\treadonly inner: ResourceClient;\n\treadonly options: RequestOptions;\n\treadonly waitMs: number;\n}\n\ninterface CapacityRetryCall {\n\treadonly callerSignal: AbortSignal | undefined;\n\treadonly current: LuauExecutionCapacityError;\n\treadonly options: RequestOptions;\n\treadonly submitCall: SubmitOnceCall;\n}\n\ntype CapacityRetryDecision =\n\t| { readonly capacityError: LuauExecutionCapacityError; readonly continue: true }\n\t| {\n\t\t\treadonly continue: false;\n\t\t\treadonly result: Result<LuauExecutionTask, OpenCloudError>;\n\t };\n\n/**\n * Submits through capacity admission when the caller opts in.\n *\n * @param call - Resource client, submit parameters, and per-request options.\n * @returns The submitted task or the failure that stopped admission.\n */\nexport async function submitWithCapacityAsync({\n\tinner,\n\toptions,\n\tparameters,\n}: CapacitySubmitCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst { capacityWaitMs, ...requestOptions } = options ?? {};\n\tif (capacityWaitMs === undefined) {\n\t\treturn submitOnceAsync({ inner, options: requestOptions, parameters });\n\t}\n\n\tfunction refineError(error: OpenCloudError): OpenCloudError {\n\t\treturn capacityErrorFrom(error, parameters) ?? error;\n\t}\n\n\tconst submitCall = { inner, options: requestOptions, parameters, refineError };\n\tconst first = await submitOnceAsync(submitCall);\n\tif (!isCapacityFailure(first)) {\n\t\treturn first;\n\t}\n\n\tif (\n\t\t!Number.isFinite(capacityWaitMs) ||\n\t\tcapacityWaitMs < 1 ||\n\t\tcapacityWaitMs > MAX_CAPACITY_WAIT_MS\n\t) {\n\t\treturn first;\n\t}\n\n\treturn admitWithinCapacityAsync({\n\t\tcapacityError: first.err,\n\t\toptions: requestOptions,\n\t\tsubmitCall,\n\t\twaitMs: capacityWaitMs,\n\t});\n}\n\nfunction isCapacityFailure(\n\tresult: Result<LuauExecutionTask, OpenCloudError>,\n): result is { readonly err: LuauExecutionCapacityError; readonly success: false } {\n\treturn !result.success && result.err instanceof LuauExecutionCapacityError;\n}\n\nfunction capacityBoundAborted(\n\toptions: RequestOptions,\n\tcallerSignal: AbortSignal | undefined,\n): boolean {\n\treturn options.signal?.aborted === true && callerSignal?.aborted !== true;\n}\n\nasync function observeBlockersAsync({\n\tblockers,\n\tinner,\n\toptions,\n}: ObserveBlockersCall): Promise<Result<LuauExecutionTaskRef | undefined, OpenCloudError>> {\n\tfor (const blocker of blockers) {\n\t\tconst observed = await inner.executeAsync({\n\t\t\toptions,\n\t\t\tparameters: { ref: blocker, view: \"BASIC\" as const },\n\t\t\tspec: GET_SPEC,\n\t\t});\n\t\tif (!observed.success) {\n\t\t\treturn observed;\n\t\t}\n\n\t\tif (isTerminalTask(observed.data)) {\n\t\t\treturn { data: blocker, success: true };\n\t\t}\n\t}\n\n\treturn { data: undefined, success: true };\n}\n\nasync function sleepForCapacityAsync({ inner, options, waitMs }: CapacitySleepCall): Promise<void> {\n\tawait observeAdmissionWaitAsync({\n\t\tdurationMs: waitMs,\n\t\tobserver: options.onAdmissionWait,\n\t\treason: \"operation-capacity\",\n\t\twaitAsync: async () => {\n\t\t\treturn raceWithAbortAsync(\n\t\t\t\tasync () => inner.sleep(waitMs, options.signal),\n\t\t\t\toptions.signal,\n\t\t\t);\n\t\t},\n\t});\n}\n\nasync function observeWithinCapacityAsync({\n\tblockers,\n\tcapacityError,\n\tdeadlineAt,\n\tinner,\n\toptions,\n\tstartedAt,\n}: CapacityWaitCall): Promise<Result<LuauExecutionTaskRef, OpenCloudError>> {\n\twhile (Date.now() < deadlineAt) {\n\t\tconst observed = await observeBlockersAsync({ blockers, inner, options });\n\t\tif (!observed.success) {\n\t\t\treturn observed;\n\t\t}\n\n\t\tif (observed.data !== undefined) {\n\t\t\treturn { data: observed.data, success: true };\n\t\t}\n\n\t\tconst elapsedMs = Date.now() - startedAt;\n\t\tconst pollWaitMs = defaultPollDelay(elapsedMs);\n\t\tconst deadlineFailure = waitDeadlineFailure({\n\t\t\tcause: capacityError,\n\t\t\tdeadlineMs: options.deadlineMs,\n\t\t\twaitMs: pollWaitMs,\n\t\t\twaitReason: \"operation-capacity\",\n\t\t});\n\t\tif (deadlineFailure !== undefined) {\n\t\t\treturn { err: deadlineFailure, success: false };\n\t\t}\n\n\t\tconst waitMs = Math.min(pollWaitMs, deadlineAt - Date.now());\n\t\tawait sleepForCapacityAsync({ inner, options, waitMs });\n\t}\n\n\treturn { err: capacityError, success: false };\n}\n\nfunction hasSameBlockers(\n\tleft: LuauExecutionCapacityError,\n\tright: LuauExecutionCapacityError,\n): boolean {\n\tif (left.blockers.length !== right.blockers.length) {\n\t\treturn false;\n\t}\n\n\tconst rightKeys = new Set(right.blockers.map(luauTaskRefKey));\n\treturn left.blockers.every((blocker) => rightKeys.has(luauTaskRefKey(blocker)));\n}\n\nasync function retryAfterCapacityAsync({\n\tcallerSignal,\n\tcurrent,\n\toptions,\n\tsubmitCall,\n}: CapacityRetryCall): Promise<CapacityRetryDecision> {\n\tconst retried = await submitOnceAsync(submitCall);\n\tif (!retried.success && capacityBoundAborted(options, callerSignal)) {\n\t\treturn { continue: false, result: { err: current, success: false } };\n\t}\n\n\tif (!isCapacityFailure(retried) || hasSameBlockers(current, retried.err)) {\n\t\treturn { continue: false, result: retried };\n\t}\n\n\treturn { capacityError: retried.err, continue: true };\n}\n\nasync function runCapacityAdmissionAsync({\n\tcallerSignal,\n\tcapacityError,\n\tdeadlineAt,\n\toptions,\n\tstartedAt,\n\tsubmitCall,\n}: CapacityAdmissionCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst cleared = new Set<string>();\n\tlet current = capacityError;\n\twhile (true) {\n\t\tconst pending = current.blockers.filter((blocker) => !cleared.has(luauTaskRefKey(blocker)));\n\t\tif (pending.length === 0) {\n\t\t\treturn { err: current, success: false };\n\t\t}\n\n\t\tconst observed = await observeWithinCapacityAsync({\n\t\t\tblockers: pending,\n\t\t\tcapacityError: current,\n\t\t\tdeadlineAt,\n\t\t\tinner: submitCall.inner,\n\t\t\toptions,\n\t\t\tstartedAt,\n\t\t});\n\t\tif (!observed.success) {\n\t\t\treturn capacityBoundAborted(options, callerSignal)\n\t\t\t\t? { err: current, success: false }\n\t\t\t\t: observed;\n\t\t}\n\n\t\tcleared.add(luauTaskRefKey(observed.data));\n\t\tconst retry = await retryAfterCapacityAsync({ callerSignal, current, options, submitCall });\n\t\tif (!retry.continue) {\n\t\t\treturn retry.result;\n\t\t}\n\n\t\tcurrent = retry.capacityError;\n\t}\n}\n\nasync function admitWithinCapacityAsync({\n\tcapacityError,\n\toptions,\n\tsubmitCall,\n\twaitMs,\n}: {\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly options: RequestOptions;\n\treadonly submitCall: SubmitOnceCall;\n\treadonly waitMs: number;\n}): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst deadline = new AbortController();\n\tconst timer = setTimeout(() => {\n\t\tdeadline.abort();\n\t}, waitMs);\n\tconst signal =\n\t\toptions.signal === undefined\n\t\t\t? deadline.signal\n\t\t\t: AbortSignal.any([options.signal, deadline.signal]);\n\tconst startedAt = Date.now();\n\ttry {\n\t\treturn await runCapacityAdmissionAsync({\n\t\t\tcallerSignal: options.signal,\n\t\t\tcapacityError,\n\t\t\tdeadlineAt: startedAt + waitMs,\n\t\t\toptions: { ...options, signal },\n\t\t\tstartedAt,\n\t\t\tsubmitCall: { ...submitCall, options: { ...submitCall.options, signal } },\n\t\t});\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\n","import { GET_SPEC } from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { type LuauExecutionRunOptions, submitWithCapacityAsync } from \"./capacity-admission.ts\";\nimport {\n\tbudgetFailure,\n\topenPollBudget,\n\ttype PollDependencies,\n\tpollUntilDoneCoreAsync,\n\ttype PollUntilDoneOptions,\n} from \"./polling.ts\";\n\n/**\n * Builds the {@link PollDependencies} bundle used by {@link\n * pollUntilDoneCoreAsync}, closing over the supplied {@link ResourceClient},\n * task ref, and per-request options so the core loop stays narrow.\n *\n * @param inner - The {@link ResourceClient} that issues each `tasks.get` call.\n * @param args - The polling options and the task ref to fetch on every iteration.\n * @returns A {@link PollDependencies} bundle wiring `fetch`, `now`, and `sleep`.\n */\nexport function buildPollDependencies(\n\tinner: ResourceClient,\n\targs: { options: PollUntilDoneOptions; ref: LuauExecutionTaskRef },\n): PollDependencies {\n\treturn {\n\t\tfetch: async (deadlineMs) => {\n\t\t\treturn inner.executeAsync({\n\t\t\t\toptions: withRequestDeadline(args.options, deadlineMs),\n\t\t\t\tparameters: { ref: args.ref, view: \"BASIC\" },\n\t\t\t\tspec: GET_SPEC,\n\t\t\t});\n\t\t},\n\t\tnow: Date.now,\n\t\tsleep: inner.sleep,\n\t};\n}\n\n/**\n * Submits a Luau execution task and polls it to a terminal state. Dispatches\n * to the head-version or specific-version submit spec based on the presence of\n * `versionId`, then delegates to {@link pollUntilDoneCoreAsync}. The poll\n * budget opens before the submit, so `timeoutMs` covers the submit and the\n * polling together; a submit cut off by the budget returns\n * `PollTimeoutError` with no task.\n *\n * @param inner - The {@link ResourceClient} that issues submit and poll calls.\n * @param args - The polling options and submit parameters.\n * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask}, or\n * the {@link OpenCloudError} that caused submit or polling to fail.\n */\nexport async function submitAndPollAsync(\n\tinner: ResourceClient,\n\t{\n\t\toptions,\n\t\tparameters,\n\t}: {\n\t\toptions: LuauExecutionRunOptions;\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n\t},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst startedAt = Date.now();\n\tconst budget = openPollBudget(startedAt, options);\n\tconst submitResult = await submitWithCapacityAsync({\n\t\tinner,\n\t\toptions: withRequestDeadline(options, budget.requestDeadlineMs),\n\t\tparameters,\n\t});\n\tif (!submitResult.success) {\n\t\treturn {\n\t\t\terr: budgetFailure(submitResult.err, {\n\t\t\t\tbudget,\n\t\t\t\tlastTask: undefined,\n\t\t\t\tsignal: options.signal,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn pollUntilDoneCoreAsync(\n\t\t{ ...buildPollDependencies(inner, { options, ref: submitResult.data.ref }), startedAt },\n\t\toptions,\n\t);\n}\n\n/**\n * Applies the budget's request deadline. It already folds in the caller's own\n * `deadlineMs`, so it is `undefined` only when the caller set none either.\n *\n * @template TOptions - The concrete option shape to preserve.\n * @param options - The caller's options.\n * @param deadlineMs - The request deadline from the opened budget.\n * @returns The options with `deadlineMs` set to the request deadline.\n */\nfunction withRequestDeadline<TOptions extends PollUntilDoneOptions>(\n\toptions: TOptions,\n\tdeadlineMs: number | undefined,\n): TOptions {\n\treturn { ...options, deadlineMs };\n}\n"],"mappings":";;;;;;AAQA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;AAuBrB,IAAa,6BAAb,cAAgD,eAAe;;CAE9D;CACA,OAAgC;;;;;;CAOhC,YAAY,UAA+C;EAC1D,MAAM,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;EAC3E,KAAK,WAAW,OAAO,OAAO,SAAS,KAAK,YAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;CACvF;AACD;;;;;;;AAQA,SAAgB,eAAe,KAAmC;CACjE,OAAO,GAAG,IAAI,UAAU,GAAG,IAAI,UAAU,GAAG,IAAI;AACjD;;;;;;;;;AAUA,SAAgB,kBACf,OACA,YACyC;CACzC,MAAM,WAAW,qBAAqB,OAAO,UAAU;CACvD,OAAO,SAAS,WAAW,IAAI,KAAA,IA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N;EAAE,GAAG,sBAAsB,OAAO;GAAE;GAAS,KAAK,aAAa,KAAK;EAAI,CAAC;EAAG;CAAU,GACtF,OACD;AACD;;;;;;;;;;AAWA,SAAS,oBACR,SACA,YACW;CACX,OAAO;EAAE,GAAG;EAAS;CAAW;AACjC"}
@@ -1,4 +1,4 @@
1
- import { s as isRecord } from "./resource-client-3cOhqZpX.mjs";
1
+ import { j as isRecord } from "./retry-CMRDvAR4.mjs";
2
2
  //#region src/internal/price-information.ts
3
3
  /**
4
4
  * Narrows `value` to {@link PriceInformationLike} for a given feature literal
@@ -39,4 +39,4 @@ function copyPriceInformation(wire) {
39
39
  //#endregion
40
40
  export { isPriceInformationLike as n, copyPriceInformation as t };
41
41
 
42
- //# sourceMappingURL=price-information-hWXV6DAI.mjs.map
42
+ //# sourceMappingURL=price-information-DEkEQ8Pq.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"price-information-hWXV6DAI.mjs","names":[],"sources":["../src/internal/price-information.ts"],"sourcesContent":["import { isRecord } from \"./utils/is-record.ts\";\n\n/**\n * Wire shape shared by every Roblox commerce resource that carries a\n * `priceInformation` block (game passes, developer products, ...). Resources\n * vary in the literal set their `enabledFeatures` may contain, so the feature\n * type is left as a parameter `F`.\n *\n * @template F - The string-literal union for this resource's pricing-feature flags.\n */\nexport interface PriceInformationLike<F extends string> {\n\t/** Default Robux price; `undefined` when the schema returns null. */\n\treadonly defaultPriceInRobux: number | undefined;\n\t/** Enabled pricing feature flags, in the order returned by the API. */\n\treadonly enabledFeatures: ReadonlyArray<F>;\n}\n\n/**\n * Narrows `value` to {@link PriceInformationLike} for a given feature literal\n * union by delegating per-element validation to the supplied `isFeature`\n * predicate.\n *\n * @template F - The pricing-feature literal union the caller wants to narrow to.\n * @param value - Unknown wire value to validate.\n * @param isFeature - Type guard for a single `enabledFeatures` element.\n * @returns `true` when `value` is a record whose `defaultPriceInRobux` is a\n * number, `null`, or absent and whose `enabledFeatures` is an array of\n * values that all satisfy `isFeature`.\n */\nexport function isPriceInformationLike<F extends string>(\n\tvalue: unknown,\n\tisFeature: (candidate: unknown) => candidate is F,\n): value is PriceInformationLike<F> {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\tconst defaultPrice = value[\"defaultPriceInRobux\"] ?? undefined;\n\tif (defaultPrice !== undefined && typeof defaultPrice !== \"number\") {\n\t\treturn false;\n\t}\n\n\tconst features = value[\"enabledFeatures\"];\n\tif (!Array.isArray(features)) {\n\t\treturn false;\n\t}\n\n\tfor (const feature of features) {\n\t\tif (!isFeature(feature)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns a fresh {@link PriceInformationLike} value with a new\n * `enabledFeatures` array, so the caller can hand the result on without\n * exposing the wire object's internal storage.\n *\n * @template F - The pricing-feature literal union of the input.\n * @param wire - Already-validated wire shape.\n * @returns A new record with the same defaults and a copied feature array.\n */\nexport function copyPriceInformation<F extends string>(\n\twire: PriceInformationLike<F>,\n): PriceInformationLike<F> {\n\treturn {\n\t\tdefaultPriceInRobux: wire.defaultPriceInRobux ?? undefined,\n\t\tenabledFeatures: [...wire.enabledFeatures],\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BA,SAAgB,uBACf,OACA,WACmC;CACnC,IAAI,CAAC,SAAS,KAAK,GAClB,OAAO;CAGR,MAAM,eAAe,MAAM,0BAA0B,KAAA;CACrD,IAAI,iBAAiB,KAAA,KAAa,OAAO,iBAAiB,UACzD,OAAO;CAGR,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAC1B,OAAO;CAGR,KAAK,MAAM,WAAW,UACrB,IAAI,CAAC,UAAU,OAAO,GACrB,OAAO;CAIT,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,qBACf,MAC0B;CAC1B,OAAO;EACN,qBAAqB,KAAK,uBAAuB,KAAA;EACjD,iBAAiB,CAAC,GAAG,KAAK,eAAe;CAC1C;AACD"}
1
+ {"version":3,"file":"price-information-DEkEQ8Pq.mjs","names":[],"sources":["../src/internal/price-information.ts"],"sourcesContent":["import { isRecord } from \"./utils/is-record.ts\";\n\n/**\n * Wire shape shared by every Roblox commerce resource that carries a\n * `priceInformation` block (game passes, developer products, ...). Resources\n * vary in the literal set their `enabledFeatures` may contain, so the feature\n * type is left as a parameter `F`.\n *\n * @template F - The string-literal union for this resource's pricing-feature flags.\n */\nexport interface PriceInformationLike<F extends string> {\n\t/** Default Robux price; `undefined` when the schema returns null. */\n\treadonly defaultPriceInRobux: number | undefined;\n\t/** Enabled pricing feature flags, in the order returned by the API. */\n\treadonly enabledFeatures: ReadonlyArray<F>;\n}\n\n/**\n * Narrows `value` to {@link PriceInformationLike} for a given feature literal\n * union by delegating per-element validation to the supplied `isFeature`\n * predicate.\n *\n * @template F - The pricing-feature literal union the caller wants to narrow to.\n * @param value - Unknown wire value to validate.\n * @param isFeature - Type guard for a single `enabledFeatures` element.\n * @returns `true` when `value` is a record whose `defaultPriceInRobux` is a\n * number, `null`, or absent and whose `enabledFeatures` is an array of\n * values that all satisfy `isFeature`.\n */\nexport function isPriceInformationLike<F extends string>(\n\tvalue: unknown,\n\tisFeature: (candidate: unknown) => candidate is F,\n): value is PriceInformationLike<F> {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\tconst defaultPrice = value[\"defaultPriceInRobux\"] ?? undefined;\n\tif (defaultPrice !== undefined && typeof defaultPrice !== \"number\") {\n\t\treturn false;\n\t}\n\n\tconst features = value[\"enabledFeatures\"];\n\tif (!Array.isArray(features)) {\n\t\treturn false;\n\t}\n\n\tfor (const feature of features) {\n\t\tif (!isFeature(feature)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns a fresh {@link PriceInformationLike} value with a new\n * `enabledFeatures` array, so the caller can hand the result on without\n * exposing the wire object's internal storage.\n *\n * @template F - The pricing-feature literal union of the input.\n * @param wire - Already-validated wire shape.\n * @returns A new record with the same defaults and a copied feature array.\n */\nexport function copyPriceInformation<F extends string>(\n\twire: PriceInformationLike<F>,\n): PriceInformationLike<F> {\n\treturn {\n\t\tdefaultPriceInRobux: wire.defaultPriceInRobux ?? undefined,\n\t\tenabledFeatures: [...wire.enabledFeatures],\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BA,SAAgB,uBACf,OACA,WACmC;CACnC,IAAI,CAAC,SAAS,KAAK,GAClB,OAAO;CAGR,MAAM,eAAe,MAAM,0BAA0B,KAAA;CACrD,IAAI,iBAAiB,KAAA,KAAa,OAAO,iBAAiB,UACzD,OAAO;CAGR,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAC1B,OAAO;CAGR,KAAK,MAAM,WAAW,UACrB,IAAI,CAAC,UAAU,OAAO,GACrB,OAAO;CAIT,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,qBACf,MAC0B;CAC1B,OAAO;EACN,qBAAqB,KAAK,uBAAuB,KAAA;EACjD,iBAAiB,CAAC,GAAG,KAAK,eAAe;CAC1C;AACD"}
@@ -0,0 +1,168 @@
1
+ import { c as OpenCloudClientOptions, d as RequestOptions, g as OpenCloudError, h as SleepFunc, m as Result, o as HttpRequest, s as HttpResponse } from "./types-CdMr_J1M.mjs";
2
+ import { i as RetryResolvable, n as MethodKind, o as RateLimitError } from "./retry-C2oHesDx.mjs";
3
+ //#region src/internal/http/rate-limit-observation.d.ts
4
+ /**
5
+ * Returns `true` when a long 429's evidence shows it clears on some other
6
+ * event than its guided wait, so it must not lock its scope out.
7
+ */
8
+ type LockoutExemption = (error: RateLimitError) => boolean;
9
+ //#endregion
10
+ //#region src/internal/http/rate-limit-queue.d.ts
11
+ /**
12
+ * Identifies and bounds a single Roblox Open Cloud operation for rate
13
+ * limiting, e.g. `{ operationKey: "game-passes.create", maxPerSecond: 5 }`.
14
+ */
15
+ interface OperationLimit {
16
+ /**
17
+ * How many requests may be issued back to back before pacing begins,
18
+ * as a whole number of requests. Defaults to `max(1, maxPerSecond)`,
19
+ * which leaves operations at or above 1/s paced exactly as their
20
+ * sustained rate allows while still granting a slower operation one
21
+ * request after it has idled. Set this to the allowance the schema
22
+ * documents (e.g. 5 per minute) to grant the burst the server permits.
23
+ */
24
+ readonly burstCapacity?: number;
25
+ /** Maximum sustained request rate in requests per second. */
26
+ readonly maxPerSecond: number;
27
+ /**
28
+ * Stable identifier for the operation (e.g. "game-passes.create"). Not
29
+ * consumed by the queue itself; callers use it to key per-operation
30
+ * queues in a registry (see GamePassesClient).
31
+ */
32
+ readonly operationKey: string;
33
+ }
34
+ //#endregion
35
+ //#region src/internal/resource-client.d.ts
36
+ /**
37
+ * Describes a single resource method's shape for dispatch through
38
+ * `ResourceClient.execute`. Each resource client declares one module-level
39
+ * constant per public method; that constant binds the four resource-specific
40
+ * values (request builder, response parser, retry-policy method kind,
41
+ * operation-level rate limit) and flows through `execute` uniformly.
42
+ *
43
+ * @template P - The resource-specific parameter shape the builder
44
+ * accepts.
45
+ * @template T - The resource-specific parsed success type the parser
46
+ * produces.
47
+ */
48
+ interface ResourceMethodSpec<P, T> {
49
+ /**
50
+ * Marks an Operation that Roblox accepts only with an API key. An OAuth
51
+ * call returns `CredentialNotSupportedError` with no token and no request.
52
+ */
53
+ readonly apiKeyOnly?: boolean;
54
+ /**
55
+ * Builds the pure {@link HttpRequest} for a single call. Returns a
56
+ * {@link Result} so a builder can short-circuit with a local error
57
+ * (typically a {@link OpenCloudError} subclass such as `ValidationError`)
58
+ * before any HTTP, queue, or retry work happens. Builders that cannot
59
+ * fail wrap their return as `{ data: request, success: true }`.
60
+ */
61
+ readonly buildRequest: (parameters: P) => Result<HttpRequest, OpenCloudError>;
62
+ /** Method-level retry defaults merged into the resolved config. */
63
+ readonly methodDefaults: Partial<RetryResolvable>;
64
+ /**
65
+ * Method kind, controlling merge precedence: `"create"` lets method
66
+ * defaults win over client config so create safety cannot be relaxed
67
+ * silently; `"idempotent"` lets client config win over method defaults
68
+ * so consumers can loosen retry globally.
69
+ */
70
+ readonly methodKind: MethodKind;
71
+ /**
72
+ * Operation-level rate limit, keyed into the client's per-key queue map.
73
+ */
74
+ readonly operationLimit: OperationLimit;
75
+ /**
76
+ * Converts the full {@link HttpResponse} into the resource-specific
77
+ * parsed shape. Takes the whole response (body, status, headers) so
78
+ * future parsers can read headers without widening the signature.
79
+ */
80
+ readonly parse: (response: HttpResponse) => Result<T, OpenCloudError>;
81
+ /**
82
+ * Open Cloud scopes the API key or OAuth token must carry for this
83
+ * method, sourced from the vendored OpenAPI schema's `x-roblox-scopes`.
84
+ * When set, a 401 or 403 ApiError from the upstream call is upgraded to
85
+ * a {@link PermissionError} carrying these scopes alongside
86
+ * {@link OperationLimit.operationKey}, so callers can name the missing
87
+ * scope instead of just the HTTP status. On an OAuth credential a
88
+ * non-gateway 401 is a `CredentialRejectedError` instead, and the 403
89
+ * message adds a grant hint. Optional so test specs and
90
+ * not-yet-wired resources can opt out.
91
+ */
92
+ readonly requiredScopes?: ReadonlyArray<string>;
93
+ /**
94
+ * Marks an Operation that Roblox documents as unauthenticated, served from
95
+ * this origin. The call sends no credential, never asks an OAuth provider
96
+ * for a token, and shares one rate-limit queue across credentials.
97
+ */
98
+ readonly unauthenticatedBaseUrl?: string;
99
+ }
100
+ /**
101
+ * Single-argument bundle consumed by `ResourceClient.execute`: the per-method
102
+ * spec, the resource-specific parameters, and optional per-request config
103
+ * overrides.
104
+ *
105
+ * @template P - The resource-specific parameter shape the builder accepts.
106
+ * @template T - The resource-specific parsed success type the parser produces.
107
+ */
108
+ interface ExecuteCall<P, T> {
109
+ /**
110
+ * Optionally exempts a long 429 from locking the operation out, when its
111
+ * evidence shows it clears on some other event than its guided wait.
112
+ */
113
+ readonly exemptsLockout?: LockoutExemption | undefined;
114
+ /** Optional per-request config overrides. */
115
+ readonly options?: RequestOptions | undefined;
116
+ /** Resource-specific request parameters. */
117
+ readonly parameters: P;
118
+ /** Optionally refines a transport error with resource-specific evidence. */
119
+ readonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;
120
+ /**
121
+ * Per-method binding of builder, parser, method kind, and operation limit.
122
+ */
123
+ readonly spec: ResourceMethodSpec<P, T>;
124
+ }
125
+ /**
126
+ * Internal orchestrator shared by every Open Cloud resource client. Holds
127
+ * the frozen client config, observability hooks, injected HTTP client and
128
+ * sleep, and the per-effective-key rate-limit queue registry. Resource
129
+ * classes compose one instance and dispatch every public method through
130
+ * {@link ResourceClient.executeAsync} with a per-method {@link ResourceMethodSpec}.
131
+ * Not exported from any package subpath; reachable only via sibling
132
+ * `src/resources/**` modules in this package.
133
+ */
134
+ declare class ResourceClient {
135
+ #private;
136
+ /**
137
+ * Creates a new {@link ResourceClient}. Resolves the injected HTTP
138
+ * client and sleep (defaulting to fetch + `setTimeout`) and freezes the
139
+ * merged client config so subsequent calls cannot mutate it.
140
+ *
141
+ * @param options - Client-level configuration including the credential
142
+ * and optional construction-time test seams.
143
+ */
144
+ constructor({ hooks, httpClient, reportHint, sleep, ...overrides }: OpenCloudClientOptions);
145
+ /**
146
+ * Dispatches a single resource-method call. Merges the frozen client
147
+ * config with the method's `methodDefaults` and the caller's optional
148
+ * per-request `options`, routes through the effective-credential rate-limit
149
+ * queue, runs the retry loop, and finally parses the response with the
150
+ * spec's parser.
151
+ *
152
+ * @param call - The per-method spec, resource-specific parameters, and
153
+ * optional per-request overrides.
154
+ * @returns The parsed success payload or the {@link OpenCloudError} that
155
+ * caused the request to fail. Never throws.
156
+ * @rejects An unexpected collaborator failure unrelated to caller cancellation.
157
+ */
158
+ executeAsync<P, T>({ exemptsLockout, options, parameters, refineError, spec }: ExecuteCall<P, T>): Promise<Result<T, OpenCloudError>>;
159
+ /**
160
+ * Returns the sleep function used by this client instance.
161
+ *
162
+ * @returns The sleep function injected at construction time.
163
+ */
164
+ get sleep(): SleepFunc;
165
+ }
166
+ //#endregion
167
+ export { ResourceClient as t };
168
+ //# sourceMappingURL=resource-client-BCKukheG.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-client-BCKukheG.d.mts","names":[],"sources":["../src/internal/http/rate-limit-observation.ts","../src/internal/http/rate-limit-queue.ts","../src/internal/resource-client.ts"],"mappings":";;;;;;;KAcY,oBAAoB,OAAO;;;;;;;UCDtB;;;;;;;;;WASP;;WAEA;;;;;;WAMA;;;;;;;;;;;;;;;;UC4BO,mBAAmB,GAAG;;;;;WAK7B;;;;;;;;WAQA,eAAe,YAAY,MAAM,OAAO,aAAa;;WAErD,gBAAgB,QAAQ;;;;;;;WAOxB,YAAY;;;;WAIZ,gBAAgB;;;;;;WAMhB,QAAQ,UAAU,iBAAiB,OAAO,GAAG;;;;;;;;;;;;WAY7C,iBAAiB;;;;;;WAMjB;;;;;;;;;;UAWA,YAAY,GAAG;;;;;WAKf,iBAAiB;;WAEjB,UAAU;;WAEV,YAAY;;WAEZ,gBAAgB,OAAO,mBAAmB;;;;WAI1C,MAAM,mBAAmB,GAAG;;;;;;;;;;;cA0EzB;;;;;;;;;;EAiBZ,cAAc,OAAO,YAAY,YAAY,UAAU,aAAa;;;;;;;;;;;;;;EA2BpE,aAA0B,GAAG,KAC5B,gBACA,SACA,YACA,aACA,QACE,YAAY,GAAG,KAAK,QAAQ,OAAO,GAAG;;;;;;MAmC9B,SAAS"}