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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +9 -5
  2. package/dist/badge-cost-mismatch-DrlvhlQc.mjs +47 -0
  3. package/dist/badge-cost-mismatch-DrlvhlQc.mjs.map +1 -0
  4. package/dist/badges.d.mts +228 -184
  5. package/dist/badges.d.mts.map +1 -1
  6. package/dist/badges.mjs +176 -18
  7. package/dist/badges.mjs.map +1 -1
  8. package/dist/capacity-admission-hycCFkTo.d.mts +355 -0
  9. package/dist/capacity-admission-hycCFkTo.d.mts.map +1 -0
  10. package/dist/{data.generated-B2ceLfSn.d.mts → data.generated-D_vpa5-g.d.mts} +23 -23
  11. package/dist/data.generated-D_vpa5-g.d.mts.map +1 -0
  12. package/dist/developer-products.d.mts +181 -186
  13. package/dist/developer-products.d.mts.map +1 -1
  14. package/dist/developer-products.mjs +24 -24
  15. package/dist/developer-products.mjs.map +1 -1
  16. package/dist/game-passes.d.mts +206 -203
  17. package/dist/game-passes.d.mts.map +1 -1
  18. package/dist/game-passes.mjs +26 -21
  19. package/dist/game-passes.mjs.map +1 -1
  20. package/dist/index.d.mts +924 -306
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +325 -10
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/locales.d.mts +30 -2
  25. package/dist/locales.d.mts.map +1 -0
  26. package/dist/locales.mjs +24 -1
  27. package/dist/locales.mjs.map +1 -1
  28. package/dist/luau-execution.d.mts +154 -151
  29. package/dist/luau-execution.d.mts.map +1 -1
  30. package/dist/luau-execution.mjs +11 -8
  31. package/dist/luau-execution.mjs.map +1 -1
  32. package/dist/{network-error-DR9FX5hb.mjs → network-error-iVSng5MT.mjs} +44 -6
  33. package/dist/network-error-iVSng5MT.mjs.map +1 -0
  34. package/dist/places.d.mts +204 -180
  35. package/dist/places.d.mts.map +1 -1
  36. package/dist/places.mjs +66 -20
  37. package/dist/places.mjs.map +1 -1
  38. package/dist/{poll-timeout-3PXLsabj.mjs → poll-timeout-DzztDymd.mjs} +2 -2
  39. package/dist/{poll-timeout-3PXLsabj.mjs.map → poll-timeout-DzztDymd.mjs.map} +1 -1
  40. package/dist/{polling-helpers-sKTsqEc1.mjs → polling-helpers-DfF5dspc.mjs} +249 -83
  41. package/dist/polling-helpers-DfF5dspc.mjs.map +1 -0
  42. package/dist/{price-information-hWXV6DAI.mjs → price-information-DEkEQ8Pq.mjs} +2 -2
  43. package/dist/{price-information-hWXV6DAI.mjs.map → price-information-DEkEQ8Pq.mjs.map} +1 -1
  44. package/dist/resource-client-BCKukheG.d.mts +168 -0
  45. package/dist/resource-client-BCKukheG.d.mts.map +1 -0
  46. package/dist/resource-client-CaIVr-go.mjs +1419 -0
  47. package/dist/resource-client-CaIVr-go.mjs.map +1 -0
  48. package/dist/retry-C2oHesDx.d.mts +229 -0
  49. package/dist/retry-C2oHesDx.d.mts.map +1 -0
  50. package/dist/{retry-vpHMIwaU.mjs → retry-CMRDvAR4.mjs} +390 -20
  51. package/dist/retry-CMRDvAR4.mjs.map +1 -0
  52. package/dist/storage.d.mts +333 -334
  53. package/dist/storage.d.mts.map +1 -1
  54. package/dist/storage.mjs +29 -22
  55. package/dist/storage.mjs.map +1 -1
  56. package/dist/testing.d.mts +347 -360
  57. package/dist/testing.d.mts.map +1 -1
  58. package/dist/testing.mjs +3 -4
  59. package/dist/testing.mjs.map +1 -1
  60. package/dist/types-CdMr_J1M.d.mts +509 -0
  61. package/dist/types-CdMr_J1M.d.mts.map +1 -0
  62. package/dist/universes.d.mts +619 -422
  63. package/dist/universes.d.mts.map +1 -1
  64. package/dist/universes.mjs +421 -48
  65. package/dist/universes.mjs.map +1 -1
  66. package/dist/{validation-B_Zs1So2.mjs → validation-964VNlbp.mjs} +2 -2
  67. package/dist/{validation-B_Zs1So2.mjs.map → validation-964VNlbp.mjs.map} +1 -1
  68. package/dist/wire-DJqupefn.d.mts +41 -0
  69. package/dist/wire-DJqupefn.d.mts.map +1 -0
  70. package/package.json +14 -14
  71. package/dist/capacity-admission-BvnJjY0S.d.mts +0 -369
  72. package/dist/capacity-admission-BvnJjY0S.d.mts.map +0 -1
  73. package/dist/data.generated-B2ceLfSn.d.mts.map +0 -1
  74. package/dist/network-error-DR9FX5hb.mjs.map +0 -1
  75. package/dist/polling-helpers-sKTsqEc1.mjs.map +0 -1
  76. package/dist/resource-client-3cOhqZpX.mjs +0 -899
  77. package/dist/resource-client-3cOhqZpX.mjs.map +0 -1
  78. package/dist/resource-client-BivRq3JZ.d.mts +0 -164
  79. package/dist/resource-client-BivRq3JZ.d.mts.map +0 -1
  80. package/dist/retry-DXEklFrt.d.mts +0 -373
  81. package/dist/retry-DXEklFrt.d.mts.map +0 -1
  82. package/dist/retry-vpHMIwaU.mjs.map +0 -1
  83. package/dist/types-C3Egi37J.d.mts +0 -378
  84. package/dist/types-C3Egi37J.d.mts.map +0 -1
  85. package/dist/wire-D3K-a-UP.d.mts +0 -37
  86. package/dist/wire-D3K-a-UP.d.mts.map +0 -1
