@bedrock-rbx/ocale 0.3.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +10 -5
  2. package/dist/assets.d.mts +64 -0
  3. package/dist/assets.d.mts.map +1 -0
  4. package/dist/assets.mjs +301 -0
  5. package/dist/assets.mjs.map +1 -0
  6. package/dist/badge-insufficient-funds-BLFvQZt1.mjs +91 -0
  7. package/dist/badge-insufficient-funds-BLFvQZt1.mjs.map +1 -0
  8. package/dist/badges.d.mts +359 -196
  9. package/dist/badges.d.mts.map +1 -1
  10. package/dist/badges.mjs +493 -59
  11. package/dist/badges.mjs.map +1 -1
  12. package/dist/capacity-admission-Ce2V9QNb.d.mts +347 -0
  13. package/dist/capacity-admission-Ce2V9QNb.d.mts.map +1 -0
  14. package/dist/{data.generated-B2ceLfSn.d.mts → data.generated-B4Fztv_7.d.mts} +23 -25
  15. package/dist/data.generated-B4Fztv_7.d.mts.map +1 -0
  16. package/dist/developer-products.d.mts +207 -194
  17. package/dist/developer-products.d.mts.map +1 -1
  18. package/dist/developer-products.mjs +125 -39
  19. package/dist/developer-products.mjs.map +1 -1
  20. package/dist/game-passes.d.mts +206 -211
  21. package/dist/game-passes.d.mts.map +1 -1
  22. package/dist/game-passes.mjs +35 -36
  23. package/dist/game-passes.mjs.map +1 -1
  24. package/dist/index.d.mts +947 -366
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +324 -12
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/is-date-time-string-C91G44SI.mjs +19 -0
  29. package/dist/is-date-time-string-C91G44SI.mjs.map +1 -0
  30. package/dist/locales.d.mts +28 -2
  31. package/dist/locales.d.mts.map +1 -0
  32. package/dist/locales.mjs +24 -3
  33. package/dist/locales.mjs.map +1 -1
  34. package/dist/luau-execution.d.mts +154 -157
  35. package/dist/luau-execution.d.mts.map +1 -1
  36. package/dist/luau-execution.mjs +15 -16
  37. package/dist/luau-execution.mjs.map +1 -1
  38. package/dist/{network-error-DR9FX5hb.mjs → network-error-P4An7nUB.mjs} +48 -14
  39. package/dist/network-error-P4An7nUB.mjs.map +1 -0
  40. package/dist/places.d.mts +258 -186
  41. package/dist/places.d.mts.map +1 -1
  42. package/dist/places.mjs +187 -35
  43. package/dist/places.mjs.map +1 -1
  44. package/dist/{poll-timeout-3PXLsabj.mjs → poll-timeout-BCxgN97O.mjs} +4 -6
  45. package/dist/{poll-timeout-3PXLsabj.mjs.map → poll-timeout-BCxgN97O.mjs.map} +1 -1
  46. package/dist/{polling-helpers-CoVhsC33.mjs → polling-helpers-BtEYR5dN.mjs} +260 -105
  47. package/dist/polling-helpers-BtEYR5dN.mjs.map +1 -0
  48. package/dist/{price-information-B0tkOoAX.mjs → price-information--d6GZAcp.mjs} +3 -4
  49. package/dist/{price-information-B0tkOoAX.mjs.map → price-information--d6GZAcp.mjs.map} +1 -1
  50. package/dist/resource-client-CF8SPsV8.d.mts +162 -0
  51. package/dist/resource-client-CF8SPsV8.d.mts.map +1 -0
  52. package/dist/{resource-client-rqTMkBeR.mjs → resource-client-Cm_bPcCs.mjs} +589 -197
  53. package/dist/resource-client-Cm_bPcCs.mjs.map +1 -0
  54. package/dist/retry-DYxm_eBU.d.mts +225 -0
  55. package/dist/retry-DYxm_eBU.d.mts.map +1 -0
  56. package/dist/{retry-BlX4tUnT.mjs → retry-Dv5TsY9O.mjs} +312 -54
  57. package/dist/retry-Dv5TsY9O.mjs.map +1 -0
  58. package/dist/{signatures-JF-7Psce.mjs → signatures-CtJ7jfVN.mjs} +2 -3
  59. package/dist/{signatures-JF-7Psce.mjs.map → signatures-CtJ7jfVN.mjs.map} +1 -1
  60. package/dist/storage.d.mts +333 -344
  61. package/dist/storage.d.mts.map +1 -1
  62. package/dist/storage.mjs +39 -40
  63. package/dist/storage.mjs.map +1 -1
  64. package/dist/testing.d.mts +369 -434
  65. package/dist/testing.d.mts.map +1 -1
  66. package/dist/testing.mjs +18 -33
  67. package/dist/testing.mjs.map +1 -1
  68. package/dist/{to-blob-RPqMBuft.mjs → to-blob-Bqu7bmlE.mjs} +2 -3
  69. package/dist/{to-blob-RPqMBuft.mjs.map → to-blob-Bqu7bmlE.mjs.map} +1 -1
  70. package/dist/types-Z4abDJfK.d.mts +501 -0
  71. package/dist/types-Z4abDJfK.d.mts.map +1 -0
  72. package/dist/universes.d.mts +619 -436
  73. package/dist/universes.d.mts.map +1 -1
  74. package/dist/universes.mjs +432 -79
  75. package/dist/universes.mjs.map +1 -1
  76. package/dist/{validation-B_Zs1So2.mjs → validation-kaTLLAD1.mjs} +3 -4
  77. package/dist/{validation-B_Zs1So2.mjs.map → validation-kaTLLAD1.mjs.map} +1 -1
  78. package/dist/wire-DDG87I-d.d.mts +39 -0
  79. package/dist/wire-DDG87I-d.d.mts.map +1 -0
  80. package/package.json +15 -14
  81. package/dist/capacity-admission-IDO3fcUC.d.mts +0 -369
  82. package/dist/capacity-admission-IDO3fcUC.d.mts.map +0 -1
  83. package/dist/data.generated-B2ceLfSn.d.mts.map +0 -1
  84. package/dist/network-error-DR9FX5hb.mjs.map +0 -1
  85. package/dist/polling-helpers-CoVhsC33.mjs.map +0 -1
  86. package/dist/resource-client-B6NeFXUv.d.mts +0 -164
  87. package/dist/resource-client-B6NeFXUv.d.mts.map +0 -1
  88. package/dist/resource-client-rqTMkBeR.mjs.map +0 -1
  89. package/dist/retry-BlX4tUnT.mjs.map +0 -1
  90. package/dist/retry-war_-9tb.d.mts +0 -373
  91. package/dist/retry-war_-9tb.d.mts.map +0 -1
  92. package/dist/types-CvYh4SPC.d.mts +0 -386
  93. package/dist/types-CvYh4SPC.d.mts.map +0 -1
  94. package/dist/wire-D3K-a-UP.d.mts +0 -37
  95. package/dist/wire-D3K-a-UP.d.mts.map +0 -1
