@bedrock-rbx/ocale 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/badges.d.mts +1 -1
- package/dist/badges.mjs +3 -3
- package/dist/{polling-0t1wQyVY.d.mts → capacity-admission-BvnJjY0S.d.mts} +35 -3
- package/dist/capacity-admission-BvnJjY0S.d.mts.map +1 -0
- package/dist/developer-products.d.mts +1 -1
- package/dist/developer-products.mjs +4 -4
- package/dist/game-passes.d.mts +1 -1
- package/dist/game-passes.mjs +4 -4
- package/dist/index.d.mts +112 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/luau-execution.d.mts +39 -5
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +8 -13
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{network-error-DmNy_j-u.mjs → network-error-DR9FX5hb.mjs} +32 -7
- package/dist/network-error-DR9FX5hb.mjs.map +1 -0
- package/dist/places.d.mts +4 -4
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +8 -13
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-wrPTnGl_.mjs → poll-timeout-3PXLsabj.mjs} +2 -2
- package/dist/{poll-timeout-wrPTnGl_.mjs.map → poll-timeout-3PXLsabj.mjs.map} +1 -1
- package/dist/{polling-helpers-CzdT2FS5.mjs → polling-helpers-CFuSt2O5.mjs} +323 -21
- package/dist/polling-helpers-CFuSt2O5.mjs.map +1 -0
- package/dist/{price-information-Czs5cWR1.mjs → price-information-D8BxwgTS.mjs} +2 -2
- package/dist/{price-information-Czs5cWR1.mjs.map → price-information-D8BxwgTS.mjs.map} +1 -1
- package/dist/{resource-client-aqk_V4TD.mjs → resource-client--yYybltk.mjs} +254 -72
- package/dist/resource-client--yYybltk.mjs.map +1 -0
- package/dist/resource-client-BivRq3JZ.d.mts +164 -0
- package/dist/resource-client-BivRq3JZ.d.mts.map +1 -0
- package/dist/{retry-DIK_T_oF.mjs → retry-Cc4LcXYZ.mjs} +266 -132
- package/dist/retry-Cc4LcXYZ.mjs.map +1 -0
- package/dist/{retry-Cj5OXCdL.d.mts → retry-DXEklFrt.d.mts} +51 -16
- package/dist/{retry-Cj5OXCdL.d.mts.map → retry-DXEklFrt.d.mts.map} +1 -1
- package/dist/storage.d.mts +2 -158
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +3 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/{types-D_njb3qW.d.mts → types-C3Egi37J.d.mts} +14 -8
- package/dist/types-C3Egi37J.d.mts.map +1 -0
- package/dist/universes.d.mts +1 -1
- package/dist/universes.mjs +4 -4
- package/dist/{validation-BwjwOJPD.mjs → validation-B_Zs1So2.mjs} +2 -2
- package/dist/{validation-BwjwOJPD.mjs.map → validation-B_Zs1So2.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/network-error-DmNy_j-u.mjs.map +0 -1
- package/dist/polling-0t1wQyVY.d.mts.map +0 -1
- package/dist/polling-helpers-CzdT2FS5.mjs.map +0 -1
- package/dist/resource-client-aqk_V4TD.mjs.map +0 -1
- package/dist/retry-DIK_T_oF.mjs.map +0 -1
- package/dist/types-D_njb3qW.d.mts.map +0 -1
|
@@ -1,8 +1,104 @@
|
|
|
1
|
-
import { a as ApiError, t as NetworkError } from "./network-error-
|
|
2
|
-
import {
|
|
3
|
-
import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-
|
|
4
|
-
import { t as ValidationError } from "./validation-
|
|
5
|
-
import { a as
|
|
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-Cc4LcXYZ.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--yYybltk.mjs";
|
|
6
|
+
//#region src/resources/luau-execution/capacity-error.ts
|
|
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
|
+
/**
|
|
9
|
+
* A Luau task submission refused because validated tasks occupy the target
|
|
10
|
+
* place's execution capacity.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { LuauExecutionCapacityError } from "@bedrock-rbx/ocale/luau-execution";
|
|
16
|
+
*
|
|
17
|
+
* const error = new LuauExecutionCapacityError([{
|
|
18
|
+
* placeId: "456",
|
|
19
|
+
* sessionId: "11111111-1111-4111-8111-111111111111",
|
|
20
|
+
* taskId: "22222222-2222-4222-8222-222222222222",
|
|
21
|
+
* universeId: "123",
|
|
22
|
+
* versionId: "789",
|
|
23
|
+
* }]);
|
|
24
|
+
* expect(error.blockers).toHaveLength(1);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @since 0.3.2
|
|
28
|
+
*/
|
|
29
|
+
var LuauExecutionCapacityError = class extends OpenCloudError {
|
|
30
|
+
/** Validated task references reported as occupying the target place. */
|
|
31
|
+
blockers;
|
|
32
|
+
name = "LuauExecutionCapacityError";
|
|
33
|
+
/**
|
|
34
|
+
* Creates a capacity failure from validated blocker references.
|
|
35
|
+
*
|
|
36
|
+
* @param blockers - Tasks reported as occupying the submitted place.
|
|
37
|
+
*/
|
|
38
|
+
constructor(blockers) {
|
|
39
|
+
super("Luau execution capacity is occupied", { code: "RESOURCE_EXHAUSTED" });
|
|
40
|
+
this.blockers = Object.freeze(blockers.map((blocker) => Object.freeze({ ...blocker })));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Builds the identity key shared by capacity blocker collections.
|
|
45
|
+
*
|
|
46
|
+
* @param ref - Luau task reference to identify.
|
|
47
|
+
* @returns The version, session, and task identity components.
|
|
48
|
+
*/
|
|
49
|
+
function luauTaskRefKey(ref) {
|
|
50
|
+
return `${ref.versionId}/${ref.sessionId}/${ref.taskId}`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts a positively identified Luau capacity response into its typed
|
|
54
|
+
* error.
|
|
55
|
+
*
|
|
56
|
+
* @param error - The response error to inspect.
|
|
57
|
+
* @param parameters - The submitted target used to validate blocker refs.
|
|
58
|
+
* @returns A typed capacity error, or `undefined` without positive evidence.
|
|
59
|
+
*/
|
|
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);
|
|
65
|
+
return blockers.length === 0 ? void 0 : new LuauExecutionCapacityError(blockers);
|
|
66
|
+
}
|
|
67
|
+
function capacityMessage(details) {
|
|
68
|
+
if (details === null || typeof details !== "object" || Array.isArray(details)) return;
|
|
69
|
+
const code = Reflect.get(details, "code");
|
|
70
|
+
const message = Reflect.get(details, "message");
|
|
71
|
+
return code === "RESOURCE_EXHAUSTED" && typeof message === "string" ? message : void 0;
|
|
72
|
+
}
|
|
73
|
+
function escapeRegExp(value) {
|
|
74
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
75
|
+
}
|
|
76
|
+
function compareTaskRefs(left, right) {
|
|
77
|
+
return luauTaskRefKey(left).localeCompare(luauTaskRefKey(right));
|
|
78
|
+
}
|
|
79
|
+
function blockerRefsFrom(message, parameters) {
|
|
80
|
+
const universeId = escapeRegExp(parameters.universeId);
|
|
81
|
+
const placeId = escapeRegExp(parameters.placeId);
|
|
82
|
+
const pattern = new RegExp(`universes/(${universeId})/places/(${placeId})/versions/([1-9][0-9]*)/luau-execution-sessions/(${UUID_PATTERN})/tasks/(${UUID_PATTERN})(?=$|[^A-Za-z0-9_-])`, "giu");
|
|
83
|
+
const unique = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const match of message.matchAll(pattern)) {
|
|
85
|
+
const matchedUniverseId = String(match[1]);
|
|
86
|
+
const matchedPlaceId = String(match[2]);
|
|
87
|
+
const versionId = String(match[3]);
|
|
88
|
+
const sessionId = String(match[4]);
|
|
89
|
+
const taskId = String(match[5]);
|
|
90
|
+
const ref = Object.freeze({
|
|
91
|
+
placeId: matchedPlaceId,
|
|
92
|
+
sessionId,
|
|
93
|
+
taskId,
|
|
94
|
+
universeId: matchedUniverseId,
|
|
95
|
+
versionId
|
|
96
|
+
});
|
|
97
|
+
unique.set(luauTaskRefKey(ref), ref);
|
|
98
|
+
}
|
|
99
|
+
return Object.freeze([...unique.values()].toSorted(compareTaskRefs));
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
6
102
|
//#region src/domains/cloud-v2/luau-execution-task-logs/builders.ts
|
|
7
103
|
/**
|
|
8
104
|
* Builds a `GET` request for the Open Cloud "list Luau execution session
|
|
@@ -557,17 +653,27 @@ function defaultPollDelay(elapsedMs) {
|
|
|
557
653
|
* already agreed to wait for the whole operation, so the backend can answer or
|
|
558
654
|
* surface a retryable status instead.
|
|
559
655
|
*
|
|
656
|
+
* @template TOptions - The concrete polling option shape to preserve.
|
|
560
657
|
* @param options - The caller's poll and per-request options.
|
|
561
658
|
* @returns The options with `timeout` filled from the budget when it was unset.
|
|
562
659
|
*/
|
|
563
660
|
function withBudgetRequestTimeout(options) {
|
|
564
|
-
|
|
661
|
+
const timeout = options.timeout ?? options.timeoutMs ?? 3e5;
|
|
565
662
|
return {
|
|
566
663
|
...options,
|
|
567
|
-
timeout
|
|
664
|
+
timeout
|
|
568
665
|
};
|
|
569
666
|
}
|
|
570
667
|
/**
|
|
668
|
+
* Reports whether a Luau task can no longer change execution state.
|
|
669
|
+
*
|
|
670
|
+
* @param task - Task whose state should be classified.
|
|
671
|
+
* @returns Whether the task is complete, failed, or cancelled.
|
|
672
|
+
*/
|
|
673
|
+
function isTerminalTask(task) {
|
|
674
|
+
return task.state === "COMPLETE" || task.state === "FAILED" || task.state === "CANCELLED";
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
571
677
|
* Core polling loop. Calls `deps.fetch()` repeatedly, sleeping
|
|
572
678
|
* `pollDelay(elapsedMs)` ms between iterations, until a terminal state
|
|
573
679
|
* is observed, the wall-clock budget is exhausted, or an `AbortSignal`
|
|
@@ -691,9 +797,6 @@ function makeTimeout(task, timeoutMs) {
|
|
|
691
797
|
timeoutMs
|
|
692
798
|
});
|
|
693
799
|
}
|
|
694
|
-
function isTerminal(task) {
|
|
695
|
-
return task.state === "COMPLETE" || task.state === "FAILED" || task.state === "CANCELLED";
|
|
696
|
-
}
|
|
697
800
|
/**
|
|
698
801
|
* A failed poll is worth re-polling only when it is a `NetworkError` carrying a
|
|
699
802
|
* known transient transport code. A self-aborted request timeout has no
|
|
@@ -728,7 +831,7 @@ async function fetchOnceAsync(dependencies, signal) {
|
|
|
728
831
|
error: fetchResult.err,
|
|
729
832
|
kind: "failed"
|
|
730
833
|
};
|
|
731
|
-
return
|
|
834
|
+
return isTerminalTask(fetchResult.data) ? {
|
|
732
835
|
kind: "terminal",
|
|
733
836
|
task: fetchResult.data
|
|
734
837
|
} : {
|
|
@@ -737,6 +840,209 @@ async function fetchOnceAsync(dependencies, signal) {
|
|
|
737
840
|
};
|
|
738
841
|
}
|
|
739
842
|
//#endregion
|
|
843
|
+
//#region src/resources/luau-execution/capacity-admission.ts
|
|
844
|
+
const MAX_CAPACITY_WAIT_MS = 2147483647;
|
|
845
|
+
/**
|
|
846
|
+
* Submits through capacity admission when the caller opts in.
|
|
847
|
+
*
|
|
848
|
+
* @param call - Resource client, submit parameters, and per-request options.
|
|
849
|
+
* @returns The submitted task or the failure that stopped admission.
|
|
850
|
+
*/
|
|
851
|
+
async function submitWithCapacityAsync({ inner, options, parameters }) {
|
|
852
|
+
const { capacityWaitMs, ...requestOptions } = options ?? {};
|
|
853
|
+
if (capacityWaitMs === void 0) return submitOnceAsync({
|
|
854
|
+
inner,
|
|
855
|
+
options: requestOptions,
|
|
856
|
+
parameters
|
|
857
|
+
});
|
|
858
|
+
function refineError(error) {
|
|
859
|
+
return capacityErrorFrom(error, parameters) ?? error;
|
|
860
|
+
}
|
|
861
|
+
const submitCall = {
|
|
862
|
+
inner,
|
|
863
|
+
options: requestOptions,
|
|
864
|
+
parameters,
|
|
865
|
+
refineError
|
|
866
|
+
};
|
|
867
|
+
const first = await submitOnceAsync(submitCall);
|
|
868
|
+
if (!isCapacityFailure(first)) return first;
|
|
869
|
+
if (!Number.isFinite(capacityWaitMs) || capacityWaitMs < 1 || capacityWaitMs > MAX_CAPACITY_WAIT_MS) return first;
|
|
870
|
+
return admitWithinCapacityAsync({
|
|
871
|
+
capacityError: first.err,
|
|
872
|
+
options: requestOptions,
|
|
873
|
+
submitCall,
|
|
874
|
+
waitMs: capacityWaitMs
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function isCapacityFailure(result) {
|
|
878
|
+
return !result.success && result.err instanceof LuauExecutionCapacityError;
|
|
879
|
+
}
|
|
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
|
+
function capacityBoundAborted(options, callerSignal) {
|
|
894
|
+
return options.signal?.aborted === true && callerSignal?.aborted !== true;
|
|
895
|
+
}
|
|
896
|
+
async function observeBlockersAsync({ blockers, inner, options }) {
|
|
897
|
+
for (const blocker of blockers) {
|
|
898
|
+
const observed = await inner.executeAsync({
|
|
899
|
+
options,
|
|
900
|
+
parameters: {
|
|
901
|
+
ref: blocker,
|
|
902
|
+
view: "BASIC"
|
|
903
|
+
},
|
|
904
|
+
spec: GET_SPEC
|
|
905
|
+
});
|
|
906
|
+
if (!observed.success) return observed;
|
|
907
|
+
if (isTerminalTask(observed.data)) return {
|
|
908
|
+
data: blocker,
|
|
909
|
+
success: true
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
data: void 0,
|
|
914
|
+
success: true
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
async function sleepForCapacityAsync({ inner, options, waitMs }) {
|
|
918
|
+
await observeAdmissionWaitAsync({
|
|
919
|
+
durationMs: waitMs,
|
|
920
|
+
observer: options.onAdmissionWait,
|
|
921
|
+
reason: "operation-capacity",
|
|
922
|
+
waitAsync: async () => {
|
|
923
|
+
return raceWithAbortAsync(async () => inner.sleep(waitMs, options.signal), options.signal);
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
async function observeWithinCapacityAsync({ blockers, capacityError, deadlineAt, inner, options, startedAt }) {
|
|
928
|
+
while (Date.now() < deadlineAt) {
|
|
929
|
+
const observed = await observeBlockersAsync({
|
|
930
|
+
blockers,
|
|
931
|
+
inner,
|
|
932
|
+
options
|
|
933
|
+
});
|
|
934
|
+
if (!observed.success) return observed;
|
|
935
|
+
if (observed.data !== void 0) return {
|
|
936
|
+
data: observed.data,
|
|
937
|
+
success: true
|
|
938
|
+
};
|
|
939
|
+
const pollWaitMs = defaultPollDelay(Date.now() - startedAt);
|
|
940
|
+
const deadlineFailure = waitDeadlineFailure({
|
|
941
|
+
cause: capacityError,
|
|
942
|
+
deadlineMs: options.deadlineMs,
|
|
943
|
+
waitMs: pollWaitMs,
|
|
944
|
+
waitReason: "operation-capacity"
|
|
945
|
+
});
|
|
946
|
+
if (deadlineFailure !== void 0) return {
|
|
947
|
+
err: deadlineFailure,
|
|
948
|
+
success: false
|
|
949
|
+
};
|
|
950
|
+
await sleepForCapacityAsync({
|
|
951
|
+
inner,
|
|
952
|
+
options,
|
|
953
|
+
waitMs: Math.min(pollWaitMs, deadlineAt - Date.now())
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
return {
|
|
957
|
+
err: capacityError,
|
|
958
|
+
success: false
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
function hasSameBlockers(left, right) {
|
|
962
|
+
if (left.blockers.length !== right.blockers.length) return false;
|
|
963
|
+
const rightKeys = new Set(right.blockers.map(luauTaskRefKey));
|
|
964
|
+
return left.blockers.every((blocker) => rightKeys.has(luauTaskRefKey(blocker)));
|
|
965
|
+
}
|
|
966
|
+
async function retryAfterCapacityAsync({ callerSignal, current, options, submitCall }) {
|
|
967
|
+
const retried = await submitOnceAsync(submitCall);
|
|
968
|
+
if (!retried.success && capacityBoundAborted(options, callerSignal)) return {
|
|
969
|
+
continue: false,
|
|
970
|
+
result: {
|
|
971
|
+
err: current,
|
|
972
|
+
success: false
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
if (!isCapacityFailure(retried) || hasSameBlockers(current, retried.err)) return {
|
|
976
|
+
continue: false,
|
|
977
|
+
result: retried
|
|
978
|
+
};
|
|
979
|
+
return {
|
|
980
|
+
capacityError: retried.err,
|
|
981
|
+
continue: true
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
async function runCapacityAdmissionAsync({ callerSignal, capacityError, deadlineAt, options, startedAt, submitCall }) {
|
|
985
|
+
const cleared = /* @__PURE__ */ new Set();
|
|
986
|
+
let current = capacityError;
|
|
987
|
+
while (true) {
|
|
988
|
+
const pending = current.blockers.filter((blocker) => !cleared.has(luauTaskRefKey(blocker)));
|
|
989
|
+
if (pending.length === 0) return {
|
|
990
|
+
err: current,
|
|
991
|
+
success: false
|
|
992
|
+
};
|
|
993
|
+
const observed = await observeWithinCapacityAsync({
|
|
994
|
+
blockers: pending,
|
|
995
|
+
capacityError: current,
|
|
996
|
+
deadlineAt,
|
|
997
|
+
inner: submitCall.inner,
|
|
998
|
+
options,
|
|
999
|
+
startedAt
|
|
1000
|
+
});
|
|
1001
|
+
if (!observed.success) return capacityBoundAborted(options, callerSignal) ? {
|
|
1002
|
+
err: current,
|
|
1003
|
+
success: false
|
|
1004
|
+
} : observed;
|
|
1005
|
+
cleared.add(luauTaskRefKey(observed.data));
|
|
1006
|
+
const retry = await retryAfterCapacityAsync({
|
|
1007
|
+
callerSignal,
|
|
1008
|
+
current,
|
|
1009
|
+
options,
|
|
1010
|
+
submitCall
|
|
1011
|
+
});
|
|
1012
|
+
if (!retry.continue) return retry.result;
|
|
1013
|
+
current = retry.capacityError;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
async function admitWithinCapacityAsync({ capacityError, options, submitCall, waitMs }) {
|
|
1017
|
+
const deadline = new AbortController();
|
|
1018
|
+
const timer = setTimeout(() => {
|
|
1019
|
+
deadline.abort();
|
|
1020
|
+
}, waitMs);
|
|
1021
|
+
const signal = options.signal === void 0 ? deadline.signal : AbortSignal.any([options.signal, deadline.signal]);
|
|
1022
|
+
const startedAt = Date.now();
|
|
1023
|
+
try {
|
|
1024
|
+
return await runCapacityAdmissionAsync({
|
|
1025
|
+
callerSignal: options.signal,
|
|
1026
|
+
capacityError,
|
|
1027
|
+
deadlineAt: startedAt + waitMs,
|
|
1028
|
+
options: {
|
|
1029
|
+
...options,
|
|
1030
|
+
signal
|
|
1031
|
+
},
|
|
1032
|
+
startedAt,
|
|
1033
|
+
submitCall: {
|
|
1034
|
+
...submitCall,
|
|
1035
|
+
options: {
|
|
1036
|
+
...submitCall.options,
|
|
1037
|
+
signal
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
} finally {
|
|
1042
|
+
clearTimeout(timer);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
740
1046
|
//#region src/resources/luau-execution/polling-helpers.ts
|
|
741
1047
|
/**
|
|
742
1048
|
* Builds the {@link PollDependencies} bundle used by {@link
|
|
@@ -774,15 +1080,11 @@ function buildPollDependencies(inner, args) {
|
|
|
774
1080
|
* the {@link OpenCloudError} that caused submit or polling to fail.
|
|
775
1081
|
*/
|
|
776
1082
|
async function submitAndPollAsync(inner, { options, parameters }) {
|
|
777
|
-
const submitResult = await (
|
|
778
|
-
|
|
779
|
-
parameters,
|
|
780
|
-
spec: SUBMIT_VERSION_SPEC
|
|
781
|
-
}) : inner.executeAsync({
|
|
1083
|
+
const submitResult = await submitWithCapacityAsync({
|
|
1084
|
+
inner,
|
|
782
1085
|
options,
|
|
783
|
-
parameters
|
|
784
|
-
|
|
785
|
-
}));
|
|
1086
|
+
parameters
|
|
1087
|
+
});
|
|
786
1088
|
if (!submitResult.success) return submitResult;
|
|
787
1089
|
return pollUntilDoneCoreAsync(buildPollDependencies(inner, {
|
|
788
1090
|
options,
|
|
@@ -790,6 +1092,6 @@ async function submitAndPollAsync(inner, { options, parameters }) {
|
|
|
790
1092
|
}), options);
|
|
791
1093
|
}
|
|
792
1094
|
//#endregion
|
|
793
|
-
export {
|
|
1095
|
+
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 };
|
|
794
1096
|
|
|
795
|
-
//# sourceMappingURL=polling-helpers-
|
|
1097
|
+
//# sourceMappingURL=polling-helpers-CFuSt2O5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polling-helpers-CFuSt2O5.mjs","names":["SECONDS_PER_MINUTE","malformed","makeSpec"],"sources":["../src/resources/luau-execution/capacity-error.ts","../src/domains/cloud-v2/luau-execution-task-logs/builders.ts","../src/domains/cloud-v2/luau-execution-task-logs/operations.ts","../src/domains/cloud-v2/luau-execution-task-logs/parsers.ts","../src/domains/cloud-v2/luau-execution-task-logs/specs.ts","../src/domains/cloud-v2/luau-execution-tasks/builders.ts","../src/domains/cloud-v2/luau-execution-tasks/operations.ts","../src/domains/cloud-v2/luau-execution-tasks/parsers.ts","../src/domains/cloud-v2/luau-execution-tasks/specs.ts","../src/resources/luau-execution/polling.ts","../src/resources/luau-execution/capacity-admission.ts","../src/resources/luau-execution/polling-helpers.ts"],"sourcesContent":["import type {\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport { OpenCloudError } from \"../../errors/base.ts\";\nimport { RateLimitError } from \"../../errors/rate-limit.ts\";\n\nconst UUID_PATTERN = \"[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\";\n\n/**\n * A Luau task submission refused because validated tasks occupy the target\n * place's execution capacity.\n *\n * @example\n *\n * ```ts\n * import { LuauExecutionCapacityError } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const error = new LuauExecutionCapacityError([{\n * placeId: \"456\",\n * sessionId: \"11111111-1111-4111-8111-111111111111\",\n * taskId: \"22222222-2222-4222-8222-222222222222\",\n * universeId: \"123\",\n * versionId: \"789\",\n * }]);\n * expect(error.blockers).toHaveLength(1);\n * ```\n *\n * @since 0.3.2\n */\nexport class LuauExecutionCapacityError extends OpenCloudError {\n\t/** Validated task references reported as occupying the target place. */\n\tpublic readonly blockers: ReadonlyArray<LuauExecutionTaskRef>;\n\tpublic override readonly name = \"LuauExecutionCapacityError\";\n\n\t/**\n\t * Creates a capacity failure from validated blocker references.\n\t *\n\t * @param blockers - Tasks reported as occupying the submitted place.\n\t */\n\tconstructor(blockers: ReadonlyArray<LuauExecutionTaskRef>) {\n\t\tsuper(\"Luau execution capacity is occupied\", { code: \"RESOURCE_EXHAUSTED\" });\n\t\tthis.blockers = Object.freeze(blockers.map((blocker) => Object.freeze({ ...blocker })));\n\t}\n}\n\n/**\n * Builds the identity key shared by capacity blocker collections.\n *\n * @param ref - Luau task reference to identify.\n * @returns The version, session, and task identity components.\n */\nexport function luauTaskRefKey(ref: LuauExecutionTaskRef): string {\n\treturn `${ref.versionId}/${ref.sessionId}/${ref.taskId}`;\n}\n\n/**\n * Converts a positively identified Luau capacity response into its typed\n * error.\n *\n * @param error - The response error to inspect.\n * @param parameters - The submitted target used to validate blocker refs.\n * @returns A typed capacity error, or `undefined` without positive evidence.\n */\nexport function capacityErrorFrom(\n\terror: OpenCloudError,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): LuauExecutionCapacityError | undefined {\n\tif (!(error instanceof RateLimitError) || error.code !== \"RESOURCE_EXHAUSTED\") {\n\t\treturn undefined;\n\t}\n\n\tconst message = capacityMessage(error.details);\n\tif (message === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst blockers = blockerRefsFrom(message, parameters);\n\treturn blockers.length === 0 ? undefined : new LuauExecutionCapacityError(blockers);\n}\n\nfunction capacityMessage(details: JSONValue | undefined): string | undefined {\n\tif (details === null || typeof details !== \"object\" || Array.isArray(details)) {\n\t\treturn undefined;\n\t}\n\n\tconst code = Reflect.get(details, \"code\");\n\tconst message = Reflect.get(details, \"message\");\n\treturn code === \"RESOURCE_EXHAUSTED\" && typeof message === \"string\" ? message : undefined;\n}\n\nfunction escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/gu, \"\\\\$&\");\n}\n\nfunction compareTaskRefs(left: LuauExecutionTaskRef, right: LuauExecutionTaskRef): number {\n\treturn luauTaskRefKey(left).localeCompare(luauTaskRefKey(right));\n}\n\nfunction blockerRefsFrom(\n\tmessage: string,\n\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters,\n): ReadonlyArray<LuauExecutionTaskRef> {\n\tconst universeId = escapeRegExp(parameters.universeId);\n\tconst placeId = escapeRegExp(parameters.placeId);\n\tconst pattern = new RegExp(\n\t\t`universes/(${universeId})/places/(${placeId})/versions/([1-9][0-9]*)/luau-execution-sessions/(${UUID_PATTERN})/tasks/(${UUID_PATTERN})(?=$|[^A-Za-z0-9_-])`,\n\t\t\"giu\",\n\t);\n\tconst unique = new Map<string, LuauExecutionTaskRef>();\n\tfor (const match of message.matchAll(pattern)) {\n\t\tconst matchedUniverseId = String(match[1]);\n\t\tconst matchedPlaceId = String(match[2]);\n\t\tconst versionId = String(match[3]);\n\t\tconst sessionId = String(match[4]);\n\t\tconst taskId = String(match[5]);\n\n\t\tconst ref = Object.freeze({\n\t\t\tplaceId: matchedPlaceId,\n\t\t\tsessionId,\n\t\t\ttaskId,\n\t\t\tuniverseId: matchedUniverseId,\n\t\t\tversionId,\n\t\t});\n\t\tunique.set(luauTaskRefKey(ref), ref);\n\t}\n\n\treturn Object.freeze([...unique.values()].toSorted(compareTaskRefs));\n}\n","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.\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 (\n\t\tvalue === \"MESSAGE_TYPE_UNSPECIFIED\" ||\n\t\tvalue === \"OUTPUT\" ||\n\t\tvalue === \"INFO\" ||\n\t\tvalue === \"WARNING\" ||\n\t\tvalue === \"ERROR\"\n\t);\n}\n\nfunction isLogMessageWire(value: unknown): value is LogMessageWire {\n\treturn (\n\t\tisRecord(value) &&\n\t\ttypeof value[\"createTime\"] === \"string\" &&\n\t\ttypeof value[\"message\"] === \"string\" &&\n\t\tisAcceptedMessageType(value[\"messageType\"])\n\t);\n}\n\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_AT_HEAD_PER_MINUTE = 5;\nconst SUBMIT_AT_VERSION_PER_MINUTE = 5;\nconst GET_PER_MINUTE = 200;\nconst SECONDS_PER_MINUTE = 60;\n\n/**\n * Per-second request ceiling for submitting a Luau execution task at a\n * place's head version, sourced from\n * `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTask__Using_Universes` operation\n * (5 requests per minute per API key owner), which is also the burst\n * the server allows.\n */\nexport const SUBMIT_HEAD_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: SUBMIT_AT_HEAD_PER_MINUTE,\n\tmaxPerSecond: SUBMIT_AT_HEAD_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.submit\",\n});\n\n/**\n * Per-second request ceiling for submitting a Luau execution task at a\n * specific place version, sourced from\n * `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_CreateLuauExecutionSessionTask__Using_Universes_Places`\n * operation (5 requests per minute per API key owner), which is also\n * the burst the server allows. Carries its own operation key so the\n * version-pinned URL shape is paced from its own quota: the server\n * meters the two shapes in separate buckets whose ceilings are\n * additive, and pinned traffic does not consume head budget. The two\n * ceilings are equal (5 each), but equal is not shared.\n */\nexport const SUBMIT_VERSION_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tburstCapacity: SUBMIT_AT_VERSION_PER_MINUTE,\n\tmaxPerSecond: SUBMIT_AT_VERSION_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.submit-at-version\",\n});\n\n/**\n * Per-second request ceiling for fetching a Luau execution task,\n * sourced from `x-roblox-rate-limits.perApiKeyOwner` on the\n * `Cloud_GetLuauExecutionSessionTask` operation (200 requests per\n * minute per API key owner).\n */\nexport const GET_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: GET_PER_MINUTE / SECONDS_PER_MINUTE,\n\toperationKey: \"luau-execution-tasks.get\",\n});\n\n/**\n * Scopes required to submit a Luau execution task, sourced from\n * `x-roblox-scopes` on the create operation in the vendored OpenAPI\n * schema. Surfaced via the `requiredScopes` field of the per-method\n * spec so a 401 or 403 ApiError is upgraded to a `PermissionError`\n * naming the missing scope.\n */\nexport const SUBMIT_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:write\",\n]);\n\n/**\n * Scopes required to fetch a Luau execution task, sourced from\n * `x-roblox-scopes` on the get operation. The `:write` scope also\n * grants read in upstream auth, but we surface only `:read` here as\n * the minimum-privilege requirement for this method.\n */\nexport const GET_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"universe.place.luau-execution-session:read\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { 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(state: unknown): state is LuauExecutionTaskWire[\"state\"] {\n\treturn (\n\t\tstate === \"STATE_UNSPECIFIED\" ||\n\t\tstate === \"QUEUED\" ||\n\t\tstate === \"PROCESSING\" ||\n\t\tstate === \"CANCELLED\" ||\n\t\tstate === \"COMPLETE\" ||\n\t\tstate === \"FAILED\"\n\t);\n}\n\nfunction isErrorWireCode(code: unknown): code is LuauExecutionTaskErrorWire[\"code\"] {\n\treturn (\n\t\tcode === \"ERROR_CODE_UNSPECIFIED\" ||\n\t\tcode === \"SCRIPT_ERROR\" ||\n\t\tcode === \"DEADLINE_EXCEEDED\" ||\n\t\tcode === \"OUTPUT_SIZE_LIMIT_EXCEEDED\" ||\n\t\tcode === \"INTERNAL_ERROR\"\n\t);\n}\n\nfunction isErrorWire(value: unknown): value is LuauExecutionTaskErrorWire {\n\treturn (\n\t\tisRecord(value) && isErrorWireCode(value[\"code\"]) && typeof value[\"message\"] === \"string\"\n\t);\n}\n\nfunction isOptionalErrorWire(value: unknown): value is LuauExecutionTaskErrorWire | undefined {\n\treturn value === undefined || isErrorWire(value);\n}\n\nfunction isOutputWire(value: unknown): value is LuauExecutionTaskOutputWire {\n\treturn isRecord(value) && Array.isArray(value[\"results\"]);\n}\n\nfunction isOptionalOutputWire(value: unknown): value is LuauExecutionTaskOutputWire | undefined {\n\treturn value === undefined || isOutputWire(value);\n}\n\nfunction isOptionalString(value: unknown): value is string | undefined {\n\treturn value === undefined || typeof value === \"string\";\n}\n\nfunction isOptionalBoolean(value: unknown): value is boolean | undefined {\n\treturn value === undefined || typeof value === \"boolean\";\n}\n\nfunction isOptionalDateTimeString(value: unknown): value is string | undefined {\n\treturn value === undefined || isDateTimeString(value);\n}\n\nfunction isLuauExecutionTaskWire(body: unknown): body is LuauExecutionTaskWire {\n\treturn (\n\t\tisRecord(body) &&\n\t\ttypeof body[\"path\"] === \"string\" &&\n\t\tisOptionalDateTimeString(body[\"createTime\"]) &&\n\t\tisOptionalDateTimeString(body[\"updateTime\"]) &&\n\t\tisAcceptedWireState(body[\"state\"]) &&\n\t\ttypeof body[\"user\"] === \"string\" &&\n\t\tisOptionalOutputWire(body[\"output\"]) &&\n\t\tisOptionalErrorWire(body[\"error\"]) &&\n\t\tisOptionalDurationWire(body[\"timeout\"]) &&\n\t\tisOptionalString(body[\"binaryInput\"]) &&\n\t\tisOptionalBoolean(body[\"enableBinaryOutput\"]) &&\n\t\tisOptionalString(body[\"binaryOutputUri\"])\n\t);\n}\n\nfunction parseOptionalDate(value: string | undefined): Date | undefined {\n\treturn value === undefined ? undefined : new Date(value);\n}\n\nconst DURATION_PATTERN = /^(\\d+)s$/;\n\nfunction isOptionalDurationWire(value: unknown): value is string | undefined {\n\treturn value === undefined || (typeof value === \"string\" && DURATION_PATTERN.test(value));\n}\n\nfunction parseTimeoutSeconds(value: string | undefined): number | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst match = DURATION_PATTERN.exec(value);\n\tconst seconds = match?.[1];\n\tif (seconds === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn Number.parseInt(seconds, 10);\n}\n\nfunction malformed(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_HEAD_OPERATION_LIMIT,\n\tSUBMIT_REQUIRED_SCOPES,\n\tSUBMIT_VERSION_OPERATION_LIMIT,\n} from \"./operations.ts\";\nimport { parseLuauExecutionTaskResponse } from \"./parsers.ts\";\nimport type {\n\tGetParameters,\n\tLuauExecutionTask,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"./types.ts\";\n\nfunction makeSpec<P>(\n\tspec: ResourceMethodSpec<P, LuauExecutionTask>,\n): ResourceMethodSpec<P, LuauExecutionTask> {\n\treturn Object.freeze(spec);\n}\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * place's head version. Frozen at module scope so both the top-level\n * `LuauExecutionClient` and the `luauExecution` Operation Group on\n * `PlacesClient` share the same instance reference.\n */\nexport const SUBMIT_HEAD_SPEC = makeSpec<SubmitAtHeadParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtHeadRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_HEAD_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for submitting a Luau execution task at a\n * specific place version. Shares the required scope set with {@link\n * SUBMIT_HEAD_SPEC} but carries its own rate-limit queue: the server\n * meters the version-pinned URL shape in a bucket separate from the\n * head shape's.\n */\nexport const SUBMIT_VERSION_SPEC = makeSpec<SubmitAtVersionParameters>({\n\tbuildRequest: (parameters) => okRequest(buildSubmitAtVersionRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: SUBMIT_VERSION_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: SUBMIT_REQUIRED_SCOPES,\n});\n\n/**\n * Per-method dispatch spec for fetching a Luau execution task. Uses\n * idempotent retry semantics (429 and 5xx both retried) so reads\n * recover transparently from transient server errors.\n */\nexport const GET_SPEC = makeSpec<GetParameters>({\n\tbuildRequest: buildGetRequest,\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: GET_OPERATION_LIMIT,\n\tparse: parseLuauExecutionTaskResponse,\n\trequiredScopes: GET_REQUIRED_SCOPES,\n});\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport type { LuauExecutionTask } from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { NetworkError } from \"../../errors/network-error.ts\";\nimport { PollAbortedError } from \"../../errors/poll-aborted.ts\";\nimport { PollTimeoutError } from \"../../errors/poll-timeout.ts\";\nimport { TRANSIENT_TRANSPORT_CODES } from \"../../internal/http/retry.ts\";\nimport { ABORTED, raceWithAbortAsync } from \"../../internal/utils/abort.ts\";\nimport { findErrorCode } from \"../../internal/utils/find-error-code.ts\";\nimport type { SleepFunc } from \"../../internal/utils/sleep.ts\";\nimport type { Result } from \"../../types.ts\";\n\n/** Default total polling budget in milliseconds (5 minutes). */\nexport const DEFAULT_POLL_TIMEOUT_MS = 300_000;\n\n/** One step of the default poll-cadence schedule. */\ninterface PollDelayTier {\n\t/** Delay in ms to wait between polls while within this tier. */\n\treadonly delayMs: number;\n\t/**\n\t * Upper elapsed-time bound (exclusive) at which this tier stops applying.\n\t */\n\treadonly untilMs: number;\n}\n\n/** Steady-state delay once elapsed time reaches the final tier bound. */\nconst STEADY_POLL_DELAY_MS = 5_000;\n\n/**\n * Fast-to-slow poll-cadence tiers keyed on elapsed wall-clock time. Elapsed\n * times at or beyond the last `untilMs` fall through to\n * {@link STEADY_POLL_DELAY_MS}.\n */\nconst DEFAULT_POLL_TIERS: ReadonlyArray<PollDelayTier> = [\n\t{ delayMs: 500, untilMs: 20_000 },\n\t{ delayMs: 1_000, untilMs: 60_000 },\n];\n\n/**\n * Default poll cadence as a function of elapsed wall-clock time since\n * polling began. Polls quickly while a task is young so short runs resolve\n * snappily, then eases off so a long run leaves rate-limit headroom for\n * newer tasks: 0-20s is 500ms, 20-60s is 1000ms, 60s+ is 5000ms.\n *\n * @since 0.1.0\n *\n * @example\n * ```ts\n * import { defaultPollDelay } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * expect(defaultPollDelay(0)).toBe(500);\n * expect(defaultPollDelay(30_000)).toBe(1000);\n * expect(defaultPollDelay(120_000)).toBe(5000);\n * ```\n *\n * @param elapsedMs - Milliseconds elapsed since polling started.\n * @returns The delay in milliseconds to wait before the next poll.\n */\nexport function defaultPollDelay(elapsedMs: number): number {\n\tconst tier = DEFAULT_POLL_TIERS.find((candidate) => elapsedMs < candidate.untilMs);\n\treturn tier?.delayMs ?? STEADY_POLL_DELAY_MS;\n}\n\n/**\n * Default number of consecutive transport failures tolerated before the poll\n * loop gives up. With per-request retries already absorbing isolated blips,\n * three consecutive loop-level failures signals a genuinely unreachable\n * endpoint, so it bails in seconds rather than spinning out the wall-clock\n * budget.\n */\nexport const DEFAULT_POLL_FAILURE_CAP = 3;\n\n/**\n * Injected dependencies for the deep-module polling loop. The `fetch`\n * callback is pre-bound by the wiring layer and closes over the task ref\n * and request options, keeping the core loop narrow.\n */\nexport interface PollDependencies {\n\t/** 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\ninterface ResolvedPollOptions {\n\treadonly maxFailures: number;\n\treadonly pollDelay: (elapsedMs: number) => number;\n\treadonly signal: AbortSignal | undefined;\n\treadonly timeoutMs: number;\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 * 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 * @template TOptions - The concrete polling option shape to preserve.\n * @param options - The caller's poll and per-request options.\n * @returns The options with `timeout` filled from the budget when it was unset.\n */\nexport function withBudgetRequestTimeout<TOptions extends PollUntilDoneOptions>(\n\toptions: TOptions,\n): TOptions & { readonly timeout: number } {\n\tconst timeout = options.timeout ?? options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n\treturn { ...options, timeout };\n}\n\n/**\n * Reports whether a Luau task can no longer change execution state.\n *\n * @param task - Task whose state should be classified.\n * @returns Whether the task is complete, failed, or cancelled.\n */\nexport function isTerminalTask(task: LuauExecutionTask): boolean {\n\treturn task.state === \"COMPLETE\" || task.state === \"FAILED\" || task.state === \"CANCELLED\";\n}\n\n/**\n * Core polling loop. Calls `deps.fetch()` repeatedly, sleeping\n * `pollDelay(elapsedMs)` ms between iterations, until a terminal state\n * is observed, the wall-clock budget is exhausted, or an `AbortSignal`\n * fires. A transient transport failure ({@link NetworkError}) is tolerated\n * and the loop continues, giving up only after `maxConsecutivePollFailures`\n * consecutive failures; any other failure aborts immediately, since an API\n * response (a 404 for a vanished task, a 403) means there is nothing left to\n * poll. A successful poll resets the failure count.\n *\n * @param deps - Injected fetch, now, and sleep callbacks.\n * @param options - Optional poll delay, timeout, failure cap, and abort signal.\n * @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.\n */\nexport async function pollUntilDoneCoreAsync(\n\tdeps: PollDependencies,\n\toptions: PollOptions = {},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst { maxFailures, pollDelay, signal, timeoutMs } = resolvePollOptions(options);\n\tif (signal?.aborted === true) {\n\t\treturn abortedResult(signal);\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, signal);\n\t\tconst action = applyOutcome(outcome, { maxFailures, signal, state });\n\t\tif (action.kind === \"return\") {\n\t\t\treturn action.result;\n\t\t}\n\n\t\t({ state } = action);\n\t\tconst sleepWasAborted = await sleepWithAbortAsync({\n\t\t\tms: pollDelay(elapsedMs),\n\t\t\tsignal,\n\t\t\tsleep: deps.sleep,\n\t\t});\n\t\tif (sleepWasAborted) {\n\t\t\treturn abortedResult(signal);\n\t\t}\n\t}\n}\n\nfunction resolvePollOptions(options: PollOptions): ResolvedPollOptions {\n\treturn {\n\t\tmaxFailures: options.maxConsecutivePollFailures ?? DEFAULT_POLL_FAILURE_CAP,\n\t\tpollDelay: options.pollDelay ?? defaultPollDelay,\n\t\tsignal: options.signal,\n\t\ttimeoutMs: options.timeoutMs ?? DEFAULT_POLL_TIMEOUT_MS,\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\nasync function sleepWithAbortAsync({ ms, signal, sleep }: SleepWithAbortOptions): Promise<boolean> {\n\treturn (await raceWithAbortAsync(async () => sleep(ms, signal), signal)) === 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\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 * A 2xx whose body would not parse is deliberately not re-polled here: it is\n * recovered a layer down, by the request-level retry that\n * `RESPONSE_UNPARSEABLE` puts in every idempotent policy. Reaching this\n * function means that retry budget is already spent, and a fourth read of the\n * same body is not a different answer.\n *\n * @param error - The error returned by a failed poll.\n * @returns `true` when the loop should tolerate and re-poll.\n */\nfunction isTransientTransport(error: OpenCloudError): error is NetworkError {\n\tif (!(error instanceof NetworkError)) {\n\t\treturn false;\n\t}\n\n\tconst code = findErrorCode(error);\n\treturn code !== undefined && TRANSIENT_TRANSPORT_CODES.includes(code);\n}\n\nasync function fetchOnceAsync(\n\tdependencies: PollDependencies,\n\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 isTerminalTask(fetchResult.data)\n\t\t? { kind: \"terminal\", task: fetchResult.data }\n\t\t: { kind: \"pending\", task: fetchResult.data };\n}\n","import type { RequestOptions } from \"../../client/types.ts\";\nimport {\n\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 { observeAdmissionWaitAsync } from \"../../internal/http/admission-wait.ts\";\nimport { waitDeadlineFailure } from \"../../internal/http/request-deadline.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport { raceWithAbortAsync } from \"../../internal/utils/abort.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { capacityErrorFrom, LuauExecutionCapacityError, luauTaskRefKey } from \"./capacity-error.ts\";\nimport { defaultPollDelay, isTerminalTask, type PollUntilDoneOptions } from \"./polling.ts\";\n\nconst MAX_CAPACITY_WAIT_MS = 2_147_483_647;\n\n/**\n * Per-request options for submitting a Luau execution task.\n *\n * @example\n *\n * ```ts\n * import type { LuauExecutionSubmitOptions } from \"@bedrock-rbx/ocale/luau-execution\";\n *\n * const options: LuauExecutionSubmitOptions = { capacityWaitMs: 60_000 };\n * expect(options.capacityWaitMs).toBe(60_000);\n * ```\n *\n * @since 0.3.2\n */\nexport interface LuauExecutionSubmitOptions extends RequestOptions {\n\t/**\n\t * Maximum milliseconds to spend waiting for occupied place capacity, from 1\n\t * through 2,147,483,647. Supplying this value opts the submission into\n\t * capacity-aware admission.\n\t */\n\treadonly capacityWaitMs?: number;\n}\n\n/**\n * Per-request capacity and polling options for submitting and awaiting a Luau\n * execution task.\n *\n * @since 0.3.2\n */\nexport type LuauExecutionRunOptions = LuauExecutionSubmitOptions & PollUntilDoneOptions;\n\ninterface CapacitySubmitCall {\n\treadonly inner: ResourceClient;\n\treadonly options: LuauExecutionSubmitOptions | undefined;\n\treadonly parameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n}\n\ninterface SubmitOnceCall extends CapacitySubmitCall {\n\treadonly options: RequestOptions;\n\treadonly refineError?: ((error: OpenCloudError) => OpenCloudError) | undefined;\n}\n\ninterface ObserveBlockersCall {\n\treadonly blockers: ReadonlyArray<LuauExecutionTaskRef>;\n\treadonly inner: ResourceClient;\n\treadonly options: RequestOptions;\n}\n\ninterface CapacityWaitCall extends ObserveBlockersCall {\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly deadlineAt: number;\n\treadonly startedAt: number;\n}\n\ninterface CapacityAdmissionCall {\n\treadonly callerSignal: AbortSignal | undefined;\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly deadlineAt: number;\n\treadonly options: RequestOptions;\n\treadonly startedAt: number;\n\treadonly submitCall: SubmitOnceCall;\n}\n\ninterface CapacitySleepCall {\n\treadonly inner: ResourceClient;\n\treadonly options: RequestOptions;\n\treadonly waitMs: number;\n}\n\ninterface CapacityRetryCall {\n\treadonly callerSignal: AbortSignal | undefined;\n\treadonly current: LuauExecutionCapacityError;\n\treadonly options: RequestOptions;\n\treadonly submitCall: SubmitOnceCall;\n}\n\ntype CapacityRetryDecision =\n\t| { readonly capacityError: LuauExecutionCapacityError; readonly continue: true }\n\t| {\n\t\t\treadonly continue: false;\n\t\t\treadonly result: Result<LuauExecutionTask, OpenCloudError>;\n\t };\n\n/**\n * Submits through capacity admission when the caller opts in.\n *\n * @param call - Resource client, submit parameters, and per-request options.\n * @returns The submitted task or the failure that stopped admission.\n */\nexport async function submitWithCapacityAsync({\n\tinner,\n\toptions,\n\tparameters,\n}: CapacitySubmitCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst { capacityWaitMs, ...requestOptions } = options ?? {};\n\tif (capacityWaitMs === undefined) {\n\t\treturn submitOnceAsync({ inner, options: requestOptions, parameters });\n\t}\n\n\tfunction refineError(error: OpenCloudError): OpenCloudError {\n\t\treturn capacityErrorFrom(error, parameters) ?? error;\n\t}\n\n\tconst submitCall = { inner, options: requestOptions, parameters, refineError };\n\tconst first = await submitOnceAsync(submitCall);\n\tif (!isCapacityFailure(first)) {\n\t\treturn first;\n\t}\n\n\tif (\n\t\t!Number.isFinite(capacityWaitMs) ||\n\t\tcapacityWaitMs < 1 ||\n\t\tcapacityWaitMs > MAX_CAPACITY_WAIT_MS\n\t) {\n\t\treturn first;\n\t}\n\n\treturn admitWithinCapacityAsync({\n\t\tcapacityError: first.err,\n\t\toptions: requestOptions,\n\t\tsubmitCall,\n\t\twaitMs: capacityWaitMs,\n\t});\n}\n\nfunction isCapacityFailure(\n\tresult: Result<LuauExecutionTask, OpenCloudError>,\n): result is { readonly err: LuauExecutionCapacityError; readonly success: false } {\n\treturn !result.success && result.err instanceof LuauExecutionCapacityError;\n}\n\nasync function submitOnceAsync({\n\tinner,\n\toptions,\n\tparameters,\n\trefineError,\n}: SubmitOnceCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\treturn \"versionId\" in parameters\n\t\t? inner.executeAsync({ options, parameters, refineError, spec: SUBMIT_VERSION_SPEC })\n\t\t: inner.executeAsync({ options, parameters, refineError, spec: SUBMIT_HEAD_SPEC });\n}\n\nfunction capacityBoundAborted(\n\toptions: RequestOptions,\n\tcallerSignal: AbortSignal | undefined,\n): boolean {\n\treturn options.signal?.aborted === true && callerSignal?.aborted !== true;\n}\n\nasync function observeBlockersAsync({\n\tblockers,\n\tinner,\n\toptions,\n}: ObserveBlockersCall): Promise<Result<LuauExecutionTaskRef | undefined, OpenCloudError>> {\n\tfor (const blocker of blockers) {\n\t\tconst observed = await inner.executeAsync({\n\t\t\toptions,\n\t\t\tparameters: { ref: blocker, view: \"BASIC\" as const },\n\t\t\tspec: GET_SPEC,\n\t\t});\n\t\tif (!observed.success) {\n\t\t\treturn observed;\n\t\t}\n\n\t\tif (isTerminalTask(observed.data)) {\n\t\t\treturn { data: blocker, success: true };\n\t\t}\n\t}\n\n\treturn { data: undefined, success: true };\n}\n\nasync function sleepForCapacityAsync({ inner, options, waitMs }: CapacitySleepCall): Promise<void> {\n\tawait observeAdmissionWaitAsync({\n\t\tdurationMs: waitMs,\n\t\tobserver: options.onAdmissionWait,\n\t\treason: \"operation-capacity\",\n\t\twaitAsync: async () => {\n\t\t\treturn raceWithAbortAsync(\n\t\t\t\tasync () => inner.sleep(waitMs, options.signal),\n\t\t\t\toptions.signal,\n\t\t\t);\n\t\t},\n\t});\n}\n\nasync function observeWithinCapacityAsync({\n\tblockers,\n\tcapacityError,\n\tdeadlineAt,\n\tinner,\n\toptions,\n\tstartedAt,\n}: CapacityWaitCall): Promise<Result<LuauExecutionTaskRef, OpenCloudError>> {\n\twhile (Date.now() < deadlineAt) {\n\t\tconst observed = await observeBlockersAsync({ blockers, inner, options });\n\t\tif (!observed.success) {\n\t\t\treturn observed;\n\t\t}\n\n\t\tif (observed.data !== undefined) {\n\t\t\treturn { data: observed.data, success: true };\n\t\t}\n\n\t\tconst elapsedMs = Date.now() - startedAt;\n\t\tconst pollWaitMs = defaultPollDelay(elapsedMs);\n\t\tconst deadlineFailure = waitDeadlineFailure({\n\t\t\tcause: capacityError,\n\t\t\tdeadlineMs: options.deadlineMs,\n\t\t\twaitMs: pollWaitMs,\n\t\t\twaitReason: \"operation-capacity\",\n\t\t});\n\t\tif (deadlineFailure !== undefined) {\n\t\t\treturn { err: deadlineFailure, success: false };\n\t\t}\n\n\t\tconst waitMs = Math.min(pollWaitMs, deadlineAt - Date.now());\n\t\tawait sleepForCapacityAsync({ inner, options, waitMs });\n\t}\n\n\treturn { err: capacityError, success: false };\n}\n\nfunction hasSameBlockers(\n\tleft: LuauExecutionCapacityError,\n\tright: LuauExecutionCapacityError,\n): boolean {\n\tif (left.blockers.length !== right.blockers.length) {\n\t\treturn false;\n\t}\n\n\tconst rightKeys = new Set(right.blockers.map(luauTaskRefKey));\n\treturn left.blockers.every((blocker) => rightKeys.has(luauTaskRefKey(blocker)));\n}\n\nasync function retryAfterCapacityAsync({\n\tcallerSignal,\n\tcurrent,\n\toptions,\n\tsubmitCall,\n}: CapacityRetryCall): Promise<CapacityRetryDecision> {\n\tconst retried = await submitOnceAsync(submitCall);\n\tif (!retried.success && capacityBoundAborted(options, callerSignal)) {\n\t\treturn { continue: false, result: { err: current, success: false } };\n\t}\n\n\tif (!isCapacityFailure(retried) || hasSameBlockers(current, retried.err)) {\n\t\treturn { continue: false, result: retried };\n\t}\n\n\treturn { capacityError: retried.err, continue: true };\n}\n\nasync function runCapacityAdmissionAsync({\n\tcallerSignal,\n\tcapacityError,\n\tdeadlineAt,\n\toptions,\n\tstartedAt,\n\tsubmitCall,\n}: CapacityAdmissionCall): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst cleared = new Set<string>();\n\tlet current = capacityError;\n\twhile (true) {\n\t\tconst pending = current.blockers.filter((blocker) => !cleared.has(luauTaskRefKey(blocker)));\n\t\tif (pending.length === 0) {\n\t\t\treturn { err: current, success: false };\n\t\t}\n\n\t\tconst observed = await observeWithinCapacityAsync({\n\t\t\tblockers: pending,\n\t\t\tcapacityError: current,\n\t\t\tdeadlineAt,\n\t\t\tinner: submitCall.inner,\n\t\t\toptions,\n\t\t\tstartedAt,\n\t\t});\n\t\tif (!observed.success) {\n\t\t\treturn capacityBoundAborted(options, callerSignal)\n\t\t\t\t? { err: current, success: false }\n\t\t\t\t: observed;\n\t\t}\n\n\t\tcleared.add(luauTaskRefKey(observed.data));\n\t\tconst retry = await retryAfterCapacityAsync({ callerSignal, current, options, submitCall });\n\t\tif (!retry.continue) {\n\t\t\treturn retry.result;\n\t\t}\n\n\t\tcurrent = retry.capacityError;\n\t}\n}\n\nasync function admitWithinCapacityAsync({\n\tcapacityError,\n\toptions,\n\tsubmitCall,\n\twaitMs,\n}: {\n\treadonly capacityError: LuauExecutionCapacityError;\n\treadonly options: RequestOptions;\n\treadonly submitCall: SubmitOnceCall;\n\treadonly waitMs: number;\n}): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst deadline = new AbortController();\n\tconst timer = setTimeout(() => {\n\t\tdeadline.abort();\n\t}, waitMs);\n\tconst signal =\n\t\toptions.signal === undefined\n\t\t\t? deadline.signal\n\t\t\t: AbortSignal.any([options.signal, deadline.signal]);\n\tconst startedAt = Date.now();\n\ttry {\n\t\treturn await runCapacityAdmissionAsync({\n\t\t\tcallerSignal: options.signal,\n\t\t\tcapacityError,\n\t\t\tdeadlineAt: startedAt + waitMs,\n\t\t\toptions: { ...options, signal },\n\t\t\tstartedAt,\n\t\t\tsubmitCall: { ...submitCall, options: { ...submitCall.options, signal } },\n\t\t});\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\n","import { GET_SPEC } from \"../../domains/cloud-v2/luau-execution-tasks/specs.ts\";\nimport type {\n\tLuauExecutionTask,\n\tLuauExecutionTaskRef,\n\tSubmitAtHeadParameters,\n\tSubmitAtVersionParameters,\n} from \"../../domains/cloud-v2/luau-execution-tasks/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport type { ResourceClient } from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\nimport { type LuauExecutionRunOptions, submitWithCapacityAsync } from \"./capacity-admission.ts\";\nimport {\n\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: LuauExecutionRunOptions;\n\t\tparameters: SubmitAtHeadParameters | SubmitAtVersionParameters;\n\t},\n): Promise<Result<LuauExecutionTask, OpenCloudError>> {\n\tconst submitResult = await submitWithCapacityAsync({ inner, options, parameters });\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":";;;;;;AAQA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;AAuBrB,IAAa,6BAAb,cAAgD,eAAe;;CAE9D;CACA,OAAgC;;;;;;CAOhC,YAAY,UAA+C;EAC1D,MAAM,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;EAC3E,KAAK,WAAW,OAAO,OAAO,SAAS,KAAK,YAAY,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC,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
|
//#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-
|
|
42
|
+
//# sourceMappingURL=price-information-D8BxwgTS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-information-
|
|
1
|
+
{"version":3,"file":"price-information-D8BxwgTS.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"}
|