@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,9 +1,10 @@
1
- import { a as ApiError } from "./network-error-DR9FX5hb.mjs";
2
- import { r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS } from "./retry-BlX4tUnT.mjs";
3
- import { t as ValidationError } from "./validation-B_Zs1So2.mjs";
4
- import { t as toBlob } from "./to-blob-RPqMBuft.mjs";
5
- import { c as isDateTimeString, n as okRequest, o as toJsonDetails, r as parseEmptyResponse, s as isRecord, t as ResourceClient } from "./resource-client-rqTMkBeR.mjs";
6
- //#region src/internal/utils/positive-integer-id.ts
1
+ import { t as ValidationError } from "./validation-kaTLLAD1.mjs";
2
+ import { n as okRequest, r as parseEmptyResponse, s as toJsonDetails, t as ResourceClient } from "./resource-client-Cm_bPcCs.mjs";
3
+ import { N as isRecord, m as UnexpectedResponseError, r as IDEMPOTENT_METHOD_DEFAULTS, t as CREATE_METHOD_DEFAULTS } from "./retry-Dv5TsY9O.mjs";
4
+ import { t as isDateTimeString } from "./is-date-time-string-C91G44SI.mjs";
5
+ import { t as toBlob } from "./to-blob-Bqu7bmlE.mjs";
6
+ import { a as ApiError, o as requestContextOf } from "./network-error-P4An7nUB.mjs";
7
+ // src/internal/utils/positive-integer-id.ts
7
8
  const POSITIVE_INTEGER_PATTERN = /^[1-9]\d*$/;
8
9
  /**
9
10
  * Parses stringified Roblox IDs for a wire field typed as an integer array.
@@ -16,10 +17,13 @@ const POSITIVE_INTEGER_PATTERN = /^[1-9]\d*$/;
16
17
  */
