@bedrock-rbx/ocale 0.1.0-beta.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +182 -0
  2. package/dist/badges.d.mts +33 -2
  3. package/dist/badges.d.mts.map +1 -1
  4. package/dist/badges.mjs +16 -4
  5. package/dist/badges.mjs.map +1 -1
  6. package/dist/{data.generated-Cb6g6asv.d.mts → data.generated-B2ceLfSn.d.mts} +9 -1
  7. package/dist/data.generated-B2ceLfSn.d.mts.map +1 -0
  8. package/dist/developer-products.d.mts +38 -2
  9. package/dist/developer-products.d.mts.map +1 -1
  10. package/dist/developer-products.mjs +32 -8
  11. package/dist/developer-products.mjs.map +1 -1
  12. package/dist/game-passes.d.mts +40 -2
  13. package/dist/game-passes.d.mts.map +1 -1
  14. package/dist/game-passes.mjs +30 -6
  15. package/dist/game-passes.mjs.map +1 -1
  16. package/dist/index.d.mts +21 -12
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +5 -5
  19. package/dist/locales.d.mts +1 -1
  20. package/dist/locales.mjs +2 -0
  21. package/dist/locales.mjs.map +1 -1
  22. package/dist/luau-execution.d.mts +22 -3
  23. package/dist/luau-execution.d.mts.map +1 -1
  24. package/dist/luau-execution.mjs +29 -13
  25. package/dist/luau-execution.mjs.map +1 -1
  26. package/dist/places.d.mts +20 -2
  27. package/dist/places.d.mts.map +1 -1
  28. package/dist/places.mjs +34 -14
  29. package/dist/places.mjs.map +1 -1
  30. package/dist/{poll-timeout-Dg_QFEqi.mjs → poll-timeout-C0nmJzOd.mjs} +6 -2
  31. package/dist/poll-timeout-C0nmJzOd.mjs.map +1 -0
  32. package/dist/{polling-helpers-CS00apdU.mjs → polling-helpers-BcycDhDm.mjs} +225 -78
  33. package/dist/polling-helpers-BcycDhDm.mjs.map +1 -0
  34. package/dist/{polling-BMrYajok.d.mts → polling-rj0dGREg.d.mts} +73 -14
  35. package/dist/polling-rj0dGREg.d.mts.map +1 -0
  36. package/dist/{price-information-DIrvwCmd.mjs → price-information-DK83Wul1.mjs} +2 -2
  37. package/dist/{price-information-DIrvwCmd.mjs.map → price-information-DK83Wul1.mjs.map} +1 -1
  38. package/dist/{rate-limit-D1q2Js-z.mjs → rate-limit-Co9i28qi.mjs} +30 -2
  39. package/dist/rate-limit-Co9i28qi.mjs.map +1 -0
  40. package/dist/{resource-client-D6Efj9fU.mjs → resource-client-C_D--PYX.mjs} +328 -243
  41. package/dist/resource-client-C_D--PYX.mjs.map +1 -0
  42. package/dist/retry-CbHBw60o.mjs +380 -0
  43. package/dist/retry-CbHBw60o.mjs.map +1 -0
  44. package/dist/retry-r1TXe5Zd.d.mts +189 -0
  45. package/dist/retry-r1TXe5Zd.d.mts.map +1 -0
  46. package/dist/{signatures-B5Fojgn0.mjs → signatures-JF-7Psce.mjs} +1 -1
  47. package/dist/{signatures-B5Fojgn0.mjs.map → signatures-JF-7Psce.mjs.map} +1 -1
  48. package/dist/storage.d.mts +30 -27
  49. package/dist/storage.d.mts.map +1 -1
  50. package/dist/storage.mjs +46 -31
  51. package/dist/storage.mjs.map +1 -1
  52. package/dist/testing.d.mts +24 -9
  53. package/dist/testing.d.mts.map +1 -1
  54. package/dist/testing.mjs +2 -2
  55. package/dist/testing.mjs.map +1 -1
  56. package/dist/{to-blob-B27VhoRp.mjs → to-blob-RPqMBuft.mjs} +1 -1
  57. package/dist/{to-blob-B27VhoRp.mjs.map → to-blob-RPqMBuft.mjs.map} +1 -1
  58. package/dist/{types-CwtZT1ek.d.mts → types-CRiJg5EQ.d.mts} +46 -4
  59. package/dist/types-CRiJg5EQ.d.mts.map +1 -0
  60. package/dist/universes.d.mts +47 -5
  61. package/dist/universes.d.mts.map +1 -1
  62. package/dist/universes.mjs +31 -15
  63. package/dist/universes.mjs.map +1 -1
  64. package/dist/{validation-DkL5KQqz.mjs → validation-9oU6qNNQ.mjs} +4 -2
  65. package/dist/validation-9oU6qNNQ.mjs.map +1 -0
  66. package/dist/{wire-CeL6W_V7.d.mts → wire-D3K-a-UP.d.mts} +3 -1
  67. package/dist/wire-D3K-a-UP.d.mts.map +1 -0
  68. package/package.json +7 -6
  69. package/dist/data.generated-Cb6g6asv.d.mts.map +0 -1
  70. package/dist/permission-error-DOVtNq3A.mjs +0 -46
  71. package/dist/permission-error-DOVtNq3A.mjs.map +0 -1
  72. package/dist/poll-timeout-Dg_QFEqi.mjs.map +0 -1
  73. package/dist/polling-BMrYajok.d.mts.map +0 -1
  74. package/dist/polling-helpers-CS00apdU.mjs.map +0 -1
  75. package/dist/rate-limit-BYuizHoD.d.mts +0 -92
  76. package/dist/rate-limit-BYuizHoD.d.mts.map +0 -1
  77. package/dist/rate-limit-D1q2Js-z.mjs.map +0 -1
  78. package/dist/resource-client-D6Efj9fU.mjs.map +0 -1
  79. package/dist/types-CwtZT1ek.d.mts.map +0 -1
  80. package/dist/validation-DkL5KQqz.mjs.map +0 -1
  81. package/dist/wire-CeL6W_V7.d.mts.map +0 -1