@@ -1,8 +1,8 @@
1
- import { a as ApiError, n as RateLimitError, s as OpenCloudError, t as NetworkError } from "./network-error-DR9FX5hb.mjs";
2
- import { _ as ABORTED, a as TRANSIENT_TRANSPORT_CODES, d as findErrorCode, r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS, v as raceWithAbortAsync } from "./retry-vpHMIwaU.mjs";
3
- import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-3PXLsabj.mjs";
4
- import { t as ValidationError } from "./validation-B_Zs1So2.mjs";
5
- import { a as observeAdmissionWaitAsync, c as isDateTimeString, i as waitDeadlineFailure, n as okRequest, o as toJsonDetails, s as isRecord } from "./resource-client-3cOhqZpX.mjs";
1
+ import { n as RateLimitError, s as OpenCloudError, t as NetworkError } from "./network-error-iVSng5MT.mjs";
2
+ import { T as raceWithAbortAsync, a as TRANSIENT_TRANSPORT_CODES, g as RequestDeadlineExceededError, j as isRecord, m as UnexpectedResponseError, p as findErrorCode, r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS, w as ABORTED } from "./retry-CMRDvAR4.mjs";
3
+ import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-DzztDymd.mjs";
4
+ import { t as ValidationError } from "./validation-964VNlbp.mjs";
5
+ import { a as waitDeadlineFailure, c as isDateTimeString, n as okRequest, o as observeAdmissionWaitAsync, s as toJsonDetails } from "./resource-client-CaIVr-go.mjs";
6
6
  //#region src/resources/luau-execution/capacity-error.ts
7
7
  const UUID_PATTERN = "[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}";
8
8
  /**
@@ -58,12 +58,21 @@ function luauTaskRefKey(ref) {
58
58
  * @returns A typed capacity error, or `undefined` without positive evidence.
59
59
  */
60
60
  function capacityErrorFrom(error, parameters) {
61
- if (!(error instanceof RateLimitError) || error.code !== "RESOURCE_EXHAUSTED") return;
62
- const message = capacityMessage(error.details);
63
- if (message === void 0) return;
64
- const blockers = blockerRefsFrom(message, parameters);
61
+ const blockers = capacityBlockersFrom(error, parameters);
65
62
  return blockers.length === 0 ? void 0 : new LuauExecutionCapacityError(blockers);
66
63
  }