17
18
  function parsePositiveIntegerIds(ids, { code, field }) {
18
19
  const invalid = ids.find((id) => parsePositiveIntegerId(id) === void 0);
19
- if (invalid !== void 0) return {
20
- err: new ValidationError(`${field} entry ${JSON.stringify(invalid)} is not a positive integer ID`, { code }),
21
- success: false
22
- };
20
+ if (invalid !== void 0) {
21
+ const message = `${field} entry ${JSON.stringify(invalid)} is not a positive integer ID`;
22
+ return {
23
+ err: new ValidationError(message, { code }),
24
+ success: false
25
+ };
26
+ }
23
27
  return {
24
28
  data: ids.map(Number),
25
29
  success: true
@@ -30,8 +34,7 @@ function parsePositiveIntegerId(value) {
30
34
  const parsed = Number(value);
31
35
  return Number.isSafeInteger(parsed) ? parsed : void 0;
32
36
  }
33
- //#endregion
34
- //#region src/domains/cloud-v2/universes/builders.ts
37
+ // src/domains/cloud-v2/universes/builders.ts
35
38
  /**
36
39
  * Dodges `unicorn/no-null` while still emitting a literal `null` onto
37
40
  * the wire, which the Open Cloud `Cloud_UpdateUniverse` endpoint
@@ -125,8 +128,7 @@ function bodyValueFor(parameters, key) {
125
128
  const value = Reflect.get(parameters, key);
126
129
  return value === void 0 ? NULL_SENTINEL : value;
127
130
  }
128
- //#endregion
129
- //#region src/domains/cloud-v2/universes/operations.ts
131
+ // src/domains/cloud-v2/universes/operations.ts
130
132
  const PER_MINUTE$1 = 100;
131
133
  const RESTART_SERVERS_PER_MINUTE = 30;
132
134
  const SECONDS_PER_MINUTE$1 = 60;
@@ -176,8 +178,7 @@ const RESTART_OPERATION_LIMIT = Object.freeze({
176
178
  * vendored OpenAPI schema.
177
179
  */
178
180
  const RESTART_REQUIRED_SCOPES = Object.freeze(["universe:write"]);
179
- //#endregion
180
- //#region src/domains/cloud-v2/universes/parsers.ts
181
+ // src/domains/cloud-v2/universes/parsers.ts
181
182
  const VISIBILITY_MAP = {
182
183
  PRIVATE: "private",
183
184
  PUBLIC: "public",
@@ -200,7 +201,8 @@ const OWNER_PATH_PATTERN = /^(?:users|groups)\/(\d+)$/;
200
201
  *
201
202
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
202
203
  * @returns A success result wrapping the parsed {@link Universe}, or
203
- * an {@link ApiError} when the body does not match the wire schema.
204
+ * an {@link UnexpectedResponseError} when the body does not match the wire
205
+ * schema.
204
206
  */
205
207
  function parseUniverseResponse({ body, status: statusCode }) {
206
208
  if (!isUniverseWire(body)) return malformed$1(statusCode, body);
@@ -219,7 +221,7 @@ function parseUniverseResponse({ body, status: statusCode }) {
219
221
  }
220
222
  function malformed$1(statusCode, body) {
221
223
  return {
222
- err: new ApiError(MALFORMED_MESSAGE, {
224
+ err: new UnexpectedResponseError(MALFORMED_MESSAGE, {
223
225
  details: toJsonDetails(body),
224
226
  statusCode
225
227
  }),
@@ -323,8 +325,7 @@ function resolveOwner(body) {
323
325
  success: false
324
326
  };
325
327
  }
326
- //#endregion
327
- //#region src/domains/game-internationalization/game-icon/builders.ts
328
+ // src/domains/game-internationalization/game-icon/builders.ts
328
329
  /**
329
330
  * Builds a `POST` request for the localized "upload experience icon"
330
331
  * endpoint. A successful upload replaces any existing icon for the same
@@ -371,15 +372,15 @@ function buildListIconsRequest(parameters) {
371
372
  url: `/legacy-game-internationalization/v1/game-icon/games/${parameters.universeId}`
372
373
  };
373
374
  }
374
- //#endregion
375
- //#region src/domains/game-internationalization/game-icon/operations.ts
375
+ // src/domains/game-internationalization/game-icon/operations.ts
376
376
  /**
377
- * Per-second request ceiling for every game-icon Operation bound on
378
- * `UniversesClient.icon`. The legacy `gameinternationalization` service caps
379
- * each API key at 100 requests per minute *shared across the entire service*
380
- * (see the `x-roblox-rate-limits` extension on every operation in the
381
- * vendored Open Cloud spec), so all methods queue against the same operation
382
- * key.
377
+ * Per-second request ceiling for game-icon Operations on
378
+ * `UniversesClient.icon`, from each operation's
379
+ * `x-roblox-rate-limits.perApiKeyOwner` in the vendored schema (100 requests
380
+ * per minute). This family's key stays separate from other
381
+ * game-internationalization families: the #587 probe measured independent
382
+ * reported 100/minute counters. Successful writes may have additional service
383
+ * limits; see `docs/spikes/game-internationalization-rate-limits/README.md`.
383
384
  */
384
385
  const ICON_OPERATION_LIMIT = Object.freeze({
385
386
  maxPerSecond: 100 / 60,
@@ -391,19 +392,18 @@ const ICON_OPERATION_LIMIT = Object.freeze({
391
392
  * endpoints in the vendored OpenAPI schema.
392
393
  */
393
394
  const ICON_REQUIRED_SCOPES = Object.freeze(["legacy-universe:manage"]);
394
- //#endregion
395
- //#region src/domains/game-internationalization/game-icon/parsers.ts
395
+ // src/domains/game-internationalization/game-icon/parsers.ts
396
396
  /**
397
397
  * Parses a successful icon-list response into a public array of
398
398
  * {@link ExperienceIcon} entries.
399
399
  *
400
400
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
401
401
  * @returns A success result wrapping the converted icon list, or an
402
- * `ApiError` when the body does not match the wire schema.
402
+ * `UnexpectedResponseError` when the body does not match the wire schema.
403
403
  */
404
404
  function parseIconListResponse({ body, status: statusCode }) {
405
405
  if (!isGameIconListWire(body)) return {
406
- err: new ApiError("Malformed icon list response", {
406
+ err: new UnexpectedResponseError("Malformed icon list response", {
407
407
  details: toJsonDetails(body),
408
408
  statusCode
409
409
  }),
@@ -419,7 +419,7 @@ function isGameIconState(value) {
419
419
  }
420
420
  function isGetGameIconResponseWire(value) {
421
421
  if (!isRecord(value)) return false;
422
- return typeof value["imageId"] === "string" && typeof value["imageUrl"] === "string" && typeof value["languageCode"] === "string" && isGameIconState(value["state"]);
422
+ return (value["imageId"] === null || typeof value["imageId"] === "string") && typeof value["imageUrl"] === "string" && typeof value["languageCode"] === "string" && isGameIconState(value["state"]);
423
423
  }
424
424
  function isGameIconListWire(body) {
425
425
  if (!isRecord(body)) return false;
@@ -429,14 +429,13 @@ function isGameIconListWire(body) {
429
429
  }
430
430
  function toExperienceIcon(wire) {
431
431
  return {
432
- imageId: wire.imageId,
432
+ imageId: wire.imageId ?? void 0,
433
433
  imageUrl: wire.imageUrl,
434
434
  languageCode: wire.languageCode,
435
435
  state: wire.state
436
436
  };
437
437
  }
438
- //#endregion
439
- //#region src/domains/game-internationalization/game-thumbnails/builders.ts
438
+ // src/domains/game-internationalization/game-thumbnails/builders.ts
440
439
  /**
441
440
  * Builds a `POST` request for the localized "upload experience thumbnail"
442
441
  * endpoint. Each successful upload appends a new entry to the carousel.
@@ -499,15 +498,16 @@ function parseOrderedImageIds(orderedImageIds) {
499
498
  field: "orderedImageIds"
500
499
  });
501
500
  }
502
- //#endregion
503
- //#region src/domains/game-internationalization/game-thumbnails/operations.ts
501
+ // src/domains/game-internationalization/game-thumbnails/operations.ts
504
502
  /**
505
- * Per-second request ceiling for every game-thumbnails Operation bound on
506
- * `UniversesClient.thumbnails`. The legacy `gameinternationalization`
507
- * service caps each API key at 100 requests per minute *shared across the
508
- * entire service* (see the `x-roblox-rate-limits` extension on every
509
- * operation in the vendored Open Cloud spec), so all methods queue against
510
- * the same operation key.
503
+ * Per-second request ceiling for game-thumbnails Operations on
504
+ * `UniversesClient.thumbnails`, from each operation's
505
+ * `x-roblox-rate-limits.perApiKeyOwner` in the vendored schema (100 requests
506
+ * per minute). This family's key stays separate from other
507
+ * game-internationalization families: the #587 probe measured independent
508
+ * reported 100/minute counters on rejected requests. Successful writes may
509
+ * have additional service limits; see
510
+ * `docs/spikes/game-internationalization-rate-limits/README.md`.
511
511
  */
512
512
  const THUMBNAILS_OPERATION_LIMIT = Object.freeze({
513
513
  maxPerSecond: 100 / 60,
@@ -519,8 +519,7 @@ const THUMBNAILS_OPERATION_LIMIT = Object.freeze({
519
519
  * endpoints in the vendored OpenAPI schema.
520
520
  */
521
521
  const THUMBNAILS_REQUIRED_SCOPES = Object.freeze(["legacy-universe:manage"]);
522
- //#endregion
523
- //#region src/domains/game-internationalization/game-thumbnails/parsers.ts
522
+ // src/domains/game-internationalization/game-thumbnails/parsers.ts
524
523
  /**
525
524
  * Parses a successful thumbnail-upload response into the public
526
525
  * {@link UploadedExperienceThumbnail} shape, returning a {@link Result}
@@ -528,11 +527,11 @@ const THUMBNAILS_REQUIRED_SCOPES = Object.freeze(["legacy-universe:manage"]);
528
527
  *
529
528
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
530
529
  * @returns A success result wrapping the converted upload, or an
531
- * `ApiError` when the body does not match the wire schema.
530
+ * `UnexpectedResponseError` when the body does not match the wire schema.
532
531
  */
533
532
  function parseThumbnailUploadResponse({ body, status: statusCode }) {
534
533
  if (!isGameThumbnailUploadWire(body)) return {
535
- err: new ApiError("Malformed thumbnail upload response", {
534
+ err: new UnexpectedResponseError("Malformed thumbnail upload response", {
536
535
  details: toJsonDetails(body),
537
536
  statusCode
538
537
  }),
@@ -547,8 +546,122 @@ function isGameThumbnailUploadWire(body) {
547
546
  if (!isRecord(body)) return false;
548
547
  return typeof body["mediaAssetId"] === "string";
549
548
  }
550
- //#endregion
551
- //#region src/domains/server-management/restarts/builders.ts
549
+ // src/domains/develop/universes/builders.ts
550
+ /**
551
+ * Builds the Open Cloud experience activation request.
552
+ * @param parameters - The universe identifier.
553
+ * @returns The POST request wrapped in a success Result.
554
+ */
555
+ function buildActivateRequest(parameters) {
556
+ return okRequest({
557
+ method: "POST",
558
+ url: `/legacy-develop/v1/universes/${parameters.universeId}/activate`
559
+ });
560
+ }
561
+ /**
562
+ * Builds the Open Cloud experience deactivation request.
563
+ * @param parameters - The universe identifier.
564
+ * @returns The POST request wrapped in a success Result.
565
+ */
566
+ function buildDeactivateRequest(parameters) {
567
+ return okRequest({
568
+ method: "POST",
569
+ url: `/legacy-develop/v1/universes/${parameters.universeId}/deactivate`
570
+ });
571
+ }
572
+ // src/domains/develop/universes/operations.ts
573
+ /**
574
+ * OpenAPI specifies 100 requests per minute per API key owner or OAuth
575
+ * authorization.
576
+ */
577
+ const ACTIVATE_OPERATION_LIMIT = Object.freeze({
578
+ maxPerSecond: 100 / 60,
579
+ operationKey: "universes.activate"
580
+ });
581
+ /**
582
+ * OpenAPI specifies 100 requests per minute per API key owner or OAuth
583
+ * authorization.
584
+ */
585
+ const DEACTIVATE_OPERATION_LIMIT = Object.freeze({
586
+ maxPerSecond: 100 / 60,
587
+ operationKey: "universes.deactivate"
588
+ });
589
+ /** Required scope declared by both experience visibility operations. */
590
+ const ACTIVATION_REQUIRED_SCOPES = Object.freeze(["legacy-universe:manage"]);
591
+ // src/resources/universes/activation-specs.ts
592
+ const GET_SPEC = Object.freeze({
593
+ buildRequest: buildGetRequest,
594
+ methodDefaults: {},
595
+ methodKind: "idempotent",
596
+ operationLimit: GET_OPERATION_LIMIT,
597
+ parse: parseUniverseResponse
598
+ });
599
+ const ACTIVATE_SPEC = Object.freeze({
600
+ buildRequest: buildActivateRequest,
601
+ methodDefaults: CREATE_METHOD_DEFAULTS,
602
+ methodKind: "create",
603
+ operationLimit: ACTIVATE_OPERATION_LIMIT,
604
+ parse: parseEmptyResponse,
605
+ requiredScopes: ACTIVATION_REQUIRED_SCOPES
606
+ });
607
+ const DEACTIVATE_SPEC = Object.freeze({
608
+ buildRequest: buildDeactivateRequest,
609
+ methodDefaults: CREATE_METHOD_DEFAULTS,
610
+ methodKind: "create",
611
+ operationLimit: DEACTIVATE_OPERATION_LIMIT,
612
+ parse: parseEmptyResponse,
613
+ requiredScopes: ACTIVATION_REQUIRED_SCOPES
614
+ });
615
+ // src/resources/universes/activation-error.ts
616
+ /**
617
+ * Adds the known eligibility explanation without diagnosing a missing rating.
618
+ *
619
+ * @param err - The activation attempt's transport error.
620
+ * @returns An error retaining the original request and response evidence.
621
+ */
622
+ function explainActivationError(err) {
623
+ if (!(err instanceof ApiError) || err.statusCode !== 403) return err;
624
+ const code = err.code ?? (isRecord(err.details) ? err.details["code"] : void 0);
625
+ if (code !== 3 && code !== "3") return err;
626
+ return new ApiError(`${err.message} A missing content maturity rating is a possible cause; complete the content questionnaire in Creator Hub.`, {
627
+ ...requestContextOf(err),
628
+ cause: err,
629
+ code: err.code,
630
+ details: err.details,
631
+ statusCode: err.statusCode
632
+ });
633
+ }
634
+ // src/resources/universes/activation.ts
635
+ /**
636
+ * Changes visibility and verifies an ambiguous gateway timeout through a read.
637
+ * @param inner - The universe client's shared request pipeline.
638
+ * @param call - The universe, desired visibility and request overrides.
639
+ * @returns A success only when the write or verification confirms it.
640
+ */
641
+ async function setVisibilityAsync(inner, { options, parameters, visibility }) {
642
+ const activating = visibility === "public";
643
+ const result = await inner.executeAsync({
644
+ options: {
645
+ ...options,
646
+ retryableStatuses: options?.retryableStatuses?.filter((status) => status !== 504) ?? CREATE_METHOD_DEFAULTS.retryableStatuses
647
+ },
648
+ parameters,
649
+ refineError: activating ? explainActivationError : void 0,
650
+ spec: activating ? ACTIVATE_SPEC : DEACTIVATE_SPEC
651
+ });
652
+ if (result.success || !(result.err instanceof ApiError) || result.err.statusCode !== 504) return result;
653
+ const observed = await inner.executeAsync({
654
+ options,
655
+ parameters,
656
+ spec: GET_SPEC
657
+ });
658
+ if (observed.success && observed.data.visibility === visibility) return {
659
+ data: void 0,
660
+ success: true
661
+ };
662
+ return result;
663
+ }
664
+ // src/domains/server-management/restarts/builders.ts
552
665
  /**
553
666
  * Builds a `GET` request for the server-management restart forecast.
554
667
  *
@@ -589,8 +702,7 @@ function buildListRequest(parameters) {
589
702
  url: `/server-management/v1/universes/${parameters.universeId}/restarts`
590
703
  });
591
704
  }
592
- //#endregion
593
- //#region src/domains/server-management/restarts/operations.ts
705
+ // src/domains/server-management/restarts/operations.ts
594
706
  const PER_MINUTE = 100;
595
707
  const SECONDS_PER_MINUTE = 60;
596
708
  /**
@@ -629,9 +741,8 @@ const LIST_OPERATION_LIMIT = Object.freeze({
629
741
  maxPerSecond: PER_MINUTE / SECONDS_PER_MINUTE,
630
742
  operationKey: "restarts.list"
631
743
  });
632
- //#endregion
633
- //#region src/domains/server-management/restarts/parsers.ts
634
- const RESTART_STATES = new Set([
744
+ // src/domains/server-management/restarts/parsers.ts
745
+ const RESTART_STATES = /* @__PURE__ */ new Set([
635
746
  "DELAYING",
636
747
  "RESTARTING",
637
748
  "SUCCEEDED"
@@ -643,7 +754,7 @@ const NIL_RESTART_ID = "00000000-0000-0000-0000-000000000000";
643
754
  * {@link PlaceRestartForecast} per place.
644
755
  *
645
756
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
646
- * @returns A success result wrapping the forecasts, or an {@link ApiError}
757
+ * @returns A success result wrapping the forecasts, or an {@link UnexpectedResponseError}
647
758
  * when the body does not match the wire schema.
648
759
  */
649
760
  function parseForecastResponse({ body, status: statusCode }) {
@@ -663,7 +774,8 @@ function parseForecastResponse({ body, status: statusCode }) {
663
774
  *
664
775
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
665
776
  * @returns A success result wrapping the launched restart, or an
666
- * {@link ApiError} when the body does not match the wire schema.
777
+ * {@link UnexpectedResponseError} when the body does not match the wire
778
+ * schema.
667
779
  */
668
780
  function parseLaunchResponse({ body, status: statusCode }) {
669
781
  if (!isLaunchWire(body)) return malformed("Malformed restart launch response", {
@@ -684,7 +796,7 @@ function parseLaunchResponse({ body, status: statusCode }) {
684
796
  * {@link RestartStatus} per restart.
685
797
  *
686
798
  * @param response - The full {@link HttpResponse} from the Open Cloud API.
687
- * @returns A success result wrapping the restarts, or an {@link ApiError}
799
+ * @returns A success result wrapping the restarts, or an {@link UnexpectedResponseError}
688
800
  * when the body does not match the wire schema.
689
801
  */
690
802
  function parseListResponse({ body, status: statusCode }) {
@@ -701,7 +813,7 @@ function parseListResponse({ body, status: statusCode }) {
701
813
  }
702
814
  function malformed(message, { body, statusCode }) {
703
815
  return {
704
- err: new ApiError(message, {
816
+ err: new UnexpectedResponseError(message, {
705
817
  details: toJsonDetails(body),
706
818
  statusCode
707
819
  }),
@@ -800,8 +912,49 @@ function isRestartStatusWire(value) {
800
912
  function isListWire(body) {
801
913
  return isRecord(body) && isOptionalRecordOf(body["restartStatuses"], isRestartStatusWire);
802
914
  }
803
- //#endregion
804
- //#region src/resources/universes/restarts-group.ts
915
+ // src/domains/server-management/restarts/select-outdated.ts
916
+ /**
917
+ * Selects the requested places whose forecast counts outdated servers. A
918
+ * place missing from the forecast has no live server and counts 0. A
919
+ * repeated place ID counts once, at its first position.
920
+ *
921
+ * @param placeIds - The requested place IDs.
922
+ * @param forecasts - The universe's restart forecast.
923
+ * @returns Each requested place with its outdated server count, and the
924
+ * places to restart.
925
+ */
926
+ function selectOutdatedPlaces(placeIds, forecasts) {
927
+ const impacted = new Map(forecasts.map((forecast) => [forecast.placeId, forecast.instancesImpacted]));
928
+ const places = Array.from(new Set(placeIds), (placeId) => {
929
+ return {
930
+ instancesImpacted: impacted.get(placeId) ?? 0,
931
+ placeId
932
+ };
933
+ });
934
+ return {
935
+ placeIds: places.filter(({ instancesImpacted }) => instancesImpacted > 0).map(({ placeId }) => placeId),
936
+ places
937
+ };
938
+ }
939
+ /**
940
+ * Builds the per-place outcome of a restart of `selection.placeIds`.
941
+ *
942
+ * @param selection - The selection that drove the final decision.
943
+ * @param restarted - Whether the restart call for the selection succeeded.
944
+ * @returns The outcome, with only the selected places marked restarted.
945
+ */
946
+ function summarizeOutdatedRestart(selection, restarted) {
947
+ return {
948
+ places: selection.places.map((place) => {
949
+ return {
950
+ ...place,
951
+ restarted: restarted && place.instancesImpacted > 0
952
+ };
953
+ }),
954
+ restarted
955
+ };
956
+ }
957
+ // src/resources/universes/restarts-group.ts
805
958
  function makeSpec(spec) {
806
959
  return Object.freeze(spec);
807
960
  }
@@ -821,6 +974,22 @@ const LAUNCH_SPEC = makeSpec({
821
974
  parse: parseLaunchResponse,
822
975
  requiredScopes: LAUNCH_REQUIRED_SCOPES
823
976
  });
977
+ const RESTART_OUTDATED_SPEC = makeSpec({
978
+ buildRequest: buildRestartServersRequest,
979
+ methodDefaults: Object.freeze({
980
+ retryableStatuses: Object.freeze([
981
+ 429,
982
+ 502,
983
+ 503,
984
+ 504
985
+ ]),
986
+ retryableTransportCodes: IDEMPOTENT_METHOD_DEFAULTS.retryableTransportCodes
987
+ }),
988
+ methodKind: "create",
989
+ operationLimit: RESTART_OPERATION_LIMIT,
990
+ parse: parseEmptyResponse,
991
+ requiredScopes: RESTART_REQUIRED_SCOPES
992
+ });
824
993
  const LIST_SPEC = makeSpec({
825
994
  buildRequest: buildListRequest,
826
995
  methodDefaults: IDEMPOTENT_METHOD_DEFAULTS,
@@ -831,8 +1000,9 @@ const LIST_SPEC = makeSpec({
831
1000
  });
832
1001
  /**
833
1002
  * Operation Group on `UniversesClient` that exposes the server-management
834
- * restart endpoints: preview a restart, launch one, and track it. The
835
- * endpoints are BETA on the Roblox side.
1003
+ * restart endpoints: preview a restart, launch one, and track it. Its
1004
+ * `restartOutdated` also uses the universe `:restartServers` method. The
1005
+ * server-management endpoints are BETA on the Roblox side.
836
1006
  */
837
1007
  var UniverseRestartsGroup = class {
838
1008
  #inner;
@@ -882,7 +1052,10 @@ var UniverseRestartsGroup = class {
882
1052
  * },
883
1053
  * status: 200,
884
1054
  * });
885
- * const client = new UniversesClient({ apiKey: "your-key", httpClient });
1055
+ * const client = new UniversesClient({
1056
+ * credential: { apiKey: "your-key", kind: "apiKey" },
1057
+ * httpClient,
1058
+ * });
886
1059
  *
887
1060
  * return client.restarts
888
1061
  * .launch({ bleedOffDurationMinutes: 5, universeId: "42" })
@@ -924,16 +1097,126 @@ var UniverseRestartsGroup = class {
924
1097
  spec: LIST_SPEC
925
1098
  });
926
1099
  }
1100
+ /**
1101
+ * Restarts only the servers that run an older version of the given
1102
+ * places, for example after a publish. It reads the forecast
1103
+ * (`universe:read`), keeps each place with at least one outdated
1104
+ * server, and sends one `:restartServers` call (`universe:write`) for
1105
+ * them. When no place has an outdated server, it sends no restart.
1106
+ *
1107
+ * Roblox answers a 500 when any listed place has no live server, which
1108
+ * happens when a place loses its last outdated server between the
1109
+ * forecast and the restart. On that 500 it reads the forecast once more
1110
+ * and sends one more restart for the places still outdated. A 502, 503
1111
+ * or 504 on the restart is retried. The selection relies on the
1112
+ * forecast's `instancesImpacted` counting only servers on an older
1113
+ * version, which live captures show but Roblox does not document.
1114
+ *
1115
+ * @example
1116
+ * ```ts
1117
+ * import { createFakeHttpClient } from "@bedrock-rbx/ocale/testing";
1118
+ * import { UniversesClient } from "@bedrock-rbx/ocale/universes";
1119
+ *
1120
+ * const httpClient = createFakeHttpClient()
1121
+ * .mockResponse({
1122
+ * body: {
1123
+ * placeForecasts: {
1124
+ * 111: {
1125
+ * instancesImpacted: 2,
1126
+ * instancesPerVersion: { 5: 2, 6: 1 },
1127
+ * isNotInUniverse: false,
1128
+ * latestPlaceVersion: "6",
1129
+ * playersImpacted: 4,
1130
+ * playersPerVersion: { 5: 4, 6: 1 },
1131
+ * publishTime: "2026-04-24T02:36:28.673Z",
1132
+ * totalInstances: 3,
1133
+ * totalPlayers: 5,
1134
+ * },
1135
+ * },
1136
+ * },
1137
+ * status: 200,
1138
+ * })
1139
+ * .mockResponse({ body: {}, status: 200 });
1140
+ * const client = new UniversesClient({
1141
+ * credential: { apiKey: "your-key", kind: "apiKey" },
1142
+ * httpClient,
1143
+ * });
1144
+ *
1145
+ * return client.restarts
1146
+ * .restartOutdated({ placeIds: ["111", "222"], universeId: "42" })
1147
+ * .then((result) => {
1148
+ * expect(result).toEqual({
1149
+ * data: {
1150
+ * places: [
1151
+ * { instancesImpacted: 2, placeId: "111", restarted: true },
1152
+ * { instancesImpacted: 0, placeId: "222", restarted: false },
1153
+ * ],
1154
+ * restarted: true,
1155
+ * },
1156
+ * success: true,
1157
+ * });
1158
+ * });
1159
+ * ```
1160
+ *
1161
+ * @param parameters - The universe and the places to check.
1162
+ * @param options - Optional per-request overrides, applied to every
1163
+ * request.
1164
+ * @returns A {@link Result} wrapping the {@link OutdatedRestart}, or
1165
+ * the {@link OpenCloudError} that caused a request to fail.
1166
+ */
1167
+ async restartOutdated({ placeIds, universeId }, options) {
1168
+ const validated = buildRestartServersRequest({
1169
+ placeIds,
1170
+ universeId
1171
+ });
1172
+ if (!validated.success) return validated;
1173
+ let selection = await this.#selectOutdated({
1174
+ placeIds,
1175
+ universeId
1176
+ }, options);
1177
+ if (!selection.success) return selection;
1178
+ let restart = await this.#restartSelected({
1179
+ placeIds: selection.data.placeIds,
1180
+ universeId
1181
+ }, options);
1182
+ if (!restart.success && restart.err instanceof ApiError && restart.err.statusCode === 500) {
1183
+ selection = await this.#selectOutdated({
1184
+ placeIds,
1185
+ universeId
1186
+ }, options);
1187
+ if (!selection.success) return selection;
1188
+ restart = await this.#restartSelected({
1189
+ placeIds: selection.data.placeIds,
1190
+ universeId
1191
+ }, options);
1192
+ }
1193
+ const restarted = selection.data.placeIds.length > 0;
1194
+ return restart.success ? {
1195
+ data: summarizeOutdatedRestart(selection.data, restarted),
1196
+ success: true
1197
+ } : restart;
1198
+ }
1199
+ async #restartSelected(parameters, options) {
1200
+ if (parameters.placeIds.length === 0) return {
1201
+ data: void 0,
1202
+ success: true
1203
+ };
1204
+ return this.#inner.executeAsync({
1205
+ options,
1206
+ parameters,
1207
+ spec: RESTART_OUTDATED_SPEC
1208
+ });
1209
+ }
1210
+ async #selectOutdated({ placeIds, universeId }, options) {
1211
+ const forecast = await this.forecast({ universeId }, options);
1212
+ if (!forecast.success) return forecast;
1213
+ return {
1214
+ data: selectOutdatedPlaces(placeIds, forecast.data),
1215
+ success: true
1216
+ };
1217
+ }
927
1218
  };
928
- //#endregion
929
- //#region src/resources/universes/client.ts
930
- const GET_SPEC = Object.freeze({
931
- buildRequest: buildGetRequest,
932
- methodDefaults: {},
933
- methodKind: "idempotent",
934
- operationLimit: GET_OPERATION_LIMIT,
935
- parse: parseUniverseResponse
936
- });
1219
+ // src/resources/universes/client.ts
937
1220
  const UPDATE_SPEC = Object.freeze({
938
1221
  buildRequest: buildUpdateRequest,
939
1222
  methodDefaults: {},
@@ -1039,7 +1322,7 @@ const THUMBNAIL_REORDER_SPEC = Object.freeze({
1039
1322
  * ```ts
1040
1323
  * import { UniversesClient } from "@bedrock-rbx/ocale/universes";
1041
1324
  *
1042
- * const client = new UniversesClient({ apiKey: "your-key" });
1325
+ * const client = new UniversesClient({ credential: { apiKey: "your-key", kind: "apiKey" } });
1043
1326
  * expect(client).toBeInstanceOf(UniversesClient);
1044
1327
  * ```
1045
1328
  */
@@ -1054,8 +1337,9 @@ var UniversesClient = class {
1054
1337
  icon;
1055
1338
  /**
1056
1339
  * Operation Group exposing the server-management restart Operations
1057
- * (`forecast`, `launch`, `list`). Shares the parent client's HTTP,
1058
- * rate-limit, and retry plumbing.
1340
+ * (`forecast`, `launch`, `list`, `restartOutdated`). `restartOutdated`
1341
+ * also uses the universe `:restartServers` method. Shares the parent
1342
+ * client's HTTP, rate-limit, and retry plumbing.
1059
1343
  */
1060
1344
  restarts;
1061
1345
  /**
@@ -1082,11 +1366,81 @@ var UniversesClient = class {
1082
1366
  this.thumbnails = createThumbnailsHandle(this.#inner);
1083
1367
  }
1084
1368
  /**
1369
+ * Makes an experience public. The API key needs `legacy-universe:manage`.
1370
+ * A missing content maturity rating can cause a misleading 403; complete
1371
+ * the content questionnaire in Creator Hub before activating.
1372
+ * On a 504, reads the universe's visibility and succeeds only if public.
1373
+ * This verification needs permission to read the universe. Otherwise the
1374
+ * original 504 is returned, leaving the outcome unconfirmed.
1375
+ *
1376
+ * @since 0.4.0
1377
+ * @param parameters - The universe identifier.
1378
+ * @param options - Optional per-request overrides.
1379
+ * @returns A success Result with no payload, or the Open Cloud error.
1380
+ *
1381
+ * @example
1382
+ *
1383
+ * ```ts
1384
+ * import { UniversesClient } from "@bedrock-rbx/ocale/universes";
1385
+ * import { createFakeHttpClient } from "@bedrock-rbx/ocale/testing";
1386
+ * const httpClient = createFakeHttpClient()
1387
+ * .mockResponse({ body: {}, status: 200 });
1388
+ * const client = new UniversesClient({
1389
+ * credential: { apiKey: "your-key", kind: "apiKey" },
1390
+ * httpClient,
1391
+ * });
1392
+ * const result = client.activate({ universeId: "123" });
1393
+ * return expect(result).resolves.toEqual({ data: undefined, success: true });
1394
+ * ```
1395
+ */
1396
+ async activate(parameters, options) {
1397
+ return setVisibilityAsync(this.#inner, {
1398
+ options,
1399
+ parameters,
1400
+ visibility: "public"
1401
+ });
1402
+ }
1403
+ /**
1404
+ * Makes an experience private, including one that is already private.
1405
+ * The API key needs `legacy-universe:manage`.
1406
+ * On a 504, reads the universe's visibility and succeeds only if private.
1407
+ * This verification needs permission to read the universe. Otherwise the
1408
+ * original 504 is returned, leaving the outcome unconfirmed.
1409
+ *
1410
+ * @since 0.4.0
1411
+ * @param parameters - The universe identifier.
1412
+ * @param options - Optional per-request overrides.
1413
+ * @returns A success Result with no payload, or the Open Cloud error.
1414
+ *
1415
+ * @example
1416
+ *
1417
+ * ```ts
1418
+ * import { UniversesClient } from "@bedrock-rbx/ocale/universes";
1419
+ * import { createFakeHttpClient } from "@bedrock-rbx/ocale/testing";
1420
+ *
1421
+ * const httpClient = createFakeHttpClient()
1422
+ * .mockResponse({ body: {}, status: 200 });
1423
+ * const client = new UniversesClient({
1424
+ * credential: { apiKey: "your-key", kind: "apiKey" },
1425
+ * httpClient,
1426
+ * });
1427
+ * const result = client.deactivate({ universeId: "123" });
1428
+ * return expect(result).resolves.toEqual({ data: undefined, success: true });
1429
+ * ```
1430
+ */
1431
+ async deactivate(parameters, options) {
1432
+ return setVisibilityAsync(this.#inner, {
1433
+ options,
1434
+ parameters,
1435
+ visibility: "private"
1436
+ });
1437
+ }
1438
+ /**
1085
1439
  * Fetches the current configuration of a universe.
1086
1440
  *
1087
1441
  * @param parameters - The universe identifier.
1088
1442
  * @param options - Optional per-request overrides (e.g. A different
1089
- * {@link OpenCloudClientOptions.apiKey} for this call only).
1443
+ * {@link OpenCloudClientOptions.credential} for this call only).
1090
1444
  * @returns A {@link Result} wrapping the parsed {@link Universe}
1091
1445
  * or the {@link OpenCloudError} that caused the request to fail.
1092
1446
  */
@@ -1123,7 +1477,7 @@ var UniversesClient = class {
1123
1477
  * @param parameters - The universe identifier and the fields to
1124
1478
  * update. At least one updatable field must be supplied.
1125
1479
  * @param options - Optional per-request overrides (e.g. A different
1126
- * {@link OpenCloudClientOptions.apiKey} for this call only).
1480
+ * {@link OpenCloudClientOptions.credential} for this call only).
1127
1481
  * @returns A {@link Result} wrapping the parsed {@link Universe}
1128
1482
  * or the {@link OpenCloudError} that caused the request to fail.
1129
1483
  */
@@ -1185,7 +1539,6 @@ function createThumbnailsHandle(inner) {
1185
1539
  }
1186
1540
  };
1187
1541
  }
1188
- //#endregion
1189
1542
  export { UniversesClient };
1190
1543
 
1191
1544
  //# sourceMappingURL=universes.mjs.map