@bedrock-rbx/ocale 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/badges.d.mts +1 -1
- package/dist/badges.mjs +3 -3
- package/dist/{polling-Bs0GDvEa.d.mts → capacity-admission-BvnJjY0S.d.mts} +53 -14
- package/dist/capacity-admission-BvnJjY0S.d.mts.map +1 -0
- package/dist/developer-products.d.mts +1 -1
- package/dist/developer-products.mjs +4 -4
- package/dist/game-passes.d.mts +1 -1
- package/dist/game-passes.mjs +4 -4
- package/dist/index.d.mts +217 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +70 -5
- package/dist/index.mjs.map +1 -0
- package/dist/luau-execution.d.mts +39 -5
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +8 -13
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{rate-limit-Df55K34f.mjs → network-error-DR9FX5hb.mjs} +81 -36
- package/dist/network-error-DR9FX5hb.mjs.map +1 -0
- package/dist/places.d.mts +4 -4
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +8 -13
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-DpEY-gAc.mjs → poll-timeout-3PXLsabj.mjs} +2 -2
- package/dist/{poll-timeout-DpEY-gAc.mjs.map → poll-timeout-3PXLsabj.mjs.map} +1 -1
- package/dist/{polling-helpers-BjFXyaOm.mjs → polling-helpers-CFuSt2O5.mjs} +349 -67
- package/dist/polling-helpers-CFuSt2O5.mjs.map +1 -0
- package/dist/{price-information-Brs8ebsh.mjs → price-information-D8BxwgTS.mjs} +2 -2
- package/dist/{price-information-Brs8ebsh.mjs.map → price-information-D8BxwgTS.mjs.map} +1 -1
- package/dist/resource-client--yYybltk.mjs +899 -0
- package/dist/resource-client--yYybltk.mjs.map +1 -0
- package/dist/resource-client-BivRq3JZ.d.mts +164 -0
- package/dist/resource-client-BivRq3JZ.d.mts.map +1 -0
- package/dist/retry-Cc4LcXYZ.mjs +1456 -0
- package/dist/retry-Cc4LcXYZ.mjs.map +1 -0
- package/dist/{retry-CdpA3z4A.d.mts → retry-DXEklFrt.d.mts} +51 -16
- package/dist/{retry-CdpA3z4A.d.mts.map → retry-DXEklFrt.d.mts.map} +1 -1
- package/dist/storage.d.mts +2 -157
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +3 -3
- package/dist/testing.d.mts +9 -17
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/{types-mhEalVsR.d.mts → types-C3Egi37J.d.mts} +86 -10
- package/dist/types-C3Egi37J.d.mts.map +1 -0
- package/dist/universes.d.mts +1 -1
- package/dist/universes.mjs +4 -4
- package/dist/{validation-Cg2lBhpQ.mjs → validation-B_Zs1So2.mjs} +2 -2
- package/dist/{validation-Cg2lBhpQ.mjs.map → validation-B_Zs1So2.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/polling-Bs0GDvEa.d.mts.map +0 -1
- package/dist/polling-helpers-BjFXyaOm.mjs.map +0 -1
- package/dist/rate-limit-Df55K34f.mjs.map +0 -1
- package/dist/resource-client-DtfDWglY.mjs +0 -1177
- package/dist/resource-client-DtfDWglY.mjs.map +0 -1
- package/dist/retry-DM2-tlR8.mjs +0 -458
- package/dist/retry-DM2-tlR8.mjs.map +0 -1
- package/dist/types-mhEalVsR.d.mts.map +0 -1
package/dist/luau-execution.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CREATE_METHOD_DEFAULTS } from "./retry-
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
1
|
+
import { a as ApiError } from "./network-error-DR9FX5hb.mjs";
|
|
2
|
+
import { t as CREATE_METHOD_DEFAULTS } from "./retry-Cc4LcXYZ.mjs";
|
|
3
|
+
import { n as okRequest, o as toJsonDetails, s as isRecord, t as ResourceClient } from "./resource-client--yYybltk.mjs";
|
|
4
|
+
import { a as pollUntilDoneCoreAsync, c as LIST_LOGS_SPEC, i as defaultPollDelay, l as LuauExecutionCapacityError, n as submitAndPollAsync, o as withBudgetRequestTimeout, r as submitWithCapacityAsync, s as GET_SPEC, t as buildPollDependencies } from "./polling-helpers-CFuSt2O5.mjs";
|
|
5
5
|
//#region src/domains/cloud-v2/luau-execution-task-binary-inputs/builders.ts
|
|
6
6
|
/**
|
|
7
7
|
* Builds a `POST` request for the Open Cloud
|
|
@@ -165,20 +165,15 @@ function createTasksHandle(inner) {
|
|
|
165
165
|
});
|
|
166
166
|
},
|
|
167
167
|
async submit(parameters, options) {
|
|
168
|
-
|
|
168
|
+
return submitWithCapacityAsync({
|
|
169
|
+
inner,
|
|
169
170
|
options,
|
|
170
|
-
parameters
|
|
171
|
-
spec: SUBMIT_VERSION_SPEC
|
|
172
|
-
});
|
|
173
|
-
return inner.executeAsync({
|
|
174
|
-
options,
|
|
175
|
-
parameters,
|
|
176
|
-
spec: SUBMIT_HEAD_SPEC
|
|
171
|
+
parameters
|
|
177
172
|
});
|
|
178
173
|
}
|
|
179
174
|
};
|
|
180
175
|
}
|
|
181
176
|
//#endregion
|
|
182
|
-
export { LuauExecutionClient, defaultPollDelay };
|
|
177
|
+
export { LuauExecutionCapacityError, LuauExecutionClient, defaultPollDelay };
|
|
183
178
|
|
|
184
179
|
//# sourceMappingURL=luau-execution.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"luau-execution.mjs","names":["#inner"],"sources":["../src/domains/cloud-v2/luau-execution-task-binary-inputs/builders.ts","../src/domains/cloud-v2/luau-execution-task-binary-inputs/operations.ts","../src/domains/cloud-v2/luau-execution-task-binary-inputs/parsers.ts","../src/resources/luau-execution/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../client/types.ts\";\nimport type { CreateBinaryInputParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the Open Cloud\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` endpoint. The\n * server responds with a presigned `uploadUri` and the resource `path`.\n *\n * @param parameters - Universe identifier and the byte size of the\n * binary to be uploaded.\n * @returns A pure {@link HttpRequest} describing the create call.\n */\nexport function buildCreateBinaryInputRequest({\n\tsize,\n\tuniverseId,\n}: CreateBinaryInputParameters): HttpRequest {\n\treturn {\n\t\tbody: { size },\n\t\theaders: { \"content-type\": \"application/json\" },\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/luau-execution-session-task-binary-inputs`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst CREATE_PER_MINUTE = 5;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for creating a Luau execution task binary\n * input, sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` operation (5 requests\n * per minute per API key owner). The whole per-minute allowance is also\n * the burst, matching the server: a probe found the sixth create within\n * one minute is the first to draw a 429.\n */\nexport const CREATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: CREATE_PER_MINUTE,\n\tmaxPerSecond: CREATE_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-task-binary-inputs.create\",\n});\n\n/**\n * Scopes required to create a Luau execution task binary input, sourced\n * from `x-roblox-scopes` on the create operation in the vendored OpenAPI\n * schema.\n */\nexport const CREATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { LuauExecutionTaskBinaryInput } from \"./types.ts\";\n\nconst PATH_PATTERN = /^universes\\/(\\d+)\\/luau-execution-session-task-binary-inputs\\/([^/]+)$/;\n\nconst MALFORMED_MESSAGE = \"Malformed luau-execution-session-task-binary-input response\";\n\n/**\n * Parses a successful Open Cloud\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` response body into\n * the public {@link LuauExecutionTaskBinaryInput}.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed binary input, or an\n * {@link ApiError} when the body does not match the expected shape.\n */\nexport function parseBinaryInputResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LuauExecutionTaskBinaryInput, ApiError> {\n\tif (!isRecord(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tif (typeof body[\"path\"] !== \"string\" || !PATH_PATTERN.test(body[\"path\"])) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tif (typeof body[\"uploadUri\"] !== \"string\") {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: { path: body[\"path\"], uploadUri: body[\"uploadUri\"] },\n\t\tsuccess: true,\n\t};\n}\n\nfunction malformed(\n\tstatusCode: number,\n\tbody: unknown,\n): Result<LuauExecutionTaskBinaryInput, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { buildCreateBinaryInputRequest } from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tCREATE_REQUIRED_SCOPES,\n} from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/operations.ts\";\nimport { parseBinaryInputResponse } from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/parsers.ts\";\nimport type {\n\tCreateBinaryInputParameters,\n\tLuauExecutionTaskBinaryInput,\n} from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/types.ts\";\nimport { LIST_LOGS_SPEC } from \"../../domains/cloud-v2/luau-execution-task-logs/specs.ts\";\nimport type {\n\tListLogsParameters,\n\tLogPage,\n} from \"../../domains/cloud-v2/luau-execution-task-logs/types.ts\";\nimport {\n\tGET_SPEC,\n\tSUBMIT_HEAD_SPEC,\n\tSUBMIT_VERSION_SPEC,\n} from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tGetParameters,\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 { CREATE_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport {\n\tokRequest,\n\tResourceClient,\n\ttype ResourceMethodSpec,\n} from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { buildPollDependencies, submitAndPollAsync } from \"./polling-helpers.ts\";\nimport {\n\tpollUntilDoneCoreAsync,\n\ttype PollUntilDoneOptions,\n\twithBudgetRequestTimeout,\n} from \"./polling.ts\";\n\nfunction makeSpec<P, R>(spec: ResourceMethodSpec<P, R>): ResourceMethodSpec<P, R> {\n\treturn Object.freeze(spec);\n}\n\nconst CREATE_BINARY_INPUT_SPEC = makeSpec<\n\tCreateBinaryInputParameters,\n\tLuauExecutionTaskBinaryInput\n>({\n\tbuildRequest: (parameters) => okRequest(buildCreateBinaryInputRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: CREATE_OPERATION_LIMIT,\n\tparse: parseBinaryInputResponse,\n\trequiredScopes: CREATE_REQUIRED_SCOPES,\n});\n\n/**\n * Operation handle for the `binaryInputs` namespace on\n * {@link LuauExecutionClient}. Provides `create` to allocate a presigned\n * upload slot for binary script inputs.\n *\n * @since 0.1.0\n */\nexport interface BinaryInputsHandle {\n\t/**\n\t * Allocates a presigned binary input upload slot. The returned\n\t * `uploadUri` is a presigned `PUT` target; the caller uploads the\n\t * binary data directly and passes `path` to `tasks.submit` as\n\t * `binaryInput`.\n\t *\n\t * @param parameters - Universe identifier and the byte size of the\n\t * binary to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTaskBinaryInput} or the {@link OpenCloudError}\n\t * that caused the request to fail.\n\t */\n\tcreate(\n\t\tparameters: CreateBinaryInputParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTaskBinaryInput, OpenCloudError>>;\n}\n\n/**\n * Operation handle exposed by {@link LuauExecutionClient} as the\n * `tasks` namespace. Provides `submit` to queue a Luau script, `get`\n * to fetch a task's current state, and `listLogs` to retrieve\n * structured log messages produced by a task.\n *\n * @since 0.1.0\n */\nexport interface TasksHandle {\n\t/**\n\t * Fetches the current state of a previously-submitted Luau\n\t * execution task. Uses idempotent retry semantics for both 429 and\n\t * 5xx.\n\t *\n\t * @param parameters - The task ref plus an optional `view` selector.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tget(\n\t\tparameters: GetParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Lists one page of structured log messages produced by a\n\t * previously-submitted Luau execution task. Messages from multiple\n\t * server-side chunks are flattened into a single ordered array.\n\t * Uses idempotent retry semantics for both 429 and 5xx.\n\t *\n\t * @param parameters - The task ref and optional pagination controls\n\t * (`pageSize`, `pageToken`).\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link LogPage} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tlistLogs(\n\t\tparameters: ListLogsParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LogPage, OpenCloudError>>;\n\t/**\n\t * Polls `tasks.get` with `view=BASIC` on a configurable backoff schedule\n\t * until the task reaches a terminal state, the wall-clock budget is\n\t * exhausted, or the supplied `AbortSignal` fires. Returns the terminal\n\t * task on success.\n\t *\n\t * @param ref - Reference to the task to poll, typically returned by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask},\n\t * or an error if aborted, timed out, or the transport fails.\n\t */\n\tpollUntilDone(\n\t\tref: LuauExecutionTaskRef,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script and polls `tasks.get` with `view=BASIC` until\n\t * the task reaches a terminal state, the wall-clock budget is\n\t * exhausted, or the supplied `AbortSignal` fires. Combines `submit`\n\t * and `pollUntilDone` in one call.\n\t *\n\t * @param parameters - The same input accepted by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal\n\t * {@link LuauExecutionTask}, or an error if submit fails, the task\n\t * is aborted, timed out, or the transport fails.\n\t */\n\trunUntilDone(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script for execution against a place. Dispatches\n\t * to the head-version URL when `versionId` is omitted, or to the\n\t * specific-version URL when one is supplied. Both URL shapes share\n\t * one rate-limit queue and one required-scope set.\n\t *\n\t * @param parameters - The universe and place identifiers, the\n\t * script to run, an optional `versionId`, and any other writable\n\t * submit fields.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tsubmit(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n}\n\n/**\n * Public client for the Roblox Open Cloud `LuauExecutionSessionTask`\n * resource. Tasks run a Luau script against a place and surface state,\n * output, or error through the `LuauExecutionTask` discriminated\n * union. Exposes `tasks.submit` for both the head version and a\n * specific place version, `tasks.get` for fetching task state,\n * `tasks.listLogs` for fetching structured log messages, and\n * `binaryInputs.create` for allocating presigned upload slots.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { LuauExecutionClient } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const client = new LuauExecutionClient({ apiKey: \"your-key\" });\n * expect(client).toBeInstanceOf(LuauExecutionClient);\n * ```\n */\nexport class LuauExecutionClient {\n\treadonly #inner: ResourceClient;\n\n\tpublic readonly binaryInputs: BinaryInputsHandle;\n\tpublic readonly tasks: TasksHandle;\n\n\t/**\n\t * Creates a new {@link LuauExecutionClient}. Configuration is frozen\n\t * on construction; per-request overrides are accepted on each\n\t * method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.binaryInputs = createBinaryInputsHandle(this.#inner);\n\t\tthis.tasks = createTasksHandle(this.#inner);\n\t}\n}\n\nfunction createBinaryInputsHandle(inner: ResourceClient): BinaryInputsHandle {\n\treturn {\n\t\tasync create(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: CREATE_BINARY_INPUT_SPEC });\n\t\t},\n\t};\n}\n\nfunction createTasksHandle(inner: ResourceClient): TasksHandle {\n\treturn {\n\t\tasync get(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: GET_SPEC });\n\t\t},\n\t\tasync listLogs(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: LIST_LOGS_SPEC });\n\t\t},\n\t\tasync pollUntilDone(ref, options = {}) {\n\t\t\tconst resolved = withBudgetRequestTimeout(options);\n\t\t\treturn pollUntilDoneCoreAsync(\n\t\t\t\tbuildPollDependencies(inner, { options: resolved, ref }),\n\t\t\t\tresolved,\n\t\t\t);\n\t\t},\n\t\tasync runUntilDone(parameters, options = {}) {\n\t\t\treturn submitAndPollAsync(inner, {\n\t\t\t\toptions: withBudgetRequestTimeout(options),\n\t\t\t\tparameters,\n\t\t\t});\n\t\t},\n\t\tasync submit(parameters, options) {\n\t\t\tif (\"versionId\" in parameters) {\n\t\t\t\treturn inner.executeAsync({ options, parameters, spec: SUBMIT_VERSION_SPEC });\n\t\t\t}\n\n\t\t\treturn inner.executeAsync({ options, parameters, spec: SUBMIT_HEAD_SPEC });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,8BAA8B,EAC7C,MACA,cAC4C;CAC5C,OAAO;EACN,MAAM,EAAE,KAAK;EACb,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,QAAQ;EACR,KAAK,uBAAuB,WAAW;CACxC;AACD;;;ACpBA,MAAM,oBAAoB;;;;;;;;;AAW1B,MAAa,yBAAyC,OAAO,OAAO;CACnE,eAAe;CACf,cAAc,oBAAoB;CAClC,cAAc;AACf,CAAC;;;;;;AAOD,MAAa,yBAAgD,OAAO,OAAO,CAC1E,6CACD,CAAC;;;ACnBD,MAAM,eAAe;AAErB,MAAM,oBAAoB;;;;;;;;;;AAW1B,SAAgB,yBAAyB,EACxC,MACA,QAAQ,cACwD;CAChE,IAAI,CAAC,SAAS,IAAI,GACjB,OAAO,UAAU,YAAY,IAAI;CAGlC,IAAI,OAAO,KAAK,YAAY,YAAY,CAAC,aAAa,KAAK,KAAK,OAAO,GACtE,OAAO,UAAU,YAAY,IAAI;CAGlC,IAAI,OAAO,KAAK,iBAAiB,UAChC,OAAO,UAAU,YAAY,IAAI;CAGlC,OAAO;EACN,MAAM;GAAE,MAAM,KAAK;GAAS,WAAW,KAAK;EAAa;EACzD,SAAS;CACV;AACD;AAEA,SAAS,UACR,YACA,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C,IAAI,eAAe,YAClB,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAAoB,CAAC;GAG7E,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAAiB,CAAC;EAC1E;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"luau-execution.mjs","names":["#inner"],"sources":["../src/domains/cloud-v2/luau-execution-task-binary-inputs/builders.ts","../src/domains/cloud-v2/luau-execution-task-binary-inputs/operations.ts","../src/domains/cloud-v2/luau-execution-task-binary-inputs/parsers.ts","../src/resources/luau-execution/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../client/types.ts\";\nimport type { CreateBinaryInputParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the Open Cloud\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` endpoint. The\n * server responds with a presigned `uploadUri` and the resource `path`.\n *\n * @param parameters - Universe identifier and the byte size of the\n * binary to be uploaded.\n * @returns A pure {@link HttpRequest} describing the create call.\n */\nexport function buildCreateBinaryInputRequest({\n\tsize,\n\tuniverseId,\n}: CreateBinaryInputParameters): HttpRequest {\n\treturn {\n\t\tbody: { size },\n\t\theaders: { \"content-type\": \"application/json\" },\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/luau-execution-session-task-binary-inputs`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst CREATE_PER_MINUTE = 5;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for creating a Luau execution task binary\n * input, sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` operation (5 requests\n * per minute per API key owner). The whole per-minute allowance is also\n * the burst, matching the server: a probe found the sixth create within\n * one minute is the first to draw a 429.\n */\nexport const CREATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: CREATE_PER_MINUTE,\n\tmaxPerSecond: CREATE_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-task-binary-inputs.create\",\n});\n\n/**\n * Scopes required to create a Luau execution task binary input, sourced\n * from `x-roblox-scopes` on the create operation in the vendored OpenAPI\n * schema.\n */\nexport const CREATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { LuauExecutionTaskBinaryInput } from \"./types.ts\";\n\nconst PATH_PATTERN = /^universes\\/(\\d+)\\/luau-execution-session-task-binary-inputs\\/([^/]+)$/;\n\nconst MALFORMED_MESSAGE = \"Malformed luau-execution-session-task-binary-input response\";\n\n/**\n * Parses a successful Open Cloud\n * `Cloud_CreateLuauExecutionSessionTaskBinaryInput` response body into\n * the public {@link LuauExecutionTaskBinaryInput}.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed binary input, or an\n * {@link ApiError} when the body does not match the expected shape.\n */\nexport function parseBinaryInputResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LuauExecutionTaskBinaryInput, ApiError> {\n\tif (!isRecord(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tif (typeof body[\"path\"] !== \"string\" || !PATH_PATTERN.test(body[\"path\"])) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tif (typeof body[\"uploadUri\"] !== \"string\") {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: { path: body[\"path\"], uploadUri: body[\"uploadUri\"] },\n\t\tsuccess: true,\n\t};\n}\n\nfunction malformed(\n\tstatusCode: number,\n\tbody: unknown,\n): Result<LuauExecutionTaskBinaryInput, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { buildCreateBinaryInputRequest } from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tCREATE_REQUIRED_SCOPES,\n} from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/operations.ts\";\nimport { parseBinaryInputResponse } from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/parsers.ts\";\nimport type {\n\tCreateBinaryInputParameters,\n\tLuauExecutionTaskBinaryInput,\n} from \"../../domains/cloud-v2/luau-execution-task-binary-inputs/types.ts\";\nimport { LIST_LOGS_SPEC } from \"../../domains/cloud-v2/luau-execution-task-logs/specs.ts\";\nimport type {\n\tListLogsParameters,\n\tLogPage,\n} from \"../../domains/cloud-v2/luau-execution-task-logs/types.ts\";\nimport { GET_SPEC } from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tGetParameters,\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 { CREATE_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport {\n\tokRequest,\n\tResourceClient,\n\ttype ResourceMethodSpec,\n} from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport {\n\ttype LuauExecutionRunOptions,\n\ttype LuauExecutionSubmitOptions,\n\tsubmitWithCapacityAsync,\n} from \"./capacity-admission.ts\";\nimport { buildPollDependencies, submitAndPollAsync } from \"./polling-helpers.ts\";\nimport {\n\tpollUntilDoneCoreAsync,\n\ttype PollUntilDoneOptions,\n\twithBudgetRequestTimeout,\n} from \"./polling.ts\";\n\nfunction makeSpec<P, R>(spec: ResourceMethodSpec<P, R>): ResourceMethodSpec<P, R> {\n\treturn Object.freeze(spec);\n}\n\nconst CREATE_BINARY_INPUT_SPEC = makeSpec<\n\tCreateBinaryInputParameters,\n\tLuauExecutionTaskBinaryInput\n>({\n\tbuildRequest: (parameters) => okRequest(buildCreateBinaryInputRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: CREATE_OPERATION_LIMIT,\n\tparse: parseBinaryInputResponse,\n\trequiredScopes: CREATE_REQUIRED_SCOPES,\n});\n\n/**\n * Operation handle for the `binaryInputs` namespace on\n * {@link LuauExecutionClient}. Provides `create` to allocate a presigned\n * upload slot for binary script inputs.\n *\n * @since 0.1.0\n */\nexport interface BinaryInputsHandle {\n\t/**\n\t * Allocates a presigned binary input upload slot. The returned\n\t * `uploadUri` is a presigned `PUT` target; the caller uploads the\n\t * binary data directly and passes `path` to `tasks.submit` as\n\t * `binaryInput`.\n\t *\n\t * @param parameters - Universe identifier and the byte size of the\n\t * binary to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTaskBinaryInput} or the {@link OpenCloudError}\n\t * that caused the request to fail.\n\t */\n\tcreate(\n\t\tparameters: CreateBinaryInputParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTaskBinaryInput, OpenCloudError>>;\n}\n\n/**\n * Operation handle exposed by {@link LuauExecutionClient} as the\n * `tasks` namespace. Provides `submit` to queue a Luau script, `get`\n * to fetch a task's current state, and `listLogs` to retrieve\n * structured log messages produced by a task.\n *\n * @since 0.1.0\n */\nexport interface TasksHandle {\n\t/**\n\t * Fetches the current state of a previously-submitted Luau\n\t * execution task. Uses idempotent retry semantics for both 429 and\n\t * 5xx.\n\t *\n\t * @param parameters - The task ref plus an optional `view` selector.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tget(\n\t\tparameters: GetParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Lists one page of structured log messages produced by a\n\t * previously-submitted Luau execution task. Messages from multiple\n\t * server-side chunks are flattened into a single ordered array.\n\t * Uses idempotent retry semantics for both 429 and 5xx.\n\t *\n\t * @param parameters - The task ref and optional pagination controls\n\t * (`pageSize`, `pageToken`).\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link LogPage} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tlistLogs(\n\t\tparameters: ListLogsParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LogPage, OpenCloudError>>;\n\t/**\n\t * Polls `tasks.get` with `view=BASIC` on a configurable backoff schedule\n\t * until the task reaches a terminal state, the wall-clock budget is\n\t * exhausted, or the supplied `AbortSignal` fires. Returns the terminal\n\t * task on success.\n\t *\n\t * @param ref - Reference to the task to poll, typically returned by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask},\n\t * or an error if aborted, timed out, or the transport fails.\n\t */\n\tpollUntilDone(\n\t\tref: LuauExecutionTaskRef,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script and polls `tasks.get` with `view=BASIC` until\n\t * the task reaches a terminal state, the wall-clock budget is\n\t * exhausted, or the supplied `AbortSignal` fires. Combines `submit`\n\t * and `pollUntilDone` in one call.\n\t *\n\t * @param parameters - The same input accepted by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal\n\t * {@link LuauExecutionTask}, or an error if submit fails, the task\n\t * is aborted, timed out, or the transport fails.\n\t */\n\trunUntilDone(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: LuauExecutionRunOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script for execution against a place. Dispatches\n\t * to the head-version URL when `versionId` is omitted, or to the\n\t * specific-version URL when one is supplied. Both URL shapes share\n\t * one rate-limit queue and one required-scope set.\n\t *\n\t * @param parameters - The universe and place identifiers, the\n\t * script to run, an optional `versionId`, and any other writable\n\t * submit fields.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tsubmit(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: LuauExecutionSubmitOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n}\n\n/**\n * Public client for the Roblox Open Cloud `LuauExecutionSessionTask`\n * resource. Tasks run a Luau script against a place and surface state,\n * output, or error through the `LuauExecutionTask` discriminated\n * union. Exposes `tasks.submit` for both the head version and a\n * specific place version, `tasks.get` for fetching task state,\n * `tasks.listLogs` for fetching structured log messages, and\n * `binaryInputs.create` for allocating presigned upload slots.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { LuauExecutionClient } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const client = new LuauExecutionClient({ apiKey: \"your-key\" });\n * expect(client).toBeInstanceOf(LuauExecutionClient);\n * ```\n */\nexport class LuauExecutionClient {\n\treadonly #inner: ResourceClient;\n\n\tpublic readonly binaryInputs: BinaryInputsHandle;\n\tpublic readonly tasks: TasksHandle;\n\n\t/**\n\t * Creates a new {@link LuauExecutionClient}. Configuration is frozen\n\t * on construction; per-request overrides are accepted on each\n\t * method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.binaryInputs = createBinaryInputsHandle(this.#inner);\n\t\tthis.tasks = createTasksHandle(this.#inner);\n\t}\n}\n\nfunction createBinaryInputsHandle(inner: ResourceClient): BinaryInputsHandle {\n\treturn {\n\t\tasync create(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: CREATE_BINARY_INPUT_SPEC });\n\t\t},\n\t};\n}\n\nfunction createTasksHandle(inner: ResourceClient): TasksHandle {\n\treturn {\n\t\tasync get(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: GET_SPEC });\n\t\t},\n\t\tasync listLogs(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: LIST_LOGS_SPEC });\n\t\t},\n\t\tasync pollUntilDone(ref, options = {}) {\n\t\t\tconst resolved = withBudgetRequestTimeout(options);\n\t\t\treturn pollUntilDoneCoreAsync(\n\t\t\t\tbuildPollDependencies(inner, { options: resolved, ref }),\n\t\t\t\tresolved,\n\t\t\t);\n\t\t},\n\t\tasync runUntilDone(parameters, options = {}) {\n\t\t\treturn submitAndPollAsync(inner, {\n\t\t\t\toptions: withBudgetRequestTimeout(options),\n\t\t\t\tparameters,\n\t\t\t});\n\t\t},\n\t\tasync submit(parameters, options) {\n\t\t\treturn submitWithCapacityAsync({ inner, options, parameters });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,8BAA8B,EAC7C,MACA,cAC4C;CAC5C,OAAO;EACN,MAAM,EAAE,KAAK;EACb,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,QAAQ;EACR,KAAK,uBAAuB,WAAW;CACxC;AACD;;;ACpBA,MAAM,oBAAoB;;;;;;;;;AAW1B,MAAa,yBAAyC,OAAO,OAAO;CACnE,eAAe;CACf,cAAc,oBAAoB;CAClC,cAAc;AACf,CAAC;;;;;;AAOD,MAAa,yBAAgD,OAAO,OAAO,CAC1E,6CAC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;IAAE;IAAS;IAAY,MAAM;GAAS,CAAC;EAClE;EACA,MAAM,SAAS,YAAY,SAAS;GACnC,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAAe,CAAC;EACxE;EACA,MAAM,cAAc,KAAK,UAAU,CAAC,GAAG;GACtC,MAAM,WAAW,yBAAyB,OAAO;GACjD,OAAO,uBACN,sBAAsB,OAAO;IAAE,SAAS;IAAU;GAAI,CAAC,GACvD,QACD;EACD;EACA,MAAM,aAAa,YAAY,UAAU,CAAC,GAAG;GAC5C,OAAO,mBAAmB,OAAO;IAChC,SAAS,yBAAyB,OAAO;IACzC;GACD,CAAC;EACF;EACA,MAAM,OAAO,YAAY,SAAS;GACjC,OAAO,wBAAwB;IAAE;IAAO;IAAS;GAAW,CAAC;EAC9D;CACD;AACD"}
|
|
@@ -146,38 +146,13 @@ function requestContextOf(err) {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
//#endregion
|
|
149
|
-
//#region src/errors/network-error.ts
|
|
150
|
-
/**
|
|
151
|
-
* Thrown when a network-level failure prevents the request from reaching
|
|
152
|
-
* the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).
|
|
153
|
-
* The `method` and `url` name the failing call so a transport failure that
|
|
154
|
-
* survives every retry can be diagnosed; the underlying transport error is
|
|
155
|
-
* carried on `cause`.
|
|
156
|
-
*
|
|
157
|
-
* @since 0.1.0
|
|
158
|
-
*/
|
|
159
|
-
var NetworkError = class extends OpenCloudError {
|
|
160
|
-
method;
|
|
161
|
-
name = "NetworkError";
|
|
162
|
-
url;
|
|
163
|
-
/**
|
|
164
|
-
* Creates a new NetworkError.
|
|
165
|
-
*
|
|
166
|
-
* @param message - Human-readable error description.
|
|
167
|
-
* @param options - Error options including the optional `cause` and the
|
|
168
|
-
* `method` / `url` of the request that failed.
|
|
169
|
-
*/
|
|
170
|
-
constructor(message, options) {
|
|
171
|
-
super(message, options);
|
|
172
|
-
this.method = options?.method;
|
|
173
|
-
this.url = options?.url;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
//#endregion
|
|
177
149
|
//#region src/errors/rate-limit.ts
|
|
178
150
|
/**
|
|
179
151
|
* Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests
|
|
180
|
-
* response. Contains the server-suggested retry delay
|
|
152
|
+
* response. Contains the server-suggested retry delay and safe,
|
|
153
|
+
* machine-readable response evidence. Generic 429 evidence can be ambiguous:
|
|
154
|
+
* no individual header, body code, or remaining-budget value guarantees the
|
|
155
|
+
* upstream cause.
|
|
181
156
|
*
|
|
182
157
|
* @since 0.1.0
|
|
183
158
|
*
|
|
@@ -187,21 +162,42 @@ var NetworkError = class extends OpenCloudError {
|
|
|
187
162
|
* import { RateLimitError } from "@bedrock-rbx/ocale";
|
|
188
163
|
*
|
|
189
164
|
* const error = new RateLimitError("Too many requests", {
|
|
190
|
-
*
|
|
165
|
+
* code: "RESOURCE_EXHAUSTED",
|
|
166
|
+
* remaining: 3,
|
|
167
|
+
* responseHeaders: {
|
|
168
|
+
* "retry-after": "1856",
|
|
169
|
+
* "x-ratelimit-limit": "5, 5;w=60, 5;w=60",
|
|
170
|
+
* },
|
|
171
|
+
* retryAfterSeconds: 1856,
|
|
191
172
|
* });
|
|
192
173
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
174
|
+
* // Inspect the available evidence without assuming it identifies the cause.
|
|
175
|
+
* const evidence = {
|
|
176
|
+
* code: error.code,
|
|
177
|
+
* limit: error.responseHeaders?.["x-ratelimit-limit"],
|
|
178
|
+
* retryAfter: error.responseHeaders?.["retry-after"],
|
|
179
|
+
* };
|
|
180
|
+
*
|
|
181
|
+
* expect(evidence).toEqual({
|
|
182
|
+
* code: "RESOURCE_EXHAUSTED",
|
|
183
|
+
* limit: "5, 5;w=60, 5;w=60",
|
|
184
|
+
* retryAfter: "1856",
|
|
185
|
+
* });
|
|
195
186
|
* ```
|
|
196
187
|
*/
|
|
197
188
|
var RateLimitError = class extends OpenCloudError {
|
|
198
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Parsed 429 response body. A literal JSON `null` remains `null`; an absent
|
|
191
|
+
* body is `undefined`.
|
|
192
|
+
*/
|
|
199
193
|
details;
|
|
200
194
|
name = "RateLimitError";
|
|
201
195
|
/**
|
|
202
|
-
* Requests left in the
|
|
196
|
+
* Requests left in the reported window, or `undefined` if not reported.
|
|
203
197
|
*/
|
|
204
198
|
remaining;
|
|
199
|
+
/** Allowlisted raw response headers, or `undefined` if not set. */
|
|
200
|
+
responseHeaders;
|
|
205
201
|
retryAfterSeconds;
|
|
206
202
|
/** HTTP status code that produced the error, or `undefined` if not set. */
|
|
207
203
|
statusCode;
|
|
@@ -215,11 +211,60 @@ var RateLimitError = class extends OpenCloudError {
|
|
|
215
211
|
super(message, options);
|
|
216
212
|
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
217
213
|
this.remaining = options.remaining;
|
|
214
|
+
this.responseHeaders = options.responseHeaders;
|
|
218
215
|
this.details = options.details;
|
|
219
216
|
this.statusCode = options.statusCode;
|
|
220
217
|
}
|
|
221
218
|
};
|
|
219
|
+
const GUIDED_ERRORS = /* @__PURE__ */ new WeakSet();
|
|
220
|
+
/**
|
|
221
|
+
* Marks a transport-minted error whose zero-second delay is explicit guidance.
|
|
222
|
+
*
|
|
223
|
+
* @param error - The classified rate-limit failure.
|
|
224
|
+
* @returns The same error, marked for retry orchestration.
|
|
225
|
+
*/
|
|
226
|
+
function markServerRetryGuidance(error) {
|
|
227
|
+
GUIDED_ERRORS.add(error);
|
|
228
|
+
return error;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Checks whether an error carries applicable server retry guidance.
|
|
232
|
+
*
|
|
233
|
+
* @param error - The rate-limit failure to inspect.
|
|
234
|
+
* @returns Whether its delay should override caller backoff.
|
|
235
|
+
*/
|
|
236
|
+
function hasServerRetryGuidance(error) {
|
|
237
|
+
return error.retryAfterSeconds > 0 || GUIDED_ERRORS.has(error);
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/errors/network-error.ts
|
|
241
|
+
/**
|
|
242
|
+
* Thrown when a network-level failure prevents the request from reaching
|
|
243
|
+
* the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).
|
|
244
|
+
* The `method` and `url` name the failing call so a transport failure that
|
|
245
|
+
* survives every retry can be diagnosed; the underlying transport error is
|
|
246
|
+
* carried on `cause`.
|
|
247
|
+
*
|
|
248
|
+
* @since 0.1.0
|
|
249
|
+
*/
|
|
250
|
+
var NetworkError = class extends OpenCloudError {
|
|
251
|
+
method;
|
|
252
|
+
name = "NetworkError";
|
|
253
|
+
url;
|
|
254
|
+
/**
|
|
255
|
+
* Creates a new NetworkError.
|
|
256
|
+
*
|
|
257
|
+
* @param message - Human-readable error description.
|
|
258
|
+
* @param options - Error options including the optional `cause` and the
|
|
259
|
+
* `method` / `url` of the request that failed.
|
|
260
|
+
*/
|
|
261
|
+
constructor(message, options) {
|
|
262
|
+
super(message, options);
|
|
263
|
+
this.method = options?.method;
|
|
264
|
+
this.url = options?.url;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
222
267
|
//#endregion
|
|
223
|
-
export {
|
|
268
|
+
export { ApiError as a, markServerRetryGuidance as i, RateLimitError as n, requestContextOf as o, hasServerRetryGuidance as r, OpenCloudError as s, NetworkError as t };
|
|
224
269
|
|
|
225
|
-
//# sourceMappingURL=
|
|
270
|
+
//# sourceMappingURL=network-error-DR9FX5hb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-error-DR9FX5hb.mjs","names":[],"sources":["../src/errors/base.ts","../src/errors/api-error.ts","../src/errors/rate-limit.ts","../src/errors/network-error.ts"],"sourcesContent":["/**\n * Options for constructing an {@link OpenCloudError}.\n *\n * @since 0.3.0\n */\nexport interface OpenCloudErrorOptions extends ErrorOptions {\n\t/**\n\t * Machine-readable classifier for the failure, when the error has one. An\n\t * `ApiError` and `RateLimitError` fill it from the response body; a\n\t * `ValidationError` narrows it to its own closed union. Errors with nothing\n\t * to classify (transport failures and poll timeouts) leave it `undefined`.\n\t */\n\treadonly code?: string | undefined;\n}\n\n/**\n * Base error class for all Open Cloud SDK errors.\n *\n * All specific error types (RateLimitError, ApiError, NetworkError)\n * extend this class, enabling `instanceof OpenCloudError` checks.\n *\n * `code` is declared here rather than on the subclasses that populate it, so a\n * caller holding the `OpenCloudError` that `Result.err` is typed as can branch\n * on it without first narrowing to a subclass.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { ApiError, OpenCloudError } from \"@bedrock-rbx/ocale\";\n *\n * // `Result.err` is typed as OpenCloudError, so a caller draining a queue\n * // branches on the canonical status without narrowing to a subclass first.\n * const err: OpenCloudError = new ApiError(\"HTTP 404: Queue items not found.\", {\n * code: \"NOT_FOUND\",\n * statusCode: 404,\n * });\n *\n * expect(err.code).toBe(\"NOT_FOUND\");\n * expect(new OpenCloudError(\"no classifier\").code).toBeUndefined();\n * ```\n */\nexport class OpenCloudError extends Error {\n\t/** Machine-readable classifier, or `undefined` when the error has none. */\n\tpublic readonly code: string | undefined;\n\tpublic override readonly name: string = \"OpenCloudError\";\n\n\t/**\n\t * Creates a new OpenCloudError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the optional `cause` and the\n\t * machine-readable `code`.\n\t */\n\tconstructor(message?: string, options?: OpenCloudErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.code = options?.code;\n\t}\n}\n","import { OpenCloudError, type OpenCloudErrorOptions } from \"./base.ts\";\n\n/**\n * Options for constructing an {@link ApiError}.\n *\n * @since 0.1.0\n */\nexport interface ApiErrorOptions extends OpenCloudErrorOptions {\n\t/** Parsed response body, when present. */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Wall-clock time the request was in flight before this error, in\n\t * milliseconds. Present for errors built by the transport; a long elapsed\n\t * time on an intermittent failure points at a load or timeout correlation.\n\t */\n\telapsedMs?: number | undefined;\n\t/**\n\t * Human-readable summary extracted from an HTML gateway error page, set\n\t * when the error body was such a page (an HAProxy-style load-balancer\n\t * rejection) rather than an Open Cloud response. When present, the raw HTML\n\t * is not retained on {@link ApiError.details}.\n\t */\n\tgatewaySummary?: string | undefined;\n\t/** HTTP method of the request that produced this error. */\n\tmethod?: string | undefined;\n\t/**\n\t * Allowlisted response headers useful for diagnosis and escalation (request\n\t * ids, edge/server identifiers). The full header set is never retained, to\n\t * avoid surfacing anything sensitive and to keep errors light.\n\t */\n\tresponseHeaders?: Readonly<Record<string, string>> | undefined;\n\t/** HTTP status code from the API response. */\n\tstatusCode: number;\n\t/**\n\t * Length, in decoded characters, of a 2xx body that could not be parsed as\n\t * JSON. Set only by the transport, and only for that failure — nothing else\n\t * builds an {@link ApiError} over a successful status — so its presence is\n\t * also how a body-parse failure is told apart from an API rejection. The\n\t * number is the diagnostic one: a body that stops mid-token at exactly the\n\t * length the edge delivered is a truncated read, not malformed JSON.\n\t */\n\tunparsedBodyLength?: number | undefined;\n\t/** Fully-qualified URL of the request that produced this error. */\n\turl?: string | undefined;\n}\n\n/**\n * Everything in {@link ApiErrorOptions} except what the API answered ({@link\n * ApiErrorOptions.code}, {@link ApiErrorOptions.details}, and {@link\n * ApiErrorOptions.statusCode}): the request the transport made, how long it was\n * in flight, and what the response carried alongside its body. Every field is\n * required, and every one accepts `undefined` for a field the transport did not\n * capture.\n *\n * @since 0.2.0\n */\nexport type ApiRequestContext = {\n\t[K in Exclude<keyof ApiErrorOptions, \"cause\" | \"code\" | \"details\" | \"statusCode\">]-?:\n\t\t| ApiErrorOptions[K]\n\t\t| undefined;\n};\n\n/**\n * Thrown when the Roblox Open Cloud API returns a non-2xx response\n * that is not a rate limit (429).\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { ApiError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new ApiError(\"HTTP 404: Pass not found (code NotFound)\", {\n * code: \"NotFound\",\n * details: { errorCode: \"NotFound\", message: \"Pass not found\" },\n * statusCode: 404,\n * });\n *\n * expect(error).toBeInstanceOf(ApiError);\n * expect(error.statusCode).toBe(404);\n * expect(error.code).toBe(\"NotFound\");\n * expect(error.details).toEqual({\n * errorCode: \"NotFound\",\n * message: \"Pass not found\",\n * });\n * ```\n */\nexport class ApiError extends OpenCloudError {\n\tpublic readonly details: JSONValue | undefined;\n\tpublic readonly elapsedMs: number | undefined;\n\tpublic readonly gatewaySummary: string | undefined;\n\tpublic readonly method: string | undefined;\n\tpublic override readonly name: string = \"ApiError\";\n\tpublic readonly responseHeaders: Readonly<Record<string, string>> | undefined;\n\tpublic readonly statusCode: number;\n\tpublic readonly unparsedBodyLength: number | undefined;\n\tpublic readonly url: string | undefined;\n\n\t/**\n\t * Creates a new ApiError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including status code, optional error\n\t * code, the parsed response body when present, and the request context\n\t * (method, url, elapsed time, allowlisted response headers) when built by\n\t * the transport.\n\t */\n\tconstructor(message: string, options: ApiErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.statusCode = options.statusCode;\n\t\tthis.details = options.details;\n\t\tthis.method = options.method;\n\t\tthis.url = options.url;\n\t\tthis.elapsedMs = options.elapsedMs;\n\t\tthis.responseHeaders = options.responseHeaders;\n\t\tthis.gatewaySummary = options.gatewaySummary;\n\t\tthis.unparsedBodyLength = options.unparsedBodyLength;\n\t}\n}\n\n/**\n * Reads the request context off an {@link ApiError} so a replacement error can\n * carry it. Spread the result into the options of the new error. {@link\n * OpenCloudError.code}, {@link ApiError.details}, and {@link\n * ApiError.statusCode} describe the API's answer and are left to the caller.\n *\n * @since 0.2.0\n *\n * @param err - The error to read the request context from.\n * @returns The transport-captured fields, each undefined when unset.\n *\n * @example\n *\n * ```ts\n * import { ApiError, requestContextOf } from \"@bedrock-rbx/ocale\";\n *\n * const original = new ApiError(\"HTTP 404\", {\n * elapsedMs: 512,\n * method: \"GET\",\n * statusCode: 404,\n * url: \"https://apis.roblox.com/cloud/v2/universes/1\",\n * });\n *\n * const rewrapped = new ApiError(\"Universe 1 was not found; adoption failed\", {\n * ...requestContextOf(original),\n * statusCode: 404,\n * });\n *\n * expect(rewrapped.method).toBe(\"GET\");\n * expect(rewrapped.url).toBe(\"https://apis.roblox.com/cloud/v2/universes/1\");\n * expect(rewrapped.elapsedMs).toBe(512);\n * ```\n */\nexport function requestContextOf(err: ApiError): ApiRequestContext {\n\treturn {\n\t\telapsedMs: err.elapsedMs,\n\t\tgatewaySummary: err.gatewaySummary,\n\t\tmethod: err.method,\n\t\tresponseHeaders: err.responseHeaders,\n\t\tunparsedBodyLength: err.unparsedBodyLength,\n\t\turl: err.url,\n\t};\n}\n","import { OpenCloudError, type OpenCloudErrorOptions } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RateLimitError}.\n *\n * @since 0.1.0\n */\nexport interface RateLimitErrorOptions extends OpenCloudErrorOptions {\n\t/**\n\t * Parsed 429 response body, when present. Holds the server's 429\n\t * explanation (JSON when the body parses, otherwise the truncated raw\n\t * text) so a rate limit stays diagnosable from the error alone. A literal\n\t * JSON `null` remains `null`; an absent body is `undefined`.\n\t */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Requests left in the reported rate-limit window. Read from\n\t * `x-ratelimit-remaining` using the smallest valid token.\n\t *\n\t * `undefined` when the header has no valid non-negative integer token.\n\t *\n\t * Parsed separately from `x-ratelimit-reset`; a valid value survives an\n\t * invalid reset.\n\t *\n\t * This is one budget reading, not a classifier for the cause of the 429.\n\t */\n\tremaining?: number | undefined;\n\t/**\n\t * Allowlisted response headers useful for diagnosing the 429. Values are\n\t * preserved exactly as the Fetch API presents them, including comma-joined\n\t * multi-window values. The full header set is never retained.\n\t */\n\tresponseHeaders?: Readonly<Record<string, string>> | undefined;\n\t/** Seconds to wait before retrying the request. */\n\tretryAfterSeconds: number;\n\t/**\n\t * HTTP status code that produced the error. Always `429` when minted by the\n\t * SDK transport; `undefined` when constructed without one.\n\t */\n\tstatusCode?: number | undefined;\n}\n\n/**\n * Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests\n * response. Contains the server-suggested retry delay and safe,\n * machine-readable response evidence. Generic 429 evidence can be ambiguous:\n * no individual header, body code, or remaining-budget value guarantees the\n * upstream cause.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { RateLimitError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new RateLimitError(\"Too many requests\", {\n * code: \"RESOURCE_EXHAUSTED\",\n * remaining: 3,\n * responseHeaders: {\n * \"retry-after\": \"1856\",\n * \"x-ratelimit-limit\": \"5, 5;w=60, 5;w=60\",\n * },\n * retryAfterSeconds: 1856,\n * });\n *\n * // Inspect the available evidence without assuming it identifies the cause.\n * const evidence = {\n * code: error.code,\n * limit: error.responseHeaders?.[\"x-ratelimit-limit\"],\n * retryAfter: error.responseHeaders?.[\"retry-after\"],\n * };\n *\n * expect(evidence).toEqual({\n * code: \"RESOURCE_EXHAUSTED\",\n * limit: \"5, 5;w=60, 5;w=60\",\n * retryAfter: \"1856\",\n * });\n * ```\n */\nexport class RateLimitError extends OpenCloudError {\n\t/**\n\t * Parsed 429 response body. A literal JSON `null` remains `null`; an absent\n\t * body is `undefined`.\n\t */\n\tpublic readonly details: JSONValue | undefined;\n\tpublic override readonly name = \"RateLimitError\";\n\t/**\n\t * Requests left in the reported window, or `undefined` if not reported.\n\t */\n\tpublic readonly remaining: number | undefined;\n\t/** Allowlisted raw response headers, or `undefined` if not set. */\n\tpublic readonly responseHeaders: Readonly<Record<string, string>> | undefined;\n\tpublic readonly retryAfterSeconds: number;\n\t/** HTTP status code that produced the error, or `undefined` if not set. */\n\tpublic readonly statusCode: number | undefined;\n\n\t/**\n\t * Creates a new RateLimitError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the retry delay.\n\t */\n\tconstructor(message: string, options: RateLimitErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.retryAfterSeconds = options.retryAfterSeconds;\n\t\tthis.remaining = options.remaining;\n\t\tthis.responseHeaders = options.responseHeaders;\n\t\tthis.details = options.details;\n\t\tthis.statusCode = options.statusCode;\n\t}\n}\n\nconst GUIDED_ERRORS = new WeakSet<RateLimitError>();\n\n/**\n * Marks a transport-minted error whose zero-second delay is explicit guidance.\n *\n * @param error - The classified rate-limit failure.\n * @returns The same error, marked for retry orchestration.\n */\nexport function markServerRetryGuidance(error: RateLimitError): RateLimitError {\n\tGUIDED_ERRORS.add(error);\n\treturn error;\n}\n\n/**\n * Checks whether an error carries applicable server retry guidance.\n *\n * @param error - The rate-limit failure to inspect.\n * @returns Whether its delay should override caller backoff.\n */\nexport function hasServerRetryGuidance(error: RateLimitError): boolean {\n\treturn error.retryAfterSeconds > 0 || GUIDED_ERRORS.has(error);\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link NetworkError}.\n *\n * @since 0.1.0\n */\nexport interface NetworkErrorOptions extends ErrorOptions {\n\t/** HTTP method of the request that failed. */\n\tmethod?: string | undefined;\n\t/** Fully-qualified URL of the request that failed. */\n\turl?: string | undefined;\n}\n\n/**\n * Thrown when a network-level failure prevents the request from reaching\n * the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).\n * The `method` and `url` name the failing call so a transport failure that\n * survives every retry can be diagnosed; the underlying transport error is\n * carried on `cause`.\n *\n * @since 0.1.0\n */\nexport class NetworkError extends OpenCloudError {\n\tpublic readonly method: string | undefined;\n\tpublic override readonly name: string = \"NetworkError\";\n\tpublic readonly url: string | undefined;\n\n\t/**\n\t * Creates a new NetworkError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the optional `cause` and the\n\t * `method` / `url` of the request that failed.\n\t */\n\tconstructor(message: string, options?: NetworkErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.method = options?.method;\n\t\tthis.url = options?.url;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,iBAAb,cAAoC,MAAM;;CAEzC;CACA,OAAwC;;;;;;;;CASxC,YAAY,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;;;;;;;;;;;AC/GA,IAAa,eAAb,cAAkC,eAAe;CAChD;CACA,OAAwC;CACxC;;;;;;;;CASA,YAAY,SAAiB,SAA+B;EAC3D,MAAM,SAAS,OAAO;EACtB,KAAK,SAAS,SAAS;EACvB,KAAK,MAAM,SAAS;CACrB;AACD"}
|
package/dist/places.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { f as Result, m as OpenCloudError, s as OpenCloudClientOptions, u as RequestOptions } from "./types-C3Egi37J.mjs";
|
|
2
|
+
import { a as ListLogsParameters, f as LuauExecutionTask, h as SubmitAtVersionParameters, m as SubmitAtHeadParameters, n as LuauExecutionSubmitOptions, o as LogMessage, p as LuauExecutionTaskRef, r as PollUntilDoneOptions, s as LogPage, t as LuauExecutionRunOptions, u as GetParameters } from "./capacity-admission-BvnJjY0S.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/cloud-v2/places/types.d.ts
|
|
5
5
|
/**
|
|
@@ -150,7 +150,7 @@ interface LuauExecutionHandle {
|
|
|
150
150
|
* {@link LuauExecutionTask}, or an error if submit fails, the task
|
|
151
151
|
* is aborted, timed out, or the transport fails.
|
|
152
152
|
*/
|
|
153
|
-
runUntilDone(parameters: SubmitAtHeadParameters | SubmitAtVersionParameters, options?:
|
|
153
|
+
runUntilDone(parameters: SubmitAtHeadParameters | SubmitAtVersionParameters, options?: LuauExecutionRunOptions): Promise<Result<LuauExecutionTask, OpenCloudError>>;
|
|
154
154
|
/**
|
|
155
155
|
* Submits a Luau script for execution against a place. Dispatches
|
|
156
156
|
* to the head-version URL when `versionId` is omitted, or to the
|
|
@@ -166,7 +166,7 @@ interface LuauExecutionHandle {
|
|
|
166
166
|
* {@link LuauExecutionTask} or the {@link OpenCloudError} that
|
|
167
167
|
* caused the request to fail.
|
|
168
168
|
*/
|
|
169
|
-
submit(parameters: SubmitAtHeadParameters | SubmitAtVersionParameters, options?:
|
|
169
|
+
submit(parameters: SubmitAtHeadParameters | SubmitAtVersionParameters, options?: LuauExecutionSubmitOptions): Promise<Result<LuauExecutionTask, OpenCloudError>>;
|
|
170
170
|
}
|
|
171
171
|
/**
|
|
172
172
|
* Public client for the Roblox Open Cloud `Place` resource. Covers
|
package/dist/places.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.d.mts","names":[],"sources":["../src/domains/cloud-v2/places/types.ts","../src/domains/universes/places/types.ts","../src/resources/places/client.ts"],"mappings":";;;;;;;;AAQA;;;;UAAiB,qBAAA;;WAEP,WAAA;;WAEA,WAAA;EAMA;EAAA,SAJA,OAAA;EAaV;EAAA,SAXU,UAAA;;WAEA,UAAA;AAAA;;;;;;;UASO,KAAA;;WAEP,EAAA;;WAEA,SAAA,EAAW,IAAA;EAcA;EAAA,SAZX,WAAA;;WAEA,WAAA;EC3BV;EAAA,SD6BU,IAAA;;WAEA,UAAA;;WAEA,UAAA;;WAEA,uBAAA;;WAEA,SAAA,EAAW,IAAA;AAAA;;;;;;;AArCrB;;;;UCAiB,iBAAA;;WAEP,IAAA,EAAM,UAAA,CAAW,WAAA;;;;ADQjB;AASV;;WCVU,MAAA;ED4BW;EAAA,SC1BX,OAAA;;WAEA,UAAA;AAAA;;;;;;UAQO,YAAA;;;ADgBI;;;WCVX,aAAA;AAAA
|
|
1
|
+
{"version":3,"file":"places.d.mts","names":[],"sources":["../src/domains/cloud-v2/places/types.ts","../src/domains/universes/places/types.ts","../src/resources/places/client.ts"],"mappings":";;;;;;;;AAQA;;;;UAAiB,qBAAA;;WAEP,WAAA;;WAEA,WAAA;EAMA;EAAA,SAJA,OAAA;EAaV;EAAA,SAXU,UAAA;;WAEA,UAAA;AAAA;;;;;;;UASO,KAAA;;WAEP,EAAA;;WAEA,SAAA,EAAW,IAAA;EAcA;EAAA,SAZX,WAAA;;WAEA,WAAA;EC3BV;EAAA,SD6BU,IAAA;;WAEA,UAAA;;WAEA,UAAA;;WAEA,uBAA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;;;;;;;;;;;;;;;;;;EAqBhC,IAAA,CACC,UAAA,EAAY,iBAAA,EACZ,OAAA,GAAU,cAAA,GACR,OAAA,CAAQ,MAAA,CAAO,YAAA,EAAc,cAAA;;;;;;;;;;;;;;;;EAmBhC,MAAA,CACC,UAAA,EAAY,qBAAA,EACZ,OAAA,GAAU,cAAA,GACR,OAAA,CAAQ,MAAA,CAAO,KAAA,EAAO,cAAA;AAAA"}
|
package/dist/places.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as UPLOAD_METHOD_DEFAULTS } from "./retry-
|
|
3
|
-
import { t as ValidationError } from "./validation-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { a as ApiError } from "./network-error-DR9FX5hb.mjs";
|
|
2
|
+
import { o as UPLOAD_METHOD_DEFAULTS } from "./retry-Cc4LcXYZ.mjs";
|
|
3
|
+
import { t as ValidationError } from "./validation-B_Zs1So2.mjs";
|
|
4
|
+
import { c as isDateTimeString, o as toJsonDetails, s as isRecord, t as ResourceClient } from "./resource-client--yYybltk.mjs";
|
|
5
|
+
import { a as pollUntilDoneCoreAsync, c as LIST_LOGS_SPEC, n as submitAndPollAsync, r as submitWithCapacityAsync, s as GET_SPEC, t as buildPollDependencies } from "./polling-helpers-CFuSt2O5.mjs";
|
|
6
6
|
import { n as RBXL_SIGNATURE, r as matchesSignature, t as RBXLX_SIGNATURE } from "./signatures-JF-7Psce.mjs";
|
|
7
7
|
//#region src/domains/cloud-v2/places/builders.ts
|
|
8
8
|
const NON_UPDATABLE_KEYS = new Set(["placeId", "universeId"]);
|
|
@@ -408,15 +408,10 @@ function createLuauExecutionHandle(inner) {
|
|
|
408
408
|
});
|
|
409
409
|
},
|
|
410
410
|
async submit(parameters, options) {
|
|
411
|
-
|
|
411
|
+
return submitWithCapacityAsync({
|
|
412
|
+
inner,
|
|
412
413
|
options,
|
|
413
|
-
parameters
|
|
414
|
-
spec: SUBMIT_VERSION_SPEC
|
|
415
|
-
});
|
|
416
|
-
return inner.executeAsync({
|
|
417
|
-
options,
|
|
418
|
-
parameters,
|
|
419
|
-
spec: SUBMIT_HEAD_SPEC
|
|
414
|
+
parameters
|
|
420
415
|
});
|
|
421
416
|
}
|
|
422
417
|
};
|
package/dist/places.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.mjs","names":["SECONDS_PER_MINUTE","#inner"],"sources":["../src/domains/cloud-v2/places/builders.ts","../src/domains/cloud-v2/places/operations.ts","../src/domains/cloud-v2/places/parsers.ts","../src/domains/universes/places/builders.ts","../src/domains/universes/places/operations.ts","../src/domains/universes/places/parsers.ts","../src/resources/places/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { UpdatePlaceParameters } from \"./types.ts\";\n\nconst NON_UPDATABLE_KEYS: ReadonlySet<string> = new Set([\"placeId\", \"universeId\"]);\n\n/**\n * Builds a `PATCH` request for the Open Cloud \"update place\" endpoint.\n * Derives the `updateMask` query string from the keys present on\n * `parameters` (excluding the identifiers) and emits a JSON body\n * containing those same fields.\n *\n * @param parameters - The universe and place identifiers plus the fields\n * to update.\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when no updatable fields were supplied.\n */\nexport function buildUpdateRequest(\n\tparameters: UpdatePlaceParameters,\n): Result<HttpRequest, ValidationError> {\n\tconst fieldKeys = extractUpdateFieldKeys(parameters);\n\n\tif (fieldKeys.length === 0) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Update must include at least one field\", {\n\t\t\t\tcode: \"empty_update\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst body = Object.fromEntries(\n\t\tfieldKeys.map((key): readonly [string, unknown] => [key, Reflect.get(parameters, key)]),\n\t);\n\tconst updateMask = fieldKeys.join(\",\");\n\tconst { placeId, universeId } = parameters;\n\treturn {\n\t\tdata: {\n\t\t\tbody,\n\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t\tmethod: \"PATCH\",\n\t\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}?updateMask=${updateMask}`,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction extractUpdateFieldKeys(parameters: UpdatePlaceParameters): ReadonlyArray<string> {\n\treturn Object.keys(parameters).filter((key) => !NON_UPDATABLE_KEYS.has(key));\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst UPDATE_PER_MINUTE = 100;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for updating a place, from the Open Cloud\n * OpenAPI schema (100 requests per minute per API key owner). Keyed\n * independently from the publish operation so publish and update do\n * not share a queue; upstream quota accounting is not documented as\n * shared and the conservative default is fewer cross-method\n * contention surprises.\n */\nexport const UPDATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: UPDATE_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"places.update\",\n});\n\n/**\n * Scopes required to update a place's metadata, sourced from\n * `x-roblox-scopes` on the `Cloud_UpdatePlace` operation in the vendored\n * OpenAPI schema.\n */\nexport const UPDATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { Place } from \"./types.ts\";\nimport type { PlaceWire } from \"./wire.ts\";\n\nconst MALFORMED_PLACE_MESSAGE = \"Malformed place response\";\n\nconst PLACE_PATH_PATTERN = /^universes\\/(\\d+)\\/places\\/(\\d+)$/;\n\ninterface ToPlaceArgs {\n\treadonly id: string;\n\treadonly body: PlaceWire;\n\treadonly universeId: string;\n}\n\n/**\n * Parses a successful Open Cloud `Place` response body into the public\n * {@link Place} shape.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link Place}, or an\n * {@link ApiError} when the body does not match the wire schema.\n */\nexport function parsePlaceResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<Place, ApiError> {\n\tif (!isPlaceWire(body)) {\n\t\treturn malformedPlace(statusCode, body);\n\t}\n\n\tconst match = PLACE_PATH_PATTERN.exec(body.path);\n\tconst universeId = match?.[1];\n\tconst id = match?.[2];\n\tif (id === undefined || universeId === undefined) {\n\t\treturn malformedPlace(statusCode, body);\n\t}\n\n\treturn { data: toPlace({ id, body, universeId }), success: true };\n}\n\nfunction malformedPlace(statusCode: number, body: unknown): Result<Place, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_PLACE_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n\nfunction toPlace({ id, body, universeId }: ToPlaceArgs): Place {\n\treturn {\n\t\tid,\n\t\tcreatedAt: new Date(body.createTime),\n\t\tdescription: body.description,\n\t\tdisplayName: body.displayName,\n\t\troot: body.root ?? false,\n\t\tserverSize: body.serverSize ?? undefined,\n\t\tuniverseId,\n\t\tuniverseRuntimeCreation: body.universeRuntimeCreation ?? false,\n\t\tupdatedAt: new Date(body.updateTime),\n\t};\n}\n\nfunction hasValidPlaceRequired(body: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof body[\"path\"] === \"string\" &&\n\t\tisDateTimeString(body[\"createTime\"]) &&\n\t\tisDateTimeString(body[\"updateTime\"]) &&\n\t\ttypeof body[\"displayName\"] === \"string\" &&\n\t\ttypeof body[\"description\"] === \"string\"\n\t);\n}\n\nfunction isOptionalBoolean(value: unknown): boolean {\n\treturn value === undefined || value === null || typeof value === \"boolean\";\n}\n\nfunction hasValidPlaceOptional(body: Record<string, unknown>): boolean {\n\tconst serverSize = body[\"serverSize\"] ?? undefined;\n\treturn (\n\t\t(serverSize === undefined || typeof serverSize === \"number\") &&\n\t\tisOptionalBoolean(body[\"root\"]) &&\n\t\tisOptionalBoolean(body[\"universeRuntimeCreation\"])\n\t);\n}\n\nfunction isPlaceWire(body: unknown): body is PlaceWire {\n\treturn isRecord(body) && hasValidPlaceRequired(body) && hasValidPlaceOptional(body);\n}\n","import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport { matchesSignature, RBXL_SIGNATURE, RBXLX_SIGNATURE } from \"./signatures.ts\";\nimport type { PublishParameters } from \"./types.ts\";\n\n/**\n * Whether a publish call writes a live (`Published`) or draft (`Saved`)\n * version. Surfaces only as the `versionType` query string on the\n * underlying HTTP request.\n */\ntype VersionType = \"Published\" | \"Saved\";\n\nconst CONTENT_TYPE_BY_FORMAT: Readonly<Record<PublishParameters[\"format\"], string>> = {\n\trbxl: \"application/octet-stream\",\n\trbxlx: \"application/xml\",\n};\n\n/**\n * Builds a `POST` request for the Open Cloud \"publish place version\"\n * endpoint. Performs two local validations before producing any\n * {@link HttpRequest}: a non-empty body check and a magic-byte check\n * that the bytes' actual format matches `parameters.format`.\n *\n * @param parameters - Universe and place identifiers, the place file\n * bytes, and the declared `format` of those bytes.\n * @param versionType - `\"Published\"` for `publish()`, `\"Saved\"` for\n * `save()`; baked into the `?versionType=` query string.\n * @returns A success result wrapping the request on success, or a\n * {@link ValidationError} when the body is empty or its magic bytes\n * disagree with `parameters.format`.\n */\nexport function buildPublishRequest(\n\t{ body, format, placeId, universeId }: PublishParameters,\n\tversionType: VersionType,\n): Result<HttpRequest, ValidationError> {\n\tconst validationError = validateBody(body, format);\n\tif (validationError !== undefined) {\n\t\treturn { err: validationError, success: false };\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbody,\n\t\t\theaders: { \"content-type\": CONTENT_TYPE_BY_FORMAT[format] },\n\t\t\tmethod: \"POST\",\n\t\t\turl: `/universes/v1/${universeId}/places/${placeId}/versions?versionType=${versionType}`,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\n/**\n * Checks a place body against the format its caller declared: non-empty, and\n * carrying the magic bytes of `format`. Emptiness is checked first so a\n * zero-byte body reports `empty_body` rather than a signature mismatch.\n *\n * @param body - The raw place file bytes.\n * @param format - The format the caller declared the bytes to be in.\n * @returns The {@link ValidationError} to fail with, or `undefined` when the\n * body is usable.\n */\nfunction validateBody(\n\tbody: PublishParameters[\"body\"],\n\tformat: PublishParameters[\"format\"],\n): undefined | ValidationError {\n\tif (body.length === 0) {\n\t\treturn new ValidationError(\"Place body is empty\", { code: \"empty_body\" });\n\t}\n\n\tconst expectedSignature = format === \"rbxl\" ? RBXL_SIGNATURE : RBXLX_SIGNATURE;\n\tif (!matchesSignature(body, expectedSignature)) {\n\t\treturn new ValidationError(`Place body does not match the declared \"${format}\" format`, {\n\t\t\tcode: \"format_mismatch\",\n\t\t});\n\t}\n\n\treturn undefined;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst PUBLISH_PER_MINUTE = 30;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for publishing or saving a place version,\n * from the Open Cloud OpenAPI schema (30 requests per minute, which works\n * out to `0.5` per second and is also the burst the server allows). The\n * publish and save methods both reference this constant so that a single\n * per-API-key queue serves both, matching Roblox's server-side accounting\n * which counts both call types against the same per-minute quota.\n */\nexport const PUBLISH_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: PUBLISH_PER_MINUTE,\n\tmaxPerSecond: PUBLISH_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"places.publishVersion\",\n});\n\n/**\n * Scopes required to publish or save a place version, sourced from\n * `x-roblox-scopes` on the `Places_CreatePlaceVersionApiKey` operation\n * in the vendored OpenAPI schema.\n */\nexport const PUBLISH_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe-places:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { PlaceVersion } from \"./types.ts\";\nimport type { PlaceVersionWire } from \"./wire.ts\";\n\n/**\n * Parses a successful publish-version response into the public\n * {@link PlaceVersion} shape. The Roblox endpoint sometimes returns the\n * JSON-shaped body under a `text/plain` `Content-Type`, so the body may\n * arrive either pre-decoded as a JSON object or still in its raw string\n * form; both are accepted here.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link PlaceVersion}, or\n * an {@link ApiError} when the body is malformed or its `versionNumber`\n * field is missing/wrong-typed.\n */\nexport function parsePublishResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<PlaceVersion, ApiError> {\n\tconst decodeResult = decodeBody(body, statusCode);\n\tif (!decodeResult.success) {\n\t\treturn decodeResult;\n\t}\n\n\tif (!isPlaceVersionWire(decodeResult.data)) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed publish response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: { versionNumber: decodeResult.data.versionNumber },\n\t\tsuccess: true,\n\t};\n}\n\nfunction decodeBody(body: unknown, statusCode: number): Result<unknown, ApiError> {\n\tif (typeof body !== \"string\") {\n\t\treturn { data: body, success: true };\n\t}\n\n\ttry {\n\t\treturn { data: JSON.parse(body), success: true };\n\t} catch (err) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed publish response\", {\n\t\t\t\tcause: err,\n\t\t\t\tdetails: body,\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n}\n\nfunction isPlaceVersionWire(value: unknown): value is PlaceVersionWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn typeof value[\"versionNumber\"] === \"number\";\n}\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { LIST_LOGS_SPEC } from \"../../domains/cloud-v2/luau-execution-task-logs/specs.ts\";\nimport type {\n\tListLogsParameters,\n\tLogPage,\n} from \"../../domains/cloud-v2/luau-execution-task-logs/types.ts\";\nimport {\n\tGET_SPEC,\n\tSUBMIT_HEAD_SPEC,\n\tSUBMIT_VERSION_SPEC,\n} from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tGetParameters,\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport { buildUpdateRequest } from \"../../domains/cloud-v2/places/builders.ts\";\nimport {\n\tUPDATE_OPERATION_LIMIT,\n\tUPDATE_REQUIRED_SCOPES,\n} from \"../../domains/cloud-v2/places/operations.ts\";\nimport { parsePlaceResponse } from \"../../domains/cloud-v2/places/parsers.ts\";\nimport type { Place, UpdatePlaceParameters } from \"../../domains/cloud-v2/places/types.ts\";\nimport { buildPublishRequest } from \"../../domains/universes/places/builders.ts\";\nimport {\n\tPUBLISH_OPERATION_LIMIT,\n\tPUBLISH_REQUIRED_SCOPES,\n} from \"../../domains/universes/places/operations.ts\";\nimport { parsePublishResponse } from \"../../domains/universes/places/parsers.ts\";\nimport type { PlaceVersion, PublishParameters } from \"../../domains/universes/places/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { UPLOAD_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport { ResourceClient, type ResourceMethodSpec } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { buildPollDependencies, submitAndPollAsync } from \"../luau-execution/polling-helpers.ts\";\nimport { pollUntilDoneCoreAsync, type PollUntilDoneOptions } from \"../luau-execution/polling.ts\";\n\n/**\n * Operation Group exposed by {@link PlacesClient} as the\n * `luauExecution` namespace. Provides `submit` to queue a Luau script,\n * `get` to fetch a task's current state, and `listLogs` to retrieve\n * structured log messages. Shares the same dispatch wiring as the\n * top-level `LuauExecutionClient` exposed at\n * `@bedrock-rbx/ocale/luau-execution`.\n *\n * @since 0.1.0\n */\nexport interface LuauExecutionHandle {\n\t/**\n\t * Fetches the current state of a previously-submitted Luau\n\t * execution task. Uses idempotent retry semantics for both 429 and\n\t * 5xx.\n\t *\n\t * @param parameters - The task ref plus an optional `view` selector.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tget(\n\t\tparameters: GetParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Lists one page of structured log messages produced by a\n\t * previously-submitted Luau execution task. Messages from multiple\n\t * server-side chunks are flattened into a single ordered array.\n\t * Uses idempotent retry semantics for both 429 and 5xx.\n\t *\n\t * @param parameters - The task ref and optional pagination controls\n\t * (`pageSize`, `pageToken`).\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link LogPage} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tlistLogs(\n\t\tparameters: ListLogsParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LogPage, OpenCloudError>>;\n\t/**\n\t * Polls `get` with `view=BASIC` on a configurable backoff schedule until\n\t * the task reaches a terminal state, the wall-clock budget is exhausted,\n\t * or the supplied `AbortSignal` fires. Returns the terminal task on\n\t * success.\n\t *\n\t * @param ref - Reference to the task to poll, typically returned by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask},\n\t * or an error if aborted, timed out, or the transport fails.\n\t */\n\tpollUntilDone(\n\t\tref: LuauExecutionTaskRef,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script and polls `get` with `view=BASIC` until the\n\t * task reaches a terminal state, the wall-clock budget is exhausted,\n\t * or the supplied `AbortSignal` fires. Combines `submit` and\n\t * `pollUntilDone` in one call.\n\t *\n\t * @param parameters - The same input accepted by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal\n\t * {@link LuauExecutionTask}, or an error if submit fails, the task\n\t * is aborted, timed out, or the transport fails.\n\t */\n\trunUntilDone(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script for execution against a place. Dispatches\n\t * to the head-version URL when `versionId` is omitted, or to the\n\t * specific-version URL when one is supplied. Both URL shapes share\n\t * one rate-limit queue and one required-scope set.\n\t *\n\t * @param parameters - The universe and place identifiers, the\n\t * script to run, an optional `versionId`, and any other writable\n\t * submit fields.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tsubmit(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n}\n\nfunction makePublishSpec(\n\tversionType: \"Published\" | \"Saved\",\n): ResourceMethodSpec<PublishParameters, PlaceVersion> {\n\treturn Object.freeze({\n\t\tbuildRequest: (parameters: PublishParameters) => {\n\t\t\treturn buildPublishRequest(parameters, versionType);\n\t\t},\n\t\tmethodDefaults: UPLOAD_METHOD_DEFAULTS,\n\t\tmethodKind: \"create\",\n\t\toperationLimit: PUBLISH_OPERATION_LIMIT,\n\t\tparse: parsePublishResponse,\n\t\trequiredScopes: PUBLISH_REQUIRED_SCOPES,\n\t});\n}\n\nconst PUBLISH_SPEC = makePublishSpec(\"Published\");\nconst SAVE_SPEC = makePublishSpec(\"Saved\");\n\nconst UPDATE_SPEC: ResourceMethodSpec<UpdatePlaceParameters, Place> = Object.freeze({\n\tbuildRequest: buildUpdateRequest,\n\tmethodDefaults: {},\n\tmethodKind: \"idempotent\",\n\toperationLimit: UPDATE_OPERATION_LIMIT,\n\tparse: parsePlaceResponse,\n\trequiredScopes: UPDATE_REQUIRED_SCOPES,\n});\n\n/**\n * Public client for the Roblox Open Cloud `Place` resource. Covers\n * place-version publishing (`publish`, `save`), place-configuration\n * updates (`update`), and the Luau execution Operation Group\n * (`luauExecution.submit`, `luauExecution.get`). Every method returns\n * a {@link Result} so callers handle failure explicitly; no thrown\n * {@link OpenCloudError} ever escapes the client.\n *\n * Publishing or saving a 5xx-failed place version is not retried\n * automatically: Roblox does not support idempotency keys, so a retry\n * could publish a duplicate version unnoticed. Callers that *can* detect\n * duplicates externally may opt back into 5xx retry per-call by passing\n * `retryableStatuses` on the second argument. The `update` method, by\n * contrast, is idempotent and retries both 429 and 5xx automatically.\n *\n * Failures that never reached Open Cloud *are* retried: transient transport\n * errors, and responses served by an edge gateway rather than the API. Neither\n * can have created a version, so neither risks the duplicate a 5xx does.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { PlacesClient } from \"@bedrock-rbx/ocale/places\";\n *\n * const client = new PlacesClient({ apiKey: \"your-key\" });\n * expect(client).toBeInstanceOf(PlacesClient);\n * ```\n */\nexport class PlacesClient {\n\treadonly #inner: ResourceClient;\n\n\tpublic readonly luauExecution: LuauExecutionHandle;\n\n\t/**\n\t * Creates a new {@link PlacesClient}. Configuration is frozen on\n\t * construction; per-request overrides are accepted on each method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.luauExecution = createLuauExecutionHandle(this.#inner);\n\t}\n\n\t/**\n\t * Publishes a new live version of a place.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Universe and place identifiers, the place file\n\t * bytes, and their declared `format`.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link PlaceVersion}\n\t * or the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async publish(\n\t\tparameters: PublishParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<PlaceVersion, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: PUBLISH_SPEC });\n\t}\n\n\t/**\n\t * Saves a new draft version of a place. Identical to {@link publish}\n\t * except the resulting version is not made live; consumers can list or\n\t * promote it later. Shares a single per-API-key rate-limit queue with\n\t * `publish` because Roblox attributes both calls to the same per-minute\n\t * quota.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Universe and place identifiers, the place file\n\t * bytes, and their declared `format`.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link PlaceVersion}\n\t * or the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async save(\n\t\tparameters: PublishParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<PlaceVersion, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: SAVE_SPEC });\n\t}\n\n\t/**\n\t * Partially updates a place's configuration. The fields supplied on\n\t * `parameters` (excluding the identifiers) are forwarded to the\n\t * server via a Google-style `updateMask`; unmentioned fields are\n\t * left untouched. The universe's root place is the canonical place\n\t * to update when changing a universe's description or display name:\n\t * both are derived server-side from the root place.\n\t *\n\t * @param parameters - The universe and place identifiers and the\n\t * fields to update. At least one writable field must be supplied.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link Place} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async update(\n\t\tparameters: UpdatePlaceParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<Place, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPDATE_SPEC });\n\t}\n}\n\nfunction createLuauExecutionHandle(inner: ResourceClient): LuauExecutionHandle {\n\treturn {\n\t\tasync get(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: GET_SPEC });\n\t\t},\n\t\tasync listLogs(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: LIST_LOGS_SPEC });\n\t\t},\n\t\tasync pollUntilDone(ref, options = {}) {\n\t\t\treturn pollUntilDoneCoreAsync(buildPollDependencies(inner, { options, ref }), options);\n\t\t},\n\t\tasync runUntilDone(parameters, options = {}) {\n\t\t\treturn submitAndPollAsync(inner, { options, parameters });\n\t\t},\n\t\tasync submit(parameters, options) {\n\t\t\tif (\"versionId\" in parameters) {\n\t\t\t\treturn inner.executeAsync({ options, parameters, spec: SUBMIT_VERSION_SPEC });\n\t\t\t}\n\n\t\t\treturn inner.executeAsync({ options, parameters, spec: SUBMIT_HEAD_SPEC });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAKA,MAAM,qBAA0C,IAAI,IAAI,CAAC,WAAW,YAAY,CAAC;;;;;;;;;;;;AAajF,SAAgB,mBACf,YACuC;CACvC,MAAM,YAAY,uBAAuB,UAAU;CAEnD,IAAI,UAAU,WAAW,GACxB,OAAO;EACN,KAAK,IAAI,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OAAO,mBAAmB,OAAO;IAAE;IAAS;GAAW,CAAC;EACzD;EACA,MAAM,OAAO,YAAY,SAAS;GACjC,IAAI,eAAe,YAClB,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAAoB,CAAC;GAG7E,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAAiB,CAAC;EAC1E;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"places.mjs","names":["SECONDS_PER_MINUTE","#inner"],"sources":["../src/domains/cloud-v2/places/builders.ts","../src/domains/cloud-v2/places/operations.ts","../src/domains/cloud-v2/places/parsers.ts","../src/domains/universes/places/builders.ts","../src/domains/universes/places/operations.ts","../src/domains/universes/places/parsers.ts","../src/resources/places/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { UpdatePlaceParameters } from \"./types.ts\";\n\nconst NON_UPDATABLE_KEYS: ReadonlySet<string> = new Set([\"placeId\", \"universeId\"]);\n\n/**\n * Builds a `PATCH` request for the Open Cloud \"update place\" endpoint.\n * Derives the `updateMask` query string from the keys present on\n * `parameters` (excluding the identifiers) and emits a JSON body\n * containing those same fields.\n *\n * @param parameters - The universe and place identifiers plus the fields\n * to update.\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when no updatable fields were supplied.\n */\nexport function buildUpdateRequest(\n\tparameters: UpdatePlaceParameters,\n): Result<HttpRequest, ValidationError> {\n\tconst fieldKeys = extractUpdateFieldKeys(parameters);\n\n\tif (fieldKeys.length === 0) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Update must include at least one field\", {\n\t\t\t\tcode: \"empty_update\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst body = Object.fromEntries(\n\t\tfieldKeys.map((key): readonly [string, unknown] => [key, Reflect.get(parameters, key)]),\n\t);\n\tconst updateMask = fieldKeys.join(\",\");\n\tconst { placeId, universeId } = parameters;\n\treturn {\n\t\tdata: {\n\t\t\tbody,\n\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t\tmethod: \"PATCH\",\n\t\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}?updateMask=${updateMask}`,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction extractUpdateFieldKeys(parameters: UpdatePlaceParameters): ReadonlyArray<string> {\n\treturn Object.keys(parameters).filter((key) => !NON_UPDATABLE_KEYS.has(key));\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst UPDATE_PER_MINUTE = 100;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for updating a place, from the Open Cloud\n * OpenAPI schema (100 requests per minute per API key owner). Keyed\n * independently from the publish operation so publish and update do\n * not share a queue; upstream quota accounting is not documented as\n * shared and the conservative default is fewer cross-method\n * contention surprises.\n */\nexport const UPDATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: UPDATE_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"places.update\",\n});\n\n/**\n * Scopes required to update a place's metadata, sourced from\n * `x-roblox-scopes` on the `Cloud_UpdatePlace` operation in the vendored\n * OpenAPI schema.\n */\nexport const UPDATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { Place } from \"./types.ts\";\nimport type { PlaceWire } from \"./wire.ts\";\n\nconst MALFORMED_PLACE_MESSAGE = \"Malformed place response\";\n\nconst PLACE_PATH_PATTERN = /^universes\\/(\\d+)\\/places\\/(\\d+)$/;\n\ninterface ToPlaceArgs {\n\treadonly id: string;\n\treadonly body: PlaceWire;\n\treadonly universeId: string;\n}\n\n/**\n * Parses a successful Open Cloud `Place` response body into the public\n * {@link Place} shape.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link Place}, or an\n * {@link ApiError} when the body does not match the wire schema.\n */\nexport function parsePlaceResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<Place, ApiError> {\n\tif (!isPlaceWire(body)) {\n\t\treturn malformedPlace(statusCode, body);\n\t}\n\n\tconst match = PLACE_PATH_PATTERN.exec(body.path);\n\tconst universeId = match?.[1];\n\tconst id = match?.[2];\n\tif (id === undefined || universeId === undefined) {\n\t\treturn malformedPlace(statusCode, body);\n\t}\n\n\treturn { data: toPlace({ id, body, universeId }), success: true };\n}\n\nfunction malformedPlace(statusCode: number, body: unknown): Result<Place, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_PLACE_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n\nfunction toPlace({ id, body, universeId }: ToPlaceArgs): Place {\n\treturn {\n\t\tid,\n\t\tcreatedAt: new Date(body.createTime),\n\t\tdescription: body.description,\n\t\tdisplayName: body.displayName,\n\t\troot: body.root ?? false,\n\t\tserverSize: body.serverSize ?? undefined,\n\t\tuniverseId,\n\t\tuniverseRuntimeCreation: body.universeRuntimeCreation ?? false,\n\t\tupdatedAt: new Date(body.updateTime),\n\t};\n}\n\nfunction hasValidPlaceRequired(body: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof body[\"path\"] === \"string\" &&\n\t\tisDateTimeString(body[\"createTime\"]) &&\n\t\tisDateTimeString(body[\"updateTime\"]) &&\n\t\ttypeof body[\"displayName\"] === \"string\" &&\n\t\ttypeof body[\"description\"] === \"string\"\n\t);\n}\n\nfunction isOptionalBoolean(value: unknown): boolean {\n\treturn value === undefined || value === null || typeof value === \"boolean\";\n}\n\nfunction hasValidPlaceOptional(body: Record<string, unknown>): boolean {\n\tconst serverSize = body[\"serverSize\"] ?? undefined;\n\treturn (\n\t\t(serverSize === undefined || typeof serverSize === \"number\") &&\n\t\tisOptionalBoolean(body[\"root\"]) &&\n\t\tisOptionalBoolean(body[\"universeRuntimeCreation\"])\n\t);\n}\n\nfunction isPlaceWire(body: unknown): body is PlaceWire {\n\treturn isRecord(body) && hasValidPlaceRequired(body) && hasValidPlaceOptional(body);\n}\n","import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport { matchesSignature, RBXL_SIGNATURE, RBXLX_SIGNATURE } from \"./signatures.ts\";\nimport type { PublishParameters } from \"./types.ts\";\n\n/**\n * Whether a publish call writes a live (`Published`) or draft (`Saved`)\n * version. Surfaces only as the `versionType` query string on the\n * underlying HTTP request.\n */\ntype VersionType = \"Published\" | \"Saved\";\n\nconst CONTENT_TYPE_BY_FORMAT: Readonly<Record<PublishParameters[\"format\"], string>> = {\n\trbxl: \"application/octet-stream\",\n\trbxlx: \"application/xml\",\n};\n\n/**\n * Builds a `POST` request for the Open Cloud \"publish place version\"\n * endpoint. Performs two local validations before producing any\n * {@link HttpRequest}: a non-empty body check and a magic-byte check\n * that the bytes' actual format matches `parameters.format`.\n *\n * @param parameters - Universe and place identifiers, the place file\n * bytes, and the declared `format` of those bytes.\n * @param versionType - `\"Published\"` for `publish()`, `\"Saved\"` for\n * `save()`; baked into the `?versionType=` query string.\n * @returns A success result wrapping the request on success, or a\n * {@link ValidationError} when the body is empty or its magic bytes\n * disagree with `parameters.format`.\n */\nexport function buildPublishRequest(\n\t{ body, format, placeId, universeId }: PublishParameters,\n\tversionType: VersionType,\n): Result<HttpRequest, ValidationError> {\n\tconst validationError = validateBody(body, format);\n\tif (validationError !== undefined) {\n\t\treturn { err: validationError, success: false };\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbody,\n\t\t\theaders: { \"content-type\": CONTENT_TYPE_BY_FORMAT[format] },\n\t\t\tmethod: \"POST\",\n\t\t\turl: `/universes/v1/${universeId}/places/${placeId}/versions?versionType=${versionType}`,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\n/**\n * Checks a place body against the format its caller declared: non-empty, and\n * carrying the magic bytes of `format`. Emptiness is checked first so a\n * zero-byte body reports `empty_body` rather than a signature mismatch.\n *\n * @param body - The raw place file bytes.\n * @param format - The format the caller declared the bytes to be in.\n * @returns The {@link ValidationError} to fail with, or `undefined` when the\n * body is usable.\n */\nfunction validateBody(\n\tbody: PublishParameters[\"body\"],\n\tformat: PublishParameters[\"format\"],\n): undefined | ValidationError {\n\tif (body.length === 0) {\n\t\treturn new ValidationError(\"Place body is empty\", { code: \"empty_body\" });\n\t}\n\n\tconst expectedSignature = format === \"rbxl\" ? RBXL_SIGNATURE : RBXLX_SIGNATURE;\n\tif (!matchesSignature(body, expectedSignature)) {\n\t\treturn new ValidationError(`Place body does not match the declared \"${format}\" format`, {\n\t\t\tcode: \"format_mismatch\",\n\t\t});\n\t}\n\n\treturn undefined;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst PUBLISH_PER_MINUTE = 30;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for publishing or saving a place version,\n * from the Open Cloud OpenAPI schema (30 requests per minute, which works\n * out to `0.5` per second and is also the burst the server allows). The\n * publish and save methods both reference this constant so that a single\n * per-API-key queue serves both, matching Roblox's server-side accounting\n * which counts both call types against the same per-minute quota.\n */\nexport const PUBLISH_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: PUBLISH_PER_MINUTE,\n\tmaxPerSecond: PUBLISH_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"places.publishVersion\",\n});\n\n/**\n * Scopes required to publish or save a place version, sourced from\n * `x-roblox-scopes` on the `Places_CreatePlaceVersionApiKey` operation\n * in the vendored OpenAPI schema.\n */\nexport const PUBLISH_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe-places:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.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 { PlaceVersion } from \"./types.ts\";\nimport type { PlaceVersionWire } from \"./wire.ts\";\n\n/**\n * Parses a successful publish-version response into the public\n * {@link PlaceVersion} shape. The Roblox endpoint sometimes returns the\n * JSON-shaped body under a `text/plain` `Content-Type`, so the body may\n * arrive either pre-decoded as a JSON object or still in its raw string\n * form; both are accepted here.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link PlaceVersion}, or\n * an {@link ApiError} when the body is malformed or its `versionNumber`\n * field is missing/wrong-typed.\n */\nexport function parsePublishResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<PlaceVersion, ApiError> {\n\tconst decodeResult = decodeBody(body, statusCode);\n\tif (!decodeResult.success) {\n\t\treturn decodeResult;\n\t}\n\n\tif (!isPlaceVersionWire(decodeResult.data)) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed publish response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: { versionNumber: decodeResult.data.versionNumber },\n\t\tsuccess: true,\n\t};\n}\n\nfunction decodeBody(body: unknown, statusCode: number): Result<unknown, ApiError> {\n\tif (typeof body !== \"string\") {\n\t\treturn { data: body, success: true };\n\t}\n\n\ttry {\n\t\treturn { data: JSON.parse(body), success: true };\n\t} catch (err) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed publish response\", {\n\t\t\t\tcause: err,\n\t\t\t\tdetails: body,\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n}\n\nfunction isPlaceVersionWire(value: unknown): value is PlaceVersionWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn typeof value[\"versionNumber\"] === \"number\";\n}\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { LIST_LOGS_SPEC } from \"../../domains/cloud-v2/luau-execution-task-logs/specs.ts\";\nimport type {\n\tListLogsParameters,\n\tLogPage,\n} from \"../../domains/cloud-v2/luau-execution-task-logs/types.ts\";\nimport { GET_SPEC } from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tGetParameters,\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport { buildUpdateRequest } from \"../../domains/cloud-v2/places/builders.ts\";\nimport {\n\tUPDATE_OPERATION_LIMIT,\n\tUPDATE_REQUIRED_SCOPES,\n} from \"../../domains/cloud-v2/places/operations.ts\";\nimport { parsePlaceResponse } from \"../../domains/cloud-v2/places/parsers.ts\";\nimport type { Place, UpdatePlaceParameters } from \"../../domains/cloud-v2/places/types.ts\";\nimport { buildPublishRequest } from \"../../domains/universes/places/builders.ts\";\nimport {\n\tPUBLISH_OPERATION_LIMIT,\n\tPUBLISH_REQUIRED_SCOPES,\n} from \"../../domains/universes/places/operations.ts\";\nimport { parsePublishResponse } from \"../../domains/universes/places/parsers.ts\";\nimport type { PlaceVersion, PublishParameters } from \"../../domains/universes/places/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { UPLOAD_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport { ResourceClient, type ResourceMethodSpec } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport {\n\ttype LuauExecutionRunOptions,\n\ttype LuauExecutionSubmitOptions,\n\tsubmitWithCapacityAsync,\n} from \"../luau-execution/capacity-admission.ts\";\nimport { buildPollDependencies, submitAndPollAsync } from \"../luau-execution/polling-helpers.ts\";\nimport { pollUntilDoneCoreAsync, type PollUntilDoneOptions } from \"../luau-execution/polling.ts\";\n\n/**\n * Operation Group exposed by {@link PlacesClient} as the\n * `luauExecution` namespace. Provides `submit` to queue a Luau script,\n * `get` to fetch a task's current state, and `listLogs` to retrieve\n * structured log messages. Shares the same dispatch wiring as the\n * top-level `LuauExecutionClient` exposed at\n * `@bedrock-rbx/ocale/luau-execution`.\n *\n * @since 0.1.0\n */\nexport interface LuauExecutionHandle {\n\t/**\n\t * Fetches the current state of a previously-submitted Luau\n\t * execution task. Uses idempotent retry semantics for both 429 and\n\t * 5xx.\n\t *\n\t * @param parameters - The task ref plus an optional `view` selector.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tget(\n\t\tparameters: GetParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Lists one page of structured log messages produced by a\n\t * previously-submitted Luau execution task. Messages from multiple\n\t * server-side chunks are flattened into a single ordered array.\n\t * Uses idempotent retry semantics for both 429 and 5xx.\n\t *\n\t * @param parameters - The task ref and optional pagination controls\n\t * (`pageSize`, `pageToken`).\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link LogPage} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tlistLogs(\n\t\tparameters: ListLogsParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<LogPage, OpenCloudError>>;\n\t/**\n\t * Polls `get` with `view=BASIC` on a configurable backoff schedule until\n\t * the task reaches a terminal state, the wall-clock budget is exhausted,\n\t * or the supplied `AbortSignal` fires. Returns the terminal task on\n\t * success.\n\t *\n\t * @param ref - Reference to the task to poll, typically returned by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask},\n\t * or an error if aborted, timed out, or the transport fails.\n\t */\n\tpollUntilDone(\n\t\tref: LuauExecutionTaskRef,\n\t\toptions?: PollUntilDoneOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script and polls `get` with `view=BASIC` until the\n\t * task reaches a terminal state, the wall-clock budget is exhausted,\n\t * or the supplied `AbortSignal` fires. Combines `submit` and\n\t * `pollUntilDone` in one call.\n\t *\n\t * @param parameters - The same input accepted by `submit`.\n\t * @param options - Polling and per-request overrides.\n\t * @returns A {@link Result} wrapping the terminal\n\t * {@link LuauExecutionTask}, or an error if submit fails, the task\n\t * is aborted, timed out, or the transport fails.\n\t */\n\trunUntilDone(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: LuauExecutionRunOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/**\n\t * Submits a Luau script for execution against a place. Dispatches\n\t * to the head-version URL when `versionId` is omitted, or to the\n\t * specific-version URL when one is supplied. Both URL shapes share\n\t * one rate-limit queue and one required-scope set.\n\t *\n\t * @param parameters - The universe and place identifiers, the\n\t * script to run, an optional `versionId`, and any other writable\n\t * submit fields.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed\n\t * {@link LuauExecutionTask} or the {@link OpenCloudError} that\n\t * caused the request to fail.\n\t */\n\tsubmit(\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n\t\toptions?: LuauExecutionSubmitOptions,\n\t): Promise<Result<LuauExecutionTask, OpenCloudError>>;\n}\n\nfunction makePublishSpec(\n\tversionType: \"Published\" | \"Saved\",\n): ResourceMethodSpec<PublishParameters, PlaceVersion> {\n\treturn Object.freeze({\n\t\tbuildRequest: (parameters: PublishParameters) => {\n\t\t\treturn buildPublishRequest(parameters, versionType);\n\t\t},\n\t\tmethodDefaults: UPLOAD_METHOD_DEFAULTS,\n\t\tmethodKind: \"create\",\n\t\toperationLimit: PUBLISH_OPERATION_LIMIT,\n\t\tparse: parsePublishResponse,\n\t\trequiredScopes: PUBLISH_REQUIRED_SCOPES,\n\t});\n}\n\nconst PUBLISH_SPEC = makePublishSpec(\"Published\");\nconst SAVE_SPEC = makePublishSpec(\"Saved\");\n\nconst UPDATE_SPEC: ResourceMethodSpec<UpdatePlaceParameters, Place> = Object.freeze({\n\tbuildRequest: buildUpdateRequest,\n\tmethodDefaults: {},\n\tmethodKind: \"idempotent\",\n\toperationLimit: UPDATE_OPERATION_LIMIT,\n\tparse: parsePlaceResponse,\n\trequiredScopes: UPDATE_REQUIRED_SCOPES,\n});\n\n/**\n * Public client for the Roblox Open Cloud `Place` resource. Covers\n * place-version publishing (`publish`, `save`), place-configuration\n * updates (`update`), and the Luau execution Operation Group\n * (`luauExecution.submit`, `luauExecution.get`). Every method returns\n * a {@link Result} so callers handle failure explicitly; no thrown\n * {@link OpenCloudError} ever escapes the client.\n *\n * Publishing or saving a 5xx-failed place version is not retried\n * automatically: Roblox does not support idempotency keys, so a retry\n * could publish a duplicate version unnoticed. Callers that *can* detect\n * duplicates externally may opt back into 5xx retry per-call by passing\n * `retryableStatuses` on the second argument. The `update` method, by\n * contrast, is idempotent and retries both 429 and 5xx automatically.\n *\n * Failures that never reached Open Cloud *are* retried: transient transport\n * errors, and responses served by an edge gateway rather than the API. Neither\n * can have created a version, so neither risks the duplicate a 5xx does.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { PlacesClient } from \"@bedrock-rbx/ocale/places\";\n *\n * const client = new PlacesClient({ apiKey: \"your-key\" });\n * expect(client).toBeInstanceOf(PlacesClient);\n * ```\n */\nexport class PlacesClient {\n\treadonly #inner: ResourceClient;\n\n\tpublic readonly luauExecution: LuauExecutionHandle;\n\n\t/**\n\t * Creates a new {@link PlacesClient}. Configuration is frozen on\n\t * construction; per-request overrides are accepted on each method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.luauExecution = createLuauExecutionHandle(this.#inner);\n\t}\n\n\t/**\n\t * Publishes a new live version of a place.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Universe and place identifiers, the place file\n\t * bytes, and their declared `format`.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link PlaceVersion}\n\t * or the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async publish(\n\t\tparameters: PublishParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<PlaceVersion, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: PUBLISH_SPEC });\n\t}\n\n\t/**\n\t * Saves a new draft version of a place. Identical to {@link publish}\n\t * except the resulting version is not made live; consumers can list or\n\t * promote it later. Shares a single per-API-key rate-limit queue with\n\t * `publish` because Roblox attributes both calls to the same per-minute\n\t * quota.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Universe and place identifiers, the place file\n\t * bytes, and their declared `format`.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link PlaceVersion}\n\t * or the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async save(\n\t\tparameters: PublishParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<PlaceVersion, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: SAVE_SPEC });\n\t}\n\n\t/**\n\t * Partially updates a place's configuration. The fields supplied on\n\t * `parameters` (excluding the identifiers) are forwarded to the\n\t * server via a Google-style `updateMask`; unmentioned fields are\n\t * left untouched. The universe's root place is the canonical place\n\t * to update when changing a universe's description or display name:\n\t * both are derived server-side from the root place.\n\t *\n\t * @param parameters - The universe and place identifiers and the\n\t * fields to update. At least one writable field must be supplied.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link Place} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async update(\n\t\tparameters: UpdatePlaceParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<Place, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPDATE_SPEC });\n\t}\n}\n\nfunction createLuauExecutionHandle(inner: ResourceClient): LuauExecutionHandle {\n\treturn {\n\t\tasync get(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: GET_SPEC });\n\t\t},\n\t\tasync listLogs(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: LIST_LOGS_SPEC });\n\t\t},\n\t\tasync pollUntilDone(ref, options = {}) {\n\t\t\treturn pollUntilDoneCoreAsync(buildPollDependencies(inner, { options, ref }), options);\n\t\t},\n\t\tasync runUntilDone(parameters, options = {}) {\n\t\t\treturn submitAndPollAsync(inner, { options, parameters });\n\t\t},\n\t\tasync submit(parameters, options) {\n\t\t\treturn submitWithCapacityAsync({ inner, options, parameters });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAKA,MAAM,qBAA0C,IAAI,IAAI,CAAC,WAAW,YAAY,CAAC;;;;;;;;;;;;AAajF,SAAgB,mBACf,YACuC;CACvC,MAAM,YAAY,uBAAuB,UAAU;CAEnD,IAAI,UAAU,WAAW,GACxB,OAAO;EACN,KAAK,IAAI,gBAAgB,0CAA0C,EAClE,MAAM,eACP,CAAC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CAAC;EACzD;EACA,MAAM,OAAO,YAAY,SAAS;GACjC,OAAO,wBAAwB;IAAE;IAAO;IAAS;GAAW,CAAC;EAC9D;CACD;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as OpenCloudError } from "./network-error-DR9FX5hb.mjs";
|
|
2
2
|
//#region src/errors/poll-aborted.ts
|
|
3
3
|
/**
|
|
4
4
|
* Returned when `pollUntilDone` is interrupted by an `AbortSignal` before
|
|
@@ -80,4 +80,4 @@ var PollTimeoutError = class extends OpenCloudError {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { PollAbortedError as n, PollTimeoutError as t };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=poll-timeout-
|
|
83
|
+
//# sourceMappingURL=poll-timeout-3PXLsabj.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll-timeout-
|
|
1
|
+
{"version":3,"file":"poll-timeout-3PXLsabj.mjs","names":[],"sources":["../src/errors/poll-aborted.ts","../src/errors/poll-timeout.ts"],"sourcesContent":["import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link PollAbortedError}.\n *\n * @since 0.1.0\n */\nexport interface PollAbortedErrorOptions extends ErrorOptions {\n\t/** Whatever `AbortSignal.reason` was at the moment of abort. */\n\treadonly reason?: unknown;\n}\n\n/**\n * Returned when `pollUntilDone` is interrupted by an `AbortSignal` before\n * a terminal task state is reached. The `reason` field mirrors\n * `AbortSignal.reason` so callers can distinguish intentional cancellation\n * from unexpected abort sources.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { PollAbortedError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new PollAbortedError(\"polling was aborted\", {\n * reason: \"user cancelled\",\n * });\n *\n * expect(error).toBeInstanceOf(PollAbortedError);\n * expect(error.reason).toBe(\"user cancelled\");\n * ```\n */\nexport class PollAbortedError extends OpenCloudError {\n\tpublic override readonly name: string = \"PollAbortedError\";\n\tpublic readonly reason?: unknown;\n\n\t/**\n\t * Creates a new PollAbortedError.\n\t *\n\t * @param message - Human-readable description of the abort.\n\t * @param options - Error options including the abort reason.\n\t */\n\tconstructor(message: string, options: PollAbortedErrorOptions = {}) {\n\t\tsuper(message, options);\n\t\tthis.reason = options.reason;\n\t}\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for {@link PollTimeoutError}. The `T` type parameter captures the\n * resource-specific task variant the caller polled for; defaults to `unknown`\n * so the class can be reused by future Resources without forcing a parallel\n * hierarchy.\n *\n * @since 0.1.0\n *\n * @template T - Resource-specific task type being polled.\n */\nexport interface PollTimeoutErrorOptions<T = unknown> extends ErrorOptions {\n\t/** Last task observed before the timeout budget was exhausted. */\n\treadonly lastObservedTask?: T | undefined;\n\t/** Total wall-clock budget supplied by the caller, in ms. */\n\treadonly timeoutMs: number;\n}\n\n/**\n * Returned when `pollUntilDone` exhausts its wall-clock budget without\n * observing a terminal task state. Carries the last task polled so callers\n * can inspect state and decide whether to retry with a fresh budget.\n *\n * @since 0.1.0\n *\n * @template T - Resource-specific task type being polled.\n *\n * @example\n *\n * ```ts\n * import { PollTimeoutError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new PollTimeoutError(\"polling timed out after 5 s\", {\n * lastObservedTask: { state: \"PROCESSING\" as const },\n * timeoutMs: 5000,\n * });\n *\n * expect(error).toBeInstanceOf(PollTimeoutError);\n * expect(error.timeoutMs).toBe(5000);\n * expect(error.lastObservedTask).toStrictEqual({ state: \"PROCESSING\" });\n * ```\n */\nexport class PollTimeoutError<T = unknown> extends OpenCloudError {\n\tpublic readonly lastObservedTask: T | undefined;\n\tpublic override readonly name: string = \"PollTimeoutError\";\n\tpublic readonly timeoutMs: number;\n\n\t/**\n\t * Creates a new PollTimeoutError.\n\t *\n\t * @param message - Human-readable description of the timeout.\n\t * @param options - Error options including the budget and last-observed task.\n\t */\n\tconstructor(message: string, options: PollTimeoutErrorOptions<T>) {\n\t\tsuper(message, options);\n\t\tthis.lastObservedTask = options.lastObservedTask;\n\t\tthis.timeoutMs = options.timeoutMs;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,mBAAb,cAAsC,eAAe;CACpD,OAAwC;CACxC;;;;;;;CAQA,YAAY,SAAiB,UAAmC,CAAC,GAAG;EACnE,MAAM,SAAS,OAAO;EACtB,KAAK,SAAS,QAAQ;CACvB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;ACJA,IAAa,mBAAb,cAAmD,eAAe;CACjE;CACA,OAAwC;CACxC;;;;;;;CAQA,YAAY,SAAiB,SAAqC;EACjE,MAAM,SAAS,OAAO;EACtB,KAAK,mBAAmB,QAAQ;EAChC,KAAK,YAAY,QAAQ;CAC1B;AACD"}
|