@@ -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_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,KA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A,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/free-quota/operations.ts","../src/domains/badges/badges/operations.ts","../src/domains/badges/badges/parsers.ts","../src/domains/badges/metadata/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 {\n\tBadgePaymentSource,\n\tCreateBadgeParameters,\n\tGetBadgeParameters,\n\tListBadgesParameters,\n\tUpdateBadgeParameters,\n} 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\tif (parameters.icon !== undefined) {\n\t\t// Roblox answers 500 InternalServerError when the file part has no name.\n\t\tbody.append(\"files\", toBlob(parameters.icon), \"icon\");\n\t}\n\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\n/**\n * Builds a `GET` request for the unauthenticated \"get badge\" endpoint.\n *\n * @param parameters - The badge to read.\n * @returns A pure {@link HttpRequest} describing the read.\n */\nexport function buildGetRequest({ badgeId }: GetBadgeParameters): HttpRequest {\n\treturn { method: \"GET\", url: `/v1/badges/${badgeId}` };\n}\n\n/**\n * Builds a `GET` request for the unauthenticated \"list universe badges\"\n * endpoint. `pageSize` goes out as `limit` and `pageToken` as `cursor`, each\n * only when defined, so the server applies its own defaults otherwise.\n *\n * @param parameters - Universe identifier plus optional paging fields.\n * @returns A pure {@link HttpRequest} describing the list call.\n */\nexport function buildListRequest(parameters: ListBadgesParameters): HttpRequest {\n\tconst query = new URLSearchParams();\n\tif (parameters.pageSize !== undefined) {\n\t\tquery.append(\"limit\", String(parameters.pageSize));\n\t}\n\n\tif (parameters.pageToken !== undefined) {\n\t\tquery.append(\"cursor\", parameters.pageToken);\n\t}\n\n\tconst queryString = query.toString();\n\tconst base = `/v1/universes/${parameters.universeId}/badges`;\n\treturn { method: \"GET\", url: queryString === \"\" ? base : `${base}?${queryString}` };\n}\n\nfunction toPaymentSourceWire(source: BadgePaymentSource): \"1\" | \"2\" {\n\treturn source === \"User\" ? \"1\" : \"2\";\n}\n","import type { HttpRequest, HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport type { OperationLimit } from \"../../../internal/http/rate-limit-queue.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\nfunction isCount(value: unknown): value is number {\n\treturn Number.isSafeInteger(value) && Number(value) >= 0;\n}\n","import { ApiError } from \"../../../errors/api-error.ts\";\nimport { BadgeCostMismatchError } from \"../../../errors/badge-cost-mismatch.ts\";\nimport { BadgeGroupSpendPermissionError } from \"../../../errors/badge-group-spend-permission.ts\";\nimport { BadgeInsufficientFundsError } from \"../../../errors/badge-insufficient-funds.ts\";\nimport type { OpenCloudError } from \"../../../errors/base.ts\";\nimport type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\nimport { FREE_QUOTA_BASE_URL } from \"../free-quota/operations.ts\";\n\n/** Body error code Roblox sends when a create's expected cost is wrong. */\nconst COST_MISMATCH_CODE = \"18\";\n\n/** Body error code Roblox sends when the payer cannot afford a create. */\nconst INSUFFICIENT_FUNDS_CODE = \"17\";\n\n/** Body error code Roblox sends when the caller may not spend group funds. */\nconst GROUP_SPEND_PERMISSION_CODE = \"28\";\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 * Origin of the unauthenticated badge read endpoints, shared with the free\n * quota read.\n */\nexport const READ_BASE_URL = FREE_QUOTA_BASE_URL;\n\n/**\n * Per-second request ceiling for reading one badge. Roblox reports 600\n * requests per 60 seconds, per caller.\n */\nexport const GET_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 600 / 60,\n\toperationKey: \"badges.get\",\n});\n\n/**\n * Per-second request ceiling for listing the badges of a universe. Roblox\n * reports 100 requests per 60 seconds, per caller.\n */\nexport const LIST_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.list\",\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 for a cost or payment\n * reason into a typed error, whatever its status: body code `18` becomes a\n * {@link BadgeCostMismatchError}, code `17` a\n * {@link BadgeInsufficientFundsError}, and code `28` a\n * {@link BadgeGroupSpendPermissionError}. Every other error passes through\n * 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)) {\n\t\t\treturn error;\n\t\t}\n\n\t\tconst options = { cause: error, code: error.code, statusCode: error.statusCode };\n\t\tif (error.code === COST_MISMATCH_CODE) {\n\t\t\treturn new BadgeCostMismatchError(error.message, { ...options, expectedCost });\n\t\t}\n\n\t\tif (error.code === INSUFFICIENT_FUNDS_CODE) {\n\t\t\treturn new BadgeInsufficientFundsError(error.message, options);\n\t\t}\n\n\t\tif (error.code === GROUP_SPEND_PERMISSION_CODE) {\n\t\t\treturn new BadgeGroupSpendPermissionError(error.message, options);\n\t\t}\n\n\t\treturn error;\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 { Page, Result } from \"../../../types.ts\";\nimport type {\n\tBadge,\n\tBadgeAwarder,\n\tBadgeAwardingUniverse,\n\tBadgeDetails,\n\tBadgeStatistics,\n} from \"./types.ts\";\nimport type {\n\tBadgeAwarderWire,\n\tBadgeAwardingUniverseWire,\n\tBadgeResponseV2Wire,\n\tBadgeResponseWire,\n\tBadgeStatisticsWire,\n} 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 malformedBadge(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: { ...copySharedFields(body), awarder: copyAwarder(body.awarder) },\n\t\tsuccess: true,\n\t};\n}\n\n/**\n * Parses the body of the unauthenticated badge read endpoints into the public\n * `BadgeDetails` shape.\n *\n * @param response - The full {@link HttpResponse}.\n * @returns A success result wrapping the converted `BadgeDetails`, or an\n * `UnexpectedResponseError` when the body does not match the wire schema.\n */\nexport function parseBadgeDetailsResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<BadgeDetails, UnexpectedResponseError> {\n\tif (!isBadgeResponseWire(body)) {\n\t\treturn malformedBadge(statusCode, body);\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\t...copySharedFields(body),\n\t\t\tawardingUniverse: copyAwardingUniverse(body.awardingUniverse),\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\n/**\n * Parses a badge list page, keeping its cursor and converting each item with\n * the same validation as a single badge read. A JSON `null` cursor becomes\n * `undefined`.\n *\n * @param response - The HTTP response to parse.\n * @returns The parsed page or an unexpected response error.\n */\nexport function parseBadgesListResponse(\n\tresponse: HttpResponse,\n): Result<Page<BadgeDetails>, UnexpectedResponseError> {\n\tconst { body, status: statusCode } = response;\n\tif (!isRecord(body) || !Array.isArray(body[\"data\"])) {\n\t\treturn malformedBadgesList(statusCode, body);\n\t}\n\n\tconst nextPageToken = body[\"nextPageCursor\"] ?? undefined;\n\tif (nextPageToken !== undefined && typeof nextPageToken !== \"string\") {\n\t\treturn malformedBadgesList(statusCode, body);\n\t}\n\n\tconst items: Array<BadgeDetails> = [];\n\tconst badges = body[\"data\"];\n\tfor (const item of badges) {\n\t\tconst parsed = parseBadgeDetailsResponse({ ...response, body: item });\n\t\tif (!parsed.success) {\n\t\t\treturn malformedBadgesList(statusCode, body);\n\t\t}\n\n\t\titems.push(parsed.data);\n\t}\n\n\treturn { data: { items, nextPageToken }, success: true };\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 copySharedFields(\n\tbody: BadgeResponseV2Wire | BadgeResponseWire,\n): Pick<Badge, Exclude<keyof Badge, \"awarder\">> {\n\treturn {\n\t\tid: String(body.id),\n\t\tname: body.name,\n\t\tcreatedAt: new Date(body.created),\n\t\tdescription: body.description,\n\t\tdisplayDescription: body.displayDescription,\n\t\tdisplayIconImageId:\n\t\t\tbody.displayIconImageId === 0 ? undefined : String(body.displayIconImageId),\n\t\tdisplayName: body.displayName,\n\t\tenabled: body.enabled,\n\t\ticonImageId: body.iconImageId === 0 ? undefined : String(body.iconImageId),\n\t\tstatistics: copyStatistics(body.statistics),\n\t\tupdatedAt: new Date(body.updated),\n\t};\n}\n\nfunction copyAwarder(awarder: BadgeAwarderWire): BadgeAwarder {\n\treturn { id: String(awarder.id), name: awarder.name, type: awarder.type };\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\nfunction malformedBadge(\n\tstatusCode: number,\n\tbody: unknown,\n): { readonly err: UnexpectedResponseError; readonly success: false } {\n\treturn {\n\t\terr: new UnexpectedResponseError(\"Malformed badge response\", {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n\nfunction copyAwardingUniverse(universe: BadgeAwardingUniverseWire): BadgeAwardingUniverse {\n\treturn {\n\t\tid: String(universe.id),\n\t\tname: universe.name,\n\t\trootPlaceId: String(universe.rootPlaceId),\n\t};\n}\n\nfunction isBadgeAwardingUniverseWire(value: unknown): value is BadgeAwardingUniverseWire {\n\tif (!isRecord(value)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttypeof value[\"id\"] === \"number\" &&\n\t\ttypeof value[\"name\"] === \"string\" &&\n\t\ttypeof value[\"rootPlaceId\"] === \"number\"\n\t);\n}\n\nfunction isBadgeResponseWire(body: unknown): body is BadgeResponseWire {\n\treturn (\n\t\tisRecord(body) &&\n\t\thasRequiredPrimitiveFields(body) &&\n\t\tisBadgeStatisticsWire(body[\"statistics\"]) &&\n\t\tisBadgeAwardingUniverseWire(body[\"awardingUniverse\"])\n\t);\n}\n\nfunction malformedBadgesList(\n\tstatusCode: number,\n\tbody: unknown,\n): Result<Page<BadgeDetails>, UnexpectedResponseError> {\n\treturn {\n\t\terr: new UnexpectedResponseError(\"Malformed badges list response\", {\n\t\t\tdetails: toJsonDetails(body),\n\t\t\tstatusCode,\n\t\t}),\n\t\tsuccess: false,\n\t};\n}\n","import type { HttpRequest, HttpResponse } from \"../../../client/types.ts\";\nimport { UnexpectedResponseError } from \"../../../errors/unexpected-response.ts\";\nimport type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport { toJsonDetails } from \"../../../internal/utils/to-json-details.ts\";\nimport type { Result } from \"../../../types.ts\";\n\n/** Origin of the unauthenticated badge metadata endpoint. */\nexport const METADATA_BASE_URL = \"https://badges.roblox.com\";\n\n/**\n * Per-second request ceiling for reading the badge metadata. The vendored\n * spec declares no limit; Roblox reports 100 requests per 60 seconds, per\n * caller.\n */\nexport const METADATA_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"badges.metadata\",\n});\n\n/**\n * Builds the `GET` request for the badge metadata.\n *\n * @returns A pure {@link HttpRequest} describing the read.\n */\nexport function buildMetadataRequest(): HttpRequest {\n\treturn { method: \"GET\", url: \"/v1/badges/metadata\" };\n}\n\n/**\n * Parses the badge metadata body down to its `badgeCreationPrice`.\n *\n * @param response - The full {@link HttpResponse}.\n * @returns The badge creation price in Robux, or an\n * `UnexpectedResponseError` when the body carries no valid price.\n */\nexport function parseCreationPriceResponse({\n\tbody,\n\tstatus: statusCode,\n}: HttpResponse): Result<number, UnexpectedResponseError> {\n\tconst price = isRecord(body) ? body[\"badgeCreationPrice\"] : undefined;\n\tif (!isPrice(price)) {\n\t\treturn {\n\t\t\terr: new UnexpectedResponseError(\"Malformed badge metadata 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: price, success: true };\n}\n\nfunction isPrice(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\t// Roblox answers 400 \"File not present in request.\" when the file part has\n\t// no name.\n\tbody.append(\"Files\", toBlob(parameters.icon), \"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 {\n\tbuildCreateRequest,\n\tbuildGetRequest,\n\tbuildListRequest,\n\tbuildUpdateRequest,\n} from \"../../domains/badges/badges/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tCREATE_REQUIRED_SCOPES,\n\tGET_OPERATION_LIMIT,\n\tLIST_OPERATION_LIMIT,\n\tREAD_BASE_URL,\n\trefineCreateError,\n\tUPDATE_OPERATION_LIMIT,\n\tUPDATE_REQUIRED_SCOPES,\n} from \"../../domains/badges/badges/operations.ts\";\nimport {\n\tparseBadgeDetailsResponse,\n\tparseBadgeResponse,\n\tparseBadgesListResponse,\n} from \"../../domains/badges/badges/parsers.ts\";\nimport type {\n\tBadge,\n\tBadgeDetails,\n\tCreateBadgeParameters,\n\tGetBadgeParameters,\n\tListBadgesParameters,\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} from \"../../domains/badges/free-quota/operations.ts\";\nimport type { GetFreeBadgeQuotaParameters } from \"../../domains/badges/free-quota/types.ts\";\nimport {\n\tbuildMetadataRequest,\n\tMETADATA_BASE_URL,\n\tMETADATA_OPERATION_LIMIT,\n\tparseCreationPriceResponse,\n} from \"../../domains/badges/metadata/operations.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 { waitForQuotaReset } from \"../../internal/http/retry-guidance.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 { Page, 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 GET_SPEC = makeSpec<GetBadgeParameters, BadgeDetails>({\n\tbuildRequest: (parameters) => okRequest(buildGetRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: GET_OPERATION_LIMIT,\n\tparse: parseBadgeDetailsResponse,\n\tunauthenticatedBaseUrl: READ_BASE_URL,\n});\n\nconst LIST_SPEC = makeSpec<ListBadgesParameters, Page<BadgeDetails>>({\n\tbuildRequest: (parameters) => okRequest(buildListRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: LIST_OPERATION_LIMIT,\n\tparse: parseBadgesListResponse,\n\tunauthenticatedBaseUrl: READ_BASE_URL,\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 CREATION_PRICE_SPEC = makeSpec<undefined, number>({\n\tbuildRequest: () => okRequest(buildMetadataRequest()),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: METADATA_OPERATION_LIMIT,\n\tparse: parseCreationPriceResponse,\n\tunauthenticatedBaseUrl: METADATA_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 one badge, enabled or disabled. A disabled badge comes back with\n\t * `enabled: false`; {@link BadgesClient.list} does not return it.\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 600 reads per minute per caller.\n\t *\n\t * @since 0.5.0\n\t * @param parameters - The badge to read.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed {@link BadgeDetails}, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async get(\n\t\tparameters: GetBadgeParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<BadgeDetails, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: GET_SPEC });\n\t}\n\n\t/**\n\t * Reads the list price in Robux of one badge create beyond the free\n\t * quota. The price is the same for every universe; it is not the cost\n\t * of the next create, which is free while\n\t * {@link BadgesClient.getFreeQuota} is above zero. Pass the price as\n\t * `expectedCost` on {@link BadgesClient.create} to pay for a create.\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 100 reads per minute per caller.\n\t *\n\t * @since 0.5.0\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the badge creation price in Robux,\n\t * or the {@link OpenCloudError} that caused the request to fail.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * import { BadgesClient } from \"@bedrock-rbx/ocale/badges\";\n\t *\n\t * const client = new BadgesClient({\n\t * \tcredential: { kind: \"none\" },\n\t * \thttpClient: {\n\t * \t\trequest: async () => ({\n\t * \t\t\tdata: { body: { badgeCreationPrice: 100 }, headers: {}, status: 200 },\n\t * \t\t\tsuccess: true,\n\t * \t\t}),\n\t * \t},\n\t * });\n\t *\n\t * return client.getCreationPrice().then((price) => {\n\t * \texpect(price).toStrictEqual({ data: 100, success: true });\n\t * });\n\t * ```\n\t */\n\tpublic async getCreationPrice(\n\t\toptions?: RequestOptions,\n\t): Promise<Result<number, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({\n\t\t\toptions,\n\t\t\tparameters: undefined,\n\t\t\tspec: CREATION_PRICE_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 * Lists one page of a universe's enabled badges. Omit\n\t * `pageToken` for the first page, then pass the returned `nextPageToken`\n\t * until it is undefined.\n\t *\n\t * This list hides disabled badges. A badge leaves the list as soon as\n\t * it is disabled, but {@link BadgesClient.get} still returns it, with\n\t * `enabled: false`. Use {@link BadgesClient.get} to see a disabled badge,\n\t * for example a tracked badge that someone disabled. A page can hold\n\t * fewer items than `pageSize` and still have a next page, so page until\n\t * `nextPageToken` is undefined.\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 100 pages per minute per caller.\n\t *\n\t * @since 0.5.0\n\t * @param parameters - Universe ID and optional paging fields.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the badge page, or the\n\t * {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async list(\n\t\tparameters: ListBadgesParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<Page<BadgeDetails>, OpenCloudError>> {\n\t\treturn this.#inner.executeAsync({ options, parameters, spec: LIST_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 {@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":";;;;;;;;;;;;;;AAiBA,SAAgB,mBAAmB,YAAgD;CAClF,MAAM,OAAO,IAAI,SAAS;CAC1B,KAAK,OAAO,QAAQ,WAAW,IAAI;CACnC,IAAI,WAAW,SAAS,KAAA,GAEvB,KAAK,OAAO,SAAS,OAAO,WAAW,IAAI,GAAG,MAAM;CAGrD,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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M,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"}
@@ -0,0 +1,347 @@
1
+ import { d as RequestOptions } from "./types-Z4abDJfK.mjs";
2
+ /**
3
+ * Caller-supplied input for submitting a Luau Execution task against a
4
+ * place's head version. Submitting against a specific place version uses
5
+ * {@link SubmitAtVersionParameters} instead.
6
+ *
7
+ * @since 0.1.0
8
+ */
9
+ interface SubmitAtHeadParameters {
10
+ /**
11
+ * Resource path returned by `binaryInputs.create`, passed to the
12
+ * server to attach a pre-uploaded binary to this task.
13
+ */
14
+ readonly binaryInput?: string | undefined;
15
+ /** When `true`, the server places the task output into a binary blob. */
16
+ readonly enableBinaryOutput?: boolean | undefined;
17
+ /** Stringified ID of the place to run the script against. */
18
+ readonly placeId: string;
19
+ /** Luau source to execute. */
20
+ readonly script: string;
21
+ /**
22
+ * Wall-clock limit in seconds. The task fails when the script does not
23
+ * complete within this duration. Server default is 5 minutes.
24
+ */
25
+ readonly timeoutSeconds?: number;
26
+ /** Stringified ID of the universe that owns the place. */
27
+ readonly universeId: string;
28
+ }
29
+ /**
30
+ * Caller-supplied input for submitting a Luau Execution task against a
31
+ * specific place version. Submitting against the head version uses
32
+ * {@link SubmitAtHeadParameters} instead.
33
+ *
34
+ * @since 0.1.0
35
+ */
36
+ interface SubmitAtVersionParameters {
37
+ /**
38
+ * Resource path returned by `binaryInputs.create`, passed to the
39
+ * server to attach a pre-uploaded binary to this task.
40
+ */
41
+ readonly binaryInput?: string | undefined;
42
+ /** When `true`, the server places the task output into a binary blob. */
43
+ readonly enableBinaryOutput?: boolean | undefined;
44
+ /** Stringified ID of the place to run the script against. */
45
+ readonly placeId: string;
46
+ /** Luau source to execute. */
47
+ readonly script: string;
48
+ /**
49
+ * Wall-clock limit in seconds. The task fails when the script does not
50
+ * complete within this duration. Server default is 5 minutes.
51
+ */
52
+ readonly timeoutSeconds?: number;
53
+ /** Stringified ID of the universe that owns the place. */
54
+ readonly universeId: string;
55
+ /** Stringified ID of the place version the script targets. */
56
+ readonly versionId: string;
57
+ }
58
+ /**
59
+ * Five-field reference to a Luau Execution session task. The parser
60
+ * extracts this from any of the four x-aep-resource `path` formats
61
+ * returned by the server, and the get builder consumes it to construct
62
+ * the maximal GET URL. `versionId` and `sessionId` are `undefined` when
63
+ * the response `path` did not include those segments.
64
+ *
65
+ * @since 0.1.0
66
+ */
67
+ interface LuauExecutionTaskRef {
68
+ /** Stringified place ID. */
69
+ readonly placeId: string;
70
+ /** Stringified luau-execution-session ID, when carried by the path. */
71
+ readonly sessionId?: string | undefined;
72
+ /** Stringified luau-execution-session-task ID. */
73
+ readonly taskId: string;
74
+ /** Stringified universe ID. */
75
+ readonly universeId: string;
76
+ /** Stringified place version ID, when carried by the path. */
77
+ readonly versionId?: string | undefined;
78
+ }
79
+ /**
80
+ * Caller-supplied input for fetching a Luau Execution task's current
81
+ * state.
82
+ *
83
+ * @since 0.1.0
84
+ */
85
+ interface GetParameters {
86
+ /** Reference to the task to fetch, typically returned by submit. */
87
+ readonly ref: LuauExecutionTaskRef;
88
+ /**
89
+ * View controls how much of the task body the server returns. The
90
+ * server defaults to BASIC (excludes `script`) when no view is sent;
91
+ * `FULL` includes every field.
92
+ */
93
+ readonly view?: "BASIC" | "FULL";
94
+ }
95
+ /**
96
+ * Discriminated variant carrying every state in which the task has not
97
+ * yet produced output or an error: queued for execution, currently
98
+ * executing, or cancelled by the caller. `STATE_UNSPECIFIED` is the
99
+ * schema's default enum value, surfaced verbatim when the server sends
100
+ * it; pollers treat it as non-terminal.
101
+ *
102
+ * @since 0.1.0
103
+ */
104
+ interface InProgressTask extends LuauExecutionTaskBase {
105
+ /**
106
+ * Discriminator: the task is unspecified, queued, processing, or
107
+ * cancelled.
108
+ */
109
+ readonly state: "CANCELLED" | "PROCESSING" | "QUEUED" | "STATE_UNSPECIFIED";
110
+ }
111
+ /**
112
+ * Discriminated variant carrying the script's return values. The
113
+ * server populates `output.results` with the Luau `return` values from
114
+ * the script run, serialized as JSON; entries that were not
115
+ * JSON-serializable (e.g., Roblox `Instance`s) appear as `null`.
116
+ *
117
+ * @since 0.1.0
118
+ */
119
+ interface CompleteTask extends LuauExecutionTaskBase {
120
+ /**
121
+ * JSON projection of the script's return values, in order. The total
122
+ * serialized size of this array is bounded by the server-enforced
123
+ * 4 MB output limit.
124
+ */
125
+ readonly output: {
126
+ readonly results: ReadonlyArray<JSONValue>;
127
+ };
128
+ /** Discriminator: the task ran to completion and produced output. */
129
+ readonly state: "COMPLETE";
130
+ }
131
+ /**
132
+ * Discriminated variant carrying the categorical error code and a
133
+ * human-readable message describing the failure. `code` mirrors the
134
+ * wire enum verbatim, including the schema's `ERROR_CODE_UNSPECIFIED`
135
+ * default.
136
+ *
137
+ * @since 0.1.0
138
+ */
139
+ interface FailedTask extends LuauExecutionTaskBase {
140
+ /** The categorical error code and message that caused the task to fail. */
141
+ readonly error: {
142
+ /**
143
+ * `SCRIPT_ERROR` for unhandled Luau errors, `DEADLINE_EXCEEDED`
144
+ * when the script outran its timeout, `OUTPUT_SIZE_LIMIT_EXCEEDED`
145
+ * when the return values exceeded 4 MB, or `INTERNAL_ERROR` for
146
+ * server-side faults. `ERROR_CODE_UNSPECIFIED` is the schema's
147
+ * default value, passed through when the server sends it.
148
+ */
149
+ readonly code: "DEADLINE_EXCEEDED" | "ERROR_CODE_UNSPECIFIED" | "INTERNAL_ERROR" | "OUTPUT_SIZE_LIMIT_EXCEEDED" | "SCRIPT_ERROR";
150
+ /** Human-readable description of the failure. */
151
+ readonly message: string;
152
+ };
153
+ /** Discriminator: the task ran but failed before producing output. */
154
+ readonly state: "FAILED";
155
+ }
156
+ /**
157
+ * Public, discriminated representation of a Luau Execution session
158
+ * task. The variants are mutually exclusive on `state`.
159
+ *
160
+ * @since 0.1.0
161
+ */
162
+ type LuauExecutionTask = CompleteTask | FailedTask | InProgressTask;
163
+ /**
164
+ * Common fields surfaced on every {@link LuauExecutionTask} variant.
165
+ * Variant-specific fields (`output` for COMPLETE, `error` for FAILED)
166
+ * live on the variants themselves.
167
+ */
168
+ interface LuauExecutionTaskBase {
169
+ /**
170
+ * Resource path of the binary input attached to this task, when one
171
+ * was supplied at submit time.
172
+ */
173
+ readonly binaryInput?: string | undefined;
174
+ /**
175
+ * Pre-signed URI from which the binary output blob can be downloaded.
176
+ * Present only after a `COMPLETE` task whose `enableBinaryOutput` was
177
+ * `true`.
178
+ */
179
+ readonly binaryOutputUri?: string | undefined;
180
+ /**
181
+ * Timestamp when the task was created; `undefined` on tasks returned by
182
+ * `submit`.
183
+ */
184
+ readonly createdAt?: Date | undefined;
185
+ /** When `true`, the server writes output to a binary blob. */
186
+ readonly enableBinaryOutput?: boolean | undefined;
187
+ /** Round-trip-safe reference to this task. */
188
+ readonly ref: LuauExecutionTaskRef;
189
+ /**
190
+ * Wall-clock execution limit in seconds, as supplied at submit time.
191
+ * Surfaces `undefined` when the request did not set a timeout (the
192
+ * server applies its 5-minute default in that case).
193
+ */
194
+ readonly timeoutSeconds?: number | undefined;
195
+ /**
196
+ * Timestamp of the most recent state change; `undefined` on tasks returned
197
+ * by `submit`.
198
+ */
199
+ readonly updatedAt?: Date | undefined;
200
+ /**
201
+ * Identifier of the user that owns the API key used to create this task.
202
+ */
203
+ readonly user: string;
204
+ }
205
+ /**
206
+ * Caller-supplied input for listing the structured log messages produced
207
+ * by a previously-submitted Luau execution task.
208
+ *
209
+ * @since 0.1.0
210
+ */
211
+ interface ListLogsParameters {
212
+ /**
213
+ * Maximum number of log messages to return per page. The server
214
+ * clamps this to the range [1, 10000]. When omitted, the server
215
+ * applies its own default page size.
216
+ */
217
+ readonly pageSize?: number | undefined;
218
+ /**
219
+ * Opaque continuation token returned by the previous `listLogs`
220
+ * call. Pass this to retrieve the next page of results.
221
+ */
222
+ readonly pageToken?: string | undefined;
223
+ /** Reference to the task whose logs are being listed. */
224
+ readonly ref: LuauExecutionTaskRef;
225
+ }
226
+ /**
227
+ * A single structured log message produced by a Luau execution task.
228
+ * The `createTime` field is a raw ISO timestamp string, not a
229
+ * {@link Date}, so it can be serialized without conversion.
230
+ *
231
+ * @since 0.1.0
232
+ */
233
+ interface LogMessage {
234
+ /** ISO timestamp when the log message was produced. */
235
+ readonly createTime: string;
236
+ /** Human-readable log message text. */
237
+ readonly message: string;
238
+ /**
239
+ * Categorical message type, mirroring the wire enum verbatim.
240
+ * `MESSAGE_TYPE_UNSPECIFIED` is the schema's default value, passed
241
+ * through when the server sends it.
242
+ */
243
+ readonly messageType: "ERROR" | "INFO" | "MESSAGE_TYPE_UNSPECIFIED" | "OUTPUT" | "WARNING";
244
+ }
245
+ /**
246
+ * One page of structured log messages from a Luau execution task.
247
+ * Chunks are flattened by the parser; consumers see a single ordered
248
+ * array. When `nextPageToken` is present, pass it to the next
249
+ * `listLogs` call to retrieve the following page.
250
+ *
251
+ * @since 0.1.0
252
+ */
253
+ interface LogPage {
254
+ /** Flattened, ordered list of log messages from this page. */
255
+ readonly messages: ReadonlyArray<LogMessage>;
256
+ /**
257
+ * Opaque token for the next page of results. `undefined` when this
258
+ * is the last page.
259
+ */
260
+ readonly nextPageToken?: string | undefined;
261
+ }
262
+ /**
263
+ * Default poll cadence as a function of elapsed wall-clock time since
264
+ * polling began. Polls quickly while a task is young so short runs resolve
265
+ * snappily, then eases off so a long run leaves rate-limit headroom for
266
+ * newer tasks: 0-20s is 500ms, 20-60s is 1000ms, 60s+ is 5000ms.
267
+ *
268
+ * @since 0.1.0
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * import { defaultPollDelay } from "@bedrock-rbx/ocale/luau-execution";
273
+ *
274
+ * expect(defaultPollDelay(0)).toBe(500);
275
+ * expect(defaultPollDelay(30_000)).toBe(1000);
276
+ * expect(defaultPollDelay(120_000)).toBe(5000);
277
+ * ```
278
+ *
279
+ * @param elapsedMs - Milliseconds elapsed since polling started.
280
+ * @returns The delay in milliseconds to wait before the next poll.
281
+ */
282
+ declare function defaultPollDelay(elapsedMs: number): number;
283
+ /**
284
+ * Public options accepted by `pollUntilDone` and `runUntilDone` on both client
285
+ * surfaces.
286
+ *
287
+ * @since 0.1.0
288
+ */
289
+ type PollUntilDoneOptions = PollOptions & RequestOptions;
290
+ /** Caller-supplied polling-loop options; all fields optional. */
291
+ interface PollOptions {
292
+ /**
293
+ * Consecutive transient transport failures tolerated before the loop gives
294
+ * up. Defaults to {@link DEFAULT_POLL_FAILURE_CAP}. A successful poll
295
+ * resets the count.
296
+ */
297
+ readonly maxConsecutivePollFailures?: number;
298
+ /**
299
+ * Returns the sleep duration given ms elapsed since polling started.
300
+ * Defaults to {@link defaultPollDelay}.
301
+ */
302
+ readonly pollDelay?: (elapsedMs: number) => number;
303
+ /**
304
+ * When aborted, the loop returns {@link PollAbortedError} rather than
305
+ * continuing.
306
+ */
307
+ readonly signal?: AbortSignal;
308
+ /**
309
+ * Total wall-clock budget in ms before the loop returns {@link
310
+ * PollTimeoutError}. It also bounds each in-flight request through the
311
+ * request deadline (the earlier of the budget end and any `deadlineMs`),
312
+ * so a hanging request ends at the budget. For `runUntilDone` the budget
313
+ * opens before the submit and covers it too.
314
+ */
315
+ readonly timeoutMs?: number;
316
+ }
317
+ /**
318
+ * Per-request options for submitting a Luau execution task.
319
+ *
320
+ * @example
321
+ *
322
+ * ```ts
323
+ * import type { LuauExecutionSubmitOptions } from "@bedrock-rbx/ocale/luau-execution";
324
+ *
325
+ * const options: LuauExecutionSubmitOptions = { capacityWaitMs: 60_000 };
326
+ * expect(options.capacityWaitMs).toBe(60_000);
327
+ * ```
328
+ *
329
+ * @since 0.3.2
330
+ */
331
+ interface LuauExecutionSubmitOptions extends RequestOptions {
332
+ /**
333
+ * Maximum milliseconds to spend waiting for occupied place capacity, from 1
334
+ * through 2,147,483,647. Supplying this value opts the submission into
335
+ * capacity-aware admission.
336
+ */
337
+ readonly capacityWaitMs?: number;
338
+ }
339
+ /**
340
+ * Per-request capacity and polling options for submitting and awaiting a Luau
341
+ * execution task.
342
+ *
343
+ * @since 0.3.2
344
+ */
345
+ type LuauExecutionRunOptions = LuauExecutionSubmitOptions & PollUntilDoneOptions;
346
+ export { ListLogsParameters as a, CompleteTask as c, InProgressTask as d, LuauExecutionTask as f, SubmitAtVersionParameters as h, defaultPollDelay as i, FailedTask as l, SubmitAtHeadParameters as m, LuauExecutionSubmitOptions as n, LogMessage as o, LuauExecutionTaskRef as p, PollUntilDoneOptions as r, LogPage as s, LuauExecutionRunOptions as t, GetParameters as u };
347
+ //# sourceMappingURL=capacity-admission-Ce2V9QNb.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacity-admission-Ce2V9QNb.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","../src/resources/luau-execution/capacity-admission.ts"],"mappings":";;;;;;;;UAOiB;;;;;WAKP;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;;;;;;;;UAUO;;;;;WAKP;;WAEA;;WAEA;;WAEA;;;;;WAKA;;WAEA;;WAEA;;;;;;;;;;;UAYO;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;UASO;;WAEP,KAAK;;;;;;WAML;;;;;;;;;;;UAYO,uBAAuB;;;;;WAK9B;;;;;;;;;;UAWO,qBAAqB;;;;;;WAM5B;aAAmB,SAAS,cAAc;;;WAE1C;;;;;;;;;;UAWO,mBAAmB;;WAE1B;;;;;;;;aAQC;;aAOA;;;WAGD;;;;;;;;KASE,oBAAoB,eAAe,aAAa;;;;;;UAOlD;;;;;WAKA;;;;;;WAMA;;;;;WAKA,YAAY;;WAEZ;;WAEA,KAAK;;;;;;WAML;;;;;WAKA,YAAY;;;;WAIZ;;;;;;;;UC1MO;;;;;;WAMP;;;;;WAKA;;WAEA,KAAK;;;;;;;;;UAUE;;WAEP;;WAEA;;;;;;WAMA;;;;;;;;;;UAWO;;WAEP,UAAU,cAAc;;;;;WAKxB;;;;;;;;;;;;;;;;;;;;;;iBCDM,iBAAiB;;;;;;;KAuDrB,uBAAuB,cAAc;;UAGvC;;;;;;WAMA;;;;;WAKA,aAAa;;;;;WAKb,SAAS;;;;;;;;WAQT;;;;;;;;;;;;;;;;UC5GO,mCAAmC;;;;;;WAM1C;;;;;;;;KASE,0BAA0B,6BAA6B"}
@@ -1,9 +1,8 @@
1
- //#region src/locales/data.generated.d.ts
2
1
  /**
3
- * One row in the vendored Roblox creator-locale list.
4
- *
5
- * @since 0.1.0
6
- */
2
+ * One row in the vendored Roblox creator-locale list.
3
+ *
4
+ * @since 0.1.0
5
+ */
7
6
  interface RobloxCreatorLocale {
8
7
  readonly locale: string;
9
8
  readonly languageCode: string;
@@ -15,12 +14,12 @@ interface RobloxCreatorLocale {
15
14
  readonly isEnabledForSignupAndLogin: boolean;
16
15
  }
17
16
  /**
18
- * Vendored snapshot of
19
- * `https://locale.roblox.com/v1/locales/supported-locales-for-creators`.
20
- * Refreshed by `pnpm --filter @bedrock-rbx/ocale refresh-locales`.
21
- *
22
- * @since 0.1.0
23
- */
17
+ * Vendored snapshot of
18
+ * `https://locale.roblox.com/v1/locales/supported-locales-for-creators`.
19
+ * Refreshed by `pnpm --filter @bedrock-rbx/ocale refresh-locales`.
20
+ *
21
+ * @since 0.1.0
22
+ */
24
23
  declare const ROBLOX_CREATOR_LOCALES: readonly [{
25
24
  readonly locale: "ar_001";
26
25
  readonly languageCode: "ar";
@@ -473,21 +472,20 @@ declare const ROBLOX_CREATOR_LOCALES: readonly [{
473
472
  readonly isEnabledForSignupAndLogin: true;
474
473
  }];
475
474
  /**
476
- * Roblox locale wire form (e.g. `en_us`, `pt_br`, `ar_001`). Used by
477
- * the legacy game-internationalization endpoints when
478
- * `languageCodeType` is `Locale`.
479
- *
480
- * @since 0.1.0
481
- */
475
+ * Roblox locale wire form (e.g. `en_us`, `pt_br`, `ar_001`). Used by
476
+ * the legacy game-internationalization endpoints when
477
+ * `languageCodeType` is `Locale`.
478
+ *
479
+ * @since 0.1.0
480
+ */
482
481
  type RobloxLocale = (typeof ROBLOX_CREATOR_LOCALES)[number]["locale"];
483
482
  /**
484
- * Roblox language wire form (e.g. `en`, `fil`, `zh-hans`). Used by
485
- * the legacy game-internationalization endpoints when
486
- * `languageCodeType` is `Language`.
487
- *
488
- * @since 0.1.0
489
- */
483
+ * Roblox language wire form (e.g. `en`, `fil`, `zh-hans`). Used by
484
+ * the legacy game-internationalization endpoints when
485
+ * `languageCodeType` is `Language`.
486
+ *
487
+ * @since 0.1.0
488
+ */
490
489
  type RobloxLanguageCode = (typeof ROBLOX_CREATOR_LOCALES)[number]["languageCode"];
491
- //#endregion
492
490
  export { RobloxLocale as i, RobloxCreatorLocale as n, RobloxLanguageCode as r, ROBLOX_CREATOR_LOCALES as t };
493
- //# sourceMappingURL=data.generated-B2ceLfSn.d.mts.map
491
+ //# sourceMappingURL=data.generated-B4Fztv_7.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.generated-B4Fztv_7.d.mts","names":[],"sources":["../src/locales/data.generated.ts"],"mappings":";;;;;UAQiB;WACP;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;cAUG;WAEX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;KAWU,uBAAuB;;;;;;;;KASvB,6BAA6B"}