@bedrock-rbx/ocale 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/badges.d.mts +186 -0
- package/dist/badges.d.mts.map +1 -0
- package/dist/badges.mjs +309 -0
- package/dist/badges.mjs.map +1 -0
- package/dist/developer-products.d.mts +245 -0
- package/dist/developer-products.d.mts.map +1 -0
- package/dist/developer-products.mjs +388 -0
- package/dist/developer-products.mjs.map +1 -0
- package/dist/game-passes.d.mts +210 -0
- package/dist/game-passes.d.mts.map +1 -0
- package/dist/game-passes.mjs +397 -0
- package/dist/game-passes.mjs.map +1 -0
- package/dist/index.d.mts +191 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/places.d.mts +161 -0
- package/dist/places.d.mts.map +1 -0
- package/dist/places.mjs +403 -0
- package/dist/places.mjs.map +1 -0
- package/dist/price-information-CmpscMc4.mjs +42 -0
- package/dist/price-information-CmpscMc4.mjs.map +1 -0
- package/dist/rate-limit-BBU_4xnZ.mjs +135 -0
- package/dist/rate-limit-BBU_4xnZ.mjs.map +1 -0
- package/dist/resource-client-CaS_j3yg.mjs +652 -0
- package/dist/resource-client-CaS_j3yg.mjs.map +1 -0
- package/dist/to-blob-1BtHsDGK.mjs +18 -0
- package/dist/to-blob-1BtHsDGK.mjs.map +1 -0
- package/dist/types-YCTsM8Qd.d.mts +214 -0
- package/dist/types-YCTsM8Qd.d.mts.map +1 -0
- package/dist/universes.d.mts +387 -0
- package/dist/universes.d.mts.map +1 -0
- package/dist/universes.mjs +705 -0
- package/dist/universes.mjs.map +1 -0
- package/dist/validation-CTZzJhmd.mjs +38 -0
- package/dist/validation-CTZzJhmd.mjs.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"developer-products.mjs","names":["buildUpdateRequest","buildUpdateRequest","buildLocaleNameDescRequest","#inner"],"sources":["../src/domains/developer-products/products/builders.ts","../src/domains/developer-products/products/operations.ts","../src/domains/developer-products/products/parsers.ts","../src/domains/game-internationalization/developer-product-icon/builders.ts","../src/domains/game-internationalization/developer-product-name-description/builders.ts","../src/domains/game-internationalization/developer-product-name-description/operations.ts","../src/resources/developer-products/client.ts"],"sourcesContent":["import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport { toBlob } from \"../../../internal/utils/to-blob.ts\";\nimport type {\n\tCreateDeveloperProductParameters,\n\tGetDeveloperProductParameters,\n\tUpdateDeveloperProductParameters,\n} from \"./types.ts\";\n\n/**\n * Builds a `GET` request for the Open Cloud \"read developer product\"\n * endpoint.\n *\n * @param parameters - Universe and product identifiers to interpolate into\n * the URL.\n * @returns A pure {@link HttpRequest} describing the read call.\n */\nexport function buildGetRequest(parameters: GetDeveloperProductParameters): HttpRequest {\n\treturn {\n\t\tmethod: \"GET\",\n\t\turl: `/developer-products/v2/universes/${parameters.universeId}/developer-products/${parameters.productId}/creator`,\n\t};\n}\n\n/**\n * Builds a `POST` request for the Open Cloud \"create developer product\"\n * endpoint.\n *\n * @param parameters - Fields describing the new developer product; optional\n * values omitted here are left off the multipart payload entirely.\n * @returns A pure {@link HttpRequest} describing the create call.\n */\nexport function buildCreateRequest(parameters: CreateDeveloperProductParameters): HttpRequest {\n\tconst body = new FormData();\n\tbody.append(\"name\", parameters.name);\n\tif (parameters.description !== undefined) {\n\t\tbody.append(\"description\", parameters.description);\n\t}\n\n\tif (parameters.isForSale !== undefined) {\n\t\tbody.append(\"isForSale\", String(parameters.isForSale));\n\t}\n\n\tif (parameters.price !== undefined) {\n\t\tbody.append(\"price\", String(parameters.price));\n\t}\n\n\tif (parameters.isRegionalPricingEnabled !== undefined) {\n\t\tbody.append(\"isRegionalPricingEnabled\", String(parameters.isRegionalPricingEnabled));\n\t}\n\n\tif (parameters.imageFile !== undefined) {\n\t\tbody.append(\"imageFile\", toBlob(parameters.imageFile));\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"POST\",\n\t\turl: `/developer-products/v2/universes/${parameters.universeId}/developer-products`,\n\t};\n}\n\n/**\n * Builds a `PATCH` request for the Open Cloud \"update developer product\"\n * endpoint. Every field on `parameters` except the identifiers is optional;\n * omitted fields are not appended to the multipart body so the server leaves\n * them unchanged.\n *\n * @param parameters - Identifiers plus fields to update.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(parameters: UpdateDeveloperProductParameters): HttpRequest {\n\tconst body = new FormData();\n\tif (parameters.name !== undefined) {\n\t\tbody.append(\"name\", parameters.name);\n\t}\n\n\tif (parameters.description !== undefined) {\n\t\tbody.append(\"description\", parameters.description);\n\t}\n\n\tif (parameters.isForSale !== undefined) {\n\t\tbody.append(\"isForSale\", String(parameters.isForSale));\n\t}\n\n\tif (parameters.price !== undefined) {\n\t\tbody.append(\"price\", String(parameters.price));\n\t}\n\n\tif (parameters.isRegionalPricingEnabled !== undefined) {\n\t\tbody.append(\"isRegionalPricingEnabled\", String(parameters.isRegionalPricingEnabled));\n\t}\n\n\tif (parameters.storePageEnabled !== undefined) {\n\t\tbody.append(\"storePageEnabled\", String(parameters.storePageEnabled));\n\t}\n\n\tif (parameters.imageFile !== undefined) {\n\t\tbody.append(\"imageFile\", toBlob(parameters.imageFile));\n\t}\n\n\treturn {\n\t\tbody,\n\t\tmethod: \"PATCH\",\n\t\turl: `/developer-products/v2/universes/${parameters.universeId}/developer-products/${parameters.productId}`,\n\t};\n}\n","import type { OperationLimit } from \"../../../internal/http/rate-limit-queue.ts\";\n\n/**\n * Per-second request ceiling for reading a single developer product, from\n * the Open Cloud OpenAPI schema.\n */\nexport const GET_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 10,\n\toperationKey: \"developer-products.get\",\n});\n\n/**\n * Per-second request ceiling for creating a developer product, from the\n * Open Cloud OpenAPI schema.\n */\nexport const CREATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 3,\n\toperationKey: \"developer-products.create\",\n});\n\n/**\n * Per-second request ceiling for updating a developer product, from the\n * Open Cloud OpenAPI schema. Keyed independently from\n * {@link CREATE_OPERATION_LIMIT} so create and update do not share a queue,\n * since Roblox does not document the per-minute quota as shared between\n * the POST and PATCH endpoints.\n */\nexport const UPDATE_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 3,\n\toperationKey: \"developer-products.update\",\n});\n\n/**\n * Scopes the API key or OAuth token must carry to read a developer product,\n * sourced from `x-roblox-scopes` on the `DeveloperProducts_GetDeveloperProductConfigV2`\n * operation in the vendored OpenAPI schema.\n */\nexport const GET_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\"developer-product:read\"]);\n\n/**\n * Scopes the API key or OAuth token must carry to create or update a developer\n * product, sourced from `x-roblox-scopes` on the\n * `DeveloperProducts_CreateDeveloperProductV2` and\n * `DeveloperProducts_UpdateDeveloperProductV2` operations in the vendored\n * OpenAPI schema.\n */\nexport const WRITE_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"developer-product:write\",\n]);\n","import type { HttpResponse } from \"../../../client/types.ts\";\nimport { ApiError } from \"../../../errors/api-error.ts\";\nimport {\n\tcopyPriceInformation,\n\tisPriceInformationLike,\n} from \"../../../internal/price-information.ts\";\nimport { isRecord } from \"../../../internal/utils/is-record.ts\";\nimport type { Result } from \"../../../types.ts\";\nimport type { DeveloperProduct } from \"./types.ts\";\nimport type { DeveloperProductConfigV2, DeveloperProductPricingFeatureWire } from \"./wire.ts\";\n\n/**\n * Parses a successful Developer Products API response into the public\n * `DeveloperProduct` shape, returning a `Result` so callers can handle\n * malformed payloads without 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 `DeveloperProduct`, or\n * an `ApiError` when the body does not match the wire schema.\n */\nexport function parseDeveloperProductResponse(\n\tresponse: HttpResponse,\n): Result<DeveloperProduct, ApiError> {\n\tconst { body, status: statusCode } = response;\n\n\tif (!isDeveloperProductConfigV2(body)) {\n\t\treturn {\n\t\t\terr: new ApiError(\"Malformed developer product response\", { statusCode }),\n\t\t\tsuccess: false,\n\t\t};\n\t}\n\n\tconst priceWire = body.priceInformation ?? undefined;\n\tconst iconAssetId = body.iconImageAssetId ?? undefined;\n\n\treturn {\n\t\tdata: {\n\t\t\tid: String(body.productId),\n\t\t\tname: body.name,\n\t\t\tcreatedAt: new Date(body.createdTimestamp),\n\t\t\tdescription: body.description,\n\t\t\ticonImageAssetId: iconAssetId === undefined ? undefined : String(iconAssetId),\n\t\t\tisForSale: body.isForSale,\n\t\t\tisImmutable: body.isImmutable,\n\t\t\tprice: priceWire === undefined ? undefined : copyPriceInformation(priceWire),\n\t\t\tstorePageEnabled: body.storePageEnabled,\n\t\t\tuniverseId: String(body.universeId),\n\t\t\tupdatedAt: new Date(body.updatedTimestamp),\n\t\t},\n\t\tsuccess: true,\n\t};\n}\n\nfunction hasRequiredPrimitiveFields(body: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof body[\"productId\"] === \"number\" &&\n\t\t// Roblox never assigns asset ID 0; a zero productId signals a\n\t\t// malformed response, not a legitimate product.\n\t\tbody[\"productId\"] !== 0 &&\n\t\ttypeof body[\"universeId\"] === \"number\" &&\n\t\ttypeof body[\"name\"] === \"string\" &&\n\t\ttypeof body[\"description\"] === \"string\" &&\n\t\ttypeof body[\"isForSale\"] === \"boolean\" &&\n\t\ttypeof body[\"isImmutable\"] === \"boolean\" &&\n\t\ttypeof body[\"storePageEnabled\"] === \"boolean\" &&\n\t\ttypeof body[\"createdTimestamp\"] === \"string\" &&\n\t\ttypeof body[\"updatedTimestamp\"] === \"string\"\n\t);\n}\n\nfunction isPricingFeatureWire(value: unknown): value is DeveloperProductPricingFeatureWire {\n\treturn (\n\t\tvalue === \"Invalid\" ||\n\t\tvalue === \"PriceOptimization\" ||\n\t\tvalue === \"RegionalPricing\" ||\n\t\tvalue === \"UserFixedPrice\"\n\t);\n}\n\nfunction isDeveloperProductConfigV2(body: unknown): body is DeveloperProductConfigV2 {\n\tif (!isRecord(body)) {\n\t\treturn false;\n\t}\n\n\tif (!hasRequiredPrimitiveFields(body)) {\n\t\treturn false;\n\t}\n\n\tconst iconImageAssetId = body[\"iconImageAssetId\"] ?? undefined;\n\tif (iconImageAssetId !== undefined && typeof iconImageAssetId !== \"number\") {\n\t\treturn false;\n\t}\n\n\tconst price = body[\"priceInformation\"] ?? undefined;\n\tif (price !== undefined && !isPriceInformationLike(price, isPricingFeatureWire)) {\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 { UploadDeveloperProductIconParameters } from \"./types.ts\";\n\n/**\n * Builds a `POST` request for the localized \"upload developer-product icon\"\n * endpoint. A successful upload replaces any existing icon for the same\n * `(productId, languageCode)` pair.\n *\n * @param parameters - Product 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: UploadDeveloperProductIconParameters,\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/developer-products/${parameters.productId}/icons/language-codes/${parameters.languageCode}`,\n\t};\n}\n","import type { HttpRequest } from \"../../../internal/http/types.ts\";\nimport type { UpdateDeveloperProductNameDescriptionParameters } from \"./types.ts\";\n\n/**\n * Builds a `PATCH` request for the localized \"update developer-product\n * name/description\" endpoint. Either `name`, `description`, or both may be\n * supplied; omitted fields are not included in the JSON body so the server\n * leaves the existing value for that locale untouched.\n *\n * @param parameters - Product and language identifiers plus the optional\n * replacement values.\n * @returns A pure {@link HttpRequest} describing the update call.\n */\nexport function buildUpdateRequest(\n\tparameters: UpdateDeveloperProductNameDescriptionParameters,\n): 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/developer-products/${parameters.productId}/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 developer-product localization\n * Operation. The legacy `gameinternationalization` service caps each API key\n * at 100 requests per minute *shared across the entire service* (see the\n * `x-roblox-rate-limits` extension on every operation in the vendored Open\n * Cloud spec), so all developer-product localization methods queue against\n * the same operation key.\n */\nexport const LOCALIZATION_OPERATION_LIMIT: OperationLimit = Object.freeze({\n\tmaxPerSecond: 100 / 60,\n\toperationKey: \"developer-product-localization\",\n});\n\n/**\n * Scopes required for every developer-product localization operation, sourced\n * from `x-roblox-scopes` on the legacy `gameinternationalization`\n * developer-product endpoints in the vendored OpenAPI schema.\n */\nexport const LOCALIZATION_REQUIRED_SCOPES: ReadonlyArray<string> = Object.freeze([\n\t\"legacy-developer-product:manage\",\n]);\n","import type { OpenCloudClientOptions, RequestOptions } from \"../../client/types.ts\";\nimport {\n\tbuildCreateRequest,\n\tbuildGetRequest,\n\tbuildUpdateRequest,\n} from \"../../domains/developer-products/products/builders.ts\";\nimport {\n\tCREATE_OPERATION_LIMIT,\n\tGET_OPERATION_LIMIT,\n\tGET_REQUIRED_SCOPES,\n\tUPDATE_OPERATION_LIMIT,\n\tWRITE_REQUIRED_SCOPES,\n} from \"../../domains/developer-products/products/operations.ts\";\nimport { parseDeveloperProductResponse } from \"../../domains/developer-products/products/parsers.ts\";\nimport type {\n\tCreateDeveloperProductParameters,\n\tDeveloperProduct,\n\tGetDeveloperProductParameters,\n\tUpdateDeveloperProductParameters,\n} from \"../../domains/developer-products/products/types.ts\";\nimport { buildUploadIconRequest } from \"../../domains/game-internationalization/developer-product-icon/builders.ts\";\nimport type { UploadDeveloperProductIconParameters } from \"../../domains/game-internationalization/developer-product-icon/types.ts\";\nimport { buildUpdateRequest as buildLocaleNameDescRequest } from \"../../domains/game-internationalization/developer-product-name-description/builders.ts\";\nimport {\n\tLOCALIZATION_OPERATION_LIMIT,\n\tLOCALIZATION_REQUIRED_SCOPES,\n} from \"../../domains/game-internationalization/developer-product-name-description/operations.ts\";\nimport type { UpdateDeveloperProductNameDescriptionParameters } from \"../../domains/game-internationalization/developer-product-name-description/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 = DeveloperProduct>(\n\tspec: ResourceMethodSpec<P, R>,\n): ResourceMethodSpec<P, R> {\n\treturn Object.freeze(spec);\n}\n\nconst CREATE_SPEC = makeSpec<CreateDeveloperProductParameters>({\n\tbuildRequest: (parameters) => okRequest(buildCreateRequest(parameters)),\n\tmethodDefaults: CREATE_METHOD_DEFAULTS,\n\tmethodKind: \"create\",\n\toperationLimit: CREATE_OPERATION_LIMIT,\n\tparse: parseDeveloperProductResponse,\n\trequiredScopes: WRITE_REQUIRED_SCOPES,\n});\n\nconst GET_SPEC = makeSpec<GetDeveloperProductParameters>({\n\tbuildRequest: (parameters) => okRequest(buildGetRequest(parameters)),\n\tmethodDefaults: IDEMPOTENT_METHOD_DEFAULTS,\n\tmethodKind: \"idempotent\",\n\toperationLimit: GET_OPERATION_LIMIT,\n\tparse: parseDeveloperProductResponse,\n\trequiredScopes: GET_REQUIRED_SCOPES,\n});\n\nconst UPDATE_SPEC = makeSpec<UpdateDeveloperProductParameters, 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: WRITE_REQUIRED_SCOPES,\n});\n\nconst UPDATE_NAME_DESCRIPTION_SPEC = makeSpec<\n\tUpdateDeveloperProductNameDescriptionParameters,\n\tundefined\n>({\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_ICON_SPEC = makeSpec<UploadDeveloperProductIconParameters, undefined>({\n\tbuildRequest: (parameters) => okRequest(buildUploadIconRequest(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 DeveloperProductLocalizationHandle {\n\t/**\n\t * Updates the per-locale display name and/or description registered against\n\t * a developer product. Either `name`, `description`, or both may be\n\t * supplied; omitted fields are not forwarded so the server leaves the\n\t * existing value for that locale untouched. Mirrors the upstream `200 OK`\n\t * echo body as `undefined` data.\n\t *\n\t * @param parameters - Product 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: UpdateDeveloperProductNameDescriptionParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n\t/**\n\t * Uploads or replaces the per-locale icon for a developer product. A\n\t * subsequent upload for the same `(productId, languageCode)` pair replaces\n\t * the 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.\n\t *\n\t * @param parameters - Product and language identifiers plus the image\n\t * 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\tuploadIcon: (\n\t\tparameters: UploadDeveloperProductIconParameters,\n\t\toptions?: RequestOptions,\n\t) => Promise<Result<undefined, OpenCloudError>>;\n}\n\n/**\n * Public client for the Roblox Open Cloud Developer Products API.\n *\n * Wires request builders, the injected {@link OpenCloudClientOptions.httpClient}, and response\n * parsers into a single ergonomic surface. Every method returns a\n * {@link Result} so callers handle failure explicitly; no thrown\n * `OpenCloudError` ever escapes the client.\n *\n * ```ts\n * import { DeveloperProductsClient } from \"@bedrock-rbx/ocale/developer-products\";\n *\n * const client = new DeveloperProductsClient({ apiKey: process.env.ROBLOX_API_KEY! });\n *\n * const result = await client.get({\n * universeId: \"1234567890\",\n * productId: \"9876543210\",\n * });\n *\n * if (result.success) {\n * console.log(`${result.data.name} (${result.data.id})`);\n * } else {\n * console.error(result.err.message);\n * }\n * ```\n */\nexport class DeveloperProductsClient {\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 DeveloperProductsClient.update}; methods on this\n\t * group set per-locale overlays on top. Shares the parent client's\n\t * HTTP, rate-limit, and retry plumbing.\n\t */\n\tpublic readonly localization: DeveloperProductLocalizationHandle;\n\n\t/**\n\t * Creates a new {@link DeveloperProductsClient}. Configuration is frozen\n\t * on 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 developer product under the supplied universe.\n\t *\n\t * @param parameters - Creation fields including the universe and product name.\n\t * @param options - Optional per-request overrides.\n\t * @returns A {@link Result} wrapping the parsed {@link DeveloperProduct} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async create(\n\t\tparameters: CreateDeveloperProductParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<DeveloperProduct, OpenCloudError>> {\n\t\treturn this.#inner.execute({ options, parameters, spec: CREATE_SPEC });\n\t}\n\n\t/**\n\t * Reads a single developer product by ID.\n\t *\n\t * @param parameters - Universe and product identifiers.\n\t * @param options - Optional per-request overrides (e.g. A different\n\t * {@link OpenCloudClientOptions.apiKey} for this call only).\n\t * @returns A {@link Result} wrapping the parsed {@link DeveloperProduct} or\n\t * the {@link OpenCloudError} that caused the request to fail.\n\t */\n\tpublic async get(\n\t\tparameters: GetDeveloperProductParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<DeveloperProduct, OpenCloudError>> {\n\t\treturn this.#inner.execute({ options, parameters, spec: GET_SPEC });\n\t}\n\n\t/**\n\t * Partially updates an existing developer product. Mirrors the upstream\n\t * `204 No Content` response: a successful update yields `undefined` data.\n\t * Callers that need the post-update state (for example to observe a\n\t * server-derived `updatedTimestamp`) chain {@link DeveloperProductsClient.get}\n\t * themselves so the GET only fires when actually needed.\n\t *\n\t * @param parameters - The universe and product identifiers and the\n\t * fields to update. Only fields explicitly provided are forwarded.\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: UpdateDeveloperProductParameters,\n\t\toptions?: RequestOptions,\n\t): Promise<Result<undefined, OpenCloudError>> {\n\t\treturn this.#inner.execute({ options, parameters, spec: UPDATE_SPEC });\n\t}\n}\n\nfunction createLocalizationHandle(inner: ResourceClient): DeveloperProductLocalizationHandle {\n\treturn {\n\t\tasync updateNameDescription(parameters, options) {\n\t\t\treturn inner.execute({ options, parameters, spec: UPDATE_NAME_DESCRIPTION_SPEC });\n\t\t},\n\t\tasync uploadIcon(parameters, options) {\n\t\t\treturn inner.execute({ options, parameters, spec: UPLOAD_ICON_SPEC });\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,YAAwD;AACvF,QAAO;EACN,QAAQ;EACR,KAAK,oCAAoC,WAAW,WAAW,sBAAsB,WAAW,UAAU;EAC1G;;;;;;;;;;AAWF,SAAgB,mBAAmB,YAA2D;CAC7F,MAAM,OAAO,IAAI,UAAU;AAC3B,MAAK,OAAO,QAAQ,WAAW,KAAK;AACpC,KAAI,WAAW,gBAAgB,KAAA,EAC9B,MAAK,OAAO,eAAe,WAAW,YAAY;AAGnD,KAAI,WAAW,cAAc,KAAA,EAC5B,MAAK,OAAO,aAAa,OAAO,WAAW,UAAU,CAAC;AAGvD,KAAI,WAAW,UAAU,KAAA,EACxB,MAAK,OAAO,SAAS,OAAO,WAAW,MAAM,CAAC;AAG/C,KAAI,WAAW,6BAA6B,KAAA,EAC3C,MAAK,OAAO,4BAA4B,OAAO,WAAW,yBAAyB,CAAC;AAGrF,KAAI,WAAW,cAAc,KAAA,EAC5B,MAAK,OAAO,aAAa,OAAO,WAAW,UAAU,CAAC;AAGvD,QAAO;EACN;EACA,QAAQ;EACR,KAAK,oCAAoC,WAAW,WAAW;EAC/D;;;;;;;;;;;AAYF,SAAgBA,qBAAmB,YAA2D;CAC7F,MAAM,OAAO,IAAI,UAAU;AAC3B,KAAI,WAAW,SAAS,KAAA,EACvB,MAAK,OAAO,QAAQ,WAAW,KAAK;AAGrC,KAAI,WAAW,gBAAgB,KAAA,EAC9B,MAAK,OAAO,eAAe,WAAW,YAAY;AAGnD,KAAI,WAAW,cAAc,KAAA,EAC5B,MAAK,OAAO,aAAa,OAAO,WAAW,UAAU,CAAC;AAGvD,KAAI,WAAW,UAAU,KAAA,EACxB,MAAK,OAAO,SAAS,OAAO,W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,OACZ,YACA,SACoD;AACpD,SAAO,MAAA,MAAY,QAAQ;GAAE;GAAS;GAAY,MAAM;GAAa,CAAC;;;;;;;;;;;CAYvE,MAAa,IACZ,YACA,SACoD;AACpD,SAAO,MAAA,MAAY,QAAQ;GAAE;GAAS;GAAY,MAAM;GAAU,CAAC;;;;;;;;;;;;;;;CAgBpE,MAAa,OACZ,YACA,SAC6C;AAC7C,SAAO,MAAA,MAAY,QAAQ;GAAE;GAAS;GAAY,MAAM;GAAa,CAAC;;;AAIxE,SAAS,yBAAyB,OAA2D;AAC5F,QAAO;EACN,MAAM,sBAAsB,YAAY,SAAS;AAChD,UAAO,MAAM,QAAQ;IAAE;IAAS;IAAY,MAAM;IAA8B,CAAC;;EAElF,MAAM,WAAW,YAAY,SAAS;AACrC,UAAO,MAAM,QAAQ;IAAE;IAAS;IAAY,MAAM;IAAkB,CAAC;;EAEtE"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { c as Page, d as OpenCloudError, i as OpenCloudClientOptions, l as Result, s as RequestOptions } from "./types-YCTsM8Qd.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/domains/game-passes/game-passes/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Pricing feature flags that can be enabled on a game pass. Values
|
|
6
|
+
* mirror the Open Cloud `GamePasses.PricingFeature` enum.
|
|
7
|
+
*/
|
|
8
|
+
type GamePassPricingFeature = "Invalid" | "PriceOptimization" | "RegionalPricing" | "UserFixedPrice";
|
|
9
|
+
/**
|
|
10
|
+
* Public shape of a game pass's pricing configuration.
|
|
11
|
+
*/
|
|
12
|
+
interface GamePassPrice {
|
|
13
|
+
/** Default Robux price; `undefined` when no default price is configured. */
|
|
14
|
+
readonly defaultPriceInRobux: number | undefined;
|
|
15
|
+
/** Pricing feature flags currently enabled on this game pass. */
|
|
16
|
+
readonly enabledFeatures: ReadonlyArray<GamePassPricingFeature>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Roblox game pass as exposed to SDK consumers. Fields use DX-friendly
|
|
20
|
+
* names and types (stringified IDs, `Date` timestamps) rather than the
|
|
21
|
+
* raw wire representation.
|
|
22
|
+
*/
|
|
23
|
+
interface GamePass {
|
|
24
|
+
/** Stringified game pass ID. The API returns an int64; always use this. */
|
|
25
|
+
readonly id: string;
|
|
26
|
+
/** Display name of the game pass. */
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/** ISO timestamp at which the game pass was created, as a `Date`. */
|
|
29
|
+
readonly createdAt: Date;
|
|
30
|
+
/** Consumer-facing description shown on the store listing. */
|
|
31
|
+
readonly description: string;
|
|
32
|
+
/** Icon asset ID as a string; `undefined` when no icon is uploaded. */
|
|
33
|
+
readonly iconAssetId: string | undefined;
|
|
34
|
+
/** Whether the game pass is currently purchasable. */
|
|
35
|
+
readonly isForSale: boolean;
|
|
36
|
+
/** Pricing configuration; `undefined` when pricing is not yet set. */
|
|
37
|
+
readonly price: GamePassPrice | undefined;
|
|
38
|
+
/** ISO timestamp of the most recent update, as a `Date`. */
|
|
39
|
+
readonly updatedAt: Date;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parameters for creating a new game pass under a universe.
|
|
43
|
+
*/
|
|
44
|
+
interface CreateGamePassParameters {
|
|
45
|
+
/** Display name of the new game pass. */
|
|
46
|
+
readonly name: string;
|
|
47
|
+
/** Optional consumer-facing description shown on the store listing. */
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
/** Optional icon image uploaded with the new game pass. */
|
|
50
|
+
readonly imageFile?: Blob | Uint8Array;
|
|
51
|
+
/** Whether the game pass should be purchasable immediately. */
|
|
52
|
+
readonly isForSale?: boolean;
|
|
53
|
+
/** Whether regional pricing should be enabled at creation time. */
|
|
54
|
+
readonly isRegionalPricingEnabled?: boolean;
|
|
55
|
+
/** Optional default price in Robux at creation time. */
|
|
56
|
+
readonly price?: number;
|
|
57
|
+
/** Stringified ID of the universe that owns the game pass. */
|
|
58
|
+
readonly universeId: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parameters for reading a single game pass by ID.
|
|
62
|
+
*/
|
|
63
|
+
interface GetGamePassParameters {
|
|
64
|
+
/** Stringified ID of the game pass to retrieve. */
|
|
65
|
+
readonly gamePassId: string;
|
|
66
|
+
/** Stringified ID of the universe that owns the game pass. */
|
|
67
|
+
readonly universeId: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parameters for listing the game passes registered against a universe.
|
|
71
|
+
* Pagination is cursor-based: omit `pageToken` to fetch the first page,
|
|
72
|
+
* then thread the previous response's `nextPageToken` back in until it
|
|
73
|
+
* is `undefined`.
|
|
74
|
+
*/
|
|
75
|
+
interface ListGamePassesParameters {
|
|
76
|
+
/** Optional page size; the server defaults to 50 when omitted. */
|
|
77
|
+
readonly pageSize?: number;
|
|
78
|
+
/** Optional cursor returned by a previous page; omit for the first page. */
|
|
79
|
+
readonly pageToken?: string;
|
|
80
|
+
/** Stringified ID of the universe whose game passes to list. */
|
|
81
|
+
readonly universeId: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parameters for partially updating an existing game pass. Every field
|
|
85
|
+
* except the identifiers is optional; omitted fields are not included
|
|
86
|
+
* in the multipart body so the server leaves their current values
|
|
87
|
+
* untouched.
|
|
88
|
+
*/
|
|
89
|
+
interface UpdateGamePassParameters {
|
|
90
|
+
/** Optional new display name for the game pass. */
|
|
91
|
+
readonly name?: string;
|
|
92
|
+
/** Optional new consumer-facing description shown on the store listing. */
|
|
93
|
+
readonly description?: string;
|
|
94
|
+
/** Stringified ID of the game pass to update. */
|
|
95
|
+
readonly gamePassId: string;
|
|
96
|
+
/** Optional replacement icon image. */
|
|
97
|
+
readonly imageFile?: Blob | Uint8Array;
|
|
98
|
+
/** Optional new value for whether the game pass is purchasable. */
|
|
99
|
+
readonly isForSale?: boolean;
|
|
100
|
+
/** Optional new value for whether regional pricing is enabled. */
|
|
101
|
+
readonly isRegionalPricingEnabled?: boolean;
|
|
102
|
+
/** Optional new default price in Robux. */
|
|
103
|
+
readonly price?: number;
|
|
104
|
+
/** Stringified ID of the universe that owns the game pass. */
|
|
105
|
+
readonly universeId: string;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/resources/game-passes/client.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* Public client for the Roblox Open Cloud Game Passes API.
|
|
111
|
+
*
|
|
112
|
+
* Wires request builders, the injected {@link OpenCloudClientOptions.httpClient}, and response
|
|
113
|
+
* parsers into a single ergonomic surface. Every method returns a
|
|
114
|
+
* {@link Result} so callers handle failure explicitly; no thrown
|
|
115
|
+
* `OpenCloudError` ever escapes the client.
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { GamePassesClient } from "@bedrock-rbx/ocale/game-passes";
|
|
119
|
+
*
|
|
120
|
+
* const client = new GamePassesClient({ apiKey: process.env.ROBLOX_API_KEY! });
|
|
121
|
+
*
|
|
122
|
+
* const result = await client.get({
|
|
123
|
+
* universeId: "1234567890",
|
|
124
|
+
* gamePassId: "9876543210",
|
|
125
|
+
* });
|
|
126
|
+
*
|
|
127
|
+
* if (result.success) {
|
|
128
|
+
* console.log(`${result.data.name} (${result.data.id})`);
|
|
129
|
+
* } else {
|
|
130
|
+
* console.error(result.err.message);
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* Listing is cursor-paginated; drive the loop on `nextPageToken`:
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* let pageToken: string | undefined;
|
|
138
|
+
* do {
|
|
139
|
+
* const page = await client.list({ universeId: "1234567890", pageToken });
|
|
140
|
+
* if (!page.success) {
|
|
141
|
+
* console.error(page.err.message);
|
|
142
|
+
* break;
|
|
143
|
+
* }
|
|
144
|
+
*
|
|
145
|
+
* for (const pass of page.data.items) {
|
|
146
|
+
* console.log(`${pass.name} (${pass.id})`);
|
|
147
|
+
* }
|
|
148
|
+
*
|
|
149
|
+
* pageToken = page.data.nextPageToken;
|
|
150
|
+
* } while (pageToken !== undefined);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare class GamePassesClient {
|
|
154
|
+
#private;
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new {@link GamePassesClient}. Configuration is frozen on
|
|
157
|
+
* construction; per-request overrides are accepted on each method.
|
|
158
|
+
*
|
|
159
|
+
* @param options - Client-level configuration including the API key.
|
|
160
|
+
*/
|
|
161
|
+
constructor(options: OpenCloudClientOptions);
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new game pass under the supplied universe.
|
|
164
|
+
*
|
|
165
|
+
* @param parameters - Creation fields including the universe and pass name.
|
|
166
|
+
* @param options - Optional per-request overrides.
|
|
167
|
+
* @returns A {@link Result} wrapping the parsed {@link GamePass} or the
|
|
168
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
169
|
+
*/
|
|
170
|
+
create(parameters: CreateGamePassParameters, options?: RequestOptions): Promise<Result<GamePass, OpenCloudError>>;
|
|
171
|
+
/**
|
|
172
|
+
* Reads a single game pass by ID.
|
|
173
|
+
*
|
|
174
|
+
* @param parameters - Universe and game pass identifiers.
|
|
175
|
+
* @param options - Optional per-request overrides (e.g. A different
|
|
176
|
+
* {@link OpenCloudClientOptions.apiKey} for this call only).
|
|
177
|
+
* @returns A {@link Result} wrapping the parsed {@link GamePass} or the
|
|
178
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
179
|
+
*/
|
|
180
|
+
get(parameters: GetGamePassParameters, options?: RequestOptions): Promise<Result<GamePass, OpenCloudError>>;
|
|
181
|
+
/**
|
|
182
|
+
* Lists one page of game passes for the supplied universe. Pagination is
|
|
183
|
+
* cursor-based: omit `pageToken` for the first page, then thread the
|
|
184
|
+
* previous response's `nextPageToken` back in until it is `undefined`.
|
|
185
|
+
*
|
|
186
|
+
* @param parameters - Universe identifier and optional page cursors.
|
|
187
|
+
* @param options - Optional per-request overrides.
|
|
188
|
+
* @returns A {@link Result} wrapping a {@link Page} of {@link GamePass},
|
|
189
|
+
* or the {@link OpenCloudError} that caused the request to fail.
|
|
190
|
+
*/
|
|
191
|
+
list(parameters: ListGamePassesParameters, options?: RequestOptions): Promise<Result<Page<GamePass>, OpenCloudError>>;
|
|
192
|
+
/**
|
|
193
|
+
* Partially updates an existing game pass. Mirrors the upstream
|
|
194
|
+
* `204 No Content` response: a successful update yields `undefined`
|
|
195
|
+
* data. Callers that need the post-update state (for example to
|
|
196
|
+
* observe a server-derived `updatedAt`) chain
|
|
197
|
+
* {@link GamePassesClient.get} themselves so the GET only fires when
|
|
198
|
+
* actually needed.
|
|
199
|
+
*
|
|
200
|
+
* @param parameters - The universe and game pass identifiers and the
|
|
201
|
+
* fields to update. Only fields explicitly provided are forwarded.
|
|
202
|
+
* @param options - Optional per-request overrides.
|
|
203
|
+
* @returns A success {@link Result} with no payload, or the
|
|
204
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
205
|
+
*/
|
|
206
|
+
update(parameters: UpdateGamePassParameters, options?: RequestOptions): Promise<Result<undefined, OpenCloudError>>;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
export { type CreateGamePassParameters, type GamePass, type GamePassPrice, type GamePassPricingFeature, GamePassesClient, type GetGamePassParameters, type ListGamePassesParameters, type UpdateGamePassParameters };
|
|
210
|
+
//# sourceMappingURL=game-passes.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-passes.d.mts","names":[],"sources":["../src/domains/game-passes/game-passes/types.ts","../src/resources/game-passes/client.ts"],"mappings":";;;;;;AAIA;KAAY,sBAAA;;;;UASK,aAAA;EAAA;EAAA,SAEP,mBAAA;EAEiB;EAAA,SAAjB,eAAA,EAAiB,aAAA,CAAc,sBAAA;AAAA;;;;;AAQzC;UAAiB,QAAA;;WAEP,EAAA;;WAEA,IAAA;;WAEA,SAAA,EAAW,IAAA;;WAEX,WAAA;;WAEA,WAAA;;WAEA,SAAA;;W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+
import { i as ApiError } from "./rate-limit-BBU_4xnZ.mjs";
|
|
2
|
+
import { t as toBlob } from "./to-blob-1BtHsDGK.mjs";
|
|
3
|
+
import { a as IDEMPOTENT_METHOD_DEFAULTS, i as CREATE_METHOD_DEFAULTS, n as okRequest, o as isRecord, r as parseEmptyResponse, t as ResourceClient } from "./resource-client-CaS_j3yg.mjs";
|
|
4
|
+
import { n as isPriceInformationLike, t as copyPriceInformation } from "./price-information-CmpscMc4.mjs";
|
|
5
|
+
//#region src/domains/game-passes/game-passes/builders.ts
|
|
6
|
+
/**
|
|
7
|
+
* Builds a `GET` request for the Open Cloud "read game pass" endpoint.
|
|
8
|
+
*
|
|
9
|
+
* @param parameters - Universe and game pass identifiers to interpolate into
|
|
10
|
+
* the URL.
|
|
11
|
+
* @returns A pure {@link HttpRequest} describing the read call.
|
|
12
|
+
*/
|
|
13
|
+
function buildGetRequest(parameters) {
|
|
14
|
+
return {
|
|
15
|
+
method: "GET",
|
|
16
|
+
url: `/game-passes/v1/universes/${parameters.universeId}/game-passes/${parameters.gamePassId}/creator`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builds a `GET` request for the Open Cloud "list game passes" endpoint.
|
|
21
|
+
* Optional `pageSize` and `pageToken` are appended to the query string only
|
|
22
|
+
* when defined so the server applies its own defaults for omitted fields.
|
|
23
|
+
*
|
|
24
|
+
* @param parameters - Universe identifier plus optional pagination cursors.
|
|
25
|
+
* @returns A pure {@link HttpRequest} describing the list call.
|
|
26
|
+
*/
|
|
27
|
+
function buildListRequest(parameters) {
|
|
28
|
+
const query = new URLSearchParams();
|
|
29
|
+
if (parameters.pageSize !== void 0) query.append("pageSize", String(parameters.pageSize));
|
|
30
|
+
if (parameters.pageToken !== void 0) query.append("pageToken", parameters.pageToken);
|
|
31
|
+
const queryString = query.toString();
|
|
32
|
+
const base = `/game-passes/v1/universes/${parameters.universeId}/game-passes/creator`;
|
|
33
|
+
return {
|
|
34
|
+
method: "GET",
|
|
35
|
+
url: queryString === "" ? base : `${base}?${queryString}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds a `POST` request for the Open Cloud "create game pass" endpoint.
|
|
40
|
+
*
|
|
41
|
+
* @param parameters - Fields describing the new game pass; optional values
|
|
42
|
+
* omitted here are left off the multipart payload entirely.
|
|
43
|
+
* @returns A pure {@link HttpRequest} describing the create call.
|
|
44
|
+
*/
|
|
45
|
+
function buildCreateRequest(parameters) {
|
|
46
|
+
const body = new FormData();
|
|
47
|
+
body.append("name", parameters.name);
|
|
48
|
+
if (parameters.description !== void 0) body.append("description", parameters.description);
|
|
49
|
+
if (parameters.isForSale !== void 0) body.append("isForSale", String(parameters.isForSale));
|
|
50
|
+
if (parameters.price !== void 0) body.append("price", String(parameters.price));
|
|
51
|
+
if (parameters.isRegionalPricingEnabled !== void 0) body.append("isRegionalPricingEnabled", String(parameters.isRegionalPricingEnabled));
|
|
52
|
+
if (parameters.imageFile !== void 0) body.append("imageFile", toBlob(parameters.imageFile));
|
|
53
|
+
return {
|
|
54
|
+
body,
|
|
55
|
+
method: "POST",
|
|
56
|
+
url: `/game-passes/v1/universes/${parameters.universeId}/game-passes`
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Builds a `PATCH` request for the Open Cloud "update game pass" endpoint.
|
|
61
|
+
* Every field on `parameters` except the identifiers is optional;
|
|
62
|
+
* omitted fields are not appended to the multipart body so the server
|
|
63
|
+
* leaves their current values unchanged.
|
|
64
|
+
*
|
|
65
|
+
* The public parameter `imageFile` is mapped to the wire's `file`
|
|
66
|
+
* multipart field name, matching the OpenAPI schema for this endpoint
|
|
67
|
+
* (the create endpoint uses `imageFile`, but the update endpoint uses
|
|
68
|
+
* `file`). Public consumers stay with one ergonomic name across both
|
|
69
|
+
* methods.
|
|
70
|
+
*
|
|
71
|
+
* @param parameters - Identifiers plus fields to update.
|
|
72
|
+
* @returns A pure {@link HttpRequest} describing the update call.
|
|
73
|
+
*/
|
|
74
|
+
function buildUpdateRequest(parameters) {
|
|
75
|
+
const body = new FormData();
|
|
76
|
+
if (parameters.name !== void 0) body.append("name", parameters.name);
|
|
77
|
+
if (parameters.description !== void 0) body.append("description", parameters.description);
|
|
78
|
+
if (parameters.isForSale !== void 0) body.append("isForSale", String(parameters.isForSale));
|
|
79
|
+
if (parameters.price !== void 0) body.append("price", String(parameters.price));
|
|
80
|
+
if (parameters.isRegionalPricingEnabled !== void 0) body.append("isRegionalPricingEnabled", String(parameters.isRegionalPricingEnabled));
|
|
81
|
+
if (parameters.imageFile !== void 0) body.append("file", toBlob(parameters.imageFile));
|
|
82
|
+
return {
|
|
83
|
+
body,
|
|
84
|
+
method: "PATCH",
|
|
85
|
+
url: `/game-passes/v1/universes/${parameters.universeId}/game-passes/${parameters.gamePassId}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/domains/game-passes/game-passes/operations.ts
|
|
90
|
+
/**
|
|
91
|
+
* Per-second request ceiling for reading a single game pass, from the
|
|
92
|
+
* Open Cloud OpenAPI schema.
|
|
93
|
+
*/
|
|
94
|
+
const GET_OPERATION_LIMIT = Object.freeze({
|
|
95
|
+
maxPerSecond: 10,
|
|
96
|
+
operationKey: "game-passes.get"
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Per-second request ceiling for creating a game pass, from the Open
|
|
100
|
+
* Cloud OpenAPI schema.
|
|
101
|
+
*/
|
|
102
|
+
const CREATE_OPERATION_LIMIT = Object.freeze({
|
|
103
|
+
maxPerSecond: 5,
|
|
104
|
+
operationKey: "game-passes.create"
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Per-second request ceiling for updating a game pass, from the Open
|
|
108
|
+
* Cloud OpenAPI schema. Keyed independently from
|
|
109
|
+
* {@link CREATE_OPERATION_LIMIT} so create and update do not share a
|
|
110
|
+
* queue, since the schema does not document the per-second quota as
|
|
111
|
+
* shared between the POST and PATCH endpoints.
|
|
112
|
+
*/
|
|
113
|
+
const UPDATE_OPERATION_LIMIT = Object.freeze({
|
|
114
|
+
maxPerSecond: 5,
|
|
115
|
+
operationKey: "game-passes.update"
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Per-second request ceiling for listing game passes for a universe,
|
|
119
|
+
* from the Open Cloud OpenAPI schema.
|
|
120
|
+
*/
|
|
121
|
+
const LIST_OPERATION_LIMIT = Object.freeze({
|
|
122
|
+
maxPerSecond: 10,
|
|
123
|
+
operationKey: "game-passes.list"
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Scopes required to read a game pass, sourced from `x-roblox-scopes`
|
|
127
|
+
* on the `GamePasses_GetGamePassConfig` operation in the vendored
|
|
128
|
+
* OpenAPI schema.
|
|
129
|
+
*/
|
|
130
|
+
const GET_REQUIRED_SCOPES = Object.freeze(["game-pass:read"]);
|
|
131
|
+
/**
|
|
132
|
+
* Scopes required to create a game pass, sourced from `x-roblox-scopes`
|
|
133
|
+
* on the `GamePasses_CreateGamePass` operation in the vendored OpenAPI
|
|
134
|
+
* schema.
|
|
135
|
+
*/
|
|
136
|
+
const CREATE_REQUIRED_SCOPES = Object.freeze(["game-pass:write"]);
|
|
137
|
+
/**
|
|
138
|
+
* Scopes required to update a game pass, sourced from `x-roblox-scopes`
|
|
139
|
+
* on the `GamePasses_UpdateGamePass` operation in the vendored OpenAPI
|
|
140
|
+
* schema.
|
|
141
|
+
*/
|
|
142
|
+
const UPDATE_REQUIRED_SCOPES = Object.freeze(["game-pass:write"]);
|
|
143
|
+
/**
|
|
144
|
+
* Scopes required to list game passes for a universe, sourced from
|
|
145
|
+
* `x-roblox-scopes` on the `GamePasses_ListGamePassConfigsByUniverse`
|
|
146
|
+
* operation in the vendored OpenAPI schema.
|
|
147
|
+
*/
|
|
148
|
+
const LIST_REQUIRED_SCOPES = Object.freeze(["game-pass:read"]);
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/domains/game-passes/game-passes/parsers.ts
|
|
151
|
+
/**
|
|
152
|
+
* Parses a successful Game Pass API response into the public `GamePass`
|
|
153
|
+
* shape, returning a `Result` so callers can handle malformed payloads
|
|
154
|
+
* without exceptions.
|
|
155
|
+
*
|
|
156
|
+
* @param response - The full {@link HttpResponse} from the Open Cloud API.
|
|
157
|
+
* The status code is included on the returned `ApiError` when validation
|
|
158
|
+
* fails; the headers are available for future parsers that need them.
|
|
159
|
+
* @returns A success result wrapping the converted `GamePass`, or an
|
|
160
|
+
* `ApiError` when the body does not match the wire schema.
|
|
161
|
+
*/
|
|
162
|
+
function parseGamePassResponse(response) {
|
|
163
|
+
const { body, status: statusCode } = response;
|
|
164
|
+
if (!isGamePassConfigV2(body)) return {
|
|
165
|
+
err: new ApiError("Malformed game pass response", { statusCode }),
|
|
166
|
+
success: false
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
data: toGamePass(body),
|
|
170
|
+
success: true
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parses a successful "list game passes" response into a public
|
|
175
|
+
* {@link Page} of {@link GamePass}, returning a `Result` so callers can
|
|
176
|
+
* handle malformed payloads without exceptions. JSON `null` or a missing
|
|
177
|
+
* `nextPageToken` is normalized to `undefined`.
|
|
178
|
+
*
|
|
179
|
+
* @param response - The full {@link HttpResponse} from the Open Cloud API.
|
|
180
|
+
* @returns A success result wrapping the converted page, or an
|
|
181
|
+
* `ApiError` when the body does not match the wire schema.
|
|
182
|
+
*/
|
|
183
|
+
function parseGamePassesListResponse(response) {
|
|
184
|
+
const { body, status: statusCode } = response;
|
|
185
|
+
if (!isListResponseWire(body)) return {
|
|
186
|
+
err: new ApiError("Malformed game passes list response", { statusCode }),
|
|
187
|
+
success: false
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
data: {
|
|
191
|
+
items: body.gamePasses.map(toGamePass),
|
|
192
|
+
nextPageToken: body.nextPageToken ?? void 0
|
|
193
|
+
},
|
|
194
|
+
success: true
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function toGamePass(wire) {
|
|
198
|
+
const priceWire = wire.priceInformation ?? void 0;
|
|
199
|
+
return {
|
|
200
|
+
id: String(wire.gamePassId),
|
|
201
|
+
name: wire.name,
|
|
202
|
+
createdAt: new Date(wire.createdTimestamp),
|
|
203
|
+
description: wire.description,
|
|
204
|
+
iconAssetId: wire.iconAssetId === 0 ? void 0 : String(wire.iconAssetId),
|
|
205
|
+
isForSale: wire.isForSale,
|
|
206
|
+
price: priceWire === void 0 ? void 0 : copyPriceInformation(priceWire),
|
|
207
|
+
updatedAt: new Date(wire.updatedTimestamp)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function hasRequiredPrimitiveFields(body) {
|
|
211
|
+
return typeof body["gamePassId"] === "number" && typeof body["name"] === "string" && typeof body["description"] === "string" && typeof body["isForSale"] === "boolean" && typeof body["iconAssetId"] === "number" && typeof body["createdTimestamp"] === "string" && typeof body["updatedTimestamp"] === "string";
|
|
212
|
+
}
|
|
213
|
+
function isPricingFeatureWire(value) {
|
|
214
|
+
return value === "Invalid" || value === "PriceOptimization" || value === "RegionalPricing" || value === "UserFixedPrice";
|
|
215
|
+
}
|
|
216
|
+
function isGamePassConfigV2(body) {
|
|
217
|
+
if (!isRecord(body)) return false;
|
|
218
|
+
if (!hasRequiredPrimitiveFields(body)) return false;
|
|
219
|
+
const price = body["priceInformation"] ?? void 0;
|
|
220
|
+
if (price !== void 0 && !isPriceInformationLike(price, isPricingFeatureWire)) return false;
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
function isListResponseWire(body) {
|
|
224
|
+
if (!isRecord(body)) return false;
|
|
225
|
+
const { gamePasses } = body;
|
|
226
|
+
if (!Array.isArray(gamePasses)) return false;
|
|
227
|
+
for (const item of gamePasses) if (!isGamePassConfigV2(item)) return false;
|
|
228
|
+
const nextPageToken = body["nextPageToken"] ?? void 0;
|
|
229
|
+
if (nextPageToken !== void 0 && typeof nextPageToken !== "string") return false;
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/resources/game-passes/client.ts
|
|
234
|
+
function makeSpec(spec) {
|
|
235
|
+
return Object.freeze(spec);
|
|
236
|
+
}
|
|
237
|
+
const CREATE_SPEC = makeSpec({
|
|
238
|
+
buildRequest: (parameters) => okRequest(buildCreateRequest(parameters)),
|
|
239
|
+
methodDefaults: CREATE_METHOD_DEFAULTS,
|
|
240
|
+
methodKind: "create",
|
|
241
|
+
operationLimit: CREATE_OPERATION_LIMIT,
|
|
242
|
+
parse: parseGamePassResponse,
|
|
243
|
+
requiredScopes: CREATE_REQUIRED_SCOPES
|
|
244
|
+
});
|
|
245
|
+
const GET_SPEC = makeSpec({
|
|
246
|
+
buildRequest: (parameters) => okRequest(buildGetRequest(parameters)),
|
|
247
|
+
methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,
|
|
248
|
+
methodKind: "idempotent",
|
|
249
|
+
operationLimit: GET_OPERATION_LIMIT,
|
|
250
|
+
parse: parseGamePassResponse,
|
|
251
|
+
requiredScopes: GET_REQUIRED_SCOPES
|
|
252
|
+
});
|
|
253
|
+
const UPDATE_SPEC = makeSpec({
|
|
254
|
+
buildRequest: (parameters) => okRequest(buildUpdateRequest(parameters)),
|
|
255
|
+
methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,
|
|
256
|
+
methodKind: "idempotent",
|
|
257
|
+
operationLimit: UPDATE_OPERATION_LIMIT,
|
|
258
|
+
parse: parseEmptyResponse,
|
|
259
|
+
requiredScopes: UPDATE_REQUIRED_SCOPES
|
|
260
|
+
});
|
|
261
|
+
const LIST_SPEC = makeSpec({
|
|
262
|
+
buildRequest: (parameters) => okRequest(buildListRequest(parameters)),
|
|
263
|
+
methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,
|
|
264
|
+
methodKind: "idempotent",
|
|
265
|
+
operationLimit: LIST_OPERATION_LIMIT,
|
|
266
|
+
parse: parseGamePassesListResponse,
|
|
267
|
+
requiredScopes: LIST_REQUIRED_SCOPES
|
|
268
|
+
});
|
|
269
|
+
/**
|
|
270
|
+
* Public client for the Roblox Open Cloud Game Passes API.
|
|
271
|
+
*
|
|
272
|
+
* Wires request builders, the injected {@link OpenCloudClientOptions.httpClient}, and response
|
|
273
|
+
* parsers into a single ergonomic surface. Every method returns a
|
|
274
|
+
* {@link Result} so callers handle failure explicitly; no thrown
|
|
275
|
+
* `OpenCloudError` ever escapes the client.
|
|
276
|
+
*
|
|
277
|
+
* ```ts
|
|
278
|
+
* import { GamePassesClient } from "@bedrock-rbx/ocale/game-passes";
|
|
279
|
+
*
|
|
280
|
+
* const client = new GamePassesClient({ apiKey: process.env.ROBLOX_API_KEY! });
|
|
281
|
+
*
|
|
282
|
+
* const result = await client.get({
|
|
283
|
+
* universeId: "1234567890",
|
|
284
|
+
* gamePassId: "9876543210",
|
|
285
|
+
* });
|
|
286
|
+
*
|
|
287
|
+
* if (result.success) {
|
|
288
|
+
* console.log(`${result.data.name} (${result.data.id})`);
|
|
289
|
+
* } else {
|
|
290
|
+
* console.error(result.err.message);
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* Listing is cursor-paginated; drive the loop on `nextPageToken`:
|
|
295
|
+
*
|
|
296
|
+
* ```ts
|
|
297
|
+
* let pageToken: string | undefined;
|
|
298
|
+
* do {
|
|
299
|
+
* const page = await client.list({ universeId: "1234567890", pageToken });
|
|
300
|
+
* if (!page.success) {
|
|
301
|
+
* console.error(page.err.message);
|
|
302
|
+
* break;
|
|
303
|
+
* }
|
|
304
|
+
*
|
|
305
|
+
* for (const pass of page.data.items) {
|
|
306
|
+
* console.log(`${pass.name} (${pass.id})`);
|
|
307
|
+
* }
|
|
308
|
+
*
|
|
309
|
+
* pageToken = page.data.nextPageToken;
|
|
310
|
+
* } while (pageToken !== undefined);
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
var GamePassesClient = class {
|
|
314
|
+
#inner;
|
|
315
|
+
/**
|
|
316
|
+
* Creates a new {@link GamePassesClient}. Configuration is frozen on
|
|
317
|
+
* construction; per-request overrides are accepted on each method.
|
|
318
|
+
*
|
|
319
|
+
* @param options - Client-level configuration including the API key.
|
|
320
|
+
*/
|
|
321
|
+
constructor(options) {
|
|
322
|
+
this.#inner = new ResourceClient(options);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Creates a new game pass under the supplied universe.
|
|
326
|
+
*
|
|
327
|
+
* @param parameters - Creation fields including the universe and pass name.
|
|
328
|
+
* @param options - Optional per-request overrides.
|
|
329
|
+
* @returns A {@link Result} wrapping the parsed {@link GamePass} or the
|
|
330
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
331
|
+
*/
|
|
332
|
+
async create(parameters, options) {
|
|
333
|
+
return this.#inner.execute({
|
|
334
|
+
options,
|
|
335
|
+
parameters,
|
|
336
|
+
spec: CREATE_SPEC
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Reads a single game pass by ID.
|
|
341
|
+
*
|
|
342
|
+
* @param parameters - Universe and game pass identifiers.
|
|
343
|
+
* @param options - Optional per-request overrides (e.g. A different
|
|
344
|
+
* {@link OpenCloudClientOptions.apiKey} for this call only).
|
|
345
|
+
* @returns A {@link Result} wrapping the parsed {@link GamePass} or the
|
|
346
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
347
|
+
*/
|
|
348
|
+
async get(parameters, options) {
|
|
349
|
+
return this.#inner.execute({
|
|
350
|
+
options,
|
|
351
|
+
parameters,
|
|
352
|
+
spec: GET_SPEC
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Lists one page of game passes for the supplied universe. Pagination is
|
|
357
|
+
* cursor-based: omit `pageToken` for the first page, then thread the
|
|
358
|
+
* previous response's `nextPageToken` back in until it is `undefined`.
|
|
359
|
+
*
|
|
360
|
+
* @param parameters - Universe identifier and optional page cursors.
|
|
361
|
+
* @param options - Optional per-request overrides.
|
|
362
|
+
* @returns A {@link Result} wrapping a {@link Page} of {@link GamePass},
|
|
363
|
+
* or the {@link OpenCloudError} that caused the request to fail.
|
|
364
|
+
*/
|
|
365
|
+
async list(parameters, options) {
|
|
366
|
+
return this.#inner.execute({
|
|
367
|
+
options,
|
|
368
|
+
parameters,
|
|
369
|
+
spec: LIST_SPEC
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Partially updates an existing game pass. Mirrors the upstream
|
|
374
|
+
* `204 No Content` response: a successful update yields `undefined`
|
|
375
|
+
* data. Callers that need the post-update state (for example to
|
|
376
|
+
* observe a server-derived `updatedAt`) chain
|
|
377
|
+
* {@link GamePassesClient.get} themselves so the GET only fires when
|
|
378
|
+
* actually needed.
|
|
379
|
+
*
|
|
380
|
+
* @param parameters - The universe and game pass identifiers and the
|
|
381
|
+
* fields to update. Only fields explicitly provided are forwarded.
|
|
382
|
+
* @param options - Optional per-request overrides.
|
|
383
|
+
* @returns A success {@link Result} with no payload, or the
|
|
384
|
+
* {@link OpenCloudError} that caused the request to fail.
|
|
385
|
+
*/
|
|
386
|
+
async update(parameters, options) {
|
|
387
|
+
return this.#inner.execute({
|
|
388
|
+
options,
|
|
389
|
+
parameters,
|
|
390
|
+
spec: UPDATE_SPEC
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
//#endregion
|
|
395
|
+
export { GamePassesClient };
|
|
396
|
+
|
|
397
|
+
//# sourceMappingURL=game-passes.mjs.map
|