@bedrock-rbx/ocale 0.1.0-beta.9 → 0.1.1
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 +182 -0
- package/dist/badges.d.mts +33 -2
- package/dist/badges.d.mts.map +1 -1
- package/dist/badges.mjs +16 -4
- package/dist/badges.mjs.map +1 -1
- package/dist/{data.generated-Cb6g6asv.d.mts → data.generated-B2ceLfSn.d.mts} +9 -1
- package/dist/data.generated-B2ceLfSn.d.mts.map +1 -0
- package/dist/developer-products.d.mts +38 -2
- package/dist/developer-products.d.mts.map +1 -1
- package/dist/developer-products.mjs +32 -8
- package/dist/developer-products.mjs.map +1 -1
- package/dist/game-passes.d.mts +40 -2
- package/dist/game-passes.d.mts.map +1 -1
- package/dist/game-passes.mjs +30 -6
- package/dist/game-passes.mjs.map +1 -1
- package/dist/index.d.mts +21 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/locales.d.mts +1 -1
- package/dist/locales.mjs +2 -0
- package/dist/locales.mjs.map +1 -1
- package/dist/luau-execution.d.mts +22 -3
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +29 -13
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/places.d.mts +20 -2
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +34 -14
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-Dg_QFEqi.mjs → poll-timeout-BfxUWWCZ.mjs} +6 -2
- package/dist/poll-timeout-BfxUWWCZ.mjs.map +1 -0
- package/dist/{polling-helpers-CS00apdU.mjs → polling-helpers-DCw9LyJM.mjs} +225 -78
- package/dist/polling-helpers-DCw9LyJM.mjs.map +1 -0
- package/dist/{polling-BMrYajok.d.mts → polling-rj0dGREg.d.mts} +73 -14
- package/dist/polling-rj0dGREg.d.mts.map +1 -0
- package/dist/{price-information-DIrvwCmd.mjs → price-information-C4gC2CMZ.mjs} +2 -2
- package/dist/{price-information-DIrvwCmd.mjs.map → price-information-C4gC2CMZ.mjs.map} +1 -1
- package/dist/{rate-limit-D1q2Js-z.mjs → rate-limit-Dh2leqaB.mjs} +49 -3
- package/dist/rate-limit-Dh2leqaB.mjs.map +1 -0
- package/dist/resource-client-CIAkS2xQ.mjs +960 -0
- package/dist/resource-client-CIAkS2xQ.mjs.map +1 -0
- package/dist/retry-Bh2nNjBV.d.mts +234 -0
- package/dist/retry-Bh2nNjBV.d.mts.map +1 -0
- package/dist/retry-BvZRZDXs.mjs +380 -0
- package/dist/retry-BvZRZDXs.mjs.map +1 -0
- package/dist/{signatures-B5Fojgn0.mjs → signatures-JF-7Psce.mjs} +1 -1
- package/dist/{signatures-B5Fojgn0.mjs.map → signatures-JF-7Psce.mjs.map} +1 -1
- package/dist/storage.d.mts +30 -27
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +46 -31
- package/dist/storage.mjs.map +1 -1
- package/dist/testing.d.mts +24 -9
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/testing.mjs.map +1 -1
- package/dist/{to-blob-B27VhoRp.mjs → to-blob-RPqMBuft.mjs} +1 -1
- package/dist/{to-blob-B27VhoRp.mjs.map → to-blob-RPqMBuft.mjs.map} +1 -1
- package/dist/{types-CwtZT1ek.d.mts → types-CRiJg5EQ.d.mts} +46 -4
- package/dist/types-CRiJg5EQ.d.mts.map +1 -0
- package/dist/universes.d.mts +47 -5
- package/dist/universes.d.mts.map +1 -1
- package/dist/universes.mjs +31 -15
- package/dist/universes.mjs.map +1 -1
- package/dist/{validation-DkL5KQqz.mjs → validation-xJZRa8tX.mjs} +4 -2
- package/dist/validation-xJZRa8tX.mjs.map +1 -0
- package/dist/{wire-CeL6W_V7.d.mts → wire-D3K-a-UP.d.mts} +3 -1
- package/dist/wire-D3K-a-UP.d.mts.map +1 -0
- package/package.json +6 -5
- package/dist/data.generated-Cb6g6asv.d.mts.map +0 -1
- package/dist/permission-error-DOVtNq3A.mjs +0 -46
- package/dist/permission-error-DOVtNq3A.mjs.map +0 -1
- package/dist/poll-timeout-Dg_QFEqi.mjs.map +0 -1
- package/dist/polling-BMrYajok.d.mts.map +0 -1
- package/dist/polling-helpers-CS00apdU.mjs.map +0 -1
- package/dist/rate-limit-BYuizHoD.d.mts +0 -92
- package/dist/rate-limit-BYuizHoD.d.mts.map +0 -1
- package/dist/rate-limit-D1q2Js-z.mjs.map +0 -1
- package/dist/resource-client-D6Efj9fU.mjs +0 -732
- package/dist/resource-client-D6Efj9fU.mjs.map +0 -1
- package/dist/types-CwtZT1ek.d.mts.map +0 -1
- package/dist/validation-DkL5KQqz.mjs.map +0 -1
- package/dist/wire-CeL6W_V7.d.mts.map +0 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { s as RequestOptions } from "./types-
|
|
1
|
+
import { s as RequestOptions } from "./types-CRiJg5EQ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/domains/cloud-v2/luau-execution-tasks/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Caller-supplied input for submitting a Luau Execution task against a
|
|
6
6
|
* place's head version. Submitting against a specific place version uses
|
|
7
7
|
* {@link SubmitAtVersionParameters} instead.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
8
10
|
*/
|
|
9
11
|
interface SubmitAtHeadParameters {
|
|
10
12
|
/**
|
|
@@ -30,6 +32,8 @@ interface SubmitAtHeadParameters {
|
|
|
30
32
|
* Caller-supplied input for submitting a Luau Execution task against a
|
|
31
33
|
* specific place version. Submitting against the head version uses
|
|
32
34
|
* {@link SubmitAtHeadParameters} instead.
|
|
35
|
+
*
|
|
36
|
+
* @since 0.1.0
|
|
33
37
|
*/
|
|
34
38
|
interface SubmitAtVersionParameters {
|
|
35
39
|
/**
|
|
@@ -59,6 +63,8 @@ interface SubmitAtVersionParameters {
|
|
|
59
63
|
* returned by the server, and the get builder consumes it to construct
|
|
60
64
|
* the maximal GET URL. `versionId` and `sessionId` are `undefined` when
|
|
61
65
|
* the response `path` did not include those segments.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.1.0
|
|
62
68
|
*/
|
|
63
69
|
interface LuauExecutionTaskRef {
|
|
64
70
|
/** Stringified place ID. */
|
|
@@ -75,6 +81,8 @@ interface LuauExecutionTaskRef {
|
|
|
75
81
|
/**
|
|
76
82
|
* Caller-supplied input for fetching a Luau Execution task's current
|
|
77
83
|
* state.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.1.0
|
|
78
86
|
*/
|
|
79
87
|
interface GetParameters {
|
|
80
88
|
/** Reference to the task to fetch, typically returned by submit. */
|
|
@@ -90,6 +98,8 @@ interface GetParameters {
|
|
|
90
98
|
* Discriminated variant carrying every state in which the task has not
|
|
91
99
|
* yet produced output or an error: queued for execution, currently
|
|
92
100
|
* executing, or cancelled by the caller.
|
|
101
|
+
*
|
|
102
|
+
* @since 0.1.0
|
|
93
103
|
*/
|
|
94
104
|
interface InProgressTask extends LuauExecutionTaskBase {
|
|
95
105
|
/** Discriminator: the task is queued, processing, or cancelled. */
|
|
@@ -100,6 +110,8 @@ interface InProgressTask extends LuauExecutionTaskBase {
|
|
|
100
110
|
* server populates `output.results` with the Luau `return` values from
|
|
101
111
|
* the script run, serialized as JSON; entries that were not
|
|
102
112
|
* JSON-serializable (e.g., Roblox `Instance`s) appear as `null`.
|
|
113
|
+
*
|
|
114
|
+
* @since 0.1.0
|
|
103
115
|
*/
|
|
104
116
|
interface CompleteTask extends LuauExecutionTaskBase {
|
|
105
117
|
/**
|
|
@@ -118,6 +130,8 @@ interface CompleteTask extends LuauExecutionTaskBase {
|
|
|
118
130
|
* human-readable message describing the failure. The
|
|
119
131
|
* `ERROR_CODE_UNSPECIFIED` wire sentinel is rejected by the parser, so
|
|
120
132
|
* `code` is narrowed here to the four substantive error categories.
|
|
133
|
+
*
|
|
134
|
+
* @since 0.1.0
|
|
121
135
|
*/
|
|
122
136
|
interface FailedTask extends LuauExecutionTaskBase {
|
|
123
137
|
/** The categorical error code and message that caused the task to fail. */
|
|
@@ -137,6 +151,8 @@ interface FailedTask extends LuauExecutionTaskBase {
|
|
|
137
151
|
/**
|
|
138
152
|
* Public, discriminated representation of a Luau Execution session
|
|
139
153
|
* task. The variants are mutually exclusive on `state`.
|
|
154
|
+
*
|
|
155
|
+
* @since 0.1.0
|
|
140
156
|
*/
|
|
141
157
|
type LuauExecutionTask = CompleteTask | FailedTask | InProgressTask;
|
|
142
158
|
/**
|
|
@@ -178,6 +194,8 @@ interface LuauExecutionTaskBase {
|
|
|
178
194
|
/**
|
|
179
195
|
* Caller-supplied input for listing the structured log messages produced
|
|
180
196
|
* by a previously-submitted Luau execution task.
|
|
197
|
+
*
|
|
198
|
+
* @since 0.1.0
|
|
181
199
|
*/
|
|
182
200
|
interface ListLogsParameters {
|
|
183
201
|
/**
|
|
@@ -198,6 +216,8 @@ interface ListLogsParameters {
|
|
|
198
216
|
* A single structured log message produced by a Luau execution task.
|
|
199
217
|
* The `createTime` field is a raw ISO timestamp string, not a
|
|
200
218
|
* {@link Date}, so it can be serialized without conversion.
|
|
219
|
+
*
|
|
220
|
+
* @since 0.1.0
|
|
201
221
|
*/
|
|
202
222
|
interface LogMessage {
|
|
203
223
|
/** ISO timestamp when the log message was produced. */
|
|
@@ -215,6 +235,8 @@ interface LogMessage {
|
|
|
215
235
|
* Chunks are flattened by the parser; consumers see a single ordered
|
|
216
236
|
* array. When `nextPageToken` is present, pass it to the next
|
|
217
237
|
* `listLogs` call to retrieve the following page.
|
|
238
|
+
*
|
|
239
|
+
* @since 0.1.0
|
|
218
240
|
*/
|
|
219
241
|
interface LogPage {
|
|
220
242
|
/** Flattened, ordered list of log messages from this page. */
|
|
@@ -227,27 +249,64 @@ interface LogPage {
|
|
|
227
249
|
}
|
|
228
250
|
//#endregion
|
|
229
251
|
//#region src/resources/luau-execution/polling.d.ts
|
|
230
|
-
/**
|
|
252
|
+
/**
|
|
253
|
+
* Default poll cadence as a function of elapsed wall-clock time since
|
|
254
|
+
* polling began. Polls quickly while a task is young so short runs resolve
|
|
255
|
+
* snappily, then eases off so a long run leaves rate-limit headroom for
|
|
256
|
+
* newer tasks: 0-20s is 500ms, 20-60s is 1000ms, 60s+ is 5000ms.
|
|
257
|
+
*
|
|
258
|
+
* @since 0.1.0
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* import { defaultPollDelay } from "@bedrock-rbx/ocale/luau-execution";
|
|
263
|
+
*
|
|
264
|
+
* expect(defaultPollDelay(0)).toBe(500);
|
|
265
|
+
* expect(defaultPollDelay(30_000)).toBe(1000);
|
|
266
|
+
* expect(defaultPollDelay(120_000)).toBe(5000);
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @param elapsedMs - Milliseconds elapsed since polling started.
|
|
270
|
+
* @returns The delay in milliseconds to wait before the next poll.
|
|
271
|
+
*/
|
|
272
|
+
declare function defaultPollDelay(elapsedMs: number): number;
|
|
273
|
+
/**
|
|
274
|
+
* Public options accepted by `pollUntilDone` and `runUntilDone` on both client surfaces.
|
|
275
|
+
*
|
|
276
|
+
* @since 0.1.0
|
|
277
|
+
*/
|
|
231
278
|
type PollUntilDoneOptions = PollOptions & RequestOptions;
|
|
232
279
|
/** Caller-supplied polling-loop options; all fields optional. */
|
|
233
280
|
interface PollOptions {
|
|
234
|
-
/**
|
|
235
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Consecutive transient transport failures tolerated before the loop gives
|
|
283
|
+
* up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll resets
|
|
284
|
+
* the count.
|
|
285
|
+
*/
|
|
286
|
+
readonly maxConsecutivePollFailures?: number;
|
|
287
|
+
/** Returns the sleep duration given ms elapsed since polling started. Defaults to {@link defaultPollDelay}. */
|
|
288
|
+
readonly pollDelay?: (elapsedMs: number) => number;
|
|
236
289
|
/** When aborted, the loop returns {@link PollAbortedError} rather than continuing. */
|
|
237
290
|
readonly signal?: AbortSignal;
|
|
238
291
|
/** Total wall-clock budget in ms before the loop returns {@link PollTimeoutError}. */
|
|
239
292
|
readonly timeoutMs?: number;
|
|
240
293
|
}
|
|
241
294
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
295
|
+
* Defaults the per-request `timeout` to the effective poll budget when the
|
|
296
|
+
* caller has not set one. A luau-execution submit and each poll `get` normally
|
|
297
|
+
* answer in well under a second (the submit endpoint enqueues the task without
|
|
298
|
+
* waiting for it to run), so the only job of a per-request deadline here is to
|
|
299
|
+
* bound a black-hole connection. Leaving these requests on the client-wide 30s
|
|
300
|
+
* default (tuned for snappy CRUD) turns a slow-but-alive backend into a
|
|
301
|
+
* self-abort, an error the retry layer never retries by construction, before
|
|
302
|
+
* the loop's wall-clock budget is ever consulted. Deriving the deadline from
|
|
303
|
+
* `timeoutMs` keeps a single request alive exactly as long as the caller
|
|
304
|
+
* already agreed to wait for the whole operation, so the backend can answer or
|
|
305
|
+
* surface a retryable status instead.
|
|
306
|
+
*
|
|
307
|
+
* @param options - The caller's poll and per-request options.
|
|
308
|
+
* @returns The options with `timeout` filled from the budget when it was unset.
|
|
250
309
|
*/
|
|
251
310
|
//#endregion
|
|
252
|
-
export {
|
|
253
|
-
//# sourceMappingURL=polling-
|
|
311
|
+
export { LogPage as a, GetParameters as c, LuauExecutionTaskRef as d, SubmitAtHeadParameters as f, LogMessage as i, InProgressTask as l, defaultPollDelay as n, CompleteTask as o, SubmitAtVersionParameters as p, ListLogsParameters as r, FailedTask as s, PollUntilDoneOptions as t, LuauExecutionTask as u };
|
|
312
|
+
//# sourceMappingURL=polling-rj0dGREg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polling-rj0dGREg.d.mts","names":[],"sources":["../src/domains/cloud-v2/luau-execution-tasks/types.ts","../src/domains/cloud-v2/luau-execution-task-logs/types.ts","../src/resources/luau-execution/polling.ts"],"mappings":";;;;;;AAOA;;;;UAAiB,sBAAA;;;;;WAKP,WAAA;EAaA;EAAA,SAXA,kBAAA;EAqBV;EAAA,SAnBU,OAAA;;WAEA,MAAA;;;;;WAKA,cAAA;;WAEA,UAAA;AAAA;AA8BA;AAYV;;;;;;AAZU,UApBO,yBAAA;;;;AA0CP;WArCA,WAAA;EA8CO;EAAA,SA5CP,kBAAA;EA8CK;EAAA,SA5CL,OAAA;;WAEA,MAAA;EAgDA;AAAA;AAUV;;EAVU,SA3CA,cAAA;EAqD8B;EAAA,SAnD9B,UAAA;EAgEV;EAAA,SA9DU,SAAA;AAAA;;;;;;;;;;UAYO,oBAAA;;WAEP,OAAA;EAwDA;EAAA,SAtDA,SAAA;EAiEO;EAAA,SA/DP,MAAA;EA+D0B;EAAA,SA7D1B,UAAA;;WAEA,SAAA;AAAA;;;AA6EA;AASV;;;UA7EiB,aAAA;;WAEP,GAAA,EAAK,oBAAA;EA2E6C;;;;;EAAA,SArElD,IAAA;AAAA;AAqEkD;;;;;;;AAAA,UA3D3C,cAAA,SAAuB,qBAAA;;WAE9B,KAAA;AAAA;;;;;;;;;UAWO,YAAA,SAAqB,qBAAA;EAgF5B;;;;AC3LV;ED2LU,SA1EA,MAAA;IAAA,SAAmB,OAAA,EAAS,aAAA,CAAc,SAAA;EAAA;;WAE1C,KAAA;AAAA;;;ACtGK;AAUf;;;;;UDuGiB,UAAA,SAAmB,qBAAA;;WAE1B,KAAA;IChGA;AAWV;;;;;IAXU,SDuGC,IAAA,0FC1FuB;IAAA,SDgGvB,OAAA;EAAA;EC3FD;EAAA,SD8FA,KAAA;AAAA;;AEnGV;;;;AAAiC;KF4GrB,iBAAA,GAAoB,YAAA,GAAe,UAAA,GAAa,cAAA;;;;AE5EX;AAAA;UFmFvC,qBAAA;;;;;WAKA,WAAA;;;;;AEzEA;WF+EA,eAAA;;WAEA,SAAA,GAAY,IAAA;;WAEZ,kBAAA;;WAEA,GAAA,EAAK,oBAAA;;;;;;WAML,cAAA;;WAEA,SAAA,GAAY,IAAA;;WAEZ,IAAA;AAAA;;;;AA9LV;;;;;UCGiB,kBAAA;;;;;;WAMP,QAAA;EDmBV;;;;EAAA,SCdU,SAAA;;WAEA,GAAA,EAAK,oBAAA;AAAA;;;;;ADgCL;AAYV;;UClCiB,UAAA;EDkCA;EAAA,SChCP,UAAA;;WAEA,OAAA;;;;ADwCA;WCnCA,WAAA;AAAA;;;;;;;ADoDA;AAUV;UCnDiB,OAAA;;WAEP,QAAA,EAAU,aAAA,CAAc,UAAA;EDmDxB;AAWV;;;EAXU,SC9CA,aAAA;AAAA;;;;;;;;;;ADnCA;AAUV;;;;;;;;;;;;iBEoBgB,gBAAA,CAAiB,SAAA;AFiDjC;;;;AAEU;AAFV,KEjBY,oBAAA,GAAuB,WAAA,GAAc,cAAA;;UAGvC,WAAA;;;;;;WAMA,0BAAA;;WAEA,SAAA,IAAa,SAAA;;WAEb,MAAA,GAAS,WAAA;;WAET,SAAA;AAAA;AFkCV;;;;;;;;;;AAkBU;AASV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isRecord } from "./resource-client-CIAkS2xQ.mjs";
|
|
2
2
|
//#region src/internal/price-information.ts
|
|
3
3
|
/**
|
|
4
4
|
* Narrows `value` to {@link PriceInformationLike} for a given feature literal
|
|
@@ -39,4 +39,4 @@ function copyPriceInformation(wire) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { isPriceInformationLike as n, copyPriceInformation as t };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=price-information-
|
|
42
|
+
//# sourceMappingURL=price-information-C4gC2CMZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-information-
|
|
1
|
+
{"version":3,"file":"price-information-C4gC2CMZ.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"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* All specific error types (RateLimitError, ApiError, NetworkError)
|
|
6
6
|
* extend this class, enabling `instanceof OpenCloudError` checks.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.1.0
|
|
7
9
|
*/
|
|
8
10
|
var OpenCloudError = class extends Error {
|
|
9
11
|
name = "OpenCloudError";
|
|
@@ -14,6 +16,8 @@ var OpenCloudError = class extends Error {
|
|
|
14
16
|
* Thrown when the Roblox Open Cloud API returns a non-2xx response
|
|
15
17
|
* that is not a rate limit (429).
|
|
16
18
|
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*
|
|
17
21
|
* @example
|
|
18
22
|
*
|
|
19
23
|
* ```ts
|
|
@@ -37,30 +41,61 @@ var OpenCloudError = class extends Error {
|
|
|
37
41
|
var ApiError = class extends OpenCloudError {
|
|
38
42
|
code;
|
|
39
43
|
details;
|
|
44
|
+
elapsedMs;
|
|
45
|
+
gatewaySummary;
|
|
46
|
+
method;
|
|
40
47
|
name = "ApiError";
|
|
48
|
+
responseHeaders;
|
|
41
49
|
statusCode;
|
|
50
|
+
url;
|
|
42
51
|
/**
|
|
43
52
|
* Creates a new ApiError.
|
|
44
53
|
*
|
|
45
54
|
* @param message - Human-readable error description.
|
|
46
55
|
* @param options - Error options including status code, optional error
|
|
47
|
-
* code,
|
|
56
|
+
* code, the parsed response body when present, and the request context
|
|
57
|
+
* (method, url, elapsed time, allowlisted response headers) when built by
|
|
58
|
+
* the transport.
|
|
48
59
|
*/
|
|
49
60
|
constructor(message, options) {
|
|
50
61
|
super(message, options);
|
|
51
62
|
this.statusCode = options.statusCode;
|
|
52
63
|
this.code = options.code;
|
|
53
64
|
this.details = options.details;
|
|
65
|
+
this.method = options.method;
|
|
66
|
+
this.url = options.url;
|
|
67
|
+
this.elapsedMs = options.elapsedMs;
|
|
68
|
+
this.responseHeaders = options.responseHeaders;
|
|
69
|
+
this.gatewaySummary = options.gatewaySummary;
|
|
54
70
|
}
|
|
55
71
|
};
|
|
56
72
|
//#endregion
|
|
57
73
|
//#region src/errors/network-error.ts
|
|
58
74
|
/**
|
|
59
75
|
* Thrown when a network-level failure prevents the request from reaching
|
|
60
|
-
* the Roblox Open Cloud API (e.g., DNS resolution failure, connection
|
|
76
|
+
* the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).
|
|
77
|
+
* The `method` and `url` name the failing call so a transport failure that
|
|
78
|
+
* survives every retry can be diagnosed; the underlying transport error is
|
|
79
|
+
* carried on `cause`.
|
|
80
|
+
*
|
|
81
|
+
* @since 0.1.0
|
|
61
82
|
*/
|
|
62
83
|
var NetworkError = class extends OpenCloudError {
|
|
84
|
+
method;
|
|
63
85
|
name = "NetworkError";
|
|
86
|
+
url;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a new NetworkError.
|
|
89
|
+
*
|
|
90
|
+
* @param message - Human-readable error description.
|
|
91
|
+
* @param options - Error options including the optional `cause` and the
|
|
92
|
+
* `method` / `url` of the request that failed.
|
|
93
|
+
*/
|
|
94
|
+
constructor(message, options) {
|
|
95
|
+
super(message, options);
|
|
96
|
+
this.method = options?.method;
|
|
97
|
+
this.url = options?.url;
|
|
98
|
+
}
|
|
64
99
|
};
|
|
65
100
|
//#endregion
|
|
66
101
|
//#region src/errors/rate-limit.ts
|
|
@@ -68,6 +103,8 @@ var NetworkError = class extends OpenCloudError {
|
|
|
68
103
|
* Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests response.
|
|
69
104
|
* Contains the server-suggested retry delay.
|
|
70
105
|
*
|
|
106
|
+
* @since 0.1.0
|
|
107
|
+
*
|
|
71
108
|
* @example
|
|
72
109
|
*
|
|
73
110
|
* ```ts
|
|
@@ -82,8 +119,14 @@ var NetworkError = class extends OpenCloudError {
|
|
|
82
119
|
* ```
|
|
83
120
|
*/
|
|
84
121
|
var RateLimitError = class extends OpenCloudError {
|
|
122
|
+
/** Parsed 429 response body, or `undefined` when none was carried. */
|
|
123
|
+
details;
|
|
85
124
|
name = "RateLimitError";
|
|
125
|
+
/** Requests left in the throttled window, or `undefined` if not reported. */
|
|
126
|
+
remaining;
|
|
86
127
|
retryAfterSeconds;
|
|
128
|
+
/** HTTP status code that produced the error, or `undefined` if not set. */
|
|
129
|
+
statusCode;
|
|
87
130
|
/**
|
|
88
131
|
* Creates a new RateLimitError.
|
|
89
132
|
*
|
|
@@ -93,9 +136,12 @@ var RateLimitError = class extends OpenCloudError {
|
|
|
93
136
|
constructor(message, options) {
|
|
94
137
|
super(message, options);
|
|
95
138
|
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
139
|
+
this.remaining = options.remaining;
|
|
140
|
+
this.details = options.details;
|
|
141
|
+
this.statusCode = options.statusCode;
|
|
96
142
|
}
|
|
97
143
|
};
|
|
98
144
|
//#endregion
|
|
99
145
|
export { OpenCloudError as i, NetworkError as n, ApiError as r, RateLimitError as t };
|
|
100
146
|
|
|
101
|
-
//# sourceMappingURL=rate-limit-
|
|
147
|
+
//# sourceMappingURL=rate-limit-Dh2leqaB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit-Dh2leqaB.mjs","names":[],"sources":["../src/errors/base.ts","../src/errors/api-error.ts","../src/errors/network-error.ts","../src/errors/rate-limit.ts"],"sourcesContent":["/**\n * Base error class for all Open Cloud SDK errors.\n *\n * All specific error types (RateLimitError, ApiError, NetworkError)\n * extend this class, enabling `instanceof OpenCloudError` checks.\n *\n * @since 0.1.0\n */\nexport class OpenCloudError extends Error {\n\tpublic override readonly name: string = \"OpenCloudError\";\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing an {@link ApiError}.\n *\n * @since 0.1.0\n */\nexport interface ApiErrorOptions extends ErrorOptions {\n\t/** Optional machine-readable error code from the API. */\n\tcode?: string | undefined;\n\t/** Parsed response body, when present. */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Wall-clock time the request was in flight before this error, in\n\t * milliseconds. Present for errors built by the transport; a long elapsed\n\t * time on an intermittent failure points at a load or timeout correlation.\n\t */\n\telapsedMs?: number | undefined;\n\t/**\n\t * Human-readable summary extracted from an HTML gateway error page, set when\n\t * the error body was such a page (an HAProxy-style load-balancer rejection)\n\t * rather than an Open Cloud response. When present, the raw HTML is not\n\t * retained on {@link ApiError.details}.\n\t */\n\tgatewaySummary?: string | undefined;\n\t/** HTTP method of the request that produced this error. */\n\tmethod?: string | undefined;\n\t/**\n\t * Allowlisted response headers useful for diagnosis and escalation (request\n\t * ids, edge/server identifiers). The full header set is never retained, to\n\t * avoid surfacing anything sensitive and to keep errors light.\n\t */\n\tresponseHeaders?: Readonly<Record<string, string>> | undefined;\n\t/** HTTP status code from the API response. */\n\tstatusCode: number;\n\t/** Fully-qualified URL of the request that produced this error. */\n\turl?: string | undefined;\n}\n\n/**\n * Thrown when the Roblox Open Cloud API returns a non-2xx response\n * that is not a rate limit (429).\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { ApiError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new ApiError(\"HTTP 404: Pass not found (code NotFound)\", {\n * code: \"NotFound\",\n * details: { errorCode: \"NotFound\", message: \"Pass not found\" },\n * statusCode: 404,\n * });\n *\n * expect(error).toBeInstanceOf(ApiError);\n * expect(error.statusCode).toBe(404);\n * expect(error.code).toBe(\"NotFound\");\n * expect(error.details).toEqual({\n * errorCode: \"NotFound\",\n * message: \"Pass not found\",\n * });\n * ```\n */\nexport class ApiError extends OpenCloudError {\n\tpublic readonly code: string | undefined;\n\tpublic readonly details: JSONValue | undefined;\n\tpublic readonly elapsedMs: number | undefined;\n\tpublic readonly gatewaySummary: string | undefined;\n\tpublic readonly method: string | undefined;\n\tpublic override readonly name: string = \"ApiError\";\n\tpublic readonly responseHeaders: Readonly<Record<string, string>> | undefined;\n\tpublic readonly statusCode: number;\n\tpublic readonly url: string | undefined;\n\n\t/**\n\t * Creates a new ApiError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including status code, optional error\n\t * code, the parsed response body when present, and the request context\n\t * (method, url, elapsed time, allowlisted response headers) when built by\n\t * the transport.\n\t */\n\tconstructor(message: string, options: ApiErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.statusCode = options.statusCode;\n\t\tthis.code = options.code;\n\t\tthis.details = options.details;\n\t\tthis.method = options.method;\n\t\tthis.url = options.url;\n\t\tthis.elapsedMs = options.elapsedMs;\n\t\tthis.responseHeaders = options.responseHeaders;\n\t\tthis.gatewaySummary = options.gatewaySummary;\n\t}\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link NetworkError}.\n *\n * @since 0.1.0\n */\nexport interface NetworkErrorOptions extends ErrorOptions {\n\t/** HTTP method of the request that failed. */\n\tmethod?: string | undefined;\n\t/** Fully-qualified URL of the request that failed. */\n\turl?: string | undefined;\n}\n\n/**\n * Thrown when a network-level failure prevents the request from reaching\n * the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).\n * The `method` and `url` name the failing call so a transport failure that\n * survives every retry can be diagnosed; the underlying transport error is\n * carried on `cause`.\n *\n * @since 0.1.0\n */\nexport class NetworkError extends OpenCloudError {\n\tpublic readonly method: string | undefined;\n\tpublic override readonly name: string = \"NetworkError\";\n\tpublic readonly url: string | undefined;\n\n\t/**\n\t * Creates a new NetworkError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the optional `cause` and the\n\t * `method` / `url` of the request that failed.\n\t */\n\tconstructor(message: string, options?: NetworkErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.method = options?.method;\n\t\tthis.url = options?.url;\n\t}\n}\n","import { OpenCloudError } from \"./base.ts\";\n\n/**\n * Options for constructing a {@link RateLimitError}.\n *\n * @since 0.1.0\n */\nexport interface RateLimitErrorOptions extends ErrorOptions {\n\t/**\n\t * Parsed 429 response body, when present. Holds the server's throttle\n\t * explanation (JSON when the body parses, otherwise the truncated raw\n\t * text) so a rate limit stays diagnosable from the error alone.\n\t */\n\tdetails?: JSONValue | undefined;\n\t/**\n\t * Requests still allowed in the throttled window, read from\n\t * `x-ratelimit-remaining` (the most-constrained window). `undefined` when\n\t * the header is absent or carries no finite numeric token; parsed\n\t * independently of `x-ratelimit-reset`, so a valid value survives a\n\t * non-numeric reset. Typically `0` on a genuine 429.\n\t */\n\tremaining?: number | undefined;\n\t/** Seconds to wait before retrying the request. */\n\tretryAfterSeconds: number;\n\t/**\n\t * HTTP status code that produced the error. Always `429` when minted by the\n\t * SDK transport; `undefined` when constructed without one.\n\t */\n\tstatusCode?: number | undefined;\n}\n\n/**\n * Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests response.\n * Contains the server-suggested retry delay.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { RateLimitError } from \"@bedrock-rbx/ocale\";\n *\n * const error = new RateLimitError(\"Too many requests\", {\n * retryAfterSeconds: 30,\n * });\n *\n * expect(error).toBeInstanceOf(RateLimitError);\n * expect(error.retryAfterSeconds).toBe(30);\n * ```\n */\nexport class RateLimitError extends OpenCloudError {\n\t/** Parsed 429 response body, or `undefined` when none was carried. */\n\tpublic readonly details: JSONValue | undefined;\n\tpublic override readonly name = \"RateLimitError\";\n\t/** Requests left in the throttled window, or `undefined` if not reported. */\n\tpublic readonly remaining: number | undefined;\n\tpublic readonly retryAfterSeconds: number;\n\t/** HTTP status code that produced the error, or `undefined` if not set. */\n\tpublic readonly statusCode: number | undefined;\n\n\t/**\n\t * Creates a new RateLimitError.\n\t *\n\t * @param message - Human-readable error description.\n\t * @param options - Error options including the retry delay.\n\t */\n\tconstructor(message: string, options: RateLimitErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.retryAfterSeconds = options.retryAfterSeconds;\n\t\tthis.remaining = options.remaining;\n\t\tthis.details = options.details;\n\t\tthis.statusCode = options.statusCode;\n\t}\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CACzC,OAAwC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuDA,IAAa,WAAb,cAA8B,eAAe;CAC5C;CACA;CACA;CACA;CACA;CACA,OAAwC;CACxC;CACA;CACA;;;;;;;;;;CAWA,YAAY,SAAiB,SAA0B;EACtD,MAAM,SAAS,OAAO;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAK,SAAS,QAAQ;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,YAAY,QAAQ;EACzB,KAAK,kBAAkB,QAAQ;EAC/B,KAAK,iBAAiB,QAAQ;CAC/B;AACD;;;;;;;;;;;;ACzEA,IAAa,eAAb,cAAkC,eAAe;CAChD;CACA,OAAwC;CACxC;;;;;;;;CASA,YAAY,SAAiB,SAA+B;EAC3D,MAAM,SAAS,OAAO;EACtB,KAAK,SAAS,SAAS;EACvB,KAAK,MAAM,SAAS;CACrB;AACD;;;;;;;;;;;;;;;;;;;;;;ACUA,IAAa,iBAAb,cAAoC,eAAe;;CAElD;CACA,OAAgC;;CAEhC;CACA;;CAEA;;;;;;;CAQA,YAAY,SAAiB,SAAgC;EAC5D,MAAM,SAAS,OAAO;EACtB,KAAK,oBAAoB,QAAQ;EACjC,KAAK,YAAY,QAAQ;EACzB,KAAK,UAAU,QAAQ;EACvB,KAAK,aAAa,QAAQ;CAC3B;AACD"}
|