@bedrock-rbx/ocale 0.4.0 → 0.5.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.
- package/README.md +1 -0
- package/dist/assets.d.mts +64 -0
- package/dist/assets.d.mts.map +1 -0
- package/dist/assets.mjs +301 -0
- package/dist/assets.mjs.map +1 -0
- package/dist/badge-insufficient-funds-BLFvQZt1.mjs +91 -0
- package/dist/badge-insufficient-funds-BLFvQZt1.mjs.map +1 -0
- package/dist/badges.d.mts +136 -17
- package/dist/badges.d.mts.map +1 -1
- package/dist/badges.mjs +375 -99
- package/dist/badges.mjs.map +1 -1
- package/dist/{capacity-admission-hycCFkTo.d.mts → capacity-admission-Ce2V9QNb.d.mts} +2 -10
- package/dist/capacity-admission-Ce2V9QNb.d.mts.map +1 -0
- package/dist/{data.generated-D_vpa5-g.d.mts → data.generated-B4Fztv_7.d.mts} +1 -3
- package/dist/{data.generated-D_vpa5-g.d.mts.map → data.generated-B4Fztv_7.d.mts.map} +1 -1
- package/dist/developer-products.d.mts +29 -11
- package/dist/developer-products.d.mts.map +1 -1
- package/dist/developer-products.mjs +104 -18
- package/dist/developer-products.mjs.map +1 -1
- package/dist/game-passes.d.mts +2 -10
- package/dist/game-passes.d.mts.map +1 -1
- package/dist/game-passes.mjs +12 -18
- package/dist/game-passes.mjs.map +1 -1
- package/dist/index.d.mts +58 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -12
- package/dist/index.mjs.map +1 -1
- package/dist/is-date-time-string-C91G44SI.mjs +19 -0
- package/dist/is-date-time-string-C91G44SI.mjs.map +1 -0
- package/dist/locales.d.mts +1 -3
- package/dist/locales.d.mts.map +1 -1
- package/dist/locales.mjs +2 -4
- package/dist/locales.mjs.map +1 -1
- package/dist/luau-execution.d.mts +2 -8
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +7 -11
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{network-error-iVSng5MT.mjs → network-error-P4An7nUB.mjs} +5 -9
- package/dist/{network-error-iVSng5MT.mjs.map → network-error-P4An7nUB.mjs.map} +1 -1
- package/dist/places.d.mts +57 -9
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +127 -21
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-DzztDymd.mjs → poll-timeout-BCxgN97O.mjs} +4 -6
- package/dist/{poll-timeout-DzztDymd.mjs.map → poll-timeout-BCxgN97O.mjs.map} +1 -1
- package/dist/{polling-helpers-DfF5dspc.mjs → polling-helpers-BtEYR5dN.mjs} +19 -30
- package/dist/polling-helpers-BtEYR5dN.mjs.map +1 -0
- package/dist/{price-information-DEkEQ8Pq.mjs → price-information--d6GZAcp.mjs} +3 -4
- package/dist/{price-information-DEkEQ8Pq.mjs.map → price-information--d6GZAcp.mjs.map} +1 -1
- package/dist/{resource-client-BCKukheG.d.mts → resource-client-CF8SPsV8.d.mts} +3 -9
- package/dist/resource-client-CF8SPsV8.d.mts.map +1 -0
- package/dist/{resource-client-CaIVr-go.mjs → resource-client-Cm_bPcCs.mjs} +23 -59
- package/dist/resource-client-Cm_bPcCs.mjs.map +1 -0
- package/dist/{retry-C2oHesDx.d.mts → retry-DYxm_eBU.d.mts} +2 -6
- package/dist/retry-DYxm_eBU.d.mts.map +1 -0
- package/dist/{retry-CMRDvAR4.mjs → retry-Dv5TsY9O.mjs} +50 -52
- package/dist/retry-Dv5TsY9O.mjs.map +1 -0
- package/dist/{signatures-JF-7Psce.mjs → signatures-CtJ7jfVN.mjs} +2 -3
- package/dist/{signatures-JF-7Psce.mjs.map → signatures-CtJ7jfVN.mjs.map} +1 -1
- package/dist/storage.d.mts +2 -12
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +12 -20
- package/dist/storage.mjs.map +1 -1
- package/dist/testing.d.mts +2 -54
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +16 -30
- package/dist/testing.mjs.map +1 -1
- package/dist/{to-blob-RPqMBuft.mjs → to-blob-Bqu7bmlE.mjs} +2 -3
- package/dist/{to-blob-RPqMBuft.mjs.map → to-blob-Bqu7bmlE.mjs.map} +1 -1
- package/dist/{types-CdMr_J1M.d.mts → types-Z4abDJfK.d.mts} +1 -9
- package/dist/types-Z4abDJfK.d.mts.map +1 -0
- package/dist/universes.d.mts +4 -18
- package/dist/universes.d.mts.map +1 -1
- package/dist/universes.mjs +27 -47
- package/dist/universes.mjs.map +1 -1
- package/dist/{validation-964VNlbp.mjs → validation-kaTLLAD1.mjs} +3 -4
- package/dist/{validation-964VNlbp.mjs.map → validation-kaTLLAD1.mjs.map} +1 -1
- package/dist/{wire-DJqupefn.d.mts → wire-DDG87I-d.d.mts} +1 -3
- package/dist/wire-DDG87I-d.d.mts.map +1 -0
- package/package.json +8 -7
- package/dist/badge-cost-mismatch-DrlvhlQc.mjs +0 -47
- package/dist/badge-cost-mismatch-DrlvhlQc.mjs.map +0 -1
- package/dist/capacity-admission-hycCFkTo.d.mts.map +0 -1
- package/dist/polling-helpers-DfF5dspc.mjs.map +0 -1
- package/dist/resource-client-BCKukheG.d.mts.map +0 -1
- package/dist/resource-client-CaIVr-go.mjs.map +0 -1
- package/dist/retry-C2oHesDx.d.mts.map +0 -1
- package/dist/retry-CMRDvAR4.mjs.map +0 -1
- package/dist/types-CdMr_J1M.d.mts.map +0 -1
- package/dist/wire-DJqupefn.d.mts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrock-rbx/ocale",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Roblox Open Cloud API client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
".": "./dist/index.mjs",
|
|
30
|
+
"./assets": "./dist/assets.mjs",
|
|
30
31
|
"./badges": "./dist/badges.mjs",
|
|
31
32
|
"./developer-products": "./dist/developer-products.mjs",
|
|
32
33
|
"./game-passes": "./dist/game-passes.mjs",
|
|
@@ -46,18 +47,18 @@
|
|
|
46
47
|
"@bedrock-rbx/testing": "0.0.0",
|
|
47
48
|
"@bedrock-rbx/typescript-config": "0.0.0",
|
|
48
49
|
"@bedrock-rbx/vite-config": "0.0.0",
|
|
49
|
-
"@stryker-mutator/api": "10.
|
|
50
|
-
"@stryker-mutator/core": "10.
|
|
51
|
-
"@stryker-mutator/typescript-checker": "10.
|
|
52
|
-
"@stryker-mutator/vitest-runner": "10.
|
|
50
|
+
"@stryker-mutator/api": "10.1.1",
|
|
51
|
+
"@stryker-mutator/core": "10.1.1",
|
|
52
|
+
"@stryker-mutator/typescript-checker": "10.1.1",
|
|
53
|
+
"@stryker-mutator/vitest-runner": "10.1.1",
|
|
53
54
|
"@total-typescript/shoehorn": "0.1.2",
|
|
54
55
|
"@types/bun": "1.4.4",
|
|
55
56
|
"ajv": "8.20.0",
|
|
56
57
|
"ajv-formats": "3.0.1",
|
|
57
|
-
"oxc-minify": "0.
|
|
58
|
+
"oxc-minify": "0.158.0",
|
|
58
59
|
"type-fest": "5.10.0",
|
|
59
60
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
60
|
-
"vitest": "5.0
|
|
61
|
+
"vitest": "5.1.0"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=24.12.0",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { s as OpenCloudError } from "./network-error-iVSng5MT.mjs";
|
|
2
|
-
//#region src/errors/badge-cost-mismatch.ts
|
|
3
|
-
/**
|
|
4
|
-
* Returned when Roblox refuses a badge create because its `expectedCost`
|
|
5
|
-
* differs from what the badge would actually cost (body error code `18`).
|
|
6
|
-
* Nothing is charged. A create sent with `expectedCost: 0` gets this once the
|
|
7
|
-
* universe has used its free badge quota for the day. The upstream `ApiError`
|
|
8
|
-
* is the `cause`.
|
|
9
|
-
*
|
|
10
|
-
* @since 0.4.0
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { BadgeCostMismatchError } from "@bedrock-rbx/ocale";
|
|
16
|
-
*
|
|
17
|
-
* const error = new BadgeCostMismatchError(
|
|
18
|
-
* "Expected badge cost is different from the actual badge cost.",
|
|
19
|
-
* { code: "18", expectedCost: 0, statusCode: 403 },
|
|
20
|
-
* );
|
|
21
|
-
*
|
|
22
|
-
* // A free create was refused: the free badge quota is spent for today.
|
|
23
|
-
* expect(error.expectedCost).toBe(0);
|
|
24
|
-
* expect(error.statusCode).toBe(403);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
var BadgeCostMismatchError = class extends OpenCloudError {
|
|
28
|
-
expectedCost;
|
|
29
|
-
name = "BadgeCostMismatchError";
|
|
30
|
-
statusCode;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new BadgeCostMismatchError.
|
|
33
|
-
*
|
|
34
|
-
* @param message - Human-readable error description.
|
|
35
|
-
* @param options - Error options including the cost the create expected
|
|
36
|
-
* and the HTTP status of the refusal.
|
|
37
|
-
*/
|
|
38
|
-
constructor(message, options) {
|
|
39
|
-
super(message, options);
|
|
40
|
-
this.expectedCost = options.expectedCost;
|
|
41
|
-
this.statusCode = options.statusCode;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
export { BadgeCostMismatchError as t };
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=badge-cost-mismatch-DrlvhlQc.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge-cost-mismatch-DrlvhlQc.mjs","names":[],"sources":["../src/errors/badge-cost-mismatch.ts"],"sourcesContent":["import { OpenCloudError, type OpenCloudErrorOptions } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link BadgeCostMismatchError}.\n *\n * @since 0.4.0\n */\nexport interface BadgeCostMismatchErrorOptions extends OpenCloudErrorOptions {\n\t/** The `expectedCost` the create sent, or `undefined` when it sent none. */\n\treadonly expectedCost: number | undefined;\n\t/** HTTP status code of the refusal. */\n\treadonly statusCode: number;\n}\n\n/**\n * Returned when Roblox refuses a badge create because its `expectedCost`\n * differs from what the badge would actually cost (body error code `18`).\n * Nothing is charged. A create sent with `expectedCost: 0` gets this once the\n * universe has used its free badge quota for the day. The upstream `ApiError`\n * is the `cause`.\n *\n * @since 0.4.0\n *\n * @example\n *\n * ```ts\n * import { BadgeCostMismatchError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new BadgeCostMismatchError(\n * \"Expected badge cost is different from the actual badge cost.\",\n * { code: \"18\", expectedCost: 0, statusCode: 403 },\n * );\n *\n * // A free create was refused: the free badge quota is spent for today.\n * expect(error.expectedCost).toBe(0);\n * expect(error.statusCode).toBe(403);\n * ```\n */\nexport class BadgeCostMismatchError extends OpenCloudError {\n\tpublic readonly expectedCost: number | undefined;\n\tpublic override readonly name: string = \"BadgeCostMismatchError\";\n\tpublic readonly statusCode: number;\n\n\t/**\n\t * Creates a new BadgeCostMismatchError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the cost the create expected\n\t * and the HTTP status of the refusal.\n\t */\n\tconstructor(message: string, options: BadgeCostMismatchErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.expectedCost = options.expectedCost;\n\t\tthis.statusCode = options.statusCode;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAa,yBAAb,cAA4C,eAAe;CAC1D;CACA,OAAwC;CACxC;;;;;;;;CASA,YAAY,SAAiB,SAAwC;EACpE,MAAM,SAAS,OAAO;EACtB,KAAK,eAAe,QAAQ;EAC5B,KAAK,aAAa,QAAQ;CAC3B;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capacity-admission-hycCFkTo.d.mts","names":[],"sources":["../src/domains/cloud-v2/luau-execution-tasks/types.ts","../src/domains/cloud-v2/luau-execution-task-logs/types.ts","../src/resources/luau-execution/polling.ts","../src/resources/luau-execution/capacity-admission.ts"],"mappings":";;;;;;;;;UAOiB;;;;;WAKP;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;;;;;;;;UAUO;;;;;WAKP;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;;;;;;;;;;;UAYO;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;UASO;;WAEP,KAAK;;;;;;WAML;;;;;;;;;;;UAYO,uBAAuB;;;;;WAK9B;;;;;;;;;;UAWO,qBAAqB;;;;;;WAM5B;aAAmB,SAAS,cAAc;;;WAE1C;;;;;;;;;;UAWO,mBAAmB;;WAE1B;;;;;;;;aAQC;;aAOA;;;WAGD;;;;;;;;KASE,oBAAoB,eAAe,aAAa;;;;;;UAOlD;;;;;WAKA;;;;;;WAMA;;;;;WAKA,YAAY;;WAEZ;;WAEA,KAAK;;;;;;WAML;;;;;WAKA,YAAY;;;;WAIZ;;;;;;;;;;UC1MO;;;;;;WAMP;;;;;WAKA;;WAEA,KAAK;;;;;;;;;UAUE;;WAEP;;WAEA;;;;;;WAMA;;;;;;;;;;UAWO;;WAEP,UAAU,cAAc;;;;;WAKxB;;;;;;;;;;;;;;;;;;;;;;;;iBCDM,iBAAiB;;;;;;;KAuDrB,uBAAuB,cAAc;;UAGvC;;;;;;WAMA;;;;;WAKA,aAAa;;;;;WAKb,SAAS;;;;;;;;WAQT;;;;;;;;;;;;;;;;;;UC5GO,mCAAmC;;;;;;WAM1C;;;;;;;;KASE,0BAA0B,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CA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EACC,SACA,cAKoD;CACrD,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,SAAS,eAAe,WAAW,OAAO;CAChD,MAAM,eAAe,MAAM,wBAAwB;EAClD;EACA,SAAS,oBAAoB,SAAS,OAAO,iBAAiB;EAC9D;CACD,CAAC;CACD,IAAI,CAAC,aAAa,SACjB,OAAO;EACN,KAAK,cAAc,aAAa,KAAK;GACpC;GACA,UAAU,KAAA;GACV,QAAQ,QAAQ;EACjB,CAAC;EACD,SAAS;CACV;CAGD,OAAO,uBACN;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 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-client-CaIVr-go.mjs","names":["MS_PER_SECOND","ignoreRejection"],"sources":["../src/internal/utils/is-date-time-string.ts","../src/internal/utils/to-json-details.ts","../src/internal/api-key-only.ts","../src/internal/credential-snapshot.ts","../src/internal/http/admission-wait.ts","../src/internal/http/budget-tracker.ts","../src/internal/http/request-deadline.ts","../src/internal/http/budget-gate.ts","../src/internal/http/credential-rejection.ts","../src/internal/http/execute.ts","../src/internal/http/rate-limit-observation.ts","../src/internal/http/rate-limit-queue.ts","../src/internal/http/request-config.ts","../src/internal/utils/sleep.ts","../src/internal/http/resolve-dependencies.ts","../src/internal/http/start-request.ts","../src/internal/http/credential.ts","../src/internal/http/unauthenticated.ts","../src/internal/with-request-context.ts","../src/internal/resource-client.ts"],"sourcesContent":["/**\n * Narrows `value` to a string that parses to a real {@link Date} via the\n * `Date(string)` constructor. Used by resource parsers to gate\n * `format: date-time` wire fields before handing them to `new Date(...)`,\n * which silently produces an `Invalid Date` for invalid input.\n *\n * @param value - The unknown wire value to validate.\n * @returns `true` when `value` is a string and `new Date(value).getTime()`\n * is not `NaN`.\n */\nexport function isDateTimeString(value: unknown): value is string {\n\tif (typeof value !== \"string\") {\n\t\treturn false;\n\t}\n\n\tconst parsed = new Date(value);\n\treturn !Number.isNaN(parsed.getTime());\n}\n","import { isRecord } from \"./is-record.ts\";\n\n/**\n * Narrows an untyped response body to the `JSONValue` accepted by\n * `ApiError.details`. `HttpResponse.body` is `unknown` because a transport may\n * hand back anything, but only a JSON graph is safe to retain on an error for\n * diagnostics. Anything else — functions, symbols, bigints, class instances,\n * or a cyclic graph — is dropped rather than asserted through.\n *\n * @param value - The parsed response body, or `undefined` for an empty body.\n * @returns The value as a `JSONValue`, or `undefined` when it is absent or not\n * JSON-representable.\n */\nexport function toJsonDetails(value: unknown): JSONValue | undefined {\n\treturn asJsonValue(value, new Set());\n}\n\nfunction asJsonValue(value: unknown, seen: Set<object>): JSONValue | undefined {\n\tif (value === null) {\n\t\t// eslint-disable-next-line unicorn/no-null -- JSON null is a JSONValue; the repo's undefined-only rule stops at this wire boundary\n\t\treturn null;\n\t}\n\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n\t\treturn value;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn asJsonArray(value, seen);\n\t}\n\n\tif (isRecord(value)) {\n\t\treturn asJsonObject(value, seen);\n\t}\n\n\treturn undefined;\n}\n\nfunction asJsonArray(value: ReadonlyArray<unknown>, seen: Set<object>): JSONValue | undefined {\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\tconst items: Array<JSONValue> = [];\n\tfor (const item of value) {\n\t\tconst converted = asJsonValue(item, seen);\n\t\tif (converted === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\titems.push(converted);\n\t}\n\n\tseen.delete(value);\n\treturn items;\n}\n\nfunction asJsonObject(value: Record<string, unknown>, seen: Set<object>): JSONValue | undefined {\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\tconst entries: Array<[string, JSONValue]> = [];\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tconst converted = asJsonValue(item, seen);\n\t\tif (converted === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tentries.push([key, converted]);\n\t}\n\n\tseen.delete(value);\n\treturn Object.fromEntries(entries);\n}\n","import type { Credential } from \"../client/types.ts\";\nimport { CredentialNotSupportedError } from \"../errors/credential-not-supported.ts\";\nimport type { Result } from \"../types.ts\";\nimport type { OperationLimit } from \"./http/rate-limit-queue.ts\";\n\n/** The parts of a method spec the API-key-only check reads. */\ninterface ApiKeyOnlySpec {\n\treadonly apiKeyOnly?: boolean;\n\treadonly operationLimit: OperationLimit;\n}\n\n/**\n * Fails an OAuth call to an Operation that Roblox accepts only with an API\n * key. Runs before the provider is asked for a token and before any request.\n *\n * @param spec - The method spec's flag and operation limit.\n * @param credential - The effective credential for the call.\n * @returns A {@link CredentialNotSupportedError} failure, or `undefined` when\n * the call may proceed.\n */\nexport function credentialNotSupportedFailure(\n\tspec: ApiKeyOnlySpec,\n\tcredential: Credential,\n): Result<never, CredentialNotSupportedError> | undefined {\n\tif (spec.apiKeyOnly !== true || credential.kind !== \"oauth\") {\n\t\treturn undefined;\n\t}\n\n\tconst { operationKey } = spec.operationLimit;\n\treturn {\n\t\terr: new CredentialNotSupportedError(\n\t\t\t`Operation ${operationKey} accepts only an API key credential`,\n\t\t\t{ operationKey },\n\t\t),\n\t\tsuccess: false,\n\t};\n}\n","import type { Credential } from \"../client/types.ts\";\n\n/**\n * Copies a caller's credential, so a later change to the caller's object\n * cannot change the key or the OAuth identity a client or a queued request\n * uses. An OAuth provider stays a call on the caller's object, so a class\n * method keeps its `this`.\n *\n * @param credential - The caller's credential.\n * @returns A copy the caller does not hold.\n */\nexport function snapshotCredential(credential: Credential): Credential {\n\tif (credential.kind !== \"oauth\") {\n\t\treturn { ...credential };\n\t}\n\n\treturn {\n\t\tgetAccessToken: async (context) => credential.getAccessToken(context),\n\t\tidentity: credential.identity,\n\t\tkind: \"oauth\",\n\t};\n}\n\n/**\n * Copies the credential of a per-request override, if it has one.\n *\n * @template T - The override shape.\n * @param options - The caller's per-request overrides.\n * @returns The overrides, with a credential the caller does not hold.\n */\nexport function withCredentialSnapshot<T extends { readonly credential?: Credential }>(\n\toptions: T,\n): T {\n\treturn options.credential === undefined\n\t\t? options\n\t\t: { ...options, credential: snapshotCredential(options.credential) };\n}\n","import type {\n\tAdmissionWaitEvent,\n\tAdmissionWaitObserver,\n\tAdmissionWaitReason,\n} from \"../../client/types.ts\";\n\n/** Request-local controls shared by SDK admission mechanisms. */\nexport interface AdmissionWaitContext {\n\t/**\n\t * Absolute deadline for the logical request, as Unix epoch milliseconds.\n\t */\n\treadonly deadlineMs?: number | undefined;\n\t/** Observer for this request's admission waits. */\n\treadonly observer?: AdmissionWaitObserver | undefined;\n\t/** Optional caller cancellation signal. */\n\treadonly signal?: AbortSignal | undefined;\n}\n\ninterface ObserveAdmissionWaitOptions<T> {\n\t/** Intended wait duration, when the scheduler can determine one. */\n\treadonly durationMs?: number;\n\t/** Request-scoped notification callback. */\n\treadonly observer?: AdmissionWaitObserver | undefined;\n\t/** SDK admission mechanism responsible for the wait. */\n\treadonly reason: AdmissionWaitReason;\n\t/** The actual wait to perform. */\n\treadonly waitAsync: () => Promise<T>;\n}\n\n/**\n * Performs one SDK-managed wait and emits a balanced request-scoped lifecycle.\n * Observer failures are deliberately ignored: observation cannot become part\n * of admission control.\n *\n * @template T - Value produced by the observed wait.\n * @param options - Wait metadata, observer, and the wait operation itself.\n * @returns The value produced by the wait.\n */\nexport async function observeAdmissionWaitAsync<T>({\n\tdurationMs,\n\tobserver,\n\treason,\n\twaitAsync,\n}: ObserveAdmissionWaitOptions<T>): Promise<T> {\n\tconst details = {\n\t\t...(durationMs === undefined ? {} : { durationMs }),\n\t\treason,\n\t};\n\tnotify(observer, { ...details, phase: \"started\" });\n\ttry {\n\t\treturn await waitAsync();\n\t} finally {\n\t\tnotify(observer, { ...details, phase: \"ended\" });\n\t}\n}\n\nfunction notify(observer: AdmissionWaitObserver | undefined, event: AdmissionWaitEvent): void {\n\ttry {\n\t\tconst notification = observer?.(event);\n\t\tif (notification !== undefined) {\n\t\t\t// `Boolean` consumes every rejection without throwing; the returned\n\t\t\t// promise and its boolean fulfillment are deliberately ignored.\n\t\t\tvoid Promise.resolve(notification).catch(Boolean);\n\t\t}\n\t} catch {\n\t\t// Admission observers are notification-only and cannot alter control\n\t\t// flow.\n\t}\n}\n","import type { RateLimitSample, RateLimitWindow } from \"./rate-limit-sample.ts\";\n\nconst MS_PER_SECOND = 1000;\n\n/**\n * One budget slot taken by {@link BudgetTracker.reserve}. Release it when the\n * request it paced is not sent.\n */\nexport interface BudgetReservation {\n\t/**\n\t * Gives the slot back: restores the budget when the window it came from is\n\t * still in force, and restores the pacing clock when no later reservation\n\t * has moved it. A second call does nothing.\n\t */\n\treadonly release: () => void;\n}\n\n/** Live window state for one scope: budget left and when it resets. */\ninterface WindowState {\n\t/** Best estimate of requests still allowed before the window resets. */\n\treadonly predictedRemaining: number;\n\t/** Absolute time (ms) the window resets to full. */\n\treadonly resetAt: number;\n\t/**\n\t * Fixed spacing (ms) between sends in a window opened by rollover, or\n\t * `undefined` for a window a server reading primed.\n\t */\n\treadonly spacingMs?: number;\n}\n\n/**\n * Tracks the live rate-limit budget for a single scope. Primed by `observe`\n * from response headers and drawn down by `reserve` as requests leave, so\n * `waitMs` can pace requests across the window.\n *\n * Pacing has two regimes. While budget remains, requests are spread evenly over\n * the time left in the window (`timeLeft / remaining`), so a burst does not\n * spend the whole window's budget up front and then stall. Once the budget is\n * spent, requests hold until the window resets. Budget and reset time move\n * together as one window, so the tracker is either unprimed or fully primed,\n * never half-known.\n *\n * Once a primed window's reset passes with no fresh reading, the next window\n * opens holding the scope's capacity: the last capacity a response reported,\n * or the operation's documented one. Requests queued behind a reset are\n * admitted at that capacity per window, spaced one window-length divided by\n * capacity apart.\n */\nexport class BudgetTracker {\n\t/** Time (ms) the most recent request was allowed out, for spacing. */\n\t#lastAllowedAt: number | undefined = undefined;\n\t/** Token of the latest reservation, compared by identity. */\n\t#latestReservation: object | undefined = undefined;\n\t/** Requests the server grants per window, used when a window rolls over. */\n\t#rolloverWindow: RateLimitWindow;\n\t#window: undefined | WindowState = undefined;\n\t/**\n\t * Token of the window in force, compared by identity. A new window gets a\n\t * new token, so a release can tell its window is gone.\n\t */\n\t#windowToken: object = {};\n\n\t/**\n\t * Creates a tracker for one scope.\n\t *\n\t * @param documentedWindow - The operation's documented capacity, used\n\t * until a response reports one.\n\t */\n\tconstructor(documentedWindow: RateLimitWindow) {\n\t\tthis.#rolloverWindow = documentedWindow;\n\t}\n\n\t/**\n\t * Folds a fresh server reading in, replacing any prior window. The latest\n\t * reading wins: observe time is monotonic, so the most recently resolved\n\t * response is the best current estimate. The spacing reference is left\n\t * untouched so a window refresh does not reset pacing mid-stream.\n\t *\n\t * @param sample - Parsed `remaining`/`resetSeconds` from a response.\n\t * @param now - The current time in ms.\n\t */\n\tpublic observe(sample: RateLimitSample, now: number): void {\n\t\tthis.#rolloverWindow = sample.window ?? this.#rolloverWindow;\n\t\tthis.#windowToken = {};\n\t\tthis.#window = {\n\t\t\tpredictedRemaining: sample.remaining,\n\t\t\tresetAt: now + sample.resetSeconds * MS_PER_SECOND,\n\t\t};\n\t}\n\n\t/**\n\t * Accounts for one request leaving at `now`: records the spacing reference\n\t * and decrements the prediction. A no-op on the prediction while unprimed.\n\t *\n\t * @param now - The time the request was allowed out, in ms.\n\t * @returns The reservation, to release if the request is not sent.\n\t */\n\tpublic reserve(now: number): BudgetReservation {\n\t\tconst previousAllowedAt = this.#lastAllowedAt;\n\t\tthis.#lastAllowedAt = now;\n\t\tconst reservation = {};\n\t\tthis.#latestReservation = reservation;\n\t\tconst window = this.#windowAt(now);\n\t\tif (window !== undefined) {\n\t\t\tthis.#window = { ...window, predictedRemaining: window.predictedRemaining - 1 };\n\t\t}\n\n\t\tconst windowToken = this.#windowToken;\n\t\tlet isReleased = false;\n\t\treturn {\n\t\t\trelease: () => {\n\t\t\t\tif (isReleased) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisReleased = true;\n\t\t\t\tthis.#release({ previousAllowedAt, reservation, windowToken });\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Milliseconds to wait before the next request is allowed.\n\t *\n\t * @param now - The current time in ms.\n\t * @returns `0` when a request may go now (unprimed, or the first paced send);\n\t * the time until reset when the budget is spent; otherwise the time until\n\t * this request's evenly-spaced slot.\n\t */\n\tpublic waitMs(now: number): number {\n\t\tconst window = this.#windowAt(now);\n\t\tif (window === undefined) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst { predictedRemaining, resetAt } = window;\n\t\tif (predictedRemaining <= 0) {\n\t\t\treturn Math.max(0, resetAt - now);\n\t\t}\n\n\t\tif (this.#lastAllowedAt === undefined) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst interval = window.spacingMs ?? (resetAt - now) / predictedRemaining;\n\t\treturn Math.max(0, this.#lastAllowedAt + interval - now);\n\t}\n\n\t#release({\n\t\tpreviousAllowedAt,\n\t\treservation,\n\t\twindowToken,\n\t}: {\n\t\treadonly previousAllowedAt: number | undefined;\n\t\treadonly reservation: object;\n\t\treadonly windowToken: object;\n\t}): void {\n\t\tif (reservation === this.#latestReservation) {\n\t\t\tthis.#lastAllowedAt = previousAllowedAt;\n\t\t}\n\n\t\tif (this.#window !== undefined && windowToken === this.#windowToken) {\n\t\t\tthis.#window = {\n\t\t\t\t...this.#window,\n\t\t\t\tpredictedRemaining: this.#window.predictedRemaining + 1,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * The window in force at `now`, opening the next one at full capacity once\n\t * the current window's reset has passed.\n\t *\n\t * @param now - The current time in ms.\n\t * @returns The live window, or `undefined` while unprimed.\n\t */\n\t#windowAt(now: number): undefined | WindowState {\n\t\tif (this.#window !== undefined && now >= this.#window.resetAt) {\n\t\t\tconst { capacity, windowSeconds } = this.#rolloverWindow;\n\t\t\tconst windowMs = windowSeconds * MS_PER_SECOND;\n\t\t\tthis.#windowToken = {};\n\t\t\tthis.#window = {\n\t\t\t\tpredictedRemaining: capacity,\n\t\t\t\tresetAt: now + windowMs,\n\t\t\t\tspacingMs: windowMs / capacity,\n\t\t\t};\n\t\t}\n\n\t\treturn this.#window;\n\t}\n}\n","import type { AdmissionWaitReason } from \"../../client/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { RequestAbortedError } from \"../../errors/request-aborted.ts\";\nimport {\n\tRequestDeadlineExceededError,\n\ttype RequestDeadlineExceededErrorOptions,\n} from \"../../errors/request-deadline-exceeded.ts\";\n\nconst DEADLINE_ELAPSED = Symbol(\"request deadline elapsed\");\n/** The longest delay a timer accepts; `AbortSignal.timeout` throws above it. */\nexport const MAX_ABORT_TIMEOUT_MS = 2_147_483_647;\n\n/**\n * Request-lifecycle signals derived from caller cancellation and a deadline.\n */\nexport interface RequestLifecycle {\n\t/** Caller-supplied absolute deadline, as Unix epoch milliseconds. */\n\treadonly deadlineMs: number | undefined;\n\t/** Signal owned by the deadline, used to classify its expiry. */\n\treadonly deadlineSignal: AbortSignal | undefined;\n\t/** Caller and deadline signals composed for every stage of the request. */\n\treadonly signal: AbortSignal | undefined;\n}\n\ninterface WaitDeadlineInputs {\n\treadonly cause?: Error | undefined;\n\treadonly deadlineMs: number | undefined;\n\treadonly waitMs: number;\n\treadonly waitReason: AdmissionWaitReason;\n}\n\n/**\n * Resolves one signal that spans the whole logical request.\n *\n * @param deadlineMs - Absolute deadline, as Unix epoch milliseconds.\n * @param callerSignal - Optional caller cancellation signal.\n * @returns Signals that span and classify the logical request.\n */\nexport function requestLifecycle(\n\tdeadlineMs: number | undefined,\n\tcallerSignal: AbortSignal | undefined,\n): RequestLifecycle {\n\tif (deadlineMs === undefined) {\n\t\treturn { deadlineMs, deadlineSignal: undefined, signal: callerSignal };\n\t}\n\n\tconst deadlineSignal = deadlineTimeout(deadlineMs);\n\tconst signal =\n\t\tcallerSignal === undefined\n\t\t\t? deadlineSignal\n\t\t\t: AbortSignal.any([callerSignal, deadlineSignal]);\n\treturn { deadlineMs, deadlineSignal, signal };\n}\n\n/**\n * Returns a typed failure when the deadline signal ended the request.\n *\n * @param lifecycle - Signals and timestamp for the logical request.\n * @param cause - The failure the deadline failure replaces, if any.\n * @returns A deadline failure, or `undefined` when another signal won.\n */\nexport function elapsedDeadlineFailure(\n\t{ deadlineMs, deadlineSignal, signal }: RequestLifecycle,\n\tcause?: OpenCloudError,\n): RequestDeadlineExceededError | undefined {\n\tif (\n\t\tdeadlineMs === undefined ||\n\t\tdeadlineSignal?.aborted !== true ||\n\t\t!Object.is(signal?.reason, deadlineSignal.reason)\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn new RequestDeadlineExceededError(\"Request deadline elapsed\", {\n\t\tcause,\n\t\tdeadlineMs,\n\t\tremainingMs: 0,\n\t});\n}\n\n/**\n * Reclassifies an internal abort when the request deadline supplied its signal.\n * The abort becomes the deadline failure's `cause`.\n *\n * @param error - Error returned by the request pipeline.\n * @param lifecycle - Signals and timestamp for the logical request.\n * @returns A deadline failure, or `undefined` for other failures.\n */\nexport function deadlineFailureFromError(\n\terror: OpenCloudError,\n\tlifecycle: RequestLifecycle,\n): RequestDeadlineExceededError | undefined {\n\treturn error instanceof RequestAbortedError\n\t\t? elapsedDeadlineFailure(lifecycle, error)\n\t\t: undefined;\n}\n\n/**\n * Refuses a known admission wait that cannot fit before the deadline.\n *\n * @param inputs - Deadline, wait duration, reason, and optional cause.\n * @returns A typed refusal, or `undefined` when the wait fits.\n */\nexport function waitDeadlineFailure({\n\tcause,\n\tdeadlineMs,\n\twaitMs,\n\twaitReason,\n}: WaitDeadlineInputs): RequestDeadlineExceededError | undefined {\n\tif (deadlineMs === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst now = Date.now();\n\tconst remainingMs = Math.max(0, deadlineMs - now);\n\tif (now < deadlineMs && waitMs <= remainingMs) {\n\t\treturn undefined;\n\t}\n\n\tconst options: RequestDeadlineExceededErrorOptions = {\n\t\tcause,\n\t\tdeadlineMs,\n\t\tremainingMs,\n\t\twaitMs,\n\t\twaitReason,\n\t};\n\treturn new RequestDeadlineExceededError(waitMessage(waitMs, remainingMs), options);\n}\n\nfunction armDeadlineTimeout(controller: AbortController, deadlineMs: number): void {\n\tconst remainingMs = deadlineMs - Date.now();\n\tif (remainingMs <= 0) {\n\t\tcontroller.abort(DEADLINE_ELAPSED);\n\t\treturn;\n\t}\n\n\tconst timeout = AbortSignal.timeout(Math.min(Math.ceil(remainingMs), MAX_ABORT_TIMEOUT_MS));\n\ttimeout.addEventListener(\"abort\", () => {\n\t\tarmDeadlineTimeout(controller, deadlineMs);\n\t});\n}\n\nfunction deadlineTimeout(deadlineMs: number): AbortSignal {\n\tconst controller = new AbortController();\n\tif (Number.isFinite(deadlineMs)) {\n\t\tarmDeadlineTimeout(controller, deadlineMs);\n\t} else {\n\t\tcontroller.abort(DEADLINE_ELAPSED);\n\t}\n\n\treturn controller.signal;\n}\n\nfunction waitMessage(waitMs: number, remainingMs: number): string {\n\treturn `Admission wait would take ${waitMs / 1000}s; ${remainingMs / 1000}s remain before the request deadline`;\n}\n","import type { OpenCloudError } from \"../../errors/base.ts\";\nimport { RateLimitWaitRefusedError } from \"../../errors/rate-limit-wait-refused.ts\";\nimport { RateLimitError } from \"../../errors/rate-limit.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { type AdmissionWaitContext, observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport { type BudgetReservation, BudgetTracker } from \"./budget-tracker.ts\";\nimport type { RateLimitSample, RateLimitWindow } from \"./rate-limit-sample.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\n\nconst REPORTED_BUDGET_REASON = \"reported-budget\";\nconst MS_PER_SECOND = 1000;\n\n/**\n * Identifies the rate-limit bucket one request draws on: Roblox meters each\n * operation in its own per-credential bucket.\n */\nexport interface BudgetScope {\n\t/** The effective credential's queue key, namespaced by kind. */\n\treadonly credentialKey: string;\n\t/**\n\t * The operation's documented capacity, admitted per window once a reset\n\t * passes before any response has reported the real one.\n\t */\n\treadonly documentedWindow: RateLimitWindow;\n\t/** The operation the request belongs to. */\n\treadonly operationKey: string;\n}\n\n/** A refused long 429 and the instant its scope may send again. */\ninterface Lockout {\n\treadonly cause: RateLimitError;\n\treadonly resetAt: number;\n}\n\n/**\n * Header-primed rate-limit gate shared across a client. Holds one\n * {@link BudgetTracker} per {@link BudgetScope}. Before each request the caller\n * gates on the request's scope (sleeping if that budget is spent), and after\n * each response folds the parsed sample back in, so a later call on the same\n * scope can head off a 429 the static per-operation token bucket cannot\n * foresee.\n *\n * Gating is serialized per scope through a promise chain so concurrent\n * requests on one scope cannot read the same budget and reserve the same slot;\n * each waits for the prior gate's reserve before computing its own.\n */\nexport class BudgetGate {\n\treadonly #chains = new Map<string, Promise<void>>();\n\treadonly #lockouts = new Map<string, Lockout>();\n\treadonly #pendingGates = new Map<string, number>();\n\treadonly #sleep: SleepFunc;\n\treadonly #trackers = new Map<string, BudgetTracker>();\n\n\t/**\n\t * Creates a gate bound to an injectable sleep.\n\t *\n\t * @param sleep - Injectable sleep (tests pass a fake clock).\n\t */\n\tconstructor(sleep: SleepFunc) {\n\t\tthis.#sleep = sleep;\n\t}\n\n\t/**\n\t * Holds until the scope's budget permits a send, then reserves one slot.\n\t * Runs after the prior gate on the same scope settles, whether it resolved\n\t * or rejected, so one failed attempt cannot poison later gates on the\n\t * scope.\n\t *\n\t * @param scope - The credential and operation to gate on.\n\t * @param context - Request-local observer and cancellation signal.\n\t * @returns The reserved slot. Release it when the request is not sent.\n\t * @rejects {@link RequestAbortedError} when the caller cancels while waiting.\n\t * @rejects {@link RateLimitWaitRefusedError} while the scope is locked out.\n\t */\n\tpublic async gateAsync(\n\t\tscope: BudgetScope,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext = {},\n\t): Promise<BudgetReservation> {\n\t\tconst key = scopeKey(scope);\n\t\tconst pendingGates = this.#pendingGates.get(key) ?? 0;\n\t\tconst waitsForEarlierGate = pendingGates > 0;\n\t\tthis.#pendingGates.set(key, pendingGates + 1);\n\t\tconst previous = this.#chains.get(key) ?? Promise.resolve();\n\t\tconst recovered = previous.catch(ignoreRejection);\n\t\tconst mine = recovered.then(async () => {\n\t\t\treturn this.#gateOnce(scope, {\n\t\t\t\tdeadlineMs,\n\t\t\t\tobserver: waitsForEarlierGate ? undefined : observer,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t});\n\t\tconst completed = mine.finally(() => {\n\t\t\tconst remainingGates = (this.#pendingGates.get(key) ?? 1) - 1;\n\t\t\tthis.#pendingGates.set(key, remainingGates);\n\t\t});\n\t\tthis.#chains.set(key, completed.then(ignoreRejection).catch(ignoreRejection));\n\t\tif (waitsForEarlierGate) {\n\t\t\treturn observeAdmissionWaitAsync({\n\t\t\t\tobserver,\n\t\t\t\treason: REPORTED_BUDGET_REASON,\n\t\t\t\twaitAsync: async () => waitForGateAsync(completed, signal),\n\t\t\t});\n\t\t}\n\n\t\treturn waitForGateAsync(completed, signal);\n\t}\n\n\t/**\n\t * Locks the scope out until the refused 429's guided wait ends. Until then\n\t * every gate on the scope is refused at once, without sleeping or\n\t * reserving budget. The latest lockout replaces any earlier one.\n\t *\n\t * @param scope - The same scope passed to {@link gateAsync}.\n\t * @param cause - The 429 whose guided wait was too long to take.\n\t */\n\tpublic lockOut(scope: BudgetScope, cause: RateLimitError): void {\n\t\tthis.#lockouts.set(scopeKey(scope), {\n\t\t\tcause,\n\t\t\tresetAt: Date.now() + cause.retryAfterSeconds * MS_PER_SECOND,\n\t\t});\n\t}\n\n\t/**\n\t * Folds a response's parsed budget back onto the scope. A `undefined`\n\t * sample (headers absent or non-numeric) is ignored, leaving the scope on\n\t * static pacing.\n\t *\n\t * @param scope - The same scope passed to {@link gateAsync}.\n\t * @param sample - Parsed sample, or `undefined` when none was reported.\n\t */\n\tpublic observe(scope: BudgetScope, sample: RateLimitSample | undefined): void {\n\t\tif (sample === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#tracker(scopeKey(scope), scope.documentedWindow).observe(sample, Date.now());\n\t}\n\n\t/**\n\t * Refuses a request at once while its scope is locked out, so it fails\n\t * before taking a static queue slot or waiting on anything.\n\t *\n\t * @param scope - The same scope passed to {@link gateAsync}.\n\t * @throws {@link RateLimitWaitRefusedError} While the scope is locked out.\n\t */\n\tpublic refuseDuringLockout(scope: BudgetScope): void {\n\t\tthis.#refuseDuringLockout(scopeKey(scope));\n\t}\n\n\t/**\n\t * Swaps a request's result for the lockout refusal while its scope is\n\t * locked out, for a lockout that began after the request passed its gate.\n\t *\n\t * @param scope - The same scope passed to {@link gateAsync}.\n\t * @param result - The request's result so far.\n\t * @returns The refusal while the scope is locked out, else `result`.\n\t */\n\tpublic refuseIfLockedOut<T>(\n\t\tscope: BudgetScope,\n\t\tresult: Result<T, OpenCloudError>,\n\t): Result<T, OpenCloudError> {\n\t\tconst refusal = this.#lockoutRefusal(scopeKey(scope));\n\t\treturn refusal === undefined ? result : { err: refusal, success: false };\n\t}\n\n\tasync #gateOnce(\n\t\tscope: BudgetScope,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext,\n\t): Promise<BudgetReservation> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow requestAbortedError(signal);\n\t\t}\n\n\t\tconst key = scopeKey(scope);\n\t\tconst tracker = this.#tracker(key, scope.documentedWindow);\n\n\t\tthis.#refuseDuringLockout(key);\n\t\tconst waitMs = tracker.waitMs(Date.now());\n\t\tif (waitMs > 0) {\n\t\t\tawait this.#waitAsync(waitMs, { deadlineMs, observer, signal });\n\t\t\tthis.#refuseDuringLockout(key);\n\t\t}\n\n\t\treturn tracker.reserve(Date.now());\n\t}\n\n\t#lockoutRefusal(key: string): RateLimitWaitRefusedError | undefined {\n\t\tconst lockout = this.#lockouts.get(key);\n\t\tconst now = Date.now();\n\t\treturn lockout !== undefined && now < lockout.resetAt\n\t\t\t? lockoutRefusal(lockout, now)\n\t\t\t: undefined;\n\t}\n\n\t#refuseDuringLockout(key: string): void {\n\t\tconst refusal = this.#lockoutRefusal(key);\n\t\tif (refusal !== undefined) {\n\t\t\tthrow refusal;\n\t\t}\n\t}\n\n\t#tracker(key: string, documentedWindow: RateLimitWindow): BudgetTracker {\n\t\tconst existing = this.#trackers.get(key);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst tracker = new BudgetTracker(documentedWindow);\n\t\tthis.#trackers.set(key, tracker);\n\t\treturn tracker;\n\t}\n\n\tasync #waitAsync(\n\t\twaitMs: number,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext,\n\t): Promise<void> {\n\t\tconst refusal = waitDeadlineFailure({\n\t\t\tdeadlineMs,\n\t\t\twaitMs,\n\t\t\twaitReason: REPORTED_BUDGET_REASON,\n\t\t});\n\t\tif (refusal !== undefined) {\n\t\t\tthrow refusal;\n\t\t}\n\n\t\tawait observeAdmissionWaitAsync({\n\t\t\tdurationMs: waitMs,\n\t\t\tobserver,\n\t\t\treason: REPORTED_BUDGET_REASON,\n\t\t\twaitAsync: async () => {\n\t\t\t\tconst sleepResult = await raceWithAbortAsync(\n\t\t\t\t\tasync () => this.#sleep(waitMs, signal),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (sleepResult === ABORTED) {\n\t\t\t\t\tthrow requestAbortedError(signal);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n}\n\n/**\n * Composes the map key one credential and operation are tracked under. The\n * budget gate and the rate-limit queues share it.\n *\n * @param scope - The credential key and operation naming the window.\n * @returns The key for the tracker, chain and queue maps.\n */\nexport function scopeKey({\n\tcredentialKey,\n\toperationKey,\n}: Pick<BudgetScope, \"credentialKey\" | \"operationKey\">): string {\n\treturn `${credentialKey}::${operationKey}`;\n}\n\nfunction lockoutRefusal({ cause, resetAt }: Lockout, now: number): RateLimitWaitRefusedError {\n\tconst secondsLeft = Math.ceil((resetAt - now) / MS_PER_SECOND);\n\tconst remainingLockout = new RateLimitError(cause.message, {\n\t\tcause,\n\t\tcode: cause.code,\n\t\tdetails: cause.details,\n\t\tremaining: cause.remaining,\n\t\tresponseHeaders: cause.responseHeaders,\n\t\tretryAfterSeconds: secondsLeft,\n\t\tsource: cause.source,\n\t\tstatusCode: cause.statusCode,\n\t});\n\treturn new RateLimitWaitRefusedError(\n\t\t`Rate limit lockout on this operation lasts another ${secondsLeft}s; request not sent`,\n\t\t{ cause: remainingLockout },\n\t);\n}\n\nfunction ignoreRejection(): void {\n\t// A failed or cancelled gate must not poison the next caller's chain.\n}\n\nasync function waitForGateAsync(\n\tgate: Promise<BudgetReservation>,\n\tsignal: AbortSignal | undefined,\n): Promise<BudgetReservation> {\n\tconst gateResult = await raceWithAbortAsync(async () => gate, signal);\n\tif (gateResult === ABORTED) {\n\t\tthrow requestAbortedError(signal);\n\t}\n\n\treturn gateResult;\n}\n","import type { Credential } from \"../../client/types.ts\";\nimport { ApiError, requestContextOf } from \"../../errors/api-error.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { CredentialRejectedError } from \"../../errors/credential-rejected.ts\";\nimport { PermissionError } from \"../../errors/permission-error.ts\";\nimport { extractErrorMessage } from \"./error-body.ts\";\n\n/** The v1 body message Roblox sends on a 502 after an app removal. */\nconst SCOPE_AUTHORIZATION_FAILED = \"Scope authorization failed.\";\n\nconst OAUTH_PERMISSION_HINT =\n\t\"The OAuth grant may not include the required scope or this universe.\";\n\n/** What the permission upgrade needs to know about the call. */\nexport interface PermissionContext {\n\t/** The effective credential of the call. */\n\treadonly credential: Credential;\n\t/** The operation key named on the upgraded error. */\n\treadonly operationKey: string;\n\t/**\n\t * The scopes the method declares, if any. Without them there is no\n\t * upgrade.\n\t */\n\treadonly requiredScopes: ReadonlyArray<string> | undefined;\n}\n\n/**\n * Turns Roblox's refusal of an OAuth token into a\n * {@link CredentialRejectedError}: a non-gateway 401, or a non-gateway 502\n * whose body message is \"Scope authorization failed.\". The result is not an\n * `ApiError`, so the retry loop never retries it. Every other error, and\n * every error on an API-key credential, passes through unchanged.\n *\n * @param err - The transport error for one attempt.\n * @param credential - The effective credential of the call.\n * @returns The classified error.\n */\nexport function classifyCredentialRejection(\n\terr: OpenCloudError,\n\tcredential: Credential,\n): OpenCloudError {\n\tif (credential.kind !== \"oauth\" || !isTokenRefusal(err)) {\n\t\treturn err;\n\t}\n\n\treturn new CredentialRejectedError(err.message, {\n\t\tcause: err,\n\t\tcode: err.code,\n\t\tidentity: credential.identity,\n\t\tstatusCode: err.statusCode,\n\t});\n}\n\n/**\n * Upgrades a non-gateway 401 or 403 `ApiError` to a {@link PermissionError}\n * when the method declares its scopes. On an OAuth credential the message\n * adds a hint that the grant may not include the scope or this universe.\n *\n * @param err - The final error of the call.\n * @param context - The credential, operation key and declared scopes.\n * @returns The upgraded error, or `err` unchanged.\n */\nexport function enrichPermissionError(\n\terr: OpenCloudError,\n\t{ credential, operationKey, requiredScopes }: PermissionContext,\n): OpenCloudError {\n\tif (requiredScopes === undefined) {\n\t\treturn err;\n\t}\n\n\tif (err instanceof PermissionError) {\n\t\treturn err;\n\t}\n\n\tif (!(err instanceof ApiError)) {\n\t\treturn err;\n\t}\n\n\tif (err.statusCode !== 401 && err.statusCode !== 403) {\n\t\treturn err;\n\t}\n\n\t// An edge gateway answers 401 and 403 for its own reasons, and the request\n\t// never reached the operation whose scopes these are.\n\tif (err.gatewaySummary !== undefined) {\n\t\treturn err;\n\t}\n\n\treturn new PermissionError(permissionMessage(err.message, credential), {\n\t\t...requestContextOf(err),\n\t\tcause: err.cause,\n\t\tcode: err.code,\n\t\tdetails: err.details,\n\t\toperationKey,\n\t\trequiredScopes,\n\t\tstatusCode: err.statusCode,\n\t});\n}\n\nfunction isTokenRefusal(err: OpenCloudError): err is ApiError {\n\tif (!(err instanceof ApiError) || err.gatewaySummary !== undefined) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.statusCode === 401 ||\n\t\t(err.statusCode === 502 && extractErrorMessage(err.details) === SCOPE_AUTHORIZATION_FAILED)\n\t);\n}\n\nfunction permissionMessage(message: string, credential: Credential): string {\n\tif (credential.kind !== \"oauth\") {\n\t\treturn message;\n\t}\n\n\tconst separator = message.endsWith(\".\") ? \" \" : \". \";\n\treturn `${message}${separator}${OAUTH_PERMISSION_HINT}`;\n}\n","import { type OpenCloudError, recordPreviousAttempts } from \"../../errors/base.ts\";\nimport { RateLimitWaitRefusedError } from \"../../errors/rate-limit-wait-refused.ts\";\nimport type { RateLimitError } from \"../../errors/rate-limit.ts\";\nimport { RetryDelayExceededError } from \"../../errors/retry-delay-exceeded.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\nimport { MAX_GUIDED_WAIT_SECONDS } from \"./retry-guidance.ts\";\nimport {\n\tcomputeRetryWaitMs,\n\thasGuidedWait,\n\tisRefusedGuidedWait,\n\ttype RetryResolvable,\n\tshouldRetry,\n} from \"./retry.ts\";\nimport type { AdmissionWaitObserver, HttpRequest, HttpResponse, OpenCloudHooks } from \"./types.ts\";\n\n/** A transport callback: takes a request, returns a classified Result. */\ntype SendFunc = (request: HttpRequest) => Promise<Result<HttpResponse, OpenCloudError>>;\n\ninterface RetryLimit {\n\treadonly cause: OpenCloudError;\n\treadonly deadlineMs: number | undefined;\n\treadonly retryAfterMs: number;\n}\n\n/** What follows a failed attempt: a wait to take, or a refusal to return. */\ntype RetryPlan =\n\t| { readonly refusal: OpenCloudError }\n\t| { readonly spendsAttempt: boolean; readonly waitMs: number };\n\ninterface RetryState {\n\treadonly config: RetryResolvable;\n\treadonly deadlineMs: number | undefined;\n\treadonly retries: number;\n}\n\ninterface RetryNotification {\n\treadonly attempt: number;\n\treadonly error: OpenCloudError;\n\treadonly hooks: OpenCloudHooks;\n\treadonly waitMs: number;\n}\n\n/**\n * Inputs to {@link executeWithRetryAsync} bundled as an options object to keep\n * the function signature narrow.\n */\ninterface ExecuteOptions {\n\t/** Request-scoped admission-wait observer. */\n\treadonly admissionWaitObserver?: AdmissionWaitObserver | undefined;\n\t/** Fully-resolved retry config (post-merge). */\n\treadonly config: RetryResolvable;\n\t/**\n\t * Absolute deadline for the logical request, as Unix epoch milliseconds.\n\t */\n\treadonly deadlineMs?: number | undefined;\n\t/** Client-level observability hooks. */\n\treadonly hooks: OpenCloudHooks;\n\t/** Transport callback. May be pre-wrapped by a rate-limit queue. */\n\treadonly send: SendFunc;\n\t/** Optional caller cancellation signal. */\n\treadonly signal?: AbortSignal | undefined;\n\t/** Injectable sleep (tests pass a fake). */\n\treadonly sleep: SleepFunc;\n}\n\n/**\n * Retry-aware orchestration loop. Coordinates a single logical request,\n * looping over `options.send` until it succeeds, the error is non-retryable,\n * or `options.config.maxRetries` is exhausted. Server-guided rate-limit waits\n * do not count against `maxRetries`; the request deadline and `signal` bound\n * them. Fires observability hooks at each transition. Queue-agnostic: `send`\n * may be any callback, including one wrapped by a rate-limit queue.\n *\n * @param request - The immutable request to send.\n * @param options - The transport callback, resolved config, hooks, and sleep.\n * @returns The first success, or the final error after retries are exhausted.\n */\nexport async function executeWithRetryAsync(\n\trequest: HttpRequest,\n\toptions: ExecuteOptions,\n): Promise<Result<HttpResponse, OpenCloudError>> {\n\tconst { config, deadlineMs, hooks, signal } = options;\n\tif (signal?.aborted === true) {\n\t\treturn abortedResult(signal);\n\t}\n\n\tlet result = await attemptAsync(request, options);\n\tlet retries = 0;\n\tlet earlier: ReadonlyArray<OpenCloudError> = [];\n\n\twhile (!result.success) {\n\t\tconst failure = result.err;\n\t\tconst plan = planRetry(failure, { config, deadlineMs, retries });\n\t\tif (plan === undefined) {\n\t\t\treturn failed(failure, earlier);\n\t\t}\n\n\t\tif (\"refusal\" in plan) {\n\t\t\treturn failed(plan.refusal, earlier);\n\t\t}\n\n\t\tretries += plan.spendsAttempt ? 1 : 0;\n\t\tearlier = [...earlier, failure];\n\t\tannounceRetry({ attempt: earlier.length, error: failure, hooks, waitMs: plan.waitMs });\n\t\tif ((await waitForRetryAsync(plan.waitMs, options)) === ABORTED) {\n\t\t\treturn failed(requestAbortedError(signal), earlier);\n\t\t}\n\n\t\tresult = await attemptAsync(request, options);\n\t}\n\n\treturn result;\n}\n\nfunction failed(\n\terr: OpenCloudError,\n\tearlier: ReadonlyArray<OpenCloudError>,\n): Result<never, OpenCloudError> {\n\treturn { err: recordPreviousAttempts(err, earlier), success: false };\n}\n\nfunction retryRefusal({\n\tcause,\n\tdeadlineMs,\n\tretryAfterMs,\n}: RetryLimit): RetryDelayExceededError | undefined {\n\tif (deadlineMs === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst refusal = waitDeadlineFailure({\n\t\tcause,\n\t\tdeadlineMs,\n\t\twaitMs: retryAfterMs,\n\t\twaitReason: \"retry-delay\",\n\t});\n\tif (refusal === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst { remainingMs } = refusal;\n\treturn new RetryDelayExceededError(\n\t\t`Retry delay would wait ${retryAfterMs / 1000}s; ${remainingMs / 1000}s remain before the request deadline`,\n\t\t{ cause, deadlineMs, remainingMs, retryAfterMs },\n\t);\n}\n\nfunction guidedWaitRefusal(cause: RateLimitError): RateLimitWaitRefusedError {\n\treturn new RateLimitWaitRefusedError(\n\t\t`Rate limit asks for a ${cause.retryAfterSeconds}s wait, longer than the ${MAX_GUIDED_WAIT_SECONDS}s the SDK waits out`,\n\t\t{ cause },\n\t);\n}\n\n/**\n * Decides what follows a failed attempt. A rate limit carrying a server-guided\n * wait is waited out without spending one of `maxRetries`, unless the wait is\n * longer than {@link MAX_GUIDED_WAIT_SECONDS}, which is refused outright; every\n * other retryable failure spends one.\n *\n * @param err - The failure the attempt returned.\n * @param state - Resolved config, request deadline, and attempts spent so far.\n * @returns The wait to take, a refusal to return instead, or `undefined` to\n * return the failure as is.\n */\nfunction planRetry(\n\terr: OpenCloudError,\n\t{ config, deadlineMs, retries }: RetryState,\n): RetryPlan | undefined {\n\tif (!shouldRetry(err, config)) {\n\t\treturn undefined;\n\t}\n\n\tconst guided = hasGuidedWait(err);\n\tif (!guided && retries >= config.maxRetries) {\n\t\treturn undefined;\n\t}\n\n\tif (isRefusedGuidedWait(err)) {\n\t\treturn { refusal: guidedWaitRefusal(err) };\n\t}\n\n\tconst waitMs = computeRetryWaitMs(err, { attempt: retries, retryDelay: config.retryDelay });\n\tconst refusal = retryRefusal({ cause: err, deadlineMs, retryAfterMs: waitMs });\n\treturn refusal === undefined ? { spendsAttempt: !guided, waitMs } : { refusal };\n}\n\nasync function waitForRetryAsync(\n\twaitMs: number,\n\t{ admissionWaitObserver, signal, sleep }: ExecuteOptions,\n): Promise<typeof ABORTED | void> {\n\treturn observeAdmissionWaitAsync({\n\t\tdurationMs: waitMs,\n\t\tobserver: admissionWaitObserver,\n\t\treason: \"retry-delay\",\n\t\twaitAsync: async () => raceWithAbortAsync(async () => sleep(waitMs, signal), signal),\n\t});\n}\n\nfunction announceRetry({ attempt, error, hooks, waitMs }: RetryNotification): void {\n\thooks.onRetry?.(attempt, error);\n\thooks.onRateLimit?.(waitMs);\n}\n\nfunction abortedResult(signal: AbortSignal | undefined): Result<never, OpenCloudError> {\n\treturn { err: requestAbortedError(signal), success: false };\n}\n\nasync function attemptAsync(\n\trequest: HttpRequest,\n\t{ hooks, send, signal }: ExecuteOptions,\n): Promise<Result<HttpResponse, OpenCloudError>> {\n\thooks.onRequest?.(request);\n\tconst attempt = await raceWithAbortAsync(async () => send(request), signal);\n\treturn attempt === ABORTED ? abortedResult(signal) : attempt;\n}\n","import type { OpenCloudError } from \"../../errors/base.ts\";\nimport { hasServerRetryGuidance, RateLimitError } from \"../../errors/rate-limit.ts\";\nimport type { Result } from \"../../types.ts\";\nimport type { BudgetGate, BudgetScope } from \"./budget-gate.ts\";\nimport type { RateLimitSample } from \"./rate-limit-sample.ts\";\nimport { parseRateLimitHeaders, withReportedWindow } from \"./rate-limit-sample.ts\";\nimport { MAX_GUIDED_WAIT_SECONDS } from \"./retry-guidance.ts\";\nimport { isRefusedGuidedWait } from \"./retry.ts\";\nimport type { HttpResponse } from \"./types.ts\";\n\n/**\n * Returns `true` when a long 429's evidence shows it clears on some other\n * event than its guided wait, so it must not lock its scope out.\n */\nexport type LockoutExemption = (error: RateLimitError) => boolean;\n\n/** One sent attempt, as the budget gate learns from it. */\nexport interface ObservedAttempt {\n\t/** Returns `true` to keep a long 429 from locking the scope out. */\n\treadonly exemptsLockout: LockoutExemption | undefined;\n\t/** The scope the attempt was gated on. */\n\treadonly scope: BudgetScope;\n\t/** The classified, unrefined transport result of the attempt. */\n\treadonly transportResult: Result<HttpResponse, OpenCloudError>;\n}\n\n/**\n * Extracts a {@link RateLimitSample} from a transport result so the budget\n * gate can be fed from every attempt. A 2xx carries the budget in its headers.\n * A 429 with valid server guidance primes the gate as spent for its guided\n * wait, whatever `x-ratelimit-remaining` reports: the remaining count is only\n * a pacing hint on 2xx responses. A 429 asking for a longer wait than the SDK\n * takes is refused, so it does not prime the gate either. A 429 also carries\n * the window capacity its `x-ratelimit-limit` header reports. Any other error\n * yields `undefined`.\n *\n * @param result - The classified transport result for one attempt.\n * @returns The parsed sample, or `undefined` when none was reported.\n */\nexport function rateLimitSampleFromResult(\n\tresult: Result<HttpResponse, OpenCloudError>,\n): RateLimitSample | undefined {\n\tif (result.success) {\n\t\treturn parseRateLimitHeaders(result.data.headers);\n\t}\n\n\tconst { err } = result;\n\tif (\n\t\terr instanceof RateLimitError &&\n\t\thasServerRetryGuidance(err) &&\n\t\terr.retryAfterSeconds <= MAX_GUIDED_WAIT_SECONDS\n\t) {\n\t\tconst sample = { remaining: 0, resetSeconds: err.retryAfterSeconds };\n\t\treturn withReportedWindow(sample, err.responseHeaders?.[\"x-ratelimit-limit\"]);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Picks out a 429 whose guided wait is longer than the SDK waits out on its\n * own. Such a lockout is refused, and later requests on the same scope fail\n * locally until it ends instead of reaching the server.\n *\n * @param result - The classified transport result for one attempt.\n * @returns The locking 429, or `undefined` for any other result.\n */\nexport function rateLimitLockoutFromResult(\n\tresult: Result<HttpResponse, OpenCloudError>,\n): RateLimitError | undefined {\n\treturn !result.success && isRefusedGuidedWait(result.err) ? result.err : undefined;\n}\n\n/**\n * Feeds one attempt back into the budget gate: its reported budget always,\n * and a long 429 as a lockout unless the caller exempts it (such as a 429\n * naming tasks that occupy a Luau place).\n *\n * @param budgets - The gate shared across the client.\n * @param attempt - The scope, transport result, and lockout exemption.\n */\nexport function observeAttempt(\n\tbudgets: BudgetGate,\n\t{ exemptsLockout, scope, transportResult }: ObservedAttempt,\n): void {\n\tbudgets.observe(scope, rateLimitSampleFromResult(transportResult));\n\tconst lockout = rateLimitLockoutFromResult(transportResult);\n\tif (lockout !== undefined && exemptsLockout?.(lockout) !== true) {\n\t\tbudgets.lockOut(scope, lockout);\n\t}\n}\n","import { ABORTED, raceWithAbortAsync, requestAbortedError } from \"../utils/abort.ts\";\nimport type { SleepFunc } from \"../utils/sleep.ts\";\nimport { type AdmissionWaitContext, observeAdmissionWaitAsync } from \"./admission-wait.ts\";\nimport type { RateLimitWindow } from \"./rate-limit-sample.ts\";\nimport { waitDeadlineFailure } from \"./request-deadline.ts\";\nimport type { OpenCloudHooks } from \"./types.ts\";\n\nconst OPERATION_QUEUE_REASON = \"operation-queue\";\n\n/**\n * Identifies and bounds a single Roblox Open Cloud operation for rate\n * limiting, e.g. `{ operationKey: \"game-passes.create\", maxPerSecond: 5 }`.\n */\nexport interface OperationLimit {\n\t/**\n\t * How many requests may be issued back to back before pacing begins,\n\t * as a whole number of requests. Defaults to `max(1, maxPerSecond)`,\n\t * which leaves operations at or above 1/s paced exactly as their\n\t * sustained rate allows while still granting a slower operation one\n\t * request after it has idled. Set this to the allowance the schema\n\t * documents (e.g. 5 per minute) to grant the burst the server permits.\n\t */\n\treadonly burstCapacity?: number;\n\t/** Maximum sustained request rate in requests per second. */\n\treadonly maxPerSecond: number;\n\t/**\n\t * Stable identifier for the operation (e.g. \"game-passes.create\"). Not\n\t * consumed by the queue itself; callers use it to key per-operation\n\t * queues in a registry (see GamePassesClient).\n\t */\n\treadonly operationKey: string;\n}\n\ninterface QueueWait extends AdmissionWaitContext {\n\treadonly now: number;\n\treadonly waitMs: number;\n}\n\n/**\n * Token-bucket rate limiter for a single `(credential identity, operation)`\n * pair. Every call to `acquire` consumes one token; when the bucket is empty\n * the call waits until a token regenerates before invoking the task. Tokens\n * refill at `maxPerSecond` per second, up to the operation's `burstCapacity`.\n *\n * Implemented as a leaky bucket tracking drain debt in ms. `#lastCheck`\n * advances by `waitMs` after every sleep so the algorithm stays correct\n * whether or not the injected sleep moves `Date.now()` forward. `#bucketLevel`\n * and `#maxBucketLevel` are both ms of drain debt, so the ceiling is the burst\n * expressed in that unit: `burstCapacity` refill intervals. Deriving it any\n * other way (notably `maxPerSecond * intervalMs`, whose units cancel to a\n * constant 1000) starves every operation slower than one request per second.\n */\nexport class RateLimitQueue {\n\treadonly #hooks: OpenCloudHooks;\n\treadonly #intervalMs: number;\n\treadonly #maxBucketLevel: number;\n\treadonly #sleep: SleepFunc;\n\n\t#bucketLevel = 0;\n\t#chain: Promise<void> = Promise.resolve();\n\t#lastCheck: number = Date.now();\n\t#pendingAcquisitions = 0;\n\n\t/**\n\t * Creates a rate-limit queue bound to a single operation.\n\t *\n\t * @param limit - The operation key and its per-second request ceiling.\n\t * @param hooks - Observability callbacks; `onRateLimit` fires when the\n\t * bucket is empty and a sleep is about to start.\n\t * @param sleep - Injectable sleep (tests pass a fake).\n\t */\n\tconstructor(limit: OperationLimit, hooks: OpenCloudHooks, sleep: SleepFunc) {\n\t\tthis.#intervalMs = 1000 / limit.maxPerSecond;\n\t\tthis.#maxBucketLevel = documentedWindow(limit).capacity * this.#intervalMs;\n\t\tthis.#hooks = hooks;\n\t\tthis.#sleep = sleep;\n\t}\n\n\t/**\n\t * Waits for a token — sleeping and firing `hooks.onRateLimit` if the\n\t * bucket is empty — then executes `task`. Concurrent callers are\n\t * serialized at token acquisition; tasks themselves run independently\n\t * once their token is secured.\n\t *\n\t * @param task - The request to run once a token is available.\n\t * @param context - Request-local observer and cancellation signal.\n\t * @returns The value produced by `task`.\n\t * @rejects {@link RequestAbortedError} when the caller cancels while queued.\n\t */\n\tpublic async acquireAsync<T>(\n\t\ttask: () => Promise<T>,\n\t\t{ deadlineMs, observer, signal }: AdmissionWaitContext = {},\n\t): Promise<T> {\n\t\tconst waitsForEarlierAcquisition = this.#pendingAcquisitions > 0;\n\t\tthis.#pendingAcquisitions++;\n\t\tconst waitForTokenAsync = async (): Promise<void> => {\n\t\t\treturn this.#waitForToken({\n\t\t\t\tdeadlineMs,\n\t\t\t\tobserver: waitsForEarlierAcquisition ? undefined : observer,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t};\n\n\t\tconst myTurn = this.#chain.catch(ignoreRejection).then(waitForTokenAsync);\n\t\tconst completed = myTurn.finally(() => {\n\t\t\tthis.#pendingAcquisitions--;\n\t\t});\n\t\tthis.#chain = completed.catch(ignoreRejection);\n\t\tif (waitsForEarlierAcquisition) {\n\t\t\tawait observeAdmissionWaitAsync({\n\t\t\t\tobserver,\n\t\t\t\treason: OPERATION_QUEUE_REASON,\n\t\t\t\twaitAsync: async () => waitForTurnAsync(completed, signal),\n\t\t\t});\n\t\t} else {\n\t\t\tawait waitForTurnAsync(completed, signal);\n\t\t}\n\n\t\treturn task();\n\t}\n\n\tasync #waitAsync({ deadlineMs, now, observer, signal, waitMs }: QueueWait): Promise<void> {\n\t\tconst refusal = waitDeadlineFailure({\n\t\t\tdeadlineMs,\n\t\t\twaitMs,\n\t\t\twaitReason: OPERATION_QUEUE_REASON,\n\t\t});\n\t\tif (refusal !== undefined) {\n\t\t\tthrow refusal;\n\t\t}\n\n\t\tthis.#hooks.onRateLimit?.(waitMs);\n\t\tawait observeAdmissionWaitAsync({\n\t\t\tdurationMs: waitMs,\n\t\t\tobserver,\n\t\t\treason: OPERATION_QUEUE_REASON,\n\t\t\twaitAsync: async () => {\n\t\t\t\tconst sleepResult = await raceWithAbortAsync(\n\t\t\t\t\tasync () => this.#sleep(waitMs, signal),\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tif (sleepResult === ABORTED) {\n\t\t\t\t\tthrow requestAbortedError(signal);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tthis.#bucketLevel = this.#maxBucketLevel;\n\t\tthis.#lastCheck = now + waitMs;\n\t}\n\n\tasync #waitForToken({ deadlineMs, observer, signal }: AdmissionWaitContext): Promise<void> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow requestAbortedError(signal);\n\t\t}\n\n\t\tconst now = Math.max(Date.now(), this.#lastCheck);\n\t\tconst drained = Math.max(0, this.#bucketLevel - (now - this.#lastCheck));\n\t\tthis.#lastCheck = now;\n\n\t\tif (drained + this.#intervalMs <= this.#maxBucketLevel) {\n\t\t\tthis.#bucketLevel = drained + this.#intervalMs;\n\t\t\treturn;\n\t\t}\n\n\t\tconst waitMs = drained + this.#intervalMs - this.#maxBucketLevel;\n\t\tawait this.#waitAsync({ deadlineMs, now, observer, signal, waitMs });\n\t}\n}\n\n/**\n * Expresses an operation's documented limit as a fixed window: its burst\n * capacity, granted once per the time the sustained rate takes to refill it.\n *\n * @param limit - The operation's documented rate limit.\n * @returns The capacity granted per window and the window's length.\n */\nexport function documentedWindow(limit: OperationLimit): RateLimitWindow {\n\tconst capacity = limit.burstCapacity ?? Math.max(1, limit.maxPerSecond);\n\treturn { capacity, windowSeconds: capacity / limit.maxPerSecond };\n}\n\nfunction ignoreRejection(): void {\n\t// A failed or cancelled acquire must not poison the next caller's chain.\n}\n\nasync function waitForTurnAsync(\n\tturn: Promise<void>,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tconst turnResult = await raceWithAbortAsync(async () => turn, signal);\n\tif (turnResult === ABORTED) {\n\t\tthrow requestAbortedError(signal);\n\t}\n}\n","import type { Except } from \"type-fest\";\n\nimport type { HttpRequest, RequestConfig, RequestOptions } from \"../../client/types.ts\";\nimport type { RetryResolvable } from \"./retry.ts\";\nimport { isUploadRequest } from \"./upload-request.ts\";\n\n/**\n * Inputs to {@link buildRequestConfig}, bundled to keep the signature narrow.\n */\nexport interface RequestConfigInputs {\n\t/** The resolved config for this call. */\n\treadonly merged: RetryResolvable;\n\t/** The caller's per-request overrides, if any. */\n\treadonly options: RequestOptions | undefined;\n\t/** The built request, inspected for an upload body. */\n\treadonly request: HttpRequest;\n\t/** Caller and deadline signal composed for the whole logical request. */\n\treadonly signal: AbortSignal | undefined;\n}\n\n/**\n * Resolves the per-request {@link RequestConfig}, less the credential, which\n * is resolved per transport attempt. Upload requests ({@link isUploadRequest})\n * carry no default timeout: a multi-megabyte place file over a slow link is\n * bandwidth-bound, so a transport-attempt timeout only fires spuriously. An\n * explicit `options.timeout` still applies to any request; every non-upload\n * request keeps the merged default.\n *\n * @param inputs - The merged config, the built request, and per-request\n * overrides.\n * @returns The config to hand to the transport, with `timeout` omitted when\n * no transport-attempt timeout should apply.\n */\nexport function buildRequestConfig({\n\tmerged,\n\toptions,\n\trequest,\n\tsignal,\n}: RequestConfigInputs): Except<RequestConfig, \"credential\"> {\n\tconst shouldOmitDefaultTimeout = options?.timeout === undefined && isUploadRequest(request);\n\treturn {\n\t\tbaseUrl: merged.baseUrl,\n\t\t...(signal === undefined ? {} : { signal }),\n\t\t...(shouldOmitDefaultTimeout ? {} : { timeout: merged.timeout }),\n\t};\n}\n","import { setTimeout } from \"node:timers/promises\";\n\n/**\n * Injectable sleep function signature for testing.\n *\n * @since 0.1.0\n */\nexport type SleepFunc = (ms: number, signal?: AbortSignal) => Promise<void>;\n\n/**\n * Timer-backed production sleep that releases its timer on cancellation.\n *\n * @param ms - Duration to wait in milliseconds.\n * @param signal - Optional caller cancellation signal.\n */\nexport async function defaultSleepAsync(ms: number, signal?: AbortSignal): Promise<void> {\n\tawait setTimeout(ms, undefined, { signal });\n}\n","import type { HttpClient, SleepFunc } from \"../../client/types.ts\";\nimport { defaultSleepAsync } from \"../utils/sleep.ts\";\nimport { createFetchHttpClient } from \"./fetch-client.ts\";\n\n/**\n * Options accepted by {@link resolveDependencies}. Mirrors the test-seam\n * subset of the public client options.\n */\ninterface ResolveDependenciesOptions {\n\t/**\n\t * Test seam: custom {@link HttpClient}. Defaults to a fetch-backed client.\n\t */\n\treadonly httpClient?: HttpClient | undefined;\n\t/**\n\t * Test seam: custom {@link SleepFunc}. Defaults to a `setTimeout`-backed\n\t * sleep.\n\t */\n\treadonly sleep?: SleepFunc | undefined;\n}\n\n/**\n * Fully-populated dependency set consumed by resource client constructors.\n */\ninterface ResolvedDependencies {\n\t/** Concrete {@link HttpClient} implementation. */\n\treadonly httpClient: HttpClient;\n\t/** Concrete {@link SleepFunc} implementation. */\n\treadonly sleep: SleepFunc;\n}\n\n/**\n * Resolves the concrete HTTP client and sleep implementation a resource\n * client should use. Falls back to the fetch-backed HTTP client and the\n * default `setTimeout`-based sleep when the caller omits the test seams.\n *\n * Extracted so resource client constructors can keep their dependency\n * resolution logic in a single, unit-testable place; this makes the\n * default branches easy to cover without stubbing globals like `fetch`.\n *\n * @param options - Optional {@link HttpClient} and {@link SleepFunc} test seams.\n * @returns A {@link ResolvedDependencies} with defaults applied.\n */\nexport function resolveDependencies(options: ResolveDependenciesOptions): ResolvedDependencies {\n\treturn {\n\t\thttpClient: options.httpClient ?? createFetchHttpClient(),\n\t\tsleep: options.sleep ?? defaultSleepAsync,\n\t};\n}\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { withCredentialSnapshot } from \"../credential-snapshot.ts\";\nimport { requestAbortedError } from \"../utils/abort.ts\";\nimport type { AdmissionWaitContext } from \"./admission-wait.ts\";\nimport {\n\telapsedDeadlineFailure,\n\trequestLifecycle,\n\ttype RequestLifecycle,\n} from \"./request-deadline.ts\";\nimport type { RetryResolvable } from \"./retry.ts\";\n\n/** Request-only controls resolved before request construction. */\nexport interface RequestStart {\n\t/** Admission controls the rate-limit queue and budget gate honour. */\n\treadonly admission: AdmissionWaitContext;\n\t/** Abort and deadline signals for the whole request. */\n\treadonly lifecycle: RequestLifecycle;\n\t/** Per-call options to merge over the client config. */\n\treadonly requestOptions: Partial<RetryResolvable>;\n}\n\n/**\n * Resolve the request-only controls of one call before its request is\n * built: fail at once on an already-aborted caller signal or an elapsed\n * deadline, otherwise start the request lifecycle and split the per-call\n * options from the admission controls.\n *\n * @param options - The caller's per-request options, if any.\n * @returns The resolved controls, or the abort or deadline failure.\n */\nexport function startRequest(\n\toptions: RequestOptions | undefined,\n): Result<RequestStart, OpenCloudError> {\n\tconst callerSignal = options?.signal;\n\tif (callerSignal?.aborted === true) {\n\t\treturn { err: requestAbortedError(callerSignal), success: false };\n\t}\n\n\tconst lifecycle = requestLifecycle(options?.deadlineMs, callerSignal);\n\tconst deadlineFailure = elapsedDeadlineFailure(lifecycle);\n\tif (deadlineFailure !== undefined) {\n\t\treturn { err: deadlineFailure, success: false };\n\t}\n\n\tconst { deadlineMs, onAdmissionWait, signal: _signal, ...requestOptions } = options ?? {};\n\treturn {\n\t\tdata: {\n\t\t\tadmission: { deadlineMs, observer: onAdmissionWait, signal: lifecycle.signal },\n\t\t\tlifecycle,\n\t\t\trequestOptions: withCredentialSnapshot(requestOptions),\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n","import type { Credential, ResolvedCredential } from \"../../client/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { CredentialError } from \"../../errors/credential-error.ts\";\nimport type { Result } from \"../../types.ts\";\n\n/** A credential that sends a header. */\nexport type SendingCredential = Extract<Credential, Readonly<Record<\"kind\", \"apiKey\" | \"oauth\">>>;\n\n/**\n * Names the rate-limit bucket a credential draws on. The key is namespaced by\n * kind, so an OAuth identity never shares a bucket with an equal API key. An\n * OAuth credential keys on its identity, so a token rotation keeps the bucket.\n *\n * @param credential - The effective credential.\n * @returns The bucket key. It holds the API key, so keep it in private maps.\n */\nexport function credentialQueueKey(credential: SendingCredential): string {\n\treturn credential.kind === \"apiKey\"\n\t\t? `apiKey:${credential.apiKey}`\n\t\t: `oauth:${credential.identity}`;\n}\n\n/**\n * Turns the effective credential into the header-ready form for one transport\n * attempt. Calls an OAuth provider once; a throw or a rejection becomes a\n * {@link CredentialError} whose `cause` is the provider's error.\n *\n * @param credential - The effective credential.\n * @param signal - The request's signal, handed to an OAuth provider. A\n * request with no signal hands the provider one that never aborts.\n * @returns The resolved credential, or the provider failure.\n */\nexport async function resolveAttemptCredentialAsync(\n\tcredential: SendingCredential,\n\tsignal: AbortSignal | undefined,\n): Promise<Result<ResolvedCredential, OpenCloudError>> {\n\tif (credential.kind === \"apiKey\") {\n\t\treturn { data: { apiKey: credential.apiKey, kind: \"apiKey\" }, success: true };\n\t}\n\n\ttry {\n\t\tconst accessToken = await credential.getAccessToken({\n\t\t\tsignal: signal ?? neverAbortingSignal(),\n\t\t});\n\t\treturn { data: { accessToken, kind: \"oauth\" }, success: true };\n\t} catch (err) {\n\t\treturn {\n\t\t\terr: new CredentialError(\"OAuth credential provider failed\", { cause: err }),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n}\n\nfunction neverAbortingSignal(): AbortSignal {\n\tconst controller = new AbortController();\n\treturn controller.signal;\n}\n","import type { ResolvedCredential } from \"../../client/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { classifyCredentialRejection } from \"./credential-rejection.ts\";\nimport {\n\tcredentialQueueKey,\n\tresolveAttemptCredentialAsync,\n\ttype SendingCredential,\n} from \"./credential.ts\";\nimport type { RetryResolvable } from \"./retry.ts\";\n\n/** What a method declares about its authentication. */\ninterface AuthenticationSpec {\n\treadonly unauthenticatedBaseUrl?: string;\n}\n\n/** The call's config and credential once its authentication is applied. */\ninterface CallAuthentication {\n\t/** The credential to send, or `undefined` for an unauthenticated call. */\n\treadonly credential: SendingCredential | undefined;\n\t/**\n\t * The merged config, pointed at the method's own origin when it has one.\n\t */\n\treadonly merged: RetryResolvable;\n}\n\nconst UNAUTHENTICATED_QUEUE_KEY = \"none\";\n\nconst UNAUTHENTICATED = Object.freeze({\n\tdata: Object.freeze({ kind: \"none\" }),\n\tsuccess: true,\n} satisfies Result<ResolvedCredential, OpenCloudError>);\n\n/**\n * Applies a method's authentication to the merged config. An unauthenticated\n * method is served from its own origin and carries no credential. A\n * `{ kind: \"none\" }` credential carries none either.\n *\n * @param merged - The merged config of the call.\n * @param spec - The method's authentication declaration.\n * @returns The config to send with and the credential, if any.\n */\nexport function authenticateCall(\n\tmerged: RetryResolvable,\n\t{ unauthenticatedBaseUrl }: AuthenticationSpec,\n): CallAuthentication {\n\tif (unauthenticatedBaseUrl !== undefined) {\n\t\treturn { credential: undefined, merged: { ...merged, baseUrl: unauthenticatedBaseUrl } };\n\t}\n\n\treturn {\n\t\tcredential: merged.credential.kind === \"none\" ? undefined : merged.credential,\n\t\tmerged,\n\t};\n}\n\n/**\n * Keys the rate-limit queue of a call. Every unauthenticated call shares one\n * key, since Roblox counts those per caller.\n *\n * @param credential - The call's credential, or `undefined` when it sends\n * none.\n * @returns The credential's queue key, or the shared unauthenticated key.\n */\nexport function callQueueKey(credential: SendingCredential | undefined): string {\n\treturn credential === undefined ? UNAUTHENTICATED_QUEUE_KEY : credentialQueueKey(credential);\n}\n\n/**\n * Resolves the credential one attempt sends. An unauthenticated call sends\n * none and runs no OAuth provider.\n *\n * @param credential - The call's credential, if any.\n * @param signal - The caller's cancellation signal.\n * @returns The resolved credential, or the provider failure.\n */\nexport async function resolveCallCredentialAsync(\n\tcredential: SendingCredential | undefined,\n\tsignal: AbortSignal | undefined,\n): Promise<Result<ResolvedCredential, OpenCloudError>> {\n\treturn credential === undefined\n\t\t? UNAUTHENTICATED\n\t\t: resolveAttemptCredentialAsync(credential, signal);\n}\n\n/**\n * Refines one attempt's transport error, then classifies a refused OAuth\n * token. An unauthenticated call sent no token, so none was refused.\n *\n * @param err - The transport error of the attempt.\n * @param context - The call's credential and optional refinement.\n * @returns The classified error.\n */\nexport function classifySendError(\n\terr: OpenCloudError,\n\t{\n\t\tcredential,\n\t\trefineError,\n\t}: {\n\t\treadonly credential: SendingCredential | undefined;\n\t\treadonly refineError: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\t},\n): OpenCloudError {\n\tconst refined = refineError === undefined ? err : refineError(err);\n\treturn credential === undefined ? refined : classifyCredentialRejection(refined, credential);\n}\n","import type { HttpRequest, HttpResponse } from \"../client/types.ts\";\nimport type { OpenCloudError } from \"../errors/base.ts\";\nimport { UnexpectedResponseError } from \"../errors/unexpected-response.ts\";\nimport { pickDiagnosticHeaders } from \"./http/diagnostics.ts\";\n\nconst TRAILING_SLASH = /\\/$/;\n\n/** The request a parser's input answered, and the response it parsed. */\nexport interface ParsedExchange {\n\t/** Base URL the request path was sent against. */\n\treadonly baseUrl: string;\n\t/** End the message with the bug report link. */\n\treadonly reportHint: boolean;\n\t/** The request that was sent. */\n\treadonly request: HttpRequest;\n\t/** The successful response the parser rejected. */\n\treadonly response: HttpResponse;\n}\n\n/**\n * Rebuilds a parser's {@link UnexpectedResponseError} with the request it\n * answered. A parser sees only the response, so the call site adds the method,\n * the full URL, and the allowlisted response headers, and ends the message with\n * the bug report link when `reportHint` is set. Any other error is returned\n * unchanged.\n *\n * @param err - The parser's error.\n * @param exchange - The base URL, the request sent, and the response parsed.\n * @returns `err`, carrying the request context when it is an unexpected\n * response.\n */\nexport function withRequestContext(\n\terr: OpenCloudError,\n\t{ baseUrl, reportHint, request, response }: ParsedExchange,\n): OpenCloudError {\n\tif (!(err instanceof UnexpectedResponseError)) {\n\t\treturn err;\n\t}\n\n\treturn new UnexpectedResponseError(err.message, {\n\t\tcause: err.cause,\n\t\tcode: err.code,\n\t\tdetails: err.details,\n\t\tmethod: request.method,\n\t\treportHint,\n\t\tresponseHeaders: pickDiagnosticHeaders({ ...response.headers }),\n\t\tstatusCode: err.statusCode,\n\t\turl: `${baseUrl.replace(TRAILING_SLASH, \"\")}${request.url}`,\n\t});\n}\n","import type { Except } from \"type-fest\";\n\nimport type {\n\tHttpClient,\n\tHttpRequest,\n\tHttpResponse,\n\tOpenCloudClientOptions,\n\tOpenCloudHooks,\n\tRequestConfig,\n\tRequestOptions,\n\tSleepFunc,\n} from \"../client/types.ts\";\nimport { type OpenCloudError, recordPreviousAttempts } from \"../errors/base.ts\";\nimport type { PermissionError } from \"../errors/permission-error.ts\";\nimport { RateLimitWaitRefusedError } from \"../errors/rate-limit-wait-refused.ts\";\nimport { RequestAbortedError } from \"../errors/request-aborted.ts\";\nimport { RequestDeadlineExceededError } from \"../errors/request-deadline-exceeded.ts\";\nimport type { Result } from \"../types.ts\";\nimport { credentialNotSupportedFailure } from \"./api-key-only.ts\";\nimport { snapshotCredential } from \"./credential-snapshot.ts\";\nimport type { AdmissionWaitContext } from \"./http/admission-wait.ts\";\nimport { BudgetGate, type BudgetScope, scopeKey } from \"./http/budget-gate.ts\";\nimport { enrichPermissionError } from \"./http/credential-rejection.ts\";\nimport type { SendingCredential } from \"./http/credential.ts\";\nimport { executeWithRetryAsync } from \"./http/execute.ts\";\nimport { type LockoutExemption, observeAttempt } from \"./http/rate-limit-observation.ts\";\nimport { documentedWindow, type OperationLimit, RateLimitQueue } from \"./http/rate-limit-queue.ts\";\nimport { buildRequestConfig } from \"./http/request-config.ts\";\nimport { deadlineFailureFromError, type RequestLifecycle } from \"./http/request-deadline.ts\";\nimport { resolveDependencies } from \"./http/resolve-dependencies.ts\";\nimport {\n\tdefaultRetryDelay,\n\tIDEMPOTENT_METHOD_DEFAULTS,\n\tmergeConfig,\n\ttype MethodKind,\n\ttype RetryResolvable,\n} from \"./http/retry.ts\";\nimport { startRequest } from \"./http/start-request.ts\";\nimport {\n\tauthenticateCall,\n\tcallQueueKey,\n\tclassifySendError,\n\tresolveCallCredentialAsync,\n} from \"./http/unauthenticated.ts\";\nimport { withRequestContext } from \"./with-request-context.ts\";\n\n/**\n * Describes a single resource method's shape for dispatch through\n * `ResourceClient.execute`. Each resource client declares one module-level\n * constant per public method; that constant binds the four resource-specific\n * values (request builder, response parser, retry-policy method kind,\n * operation-level rate limit) and flows through `execute` uniformly.\n *\n * @template P - The resource-specific parameter shape the builder\n * accepts.\n * @template T - The resource-specific parsed success type the parser\n * produces.\n */\nexport interface ResourceMethodSpec<P, T> {\n\t/**\n\t * Marks an Operation that Roblox accepts only with an API key. An OAuth\n\t * call returns `CredentialNotSupportedError` with no token and no request.\n\t */\n\treadonly apiKeyOnly?: boolean;\n\t/**\n\t * Builds the pure {@link HttpRequest} for a single call. Returns a\n\t * {@link Result} so a builder can short-circuit with a local error\n\t * (typically a {@link OpenCloudError} subclass such as `ValidationError`)\n\t * before any HTTP, queue, or retry work happens. Builders that cannot\n\t * fail wrap their return as `{ data: request, success: true }`.\n\t */\n\treadonly buildRequest: (parameters: P) => Result<HttpRequest, OpenCloudError>;\n\t/** Method-level retry defaults merged into the resolved config. */\n\treadonly methodDefaults: Partial<RetryResolvable>;\n\t/**\n\t * Method kind, controlling merge precedence: `\"create\"` lets method\n\t * defaults win over client config so create safety cannot be relaxed\n\t * silently; `\"idempotent\"` lets client config win over method defaults\n\t * so consumers can loosen retry globally.\n\t */\n\treadonly methodKind: MethodKind;\n\t/**\n\t * Operation-level rate limit, keyed into the client's per-key queue map.\n\t */\n\treadonly operationLimit: OperationLimit;\n\t/**\n\t * Converts the full {@link HttpResponse} into the resource-specific\n\t * parsed shape. Takes the whole response (body, status, headers) so\n\t * future parsers can read headers without widening the signature.\n\t */\n\treadonly parse: (response: HttpResponse) => Result<T, OpenCloudError>;\n\t/**\n\t * Open Cloud scopes the API key or OAuth token must carry for this\n\t * method, sourced from the vendored OpenAPI schema's `x-roblox-scopes`.\n\t * When set, a 401 or 403 ApiError from the upstream call is upgraded to\n\t * a {@link PermissionError} carrying these scopes alongside\n\t * {@link OperationLimit.operationKey}, so callers can name the missing\n\t * scope instead of just the HTTP status. On an OAuth credential a\n\t * non-gateway 401 is a `CredentialRejectedError` instead, and the 403\n\t * message adds a grant hint. Optional so test specs and\n\t * not-yet-wired resources can opt out.\n\t */\n\treadonly requiredScopes?: ReadonlyArray<string>;\n\t/**\n\t * Marks an Operation that Roblox documents as unauthenticated, served from\n\t * this origin. The call sends no credential, never asks an OAuth provider\n\t * for a token, and shares one rate-limit queue across credentials.\n\t */\n\treadonly unauthenticatedBaseUrl?: string;\n}\n\n/**\n * Single-argument bundle consumed by `ResourceClient.execute`: the per-method\n * spec, the resource-specific parameters, and optional per-request config\n * overrides.\n *\n * @template P - The resource-specific parameter shape the builder accepts.\n * @template T - The resource-specific parsed success type the parser produces.\n */\ninterface ExecuteCall<P, T> {\n\t/**\n\t * Optionally exempts a long 429 from locking the operation out, when its\n\t * evidence shows it clears on some other event than its guided wait.\n\t */\n\treadonly exemptsLockout?: LockoutExemption | undefined;\n\t/** Optional per-request config overrides. */\n\treadonly options?: RequestOptions | undefined;\n\t/** Resource-specific request parameters. */\n\treadonly parameters: P;\n\t/** Optionally refines a transport error with resource-specific evidence. */\n\treadonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\t/**\n\t * Per-method binding of builder, parser, method kind, and operation limit.\n\t */\n\treadonly spec: ResourceMethodSpec<P, T>;\n}\n\n/**\n * Wraps an infallible request build as a {@link Result}-returning\n * `buildRequest` callback compatible with {@link ResourceMethodSpec}.\n * Use from a resource client whose builder cannot fail; resource clients\n * with local validation should construct the {@link Result} directly.\n *\n * @param request - The pre-built {@link HttpRequest}.\n * @returns A success Result wrapping the request.\n */\nexport function okRequest(request: HttpRequest): Result<HttpRequest, OpenCloudError> {\n\treturn { data: request, success: true };\n}\n\n/**\n * A {@link ResourceMethodSpec.parse} implementation for endpoints that return\n * no business payload on success (such as `DELETE` and reorder operations).\n * Surfaces `undefined` data and never inspects the response body.\n *\n * @returns A success Result with `undefined` data.\n */\nexport function parseEmptyResponse(): Result<undefined, OpenCloudError> {\n\treturn { data: undefined, success: true };\n}\n\nconst CLIENT_DEFAULTS = Object.freeze({\n\tbaseUrl: \"https://apis.roblox.com\",\n\tmaxRetries: 3,\n\tretryableStatuses: IDEMPOTENT_METHOD_DEFAULTS.retryableStatuses,\n\tretryableTransportCodes: IDEMPOTENT_METHOD_DEFAULTS.retryableTransportCodes,\n\tretryDelay: defaultRetryDelay,\n\ttimeout: 30_000,\n} satisfies Except<RetryResolvable, \"credential\">);\n\ninterface DispatchInputs {\n\treadonly admission: AdmissionWaitContext;\n\treadonly credential: SendingCredential | undefined;\n\treadonly exemptsLockout: LockoutExemption | undefined;\n\treadonly merged: RetryResolvable;\n\treadonly operationLimit: OperationLimit;\n\treadonly refineError: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\treadonly request: HttpRequest;\n\treadonly requestConfig: Except<RequestConfig, \"credential\">;\n}\n\n/** Inputs to the request-scoped budget-gated transport callback. */\ninterface GatedSendInputs {\n\treadonly admission: AdmissionWaitContext;\n\treadonly credential: SendingCredential | undefined;\n\treadonly exemptsLockout: LockoutExemption | undefined;\n\treadonly refineError: ((error: OpenCloudError) => OpenCloudError) | undefined;\n\treadonly requestConfig: Except<RequestConfig, \"credential\">;\n\treadonly scope: BudgetScope;\n}\n\ninterface FinishRequestInputs<P, T> {\n\treadonly httpResult: Result<HttpResponse, OpenCloudError>;\n\treadonly lifecycle: RequestLifecycle;\n\treadonly merged: RetryResolvable;\n\treadonly request: HttpRequest;\n\treadonly spec: ResourceMethodSpec<P, T>;\n}\n\n/**\n * Internal orchestrator shared by every Open Cloud resource client. Holds\n * the frozen client config, observability hooks, injected HTTP client and\n * sleep, and the per-effective-key rate-limit queue registry. Resource\n * classes compose one instance and dispatch every public method through\n * {@link ResourceClient.executeAsync} with a per-method {@link ResourceMethodSpec}.\n * Not exported from any package subpath; reachable only via sibling\n * `src/resources/**` modules in this package.\n */\nexport class ResourceClient {\n\treadonly #budgets: BudgetGate;\n\treadonly #config: Readonly<RetryResolvable>;\n\treadonly #hooks: OpenCloudHooks;\n\treadonly #httpClient: HttpClient;\n\treadonly #queues = new Map<string, RateLimitQueue>();\n\treadonly #reportHint: boolean;\n\treadonly #sleep: SleepFunc;\n\n\t/**\n\t * Creates a new {@link ResourceClient}. Resolves the injected HTTP\n\t * client and sleep (defaulting to fetch + `setTimeout`) and freezes the\n\t * merged client config so subsequent calls cannot mutate it.\n\t *\n\t * @param options - Client-level configuration including the credential\n\t * and optional construction-time test seams.\n\t */\n\tconstructor({ hooks, httpClient, reportHint, sleep, ...overrides }: OpenCloudClientOptions) {\n\t\tconst resolved = resolveDependencies({ httpClient, sleep });\n\t\tthis.#httpClient = resolved.httpClient;\n\t\tthis.#sleep = resolved.sleep;\n\t\tthis.#budgets = new BudgetGate(this.#sleep);\n\t\tthis.#hooks = hooks ?? {};\n\t\tthis.#reportHint = reportHint ?? true;\n\t\tthis.#config = Object.freeze({\n\t\t\t...CLIENT_DEFAULTS,\n\t\t\t...overrides,\n\t\t\tcredential: snapshotCredential(overrides.credential),\n\t\t});\n\t}\n\n\t/**\n\t * Dispatches a single resource-method call. Merges the frozen client\n\t * config with the method's `methodDefaults` and the caller's optional\n\t * per-request `options`, routes through the effective-credential rate-limit\n\t * queue, runs the retry loop, and finally parses the response with the\n\t * spec's parser.\n\t *\n\t * @param call - The per-method spec, resource-specific parameters, and\n\t * optional per-request overrides.\n\t * @returns The parsed success payload or the {@link OpenCloudError} that\n\t * caused the request to fail. Never throws.\n\t * @rejects An unexpected collaborator failure unrelated to caller cancellation.\n\t */\n\tpublic async executeAsync<P, T>({\n\t\texemptsLockout,\n\t\toptions,\n\t\tparameters,\n\t\trefineError,\n\t\tspec,\n\t}: ExecuteCall<P, T>): Promise<Result<T, OpenCloudError>> {\n\t\tconst start = startRequest(options);\n\t\tif (!start.success) {\n\t\t\treturn start;\n\t\t}\n\n\t\tconst { admission, lifecycle, requestOptions } = start.data;\n\t\tconst { credential, merged } = authenticateCall(this.#merge(spec, requestOptions), spec);\n\t\tconst requestResult =\n\t\t\tcredentialNotSupportedFailure(spec, merged.credential) ?? spec.buildRequest(parameters);\n\t\tif (!requestResult.success) {\n\t\t\treturn requestResult;\n\t\t}\n\n\t\tconst request = requestResult.data;\n\t\tconst { signal } = admission;\n\t\tconst requestConfig = buildRequestConfig({ merged, options, request, signal });\n\t\tconst httpResult = await this.#dispatchAsync({\n\t\t\tadmission,\n\t\t\tcredential,\n\t\t\texemptsLockout,\n\t\t\tmerged,\n\t\t\toperationLimit: spec.operationLimit,\n\t\t\trefineError,\n\t\t\trequest,\n\t\t\trequestConfig,\n\t\t});\n\t\treturn finishRequest({ httpResult, lifecycle, merged, request, spec }, this.#reportHint);\n\t}\n\n\t/**\n\t * Returns the sleep function used by this client instance.\n\t *\n\t * @returns The sleep function injected at construction time.\n\t */\n\tpublic get sleep(): SleepFunc {\n\t\treturn this.#sleep;\n\t}\n\n\tasync #dispatchAsync({\n\t\tadmission,\n\t\tcredential,\n\t\texemptsLockout,\n\t\tmerged,\n\t\toperationLimit,\n\t\trefineError,\n\t\trequest,\n\t\trequestConfig,\n\t}: DispatchInputs): Promise<Result<HttpResponse, OpenCloudError>> {\n\t\tconst credentialKey = callQueueKey(credential);\n\t\tconst queue = this.#getQueue(credentialKey, operationLimit);\n\t\tconst scope = budgetScopeFor(credentialKey, operationLimit);\n\t\ttry {\n\t\t\tthis.#budgets.refuseDuringLockout(scope);\n\t\t\treturn await queue.acquireAsync(async () => {\n\t\t\t\treturn executeWithRetryAsync(request, {\n\t\t\t\t\tadmissionWaitObserver: admission.observer,\n\t\t\t\t\tconfig: merged,\n\t\t\t\t\tdeadlineMs: admission.deadlineMs,\n\t\t\t\t\thooks: this.#hooks,\n\t\t\t\t\tsend: this.#gatedSend({\n\t\t\t\t\t\tadmission,\n\t\t\t\t\t\tcredential,\n\t\t\t\t\t\texemptsLockout,\n\t\t\t\t\t\trefineError,\n\t\t\t\t\t\trequestConfig,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t}),\n\t\t\t\t\tsignal: admission.signal,\n\t\t\t\t\tsleep: this.#sleep,\n\t\t\t\t});\n\t\t\t}, admission);\n\t\t} catch (err) {\n\t\t\treturn dispatchFailure(err);\n\t\t}\n\t}\n\n\t/**\n\t * Builds the transport callback for one logical call, wrapping the HTTP\n\t * client with the budget gate: each attempt waits on the scope's budget,\n\t * then resolves the credential (an OAuth provider runs here, after every\n\t * admission wait) before sending, then folds the response's reported\n\t * budget back in so the next attempt (or a later call on the same scope)\n\t * can head off a 429. A provider failure, or a lockout that began while the\n\t * provider ran, ends the attempt unsent and gives its budget slot back.\n\t *\n\t * @param inputs - Budget scope, transport config, observer, and caller signal.\n\t * @returns A send callback for {@link executeWithRetryAsync}.\n\t */\n\t#gatedSend({\n\t\tadmission,\n\t\tcredential,\n\t\texemptsLockout,\n\t\trefineError,\n\t\trequestConfig,\n\t\tscope,\n\t}: GatedSendInputs): (request: HttpRequest) => Promise<Result<HttpResponse, OpenCloudError>> {\n\t\treturn async (toSend) => {\n\t\t\tconst reservation = await this.#budgets.gateAsync(scope, admission);\n\t\t\tconst attempted = await resolveCallCredentialAsync(credential, admission.signal);\n\t\t\tconst resolved = this.#budgets.refuseIfLockedOut(scope, attempted);\n\t\t\tif (!resolved.success) {\n\t\t\t\treservation.release();\n\t\t\t\treturn resolved;\n\t\t\t}\n\n\t\t\tconst transportResult = await this.#httpClient.request(toSend, {\n\t\t\t\t...requestConfig,\n\t\t\t\tcredential: resolved.data,\n\t\t\t});\n\t\t\tconst sendResult = transportResult.success\n\t\t\t\t? transportResult\n\t\t\t\t: {\n\t\t\t\t\t\terr: classifySendError(transportResult.err, { credential, refineError }),\n\t\t\t\t\t\tsuccess: false as const,\n\t\t\t\t\t};\n\t\t\tobserveAttempt(this.#budgets, { exemptsLockout, scope, transportResult });\n\t\t\treturn sendResult;\n\t\t};\n\t}\n\n\t#getQueue(credentialKey: string, limit: OperationLimit): RateLimitQueue {\n\t\tconst key = scopeKey({ credentialKey, operationKey: limit.operationKey });\n\t\tconst existing = this.#queues.get(key);\n\t\tif (existing !== undefined) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst queue = new RateLimitQueue(limit, this.#hooks, this.#sleep);\n\t\tthis.#queues.set(key, queue);\n\t\treturn queue;\n\t}\n\n\t#merge<P, T>(\n\t\tspec: ResourceMethodSpec<P, T>,\n\t\trequestOptions: Partial<RetryResolvable>,\n\t): RetryResolvable {\n\t\treturn mergeConfig(this.#config, {\n\t\t\tmethodDefaults: spec.methodDefaults,\n\t\t\tmethodKind: spec.methodKind,\n\t\t\trequestOptions,\n\t\t});\n\t}\n}\n\nfunction budgetScopeFor(credentialKey: string, operationLimit: OperationLimit): BudgetScope {\n\treturn {\n\t\tcredentialKey,\n\t\tdocumentedWindow: documentedWindow(operationLimit),\n\t\toperationKey: operationLimit.operationKey,\n\t};\n}\n\nfunction dispatchFailure(err: unknown): Result<never, OpenCloudError> {\n\tif (\n\t\terr instanceof RequestAbortedError ||\n\t\terr instanceof RequestDeadlineExceededError ||\n\t\terr instanceof RateLimitWaitRefusedError\n\t) {\n\t\treturn { err, success: false };\n\t}\n\n\tthrow err;\n}\n\nfunction finishRequest<P, T>(\n\t{ httpResult, lifecycle, merged, request, spec }: FinishRequestInputs<P, T>,\n\treportHint: boolean,\n): Result<T, OpenCloudError> {\n\tif (httpResult.success) {\n\t\tconst parsed = spec.parse(httpResult.data);\n\t\treturn parsed.success\n\t\t\t? parsed\n\t\t\t: {\n\t\t\t\t\terr: withRequestContext(parsed.err, {\n\t\t\t\t\t\tbaseUrl: merged.baseUrl,\n\t\t\t\t\t\treportHint,\n\t\t\t\t\t\trequest,\n\t\t\t\t\t\tresponse: httpResult.data,\n\t\t\t\t\t}),\n\t\t\t\t\tsuccess: false,\n\t\t\t\t};\n\t}\n\n\tconst deadlineFailure = deadlineFailureFromError(httpResult.err, lifecycle);\n\tconst err =\n\t\tdeadlineFailure ??\n\t\tenrichPermissionError(httpResult.err, {\n\t\t\tcredential: merged.credential,\n\t\t\toperationKey: spec.operationLimit.operationKey,\n\t\t\trequiredScopes: spec.requiredScopes,\n\t\t});\n\treturn {\n\t\terr: recordPreviousAttempts(err, httpResult.err.previousAttempts),\n\t\tsuccess: false,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAgB,iBAAiB,OAAiC;CACjE,IAAI,OAAO,UAAU,UACpB,OAAO;CAGR,MAAM,SAAS,IAAI,KAAK,K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