@@ -1,10 +1,12 @@
1
- import { s as RequestOptions } from "./types-CwtZT1ek.mjs";
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
- /** Public options accepted by `pollUntilDone` and `runUntilDone` on both client surfaces. */
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
- /** Returns the sleep duration for a given zero-indexed attempt. Defaults to {@link defaultRetryDelay}. */
235
- readonly pollDelay?: (attempt: number) => number;
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
- * Core polling loop. Calls `deps.fetch()` repeatedly, sleeping
243
- * `pollDelay(attempt)` ms between iterations, until a terminal state
244
- * is observed, the wall-clock budget is exhausted, or an `AbortSignal`
245
- * fires. Returns the terminal task on success.
246
- *
247
- * @param deps - Injected fetch, now, and sleep callbacks.
248
- * @param options - Optional poll delay, timeout, and abort signal.
249
- * @returns The terminal task, or an error if aborted, timed out, or the transport fails.
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 { CompleteTask as a, InProgressTask as c, SubmitAtHeadParameters as d, SubmitAtVersionParameters as f, LogPage as i, LuauExecutionTask as l, ListLogsParameters as n, FailedTask as o, LogMessage as r, GetParameters as s, PollUntilDoneOptions as t, LuauExecutionTaskRef as u };
253
- //# sourceMappingURL=polling-BMrYajok.d.mts.map
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 { s as isRecord } from "./resource-client-D6Efj9fU.mjs";
1
+ import { i as isRecord } from "./resource-client-C_D--PYX.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-DIrvwCmd.mjs.map
42
+ //# sourceMappingURL=price-information-DK83Wul1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"price-information-DIrvwCmd.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;AACnC,KAAI,CAAC,SAAS,MAAM,CACnB,QAAO;CAGR,MAAM,eAAe,MAAM,0BAA0B,KAAA;AACrD,KAAI,iBAAiB,KAAA,KAAa,OAAO,iBAAiB,SACzD,QAAO;CAGR,MAAM,WAAW,MAAM;AACvB,KAAI,CAAC,MAAM,QAAQ,SAAS,CAC3B,QAAO;AAGR,MAAK,MAAM,WAAW,SACrB,KAAI,CAAC,UAAU,QAAQ,CACtB,QAAO;AAIT,QAAO;;;;;;;;;;;AAYR,SAAgB,qBACf,MAC0B;AAC1B,QAAO;EACN,qBAAqB,KAAK,uBAAuB,KAAA;EACjD,iBAAiB,CAAC,GAAG,KAAK,gBAAgB;EAC1C"}
1
+ {"version":3,"file":"price-information-DK83Wul1.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
@@ -57,10 +61,29 @@ var ApiError = class extends OpenCloudError {
57
61
  //#region src/errors/network-error.ts
58
62
  /**
59
63
  * Thrown when a network-level failure prevents the request from reaching
60
- * the Roblox Open Cloud API (e.g., DNS resolution failure, connection timeout).
64
+ * the Roblox Open Cloud API (e.g., DNS resolution failure, connection reset).
65
+ * The `method` and `url` name the failing call so a transport failure that
66
+ * survives every retry can be diagnosed; the underlying transport error is
67
+ * carried on `cause`.
68
+ *
69
+ * @since 0.1.0
61
70
  */
62
71
  var NetworkError = class extends OpenCloudError {
72
+ method;
63
73
  name = "NetworkError";
74
+ url;
75
+ /**
76
+ * Creates a new NetworkError.
77
+ *
78
+ * @param message - Human-readable error description.
79
+ * @param options - Error options including the optional `cause` and the
80
+ * `method` / `url` of the request that failed.
81
+ */
82
+ constructor(message, options) {
83
+ super(message, options);
84
+ this.method = options?.method;
85
+ this.url = options?.url;
86
+ }
64
87
  };
65
88
  //#endregion
66
89
  //#region src/errors/rate-limit.ts
@@ -68,6 +91,8 @@ var NetworkError = class extends OpenCloudError {
68
91
  * Thrown when the Roblox Open Cloud API returns a 429 Too Many Requests response.
69
92
  * Contains the server-suggested retry delay.
70
93
  *
94
+ * @since 0.1.0
95
+ *
71
96
  * @example
72
97
  *
73
98
  * ```ts
@@ -83,6 +108,8 @@ var NetworkError = class extends OpenCloudError {
83
108
  */
84
109
  var RateLimitError = class extends OpenCloudError {
85
110
  name = "RateLimitError";
111
+ /** Requests left in the throttled window, or `undefined` if not reported. */
112
+ remaining;
86
113
  retryAfterSeconds;
87
114
  /**
88
115
  * Creates a new RateLimitError.
@@ -93,9 +120,10 @@ var RateLimitError = class extends OpenCloudError {
93
120
  constructor(message, options) {
94
121
  super(message, options);
95
122
  this.retryAfterSeconds = options.retryAfterSeconds;
123
+ this.remaining = options.remaining;
96
124
  }
97
125
  };
98
126
  //#endregion
99
127
  export { OpenCloudError as i, NetworkError as n, ApiError as r, RateLimitError as t };
100
128
 
101
- //# sourceMappingURL=rate-limit-D1q2Js-z.mjs.map
129
+ //# sourceMappingURL=rate-limit-Co9i28qi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-Co9i28qi.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/** HTTP status code from the API response. */\n\tstatusCode: number;\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 override readonly name: string = \"ApiError\";\n\tpublic readonly statusCode: number;\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, and the parsed response body when present.\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}\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 * 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}\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\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\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}\n}\n"],"mappings":";;;;;;;;;AAQA,IAAa,iBAAb,cAAoC,MAAM;CACzC,OAAwC;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgCA,IAAa,WAAb,cAA8B,eAAe;CAC5C;CACA;CACA,OAAwC;CACxC;;;;;;;;CASA,YAAY,SAAiB,SAA0B;EACtD,MAAM,SAAS,OAAO;EACtB,KAAK,aAAa,QAAQ;EAC1B,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;CACxB;AACD;;;;;;;;;;;;ACtCA,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;;;;;;;;;;;;;;;;;;;;;;ACDA,IAAa,iBAAb,cAAoC,eAAe;CAClD,OAAgC;;CAEhC;CACA;;;;;;;CAQA,YAAY,SAAiB,SAAgC;EAC5D,MAAM,SAAS,OAAO;EACtB,KAAK,oBAAoB,QAAQ;EACjC,KAAK,YAAY,QAAQ;CAC1B;AACD"}