@bedrock-rbx/ocale 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/badges.d.mts +21 -6
  2. package/dist/badges.d.mts.map +1 -1
  3. package/dist/badges.mjs +10 -11
  4. package/dist/badges.mjs.map +1 -1
  5. package/dist/developer-products.d.mts +22 -11
  6. package/dist/developer-products.d.mts.map +1 -1
  7. package/dist/developer-products.mjs +21 -20
  8. package/dist/developer-products.mjs.map +1 -1
  9. package/dist/game-passes.d.mts +5 -5
  10. package/dist/game-passes.mjs +18 -20
  11. package/dist/game-passes.mjs.map +1 -1
  12. package/dist/index.d.mts +9 -5
  13. package/dist/index.d.mts.map +1 -1
  14. package/dist/index.mjs +4 -4
  15. package/dist/luau-execution.d.mts +5 -3
  16. package/dist/luau-execution.d.mts.map +1 -1
  17. package/dist/luau-execution.mjs +22 -18
  18. package/dist/luau-execution.mjs.map +1 -1
  19. package/dist/places.d.mts +2 -2
  20. package/dist/places.d.mts.map +1 -1
  21. package/dist/places.mjs +31 -31
  22. package/dist/places.mjs.map +1 -1
  23. package/dist/{poll-timeout-BfxUWWCZ.mjs → poll-timeout-DXfJVZzR.mjs} +2 -2
  24. package/dist/{poll-timeout-BfxUWWCZ.mjs.map → poll-timeout-DXfJVZzR.mjs.map} +1 -1
  25. package/dist/{polling-rj0dGREg.d.mts → polling-CG12rHaz.d.mts} +29 -11
  26. package/dist/polling-CG12rHaz.d.mts.map +1 -0
  27. package/dist/{polling-helpers-DkJcWZpp.mjs → polling-helpers-SBN188o5.mjs} +47 -53
  28. package/dist/polling-helpers-SBN188o5.mjs.map +1 -0
  29. package/dist/{price-information-ClGhSmgI.mjs → price-information-DziMfTQ6.mjs} +2 -2
  30. package/dist/{price-information-ClGhSmgI.mjs.map → price-information-DziMfTQ6.mjs.map} +1 -1
  31. package/dist/{rate-limit-Dh2leqaB.mjs → rate-limit-B20REZEY.mjs} +6 -4
  32. package/dist/{rate-limit-Dh2leqaB.mjs.map → rate-limit-B20REZEY.mjs.map} +1 -1
  33. package/dist/{resource-client-CsbYSKwf.mjs → resource-client-rQ9bBn4L.mjs} +138 -62
  34. package/dist/resource-client-rQ9bBn4L.mjs.map +1 -0
  35. package/dist/{retry-BEh37aK2.d.mts → retry-DGY51INM.d.mts} +14 -12
  36. package/dist/{retry-BEh37aK2.d.mts.map → retry-DGY51INM.d.mts.map} +1 -1
  37. package/dist/{retry-CMzwdn1c.mjs → retry-PmpgEwFN.mjs} +21 -19
  38. package/dist/retry-PmpgEwFN.mjs.map +1 -0
  39. package/dist/storage.d.mts +33 -8
  40. package/dist/storage.d.mts.map +1 -1
  41. package/dist/storage.mjs +24 -33
  42. package/dist/storage.mjs.map +1 -1
  43. package/dist/testing.d.mts +50 -16
  44. package/dist/testing.d.mts.map +1 -1
  45. package/dist/testing.mjs +5 -3
  46. package/dist/testing.mjs.map +1 -1
  47. package/dist/{types-CRiJg5EQ.d.mts → types-DXai6-hU.d.mts} +5 -3
  48. package/dist/{types-CRiJg5EQ.d.mts.map → types-DXai6-hU.d.mts.map} +1 -1
  49. package/dist/universes.d.mts +7 -4
  50. package/dist/universes.d.mts.map +1 -1
  51. package/dist/universes.mjs +20 -25
  52. package/dist/universes.mjs.map +1 -1
  53. package/dist/{validation-xJZRa8tX.mjs → validation-BXhEM3OP.mjs} +2 -2
  54. package/dist/{validation-xJZRa8tX.mjs.map → validation-BXhEM3OP.mjs.map} +1 -1
  55. package/package.json +4 -3
  56. package/dist/polling-helpers-DkJcWZpp.mjs.map +0 -1
  57. package/dist/polling-rj0dGREg.d.mts.map +0 -1
  58. package/dist/resource-client-CsbYSKwf.mjs.map +0 -1
  59. package/dist/retry-CMzwdn1c.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { s as RequestOptions } from "./types-CRiJg5EQ.mjs";
1
+ import { s as RequestOptions } from "./types-DXai6-hU.mjs";
2
2
 
3
3
  //#region src/domains/cloud-v2/luau-execution-tasks/types.d.ts
4
4
  /**
@@ -172,7 +172,10 @@ interface LuauExecutionTaskBase {
172
172
  * `true`.
173
173
  */
174
174
  readonly binaryOutputUri?: string | undefined;
175
- /** Timestamp when the task was created; `undefined` on tasks returned by `submit`. */
175
+ /**
176
+ * Timestamp when the task was created; `undefined` on tasks returned by
177
+ * `submit`.
178
+ */
176
179
  readonly createdAt?: Date | undefined;
177
180
  /** When `true`, the server writes output to a binary blob. */
178
181
  readonly enableBinaryOutput?: boolean | undefined;
@@ -184,9 +187,14 @@ interface LuauExecutionTaskBase {
184
187
  * server applies its 5-minute default in that case).
185
188
  */
186
189
  readonly timeoutSeconds?: number | undefined;
187
- /** Timestamp of the most recent state change; `undefined` on tasks returned by `submit`. */
190
+ /**
191
+ * Timestamp of the most recent state change; `undefined` on tasks returned
192
+ * by `submit`.
193
+ */
188
194
  readonly updatedAt?: Date | undefined;
189
- /** Identifier of the user that owns the API key used to create this task. */
195
+ /**
196
+ * Identifier of the user that owns the API key used to create this task.
197
+ */
190
198
  readonly user: string;
191
199
  }
192
200
  //#endregion
