@bedrock-rbx/ocale 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/badge-cost-mismatch-DrlvhlQc.mjs +47 -0
- package/dist/badge-cost-mismatch-DrlvhlQc.mjs.map +1 -0
- package/dist/badges.d.mts +228 -184
- package/dist/badges.d.mts.map +1 -1
- package/dist/badges.mjs +176 -18
- package/dist/badges.mjs.map +1 -1
- package/dist/capacity-admission-hycCFkTo.d.mts +355 -0
- package/dist/capacity-admission-hycCFkTo.d.mts.map +1 -0
- package/dist/{data.generated-B2ceLfSn.d.mts → data.generated-D_vpa5-g.d.mts} +23 -23
- package/dist/data.generated-D_vpa5-g.d.mts.map +1 -0
- package/dist/developer-products.d.mts +181 -186
- package/dist/developer-products.d.mts.map +1 -1
- package/dist/developer-products.mjs +24 -24
- package/dist/developer-products.mjs.map +1 -1
- package/dist/game-passes.d.mts +206 -203
- package/dist/game-passes.d.mts.map +1 -1
- package/dist/game-passes.mjs +26 -21
- package/dist/game-passes.mjs.map +1 -1
- package/dist/index.d.mts +905 -343
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +325 -10
- package/dist/index.mjs.map +1 -1
- package/dist/locales.d.mts +30 -2
- package/dist/locales.d.mts.map +1 -0
- package/dist/locales.mjs +24 -1
- package/dist/locales.mjs.map +1 -1
- package/dist/luau-execution.d.mts +154 -151
- package/dist/luau-execution.d.mts.map +1 -1
- package/dist/luau-execution.mjs +11 -8
- package/dist/luau-execution.mjs.map +1 -1
- package/dist/{network-error-DR9FX5hb.mjs → network-error-iVSng5MT.mjs} +44 -6
- package/dist/network-error-iVSng5MT.mjs.map +1 -0
- package/dist/places.d.mts +204 -180
- package/dist/places.d.mts.map +1 -1
- package/dist/places.mjs +66 -20
- package/dist/places.mjs.map +1 -1
- package/dist/{poll-timeout-3PXLsabj.mjs → poll-timeout-DzztDymd.mjs} +2 -2
- package/dist/{poll-timeout-3PXLsabj.mjs.map → poll-timeout-DzztDymd.mjs.map} +1 -1
- package/dist/{polling-helpers-CoVhsC33.mjs → polling-helpers-DfF5dspc.mjs} +249 -83
- package/dist/polling-helpers-DfF5dspc.mjs.map +1 -0
- package/dist/{price-information-B0tkOoAX.mjs → price-information-DEkEQ8Pq.mjs} +2 -2
- package/dist/{price-information-B0tkOoAX.mjs.map → price-information-DEkEQ8Pq.mjs.map} +1 -1
- package/dist/resource-client-BCKukheG.d.mts +168 -0
- package/dist/resource-client-BCKukheG.d.mts.map +1 -0
- package/dist/{resource-client-rqTMkBeR.mjs → resource-client-CaIVr-go.mjs} +586 -158
- package/dist/resource-client-CaIVr-go.mjs.map +1 -0
- package/dist/retry-C2oHesDx.d.mts +229 -0
- package/dist/retry-C2oHesDx.d.mts.map +1 -0
- package/dist/{retry-BlX4tUnT.mjs → retry-CMRDvAR4.mjs} +278 -18
- package/dist/retry-CMRDvAR4.mjs.map +1 -0
- package/dist/storage.d.mts +333 -334
- package/dist/storage.d.mts.map +1 -1
- package/dist/storage.mjs +29 -22
- package/dist/storage.mjs.map +1 -1
- package/dist/testing.d.mts +347 -360
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +3 -4
- package/dist/testing.mjs.map +1 -1
- package/dist/types-CdMr_J1M.d.mts +509 -0
- package/dist/types-CdMr_J1M.d.mts.map +1 -0
- package/dist/universes.d.mts +619 -422
- package/dist/universes.d.mts.map +1 -1
- package/dist/universes.mjs +421 -48
- package/dist/universes.mjs.map +1 -1
- package/dist/{validation-B_Zs1So2.mjs → validation-964VNlbp.mjs} +2 -2
- package/dist/{validation-B_Zs1So2.mjs.map → validation-964VNlbp.mjs.map} +1 -1
- package/dist/wire-DJqupefn.d.mts +41 -0
- package/dist/wire-DJqupefn.d.mts.map +1 -0
- package/package.json +14 -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
package/dist/badges.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { a as ApiError } from "./network-error-
|
|
2
|
-
import { r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS } from "./retry-
|
|
1
|
+
import { a as ApiError, n as RateLimitError } from "./network-error-iVSng5MT.mjs";
|
|
2
|
+
import { O as parseQuotaResetSeconds, j as isRecord, m as UnexpectedResponseError, r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS } from "./retry-CMRDvAR4.mjs";
|
|
3
|
+
import { t as BadgeCostMismatchError } from "./badge-cost-mismatch-DrlvhlQc.mjs";
|
|
3
4
|
import { t as toBlob } from "./to-blob-RPqMBuft.mjs";
|
|
4
|
-
import { c as isDateTimeString, n as okRequest,
|
|
5
|
+
import { c as isDateTimeString, n as okRequest, r as parseEmptyResponse, s as toJsonDetails, t as ResourceClient } from "./resource-client-CaIVr-go.mjs";
|
|
5
6
|
//#region src/domains/badges/badges/builders.ts
|
|
6
7
|
/**
|
|
7
8
|
* Builds a `POST` request for the legacy "create badge" endpoint.
|
|
@@ -48,6 +49,8 @@ function toPaymentSourceWire(source) {
|
|
|
48
49
|
}
|
|
49
50
|
//#endregion
|
|
50
51
|
//#region src/domains/badges/badges/operations.ts
|
|
52
|
+
/** Body error code Roblox sends when a create's expected cost is wrong. */
|
|
53
|
+
const COST_MISMATCH_CODE = "18";
|
|
51
54
|
/**
|
|
52
55
|
* Per-second request ceiling for creating a badge, sourced from
|
|
53
56
|
* `x-roblox-rate-limits` on the legacy badges create operation in the
|
|
@@ -83,6 +86,25 @@ const CREATE_REQUIRED_SCOPES = Object.freeze(["legacy-universe.badge:manage-and-
|
|
|
83
86
|
* in the vendored OpenAPI schema.
|
|
84
87
|
*/
|
|
85
88
|
const UPDATE_REQUIRED_SCOPES = Object.freeze(["legacy-universe.badge:write"]);
|
|
89
|
+
/**
|
|
90
|
+
* Builds the refinement that turns a create refused with body code `18` into
|
|
91
|
+
* a {@link BadgeCostMismatchError}, whatever its status. Every other error
|
|
92
|
+
* passes through unchanged.
|
|
93
|
+
*
|
|
94
|
+
* @param expectedCost - The `expectedCost` the create sent, if any.
|
|
95
|
+
* @returns The refinement for one create call.
|
|
96
|
+
*/
|
|
97
|
+
function refineCreateError(expectedCost) {
|
|
98
|
+
return (error) => {
|
|
99
|
+
if (!(error instanceof ApiError) || error.code !== COST_MISMATCH_CODE) return error;
|
|
100
|
+
return new BadgeCostMismatchError(error.message, {
|
|
101
|
+
cause: error,
|
|
102
|
+
code: error.code,
|
|
103
|
+
expectedCost,
|
|
104
|
+
statusCode: error.statusCode
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
}
|
|
86
108
|
//#endregion
|
|
87
109
|
//#region src/domains/badges/badges/parsers.ts
|
|
88
110
|
/**
|
|
@@ -91,14 +113,15 @@ const UPDATE_REQUIRED_SCOPES = Object.freeze(["legacy-universe.badge:write"]);
|
|
|
91
113
|
* exceptions.
|
|
92
114
|
*
|
|
93
115
|
* @param response - The full {@link HttpResponse} from the Open Cloud API.
|
|
94
|
-
* The status code is included on the returned `
|
|
95
|
-
* fails; the headers are available for future parsers that need
|
|
116
|
+
* The status code is included on the returned `UnexpectedResponseError` when
|
|
117
|
+
* validation fails; the headers are available for future parsers that need
|
|
118
|
+
* them.
|
|
96
119
|
* @returns A success result wrapping the converted `Badge`, or an
|
|
97
|
-
* `
|
|
120
|
+
* `UnexpectedResponseError` when the body does not match the wire schema.
|
|
98
121
|
*/
|
|
99
122
|
function parseBadgeResponse({ body, status: statusCode }) {
|
|
100
123
|
if (!isBadgeResponseV2Wire(body)) return {
|
|
101
|
-
err: new
|
|
124
|
+
err: new UnexpectedResponseError("Malformed badge response", {
|
|
102
125
|
details: toJsonDetails(body),
|
|
103
126
|
statusCode
|
|
104
127
|
}),
|
|
@@ -126,7 +149,7 @@ function copyAwarder(awarder) {
|
|
|
126
149
|
return {
|
|
127
150
|
id: String(awarder.id),
|
|
128
151
|
name: awarder.name,
|
|
129
|
-
type:
|
|
152
|
+
type: awarder.type
|
|
130
153
|
};
|
|
131
154
|
}
|
|
132
155
|
function copyStatistics(statistics) {
|
|
@@ -141,7 +164,7 @@ function hasRequiredPrimitiveFields(body) {
|
|
|
141
164
|
}
|
|
142
165
|
function isBadgeAwarderWire(value) {
|
|
143
166
|
if (!isRecord(value)) return false;
|
|
144
|
-
return typeof value["id"] === "number" && typeof value["name"] === "string" && value["type"] ===
|
|
167
|
+
return typeof value["id"] === "number" && (value["name"] === void 0 || typeof value["name"] === "string") && value["type"] === "Place";
|
|
145
168
|
}
|
|
146
169
|
function isBadgeStatisticsWire(value) {
|
|
147
170
|
if (!isRecord(value)) return false;
|
|
@@ -155,6 +178,76 @@ function isBadgeResponseV2Wire(body) {
|
|
|
155
178
|
return true;
|
|
156
179
|
}
|
|
157
180
|
//#endregion
|
|
181
|
+
//#region src/domains/badges/free-quota/operations.ts
|
|
182
|
+
/** Origin of the unauthenticated free badge quota endpoint. */
|
|
183
|
+
const FREE_QUOTA_BASE_URL = "https://badges.roblox.com";
|
|
184
|
+
/**
|
|
185
|
+
* Per-second request ceiling for reading the free badge quota. Roblox
|
|
186
|
+
* reports 60 requests per 60 seconds, per caller.
|
|
187
|
+
*/
|
|
188
|
+
const FREE_QUOTA_OPERATION_LIMIT = Object.freeze({
|
|
189
|
+
maxPerSecond: 1,
|
|
190
|
+
operationKey: "badges.free-quota"
|
|
191
|
+
});
|
|
192
|
+
/**
|
|
193
|
+
* Builds the `GET` request for the free badge quota of a universe.
|
|
194
|
+
*
|
|
195
|
+
* @param parameters - The universe to read.
|
|
196
|
+
* @returns A pure {@link HttpRequest} describing the read.
|
|
197
|
+
*/
|
|
198
|
+
function buildFreeQuotaRequest({ universeId }) {
|
|
199
|
+
return {
|
|
200
|
+
method: "GET",
|
|
201
|
+
url: `/v1/universes/${universeId}/free-badges-quota`
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Parses the free badge quota body, a bare non-negative integer.
|
|
206
|
+
*
|
|
207
|
+
* @param response - The full {@link HttpResponse}.
|
|
208
|
+
* @returns The free badges left today, or an `UnexpectedResponseError` when
|
|
209
|
+
* the body is not a count.
|
|
210
|
+
*/
|
|
211
|
+
function parseFreeQuotaResponse({ body, status: statusCode }) {
|
|
212
|
+
if (!isCount(body)) return {
|
|
213
|
+
err: new UnexpectedResponseError("Malformed free badge quota response", {
|
|
214
|
+
details: toJsonDetails(body),
|
|
215
|
+
statusCode
|
|
216
|
+
}),
|
|
217
|
+
success: false
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
data: body,
|
|
221
|
+
success: true
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Points a free badge quota 429 at `x-ratelimit-reset`. The endpoint's
|
|
226
|
+
* `retry-after` is shorter than its window, which reopens only at the reset.
|
|
227
|
+
* Any other error, or a 429 without a reset, passes through unchanged.
|
|
228
|
+
*
|
|
229
|
+
* @param error - The transport error of one attempt.
|
|
230
|
+
* @returns The error with its wait set to the reported reset.
|
|
231
|
+
*/
|
|
232
|
+
function waitForQuotaReset(error) {
|
|
233
|
+
if (!(error instanceof RateLimitError)) return error;
|
|
234
|
+
const resetSeconds = parseQuotaResetSeconds(error.responseHeaders?.["x-ratelimit-reset"]);
|
|
235
|
+
if (resetSeconds === void 0) return error;
|
|
236
|
+
return new RateLimitError(error.message, {
|
|
237
|
+
cause: error.cause,
|
|
238
|
+
code: error.code,
|
|
239
|
+
details: error.details,
|
|
240
|
+
remaining: error.remaining,
|
|
241
|
+
responseHeaders: error.responseHeaders,
|
|
242
|
+
retryAfterSeconds: resetSeconds,
|
|
243
|
+
source: error.source,
|
|
244
|
+
statusCode: error.statusCode
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function isCount(value) {
|
|
248
|
+
return Number.isSafeInteger(value) && Number(value) >= 0;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
158
251
|
//#region src/domains/game-internationalization/badge-icon/builders.ts
|
|
159
252
|
/**
|
|
160
253
|
* Builds a `POST` request for the localized "upload badge icon" endpoint. A
|
|
@@ -199,12 +292,13 @@ function buildUpdateRequest(parameters) {
|
|
|
199
292
|
//#endregion
|
|
200
293
|
//#region src/domains/game-internationalization/badge-name-description/operations.ts
|
|
201
294
|
/**
|
|
202
|
-
* Per-second request ceiling for
|
|
203
|
-
*
|
|
204
|
-
* requests per minute
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
295
|
+
* Per-second request ceiling for badge localization Operations, from each
|
|
296
|
+
* operation's `x-roblox-rate-limits.perApiKeyOwner` in the vendored schema
|
|
297
|
+
* (100 requests per minute). This family's key stays separate from other
|
|
298
|
+
* game-internationalization families: the #587 probe measured independent
|
|
299
|
+
* reported 100/minute counters, including on rejected requests. Successful
|
|
300
|
+
* writes may have additional service limits; see
|
|
301
|
+
* `docs/spikes/game-internationalization-rate-limits/README.md`.
|
|
208
302
|
*/
|
|
209
303
|
const LOCALIZATION_OPERATION_LIMIT = Object.freeze({
|
|
210
304
|
maxPerSecond: 100 / 60,
|
|
@@ -256,6 +350,33 @@ const UPLOAD_ICON_OPERATION_LIMIT = Object.freeze({
|
|
|
256
350
|
*/
|
|
257
351
|
const UPLOAD_ICON_REQUIRED_SCOPES = Object.freeze(["legacy-badge:manage"]);
|
|
258
352
|
//#endregion
|
|
353
|
+
//#region src/domains/publish/badge-icon/parsers.ts
|
|
354
|
+
/**
|
|
355
|
+
* Parses a badge icon upload response, whose `targetId` is the asset ID of
|
|
356
|
+
* the uploaded icon.
|
|
357
|
+
*
|
|
358
|
+
* @param response - The full {@link HttpResponse}.
|
|
359
|
+
* @returns The uploaded icon, or an `UnexpectedResponseError` when the body
|
|
360
|
+
* names no positive integer asset ID.
|
|
361
|
+
*/
|
|
362
|
+
function parseUploadIconResponse({ body, status: statusCode }) {
|
|
363
|
+
const targetId = isRecord(body) ? body["targetId"] : void 0;
|
|
364
|
+
if (!isAssetId(targetId)) return {
|
|
365
|
+
err: new UnexpectedResponseError("Malformed badge icon upload response", {
|
|
366
|
+
details: toJsonDetails(body),
|
|
367
|
+
statusCode
|
|
368
|
+
}),
|
|
369
|
+
success: false
|
|
370
|
+
};
|
|
371
|
+
return {
|
|
372
|
+
data: { iconImageId: String(targetId) },
|
|
373
|
+
success: true
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function isAssetId(value) {
|
|
377
|
+
return Number.isSafeInteger(value) && Number(value) > 0;
|
|
378
|
+
}
|
|
379
|
+
//#endregion
|
|
259
380
|
//#region src/resources/badges/client.ts
|
|
260
381
|
function makeSpec(spec) {
|
|
261
382
|
return Object.freeze(spec);
|
|
@@ -276,12 +397,20 @@ const UPDATE_SPEC = makeSpec({
|
|
|
276
397
|
parse: parseEmptyResponse,
|
|
277
398
|
requiredScopes: UPDATE_REQUIRED_SCOPES
|
|
278
399
|
});
|
|
400
|
+
const FREE_QUOTA_SPEC = makeSpec({
|
|
401
|
+
buildRequest: (parameters) => okRequest(buildFreeQuotaRequest(parameters)),
|
|
402
|
+
methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,
|
|
403
|
+
methodKind: "idempotent",
|
|
404
|
+
operationLimit: FREE_QUOTA_OPERATION_LIMIT,
|
|
405
|
+
parse: parseFreeQuotaResponse,
|
|
406
|
+
unauthenticatedBaseUrl: FREE_QUOTA_BASE_URL
|
|
407
|
+
});
|
|
279
408
|
const UPLOAD_ICON_SPEC = makeSpec({
|
|
280
409
|
buildRequest: (parameters) => okRequest(buildUploadIconRequest(parameters)),
|
|
281
410
|
methodDefaults: CREATE_METHOD_DEFAULTS,
|
|
282
411
|
methodKind: "create",
|
|
283
412
|
operationLimit: UPLOAD_ICON_OPERATION_LIMIT,
|
|
284
|
-
parse:
|
|
413
|
+
parse: parseUploadIconResponse,
|
|
285
414
|
requiredScopes: UPLOAD_ICON_REQUIRED_SCOPES
|
|
286
415
|
});
|
|
287
416
|
const UPDATE_NAME_DESCRIPTION_SPEC = makeSpec({
|
|
@@ -318,7 +447,7 @@ const UPLOAD_LOCALIZED_ICON_SPEC = makeSpec({
|
|
|
318
447
|
* ```ts
|
|
319
448
|
* import { BadgesClient } from "@bedrock-rbx/ocale/badges";
|
|
320
449
|
*
|
|
321
|
-
* const client = new BadgesClient({ apiKey: "your-key" });
|
|
450
|
+
* const client = new BadgesClient({ credential: { apiKey: "your-key", kind: "apiKey" } });
|
|
322
451
|
* expect(client).toBeInstanceOf(BadgesClient);
|
|
323
452
|
* ```
|
|
324
453
|
*/
|
|
@@ -350,6 +479,10 @@ var BadgesClient = class {
|
|
|
350
479
|
* No default request timeout applies to this upload; pass `options.timeout`
|
|
351
480
|
* to set a per-call deadline.
|
|
352
481
|
*
|
|
482
|
+
* A create whose `expectedCost` differs from the actual cost fails with a
|
|
483
|
+
* `BadgeCostMismatchError` and is not charged; with `expectedCost: 0`
|
|
484
|
+
* that means the universe's free badge quota is spent for today.
|
|
485
|
+
*
|
|
353
486
|
* @param parameters - Creation fields including the universe, name, and
|
|
354
487
|
* icon image.
|
|
355
488
|
* @param options - Optional per-request overrides.
|
|
@@ -360,10 +493,35 @@ var BadgesClient = class {
|
|
|
360
493
|
return this.#inner.executeAsync({
|
|
361
494
|
options,
|
|
362
495
|
parameters,
|
|
496
|
+
refineError: refineCreateError(parameters.expectedCost),
|
|
363
497
|
spec: CREATE_SPEC
|
|
364
498
|
});
|
|
365
499
|
}
|
|
366
500
|
/**
|
|
501
|
+
* Reads how many badges the universe can still create free of charge
|
|
502
|
+
* today. Each create within the quota lowers it by one. The quota resets
|
|
503
|
+
* daily at 00:00 UTC. Roblox answers for any universe ID, existing or not.
|
|
504
|
+
*
|
|
505
|
+
* The read is unauthenticated: it sends no credential and is served from
|
|
506
|
+
* `https://badges.roblox.com`, so the client `baseUrl` does not apply.
|
|
507
|
+
* Roblox allows 60 reads per minute per caller. A 429 waits until the
|
|
508
|
+
* reported `x-ratelimit-reset` before it retries.
|
|
509
|
+
*
|
|
510
|
+
* @since 0.4.0
|
|
511
|
+
* @param parameters - The universe to read.
|
|
512
|
+
* @param options - Optional per-request overrides.
|
|
513
|
+
* @returns A {@link Result} wrapping the free badges left today, or the
|
|
514
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
515
|
+
*/
|
|
516
|
+
async getFreeQuota(parameters, options) {
|
|
517
|
+
return this.#inner.executeAsync({
|
|
518
|
+
options,
|
|
519
|
+
parameters,
|
|
520
|
+
refineError: waitForQuotaReset,
|
|
521
|
+
spec: FREE_QUOTA_SPEC
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
367
525
|
* Partially updates a badge's configuration. Mirrors the upstream
|
|
368
526
|
* `200 OK` empty response: a successful update yields `undefined`
|
|
369
527
|
* data. Only fields explicitly provided are forwarded to the server,
|
|
@@ -392,7 +550,7 @@ var BadgesClient = class {
|
|
|
392
550
|
*
|
|
393
551
|
* @param parameters - Identifier plus the image bytes to upload.
|
|
394
552
|
* @param options - Optional per-request overrides.
|
|
395
|
-
* @returns A
|
|
553
|
+
* @returns A {@link Result} wrapping the uploaded icon's asset ID, or the
|
|
396
554
|
* {@link OpenCloudError} that caused the request to fail.
|
|
397
555
|
*/
|
|
398
556
|
async uploadIcon(parameters, options) {
|
package/dist/badges.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badges.mjs","names":["buildUpdateRequest","buildUploadIconRequest","buildUpdateRequest","buildLocaleNameDescRequest","buildLocaleUploadIconRequest","#inner"],"sources":["../src/domains/badges/badges/builders.ts","../src/domains/badges/badges/operations.ts","../src/domains/badges/badges/parsers.ts","../src/domains/game-internationalization/badge-icon/builders.ts","../src/domains/game-internationalization/badge-name-description/builders.ts","../src/domains/game-internationalization/badge-name-description/operations.ts","../src/domains/publish/badge-icon/builders.ts","../src/domains/publish/badge-icon/operations.ts","../src/resources/badges/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { BadgePaymentSource, CreateBadgeParameters, UpdateBadgeParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the legacy \"create badge\" endpoint.\n *\n * @param parameters - Fields describing the new badge; optional values\n * omitted here are left off the multipart payload entirely.\n * @returns A pure {@link HttpRequest} describing the create call.\n */\nexport function buildCreateRequest(parameters: CreateBadgeParameters): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"name\", parameters.name);\n\tbody.append(\"files\", toBlob(parameters.icon));\n\tif (parameters.description !== undefined) {\n\t\tbody.append(\"description\", parameters.description);\n\t}\n\n\tif (parameters.isActive !== undefined) {\n\t\tbody.append(\"isActive\", String(parameters.isActive));\n\t}\n\n\tif (parameters.expectedCost !== undefined) {\n\t\tbody.append(\"expectedCost\", String(parameters.expectedCost));\n\t}\n\n\tif (parameters.paymentSource !== undefined) {\n\t\tbody.append(\"paymentSourceType\", toPaymentSourceWire(parameters.paymentSource));\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-badges/v1/universes/${parameters.universeId}/badges`,\n\t};\n}\n\n/**\n * Builds a `PATCH` request for the legacy \"update badge\" endpoint. Every\n * field on `parameters` except the identifier is optional; omitted fields\n * are not appended to the JSON body so the server leaves them unchanged.\n *\n * @param parameters - Identifier plus fields to update.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(parameters: UpdateBadgeParameters): HttpRequest {\n\tconst body: Record<string, boolean | string> = {};\n\tif (parameters.name !== undefined) {\n\t\tbody[\"name\"] = parameters.name;\n\t}\n\n\tif (parameters.description !== undefined) {\n\t\tbody[\"description\"] = parameters.description;\n\t}\n\n\tif (parameters.enabled !== undefined) {\n\t\tbody[\"enabled\"] = parameters.enabled;\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"PATCH\",\n\t\turl: `/legacy-badges/v1/badges/${parameters.badgeId}`,\n\t};\n}\n\nfunction toPaymentSourceWire(source: BadgePaymentSource): \"1\" | \"2\" {\n\treturn source === \"User\" ? \"1\" : \"2\";\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for creating a badge, sourced from\n * `x-roblox-rate-limits` on the legacy badges create operation in the\n * vendored OpenAPI schema (100 per minute, per API key owner).\n */\nexport const CREATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.create\",\n});\n\n/**\n * Per-second request ceiling for updating a badge, sourced from\n * `x-roblox-rate-limits` on the legacy badges update operation in the\n * vendored OpenAPI schema. Keyed independently from\n * {@link CREATE_OPERATION_LIMIT} so create and update do not share a\n * queue, since Roblox does not document the per-minute quota as shared\n * between the POST and PATCH endpoints.\n */\nexport const UPDATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.update\",\n});\n\n/**\n * Scopes the API key or OAuth token must carry to create a badge,\n * sourced from `x-roblox-scopes` on the legacy badges create operation\n * in the vendored OpenAPI schema. The trailing\n * `:manage-and-spend-robux` reflects that badge creation may charge a\n * Robux fee.\n */\nexport const CREATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-universe.badge:manage-and-spend-robux\",\n]);\n\n/**\n * Scopes the API key or OAuth token must carry to update a badge,\n * sourced from `x-roblox-scopes` on the legacy badges update operation\n * in the vendored OpenAPI schema.\n */\nexport const UPDATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-universe.badge:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.ts\";\nimport { isDateTimeString } from \"../../../internal/utils/is-date-time-string.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { Badge, BadgeAwarder, BadgeStatistics } from \"./types.ts\";\nimport type { BadgeAwarderWire, BadgeResponseV2Wire, BadgeStatisticsWire } from \"./wire.ts\";\n\n/**\n * Parses a successful Badges API response into the public `Badge` shape,\n * returning a `Result` so callers can handle malformed payloads without\n * exceptions.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * The status code is included on the returned `ApiError` when validation\n * fails; the headers are available for future parsers that need them.\n * @returns A success result wrapping the converted `Badge`, or an\n * `ApiError` when the body does not match the wire schema.\n */\nexport function parseBadgeResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<Badge, ApiError> {\n\tif (!isBadgeResponseV2Wire(body)) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed badge response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tid: String(body.id),\n\t\t\tname: body.name,\n\t\t\tawarder: copyAwarder(body.awarder),\n\t\t\tcreatedAt: new Date(body.created),\n\t\t\tdescription: body.description,\n\t\t\tdisplayDescription: body.displayDescription,\n\t\t\tdisplayIconImageId:\n\t\t\t\tbody.displayIconImageId === 0 ? undefined : String(body.displayIconImageId),\n\t\t\tdisplayName: body.displayName,\n\t\t\tenabled: body.enabled,\n\t\t\ticonImageId: body.iconImageId === 0 ? undefined : String(body.iconImageId),\n\t\t\tstatistics: copyStatistics(body.statistics),\n\t\t\tupdatedAt: new Date(body.updated),\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction copyAwarder(awarder: BadgeAwarderWire): BadgeAwarder {\n\treturn { id: String(awarder.id), name: awarder.name, type: \"Place\" };\n}\n\nfunction copyStatistics(statistics: BadgeStatisticsWire): BadgeStatistics {\n\treturn {\n\t\tawardedCount: statistics.awardedCount,\n\t\tpastDayAwardedCount: statistics.pastDayAwardedCount,\n\t\twinRatePercentage: statistics.winRatePercentage,\n\t};\n}\n\nfunction hasRequiredPrimitiveFields(body: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof body[\"id\"] === \"number\" &&\n\t\ttypeof body[\"name\"] === \"string\" &&\n\t\ttypeof body[\"description\"] === \"string\" &&\n\t\ttypeof body[\"displayName\"] === \"string\" &&\n\t\ttypeof body[\"displayDescription\"] === \"string\" &&\n\t\ttypeof body[\"enabled\"] === \"boolean\" &&\n\t\ttypeof body[\"iconImageId\"] === \"number\" &&\n\t\ttypeof body[\"displayIconImageId\"] === \"number\" &&\n\t\tisDateTimeString(body[\"created\"]) &&\n\t\tisDateTimeString(body[\"updated\"])\n\t);\n}\n\nfunction isBadgeAwarderWire(value: unknown): value is BadgeAwarderWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttypeof value[\"id\"] === \"number\" && typeof value[\"name\"] === \"string\" && value[\"type\"] === 1\n\t);\n}\n\nfunction isBadgeStatisticsWire(value: unknown): value is BadgeStatisticsWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttypeof value[\"awardedCount\"] === \"number\" &&\n\t\ttypeof value[\"pastDayAwardedCount\"] === \"number\" &&\n\t\ttypeof value[\"winRatePercentage\"] === \"number\"\n\t);\n}\n\nfunction isBadgeResponseV2Wire(body: unknown): body is BadgeResponseV2Wire {\n\tif (!isRecord(body)) {\n\t\treturn false;\n\t}\n\n\tif (!hasRequiredPrimitiveFields(body)) {\n\t\treturn false;\n\t}\n\n\tif (!isBadgeAwarderWire(body[\"awarder\"])) {\n\t\treturn false;\n\t}\n\n\tif (!isBadgeStatisticsWire(body[\"statistics\"])) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { UploadBadgeIconLocalizationParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the localized \"upload badge icon\" endpoint. A\n * successful upload replaces any existing icon for the same\n * `(badgeId, languageCode)` pair.\n *\n * @param parameters - Badge and language identifiers plus the image bytes\n * to upload.\n * @returns A pure {@link HttpRequest} describing the upload call.\n */\nexport function buildUploadIconRequest(\n\tparameters: UploadBadgeIconLocalizationParameters,\n): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"Files\", toBlob(parameters.image));\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-game-internationalization/v1/badges/${parameters.badgeId}/icons/language-codes/${parameters.languageCode}`,\n\t};\n}\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport type { UpdateBadgeNameDescriptionParameters } from \"./types.ts\";\n\n/**\n * Builds a `PATCH` request for the localized \"update badge name/description\"\n * endpoint. Either `name`, `description`, or both may be supplied; omitted\n * fields are not included in the JSON body so the server leaves the existing\n * value for that locale untouched.\n *\n * @param parameters - Badge and language identifiers plus the optional\n * replacement values.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(parameters: UpdateBadgeNameDescriptionParameters): HttpRequest {\n\tconst body: Record<string, string> = {};\n\tif (parameters.name !== undefined) {\n\t\tbody[\"name\"] = parameters.name;\n\t}\n\n\tif (parameters.description !== undefined) {\n\t\tbody[\"description\"] = parameters.description;\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"PATCH\",\n\t\turl: `/legacy-game-internationalization/v1/badges/${parameters.badgeId}/name-description/language-codes/${parameters.languageCode}`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for every badge localization Operation. The\n * legacy `gameinternationalization` service caps each API key at 100\n * requests per minute *shared across the entire service* (see the\n * `x-roblox-rate-limits` extension on every operation in the vendored\n * Open Cloud spec), so all badge localization methods queue against the\n * same operation key.\n */\nexport const LOCALIZATION_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badge-localization\",\n});\n\n/**\n * Scopes required for every badge localization operation, sourced from\n * `x-roblox-scopes` on the legacy `gameinternationalization` badge\n * endpoints in the vendored OpenAPI schema.\n */\nexport const LOCALIZATION_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-badge:manage\",\n]);\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { UploadBadgeIconParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the legacy \"upload badge icon\" endpoint. A\n * successful upload replaces any existing source-language icon on the\n * badge.\n *\n * @param parameters - Badge identifier plus the image bytes to upload.\n * @returns A pure {@link HttpRequest} describing the upload call.\n */\nexport function buildUploadIconRequest(parameters: UploadBadgeIconParameters): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"Files\", toBlob(parameters.icon));\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-publish/v1/badges/${parameters.badgeId}/icon`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for uploading a badge icon, sourced from\n * `x-roblox-rate-limits` on the legacy badge icon upload operation in\n * the vendored OpenAPI schema (100 per minute, per API key owner). Keyed\n * separately from the badges create and update buckets because Roblox\n * does not document the legacy-publish quota as shared with the\n * legacy-badges quota.\n */\nexport const UPLOAD_ICON_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.upload-icon\",\n});\n\n/**\n * Scopes the API key or OAuth token must carry to upload a badge icon,\n * sourced from `x-roblox-scopes` on the legacy badge icon upload\n * operation in the vendored OpenAPI schema.\n */\nexport const UPLOAD_ICON_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-badge:manage\",\n]);\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { buildCreateRequest, buildUpdateRequest } from \"../../domains/badges/badges/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tCREATE_REQUIRED_SCOPES,\n\tUPDATE_OPERATION_LIMIT,\n\tUPDATE_REQUIRED_SCOPES,\n} from \"../../domains/badges/badges/operations.ts\";\nimport { parseBadgeResponse } from \"../../domains/badges/badges/parsers.ts\";\nimport type {\n\tBadge,\n\tCreateBadgeParameters,\n\tUpdateBadgeParameters,\n} from \"../../domains/badges/badges/types.ts\";\nimport { buildUploadIconRequest as buildLocaleUploadIconRequest } from \"../../domains/game-internationalization/badge-icon/builders.ts\";\nimport type { UploadBadgeIconLocalizationParameters } from \"../../domains/game-internationalization/badge-icon/types.ts\";\nimport { buildUpdateRequest as buildLocaleNameDescRequest } from \"../../domains/game-internationalization/badge-name-description/builders.ts\";\nimport {\n\tLOCALIZATION_OPERATION_LIMIT,\n\tLOCALIZATION_REQUIRED_SCOPES,\n} from \"../../domains/game-internationalization/badge-name-description/operations.ts\";\nimport type { UpdateBadgeNameDescriptionParameters } from \"../../domains/game-internationalization/badge-name-description/types.ts\";\nimport { buildUploadIconRequest } from \"../../domains/publish/badge-icon/builders.ts\";\nimport {\n\tUPLOAD_ICON_OPERATION_LIMIT,\n\tUPLOAD_ICON_REQUIRED_SCOPES,\n} from \"../../domains/publish/badge-icon/operations.ts\";\nimport type { UploadBadgeIconParameters } from \"../../domains/publish/badge-icon/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { CREATE_METHOD_DEFAULTS, IDEMPOTENT_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport {\n\tokRequest,\n\tparseEmptyResponse,\n\tResourceClient,\n\ttype ResourceMethodSpec,\n} from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\n\nfunction makeSpec<P, R>(spec: ResourceMethodSpec<P, R>): ResourceMethodSpec<P, R> {\n\treturn Object.freeze(spec);\n}\n\nconst CREATE_SPEC = makeSpec<CreateBadgeParameters, Badge>({\n\tbuildRequest: (parameters) => okRequest(buildCreateRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: CREATE_OPERATION_LIMIT,\n\tparse: parseBadgeResponse,\n\trequiredScopes: CREATE_REQUIRED_SCOPES,\n});\n\nconst UPDATE_SPEC = makeSpec<UpdateBadgeParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildUpdateRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: UPDATE_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: UPDATE_REQUIRED_SCOPES,\n});\n\nconst UPLOAD_ICON_SPEC = makeSpec<UploadBadgeIconParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildUploadIconRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: UPLOAD_ICON_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: UPLOAD_ICON_REQUIRED_SCOPES,\n});\n\nconst UPDATE_NAME_DESCRIPTION_SPEC = makeSpec<UpdateBadgeNameDescriptionParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildLocaleNameDescRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: LOCALIZATION_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: LOCALIZATION_REQUIRED_SCOPES,\n});\n\nconst UPLOAD_LOCALIZED_ICON_SPEC = makeSpec<UploadBadgeIconLocalizationParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildLocaleUploadIconRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: LOCALIZATION_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: LOCALIZATION_REQUIRED_SCOPES,\n});\n\ninterface BadgeLocalizationHandle {\n\t/**\n\t * Updates the per-locale display name and/or description registered against\n\t * a badge. Either `name`, `description`, or both may be supplied; omitted\n\t * fields are not forwarded so the server leaves the existing value for\n\t * that locale untouched. Mirrors the upstream `200 OK` echo body as\n\t * `undefined` data.\n\t *\n\t * @param parameters - Badge and language identifiers plus the optional\n\t * replacement values.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tupdateNameDescription: (\n\t\tparameters: UpdateBadgeNameDescriptionParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n\t/**\n\t * Uploads or replaces the per-locale icon for a badge. A subsequent\n\t * upload for the same `(badgeId, languageCode)` pair replaces the\n\t * existing icon for that locale. Does not retry on 5xx so a duplicate\n\t * upload cannot be created if the server fails mid-write. Source-language\n\t * icons remain on {@link BadgesClient.uploadIcon}.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Badge and language identifiers plus the image bytes\n\t * to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tuploadIcon: (\n\t\tparameters: UploadBadgeIconLocalizationParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n}\n\n/**\n * Public client for the Roblox Open Cloud Badges API. Covers programmatic\n * badge creation under a universe, partial updates of badge configuration\n * (`name`, `description`, `enabled`), and source-language icon uploads.\n *\n * Wires the request builders, the injected\n * {@link OpenCloudClientOptions.httpClient}, and response parsers into a\n * single ergonomic surface. Every method returns a {@link Result} so\n * callers handle failure explicitly; no thrown {@link OpenCloudError}\n * ever escapes the client.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { BadgesClient } from \"@bedrock-rbx/ocale/badges\";\n *\n * const client = new BadgesClient({ apiKey: \"your-key\" });\n * expect(client).toBeInstanceOf(BadgesClient);\n * ```\n */\nexport class BadgesClient {\n\treadonly #inner: ResourceClient;\n\n\t/**\n\t * Operation Group exposing per-locale localization Operations\n\t * (`updateNameDescription`, `uploadIcon`) backed by the\n\t * `legacy-game-internationalization` domain. Source-language values\n\t * remain on {@link BadgesClient.update} and\n\t * {@link BadgesClient.uploadIcon}; methods on this group set per-locale\n\t * overlays on top. Shares the parent client's HTTP, rate-limit, and\n\t * retry plumbing.\n\t */\n\tpublic readonly localization: BadgeLocalizationHandle;\n\n\t/**\n\t * Creates a new {@link BadgesClient}. Configuration is frozen on\n\t * construction; per-request overrides are accepted on each method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.localization = createLocalizationHandle(this.#inner);\n\t}\n\n\t/**\n\t * Creates a new badge under the supplied universe.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Creation fields including the universe, name, and\n\t * icon image.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed {@link Badge} or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async create(\n\t\tparameters: CreateBadgeParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<Badge, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: CREATE_SPEC });\n\t}\n\n\t/**\n\t * Partially updates a badge's configuration. Mirrors the upstream\n\t * `200 OK` empty response: a successful update yields `undefined`\n\t * data. Only fields explicitly provided are forwarded to the server,\n\t * so omitted fields keep their current values.\n\t *\n\t * @param parameters - Identifier plus the fields to update.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async update(\n\t\tparameters: UpdateBadgeParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<undefined, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPDATE_SPEC });\n\t}\n\n\t/**\n\t * Uploads or replaces the source-language icon registered against a\n\t * badge. A subsequent upload for the same badge replaces the\n\t * existing source icon. Does not retry on 5xx so a duplicate icon\n\t * upload cannot be created if the server fails mid-write.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Identifier plus the image bytes to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async uploadIcon(\n\t\tparameters: UploadBadgeIconParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<undefined, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPLOAD_ICON_SPEC });\n\t}\n}\n\nfunction createLocalizationHandle(inner: ResourceClient): BadgeLocalizationHandle {\n\treturn {\n\t\tasync updateNameDescription(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: UPDATE_NAME_DESCRIPTION_SPEC });\n\t\t},\n\t\tasync uploadIcon(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: UPLOAD_LOCALIZED_IC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AAa,OACZ,YACA,SACyC;EACzC,OAAO,KAAKA,OAAO,aAAa;GAAE;GAAS;GAAY,MAAM;EAAY,CAAC;CAC3E;;;;;;;;;;;;CAaA,MAAa,OACZ,YACA,SAC6C;EAC7C,OAAO,KAAKA,OAAO,aAAa;GAAE;GAAS;GAAY,MAAM;EAAY,CAAC;CAC3E;;;;;;;;;;;;;;;CAgBA,MAAa,WACZ,YACA,SAC6C;EAC7C,OAAO,KAAKA,OAAO,aAAa;GAAE;GAAS;GAAY,MAAM;EAAiB,CAAC;CAChF;AACD;AAEA,SAAS,yBAAyB,OAAgD;CACjF,OAAO;EACN,MAAM,sBAAsB,YAAY,SAAS;GAChD,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAA6B,CAAC;EACtF;EACA,MAAM,WAAW,YAAY,SAAS;GACrC,OAAO,MAAM,aAAa;IAAE;IAAS;IAAY,MAAM;GAA2B,CAAC;EACpF;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"badges.mjs","names":["buildUpdateRequest","buildUploadIconRequest","buildUpdateRequest","buildLocaleNameDescRequest","buildLocaleUploadIconRequest"],"sources":["../src/domains/badges/badges/builders.ts","../src/domains/badges/badges/operations.ts","../src/domains/badges/badges/parsers.ts","../src/domains/badges/free-quota/operations.ts","../src/domains/game-internationalization/badge-icon/builders.ts","../src/domains/game-internationalization/badge-name-description/builders.ts","../src/domains/game-internationalization/badge-name-description/operations.ts","../src/domains/publish/badge-icon/builders.ts","../src/domains/publish/badge-icon/operations.ts","../src/domains/publish/badge-icon/parsers.ts","../src/resources/badges/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { BadgePaymentSource, CreateBadgeParameters, UpdateBadgeParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the legacy \"create badge\" endpoint.\n *\n * @param parameters - Fields describing the new badge; optional values\n * omitted here are left off the multipart payload entirely.\n * @returns A pure {@link HttpRequest} describing the create call.\n */\nexport function buildCreateRequest(parameters: CreateBadgeParameters): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"name\", parameters.name);\n\tbody.append(\"files\", toBlob(parameters.icon));\n\tif (parameters.description !== undefined) {\n\t\tbody.append(\"description\", parameters.description);\n\t}\n\n\tif (parameters.isActive !== undefined) {\n\t\tbody.append(\"isActive\", String(parameters.isActive));\n\t}\n\n\tif (parameters.expectedCost !== undefined) {\n\t\tbody.append(\"expectedCost\", String(parameters.expectedCost));\n\t}\n\n\tif (parameters.paymentSource !== undefined) {\n\t\tbody.append(\"paymentSourceType\", toPaymentSourceWire(parameters.paymentSource));\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-badges/v1/universes/${parameters.universeId}/badges`,\n\t};\n}\n\n/**\n * Builds a `PATCH` request for the legacy \"update badge\" endpoint. Every\n * field on `parameters` except the identifier is optional; omitted fields\n * are not appended to the JSON body so the server leaves them unchanged.\n *\n * @param parameters - Identifier plus fields to update.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(parameters: UpdateBadgeParameters): HttpRequest {\n\tconst body: Record<string, boolean | string> = {};\n\tif (parameters.name !== undefined) {\n\t\tbody[\"name\"] = parameters.name;\n\t}\n\n\tif (parameters.description !== undefined) {\n\t\tbody[\"description\"] = parameters.description;\n\t}\n\n\tif (parameters.enabled !== undefined) {\n\t\tbody[\"enabled\"] = parameters.enabled;\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"PATCH\",\n\t\turl: `/legacy-badges/v1/badges/${parameters.badgeId}`,\n\t};\n}\n\nfunction toPaymentSourceWire(source: BadgePaymentSource): \"1\" | \"2\" {\n\treturn source === \"User\" ? \"1\" : \"2\";\n}\n","import { ApiError } from \"../../../errors/api-error.ts\";\nimport { BadgeCostMismatchError } from \"../../../errors/badge-cost-mismatch.ts\";\nimport type { OpenCloudError } from \"../../../errors/base.ts\";\nimport type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/** Body error code Roblox sends when a create's expected cost is wrong. */\nconst COST_MISMATCH_CODE = \"18\";\n\n/**\n * Per-second request ceiling for creating a badge, sourced from\n * `x-roblox-rate-limits` on the legacy badges create operation in the\n * vendored OpenAPI schema (100 per minute, per API key owner).\n */\nexport const CREATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.create\",\n});\n\n/**\n * Per-second request ceiling for updating a badge, sourced from\n * `x-roblox-rate-limits` on the legacy badges update operation in the\n * vendored OpenAPI schema. Keyed independently from\n * {@link CREATE_OPERATION_LIMIT} so create and update do not share a\n * queue, since Roblox does not document the per-minute quota as shared\n * between the POST and PATCH endpoints.\n */\nexport const UPDATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.update\",\n});\n\n/**\n * Scopes the API key or OAuth token must carry to create a badge,\n * sourced from `x-roblox-scopes` on the legacy badges create operation\n * in the vendored OpenAPI schema. The trailing\n * `:manage-and-spend-robux` reflects that badge creation may charge a\n * Robux fee.\n */\nexport const CREATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-universe.badge:manage-and-spend-robux\",\n]);\n\n/**\n * Scopes the API key or OAuth token must carry to update a badge,\n * sourced from `x-roblox-scopes` on the legacy badges update operation\n * in the vendored OpenAPI schema.\n */\nexport const UPDATE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-universe.badge:write\",\n]);\n\n/**\n * Builds the refinement that turns a create refused with body code `18` into\n * a {@link BadgeCostMismatchError}, whatever its status. Every other error\n * passes through unchanged.\n *\n * @param expectedCost - The `expectedCost` the create sent, if any.\n * @returns The refinement for one create call.\n */\nexport function refineCreateError(\n\texpectedCost: number | undefined,\n): (error: OpenCloudError) => OpenCloudError {\n\treturn (error) => {\n\t\tif (!(error instanceof ApiError) || error.code !== COST_MISMATCH_CODE) {\n\t\t\treturn error;\n\t\t}\n\n\t\treturn new BadgeCostMismatchError(error.message, {\n\t\t\tcause: error,\n\t\t\tcode: error.code,\n\t\t\texpectedCost,\n\t\t\tstatusCode: error.statusCode,\n\t\t});\n\t};\n}\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport { isDateTimeString } from \"../../../internal/utils/is-date-time-string.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { Badge, BadgeAwarder, BadgeStatistics } from \"./types.ts\";\nimport type { BadgeAwarderWire, BadgeResponseV2Wire, BadgeStatisticsWire } from \"./wire.ts\";\n\n/**\n * Parses a successful Badges API response into the public `Badge` shape,\n * returning a `Result` so callers can handle malformed payloads without\n * exceptions.\n *\n * @param response - The full {@link HttpResponse} from the Open Cloud API.\n * The status code is included on the returned `UnexpectedResponseError` when\n * validation fails; the headers are available for future parsers that need\n * them.\n * @returns A success result wrapping the converted `Badge`, or an\n * `UnexpectedResponseError` when the body does not match the wire schema.\n */\nexport function parseBadgeResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<Badge, UnexpectedResponseError> {\n\tif (!isBadgeResponseV2Wire(body)) {\n\t\treturn {\n\t\t\terr: new UnexpectedResponseError(\"Malformed badge response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tid: String(body.id),\n\t\t\tname: body.name,\n\t\t\tawarder: copyAwarder(body.awarder),\n\t\t\tcreatedAt: new Date(body.created),\n\t\t\tdescription: body.description,\n\t\t\tdisplayDescription: body.displayDescription,\n\t\t\tdisplayIconImageId:\n\t\t\t\tbody.displayIconImageId === 0 ? undefined : String(body.displayIconImageId),\n\t\t\tdisplayName: body.displayName,\n\t\t\tenabled: body.enabled,\n\t\t\ticonImageId: body.iconImageId === 0 ? undefined : String(body.iconImageId),\n\t\t\tstatistics: copyStatistics(body.statistics),\n\t\t\tupdatedAt: new Date(body.updated),\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction copyAwarder(awarder: BadgeAwarderWire): BadgeAwarder {\n\treturn { id: String(awarder.id), name: awarder.name, type: awarder.type };\n}\n\nfunction copyStatistics(statistics: BadgeStatisticsWire): BadgeStatistics {\n\treturn {\n\t\tawardedCount: statistics.awardedCount,\n\t\tpastDayAwardedCount: statistics.pastDayAwardedCount,\n\t\twinRatePercentage: statistics.winRatePercentage,\n\t};\n}\n\nfunction hasRequiredPrimitiveFields(body: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof body[\"id\"] === \"number\" &&\n\t\ttypeof body[\"name\"] === \"string\" &&\n\t\ttypeof body[\"description\"] === \"string\" &&\n\t\ttypeof body[\"displayName\"] === \"string\" &&\n\t\ttypeof body[\"displayDescription\"] === \"string\" &&\n\t\ttypeof body[\"enabled\"] === \"boolean\" &&\n\t\ttypeof body[\"iconImageId\"] === \"number\" &&\n\t\ttypeof body[\"displayIconImageId\"] === \"number\" &&\n\t\tisDateTimeString(body[\"created\"]) &&\n\t\tisDateTimeString(body[\"updated\"])\n\t);\n}\n\nfunction isBadgeAwarderWire(value: unknown): value is BadgeAwarderWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttypeof value[\"id\"] === \"number\" &&\n\t\t(value[\"name\"] === undefined || typeof value[\"name\"] === \"string\") &&\n\t\tvalue[\"type\"] === \"Place\"\n\t);\n}\n\nfunction isBadgeStatisticsWire(value: unknown): value is BadgeStatisticsWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttypeof value[\"awardedCount\"] === \"number\" &&\n\t\ttypeof value[\"pastDayAwardedCount\"] === \"number\" &&\n\t\ttypeof value[\"winRatePercentage\"] === \"number\"\n\t);\n}\n\nfunction isBadgeResponseV2Wire(body: unknown): body is BadgeResponseV2Wire {\n\tif (!isRecord(body)) {\n\t\treturn false;\n\t}\n\n\tif (!hasRequiredPrimitiveFields(body)) {\n\t\treturn false;\n\t}\n\n\tif (!isBadgeAwarderWire(body[\"awarder\"])) {\n\t\treturn false;\n\t}\n\n\tif (!isBadgeStatisticsWire(body[\"statistics\"])) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","import type { HttpRequest, HttpResponse } from \"../../../client/types.ts\";\nimport type { OpenCloudError } from \"../../../errors/base.ts\";\nimport { RateLimitError } from \"../../../errors/rate-limit.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\nimport { parseQuotaResetSeconds } from \"../../../internal/http/retry-guidance.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { GetFreeBadgeQuotaParameters } from \"./types.ts\";\n\n/** Origin of the unauthenticated free badge quota endpoint. */\nexport const FREE_QUOTA_BASE_URL = \"https://badges.roblox.com\";\n\n/**\n * Per-second request ceiling for reading the free badge quota. Roblox\n * reports 60 requests per 60 seconds, per caller.\n */\nexport const FREE_QUOTA_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 1,\n\toperationKey: \"badges.free-quota\",\n});\n\n/**\n * Builds the `GET` request for the free badge quota of a universe.\n *\n * @param parameters - The universe to read.\n * @returns A pure {@link HttpRequest} describing the read.\n */\nexport function buildFreeQuotaRequest({ universeId }: GetFreeBadgeQuotaParameters): HttpRequest {\n\treturn { method: \"GET\", url: `/v1/universes/${universeId}/free-badges-quota` };\n}\n\n/**\n * Parses the free badge quota body, a bare non-negative integer.\n *\n * @param response - The full {@link HttpResponse}.\n * @returns The free badges left today, or an `UnexpectedResponseError` when\n * the body is not a count.\n */\nexport function parseFreeQuotaResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<number, UnexpectedResponseError> {\n\tif (!isCount(body)) {\n\t\treturn {\n\t\t\terr: new UnexpectedResponseError(\"Malformed free badge quota response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn { data: body, success: true };\n}\n\n/**\n * Points a free badge quota 429 at `x-ratelimit-reset`. The endpoint's\n * `retry-after` is shorter than its window, which reopens only at the reset.\n * Any other error, or a 429 without a reset, passes through unchanged.\n *\n * @param error - The transport error of one attempt.\n * @returns The error with its wait set to the reported reset.\n */\nexport function waitForQuotaReset(error: OpenCloudError): OpenCloudError {\n\tif (!(error instanceof RateLimitError)) {\n\t\treturn error;\n\t}\n\n\tconst resetSeconds = parseQuotaResetSeconds(error.responseHeaders?.[\"x-ratelimit-reset\"]);\n\tif (resetSeconds === undefined) {\n\t\treturn error;\n\t}\n\n\treturn new RateLimitError(error.message, {\n\t\tcause: error.cause,\n\t\tcode: error.code,\n\t\tdetails: error.details,\n\t\tremaining: error.remaining,\n\t\tresponseHeaders: error.responseHeaders,\n\t\tretryAfterSeconds: resetSeconds,\n\t\tsource: error.source,\n\t\tstatusCode: error.statusCode,\n\t});\n}\n\nfunction isCount(value: unknown): value is number {\n\treturn Number.isSafeInteger(value) && Number(value) >= 0;\n}\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { UploadBadgeIconLocalizationParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the localized \"upload badge icon\" endpoint. A\n * successful upload replaces any existing icon for the same\n * `(badgeId, languageCode)` pair.\n *\n * @param parameters - Badge and language identifiers plus the image bytes\n * to upload.\n * @returns A pure {@link HttpRequest} describing the upload call.\n */\nexport function buildUploadIconRequest(\n\tparameters: UploadBadgeIconLocalizationParameters,\n): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"Files\", toBlob(parameters.image));\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-game-internationalization/v1/badges/${parameters.badgeId}/icons/language-codes/${parameters.languageCode}`,\n\t};\n}\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport type { UpdateBadgeNameDescriptionParameters } from \"./types.ts\";\n\n/**\n * Builds a `PATCH` request for the localized \"update badge name/description\"\n * endpoint. Either `name`, `description`, or both may be supplied; omitted\n * fields are not included in the JSON body so the server leaves the existing\n * value for that locale untouched.\n *\n * @param parameters - Badge and language identifiers plus the optional\n * replacement values.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(parameters: UpdateBadgeNameDescriptionParameters): HttpRequest {\n\tconst body: Record<string, string> = {};\n\tif (parameters.name !== undefined) {\n\t\tbody[\"name\"] = parameters.name;\n\t}\n\n\tif (parameters.description !== undefined) {\n\t\tbody[\"description\"] = parameters.description;\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"PATCH\",\n\t\turl: `/legacy-game-internationalization/v1/badges/${parameters.badgeId}/name-description/language-codes/${parameters.languageCode}`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for badge localization Operations, from each\n * operation's `x-roblox-rate-limits.perApiKeyOwner` in the vendored schema\n * (100 requests per minute). This family's key stays separate from other\n * game-internationalization families: the #587 probe measured independent\n * reported 100/minute counters, including on rejected requests. Successful\n * writes may have additional service limits; see\n * `docs/spikes/game-internationalization-rate-limits/README.md`.\n */\nexport const LOCALIZATION_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badge-localization\",\n});\n\n/**\n * Scopes required for every badge localization operation, sourced from\n * `x-roblox-scopes` on the legacy `gameinternationalization` badge\n * endpoints in the vendored OpenAPI schema.\n */\nexport const LOCALIZATION_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-badge:manage\",\n]);\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type { UploadBadgeIconParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the legacy \"upload badge icon\" endpoint. A\n * successful upload replaces any existing source-language icon on the\n * badge.\n *\n * @param parameters - Badge identifier plus the image bytes to upload.\n * @returns A pure {@link HttpRequest} describing the upload call.\n */\nexport function buildUploadIconRequest(parameters: UploadBadgeIconParameters): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"Files\", toBlob(parameters.icon));\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/legacy-publish/v1/badges/${parameters.badgeId}/icon`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for uploading a badge icon, sourced from\n * `x-roblox-rate-limits` on the legacy badge icon upload operation in\n * the vendored OpenAPI schema (100 per minute, per API key owner). Keyed\n * separately from the badges create and update buckets because Roblox\n * does not document the legacy-publish quota as shared with the\n * legacy-badges quota.\n */\nexport const UPLOAD_ICON_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.upload-icon\",\n});\n\n/**\n * Scopes the API key or OAuth token must carry to upload a badge icon,\n * sourced from `x-roblox-scopes` on the legacy badge icon upload\n * operation in the vendored OpenAPI schema.\n */\nexport const UPLOAD_ICON_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-badge:manage\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { UploadedBadgeIcon } from \"./types.ts\";\n\n/**\n * Parses a badge icon upload response, whose `targetId` is the asset ID of\n * the uploaded icon.\n *\n * @param response - The full {@link HttpResponse}.\n * @returns The uploaded icon, or an `UnexpectedResponseError` when the body\n * names no positive integer asset ID.\n */\nexport function parseUploadIconResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<UploadedBadgeIcon, UnexpectedResponseError> {\n\tconst targetId = isRecord(body) ? body[\"targetId\"] : undefined;\n\tif (!isAssetId(targetId)) {\n\t\treturn {\n\t\t\terr: new UnexpectedResponseError(\"Malformed badge icon upload response\", {\n\t\t\t\tdetails: toJsonDetails(body),\n\t\t\t\tstatusCode,\n\t\t\t}),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\treturn { data: { iconImageId: String(targetId) }, success: true };\n}\n\nfunction isAssetId(value: unknown): value is number {\n\treturn Number.isSafeInteger(value) && Number(value) > 0;\n}\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport { buildCreateRequest, buildUpdateRequest } from \"../../domains/badges/badges/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tCREATE_REQUIRED_SCOPES,\n\trefineCreateError,\n\tUPDATE_OPERATION_LIMIT,\n\tUPDATE_REQUIRED_SCOPES,\n} from \"../../domains/badges/badges/operations.ts\";\nimport { parseBadgeResponse } from \"../../domains/badges/badges/parsers.ts\";\nimport type {\n\tBadge,\n\tCreateBadgeParameters,\n\tUpdateBadgeParameters,\n} from \"../../domains/badges/badges/types.ts\";\nimport {\n\tbuildFreeQuotaRequest,\n\tFREE_QUOTA_BASE_URL,\n\tFREE_QUOTA_OPERATION_LIMIT,\n\tparseFreeQuotaResponse,\n\twaitForQuotaReset,\n} from \"../../domains/badges/free-quota/operations.ts\";\nimport type { GetFreeBadgeQuotaParameters } from \"../../domains/badges/free-quota/types.ts\";\nimport { buildUploadIconRequest as buildLocaleUploadIconRequest } from \"../../domains/game-internationalization/badge-icon/builders.ts\";\nimport type { UploadBadgeIconLocalizationParameters } from \"../../domains/game-internationalization/badge-icon/types.ts\";\nimport { buildUpdateRequest as buildLocaleNameDescRequest } from \"../../domains/game-internationalization/badge-name-description/builders.ts\";\nimport {\n\tLOCALIZATION_OPERATION_LIMIT,\n\tLOCALIZATION_REQUIRED_SCOPES,\n} from \"../../domains/game-internationalization/badge-name-description/operations.ts\";\nimport type { UpdateBadgeNameDescriptionParameters } from \"../../domains/game-internationalization/badge-name-description/types.ts\";\nimport { buildUploadIconRequest } from \"../../domains/publish/badge-icon/builders.ts\";\nimport {\n\tUPLOAD_ICON_OPERATION_LIMIT,\n\tUPLOAD_ICON_REQUIRED_SCOPES,\n} from \"../../domains/publish/badge-icon/operations.ts\";\nimport { parseUploadIconResponse } from \"../../domains/publish/badge-icon/parsers.ts\";\nimport type {\n\tUploadBadgeIconParameters,\n\tUploadedBadgeIcon,\n} from \"../../domains/publish/badge-icon/types.ts\";\nimport type { OpenCloudError } from \"../../errors/base.ts\";\nimport { CREATE_METHOD_DEFAULTS, IDEMPOTENT_METHOD_DEFAULTS } from \"../../internal/http/retry.ts\";\nimport {\n\tokRequest,\n\tparseEmptyResponse,\n\tResourceClient,\n\ttype ResourceMethodSpec,\n} from \"../../internal/resource-client.ts\";\nimport type { Result } from \"../../types.ts\";\n\nfunction makeSpec<P, R>(spec: ResourceMethodSpec<P, R>): ResourceMethodSpec<P, R> {\n\treturn Object.freeze(spec);\n}\n\nconst CREATE_SPEC = makeSpec<CreateBadgeParameters, Badge>({\n\tbuildRequest: (parameters) => okRequest(buildCreateRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: CREATE_OPERATION_LIMIT,\n\tparse: parseBadgeResponse,\n\trequiredScopes: CREATE_REQUIRED_SCOPES,\n});\n\nconst UPDATE_SPEC = makeSpec<UpdateBadgeParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildUpdateRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: UPDATE_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: UPDATE_REQUIRED_SCOPES,\n});\n\nconst FREE_QUOTA_SPEC = makeSpec<GetFreeBadgeQuotaParameters, number>({\n\tbuildRequest: (parameters) => okRequest(buildFreeQuotaRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: FREE_QUOTA_OPERATION_LIMIT,\n\tparse: parseFreeQuotaResponse,\n\tunauthenticatedBaseUrl: FREE_QUOTA_BASE_URL,\n});\n\nconst UPLOAD_ICON_SPEC = makeSpec<UploadBadgeIconParameters, UploadedBadgeIcon>({\n\tbuildRequest: (parameters) => okRequest(buildUploadIconRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: UPLOAD_ICON_OPERATION_LIMIT,\n\tparse: parseUploadIconResponse,\n\trequiredScopes: UPLOAD_ICON_REQUIRED_SCOPES,\n});\n\nconst UPDATE_NAME_DESCRIPTION_SPEC = makeSpec<UpdateBadgeNameDescriptionParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildLocaleNameDescRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: LOCALIZATION_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: LOCALIZATION_REQUIRED_SCOPES,\n});\n\nconst UPLOAD_LOCALIZED_ICON_SPEC = makeSpec<UploadBadgeIconLocalizationParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildLocaleUploadIconRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: LOCALIZATION_OPERATION_LIMIT,\n\tparse: parseEmptyResponse,\n\trequiredScopes: LOCALIZATION_REQUIRED_SCOPES,\n});\n\ninterface BadgeLocalizationHandle {\n\t/**\n\t * Updates the per-locale display name and/or description registered against\n\t * a badge. Either `name`, `description`, or both may be supplied; omitted\n\t * fields are not forwarded so the server leaves the existing value for\n\t * that locale untouched. Mirrors the upstream `200 OK` echo body as\n\t * `undefined` data.\n\t *\n\t * @param parameters - Badge and language identifiers plus the optional\n\t * replacement values.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tupdateNameDescription: (\n\t\tparameters: UpdateBadgeNameDescriptionParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n\t/**\n\t * Uploads or replaces the per-locale icon for a badge. A subsequent\n\t * upload for the same `(badgeId, languageCode)` pair replaces the\n\t * existing icon for that locale. Does not retry on 5xx so a duplicate\n\t * upload cannot be created if the server fails mid-write. Source-language\n\t * icons remain on {@link BadgesClient.uploadIcon}.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Badge and language identifiers plus the image bytes\n\t * to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tuploadIcon: (\n\t\tparameters: UploadBadgeIconLocalizationParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n}\n\n/**\n * Public client for the Roblox Open Cloud Badges API. Covers programmatic\n * badge creation under a universe, partial updates of badge configuration\n * (`name`, `description`, `enabled`), and source-language icon uploads.\n *\n * Wires the request builders, the injected\n * {@link OpenCloudClientOptions.httpClient}, and response parsers into a\n * single ergonomic surface. Every method returns a {@link Result} so\n * callers handle failure explicitly; no thrown {@link OpenCloudError}\n * ever escapes the client.\n *\n * @since 0.1.0\n *\n * @example\n *\n * ```ts\n * import { BadgesClient } from \"@bedrock-rbx/ocale/badges\";\n *\n * const client = new BadgesClient({ credential: { apiKey: \"your-key\", kind: \"apiKey\" } });\n * expect(client).toBeInstanceOf(BadgesClient);\n * ```\n */\nexport class BadgesClient {\n\treadonly #inner: ResourceClient;\n\n\t/**\n\t * Operation Group exposing per-locale localization Operations\n\t * (`updateNameDescription`, `uploadIcon`) backed by the\n\t * `legacy-game-internationalization` domain. Source-language values\n\t * remain on {@link BadgesClient.update} and\n\t * {@link BadgesClient.uploadIcon}; methods on this group set per-locale\n\t * overlays on top. Shares the parent client's HTTP, rate-limit, and\n\t * retry plumbing.\n\t */\n\tpublic readonly localization: BadgeLocalizationHandle;\n\n\t/**\n\t * Creates a new {@link BadgesClient}. Configuration is frozen on\n\t * construction; per-request overrides are accepted on each method.\n\t *\n\t * @param options - Client-level configuration including the API key.\n\t */\n\tconstructor(options: OpenCloudClientOptions) {\n\t\tthis.#inner = new ResourceClient(options);\n\t\tthis.localization = createLocalizationHandle(this.#inner);\n\t}\n\n\t/**\n\t * Creates a new badge under the supplied universe.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * A create whose `expectedCost` differs from the actual cost fails with a\n\t * `BadgeCostMismatchError` and is not charged; with `expectedCost: 0`\n\t * that means the universe's free badge quota is spent for today.\n\t *\n\t * @param parameters - Creation fields including the universe, name, and\n\t * icon image.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed {@link Badge} or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async create(\n\t\tparameters: CreateBadgeParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<Badge, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({\n\t\t\toptions,\n\t\t\tparameters,\n\t\t\trefineError: refineCreateError(parameters.expectedCost),\n\t\t\tspec: CREATE_SPEC,\n\t\t});\n\t}\n\n\t/**\n\t * Reads how many badges the universe can still create free of charge\n\t * today. Each create within the quota lowers it by one. The quota resets\n\t * daily at 00:00 UTC. Roblox answers for any universe ID, existing or not.\n\t *\n\t * The read is unauthenticated: it sends no credential and is served from\n\t * `https://badges.roblox.com`, so the client `baseUrl` does not apply.\n\t * Roblox allows 60 reads per minute per caller. A 429 waits until the\n\t * reported `x-ratelimit-reset` before it retries.\n\t *\n\t * @since 0.4.0\n\t * @param parameters - The universe to read.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the free badges left today, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async getFreeQuota(\n\t\tparameters: GetFreeBadgeQuotaParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<number, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({\n\t\t\toptions,\n\t\t\tparameters,\n\t\t\trefineError: waitForQuotaReset,\n\t\t\tspec: FREE_QUOTA_SPEC,\n\t\t});\n\t}\n\n\t/**\n\t * Partially updates a badge's configuration. Mirrors the upstream\n\t * `200 OK` empty response: a successful update yields `undefined`\n\t * data. Only fields explicitly provided are forwarded to the server,\n\t * so omitted fields keep their current values.\n\t *\n\t * @param parameters - Identifier plus the fields to update.\n\t * @param options - Optional per-request overrides.\n\t * @returns A success {@link Result} with no payload, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async update(\n\t\tparameters: UpdateBadgeParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<undefined, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPDATE_SPEC });\n\t}\n\n\t/**\n\t * Uploads or replaces the source-language icon registered against a\n\t * badge. A subsequent upload for the same badge replaces the\n\t * existing source icon. Does not retry on 5xx so a duplicate icon\n\t * upload cannot be created if the server fails mid-write.\n\t *\n\t * No default request timeout applies to this upload; pass `options.timeout`\n\t * to set a per-call deadline.\n\t *\n\t * @param parameters - Identifier plus the image bytes to upload.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the uploaded icon's asset ID, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async uploadIcon(\n\t\tparameters: UploadBadgeIconParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<UploadedBadgeIcon, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: UPLOAD_ICON_SPEC });\n\t}\n}\n\nfunction createLocalizationHandle(inner: ResourceClient): BadgeLocalizationHandle {\n\treturn {\n\t\tasync updateNameDescription(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: UPDATE_NAME_DESCRIPTION_SPEC });\n\t\t},\n\t\tasync uploadIcon(parameters, options) {\n\t\t\treturn inner.executeAsync({ options, parameters, spec: UPLOAD_LOCALIZED_ICON_SPEC });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,mBAAmB,YAAgD;CAClF,MAAM,OAAO,IAAI,SAAS;CAC1B,KAAK,OAAO,QAAQ,WAAW,IAAI;CACnC,KAAK,OAAO,SAAS,OAAO,WAAW,IAAI,CAAC;CAC5C,IAAI,WAAW,gBAAgB,KAAA,GAC9B,KAAK,OAAO,eAAe,WAAW,WAAW;CAGlD,IAAI,WAAW,aAAa,KAAA,GAC3B,KAAK,OAAO,YAAY,OAAO,WAAW,QAAQ,CAAC;CAGpD,IAAI,WAAW,iBAAiB,KAAA,GAC/B,KAAK,OAAO,gBAAgB,OAAO,WAAW,YAAY,CAAC;CAG5D,IAAI,WAAW,kBAAkB,KAAA,GAChC,KAAK,OAAO,qBAAqB,oBAAoB,WAAW,aAAa,CAAC;CAG/E,OAAO;EACN;EACA,QAAQ;EACR,KAAK,+BAA+B,WAAW,WAAW;CAC3D;AACD;;;;;;;;;AAUA,SAAgBA,qBAAmB,YAAgD;CAClF,MAAM,OAAyC,CAAC;CAChD,IAAI,WAAW,SAAS,KAAA,GACvB,KAAK,UAAU,WAAW;CAG3B,IAAI,WAAW,gBAAgB,KAAA,GAC9B,KAAK,iBAAiB,WAAW;CAGlC,IAAI,WAAW,YAAY,KAAA,GAC1B,KAAK,aAAa,WAAW;CAG9B,OAAO;EACN;EACA,QAAQ;EACR,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