@bedrock-rbx/ocale 0.3.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/assets.d.mts +64 -0
- package/dist/assets.d.mts.map +1 -0
- package/dist/assets.mjs +301 -0
- package/dist/assets.mjs.map +1 -0
- package/dist/badge-insufficient-funds-BLFvQZt1.mjs +91 -0
- package/dist/badge-insufficient-funds-BLFvQZt1.mjs.map +1 -0
- package/dist/badges.d.mts +359 -196
- package/dist/badges.d.mts.map +1 -1
- package/dist/badges.mjs +493 -59
- package/dist/badges.mjs.map +1 -1
- package/dist/capacity-admission-Ce2V9QNb.d.mts +347 -0
- package/dist/capacity-admission-Ce2V9QNb.d.mts.map +1 -0
- package/dist/{data.generated-B2ceLfSn.d.mts → data.generated-B4Fztv_7.d.mts} +23 -25
- package/dist/data.generated-B4Fztv_7.d.mts.map +1 -0
- package/dist/developer-products.d.mts +207 -194
- package/dist/developer-products.d.mts.map +1 -1
- package/dist/developer-products.mjs +125 -39
- package/dist/developer-products.mjs.map +1 -1
- package/dist/game-passes.d.mts +206 -211
- package/dist/game-passes.d.mts.map +1 -1
- package/dist/game-passes.mjs +35 -36
- package/dist/game-passes.mjs.map +1 -1
- package/dist/index.d.mts +947 -366
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +324 -12
- package/dist/index.mjs.map +1 -1
- package/dist/is-date-time-string-C91G44SI.mjs +19 -0
- package/dist/is-date-time-string-C91G44SI.mjs.map +1 -0
- package/dist/locales.d.mts +28 -2
- package/dist/locales.d.mts.map +1 -0
- package/dist/locales.mjs +24 -3
- package/dist/locales.mjs.map +1 -1
- package/dist/luau-execution.d.mts +154 -157
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +15 -16
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{network-error-DR9FX5hb.mjs → network-error-P4An7nUB.mjs} +48 -14
- package/dist/network-error-P4An7nUB.mjs.map +1 -0
- package/dist/places.d.mts +258 -186
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +187 -35
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-3PXLsabj.mjs → poll-timeout-BCxgN97O.mjs} +4 -6
- package/dist/{poll-timeout-3PXLsabj.mjs.map → poll-timeout-BCxgN97O.mjs.map} +1 -1
- package/dist/{polling-helpers-CoVhsC33.mjs → polling-helpers-BtEYR5dN.mjs} +260 -105
- package/dist/polling-helpers-BtEYR5dN.mjs.map +1 -0
- package/dist/{price-information-B0tkOoAX.mjs → price-information--d6GZAcp.mjs} +3 -4
- package/dist/{price-information-B0tkOoAX.mjs.map → price-information--d6GZAcp.mjs.map} +1 -1
- package/dist/resource-client-CF8SPsV8.d.mts +162 -0
- package/dist/resource-client-CF8SPsV8.d.mts.map +1 -0
- package/dist/{resource-client-rqTMkBeR.mjs → resource-client-Cm_bPcCs.mjs} +589 -197
- package/dist/resource-client-Cm_bPcCs.mjs.map +1 -0
- package/dist/retry-DYxm_eBU.d.mts +225 -0
- package/dist/retry-DYxm_eBU.d.mts.map +1 -0
- package/dist/{retry-BlX4tUnT.mjs → retry-Dv5TsY9O.mjs} +312 -54
- package/dist/retry-Dv5TsY9O.mjs.map +1 -0
- package/dist/{signatures-JF-7Psce.mjs → signatures-CtJ7jfVN.mjs} +2 -3
- package/dist/{signatures-JF-7Psce.mjs.map → signatures-CtJ7jfVN.mjs.map} +1 -1
- package/dist/storage.d.mts +333 -344
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +39 -40
- package/dist/storage.mjs.map +1 -1
- package/dist/testing.d.mts +369 -434
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +18 -33
- package/dist/testing.mjs.map +1 -1
- package/dist/{to-blob-RPqMBuft.mjs → to-blob-Bqu7bmlE.mjs} +2 -3
- package/dist/{to-blob-RPqMBuft.mjs.map → to-blob-Bqu7bmlE.mjs.map} +1 -1
- package/dist/types-Z4abDJfK.d.mts +501 -0
- package/dist/types-Z4abDJfK.d.mts.map +1 -0
- package/dist/universes.d.mts +619 -436
- package/dist/universes.d.mts.map +1 -1
- package/dist/universes.mjs +432 -79
- package/dist/universes.mjs.map +1 -1
- package/dist/{validation-B_Zs1So2.mjs → validation-kaTLLAD1.mjs} +3 -4
- package/dist/{validation-B_Zs1So2.mjs.map → validation-kaTLLAD1.mjs.map} +1 -1
- package/dist/wire-DDG87I-d.d.mts +39 -0
- package/dist/wire-DDG87I-d.d.mts.map +1 -0
- package/package.json +15 -14
- package/dist/capacity-admission-IDO3fcUC.d.mts +0 -369
- package/dist/capacity-admission-IDO3fcUC.d.mts.map +0 -1
- package/dist/data.generated-B2ceLfSn.d.mts.map +0 -1
- package/dist/network-error-DR9FX5hb.mjs.map +0 -1
- package/dist/polling-helpers-CoVhsC33.mjs.map +0 -1
- package/dist/resource-client-B6NeFXUv.d.mts +0 -164
- package/dist/resource-client-B6NeFXUv.d.mts.map +0 -1
- package/dist/resource-client-rqTMkBeR.mjs.map +0 -1
- package/dist/retry-BlX4tUnT.mjs.map +0 -1
- package/dist/retry-war_-9tb.d.mts +0 -373
- package/dist/retry-war_-9tb.d.mts.map +0 -1
- package/dist/types-CvYh4SPC.d.mts +0 -386
- package/dist/types-CvYh4SPC.d.mts.map +0 -1
- package/dist/wire-D3K-a-UP.d.mts +0 -37
- package/dist/wire-D3K-a-UP.d.mts.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as TRANSIENT_TRANSPORT_CODES,
|
|
3
|
-
import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-
|
|
4
|
-
import { t as ValidationError } from "./validation-
|
|
5
|
-
import { a as
|
|
6
|
-
|
|
1
|
+
import { n as RateLimitError, s as OpenCloudError, t as NetworkError } from "./network-error-P4An7nUB.mjs";
|
|
2
|
+
import { E as raceWithAbortAsync, N as isRecord, T as ABORTED, a as TRANSIENT_TRANSPORT_CODES, g as RequestDeadlineExceededError, m as UnexpectedResponseError, p as findErrorCode, r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS } from "./retry-Dv5TsY9O.mjs";
|
|
3
|
+
import { n as PollAbortedError, t as PollTimeoutError } from "./poll-timeout-BCxgN97O.mjs";
|
|
4
|
+
import { t as ValidationError } from "./validation-kaTLLAD1.mjs";
|
|
5
|
+
import { a as waitDeadlineFailure, n as okRequest, o as observeAdmissionWaitAsync, s as toJsonDetails } from "./resource-client-Cm_bPcCs.mjs";
|
|
6
|
+
import { t as isDateTimeString } from "./is-date-time-string-C91G44SI.mjs";
|
|
7
|
+
// src/resources/luau-execution/capacity-error.ts
|
|
7
8
|
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
|
/**
|
|
9
10
|
* A Luau task submission refused because validated tasks occupy the target
|
|
@@ -58,12 +59,21 @@ function luauTaskRefKey(ref) {
|
|
|
58
59
|
* @returns A typed capacity error, or `undefined` without positive evidence.
|
|
59
60
|
*/
|
|
60
61
|
function capacityErrorFrom(error, parameters) {
|
|
61
|
-
|
|
62
|
-
const message = capacityMessage(error.details);
|
|
63
|
-
if (message === void 0) return;
|
|
64
|
-
const blockers = blockerRefsFrom(message, parameters);
|
|
62
|
+
const blockers = capacityBlockersFrom(error, parameters);
|
|
65
63
|
return blockers.length === 0 ? void 0 : new LuauExecutionCapacityError(blockers);
|
|
66
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks whether a response error positively names tasks occupying the
|
|
67
|
+
* submitted place. Such a 429 clears when those tasks end, not at its
|
|
68
|
+
* guided wait, so it never locks the submit operation out.
|
|
69
|
+
*
|
|
70
|
+
* @param error - The response error to inspect.
|
|
71
|
+
* @param parameters - The submitted target used to validate blocker refs.
|
|
72
|
+
* @returns Whether the error names at least one validated blocker.
|
|
73
|
+
*/
|
|
74
|
+
function namesCapacityBlockers(error, parameters) {
|
|
75
|
+
return capacityBlockersFrom(error, parameters).length > 0;
|
|
76
|
+
}
|
|
67
77
|
function capacityMessage(details) {
|
|
68
78
|
if (details === null || typeof details !== "object" || Array.isArray(details)) return;
|
|
69
79
|
const code = Reflect.get(details, "code");
|
|
@@ -98,8 +108,12 @@ function blockerRefsFrom(message, parameters) {
|
|
|
98
108
|
}
|
|
99
109
|
return Object.freeze([...unique.values()].toSorted(compareTaskRefs));
|
|
100
110
|
}
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
function capacityBlockersFrom(error, parameters) {
|
|
112
|
+
if (!(error instanceof RateLimitError) || error.code !== "RESOURCE_EXHAUSTED") return [];
|
|
113
|
+
const message = capacityMessage(error.details);
|
|
114
|
+
return message === void 0 ? [] : blockerRefsFrom(message, parameters);
|
|
115
|
+
}
|
|
116
|
+
// src/domains/cloud-v2/luau-execution-task-logs/builders.ts
|
|
103
117
|
/**
|
|
104
118
|
* Builds a `GET` request for the Open Cloud "list Luau execution session
|
|
105
119
|
* task logs" endpoint. The endpoint requires the maximal x-aep-resource
|
|
@@ -141,8 +155,7 @@ function buildQuery(pageSize, pageToken) {
|
|
|
141
155
|
if (pageToken !== void 0) query.append("pageToken", pageToken);
|
|
142
156
|
return query;
|
|
143
157
|
}
|
|
144
|
-
|
|
145
|
-
//#region src/domains/cloud-v2/luau-execution-task-logs/operations.ts
|
|
158
|
+
// src/domains/cloud-v2/luau-execution-task-logs/operations.ts
|
|
146
159
|
const LIST_LOGS_PER_MINUTE = 45;
|
|
147
160
|
/**
|
|
148
161
|
* Per-second request ceiling for listing Luau execution task logs,
|
|
@@ -164,34 +177,34 @@ const LIST_LOGS_OPERATION_LIMIT = Object.freeze({
|
|
|
164
177
|
* minimum-privilege scope for this read-only operation.
|
|
165
178
|
*/
|
|
166
179
|
const LIST_LOGS_REQUIRED_SCOPES = Object.freeze(["universe.place.luau-execution-session:read"]);
|
|
167
|
-
|
|
168
|
-
//#region src/domains/cloud-v2/luau-execution-task-logs/parsers.ts
|
|
180
|
+
// src/domains/cloud-v2/luau-execution-task-logs/parsers.ts
|
|
169
181
|
const MALFORMED_LOGS_MESSAGE = "Malformed list-luau-execution-task-logs response";
|
|
170
182
|
/**
|
|
171
183
|
* Parses a successful Open Cloud list-luau-execution-task-logs response
|
|
172
184
|
* body into the public {@link LogPage} shape. Chunks are flattened into
|
|
173
185
|
* a single ordered array of {@link LogMessage} values.
|
|
174
186
|
*
|
|
187
|
+
* The SDK requests STRUCTURED view, so both the chunk list and each
|
|
188
|
+
* chunk's message array must be present. Explicit empty arrays are valid;
|
|
189
|
+
* missing arrays reject the page rather than silently losing log output.
|
|
190
|
+
*
|
|
175
191
|
* @param response - The full {@link HttpResponse} from the Open Cloud API.
|
|
176
192
|
* @returns A success result wrapping the parsed {@link LogPage}, or an
|
|
177
|
-
* {@link
|
|
193
|
+
* {@link UnexpectedResponseError} when the body does not match a supported
|
|
194
|
+
* shape.
|
|
178
195
|
*/
|
|
179
196
|
function parseListLogsResponse({ body, status: statusCode }) {
|
|
180
197
|
if (!isRecord(body)) return malformed$1(statusCode, body);
|
|
181
|
-
const rawChunks = body["luauExecutionSessionTaskLogs"]
|
|
182
|
-
if (!
|
|
183
|
-
const rawToken = body["nextPageToken"]
|
|
198
|
+
const rawChunks = body["luauExecutionSessionTaskLogs"];
|
|
199
|
+
if (!isLogChunks(rawChunks)) return malformed$1(statusCode, body);
|
|
200
|
+
const rawToken = body["nextPageToken"];
|
|
184
201
|
if (rawToken !== void 0 && typeof rawToken !== "string") return malformed$1(statusCode, body);
|
|
185
202
|
const messages = [];
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
message: wireMessage.message,
|
|
192
|
-
messageType: wireMessage.messageType
|
|
193
|
-
});
|
|
194
|
-
}
|
|
203
|
+
for (const chunk of rawChunks) for (const wireMessage of chunk.structuredMessages) messages.push({
|
|
204
|
+
createTime: wireMessage.createTime,
|
|
205
|
+
message: wireMessage.message,
|
|
206
|
+
messageType: wireMessage.messageType
|
|
207
|
+
});
|
|
195
208
|
return {
|
|
196
209
|
data: {
|
|
197
210
|
messages,
|
|
@@ -206,28 +219,53 @@ function isAcceptedMessageType(value) {
|
|
|
206
219
|
function isLogMessageWire(value) {
|
|
207
220
|
return isRecord(value) && typeof value["createTime"] === "string" && typeof value["message"] === "string" && isAcceptedMessageType(value["messageType"]);
|
|
208
221
|
}
|
|
209
|
-
|
|
210
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Requires an explicit message array: captured no-print tasks return `[]`.
|
|
224
|
+
* Missing or null messages do not establish that a chunk has no output.
|
|
225
|
+
*
|
|
226
|
+
* @param value - The chunk's untrusted `structuredMessages` field.
|
|
227
|
+
* @returns Whether the field is an array containing only valid messages.
|
|
228
|
+
*/
|
|
229
|
+
function isStructuredMessages(value) {
|
|
230
|
+
return Array.isArray(value) && value.every((item) => isLogMessageWire(item));
|
|
211
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Validates a chunk for the STRUCTURED view always requested by the SDK.
|
|
234
|
+
* The schema also describes FLAT chunks that omit `structuredMessages`;
|
|
235
|
+
* accepting those here would silently discard their output.
|
|
236
|
+
*
|
|
237
|
+
* @param value - An untrusted entry in the response's chunk list.
|
|
238
|
+
* @returns Whether the chunk contains a valid structured message array.
|
|
239
|
+
*/
|
|
212
240
|
function isLogChunkWire(value) {
|
|
213
|
-
return isRecord(value) &&
|
|
241
|
+
return isRecord(value) && isStructuredMessages(value["structuredMessages"]);
|
|
214
242
|
}
|
|
215
|
-
|
|
216
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Requires an explicit chunk list, including `[]` for an empty page.
|
|
245
|
+
* Validates every chunk before flattening so one malformed chunk rejects
|
|
246
|
+
* the whole page instead of returning a partial log list.
|
|
247
|
+
*
|
|
248
|
+
* @param value - The untrusted `luauExecutionSessionTaskLogs` field.
|
|
249
|
+
* @returns Whether the field is an array containing only valid chunks.
|
|
250
|
+
*/
|
|
251
|
+
function isLogChunks(value) {
|
|
252
|
+
return Array.isArray(value) && value.every((item) => isLogChunkWire(item));
|
|
217
253
|
}
|
|
218
254
|
function malformed$1(statusCode, body) {
|
|
219
255
|
return {
|
|
220
|
-
err: new
|
|
256
|
+
err: new UnexpectedResponseError(MALFORMED_LOGS_MESSAGE, {
|
|
221
257
|
details: toJsonDetails(body),
|
|
222
258
|
statusCode
|
|
223
259
|
}),
|
|
224
260
|
success: false
|
|
225
261
|
};
|
|
226
262
|
}
|
|
227
|
-
|
|
228
|
-
//#region src/domains/cloud-v2/luau-execution-task-logs/specs.ts
|
|
263
|
+
// src/domains/cloud-v2/luau-execution-task-logs/specs.ts
|
|
229
264
|
function makeSpec$1(spec) {
|
|
230
|
-
return Object.freeze(
|
|
265
|
+
return Object.freeze({
|
|
266
|
+
...spec,
|
|
267
|
+
apiKeyOnly: true
|
|
268
|
+
});
|
|
231
269
|
}
|
|
232
270
|
/**
|
|
233
271
|
* Per-method dispatch spec for listing the structured log messages
|
|
@@ -243,8 +281,7 @@ const LIST_LOGS_SPEC = makeSpec$1({
|
|
|
243
281
|
parse: parseListLogsResponse,
|
|
244
282
|
requiredScopes: LIST_LOGS_REQUIRED_SCOPES
|
|
245
283
|
});
|
|
246
|
-
|
|
247
|
-
//#region src/domains/cloud-v2/luau-execution-tasks/builders.ts
|
|
284
|
+
// src/domains/cloud-v2/luau-execution-tasks/builders.ts
|
|
248
285
|
const JSON_HEADERS = { "content-type": "application/json" };
|
|
249
286
|
/**
|
|
250
287
|
* Builds a `POST` request for the Open Cloud "create Luau execution
|
|
@@ -325,8 +362,7 @@ function buildSubmitBody({ binaryInput, enableBinaryOutput: shouldEnableBinaryOu
|
|
|
325
362
|
if (shouldEnableBinaryOutput !== void 0) body["enableBinaryOutput"] = shouldEnableBinaryOutput;
|
|
326
363
|
return body;
|
|
327
364
|
}
|
|
328
|
-
|
|
329
|
-
//#region src/domains/cloud-v2/luau-execution-tasks/operations.ts
|
|
365
|
+
// src/domains/cloud-v2/luau-execution-tasks/operations.ts
|
|
330
366
|
const SUBMIT_AT_HEAD_PER_MINUTE = 5;
|
|
331
367
|
const SUBMIT_AT_VERSION_PER_MINUTE = 5;
|
|
332
368
|
const GET_PER_MINUTE = 200;
|
|
@@ -386,8 +422,7 @@ const SUBMIT_REQUIRED_SCOPES = Object.freeze(["universe.place.luau-execution-ses
|
|
|
386
422
|
* the minimum-privilege requirement for this method.
|
|
387
423
|
*/
|
|
388
424
|
const GET_REQUIRED_SCOPES = Object.freeze(["universe.place.luau-execution-session:read"]);
|
|
389
|
-
|
|
390
|
-
//#region src/domains/cloud-v2/luau-execution-tasks/parsers.ts
|
|
425
|
+
// src/domains/cloud-v2/luau-execution-tasks/parsers.ts
|
|
391
426
|
const MALFORMED_TASK_MESSAGE = "Malformed luau-execution-session-task response";
|
|
392
427
|
const PATH_PATTERN = /^universes\/(\d+)\/places\/(\d+)(?:\/versions\/(\d+))?(?:\/luau-execution-sessions\/([^/]+)\/tasks\/([^/]+)|\/luau-execution-session-tasks\/([^/]+))$/;
|
|
393
428
|
/**
|
|
@@ -399,8 +434,8 @@ const PATH_PATTERN = /^universes\/(\d+)\/places\/(\d+)(?:\/versions\/(\d+))?(?:\
|
|
|
399
434
|
* @param response - The full {@link HttpResponse} from the Open Cloud
|
|
400
435
|
* API.
|
|
401
436
|
* @returns A success result wrapping the parsed task, or an
|
|
402
|
-
* {@link
|
|
403
|
-
* shape.
|
|
437
|
+
* {@link UnexpectedResponseError} when the body or path do not match a
|
|
438
|
+
* supported shape.
|
|
404
439
|
*/
|
|
405
440
|
function parseLuauExecutionTaskResponse({ body, status: statusCode }) {
|
|
406
441
|
if (!isLuauExecutionTaskWire(body)) return malformed(statusCode, body);
|
|
@@ -480,7 +515,7 @@ function parseTimeoutSeconds(value) {
|
|
|
480
515
|
}
|
|
481
516
|
function malformed(statusCode, body) {
|
|
482
517
|
return {
|
|
483
|
-
err: new
|
|
518
|
+
err: new UnexpectedResponseError(MALFORMED_TASK_MESSAGE, {
|
|
484
519
|
details: toJsonDetails(body),
|
|
485
520
|
statusCode
|
|
486
521
|
}),
|
|
@@ -556,10 +591,12 @@ function parseTaskRef(path) {
|
|
|
556
591
|
versionId
|
|
557
592
|
};
|
|
558
593
|
}
|
|
559
|
-
|
|
560
|
-
//#region src/domains/cloud-v2/luau-execution-tasks/specs.ts
|
|
594
|
+
// src/domains/cloud-v2/luau-execution-tasks/specs.ts
|
|
561
595
|
function makeSpec(spec) {
|
|
562
|
-
return Object.freeze(
|
|
596
|
+
return Object.freeze({
|
|
597
|
+
...spec,
|
|
598
|
+
apiKeyOnly: true
|
|
599
|
+
});
|
|
563
600
|
}
|
|
564
601
|
/**
|
|
565
602
|
* Per-method dispatch spec for submitting a Luau execution task at a
|
|
@@ -641,6 +678,50 @@ function defaultPollDelay(elapsedMs) {
|
|
|
641
678
|
return DEFAULT_POLL_TIERS.find((candidate) => elapsedMs < candidate.untilMs)?.delayMs ?? STEADY_POLL_DELAY_MS;
|
|
642
679
|
}
|
|
643
680
|
/**
|
|
681
|
+
* Opens the poll budget at `startedAt`. Each request gets the earlier of the
|
|
682
|
+
* budget deadline and the caller's own `deadlineMs`. A non-finite budget
|
|
683
|
+
* passes only the caller's deadline, since the transport rejects a
|
|
684
|
+
* non-finite one.
|
|
685
|
+
*
|
|
686
|
+
* @param startedAt - Time the budget opened, as epoch ms.
|
|
687
|
+
* @param options - The caller's `timeoutMs` and `deadlineMs`.
|
|
688
|
+
* @returns The budget window and the per-request deadline.
|
|
689
|
+
*/
|
|
690
|
+
function openPollBudget(startedAt, options) {
|
|
691
|
+
const timeoutMs = options.timeoutMs ?? 3e5;
|
|
692
|
+
const budgetDeadlineMs = startedAt + timeoutMs;
|
|
693
|
+
const callerDeadlineMs = options.deadlineMs;
|
|
694
|
+
if (!Number.isFinite(budgetDeadlineMs)) return {
|
|
695
|
+
budgetDeadlineMs,
|
|
696
|
+
requestDeadlineMs: callerDeadlineMs,
|
|
697
|
+
timeoutMs
|
|
698
|
+
};
|
|
699
|
+
return {
|
|
700
|
+
budgetDeadlineMs,
|
|
701
|
+
requestDeadlineMs: callerDeadlineMs === void 0 ? budgetDeadlineMs : Math.min(callerDeadlineMs, budgetDeadlineMs),
|
|
702
|
+
timeoutMs
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Maps a request failure caused by the budget deadline to
|
|
707
|
+
* {@link PollTimeoutError}. Any other failure, including one from the
|
|
708
|
+
* caller's own earlier deadline, is returned unchanged. A caller abort wins
|
|
709
|
+
* over the budget, so the failure is also returned unchanged when the
|
|
710
|
+
* caller's signal has fired.
|
|
711
|
+
*
|
|
712
|
+
* @param error - The failure a submit or poll request returned.
|
|
713
|
+
* @param context - The opened budget, the last task observed, if any, and
|
|
714
|
+
* the caller's signal.
|
|
715
|
+
* @returns The poll timeout, or the original error.
|
|
716
|
+
*/
|
|
717
|
+
function budgetFailure(error, context) {
|
|
718
|
+
if (!isBudgetDeadline(error, context.budget) || context.signal?.aborted === true) return error;
|
|
719
|
+
return makeTimeout(context.lastTask, {
|
|
720
|
+
cause: error,
|
|
721
|
+
timeoutMs: context.budget.timeoutMs
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
644
725
|
* Defaults the per-request `timeout` to the effective poll budget when the
|
|
645
726
|
* caller has not set one. A luau-execution submit and each poll `get` normally
|
|
646
727
|
* answer in well under a second (the submit endpoint enqueues the task without
|
|
@@ -651,14 +732,16 @@ function defaultPollDelay(elapsedMs) {
|
|
|
651
732
|
* the loop's wall-clock budget is ever consulted. Deriving the deadline from
|
|
652
733
|
* `timeoutMs` keeps a single request alive exactly as long as the caller
|
|
653
734
|
* already agreed to wait for the whole operation, so the backend can answer or
|
|
654
|
-
* surface a retryable status instead.
|
|
735
|
+
* surface a retryable status instead. A budget longer than a timer can hold,
|
|
736
|
+
* such as `Infinity`, is capped at the longest delay the transport accepts.
|
|
655
737
|
*
|
|
656
738
|
* @template TOptions - The concrete polling option shape to preserve.
|
|
657
739
|
* @param options - The caller's poll and per-request options.
|
|
658
740
|
* @returns The options with `timeout` filled from the budget when it was unset.
|
|
659
741
|
*/
|
|
660
742
|
function withBudgetRequestTimeout(options) {
|
|
661
|
-
const
|
|
743
|
+
const budgetMs = options.timeoutMs ?? 3e5;
|
|
744
|
+
const timeout = options.timeout ?? Math.min(budgetMs, 2147483647);
|
|
662
745
|
return {
|
|
663
746
|
...options,
|
|
664
747
|
timeout
|
|
@@ -688,20 +771,25 @@ function isTerminalTask(task) {
|
|
|
688
771
|
* @returns The terminal task, or an error if aborted, timed out, or the transport keeps failing.
|
|
689
772
|
*/
|
|
690
773
|
async function pollUntilDoneCoreAsync(deps, options = {}) {
|
|
691
|
-
const { maxFailures, pollDelay, signal
|
|
774
|
+
const { maxFailures, pollDelay, signal } = resolvePollOptions(options);
|
|
692
775
|
if (signal?.aborted === true) return abortedResult(signal);
|
|
693
|
-
const startedAt = deps.now();
|
|
776
|
+
const startedAt = deps.startedAt ?? deps.now();
|
|
777
|
+
const budget = openPollBudget(startedAt, options);
|
|
694
778
|
let state = {
|
|
695
779
|
consecutiveFailures: 0,
|
|
696
780
|
lastTask: void 0
|
|
697
781
|
};
|
|
698
782
|
for (;;) {
|
|
699
783
|
const elapsedMs = deps.now() - startedAt;
|
|
700
|
-
if (elapsedMs >= timeoutMs) return {
|
|
701
|
-
err: makeTimeout(state.lastTask,
|
|
784
|
+
if (elapsedMs >= budget.timeoutMs) return {
|
|
785
|
+
err: makeTimeout(state.lastTask, budget),
|
|
702
786
|
success: false
|
|
703
787
|
};
|
|
704
|
-
const action = applyOutcome(await fetchOnceAsync(deps,
|
|
788
|
+
const action = applyOutcome(await fetchOnceAsync(deps, {
|
|
789
|
+
budget,
|
|
790
|
+
signal
|
|
791
|
+
}), {
|
|
792
|
+
budget,
|
|
705
793
|
maxFailures,
|
|
706
794
|
signal,
|
|
707
795
|
state
|
|
@@ -715,12 +803,34 @@ async function pollUntilDoneCoreAsync(deps, options = {}) {
|
|
|
715
803
|
})) return abortedResult(signal);
|
|
716
804
|
}
|
|
717
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Describes why the budget ended. A wait the transport refused up front
|
|
808
|
+
* (one that carries `waitMs`) ends the poll before `timeoutMs` has elapsed,
|
|
809
|
+
* so its message reports the budget left rather than an elapsed timeout.
|
|
810
|
+
*
|
|
811
|
+
* @param cause - The budget deadline failure, if a request reported one.
|
|
812
|
+
* @param timeoutMs - The total poll budget in ms.
|
|
813
|
+
* @returns The elapsed-timeout wording, or the budget left and the refused wait.
|
|
814
|
+
*/
|
|
815
|
+
function timeoutMessage(cause, timeoutMs) {
|
|
816
|
+
if (cause?.waitMs === void 0) return `Polling timed out after ${timeoutMs} ms`;
|
|
817
|
+
return `Polling stopped with ${cause.remainingMs} ms of the ${timeoutMs} ms budget left: a required ${cause.waitMs} ms wait would exceed it`;
|
|
818
|
+
}
|
|
819
|
+
function makeTimeout(task, { cause, timeoutMs }) {
|
|
820
|
+
return new PollTimeoutError(timeoutMessage(cause, timeoutMs), {
|
|
821
|
+
...cause === void 0 ? {} : { cause },
|
|
822
|
+
lastObservedTask: task,
|
|
823
|
+
timeoutMs
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
function isBudgetDeadline(error, budget) {
|
|
827
|
+
return error instanceof RequestDeadlineExceededError && error.deadlineMs === budget.budgetDeadlineMs;
|
|
828
|
+
}
|
|
718
829
|
function resolvePollOptions(options) {
|
|
719
830
|
return {
|
|
720
831
|
maxFailures: options.maxConsecutivePollFailures ?? 3,
|
|
721
832
|
pollDelay: options.pollDelay ?? defaultPollDelay,
|
|
722
|
-
signal: options.signal
|
|
723
|
-
timeoutMs: options.timeoutMs ?? 3e5
|
|
833
|
+
signal: options.signal
|
|
724
834
|
};
|
|
725
835
|
}
|
|
726
836
|
function makeAborted(signal) {
|
|
@@ -742,19 +852,28 @@ function abortedResult(signal) {
|
|
|
742
852
|
* @param context - The loop state, failure cap, and abort signal.
|
|
743
853
|
* @returns Whether to return a final Result or continue with updated state.
|
|
744
854
|
*/
|
|
745
|
-
function applyOutcome(outcome, { maxFailures, signal, state }) {
|
|
855
|
+
function applyOutcome(outcome, { budget, maxFailures, signal, state }) {
|
|
746
856
|
switch (outcome.kind) {
|
|
747
857
|
case "aborted": return {
|
|
748
858
|
kind: "return",
|
|
749
859
|
result: abortedResult(signal)
|
|
750
860
|
};
|
|
751
|
-
case "failed":
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
861
|
+
case "failed":
|
|
862
|
+
if (signal?.aborted === true && isBudgetDeadline(outcome.error, budget)) return {
|
|
863
|
+
kind: "return",
|
|
864
|
+
result: abortedResult(signal)
|
|
865
|
+
};
|
|
866
|
+
return {
|
|
867
|
+
kind: "return",
|
|
868
|
+
result: {
|
|
869
|
+
err: budgetFailure(outcome.error, {
|
|
870
|
+
budget,
|
|
871
|
+
lastTask: state.lastTask,
|
|
872
|
+
signal
|
|
873
|
+
}),
|
|
874
|
+
success: false
|
|
875
|
+
}
|
|
876
|
+
};
|
|
758
877
|
case "pending": return {
|
|
759
878
|
kind: "continue",
|
|
760
879
|
state: {
|
|
@@ -791,15 +910,9 @@ function applyOutcome(outcome, { maxFailures, signal, state }) {
|
|
|
791
910
|
async function sleepWithAbortAsync({ ms, signal, sleep }) {
|
|
792
911
|
return await raceWithAbortAsync(async () => sleep(ms, signal), signal) === ABORTED;
|
|
793
912
|
}
|
|
794
|
-
function makeTimeout(task, timeoutMs) {
|
|
795
|
-
return new PollTimeoutError(`Polling timed out after ${timeoutMs} ms`, {
|
|
796
|
-
lastObservedTask: task,
|
|
797
|
-
timeoutMs
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
913
|
/**
|
|
801
|
-
* A failed poll is worth re-polling only when it is a `NetworkError` carrying
|
|
802
|
-
* known transient transport code. A self-aborted request timeout has no
|
|
914
|
+
* A failed poll is worth re-polling only when it is a `NetworkError` carrying
|
|
915
|
+
* a known transient transport code. A self-aborted request timeout has no
|
|
803
916
|
* `code`, and an API response (4xx/5xx) is authoritative, so both abort the
|
|
804
917
|
* loop rather than being re-polled. Transient-ness is classified against the
|
|
805
918
|
* canonical `TRANSIENT_TRANSPORT_CODES` set; this is the loop's own tolerance
|
|
@@ -821,8 +934,8 @@ function isTransientTransport(error) {
|
|
|
821
934
|
const code = findErrorCode(error);
|
|
822
935
|
return code !== void 0 && TRANSIENT_TRANSPORT_CODES.includes(code);
|
|
823
936
|
}
|
|
824
|
-
async function fetchOnceAsync(dependencies, signal) {
|
|
825
|
-
const fetchResult = await raceWithAbortAsync(dependencies.fetch, signal);
|
|
937
|
+
async function fetchOnceAsync(dependencies, { budget, signal }) {
|
|
938
|
+
const fetchResult = await raceWithAbortAsync(async () => dependencies.fetch(budget.requestDeadlineMs), signal);
|
|
826
939
|
if (fetchResult === ABORTED) return { kind: "aborted" };
|
|
827
940
|
if (!fetchResult.success) return isTransientTransport(fetchResult.err) ? {
|
|
828
941
|
error: fetchResult.err,
|
|
@@ -839,8 +952,35 @@ async function fetchOnceAsync(dependencies, signal) {
|
|
|
839
952
|
task: fetchResult.data
|
|
840
953
|
};
|
|
841
954
|
}
|
|
842
|
-
|
|
843
|
-
|
|
955
|
+
// src/resources/luau-execution/submit-once.ts
|
|
956
|
+
/**
|
|
957
|
+
* Submits a Luau task once. A 429 naming tasks that occupy the place never
|
|
958
|
+
* locks the submit operation out, whether or not the caller opted into
|
|
959
|
+
* capacity admission: it clears when those tasks end.
|
|
960
|
+
*
|
|
961
|
+
* @param call - Resource client, submit parameters, options, and refinement.
|
|
962
|
+
* @returns The submitted task or the failure the attempt produced.
|
|
963
|
+
*/
|
|
964
|
+
async function submitOnceAsync({ inner, options, parameters, refineError }) {
|
|
965
|
+
function exemptsLockout(error) {
|
|
966
|
+
return namesCapacityBlockers(error, parameters);
|
|
967
|
+
}
|
|
968
|
+
const call = {
|
|
969
|
+
exemptsLockout,
|
|
970
|
+
options,
|
|
971
|
+
refineError
|
|
972
|
+
};
|
|
973
|
+
return "versionId" in parameters ? inner.executeAsync({
|
|
974
|
+
...call,
|
|
975
|
+
parameters,
|
|
976
|
+
spec: SUBMIT_VERSION_SPEC
|
|
977
|
+
}) : inner.executeAsync({
|
|
978
|
+
...call,
|
|
979
|
+
parameters,
|
|
980
|
+
spec: SUBMIT_HEAD_SPEC
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
// src/resources/luau-execution/capacity-admission.ts
|
|
844
984
|
const MAX_CAPACITY_WAIT_MS = 2147483647;
|
|
845
985
|
/**
|
|
846
986
|
* Submits through capacity admission when the caller opts in.
|
|
@@ -877,19 +1017,6 @@ async function submitWithCapacityAsync({ inner, options, parameters }) {
|
|
|
877
1017
|
function isCapacityFailure(result) {
|
|
878
1018
|
return !result.success && result.err instanceof LuauExecutionCapacityError;
|
|
879
1019
|
}
|
|
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
1020
|
function capacityBoundAborted(options, callerSignal) {
|
|
894
1021
|
return options.signal?.aborted === true && callerSignal?.aborted !== true;
|
|
895
1022
|
}
|
|
@@ -1042,8 +1169,7 @@ async function admitWithinCapacityAsync({ capacityError, options, submitCall, wa
|
|
|
1042
1169
|
clearTimeout(timer);
|
|
1043
1170
|
}
|
|
1044
1171
|
}
|
|
1045
|
-
|
|
1046
|
-
//#region src/resources/luau-execution/polling-helpers.ts
|
|
1172
|
+
// src/resources/luau-execution/polling-helpers.ts
|
|
1047
1173
|
/**
|
|
1048
1174
|
* Builds the {@link PollDependencies} bundle used by {@link
|
|
1049
1175
|
* pollUntilDoneCoreAsync}, closing over the supplied {@link ResourceClient},
|
|
@@ -1055,9 +1181,9 @@ async function admitWithinCapacityAsync({ capacityError, options, submitCall, wa
|
|
|
1055
1181
|
*/
|
|
1056
1182
|
function buildPollDependencies(inner, args) {
|
|
1057
1183
|
return {
|
|
1058
|
-
fetch: async () => {
|
|
1184
|
+
fetch: async (deadlineMs) => {
|
|
1059
1185
|
return inner.executeAsync({
|
|
1060
|
-
options: args.options,
|
|
1186
|
+
options: withRequestDeadline(args.options, deadlineMs),
|
|
1061
1187
|
parameters: {
|
|
1062
1188
|
ref: args.ref,
|
|
1063
1189
|
view: "BASIC"
|
|
@@ -1072,7 +1198,10 @@ function buildPollDependencies(inner, args) {
|
|
|
1072
1198
|
/**
|
|
1073
1199
|
* Submits a Luau execution task and polls it to a terminal state. Dispatches
|
|
1074
1200
|
* to the head-version or specific-version submit spec based on the presence of
|
|
1075
|
-
* `versionId`, then delegates to {@link pollUntilDoneCoreAsync}.
|
|
1201
|
+
* `versionId`, then delegates to {@link pollUntilDoneCoreAsync}. The poll
|
|
1202
|
+
* budget opens before the submit, so `timeoutMs` covers the submit and the
|
|
1203
|
+
* polling together; a submit cut off by the budget returns
|
|
1204
|
+
* `PollTimeoutError` with no task.
|
|
1076
1205
|
*
|
|
1077
1206
|
* @param inner - The {@link ResourceClient} that issues submit and poll calls.
|
|
1078
1207
|
* @param args - The polling options and submit parameters.
|
|
@@ -1080,18 +1209,44 @@ function buildPollDependencies(inner, args) {
|
|
|
1080
1209
|
* the {@link OpenCloudError} that caused submit or polling to fail.
|
|
1081
1210
|
*/
|
|
1082
1211
|
async function submitAndPollAsync(inner, { options, parameters }) {
|
|
1212
|
+
const startedAt = Date.now();
|
|
1213
|
+
const budget = openPollBudget(startedAt, options);
|
|
1083
1214
|
const submitResult = await submitWithCapacityAsync({
|
|
1084
1215
|
inner,
|
|
1085
|
-
options,
|
|
1216
|
+
options: withRequestDeadline(options, budget.requestDeadlineMs),
|
|
1086
1217
|
parameters
|
|
1087
1218
|
});
|
|
1088
|
-
if (!submitResult.success) return
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1219
|
+
if (!submitResult.success) return {
|
|
1220
|
+
err: budgetFailure(submitResult.err, {
|
|
1221
|
+
budget,
|
|
1222
|
+
lastTask: void 0,
|
|
1223
|
+
signal: options.signal
|
|
1224
|
+
}),
|
|
1225
|
+
success: false
|
|
1226
|
+
};
|
|
1227
|
+
return pollUntilDoneCoreAsync({
|
|
1228
|
+
...buildPollDependencies(inner, {
|
|
1229
|
+
options,
|
|
1230
|
+
ref: submitResult.data.ref
|
|
1231
|
+
}),
|
|
1232
|
+
startedAt
|
|
1233
|
+
}, options);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Applies the budget's request deadline. It already folds in the caller's own
|
|
1237
|
+
* `deadlineMs`, so it is `undefined` only when the caller set none either.
|
|
1238
|
+
*
|
|
1239
|
+
* @template TOptions - The concrete option shape to preserve.
|
|
1240
|
+
* @param options - The caller's options.
|
|
1241
|
+
* @param deadlineMs - The request deadline from the opened budget.
|
|
1242
|
+
* @returns The options with `deadlineMs` set to the request deadline.
|
|
1243
|
+
*/
|
|
1244
|
+
function withRequestDeadline(options, deadlineMs) {
|
|
1245
|
+
return {
|
|
1246
|
+
...options,
|
|
1247
|
+
deadlineMs
|
|
1248
|
+
};
|
|
1093
1249
|
}
|
|
1094
|
-
//#endregion
|
|
1095
1250
|
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
1251
|
|
|
1097
|
-
//# sourceMappingURL=polling-helpers-
|
|
1252
|
+
//# sourceMappingURL=polling-helpers-BtEYR5dN.mjs.map
|