@@ -271,7 +279,8 @@ interface LogPage {
271
279
  */
272
280
  declare function defaultPollDelay(elapsedMs: number): number;
273
281
  /**
274
- * Public options accepted by `pollUntilDone` and `runUntilDone` on both client surfaces.
282
+ * Public options accepted by `pollUntilDone` and `runUntilDone` on both client
283
+ * surfaces.
275
284
  *
276
285
  * @since 0.1.0
277
286
  */
@@ -280,15 +289,24 @@ type PollUntilDoneOptions = PollOptions & RequestOptions;
280
289
  interface PollOptions {
281
290
  /**
282
291
  * Consecutive transient transport failures tolerated before the loop gives
283
- * up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll resets
284
- * the count.
292
+ * up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll
293
+ * resets the count.
285
294
  */
286
295
  readonly maxConsecutivePollFailures?: number;
287
- /** Returns the sleep duration given ms elapsed since polling started. Defaults to {@link defaultPollDelay}. */
296
+ /**
297
+ * Returns the sleep duration given ms elapsed since polling started.
298
+ * Defaults to {@link defaultPollDelay}.
299
+ */
288
300
  readonly pollDelay?: (elapsedMs: number) => number;
289
- /** When aborted, the loop returns {@link PollAbortedError} rather than continuing. */
301
+ /**
302
+ * When aborted, the loop returns {@link PollAbortedError} rather than
303
+ * continuing.
304
+ */
290
305
  readonly signal?: AbortSignal;
291
- /** Total wall-clock budget in ms before the loop returns {@link PollTimeoutError}. */
306
+ /**
307
+ * Total wall-clock budget in ms before the loop returns {@link
308
+ * PollTimeoutError}.
309
+ */
292
310
  readonly timeoutMs?: number;
293
311
  }
294
312
  /**
@@ -309,4 +327,4 @@ interface PollOptions {
309
327
  */
310
328
  //#endregion
311
329
  export { LogPage as a, GetParameters as c, LuauExecutionTaskRef as d, SubmitAtHeadParameters as f, LogMessage as i, InProgressTask as l, defaultPollDelay as n, CompleteTask as o, SubmitAtVersionParameters as p, ListLogsParameters as r, FailedTask as s, PollUntilDoneOptions as t, LuauExecutionTask as u };
312
- //# sourceMappingURL=polling-rj0dGREg.d.mts.map
330
+ //# sourceMappingURL=polling-CG12rHaz.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-CG12rHaz.d.mts","names":[],"sources":["../src/domains/cloud-v2/luau-execution-tasks/types.ts","../src/domains/cloud-v2/luau-execution-task-logs/types.ts","../src/resources/luau-execution/polling.ts"],"mappings":";;;;;;AAOA;;;;UAAiB,sBAAA;;;;;WAKP,WAAA;EAaA;EAAA,SAXA,kBAAA;EAqBV;EAAA,SAnBU,OAAA;;WAEA,MAAA;;;;;WAKA,cAAA;;WAEA,UAAA;AAAA;AA8BA;AAYV;;;;;;AAZU,UApBO,yBAAA;;;;AA0CP;WArCA,WAAA;EA8CO;EAAA,SA5CP,kBAAA;EA8CK;EAAA,SA5CL,OAAA;;WAEA,MAAA;EAgDA;AAAA;AAUV;;EAVU,SA3CA,cAAA;EAqD8B;EAAA,SAnD9B,UAAA;EAgEV;EAAA,SA9DU,S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;AAAA;;;;;;;;;;ADnCA;AAUV;;;;;;;;;;;;iBEsBgB,gBAAA,CAAiB,SAAA;;;;AFiDvB;AAWV;;KE1BY,oBAAA,GAAuB,WAAA,GAAc,cAAA;;UAGvC,WAAA;;;;;;WAMA,0BAAA;;;;;WAKA,SAAA,IAAa,SAAA;EF+BvB;;;;EAAA,SE1BU,MAAA,GAAS,WAAA;;;;;WAKT,SAAA;AAAA;AFgDV;;;;;;;;;;;;AAA4D;AAAA"}
@@ -1,8 +1,8 @@
1
- import { n as NetworkError, r as ApiError } from "./rate-limit-Dh2leqaB.mjs";
2
- import { l as findErrorCode, n as IDEMPOTENT_METHOD_DEFAULTS, r as TRANSIENT_TRANSPORT_CODES, t as CREATE_METHOD_DEFAULTS } from "./retry-CMzwdn1c.mjs";
3
- import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-BfxUWWCZ.mjs";
4
- import { t as ValidationError } from "./validation-xJZRa8tX.mjs";
5
- import { a as isDateTimeString, i as isRecord, n as okRequest } from "./resource-client-CsbYSKwf.mjs";
1
+ import { n as NetworkError, r as ApiError } from "./rate-limit-B20REZEY.mjs";
2
+ import { l as findErrorCode, n as IDEMPOTENT_METHOD_DEFAULTS, r as TRANSIENT_TRANSPORT_CODES, t as CREATE_METHOD_DEFAULTS } from "./retry-PmpgEwFN.mjs";
3
+ import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-DXfJVZzR.mjs";
4
+ import { t as ValidationError } from "./validation-BXhEM3OP.mjs";
5
+ import { a as isRecord, i as toJsonDetails, n as okRequest, o as isDateTimeString } from "./resource-client-rQ9bBn4L.mjs";
6
6
  //#region src/domains/cloud-v2/luau-execution-task-logs/builders.ts
7
7
  /**
8
8
  * Builds a `GET` request for the Open Cloud "list Luau execution session
@@ -21,8 +21,7 @@ import { a as isDateTimeString, i as isRecord, n as okRequest } from "./resource
21
21
  * {@link ValidationError} when the ref is missing `versionId` or
22
22
  * `sessionId`.
23
23
  */
24
- function buildListLogsRequest(parameters) {
25
- const { pageSize, pageToken, ref } = parameters;
24
+ function buildListLogsRequest({ pageSize, pageToken, ref }) {
26
25
  const { placeId, sessionId, taskId, universeId, versionId } = ref;
27
26
  if (versionId === void 0) return {
28
27
  err: new ValidationError("Task ref is missing versionId; cannot list logs", { code: "incomplete_ref" }),
@@ -46,14 +45,18 @@ function buildQuery(pageSize, pageToken) {
46
45
  if (pageToken !== void 0) query.append("pageToken", pageToken);
47
46
  return query;
48
47
  }
48
+ //#endregion
49
+ //#region src/domains/cloud-v2/luau-execution-task-logs/operations.ts
50
+ const LIST_LOGS_PER_MINUTE = 45;
49
51
  /**
50
52
  * Per-second request ceiling for listing Luau execution task logs,
51
53
  * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the
52
54
  * `Cloud_ListLuauExecutionSessionTaskLogs` operation (45 requests per
53
- * minute per API key owner).
55
+ * minute per API key owner), which is also the burst the server allows.
54
56
  */
55
57
  const LIST_LOGS_OPERATION_LIMIT = Object.freeze({
56
- maxPerSecond: 45 / 60,
58
+ burstCapacity: LIST_LOGS_PER_MINUTE,
59
+ maxPerSecond: LIST_LOGS_PER_MINUTE / 60,
57
60
  operationKey: "luau-execution-task-logs.list"
58
61
  });
59
62
  /**
@@ -78,8 +81,7 @@ const MALFORMED_LOGS_MESSAGE = "Malformed list-luau-execution-task-logs response
78
81
  * @returns A success result wrapping the parsed {@link LogPage}, or an
79
82
  * {@link ApiError} when the body does not match a supported shape.
80
83
  */
81
- function parseListLogsResponse(response) {
82
- const { body, status: statusCode } = response;
84
+ function parseListLogsResponse({ body, status: statusCode }) {
83
85
  if (!isRecord(body)) return malformed$1(statusCode, body);
84
86
  const rawChunks = body["luauExecutionSessionTaskLogs"] ?? void 0;
85
87
  if (!isOptionalLogChunks(rawChunks)) return malformed$1(statusCode, body);
@@ -121,7 +123,7 @@ function isOptionalLogChunks(value) {
121
123
  function malformed$1(statusCode, body) {
122
124
  return {
123
125
  err: new ApiError(MALFORMED_LOGS_MESSAGE, {
124
- details: body,
126
+ details: toJsonDetails(body),
125
127
  statusCode
126
128
  }),
127
129
  success: false
@@ -202,8 +204,7 @@ function buildSubmitAtVersionRequest(parameters) {
202
204
  * {@link ValidationError} when the ref is missing `versionId` or
203
205
  * `sessionId`.
204
206
  */
205
- function buildGetRequest(parameters) {
206
- const { ref, view } = parameters;
207
+ function buildGetRequest({ ref, view }) {
207
208
  const { placeId, sessionId, taskId, universeId, versionId } = ref;
208
209
  if (versionId === void 0) return {
209
210
  err: new ValidationError("Task ref is missing versionId; cannot GET", { code: "incomplete_ref" }),
@@ -222,8 +223,7 @@ function buildGetRequest(parameters) {
222
223
  success: true
223
224
  };
224
225
  }
225
- function buildSubmitBody(parameters) {
226
- const { binaryInput, enableBinaryOutput: shouldEnableBinaryOutput, script, timeoutSeconds } = parameters;
226
+ function buildSubmitBody({ binaryInput, enableBinaryOutput: shouldEnableBinaryOutput, script, timeoutSeconds }) {
227
227
  const body = { script };
228
228
  if (timeoutSeconds !== void 0) body["timeout"] = `${timeoutSeconds}s`;
229
229
  if (binaryInput !== void 0) body["binaryInput"] = binaryInput;
@@ -239,11 +239,12 @@ const SECONDS_PER_MINUTE = 60;
239
239
  * Per-second request ceiling for submitting a Luau execution task,
240
240
  * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the
241
241
  * `Cloud_CreateLuauExecutionSessionTask__Using_Universes` operation
242
- * (40 requests per minute per API key owner). The two URL shapes
243
- * (head and version) share this queue because Roblox attributes both
244
- * to the same per-minute quota.
242
+ * (40 requests per minute per API key owner), which is also the burst
243
+ * the server allows. The two URL shapes (head and version) share this
244
+ * queue because Roblox attributes both to the same per-minute quota.
245
245
  */
246
246
  const SUBMIT_OPERATION_LIMIT = Object.freeze({
247
+ burstCapacity: SUBMIT_PER_MINUTE,
247
248
  maxPerSecond: SUBMIT_PER_MINUTE / SECONDS_PER_MINUTE,
248
249
  operationKey: "luau-execution-tasks.submit"
249
250
  });
@@ -288,8 +289,7 @@ const PATH_PATTERN = /^universes\/(\d+)\/places\/(\d+)(?:\/versions\/(\d+))?(?:\
288
289
  * {@link ApiError} when the body or path do not match a supported
289
290
  * shape.
290
291
  */
291
- function parseLuauExecutionTaskResponse(response) {
292
- const { body, status: statusCode } = response;
292
+ function parseLuauExecutionTaskResponse({ body, status: statusCode }) {
293
293
  if (!isLuauExecutionTaskWire(body)) return malformed(statusCode, body);
294
294
  const ref = parseTaskRef(body.path);
295
295
  if (ref === void 0) return malformed(statusCode, body);
@@ -368,14 +368,13 @@ function parseTimeoutSeconds(value) {
368
368
  function malformed(statusCode, body) {
369
369
  return {
370
370
  err: new ApiError(MALFORMED_TASK_MESSAGE, {
371
- details: body,
371
+ details: toJsonDetails(body),
372
372
  statusCode
373
373
  }),
374
374
  success: false
375
375
  };
376
376
  }
377
- function parseInProgressTask(args) {
378
- const { body, createdAt, ref, state, timeoutSeconds, updatedAt } = args;
377
+ function parseInProgressTask({ body, createdAt, ref, state, timeoutSeconds, updatedAt }) {
379
378
  return {
380
379
  data: {
381
380
  binaryInput: body.binaryInput,
@@ -391,8 +390,7 @@ function parseInProgressTask(args) {
391
390
  success: true
392
391
  };
393
392
  }
394
- function parseCompleteTask(args) {
395
- const { body, createdAt, ref, statusCode, timeoutSeconds, updatedAt } = args;
393
+ function parseCompleteTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt }) {
396
394
  if (body.output === void 0) return malformed(statusCode, body);
397
395
  return {
398
396
  data: {
@@ -410,8 +408,7 @@ function parseCompleteTask(args) {
410
408
  success: true
411
409
  };
412
410
  }
413
- function parseFailedTask(args) {
414
- const { body, createdAt, ref, statusCode, timeoutSeconds, updatedAt } = args;
411
+ function parseFailedTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt }) {
415
412
  if (body.error === void 0) return malformed(statusCode, body);
416
413
  return {
417
414
  data: {
@@ -567,7 +564,7 @@ const ABORTED = Symbol("poll-aborted");
567
564
  * @param options - Optional poll delay, timeout, failure cap, and abort signal.
568
565
  * @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.
569
566
  */
570
- async function pollUntilDoneCore(deps, options = {}) {
567
+ async function pollUntilDoneCoreAsync(deps, options = {}) {
571
568
  const timeoutMs = options.timeoutMs ?? 3e5;
572
569
  const pollDelay = options.pollDelay ?? defaultPollDelay;
573
570
  const maxFailures = options.maxConsecutivePollFailures ?? 3;
@@ -584,14 +581,14 @@ async function pollUntilDoneCore(deps, options = {}) {
584
581
  err: makeTimeout(state.lastTask, timeoutMs),
585
582
  success: false
586
583
  };
587
- const action = applyOutcome(await fetchOnce(deps, sig), {
584
+ const action = applyOutcome(await fetchOnceAsync(deps, sig), {
588
585
  maxFailures,
589
586
  signal: sig,
590
587
  state
591
588
  });
592
589
  if (action.kind === "return") return action.result;
593
590
  ({state} = action);
594
- if (await sleepWithAbort({
591
+ if (await sleepWithAbortAsync({
595
592
  ms: pollDelay(elapsedMs),
596
593
  signal: sig,
597
594
  sleep: deps.sleep
@@ -617,8 +614,7 @@ function abortedResult(signal) {
617
614
  * @param context - The loop state, failure cap, and abort signal.
618
615
  * @returns Whether to return a final Result or continue with updated state.
619
616
  */
620
- function applyOutcome(outcome, context) {
621
- const { maxFailures, signal, state } = context;
617
+ function applyOutcome(outcome, { maxFailures, signal, state }) {
622
618
  switch (outcome.kind) {
623
619
  case "aborted": return {
624
620
  kind: "return",
@@ -678,7 +674,7 @@ function abortObserver(signal) {
678
674
  promise
679
675
  };
680
676
  }
681
- async function raceWithAbort(promise, signal) {
677
+ async function raceWithAbortAsync(promise, signal) {
682
678
  if (signal === void 0) return promise;
683
679
  if (signal.aborted) return ABORTED;
684
680
  const observer = abortObserver(signal);
@@ -688,9 +684,8 @@ async function raceWithAbort(promise, signal) {
688
684
  observer.cleanup();
689
685
  }
690
686
  }
691
- async function sleepWithAbort(options) {
692
- const { ms, signal, sleep } = options;
693
- return await raceWithAbort(sleep(ms), signal) === ABORTED;
687
+ async function sleepWithAbortAsync({ ms, signal, sleep }) {
688
+ return await raceWithAbortAsync(sleep(ms), signal) === ABORTED;
694
689
  }
695
690
  function makeTimeout(task, timeoutMs) {
696
691
  return new PollTimeoutError(`Polling timed out after ${timeoutMs} ms`, {
@@ -719,8 +714,8 @@ function isTransientTransport(error) {
719
714
  const code = findErrorCode(error);
720
715
  return code !== void 0 && TRANSIENT_TRANSPORT_CODES.includes(code);
721
716
  }
722
- async function fetchOnce(dependencies, signal) {
723
- const fetchResult = await raceWithAbort(dependencies.fetch(), signal);
717
+ async function fetchOnceAsync(dependencies, signal) {
718
+ const fetchResult = await raceWithAbortAsync(dependencies.fetch(), signal);
724
719
  if (fetchResult === ABORTED) return { kind: "aborted" };
725
720
  if (!fetchResult.success) return isTransientTransport(fetchResult.err) ? {
726
721
  error: fetchResult.err,
@@ -740,9 +735,9 @@ async function fetchOnce(dependencies, signal) {
740
735
  //#endregion
741
736
  //#region src/resources/luau-execution/polling-helpers.ts
742
737
  /**
743
- * Builds the {@link PollDependencies} bundle used by {@link pollUntilDoneCore},
744
- * closing over the supplied {@link ResourceClient}, task ref, and
745
- * per-request options so the core loop stays narrow.
738
+ * Builds the {@link PollDependencies} bundle used by {@link
739
+ * pollUntilDoneCoreAsync}, closing over the supplied {@link ResourceClient},
740
+ * task ref, and per-request options so the core loop stays narrow.
746
741
  *
747
742
  * @param inner - The {@link ResourceClient} that issues each `tasks.get` call.
748
743
  * @param args - The polling options and the task ref to fetch on every iteration.
@@ -751,7 +746,7 @@ async function fetchOnce(dependencies, signal) {
751
746
  function buildPollDependencies(inner, args) {
752
747
  return {
753
748
  fetch: async () => {
754
- return inner.execute({
749
+ return inner.executeAsync({
755
750
  options: args.options,
756
751
  parameters: {
757
752
  ref: args.ref,
@@ -765,33 +760,32 @@ function buildPollDependencies(inner, args) {
765
760
  };
766
761
  }
767
762
  /**
768
- * Submits a Luau execution task and polls it to a terminal state.
769
- * Dispatches to the head-version or specific-version submit spec based on
770
- * the presence of `versionId`, then delegates to {@link pollUntilDoneCore}.
763
+ * Submits a Luau execution task and polls it to a terminal state. Dispatches
764
+ * to the head-version or specific-version submit spec based on the presence of
765
+ * `versionId`, then delegates to {@link pollUntilDoneCoreAsync}.
771
766
  *
772
767
  * @param inner - The {@link ResourceClient} that issues submit and poll calls.
773
768
  * @param args - The polling options and submit parameters.
774
769
  * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask}, or
775
770
  * the {@link OpenCloudError} that caused submit or polling to fail.
776
771
  */
777
- async function submitAndPoll(inner, args) {
778
- const { options, parameters } = args;
779
- const submitResult = await ("versionId" in parameters ? inner.execute({
772
+ async function submitAndPollAsync(inner, { options, parameters }) {
773
+ const submitResult = await ("versionId" in parameters ? inner.executeAsync({
780
774
  options,
781
775
  parameters,
782
776
  spec: SUBMIT_VERSION_SPEC
783
- }) : inner.execute({
777
+ }) : inner.executeAsync({
784
778
  options,
785
779
  parameters,
786
780
  spec: SUBMIT_HEAD_SPEC
787
781
  }));
788
782
  if (!submitResult.success) return submitResult;
789
- return pollUntilDoneCore(buildPollDependencies(inner, {
783
+ return pollUntilDoneCoreAsync(buildPollDependencies(inner, {
790
784
  options,
791
785
  ref: submitResult.data.ref
792
786
  }), options);
793
787
  }
794
788
  //#endregion
795
- export { withBudgetRequestTimeout as a, SUBMIT_VERSION_SPEC as c, pollUntilDoneCore as i, LIST_LOGS_SPEC as l, submitAndPoll as n, GET_SPEC as o, defaultPollDelay as r, SUBMIT_HEAD_SPEC as s, buildPollDependencies as t };
789
+ export { withBudgetRequestTimeout as a, SUBMIT_VERSION_SPEC as c, pollUntilDoneCoreAsync as i, LIST_LOGS_SPEC as l, submitAndPollAsync as n, GET_SPEC as o, defaultPollDelay as r, SUBMIT_HEAD_SPEC as s, buildPollDependencies as t };
796
790
 
797
- //# sourceMappingURL=polling-helpers-DkJcWZpp.mjs.map
791
+ //# sourceMappingURL=polling-helpers-SBN188o5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-helpers-SBN188o5.mjs","names":["SECONDS_PER_MINUTE","malformed","makeSpec"],"sources":["../src/domains/cloud-v2/luau-execution-task-logs/builders.ts","../src/domains/cloud-v2/luau-execution-task-logs/operations.ts","../src/domains/cloud-v2/luau-execution-task-logs/parsers.ts","../src/domains/cloud-v2/luau-execution-task-logs/specs.ts","../src/domains/cloud-v2/luau-execution-tasks/builders.ts","../src/domains/cloud-v2/luau-execution-tasks/operations.ts","../src/domains/cloud-v2/luau-execution-tasks/parsers.ts","../src/domains/cloud-v2/luau-execution-tasks/specs.ts","../src/resources/luau-execution/polling.ts","../src/resources/luau-execution/polling-helpers.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { ListLogsParameters } from \"./types.ts\";\n\n/**\n * Builds a `GET` request for the Open Cloud \"list Luau execution session\n * task logs\" endpoint. The endpoint requires the maximal x-aep-resource\n * path shape (universe, place, version, session, task), so the supplied\n * ref must include `versionId` and `sessionId`; refs extracted from the\n * narrower path formats are rejected with a {@link ValidationError}.\n *\n * The `view` query parameter is hard-coded to `STRUCTURED` so callers\n * always receive typed structured messages. No public `view` parameter\n * is exposed.\n *\n * @param parameters - Task ref, and optional `pageSize` and `pageToken`\n * pagination controls.\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when the ref is missing `versionId` or\n * `sessionId`.\n */\nexport function buildListLogsRequest({\n\tpageSize,\n\tpageToken,\n\tref,\n}: ListLogsParameters): Result<HttpRequest, ValidationError> {\n\tconst { placeId, sessionId, taskId, universeId, versionId } = ref;\n\n\tif (versionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing versionId; cannot list logs\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tif (sessionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing sessionId; cannot list logs\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst base = `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-sessions/${sessionId}/tasks/${taskId}/logs`;\n\tconst url = `${base}?${buildQuery(pageSize, pageToken).toString()}`;\n\treturn { data: { method: \"GET\", url }, success: true };\n}\n\nfunction buildQuery(pageSize: number | undefined, pageToken: string | undefined): URLSearchParams {\n\tconst query = new URLSearchParams({ view: \"STRUCTURED\" });\n\n\tif (pageSize !== undefined) {\n\t\tquery.append(\"maxPageSize\", String(pageSize));\n\t}\n\n\tif (pageToken !== undefined) {\n\t\tquery.append(\"pageToken\", pageToken);\n\t}\n\n\treturn query;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst LIST_LOGS_PER_MINUTE = 45;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for listing Luau execution task logs,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_ListLuauExecutionSessionTaskLogs` operation (45 requests per\n * minute per API key owner), which is also the burst the server allows.\n */\nexport const LIST_LOGS_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: LIST_LOGS_PER_MINUTE,\n\tmaxPerSecond: LIST_LOGS_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-task-logs.list\",\n});\n\n/**\n * Scopes required to list Luau execution task logs, sourced from\n * `x-roblox-scopes` on the list-logs operation in the vendored OpenAPI\n * schema. Surfaced via the `requiredScopes` field of the per-method\n * spec so a 401 or 403 ApiError is upgraded to a `PermissionError`\n * naming the missing scope. Only `:read` is required as the\n * minimum-privilege scope for this read-only operation.\n */\nexport const LIST_LOGS_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:read\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { 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 { LogMessage, LogPage } from \"./types.ts\";\nimport type { LogChunkWire, LogMessageWire } from \"./wire.ts\";\n\nconst MALFORMED_LOGS_MESSAGE = \"Malformed list-luau-execution-task-logs response\";\n\n/**\n * Parses a successful Open Cloud list-luau-execution-task-logs response\n * body into the public {@link LogPage} shape. Chunks are flattened into\n * a single ordered array of {@link LogMessage} values. The\n * `MESSAGE_TYPE_UNSPECIFIED` sentinel is rejected.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * @returns A success result wrapping the parsed {@link LogPage}, or an\n * {@link ApiError} when the body does not match a supported shape.\n */\nexport function parseListLogsResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LogPage, ApiError> {\n\tif (!isRecord(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst rawChunks = body[\"luauExecutionSessionTaskLogs\"] ?? undefined;\n\tif (!isOptionalLogChunks(rawChunks)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst rawToken = body[\"nextPageToken\"] ?? undefined;\n\tif (rawToken !== undefined && typeof rawToken !== \"string\") {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst messages: Array<LogMessage> = [];\n\tconst chunks = rawChunks ?? [];\n\tfor (const chunk of chunks) {\n\t\tconst wireMessages = chunk.structuredMessages ?? [];\n\t\tfor (const wireMessage of wireMessages) {\n\t\t\tmessages.push({\n\t\t\t\tcreateTime: wireMessage.createTime,\n\t\t\t\tmessage: wireMessage.message,\n\t\t\t\tmessageType: wireMessage.messageType,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn {\n\t\tdata: { messages, nextPageToken: rawToken },\n\t\tsuccess: true,\n\t};\n}\n\nfunction isAcceptedMessageType(value: unknown): value is LogMessageWire[\"messageType\"] {\n\treturn value === \"OUTPUT\" || value === \"INFO\" || value === \"WARNING\" || value === \"ERROR\";\n}\n\nfunction isLogMessageWire(value: unknown): value is LogMessageWire {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value[\"createTime\"] === \"string\" &&\n\t\ttypeof value[\"message\"] === \"string\" &&\n\t\tisAcceptedMessageType(value[\"messageType\"])\n\t);\n}\n\nfunction isOptionalStructuredMessages(\n\tvalue: unknown,\n): value is ReadonlyArray<LogMessageWire> | undefined {\n\treturn (\n\t\tvalue === undefined ||\n\t\t(Array.isArray(value) && value.every((item: unknown) => isLogMessageWire(item)))\n\t);\n}\n\nfunction isLogChunkWire(value: unknown): value is LogChunkWire {\n\treturn isRecord(value) && isOptionalStructuredMessages(value[\"structuredMessages\"]);\n}\n\nfunction isOptionalLogChunks(value: unknown): value is ReadonlyArray<LogChunkWire> | undefined {\n\treturn (\n\t\tvalue === undefined ||\n\t\t(Array.isArray(value) && value.every((item: unknown) => isLogChunkWire(item)))\n\t);\n}\n\nfunction malformed(statusCode: number, body: unknown): Result<LogPage, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_LOGS_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n","import { IDEMPOTENT_METHOD_DEFAULTS } from \"../../../internal/http/retry.ts\";\nimport type { ResourceMethodSpec } from \"../../../internal/resource-client.ts\";\nimport { buildListLogsRequest } from \"./builders.ts\";\nimport { LIST_LOGS_OPERATION_LIMIT, LIST_LOGS_REQUIRED_SCOPES } from \"./operations.ts\";\nimport { parseListLogsResponse } from \"./parsers.ts\";\nimport type { ListLogsParameters, LogPage } from \"./types.ts\";\n\nfunction makeSpec<P>(spec: ResourceMethodSpec<P, LogPage>): ResourceMethodSpec<P, LogPage> {\n\treturn Object.freeze(spec);\n}\n\n/**\n * Per-method dispatch spec for listing the structured log messages\n * produced by a Luau execution task. Frozen at module scope so both\n * the top-level `LuauExecutionClient` and the `luauExecution` Operation\n * Group on `PlacesClient` share the same instance reference.\n */\nexport const LIST_LOGS_SPEC = makeSpec<ListLogsParameters>({\n\tbuildRequest: buildListLogsRequest,\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: LIST_LOGS_OPERATION_LIMIT,\n\tparse: parseListLogsResponse,\n\trequiredScopes: LIST_LOGS_REQUIRED_SCOPES,\n});\n","import type { HttpRequest } from \"../../../client/types.ts\";\nimport { ValidationError } from \"../../../errors/validation.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { GetParameters, SubmitAtHeadParameters, SubmitAtVersionParameters } from \"./types.ts\";\n\ninterface SubmitBodyInput {\n\treadonly binaryInput?: string | undefined;\n\treadonly enableBinaryOutput?: boolean | undefined;\n\treadonly script: string;\n\treadonly timeoutSeconds?: number;\n}\n\nconst JSON_HEADERS: Readonly<Record<string, string>> = { \"content-type\": \"application/json\" };\n\n/**\n * Builds a `POST` request for the Open Cloud \"create Luau execution\n * session task\" endpoint, targeting the place's head version. Serializes\n * `timeoutSeconds` into the wire's duration string format (`\"<n>s\"`)\n * when supplied.\n *\n * @param parameters - Universe and place identifiers, the script body,\n * and an optional `timeoutSeconds`.\n * @returns A pure {@link HttpRequest} describing the submit call.\n */\nexport function buildSubmitAtHeadRequest(parameters: SubmitAtHeadParameters): HttpRequest {\n\tconst { placeId, universeId } = parameters;\n\treturn {\n\t\tbody: buildSubmitBody(parameters),\n\t\theaders: JSON_HEADERS,\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}/luau-execution-session-tasks`,\n\t};\n}\n\n/**\n * Builds a `POST` request for the Open Cloud \"create Luau execution\n * session task\" endpoint, targeting a specific place version. Differs\n * from {@link buildSubmitAtHeadRequest} only in URL shape: the path\n * includes the `versions/{versionId}` segment so the script runs\n * against that exact place version instead of the live head.\n *\n * @param parameters - Universe, place, and version identifiers, the\n * script body, and an optional `timeoutSeconds`.\n * @returns A pure {@link HttpRequest} describing the submit call.\n */\nexport function buildSubmitAtVersionRequest(parameters: SubmitAtVersionParameters): HttpRequest {\n\tconst { placeId, universeId, versionId } = parameters;\n\treturn {\n\t\tbody: buildSubmitBody(parameters),\n\t\theaders: JSON_HEADERS,\n\t\tmethod: \"POST\",\n\t\turl: `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-session-tasks`,\n\t};\n}\n\n/**\n * Builds a `GET` request for the Open Cloud \"read Luau execution session\n * task\" endpoint. The endpoint accepts only the maximal x-aep-resource\n * path shape (universe, place, version, session, task), so the supplied\n * ref must include `versionId` and `sessionId`; refs extracted from the\n * narrower path formats are rejected with a {@link ValidationError}.\n *\n * @param parameters - Task ref and optional view selector. When `view`\n * is omitted, no `?view=` query is sent and the server applies its\n * own default (`BASIC`).\n * @returns A success result wrapping the request, or a\n * {@link ValidationError} when the ref is missing `versionId` or\n * `sessionId`.\n */\nexport function buildGetRequest({\n\tref,\n\tview,\n}: GetParameters): Result<HttpRequest, ValidationError> {\n\tconst { placeId, sessionId, taskId, universeId, versionId } = ref;\n\n\tif (versionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing versionId; cannot GET\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tif (sessionId === undefined) {\n\t\treturn {\n\t\t\terr: new ValidationError(\"Task ref is missing sessionId; cannot GET\", {\n\t\t\t\tcode: \"incomplete_ref\",\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst base = `/cloud/v2/universes/${universeId}/places/${placeId}/versions/${versionId}/luau-execution-sessions/${sessionId}/tasks/${taskId}`;\n\tconst url = view === undefined ? base : `${base}?view=${view}`;\n\treturn { data: { method: \"GET\", url }, success: true };\n}\n\nfunction buildSubmitBody({\n\tbinaryInput,\n\tenableBinaryOutput: shouldEnableBinaryOutput,\n\tscript,\n\ttimeoutSeconds,\n}: SubmitBodyInput): Record<string, unknown> {\n\tconst body: Record<string, unknown> = { script };\n\tif (timeoutSeconds !== undefined) {\n\t\tbody[\"timeout\"] = `${timeoutSeconds}s`;\n\t}\n\n\tif (binaryInput !== undefined) {\n\t\tbody[\"binaryInput\"] = binaryInput;\n\t}\n\n\tif (shouldEnableBinaryOutput !== undefined) {\n\t\tbody[\"enableBinaryOutput\"] = shouldEnableBinaryOutput;\n\t}\n\n\treturn body;\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\nconst SUBMIT_PER_MINUTE = 40;\nconst GET_PER_MINUTE = 200;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for submitting a Luau execution task,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTask__Using_Universes` operation\n * (40 requests per minute per API key owner), which is also the burst\n * the server allows. The two URL shapes (head and version) share this\n * queue because Roblox attributes both to the same per-minute quota.\n */\nexport const SUBMIT_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: SUBMIT_PER_MINUTE,\n\tmaxPerSecond: SUBMIT_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.submit\",\n});\n\n/**\n * Per-second request ceiling for fetching a Luau execution task,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_GetLuauExecutionSessionTask` operation (200 requests per\n * minute per API key owner).\n */\nexport const GET_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: GET_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.get\",\n});\n\n/**\n * Scopes required to submit a Luau execution task, sourced from\n * `x-roblox-scopes` on the create operation in the vendored OpenAPI\n * schema. Surfaced via the `requiredScopes` field of the per-method\n * spec so a 401 or 403 ApiError is upgraded to a `PermissionError`\n * naming the missing scope.\n */\nexport const SUBMIT_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:write\",\n]);\n\n/**\n * Scopes required to fetch a Luau execution task, sourced from\n * `x-roblox-scopes` on the get operation. The `:write` scope also\n * grants read in upstream auth, but we surface only `:read` here as\n * the minimum-privilege requirement for this method.\n */\nexport const GET_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:read\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { 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 { LuauExecutionTask, LuauExecutionTaskRef } from \"./types.ts\";\nimport type {\n\tLuauExecutionTaskErrorWire,\n\tLuauExecutionTaskOutputWire,\n\tLuauExecutionTaskWire,\n} from \"./wire.ts\";\n\nconst MALFORMED_TASK_MESSAGE = \"Malformed luau-execution-session-task response\";\n\n// Matches any of the four x-aep-resource path formats for a luau\n// execution session task.\n//\n// Capture groups:\n// 1. universeId\n// 2. placeId\n// 3. versionId (when `/versions/{v}/` segment is present, else undefined)\n// 4. sessionId (when `/luau-execution-sessions/{s}/tasks/...` branch matched)\n// 5. taskId (when `/luau-execution-sessions/.../tasks/{t}` branch matched)\n// 6. taskId (when `/luau-execution-session-tasks/{t}` branch matched)\nconst PATH_PATTERN =\n\t/^universes\\/(\\d+)\\/places\\/(\\d+)(?:\\/versions\\/(\\d+))?(?:\\/luau-execution-sessions\\/([^/]+)\\/tasks\\/([^/]+)|\\/luau-execution-session-tasks\\/([^/]+))$/;\n\ntype InProgressWireState = Exclude<LuauExecutionTaskWire[\"state\"], \"COMPLETE\" | \"FAILED\">;\n\ninterface ParseVariantArgs {\n\treadonly body: LuauExecutionTaskWire;\n\treadonly createdAt: Date | undefined;\n\treadonly ref: LuauExecutionTaskRef;\n\treadonly statusCode: number;\n\treadonly timeoutSeconds: number | undefined;\n\treadonly updatedAt: Date | undefined;\n}\n\n/**\n * Parses a successful Open Cloud `LuauExecutionSessionTask` response\n * body into the public {@link LuauExecutionTask} discriminated union.\n * Handles every supported task state (in-progress, COMPLETE, FAILED)\n * across all four x-aep-resource path shapes the server returns.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud\n * API.\n * @returns A success result wrapping the parsed task, or an\n * {@link ApiError} when the body or path do not match a supported\n * shape.\n */\nexport function parseLuauExecutionTaskResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<LuauExecutionTask, ApiError> {\n\tif (!isLuauExecutionTaskWire(body)) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst ref = parseTaskRef(body.path);\n\tif (ref === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\tconst timeoutSeconds = parseTimeoutSeconds(body.timeout);\n\tconst createdAt = parseOptionalDate(body.createTime);\n\tconst updatedAt = parseOptionalDate(body.updateTime);\n\n\tif (body.state === \"COMPLETE\") {\n\t\treturn parseCompleteTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt });\n\t}\n\n\tif (body.state === \"FAILED\") {\n\t\treturn parseFailedTask({ body, createdAt, ref, statusCode, timeoutSeconds, updatedAt });\n\t}\n\n\treturn parseInProgressTask({\n\t\tbody,\n\t\tcreatedAt,\n\t\tref,\n\t\tstate: body.state,\n\t\tstatusCode,\n\t\ttimeoutSeconds,\n\t\tupdatedAt,\n\t});\n}\n\nfunction isAcceptedWireState(\n\tstate: unknown,\n): state is \"CANCELLED\" | \"COMPLETE\" | \"FAILED\" | \"PROCESSING\" | \"QUEUED\" {\n\treturn (\n\t\tstate === \"QUEUED\" ||\n\t\tstate === \"PROCESSING\" ||\n\t\tstate === \"CANCELLED\" ||\n\t\tstate === \"COMPLETE\" ||\n\t\tstate === \"FAILED\"\n\t);\n}\n\nfunction isErrorWireCode(code: unknown): code is LuauExecutionTaskErrorWire[\"code\"] {\n\treturn (\n\t\tcode === \"SCRIPT_ERROR\" ||\n\t\tcode === \"DEADLINE_EXCEEDED\" ||\n\t\tcode === \"OUTPUT_SIZE_LIMIT_EXCEEDED\" ||\n\t\tcode === \"INTERNAL_ERROR\"\n\t);\n}\n\nfunction isErrorWire(value: unknown): value is LuauExecutionTaskErrorWire {\n\treturn (\n\t\tisRecord(value) && isErrorWireCode(value[\"code\"]) && typeof value[\"message\"] === \"string\"\n\t);\n}\n\nfunction isOptionalErrorWire(value: unknown): value is LuauExecutionTaskErrorWire | undefined {\n\treturn value === undefined || isErrorWire(value);\n}\n\nfunction isOutputWire(value: unknown): value is LuauExecutionTaskOutputWire {\n\treturn isRecord(value) && Array.isArray(value[\"results\"]);\n}\n\nfunction isOptionalOutputWire(value: unknown): value is LuauExecutionTaskOutputWire | undefined {\n\treturn value === undefined || isOutputWire(value);\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n\treturn value === undefined || typeof value === \"string\";\n}\n\nfunction isOptionalBoolean(value: unknown): value is boolean | undefined {\n\treturn value === undefined || typeof value === \"boolean\";\n}\n\nfunction isOptionalDateTimeString(value: unknown): value is string | undefined {\n\treturn value === undefined || isDateTimeString(value);\n}\n\nfunction isLuauExecutionTaskWire(body: unknown): body is LuauExecutionTaskWire {\n\treturn (\n\t\tisRecord(body) &&\n\t\ttypeof body[\"path\"] === \"string\" &&\n\t\tisOptionalDateTimeString(body[\"createTime\"]) &&\n\t\tisOptionalDateTimeString(body[\"updateTime\"]) &&\n\t\tisAcceptedWireState(body[\"state\"]) &&\n\t\ttypeof body[\"user\"] === \"string\" &&\n\t\tisOptionalOutputWire(body[\"output\"]) &&\n\t\tisOptionalErrorWire(body[\"error\"]) &&\n\t\tisOptionalDurationWire(body[\"timeout\"]) &&\n\t\tisOptionalString(body[\"binaryInput\"]) &&\n\t\tisOptionalBoolean(body[\"enableBinaryOutput\"]) &&\n\t\tisOptionalString(body[\"binaryOutputUri\"])\n\t);\n}\n\nfunction parseOptionalDate(value: string | undefined): Date | undefined {\n\treturn value === undefined ? undefined : new Date(value);\n}\n\nconst DURATION_PATTERN = /^(\\d+)s$/;\n\nfunction isOptionalDurationWire(value: unknown): value is string | undefined {\n\treturn value === undefined || (typeof value === \"string\" && DURATION_PATTERN.test(value));\n}\n\nfunction parseTimeoutSeconds(value: string | undefined): number | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst match = DURATION_PATTERN.exec(value);\n\tconst seconds = match?.[1];\n\tif (seconds === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn Number.parseInt(seconds, 10);\n}\n\nfunction malformed(statusCode: number, body: unknown): Result<LuauExecutionTask, ApiError> {\n\treturn {\n\t\terr: new ApiError(MALFORMED_TASK_MESSAGE, {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n\nfunction parseInProgressTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstate,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs & { readonly state: InProgressWireState }): Result<\n\tLuauExecutionTask,\n\tApiError\n> {\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\tref,\n\t\t\tstate,\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseCompleteTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstatusCode,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs): Result<LuauExecutionTask, ApiError> {\n\tif (body.output === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\toutput: { results: body.output.results },\n\t\t\tref,\n\t\t\tstate: \"COMPLETE\",\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseFailedTask({\n\tbody,\n\tcreatedAt,\n\tref,\n\tstatusCode,\n\ttimeoutSeconds,\n\tupdatedAt,\n}: ParseVariantArgs): Result<LuauExecutionTask, ApiError> {\n\tif (body.error === undefined) {\n\t\treturn malformed(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tbinaryInput: body.binaryInput,\n\t\t\tbinaryOutputUri: body.binaryOutputUri,\n\t\t\tcreatedAt,\n\t\t\tenableBinaryOutput: body.enableBinaryOutput,\n\t\t\terror: { code: body.error.code, message: body.error.message },\n\t\t\tref,\n\t\t\tstate: \"FAILED\",\n\t\t\ttimeoutSeconds,\n\t\t\tupdatedAt,\n\t\t\tuser: body.user,\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction parseTaskRef(path: string): LuauExecutionTaskRef | undefined {\n\tconst match = PATH_PATTERN.exec(path);\n\tif (match === null) {\n\t\treturn undefined;\n\t}\n\n\tconst [, universeId, placeId, versionId, sessionId, sessionTaskId, plainTaskId] = match;\n\tconst taskId = sessionTaskId ?? plainTaskId;\n\tif (universeId === undefined || placeId === undefined || taskId === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn { placeId, sessionId, taskId, universeId, versionId };\n}\n","import {\n\tCREATE_METHOD_DEFAULTS,\n\tIDEMPOTENT_METHOD_DEFAULTS,\n} from \"../../../internal/http/retry.ts\";\nimport { okRequest, type ResourceMethodSpec } from \"../../../internal/resource-client.ts\";\nimport {\n\tbuildGetRequest,\n\tbuildSubmitAtHeadRequest,\n\tbuildSubmitAtVersionRequest,\n} from \"./builders.ts\";\nimport {\n\tGET_OPERATION_LIMIT,\n\tGET_REQUIRED_SCOPES,\n\tSUBMIT_OPERATION_LIMIT,\n\tSUBMIT_REQUIRED_SCOPES,\n} from \"./operations.ts\";\nimport { parseLuauExecutionTaskResponse } from \"./parsers.ts\";\nimport type {\n\tGetParameters,\n\tLuauExecutionTask,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"./types.ts\";\n\nfunction makeSpec<P>(\n\tspec: ResourceMethodSpec<P, LuauExecutionTask>,\n): ResourceMethodSpec<P, LuauExecutionTask> {\n\treturn Object.freeze(spec);\n}\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * place's head version. Frozen at module scope so both the top-level\n * `LuauExecutionClient` and the `luauExecution` Operation Group on\n * `PlacesClient` share the same instance reference.\n */\nexport const SUBMIT_HEAD_SPEC = makeSpec<SubmitAtHeadParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtHeadRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * specific place version. Shares the rate-limit queue and required\n * scope set with {@link SUBMIT_HEAD_SPEC} because Roblox attributes\n * both URL shapes to one per-minute quota.\n */\nexport const SUBMIT_VERSION_SPEC = makeSpec<SubmitAtVersionParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtVersionRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for fetching a Luau execution task. Uses\n * idempotent retry semantics (429 and 5xx both retried) so reads\n * recover transparently from transient server errors.\n */\nexport const GET_SPEC = makeSpec<GetParameters>({\n\tbuildRequest: buildGetRequest,\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: GET_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: GET_REQUIRED_SCOPES,\n});\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport type { LuauExecutionTask } from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { NetworkError } from \"../../errors/network-error.ts\";\nimport { PollAbortedError } from \"../../errors/poll-aborted.ts\";\nimport { PollTimeoutError } from \"../../errors/poll-timeout.ts\";\nimport { TRANSIENT_TRANSPORT_CODES } from \"../../internal/http/retry.ts\";\nimport { findErrorCode } from \"../../internal/utils/find-error-code.ts\";\nimport type { SleepFunc } from \"../../internal/utils/sleep.ts\";\nimport type { Result } from \"../../types.ts\";\n\n/** Default total polling budget in milliseconds (5 minutes). */\nexport const DEFAULT_POLL_TIMEOUT_MS = 300_000;\n\n/** One step of the default poll-cadence schedule. */\ninterface PollDelayTier {\n\t/** Delay in ms to wait between polls while within this tier. */\n\treadonly delayMs: number;\n\t/**\n\t * Upper elapsed-time bound (exclusive) at which this tier stops applying.\n\t */\n\treadonly untilMs: number;\n}\n\n/** Steady-state delay once elapsed time reaches the final tier bound. */\nconst STEADY_POLL_DELAY_MS = 5_000;\n\n/**\n * Fast-to-slow poll-cadence tiers keyed on elapsed wall-clock time. Elapsed\n * times at or beyond the last `untilMs` fall through to\n * {@link STEADY_POLL_DELAY_MS}.\n */\nconst DEFAULT_POLL_TIERS: ReadonlyArray<PollDelayTier> = [\n\t{ delayMs: 500, untilMs: 20_000 },\n\t{ delayMs: 1_000, untilMs: 60_000 },\n];\n\n/**\n * Default poll cadence as a function of elapsed wall-clock time since\n * polling began. Polls quickly while a task is young so short runs resolve\n * snappily, then eases off so a long run leaves rate-limit headroom for\n * newer tasks: 0-20s is 500ms, 20-60s is 1000ms, 60s+ is 5000ms.\n *\n * @since 0.1.0\n *\n * @example\n * ```ts\n * import { defaultPollDelay } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * expect(defaultPollDelay(0)).toBe(500);\n * expect(defaultPollDelay(30_000)).toBe(1000);\n * expect(defaultPollDelay(120_000)).toBe(5000);\n * ```\n *\n * @param elapsedMs - Milliseconds elapsed since polling started.\n * @returns The delay in milliseconds to wait before the next poll.\n */\nexport function defaultPollDelay(elapsedMs: number): number {\n\tconst tier = DEFAULT_POLL_TIERS.find((candidate) => elapsedMs < candidate.untilMs);\n\treturn tier?.delayMs ?? STEADY_POLL_DELAY_MS;\n}\n\n/**\n * Default number of consecutive transport failures tolerated before the poll\n * loop gives up. With per-request retries already absorbing isolated blips,\n * three consecutive loop-level failures signals a genuinely unreachable\n * endpoint, so it bails in seconds rather than spinning out the wall-clock\n * budget.\n */\nexport const DEFAULT_POLL_FAILURE_CAP = 3;\n\n/**\n * Injected dependencies for the deep-module polling loop. The `fetch`\n * callback is pre-bound by the wiring layer and closes over the task ref\n * and request options, keeping the core loop narrow.\n */\nexport interface PollDependencies {\n\t/** Returns the current task or an error. Called on each loop iteration. */\n\treadonly fetch: () => Promise<Result<LuauExecutionTask, OpenCloudError>>;\n\t/** Returns the current wall-clock time in ms. */\n\treadonly now: () => number;\n\t/** Injectable sleep for deterministic tests. */\n\treadonly sleep: SleepFunc;\n}\n\n/**\n * Public options accepted by `pollUntilDone` and `runUntilDone` on both client\n * surfaces.\n *\n * @since 0.1.0\n */\nexport type PollUntilDoneOptions = PollOptions & RequestOptions;\n\n/** Caller-supplied polling-loop options; all fields optional. */\ninterface PollOptions {\n\t/**\n\t * Consecutive transient transport failures tolerated before the loop gives\n\t * up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll\n\t * resets the count.\n\t */\n\treadonly maxConsecutivePollFailures?: number;\n\t/**\n\t * Returns the sleep duration given ms elapsed since polling started.\n\t * Defaults to {@link defaultPollDelay}.\n\t */\n\treadonly pollDelay?: (elapsedMs: number) => number;\n\t/**\n\t * When aborted, the loop returns {@link PollAbortedError} rather than\n\t * continuing.\n\t */\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Total wall-clock budget in ms before the loop returns {@link\n\t * PollTimeoutError}.\n\t */\n\treadonly timeoutMs?: number;\n}\n\n/**\n * Defaults the per-request `timeout` to the effective poll budget when the\n * caller has not set one. A luau-execution submit and each poll `get` normally\n * answer in well under a second (the submit endpoint enqueues the task without\n * waiting for it to run), so the only job of a per-request deadline here is to\n * bound a black-hole connection. Leaving these requests on the client-wide 30s\n * default (tuned for snappy CRUD) turns a slow-but-alive backend into a\n * self-abort, an error the retry layer never retries by construction, before\n * the loop's wall-clock budget is ever consulted. Deriving the deadline from\n * `timeoutMs` keeps a single request alive exactly as long as the caller\n * already agreed to wait for the whole operation, so the backend can answer or\n * surface a retryable status instead.\n *\n * @param options - The caller's poll and per-request options.\n * @returns The options with `timeout` filled from the budget when it was unset.\n */\nexport function withBudgetRequestTimeout(options: PollUntilDoneOptions): PollUntilDoneOptions {\n\tif (options.timeout !== undefined) {\n\t\treturn options;\n\t}\n\n\treturn { ...options, timeout: options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS };\n}\n\nconst ABORTED = Symbol(\"poll-aborted\");\ntype Aborted = typeof ABORTED;\n\ninterface AbortObserver {\n\treadonly cleanup: () => void;\n\treadonly promise: Promise<Aborted>;\n}\n\ninterface SleepWithAbortOptions {\n\treadonly ms: number;\n\treadonly signal: AbortSignal | undefined;\n\treadonly sleep: SleepFunc;\n}\n\ntype FetchOutcome =\n\t| { readonly error: NetworkError; readonly kind: \"transient\" }\n\t| { readonly error: OpenCloudError; readonly kind: \"failed\" }\n\t| { readonly kind: \"aborted\" }\n\t| { readonly kind: \"pending\"; readonly task: LuauExecutionTask }\n\t| { readonly kind: \"terminal\"; readonly task: LuauExecutionTask };\n\n/** Mutable-per-iteration loop state threaded through {@link applyOutcome}. */\ninterface LoopState {\n\treadonly consecutiveFailures: number;\n\treadonly lastTask: LuauExecutionTask | undefined;\n}\n\ntype LoopAction =\n\t| { readonly kind: \"continue\"; readonly state: LoopState }\n\t| { readonly kind: \"return\"; readonly result: Result<LuauExecutionTask, OpenCloudError> };\n\n/** Per-iteration inputs to {@link applyOutcome}. */\ninterface OutcomeContext {\n\treadonly maxFailures: number;\n\treadonly signal: AbortSignal | undefined;\n\treadonly state: LoopState;\n}\n\n/**\n * Core polling loop. Calls `deps.fetch()` repeatedly, sleeping\n * `pollDelay(elapsedMs)` ms between iterations, until a terminal state\n * is observed, the wall-clock budget is exhausted, or an `AbortSignal`\n * fires. A transient transport failure ({@link NetworkError}) is tolerated\n * and the loop continues, giving up only after `maxConsecutivePollFailures`\n * consecutive failures; any other failure aborts immediately, since an API\n * response (a 404 for a vanished task, a 403) means there is nothing left to\n * poll. A successful poll resets the failure count.\n *\n * @param deps - Injected fetch, now, and sleep callbacks.\n * @param options - Optional poll delay, timeout, failure cap, and abort signal.\n * @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.\n */\nexport async function pollUntilDoneCoreAsync(\n\tdeps: PollDependencies,\n\toptions: PollOptions = {},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst timeoutMs = options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n\tconst pollDelay = options.pollDelay ?? defaultPollDelay;\n\tconst maxFailures = options.maxConsecutivePollFailures ?? DEFAULT_POLL_FAILURE_CAP;\n\tconst sig = options.signal;\n\tif (sig?.aborted === true) {\n\t\treturn abortedResult(sig);\n\t}\n\n\tconst startedAt = deps.now();\n\tlet state: LoopState = { consecutiveFailures: 0, lastTask: undefined };\n\tfor (;;) {\n\t\tconst elapsedMs = deps.now() - startedAt;\n\t\tif (elapsedMs >= timeoutMs) {\n\t\t\treturn { err: makeTimeout(state.lastTask, timeoutMs), success: false };\n\t\t}\n\n\t\tconst outcome = await fetchOnceAsync(deps, sig);\n\t\tconst action = applyOutcome(outcome, { maxFailures, signal: sig, state });\n\t\tif (action.kind === \"return\") {\n\t\t\treturn action.result;\n\t\t}\n\n\t\t({ state } = action);\n\t\tif (\n\t\t\tawait sleepWithAbortAsync({ ms: pollDelay(elapsedMs), signal: sig, sleep: deps.sleep })\n\t\t) {\n\t\t\treturn abortedResult(sig);\n\t\t}\n\t}\n}\n\nfunction makeAborted(signal: AbortSignal | undefined): PollAbortedError {\n\treturn new PollAbortedError(\"Polling was aborted\", { reason: signal?.reason });\n}\n\nfunction abortedResult(signal: AbortSignal | undefined): Result<LuauExecutionTask, OpenCloudError> {\n\treturn { err: makeAborted(signal), success: false };\n}\n\n/**\n * Maps a single fetch outcome to the next loop action. Terminal, failed, and\n * aborted outcomes return immediately; a transient transport failure advances\n * the consecutive-failure count and returns once it reaches `maxFailures`; a\n * pending task resets the count and continues.\n *\n * @param outcome - The classified result of one poll fetch.\n * @param context - The loop state, failure cap, and abort signal.\n * @returns Whether to return a final Result or continue with updated state.\n */\nfunction applyOutcome(\n\toutcome: FetchOutcome,\n\t{ maxFailures, signal, state }: OutcomeContext,\n): LoopAction {\n\tswitch (outcome.kind) {\n\t\tcase \"aborted\": {\n\t\t\treturn { kind: \"return\", result: abortedResult(signal) };\n\t\t}\n\t\tcase \"failed\": {\n\t\t\treturn { kind: \"return\", result: { err: outcome.error, success: false } };\n\t\t}\n\t\tcase \"pending\": {\n\t\t\treturn { kind: \"continue\", state: { consecutiveFailures: 0, lastTask: outcome.task } };\n\t\t}\n\t\tcase \"terminal\": {\n\t\t\treturn { kind: \"return\", result: { data: outcome.task, success: true } };\n\t\t}\n\t\tcase \"transient\": {\n\t\t\tconst consecutiveFailures = state.consecutiveFailures + 1;\n\t\t\tif (consecutiveFailures >= maxFailures) {\n\t\t\t\treturn { kind: \"return\", result: { err: outcome.error, success: false } };\n\t\t\t}\n\n\t\t\treturn { kind: \"continue\", state: { consecutiveFailures, lastTask: state.lastTask } };\n\t\t}\n\t}\n}\n\nfunction abortObserver(signal: AbortSignal): AbortObserver {\n\tconst { promise, resolve } = Promise.withResolvers<Aborted>();\n\tfunction onAbort(): void {\n\t\tresolve(ABORTED);\n\t}\n\n\tsignal.addEventListener(\"abort\", onAbort);\n\tfunction cleanup(): void {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n\n\treturn { cleanup, promise };\n}\n\nasync function raceWithAbortAsync<T>(\n\tpromise: Promise<T>,\n\tsignal: AbortSignal | undefined,\n): Promise<Aborted | T> {\n\tif (signal === undefined) {\n\t\treturn promise;\n\t}\n\n\tif (signal.aborted) {\n\t\treturn ABORTED;\n\t}\n\n\tconst observer = abortObserver(signal);\n\ttry {\n\t\treturn await Promise.race([promise, observer.promise]);\n\t} finally {\n\t\tobserver.cleanup();\n\t}\n}\n\nasync function sleepWithAbortAsync({ ms, signal, sleep }: SleepWithAbortOptions): Promise<boolean> {\n\tconst raced = await raceWithAbortAsync(sleep(ms), signal);\n\treturn raced === ABORTED;\n}\n\nfunction makeTimeout(\n\ttask: LuauExecutionTask | undefined,\n\ttimeoutMs: number,\n): PollTimeoutError<LuauExecutionTask> {\n\treturn new PollTimeoutError(`Polling timed out after ${timeoutMs} ms`, {\n\t\tlastObservedTask: task,\n\t\ttimeoutMs,\n\t});\n}\n\nfunction isTerminal(task: LuauExecutionTask): boolean {\n\treturn task.state === \"COMPLETE\" || task.state === \"FAILED\" || task.state === \"CANCELLED\";\n}\n\n/**\n * A failed poll is worth re-polling only when it is a `NetworkError` carrying a\n * known transient transport code. A self-aborted request timeout has no\n * `code`, and an API response (4xx/5xx) is authoritative, so both abort the\n * loop rather than being re-polled. Transient-ness is classified against the\n * canonical `TRANSIENT_TRANSPORT_CODES` set; this is the loop's own tolerance\n * dimension, distinct from the per-request `retryableTransportCodes` override\n * (which governs request-level retries inside each poll). Loop tolerance is\n * bounded separately by `maxConsecutivePollFailures`.\n *\n * @param error - The error returned by a failed poll.\n * @returns `true` when the loop should tolerate and re-poll.\n */\nfunction isTransientTransport(error: OpenCloudError): error is NetworkError {\n\tif (!(error instanceof NetworkError)) {\n\t\treturn false;\n\t}\n\n\tconst code = findErrorCode(error);\n\treturn code !== undefined && TRANSIENT_TRANSPORT_CODES.includes(code);\n}\n\nasync function fetchOnceAsync(\n\tdependencies: PollDependencies,\n\tsignal: AbortSignal | undefined,\n): Promise<FetchOutcome> {\n\tconst fetchResult = await raceWithAbortAsync(dependencies.fetch(), signal);\n\tif (fetchResult === ABORTED) {\n\t\treturn { kind: \"aborted\" };\n\t}\n\n\tif (!fetchResult.success) {\n\t\treturn isTransientTransport(fetchResult.err)\n\t\t\t? { error: fetchResult.err, kind: \"transient\" }\n\t\t\t: { error: fetchResult.err, kind: \"failed\" };\n\t}\n\n\treturn isTerminal(fetchResult.data)\n\t\t? { kind: \"terminal\", task: fetchResult.data }\n\t\t: { kind: \"pending\", task: fetchResult.data };\n}\n","import {\n\tGET_SPEC,\n\tSUBMIT_HEAD_SPEC,\n\tSUBMIT_VERSION_SPEC,\n} from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport {\n\ttype PollDependencies,\n\tpollUntilDoneCoreAsync,\n\ttype PollUntilDoneOptions,\n} from \"./polling.ts\";\n\n/**\n * Builds the {@link PollDependencies} bundle used by {@link\n * pollUntilDoneCoreAsync}, closing over the supplied {@link ResourceClient},\n * task ref, and per-request options so the core loop stays narrow.\n *\n * @param inner - The {@link ResourceClient} that issues each `tasks.get` call.\n * @param args - The polling options and the task ref to fetch on every iteration.\n * @returns A {@link PollDependencies} bundle wiring `fetch`, `now`, and `sleep`.\n */\nexport function buildPollDependencies(\n\tinner: ResourceClient,\n\targs: { options: PollUntilDoneOptions; ref: LuauExecutionTaskRef },\n): PollDependencies {\n\treturn {\n\t\tfetch: async () => {\n\t\t\treturn inner.executeAsync({\n\t\t\t\toptions: args.options,\n\t\t\t\tparameters: { ref: args.ref, view: \"BASIC\" },\n\t\t\t\tspec: GET_SPEC,\n\t\t\t});\n\t\t},\n\t\tnow: Date.now,\n\t\tsleep: inner.sleep,\n\t};\n}\n\n/**\n * Submits a Luau execution task and polls it to a terminal state. Dispatches\n * to the head-version or specific-version submit spec based on the presence of\n * `versionId`, then delegates to {@link pollUntilDoneCoreAsync}.\n *\n * @param inner - The {@link ResourceClient} that issues submit and poll calls.\n * @param args - The polling options and submit parameters.\n * @returns A {@link Result} wrapping the terminal {@link LuauExecutionTask}, or\n * the {@link OpenCloudError} that caused submit or polling to fail.\n */\nexport async function submitAndPollAsync(\n\tinner: ResourceClient,\n\t{\n\t\toptions,\n\t\tparameters,\n\t}: {\n\t\toptions: PollUntilDoneOptions;\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n\t},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst submitResult = await (\"versionId\" in parameters\n\t\t? inner.executeAsync({ options, parameters, spec: SUBMIT_VERSION_SPEC })\n\t\t: inner.executeAsync({ options, parameters, spec: SUBMIT_HEAD_SPEC }));\n\tif (!submitResult.success) {\n\t\treturn submitResult;\n\t}\n\n\treturn pollUntilDoneCoreAsync(\n\t\tbuildPollDependencies(inner, { options, ref: submitResult.data.ref }),\n\t\toptions,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qBAAqB,EACpC,UACA,WACA,OAC4D;CAC5D,MAAM,EAAE,SAAS,WAAW,QAAQ,YAAY,cAAc;CAE9D,IAAI,cAAc,KAAA,GACjB,OAAO;EACN,KAAK,IAAI,gBAAgB,mDAAmD,EAC3E,MAAM,iBACP,CAAC;EACD,SAAS;CACV;CAGD,IAAI,cAAc,KAAA,GACjB,OAAO;EACN,KAAK,IAAI,gBAAgB,mDAAmD,EAC3E,MAAM,iBACP,CAAC;EACD,SAAS;CACV;CAKD,OAAO;EAAE,MAAM;GAAE,QAAQ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M;EAAW,MAAM,YAAY;CAAK;AAC9C;;;;;;;;;;;;ACnVA,SAAgB,sBACf,OACA,MACmB;CACnB,OAAO;EACN,OAAO,YAAY;GAClB,OAAO,MAAM,aAAa;IACzB,SAAS,KAAK;IACd,YAAY;KAAE,KAAK,KAAK;KAAK,MAAM;IAAQ;IAC3C,MAAM;GACP,CAAC;EACF;EACA,KAAK,KAAK;EACV,OAAO,MAAM;CACd;AACD;;;;;;;;;;;AAYA,eAAsB,mBACrB,OACA,EACC,SACA,cAKoD;CACrD,MAAM,eAAe,OAAO,eAAe,aACxC,MAAM,aAAa;EAAE;EAAS;EAAY,MAAM;CAAoB,CAAC,IACrE,MAAM,aAAa;EAAE;EAAS;EAAY,MAAM;CAAiB,CAAC;CACrE,IAAI,CAAC,aAAa,SACjB,OAAO;CAGR,OAAO,uBACN,sBAAsB,OAAO;EAAE;EAAS,KAAK,aAAa,KAAK;CAAI,CAAC,GACpE,OACD;AACD"}
@@ -1,4 +1,4 @@
1
- import { i as isRecord } from "./resource-client-CsbYSKwf.mjs";
1
+ import { a as isRecord } from "./resource-client-rQ9bBn4L.mjs";
2
2
  //#region src/internal/price-information.ts
3
3
  /**
4
4
  * Narrows `value` to {@link PriceInformationLike} for a given feature literal
@@ -39,4 +39,4 @@ function copyPriceInformation(wire) {
39
39
  //#endregion
40
40
  export { isPriceInformationLike as n, copyPriceInformation as t };
41
41
 
42
- //# sourceMappingURL=price-information-ClGhSmgI.mjs.map
42
+ //# sourceMappingURL=price-information-DziMfTQ6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"price-information-ClGhSmgI.mjs","names":[],"sources":["../src/internal/price-information.ts"],"sourcesContent":["import { isRecord } from \"./utils/is-record.ts\";\n\n/**\n * Wire shape shared by every Roblox commerce resource that carries a\n * `priceInformation` block (game passes, developer products, ...). Resources\n * vary in the literal set their `enabledFeatures` may contain, so the feature\n * type is left as a parameter `F`.\n *\n * @template F - The string-literal union for this resource's pricing-feature flags.\n */\nexport interface PriceInformationLike<F extends string> {\n\t/** Default Robux price; `undefined` when the schema returns null. */\n\treadonly defaultPriceInRobux: number | undefined;\n\t/** Enabled pricing feature flags, in the order returned by the API. */\n\treadonly enabledFeatures: ReadonlyArray<F>;\n}\n\n/**\n * Narrows `value` to {@link PriceInformationLike} for a given feature literal\n * union by delegating per-element validation to the supplied `isFeature`\n * predicate.\n *\n * @template F - The pricing-feature literal union the caller wants to narrow to.\n * @param value - Unknown wire value to validate.\n * @param isFeature - Type guard for a single `enabledFeatures` element.\n * @returns `true` when `value` is a record whose `defaultPriceInRobux` is a\n * number, `null`, or absent and whose `enabledFeatures` is an array of\n * values that all satisfy `isFeature`.\n */\nexport function isPriceInformationLike<F extends string>(\n\tvalue: unknown,\n\tisFeature: (candidate: unknown) => candidate is F,\n): value is PriceInformationLike<F> {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\tconst defaultPrice = value[\"defaultPriceInRobux\"] ?? undefined;\n\tif (defaultPrice !== undefined && typeof defaultPrice !== \"number\") {\n\t\treturn false;\n\t}\n\n\tconst features = value[\"enabledFeatures\"];\n\tif (!Array.isArray(features)) {\n\t\treturn false;\n\t}\n\n\tfor (const feature of features) {\n\t\tif (!isFeature(feature)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns a fresh {@link PriceInformationLike} value with a new\n * `enabledFeatures` array, so the caller can hand the result on without\n * exposing the wire object's internal storage.\n *\n * @template F - The pricing-feature literal union of the input.\n * @param wire - Already-validated wire shape.\n * @returns A new record with the same defaults and a copied feature array.\n */\nexport function copyPriceInformation<F extends string>(\n\twire: PriceInformationLike<F>,\n): PriceInformationLike<F> {\n\treturn {\n\t\tdefaultPriceInRobux: wire.defaultPriceInRobux ?? undefined,\n\t\tenabledFeatures: [...wire.enabledFeatures],\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BA,SAAgB,uBACf,OACA,WACmC;CACnC,IAAI,CAAC,SAAS,KAAK,GAClB,OAAO;CAGR,MAAM,eAAe,MAAM,0BAA0B,KAAA;CACrD,IAAI,iBAAiB,KAAA,KAAa,OAAO,iBAAiB,UACzD,OAAO;CAGR,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAC1B,OAAO;CAGR,KAAK,MAAM,WAAW,UACrB,IAAI,CAAC,UAAU,OAAO,GACrB,OAAO;CAIT,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,qBACf,MAC0B;CAC1B,OAAO;EACN,qBAAqB,KAAK,uBAAuB,KAAA;EACjD,iBAAiB,CAAC,GAAG,KAAK,eAAe;CAC1C;AACD"}
1
+ {"version":3,"file":"price-information-DziMfTQ6.mjs","names":[],"sources":["../src/internal/price-information.ts"],"sourcesContent":["import { isRecord } from \"./utils/is-record.ts\";\n\n/**\n * Wire shape shared by every Roblox commerce resource that carries a\n * `priceInformation` block (game passes, developer products, ...). Resources\n * vary in the literal set their `enabledFeatures` may contain, so the feature\n * type is left as a parameter `F`.\n *\n * @template F - The string-literal union for this resource's pricing-feature flags.\n */\nexport interface PriceInformationLike<F extends string> {\n\t/** Default Robux price; `undefined` when the schema returns null. */\n\treadonly defaultPriceInRobux: number | undefined;\n\t/** Enabled pricing feature flags, in the order returned by the API. */\n\treadonly enabledFeatures: ReadonlyArray<F>;\n}\n\n/**\n * Narrows `value` to {@link PriceInformationLike} for a given feature literal\n * union by delegating per-element validation to the supplied `isFeature`\n * predicate.\n *\n * @template F - The pricing-feature literal union the caller wants to narrow to.\n * @param value - Unknown wire value to validate.\n * @param isFeature - Type guard for a single `enabledFeatures` element.\n * @returns `true` when `value` is a record whose `defaultPriceInRobux` is a\n * number, `null`, or absent and whose `enabledFeatures` is an array of\n * values that all satisfy `isFeature`.\n */\nexport function isPriceInformationLike<F extends string>(\n\tvalue: unknown,\n\tisFeature: (candidate: unknown) => candidate is F,\n): value is PriceInformationLike<F> {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\tconst defaultPrice = value[\"defaultPriceInRobux\"] ?? undefined;\n\tif (defaultPrice !== undefined && typeof defaultPrice !== \"number\") {\n\t\treturn false;\n\t}\n\n\tconst features = value[\"enabledFeatures\"];\n\tif (!Array.isArray(features)) {\n\t\treturn false;\n\t}\n\n\tfor (const feature of features) {\n\t\tif (!isFeature(feature)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns a fresh {@link PriceInformationLike} value with a new\n * `enabledFeatures` array, so the caller can hand the result on without\n * exposing the wire object's internal storage.\n *\n * @template F - The pricing-feature literal union of the input.\n * @param wire - Already-validated wire shape.\n * @returns A new record with the same defaults and a copied feature array.\n */\nexport function copyPriceInformation<F extends string>(\n\twire: PriceInformationLike<F>,\n): PriceInformationLike<F> {\n\treturn {\n\t\tdefaultPriceInRobux: wire.defaultPriceInRobux ?? undefined,\n\t\tenabledFeatures: [...wire.enabledFeatures],\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AA6BA,SAAgB,uBACf,OACA,WACmC;CACnC,IAAI,CAAC,SAAS,KAAK,GAClB,OAAO;CAGR,MAAM,eAAe,MAAM,0BAA0B,KAAA;CACrD,IAAI,iBAAiB,KAAA,KAAa,OAAO,iBAAiB,UACzD,OAAO;CAGR,MAAM,WAAW,MAAM;CACvB,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAC1B,OAAO;CAGR,KAAK,MAAM,WAAW,UACrB,IAAI,CAAC,UAAU,OAAO,GACrB,OAAO;CAIT,OAAO;AACR;;;;;;;;;;AAWA,SAAgB,qBACf,MAC0B;CAC1B,OAAO;EACN,qBAAqB,KAAK,uBAAuB,KAAA;EACjD,iBAAiB,CAAC,GAAG,KAAK,eAAe;CAC1C;AACD"}
@@ -100,8 +100,8 @@ var NetworkError = class extends OpenCloudError {
100
100
  //#endregion
101
101
  //#region src/errors/rate-limit.ts
102
102
  /**
103
- * Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests response.
104
- * Contains the server-suggested retry delay.
103
+ * Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests
104
+ * response. Contains the server-suggested retry delay.
105
105
  *
106
106
  * @since 0.1.0
107
107
  *
@@ -122,7 +122,9 @@ var RateLimitError = class extends OpenCloudError {
122
122
  /** Parsed 429 response body, or `undefined` when none was carried. */
123
123
  details;
124
124
  name = "RateLimitError";
125
- /** Requests left in the throttled window, or `undefined` if not reported. */
125
+ /**
126
+ * Requests left in the throttled window, or `undefined` if not reported.
127
+ */
126
128
  remaining;
127
129
  retryAfterSeconds;
128
130
  /** HTTP status code that produced the error, or `undefined` if not set. */
@@ -144,4 +146,4 @@ var RateLimitError = class extends OpenCloudError {
144
146
  //#endregion
145
147
  export { OpenCloudError as i, NetworkError as n, ApiError as r, RateLimitError as t };
146
148
 
147
- //# sourceMappingURL=rate-limit-Dh2leqaB.mjs.map
149
+ //# sourceMappingURL=rate-limit-B20REZEY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limit-Dh2leqaB.mjs","names":[],"sources":["../src/errors/base.ts","../src/errors/api-error.ts","../src/errors/network-error.ts","../src/errors/rate-limit.ts"],"sourcesContent":["/**\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 * @since 0.1.0\n */\nexport class OpenCloudError extends Error {\n\tpublic override readonly name: string = \"OpenCloudError\";\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing an {@link ApiError}.\n *\n * @since 0.1.0\n */\nexport interface ApiErrorOptions extends ErrorOptions {\n\t/** Optional machine-readable error code from the API. */\n\tcode?: string | undefined;\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 when\n\t * the error body was such a page (an HAProxy-style load-balancer rejection)\n\t * rather than an Open Cloud response. When present, the raw HTML is not\n\t * 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/** Fully-qualified URL of the request that produced this error. */\n\turl?: string | 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 code: string | undefined;\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 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.code = options.code;\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}\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","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RateLimitError}.\n *\n * @since 0.1.0\n */\nexport interface RateLimitErrorOptions extends ErrorOptions {\n\t/**\n\t * Parsed 429 response body, when present. Holds the server's throttle\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.\n\t */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Requests still allowed in the throttled window, read from\n\t * `x-ratelimit-remaining` (the most-constrained window). `undefined` when\n\t * the header is absent or carries no finite numeric token; parsed\n\t * independently of `x-ratelimit-reset`, so a valid value survives a\n\t * non-numeric reset. Typically `0` on a genuine 429.\n\t */\n\tremaining?: number | 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 response.\n * Contains the server-suggested retry delay.\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 * retryAfterSeconds: 30,\n * });\n *\n * expect(error).toBeInstanceOf(RateLimitError);\n * expect(error.retryAfterSeconds).toBe(30);\n * ```\n */\nexport class RateLimitError extends OpenCloudError {\n\t/** Parsed 429 response body, or `undefined` when none was carried. */\n\tpublic readonly details: JSONValue | undefined;\n\tpublic override readonly name = \"RateLimitError\";\n\t/** Requests left in the throttled window, or `undefined` if not reported. */\n\tpublic readonly remaining: number | 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.details = options.details;\n\t\tthis.statusCode = options.statusCode;\n\t}\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CACzC,OAAwC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuDA,IAAa,WAAb,cAA8B,eAAe;CAC5C;CACA;CACA;CACA;CACA;CACA,OAAwC;CACxC;CACA;CACA;;;;;;;;;;CAWA,YAAY,SAAiB,SAA0B;EACtD,MAAM,SAAS,OAAO;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAK,SAAS,QAAQ;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,YAAY,QAAQ;EACzB,KAAK,kBAAkB,QAAQ;EAC/B,KAAK,iBAAiB,QAAQ;CAC/B;AACD;;;;;;;;;;;;ACzEA,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;;;;;;;;;;;;;;;;;;;;;;ACUA,IAAa,iBAAb,cAAoC,eAAe;;CAElD;CACA,OAAgC;;CAEhC;CACA;;CAEA;;;;;;;CAQA,YAAY,SAAiB,SAAgC;EAC5D,MAAM,SAAS,OAAO;EACtB,KAAK,oBAAoB,QAAQ;EACjC,KAAK,YAAY,QAAQ;EACzB,KAAK,UAAU,QAAQ;EACvB,KAAK,aAAa,QAAQ;CAC3B;AACD"}
1
+ {"version":3,"file":"rate-limit-B20REZEY.mjs","names":[],"sources":["../src/errors/base.ts","../src/errors/api-error.ts","../src/errors/network-error.ts","../src/errors/rate-limit.ts"],"sourcesContent":["/**\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 * @since 0.1.0\n */\nexport class OpenCloudError extends Error {\n\tpublic override readonly name: string = \"OpenCloudError\";\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing an {@link ApiError}.\n *\n * @since 0.1.0\n */\nexport interface ApiErrorOptions extends ErrorOptions {\n\t/** Optional machine-readable error code from the API. */\n\tcode?: string | undefined;\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/** Fully-qualified URL of the request that produced this error. */\n\turl?: string | 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 code: string | undefined;\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 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.code = options.code;\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}\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","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RateLimitError}.\n *\n * @since 0.1.0\n */\nexport interface RateLimitErrorOptions extends ErrorOptions {\n\t/**\n\t * Parsed 429 response body, when present. Holds the server's throttle\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.\n\t */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Requests still allowed in the throttled window, read from\n\t * `x-ratelimit-remaining` (the most-constrained window). `undefined` when\n\t * the header is absent or carries no finite numeric token; parsed\n\t * independently of `x-ratelimit-reset`, so a valid value survives a\n\t * non-numeric reset. Typically `0` on a genuine 429.\n\t */\n\tremaining?: number | 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.\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 * retryAfterSeconds: 30,\n * });\n *\n * expect(error).toBeInstanceOf(RateLimitError);\n * expect(error.retryAfterSeconds).toBe(30);\n * ```\n */\nexport class RateLimitError extends OpenCloudError {\n\t/** Parsed 429 response body, or `undefined` when none was carried. */\n\tpublic readonly details: JSONValue | undefined;\n\tpublic override readonly name = \"RateLimitError\";\n\t/**\n\t * Requests left in the throttled window, or `undefined` if not reported.\n\t */\n\tpublic readonly remaining: number | 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.details = options.details;\n\t\tthis.statusCode = options.statusCode;\n\t}\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CACzC,OAAwC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuDA,IAAa,WAAb,cAA8B,eAAe;CAC5C;CACA;CACA;CACA;CACA;CACA,OAAwC;CACxC;CACA;CACA;;;;;;;;;;CAWA,YAAY,SAAiB,SAA0B;EACtD,MAAM,SAAS,OAAO;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAK,SAAS,QAAQ;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,YAAY,QAAQ;EACzB,KAAK,kBAAkB,QAAQ;EAC/B,KAAK,iBAAiB,QAAQ;CAC/B;AACD;;;;;;;;;;;;ACzEA,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;;;;;;;;;;;;;;;;;;;;;;ACUA,IAAa,iBAAb,cAAoC,eAAe;;CAElD;CACA,OAAgC;;;;CAIhC;CACA;;CAEA;;;;;;;CAQA,YAAY,SAAiB,SAAgC;EAC5D,MAAM,SAAS,OAAO;EACtB,KAAK,oBAAoB,QAAQ;EACjC,KAAK,YAAY,QAAQ;EACzB,KAAK,UAAU,QAAQ;EACvB,KAAK,aAAa,QAAQ;CAC3B;AACD"}