64
+ /**
65
+ * Checks whether a response error positively names tasks occupying the
66
+ * submitted place. Such a 429 clears when those tasks end, not at its
67
+ * guided wait, so it never locks the submit operation out.
68
+ *
69
+ * @param error - The response error to inspect.
70
+ * @param parameters - The submitted target used to validate blocker refs.
71
+ * @returns Whether the error names at least one validated blocker.
72
+ */
73
+ function namesCapacityBlockers(error, parameters) {
74
+ return capacityBlockersFrom(error, parameters).length > 0;
75
+ }
67
76
  function capacityMessage(details) {
68
77
  if (details === null || typeof details !== "object" || Array.isArray(details)) return;
69
78
  const code = Reflect.get(details, "code");
@@ -98,6 +107,11 @@ function blockerRefsFrom(message, parameters) {
98
107
  }
99
108
  return Object.freeze([...unique.values()].toSorted(compareTaskRefs));
100
109
  }
110
+ function capacityBlockersFrom(error, parameters) {
111
+ if (!(error instanceof RateLimitError) || error.code !== "RESOURCE_EXHAUSTED") return [];
112
+ const message = capacityMessage(error.details);
113
+ return message === void 0 ? [] : blockerRefsFrom(message, parameters);
114
+ }
101
115
  //#endregion
102
116
  //#region src/domains/cloud-v2/luau-execution-task-logs/builders.ts
103
117
  /**
@@ -172,26 +186,27 @@ const MALFORMED_LOGS_MESSAGE = "Malformed list-luau-execution-task-logs response
172
186
  * body into the public {@link LogPage} shape. Chunks are flattened into
173
187
  * a single ordered array of {@link LogMessage} values.
174
188
  *
189
+ * The SDK requests STRUCTURED view, so both the chunk list and each
190
+ * chunk's message array must be present. Explicit empty arrays are valid;
191
+ * missing arrays reject the page rather than silently losing log output.
192
+ *
175
193
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
176
194
  * @returns A success result wrapping the parsed {@link LogPage}, or an
177
- * {@link ApiError} when the body does not match a supported shape.
195
+ * {@link UnexpectedResponseError} when the body does not match a supported
196
+ * shape.
178
197
  */
179
198
  function parseListLogsResponse({ body, status: statusCode }) {
180
199
  if (!isRecord(body)) return malformed$1(statusCode, body);
181
- const rawChunks = body["luauExecutionSessionTaskLogs"] ?? void 0;
182
- if (!isOptionalLogChunks(rawChunks)) return malformed$1(statusCode, body);
183
- const rawToken = body["nextPageToken"] ?? void 0;
200
+ const rawChunks = body["luauExecutionSessionTaskLogs"];
201
+ if (!isLogChunks(rawChunks)) return malformed$1(statusCode, body);
202
+ const rawToken = body["nextPageToken"];
184
203
  if (rawToken !== void 0 && typeof rawToken !== "string") return malformed$1(statusCode, body);
185
204
  const messages = [];
186
- const chunks = rawChunks ?? [];
187
- for (const chunk of chunks) {
188
- const wireMessages = chunk.structuredMessages ?? [];
189
- for (const wireMessage of wireMessages) messages.push({
190
- createTime: wireMessage.createTime,
191
- message: wireMessage.message,
192
- messageType: wireMessage.messageType
193
- });
194
- }
205
+ for (const chunk of rawChunks) for (const wireMessage of chunk.structuredMessages) messages.push({
206
+ createTime: wireMessage.createTime,
207
+ message: wireMessage.message,
208
+ messageType: wireMessage.messageType
209
+ });
195
210
  return {
196
211
  data: {
197
212
  messages,
@@ -206,18 +221,41 @@ function isAcceptedMessageType(value) {
206
221
  function isLogMessageWire(value) {
207
222
  return isRecord(value) && typeof value["createTime"] === "string" && typeof value["message"] === "string" && isAcceptedMessageType(value["messageType"]);
208
223
  }
209
- function isOptionalStructuredMessages(value) {
210
- return value === void 0 || Array.isArray(value) && value.every((item) => isLogMessageWire(item));
224
+ /**
225
+ * Requires an explicit message array: captured no-print tasks return `[]`.
226
+ * Missing or null messages do not establish that a chunk has no output.
227
+ *
228
+ * @param value - The chunk's untrusted `structuredMessages` field.
229
+ * @returns Whether the field is an array containing only valid messages.
230
+ */
231
+ function isStructuredMessages(value) {
232
+ return Array.isArray(value) && value.every((item) => isLogMessageWire(item));
211
233
  }
234
+ /**
235
+ * Validates a chunk for the STRUCTURED view always requested by the SDK.
236
+ * The schema also describes FLAT chunks that omit `structuredMessages`;
237
+ * accepting those here would silently discard their output.
238
+ *
239
+ * @param value - An untrusted entry in the response's chunk list.
240
+ * @returns Whether the chunk contains a valid structured message array.
241
+ */
212
242
  function isLogChunkWire(value) {
213
- return isRecord(value) && isOptionalStructuredMessages(value["structuredMessages"]);
243
+ return isRecord(value) && isStructuredMessages(value["structuredMessages"]);
214
244
  }
215
- function isOptionalLogChunks(value) {
216
- return value === void 0 || Array.isArray(value) && value.every((item) => isLogChunkWire(item));
245
+ /**
246
+ * Requires an explicit chunk list, including `[]` for an empty page.
247
+ * Validates every chunk before flattening so one malformed chunk rejects
248
+ * the whole page instead of returning a partial log list.
249
+ *
250
+ * @param value - The untrusted `luauExecutionSessionTaskLogs` field.
251
+ * @returns Whether the field is an array containing only valid chunks.
252
+ */
253
+ function isLogChunks(value) {
254
+ return Array.isArray(value) && value.every((item) => isLogChunkWire(item));
217
255
  }
218
256
  function malformed$1(statusCode, body) {
219
257
  return {
220
- err: new ApiError(MALFORMED_LOGS_MESSAGE, {
258
+ err: new UnexpectedResponseError(MALFORMED_LOGS_MESSAGE, {
221
259
  details: toJsonDetails(body),
222
260
  statusCode
223
261
  }),
@@ -227,7 +265,10 @@ function malformed$1(statusCode, body) {
227
265
  //#endregion
228
266
  //#region src/domains/cloud-v2/luau-execution-task-logs/specs.ts
229
267
  function makeSpec$1(spec) {
230
- return Object.freeze(spec);
268
+ return Object.freeze({
269
+ ...spec,
270
+ apiKeyOnly: true
271
+ });
231
272
  }
232
273
  /**
233
274
  * Per-method dispatch spec for listing the structured log messages
@@ -399,8 +440,8 @@ const PATH_PATTERN = /^universes\/(\d+)\/places\/(\d+)(?:\/versions\/(\d+))?(?:\
399
440
  * @param response - The full {@link HttpResponse} from the Open Cloud
400
441
  * API.
401
442
  * @returns A success result wrapping the parsed task, or an
402
- * {@link ApiError} when the body or path do not match a supported
403
- * shape.
443
+ * {@link UnexpectedResponseError} when the body or path do not match a
444
+ * supported shape.
404
445
  */
405
446
  function parseLuauExecutionTaskResponse({ body, status: statusCode }) {
406
447
  if (!isLuauExecutionTaskWire(body)) return malformed(statusCode, body);
@@ -480,7 +521,7 @@ function parseTimeoutSeconds(value) {
480
521
  }
481
522
  function malformed(statusCode, body) {
482
523
  return {
483
- err: new ApiError(MALFORMED_TASK_MESSAGE, {
524
+ err: new UnexpectedResponseError(MALFORMED_TASK_MESSAGE, {
484
525
  details: toJsonDetails(body),
485
526
  statusCode
486
527
  }),
@@ -559,7 +600,10 @@ function parseTaskRef(path) {
559
600
  //#endregion
560
601
  //#region src/domains/cloud-v2/luau-execution-tasks/specs.ts
561
602
  function makeSpec(spec) {
562
- return Object.freeze(spec);
603
+ return Object.freeze({
604
+ ...spec,
605
+ apiKeyOnly: true
606
+ });
563
607
  }
564
608
  /**
565
609
  * Per-method dispatch spec for submitting a Luau execution task at a
@@ -641,6 +685,50 @@ function defaultPollDelay(elapsedMs) {
641
685
  return DEFAULT_POLL_TIERS.find((candidate) => elapsedMs < candidate.untilMs)?.delayMs ?? STEADY_POLL_DELAY_MS;
642
686
  }
643
687
  /**
688
+ * Opens the poll budget at `startedAt`. Each request gets the earlier of the
689
+ * budget deadline and the caller's own `deadlineMs`. A non-finite budget
690
+ * passes only the caller's deadline, since the transport rejects a
691
+ * non-finite one.
692
+ *
693
+ * @param startedAt - Time the budget opened, as epoch ms.
694
+ * @param options - The caller's `timeoutMs` and `deadlineMs`.
695
+ * @returns The budget window and the per-request deadline.
696
+ */
697
+ function openPollBudget(startedAt, options) {
698
+ const timeoutMs = options.timeoutMs ?? 3e5;
699
+ const budgetDeadlineMs = startedAt + timeoutMs;
700
+ const callerDeadlineMs = options.deadlineMs;
701
+ if (!Number.isFinite(budgetDeadlineMs)) return {
702
+ budgetDeadlineMs,
703
+ requestDeadlineMs: callerDeadlineMs,
704
+ timeoutMs
705
+ };
706
+ return {
707
+ budgetDeadlineMs,
708
+ requestDeadlineMs: callerDeadlineMs === void 0 ? budgetDeadlineMs : Math.min(callerDeadlineMs, budgetDeadlineMs),
709
+ timeoutMs
710
+ };
711
+ }
712
+ /**
713
+ * Maps a request failure caused by the budget deadline to
714
+ * {@link PollTimeoutError}. Any other failure, including one from the
715
+ * caller's own earlier deadline, is returned unchanged. A caller abort wins
716
+ * over the budget, so the failure is also returned unchanged when the
717
+ * caller's signal has fired.
718
+ *
719
+ * @param error - The failure a submit or poll request returned.
720
+ * @param context - The opened budget, the last task observed, if any, and
721
+ * the caller's signal.
722
+ * @returns The poll timeout, or the original error.
723
+ */
724
+ function budgetFailure(error, context) {
725
+ if (!isBudgetDeadline(error, context.budget) || context.signal?.aborted === true) return error;
726
+ return makeTimeout(context.lastTask, {
727
+ cause: error,
728
+ timeoutMs: context.budget.timeoutMs
729
+ });
730
+ }
731
+ /**
644
732
  * Defaults the per-request `timeout` to the effective poll budget when the
645
733
  * caller has not set one. A luau-execution submit and each poll `get` normally
646
734
  * answer in well under a second (the submit endpoint enqueues the task without
@@ -651,14 +739,16 @@ function defaultPollDelay(elapsedMs) {
651
739
  * the loop's wall-clock budget is ever consulted. Deriving the deadline from
652
740
  * `timeoutMs` keeps a single request alive exactly as long as the caller
653
741
  * already agreed to wait for the whole operation, so the backend can answer or
654
- * surface a retryable status instead.
742
+ * surface a retryable status instead. A budget longer than a timer can hold,
743
+ * such as `Infinity`, is capped at the longest delay the transport accepts.
655
744
  *
656
745
  * @template TOptions - The concrete polling option shape to preserve.
657
746
  * @param options - The caller's poll and per-request options.
658
747
  * @returns The options with `timeout` filled from the budget when it was unset.
659
748
  */
660
749
  function withBudgetRequestTimeout(options) {
661
- const timeout = options.timeout ?? options.timeoutMs ?? 3e5;
750
+ const budgetMs = options.timeoutMs ?? 3e5;
751
+ const timeout = options.timeout ?? Math.min(budgetMs, 2147483647);
662
752
  return {
663
753
  ...options,
664
754
  timeout
@@ -688,20 +778,25 @@ function isTerminalTask(task) {
688
778
  * @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.
689
779
  */
690
780
  async function pollUntilDoneCoreAsync(deps, options = {}) {
691
- const { maxFailures, pollDelay, signal, timeoutMs } = resolvePollOptions(options);
781
+ const { maxFailures, pollDelay, signal } = resolvePollOptions(options);
692
782
  if (signal?.aborted === true) return abortedResult(signal);
693
- const startedAt = deps.now();
783
+ const startedAt = deps.startedAt ?? deps.now();
784
+ const budget = openPollBudget(startedAt, options);
694
785
  let state = {
695
786
  consecutiveFailures: 0,
696
787
  lastTask: void 0
697
788
  };
698
789
  for (;;) {
699
790
  const elapsedMs = deps.now() - startedAt;
700
- if (elapsedMs >= timeoutMs) return {
701
- err: makeTimeout(state.lastTask, timeoutMs),
791
+ if (elapsedMs >= budget.timeoutMs) return {
792
+ err: makeTimeout(state.lastTask, budget),
702
793
  success: false
703
794
  };
704
- const action = applyOutcome(await fetchOnceAsync(deps, signal), {
795
+ const action = applyOutcome(await fetchOnceAsync(deps, {
796
+ budget,
797
+ signal
798
+ }), {
799
+ budget,
705
800
  maxFailures,
706
801
  signal,
707
802
  state
@@ -715,12 +810,34 @@ async function pollUntilDoneCoreAsync(deps, options = {}) {
715
810
  })) return abortedResult(signal);
716
811
  }
717
812
  }
813
+ /**
814
+ * Describes why the budget ended. A wait the transport refused up front
815
+ * (one that carries `waitMs`) ends the poll before `timeoutMs` has elapsed,
816
+ * so its message reports the budget left rather than an elapsed timeout.
817
+ *
818
+ * @param cause - The budget deadline failure, if a request reported one.
819
+ * @param timeoutMs - The total poll budget in ms.
820
+ * @returns The elapsed-timeout wording, or the budget left and the refused wait.
821
+ */
822
+ function timeoutMessage(cause, timeoutMs) {
823
+ if (cause?.waitMs === void 0) return `Polling timed out after ${timeoutMs} ms`;
824
+ return `Polling stopped with ${cause.remainingMs} ms of the ${timeoutMs} ms budget left: a required ${cause.waitMs} ms wait would exceed it`;
825
+ }
826
+ function makeTimeout(task, { cause, timeoutMs }) {
827
+ return new PollTimeoutError(timeoutMessage(cause, timeoutMs), {
828
+ ...cause === void 0 ? {} : { cause },
829
+ lastObservedTask: task,
830
+ timeoutMs
831
+ });
832
+ }
833
+ function isBudgetDeadline(error, budget) {
834
+ return error instanceof RequestDeadlineExceededError && error.deadlineMs === budget.budgetDeadlineMs;
835
+ }
718
836
  function resolvePollOptions(options) {
719
837
  return {
720
838
  maxFailures: options.maxConsecutivePollFailures ?? 3,
721
839
  pollDelay: options.pollDelay ?? defaultPollDelay,
722
- signal: options.signal,
723
- timeoutMs: options.timeoutMs ?? 3e5
840
+ signal: options.signal
724
841
  };
725
842
  }
726
843
  function makeAborted(signal) {
@@ -742,19 +859,28 @@ function abortedResult(signal) {
742
859
  * @param context - The loop state, failure cap, and abort signal.
743
860
  * @returns Whether to return a final Result or continue with updated state.
744
861
  */
745
- function applyOutcome(outcome, { maxFailures, signal, state }) {
862
+ function applyOutcome(outcome, { budget, maxFailures, signal, state }) {
746
863
  switch (outcome.kind) {
747
864
  case "aborted": return {
748
865
  kind: "return",
749
866
  result: abortedResult(signal)
750
867
  };
751
- case "failed": return {
752
- kind: "return",
753
- result: {
754
- err: outcome.error,
755
- success: false
756
- }
757
- };
868
+ case "failed":
869
+ if (signal?.aborted === true && isBudgetDeadline(outcome.error, budget)) return {
870
+ kind: "return",
871
+ result: abortedResult(signal)
872
+ };
873
+ return {
874
+ kind: "return",
875
+ result: {
876
+ err: budgetFailure(outcome.error, {
877
+ budget,
878
+ lastTask: state.lastTask,
879
+ signal
880
+ }),
881
+ success: false
882
+ }
883
+ };
758
884
  case "pending": return {
759
885
  kind: "continue",
760
886
  state: {
@@ -791,15 +917,9 @@ function applyOutcome(outcome, { maxFailures, signal, state }) {
791
917
  async function sleepWithAbortAsync({ ms, signal, sleep }) {
792
918
  return await raceWithAbortAsync(async () => sleep(ms, signal), signal) === ABORTED;
793
919
  }
794
- function makeTimeout(task, timeoutMs) {
795
- return new PollTimeoutError(`Polling timed out after ${timeoutMs} ms`, {
796
- lastObservedTask: task,
797
- timeoutMs
798
- });
799
- }
800
920
  /**
801
- * A failed poll is worth re-polling only when it is a `NetworkError` carrying a
802
- * known transient transport code. A self-aborted request timeout has no
921
+ * A failed poll is worth re-polling only when it is a `NetworkError` carrying
922
+ * a known transient transport code. A self-aborted request timeout has no
803
923
  * `code`, and an API response (4xx/5xx) is authoritative, so both abort the
804
924
  * loop rather than being re-polled. Transient-ness is classified against the
805
925
  * canonical `TRANSIENT_TRANSPORT_CODES` set; this is the loop's own tolerance
@@ -821,8 +941,8 @@ function isTransientTransport(error) {
821
941
  const code = findErrorCode(error);
822
942
  return code !== void 0 && TRANSIENT_TRANSPORT_CODES.includes(code);
823
943
  }
824
- async function fetchOnceAsync(dependencies, signal) {
825
- const fetchResult = await raceWithAbortAsync(dependencies.fetch, signal);
944
+ async function fetchOnceAsync(dependencies, { budget, signal }) {
945
+ const fetchResult = await raceWithAbortAsync(async () => dependencies.fetch(budget.requestDeadlineMs), signal);
826
946
  if (fetchResult === ABORTED) return { kind: "aborted" };
827
947
  if (!fetchResult.success) return isTransientTransport(fetchResult.err) ? {
828
948
  error: fetchResult.err,
@@ -840,6 +960,35 @@ async function fetchOnceAsync(dependencies, signal) {
840
960
  };
841
961
  }
842
962
  //#endregion
963
+ //#region src/resources/luau-execution/submit-once.ts
964
+ /**
965
+ * Submits a Luau task once. A 429 naming tasks that occupy the place never
966
+ * locks the submit operation out, whether or not the caller opted into
967
+ * capacity admission: it clears when those tasks end.
968
+ *
969
+ * @param call - Resource client, submit parameters, options, and refinement.
970
+ * @returns The submitted task or the failure the attempt produced.
971
+ */
972
+ async function submitOnceAsync({ inner, options, parameters, refineError }) {
973
+ function exemptsLockout(error) {
974
+ return namesCapacityBlockers(error, parameters);
975
+ }
976
+ const call = {
977
+ exemptsLockout,
978
+ options,
979
+ refineError
980
+ };
981
+ return "versionId" in parameters ? inner.executeAsync({
982
+ ...call,
983
+ parameters,
984
+ spec: SUBMIT_VERSION_SPEC
985
+ }) : inner.executeAsync({
986
+ ...call,
987
+ parameters,
988
+ spec: SUBMIT_HEAD_SPEC
989
+ });
990
+ }
991
+ //#endregion
843
992
  //#region src/resources/luau-execution/capacity-admission.ts
844
993
  const MAX_CAPACITY_WAIT_MS = 2147483647;
845
994
  /**
@@ -877,19 +1026,6 @@ async function submitWithCapacityAsync({ inner, options, parameters }) {
877
1026
  function isCapacityFailure(result) {
878
1027
  return !result.success && result.err instanceof LuauExecutionCapacityError;
879
1028
  }
880
- async function submitOnceAsync({ inner, options, parameters, refineError }) {
881
- return "versionId" in parameters ? inner.executeAsync({
882
- options,
883
- parameters,
884
- refineError,
885
- spec: SUBMIT_VERSION_SPEC
886
- }) : inner.executeAsync({
887
- options,
888
- parameters,
889
- refineError,
890
- spec: SUBMIT_HEAD_SPEC
891
- });
892
- }
893
1029
  function capacityBoundAborted(options, callerSignal) {
894
1030
  return options.signal?.aborted === true && callerSignal?.aborted !== true;
895
1031
  }
@@ -1055,9 +1191,9 @@ async function admitWithinCapacityAsync({ capacityError, options, submitCall, wa
1055
1191
  */
1056
1192
  function buildPollDependencies(inner, args) {
1057
1193
  return {
1058
- fetch: async () => {
1194
+ fetch: async (deadlineMs) => {
1059
1195
  return inner.executeAsync({
1060
- options: args.options,
1196
+ options: withRequestDeadline(args.options, deadlineMs),
1061
1197
  parameters: {
1062
1198
  ref: args.ref,
1063
1199
  view: "BASIC"
@@ -1072,7 +1208,10 @@ function buildPollDependencies(inner, args) {
1072
1208
  /**
1073
1209
  * Submits a Luau execution task and polls it to a terminal state. Dispatches
1074
1210
  * to the head-version or specific-version submit spec based on the presence of
1075
- * `versionId`, then delegates to {@link pollUntilDoneCoreAsync}.
1211
+ * `versionId`, then delegates to {@link pollUntilDoneCoreAsync}. The poll
1212
+ * budget opens before the submit, so `timeoutMs` covers the submit and the
1213
+ * polling together; a submit cut off by the budget returns
1214
+ * `PollTimeoutError` with no task.
1076
1215
  *
1077
1216
  * @param inner - The {@link ResourceClient} that issues submit and poll calls.
1078
1217
  * @param args - The polling options and submit parameters.
@@ -1080,18 +1219,45 @@ function buildPollDependencies(inner, args) {
1080
1219
  * the {@link OpenCloudError} that caused submit or polling to fail.
1081
1220
  */
1082
1221
  async function submitAndPollAsync(inner, { options, parameters }) {
1222
+ const startedAt = Date.now();
1223
+ const budget = openPollBudget(startedAt, options);
1083
1224
  const submitResult = await submitWithCapacityAsync({
1084
1225
  inner,
1085
- options,
1226
+ options: withRequestDeadline(options, budget.requestDeadlineMs),
1086
1227
  parameters
1087
1228
  });
1088
- if (!submitResult.success) return submitResult;
1089
- return pollUntilDoneCoreAsync(buildPollDependencies(inner, {
1090
- options,
1091
- ref: submitResult.data.ref
1092
- }), options);
1229
+ if (!submitResult.success) return {
1230
+ err: budgetFailure(submitResult.err, {
1231
+ budget,
1232
+ lastTask: void 0,
1233
+ signal: options.signal
1234
+ }),
1235
+ success: false
1236
+ };
1237
+ return pollUntilDoneCoreAsync({
1238
+ ...buildPollDependencies(inner, {
1239
+ options,
1240
+ ref: submitResult.data.ref
1241
+ }),
1242
+ startedAt
1243
+ }, options);
1244
+ }
1245
+ /**
1246
+ * Applies the budget's request deadline. It already folds in the caller's own
1247
+ * `deadlineMs`, so it is `undefined` only when the caller set none either.
1248
+ *
1249
+ * @template TOptions - The concrete option shape to preserve.
1250
+ * @param options - The caller's options.
1251
+ * @param deadlineMs - The request deadline from the opened budget.
1252
+ * @returns The options with `deadlineMs` set to the request deadline.
1253
+ */
1254
+ function withRequestDeadline(options, deadlineMs) {
1255
+ return {
1256
+ ...options,
1257
+ deadlineMs
1258
+ };
1093
1259
  }
1094
1260
  //#endregion
1095
1261
  export { pollUntilDoneCoreAsync as a, LIST_LOGS_SPEC as c, defaultPollDelay as i, LuauExecutionCapacityError as l, submitAndPollAsync as n, withBudgetRequestTimeout as o, submitWithCapacityAsync as r, GET_SPEC as s, buildPollDependencies as t };
1096
1262
 
1097
- //# sourceMappingURL=polling-helpers-sKTsqEc1.mjs.map
1263
+ //# sourceMappingURL=polling-helpers-DfF5dspc.mjs.map