@hot-updater/console 1.2.0-rc.50 → 1.2.0-rc.51

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 (130) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/BundleIdDisplay-CtbmyR7f.js +1 -0
  3. package/.output/public/assets/{FoldedRows-1NvB9gAS.js → FoldedRows-ClHLI-NM.js} +1 -1
  4. package/.output/public/assets/{IosInstall-BRuSakxm.js → IosInstall-1a_GRSNg.js} +1 -1
  5. package/.output/public/assets/{RelativeTime-m-FKh1Jb.js → RelativeTime-BQErgQRj.js} +1 -1
  6. package/.output/public/assets/{TargetDisplay-Ctuz3qIp.js → TargetDisplay-D0dVdFCk.js} +1 -1
  7. package/.output/public/assets/{index-oTXLdUR-.js → index-B8BpJ73Y.js} +2 -2
  8. package/.output/public/assets/{insights-BL6Z8zFv.js → insights-BrdBpqda.js} +2 -2
  9. package/.output/public/assets/{insights-BMjBMtJU.js → insights-DsmTCDix.js} +2 -2
  10. package/.output/public/assets/{insights_.distribution-C4E-JuVI.js → insights_.distribution-BHmK7ufZ.js} +1 -1
  11. package/.output/public/assets/{insights_.distribution-Br_CW9s9.js → insights_.distribution-BNNw0whH.js} +2 -2
  12. package/.output/public/assets/native-builds-B6t0ZxKP.js +1 -0
  13. package/.output/public/assets/{native-builds-BC0sjxPC.js → native-builds-CgPSpNsA.js} +2 -2
  14. package/.output/public/assets/native-builds-TF9BhYrQ.js +1 -0
  15. package/.output/public/assets/{native-builds_._buildId-GPlkI_2m.js → native-builds_._buildId-2rPrtz9-.js} +2 -2
  16. package/.output/public/assets/native-builds_._buildId-BqUOY1Az.js +1 -0
  17. package/.output/public/assets/{native-builds_.devices-Cox001IR.js → native-builds_.devices-B9kLHngv.js} +2 -2
  18. package/.output/public/assets/{native-builds_.devices-DAW19hcQ.js → native-builds_.devices-COFYZcaA.js} +1 -1
  19. package/.output/public/assets/{routes-C7Pv3Cfg.js → routes-DMooqgLf.js} +1 -1
  20. package/.output/public/assets/{routes-JJGRGqsf.js → routes-Z2IGj8MK.js} +2 -2
  21. package/.output/server/{__23tanstack-start-server-fn-resolver-DY-niJR4.mjs → __23tanstack-start-server-fn-resolver-pdhJfnex.mjs} +58 -58
  22. package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +1 -1
  23. package/.output/server/_libs/_.mjs +1 -1
  24. package/.output/server/_ssr/BundleIdDisplay-Bbf_lM0q.mjs +26 -0
  25. package/.output/server/_ssr/{ChannelPicker-J5HfKxSS.mjs → ChannelPicker-D6dQe9hV.mjs} +4 -4
  26. package/.output/server/_ssr/{ConsoleFeatureUnavailable-C52o4oew.mjs → ConsoleFeatureUnavailable-cLOJizHM.mjs} +6 -6
  27. package/.output/server/_ssr/{EventDetails-CDLSkVNA.mjs → EventDetails-Bf9A0sIH.mjs} +6 -6
  28. package/.output/server/_ssr/{FoldedRows-CrRYEVkd.mjs → FoldedRows-CBXPkthB.mjs} +4 -4
  29. package/.output/server/_ssr/{HashValueDisplay-BrT2wgxk.mjs → HashValueDisplay-CTRuGnTF.mjs} +2 -2
  30. package/.output/server/_ssr/{InsightsPageHeader-DVrudLMJ.mjs → InsightsPageHeader-CZYqpzbC.mjs} +6 -6
  31. package/.output/server/_ssr/{IosInstall-DcKlZU_q.mjs → IosInstall-Dnv68fhL.mjs} +8 -8
  32. package/.output/server/_ssr/{NativeBuildsNav-BC1WIQ1W.mjs → NativeBuildsNav-Dg43O2Cd.mjs} +3 -3
  33. package/.output/server/_ssr/{NotFoundPage-CEhZtcst.mjs → NotFoundPage-C0hUVtGq.mjs} +2 -2
  34. package/.output/server/_ssr/{QrCode-Dj9BKV3l.mjs → QrCode-BbK966IU.mjs} +2 -2
  35. package/.output/server/_ssr/{RelativeTime-Dgbh4UPb.mjs → RelativeTime-CdBbi7fL.mjs} +3 -3
  36. package/.output/server/_ssr/{RolloutPercentageBadge-BYEDUW1d.mjs → RolloutPercentageBadge-CaK9SkbN.mjs} +3 -3
  37. package/.output/server/_ssr/{RowReason-BweNBWkA.mjs → RowReason-Cg035uIk.mjs} +3 -3
  38. package/.output/server/_ssr/{SandboxBadge-O8-kbXAw.mjs → SandboxBadge-Zta6e__x.mjs} +2 -2
  39. package/.output/server/_ssr/{TargetDisplay-D3JAXwcF.mjs → TargetDisplay-DGqswOee.mjs} +3 -3
  40. package/.output/server/_ssr/{alert-dialog-CxEcyUb6.mjs → alert-dialog-DFz9lm_Y.mjs} +1 -1
  41. package/.output/server/_ssr/{api-IIqxWeDx.mjs → api-B2LCh6pv.mjs} +4 -4
  42. package/.output/server/_ssr/{api-keys-wFak2vKN.mjs → api-keys-BbtiHE85.mjs} +9 -9
  43. package/.output/server/_ssr/{api-keys-CYefExfc.mjs → api-keys-D3oOFnP9.mjs} +2 -2
  44. package/.output/server/_ssr/{api-keys-rpc-qkGQ3Sp3.mjs → api-keys-rpc-CJIR67Ch.mjs} +3 -3
  45. package/.output/server/_ssr/{api-rpc-3NKc545A.mjs → api-rpc-Bf7S-MaH.mjs} +16 -16
  46. package/.output/server/_ssr/{auth-rpc-PCSJzNJf.mjs → auth-rpc-Dp-DCqh6.mjs} +4 -4
  47. package/.output/server/_ssr/{auth.server-NGj7G3bq.mjs → auth.server-Cc0ZRXjk.mjs} +490 -27
  48. package/.output/server/_ssr/{badge-CxSJ-pjU.mjs → badge-YEmoI1eN.mjs} +1 -1
  49. package/.output/server/_ssr/{card-BDXDcrk_.mjs → card-D0a_6Dhh.mjs} +1 -1
  50. package/.output/server/_ssr/{config.server-CwUGPk-F.mjs → config.server-CZRoGrFp.mjs} +3 -3
  51. package/.output/server/_ssr/{console-access-BOt-Xxd7.mjs → console-access-OPT4g-IS.mjs} +2 -2
  52. package/.output/server/_ssr/{console-features-api-Dw_Tktev.mjs → console-features-api-tjmlaM_N.mjs} +5 -5
  53. package/.output/server/_ssr/{console-features-rpc-D8VFHwYj.mjs → console-features-rpc-SlXJxyZV.mjs} +3 -3
  54. package/.output/server/_ssr/{databaseRows-BZMFl5QV.mjs → databaseRows-D6bc51Xq.mjs} +3 -2
  55. package/.output/server/_ssr/{dialog-CJ4zMagm.mjs → dialog-ChHbf-yX.mjs} +1 -1
  56. package/.output/server/_ssr/{empty-DYy36pwa.mjs → empty-jogqtpGm.mjs} +2 -2
  57. package/.output/server/_ssr/{field-MI8oNc5n.mjs → field-Df_Q9TWZ.mjs} +2 -2
  58. package/.output/server/_ssr/{getBundleChildren-CnOf4Frp.mjs → getBundleChildren-DDqsd1pL.mjs} +2 -2
  59. package/.output/server/_ssr/{input-group-Bf7wHa21.mjs → input-group-CVf7oJb7.mjs} +1 -1
  60. package/.output/server/_ssr/{insights-b3XeQlzF.mjs → insights-CWe8WEnp.mjs} +52 -33
  61. package/.output/server/_ssr/{insights-CKTR62Ox.mjs → insights-DFSywrbh.mjs} +5 -5
  62. package/.output/server/_ssr/{insights-CbGG5htV.mjs → insights-DIRlQAyF.mjs} +2 -2
  63. package/.output/server/_ssr/{insights-api-CqjIxe1A.mjs → insights-api-C9rxV0Tn.mjs} +3 -3
  64. package/.output/server/_ssr/{insights-failures-rpc-fmWHkLhL.mjs → insights-failures-rpc-wIScA1Qn.mjs} +4 -4
  65. package/.output/server/_ssr/{insights-recovery-rpc-BpwoS9XL.mjs → insights-recovery-rpc-BVt-dUJZ.mjs} +3 -3
  66. package/.output/server/_ssr/{insights-rpc-qwXzuBUQ.mjs → insights-rpc-BDQqwXjX.mjs} +3 -3
  67. package/.output/server/_ssr/{insights-search-B_8PizlM.mjs → insights-search-B56U9By9.mjs} +2 -2
  68. package/.output/server/_ssr/{insights-usage-rpc-Cbg82l2g.mjs → insights-usage-rpc-C084r9Yl.mjs} +3 -3
  69. package/.output/server/_ssr/{insights-usage-rpc-D8lgk1Sk.mjs → insights-usage-rpc-D6QC7xMU.mjs} +3 -3
  70. package/.output/server/_ssr/{insights_.distribution-Ed2vqrwP.mjs → insights_.distribution-BO1VAcAm.mjs} +5 -5
  71. package/.output/server/_ssr/{insights_.distribution--XTBM-oT.mjs → insights_.distribution-CoTlEOe8.mjs} +14 -14
  72. package/.output/server/_ssr/{insights_.distribution-DTaKryjw.mjs → insights_.distribution-DP1M7WJo.mjs} +2 -2
  73. package/.output/server/_ssr/{installations-DyfuFp3L.mjs → installations-BczGuyup.mjs} +11 -11
  74. package/.output/server/_ssr/{installations-W8W7AYwn.mjs → installations-CHXPyqGZ.mjs} +4 -4
  75. package/.output/server/_ssr/{installations-Ce_9dNq0.mjs → installations-CY86CKgz.mjs} +2 -2
  76. package/.output/server/_ssr/{ios-devices-rpc-5kZM1bgU.mjs → ios-devices-rpc-B-9HHSKk.mjs} +7 -7
  77. package/.output/server/_ssr/{iosDeviceCookie-BTfPOUhS.mjs → iosDeviceCookie-CZArbhzA.mjs} +3 -3
  78. package/.output/server/_ssr/{iosDeviceProfile-BAoo32s_.mjs → iosDeviceProfile-CxeXYxc-.mjs} +3 -3
  79. package/.output/server/_ssr/{iosDevices-DuNmS3td.mjs → iosDevices-Ckjp_S09.mjs} +3 -3
  80. package/.output/server/_ssr/{native-builds-lEyKQemV.mjs → native-builds-C2xGyB-t.mjs} +19 -8
  81. package/.output/server/_ssr/{native-builds-DEyFHKDa.mjs → native-builds-CKoFuBrT.mjs} +21 -19
  82. package/.output/server/_ssr/{native-builds-1s5DIHa2.mjs → native-builds-DGckAE3j.mjs} +2 -2
  83. package/.output/server/_ssr/{native-builds_._buildId-ElCXKaXI.mjs → native-builds_._buildId-BXfvqKmr.mjs} +50 -40
  84. package/.output/server/_ssr/{native-builds_._buildId-mJ8i0pL8.mjs → native-builds_._buildId-EqbJ7R4A.mjs} +2 -2
  85. package/.output/server/_ssr/{native-builds_.devices-Dz8b48Fo.mjs → native-builds_.devices-BJ75om8d.mjs} +2 -2
  86. package/.output/server/_ssr/{native-builds_.devices-DNWZLCra.mjs → native-builds_.devices-X6JpinwG.mjs} +17 -17
  87. package/.output/server/_ssr/{nativeBuildDownloadLink-D8Se_CCi.mjs → nativeBuildDownloadLink-BAfCV_k_.mjs} +2 -2
  88. package/.output/server/_ssr/{nativeBuildInstall-DemC_4Zc.mjs → nativeBuildInstall-D2rK0m4j.mjs} +5 -5
  89. package/.output/server/_ssr/{nativeBuilds-BFSeuC75.mjs → nativeBuilds-B3LcuLs4.mjs} +5 -5
  90. package/.output/server/_ssr/{release-adoption-rpc-1mKibOdV.mjs → release-adoption-rpc-xKxB0Ir0.mjs} +6 -6
  91. package/.output/server/_ssr/{releaseAdoption-DfEYq7I4.mjs → releaseAdoption-BNp2LKR5.mjs} +2 -1
  92. package/.output/server/_ssr/{releaseCatalogCompiler-CuL3ptgg.mjs → releaseCatalogCompiler-CLDa8DuR.mjs} +19 -8
  93. package/.output/server/_ssr/{remote-config-C_HNYPZ_.mjs → remote-config-ByjC_BCV.mjs} +18 -18
  94. package/.output/server/_ssr/{remote-config-D2Cohnwn.mjs → remote-config-DmEXPobC.mjs} +2 -2
  95. package/.output/server/_ssr/{remote-config-rpc-6hfHFrO6.mjs → remote-config-rpc-BNPLt44i.mjs} +3 -3
  96. package/.output/server/_ssr/{remote-config-q9fegj-G.mjs → remote-config-w3s5hFj9.mjs} +2 -2
  97. package/.output/server/_ssr/{router-DODxASKG.mjs → router-C8NZ0bVd.mjs} +35 -35
  98. package/.output/server/_ssr/{routes-C-nYThl0.mjs → routes-B8Gmx46E.mjs} +10 -10
  99. package/.output/server/_ssr/{routes-BJjTUNSe.mjs → routes-DvpKW5gf.mjs} +31 -27
  100. package/.output/server/_ssr/{schema-migration-rpc-C31JquTn.mjs → schema-migration-rpc-DlahGhrf.mjs} +3 -3
  101. package/.output/server/_ssr/{select-CjACvu9s.mjs → select-Csnyblf2.mjs} +1 -1
  102. package/.output/server/_ssr/{server-Dyw2qgSR.mjs → server-Yr7QLPLj.mjs} +3 -3
  103. package/.output/server/_ssr/{sidebar-DQkRAO_e.mjs → sidebar-bKoOUlMN.mjs} +2 -2
  104. package/.output/server/_ssr/ssr.mjs +1 -1
  105. package/.output/server/_ssr/{switch-DZJSRVl3.mjs → switch-C-HJ8oZV.mjs} +2 -2
  106. package/.output/server/_ssr/{table-BA-6GQFs.mjs → table-DSB_9Amh.mjs} +1 -1
  107. package/.output/server/_ssr/{tabs-CtB3PIts.mjs → tabs-DRTBxZTO.mjs} +2 -2
  108. package/.output/server/{_tanstack-start-manifest_v-Bfv6fYk6.mjs → _tanstack-start-manifest_v-MJAIGQWT.mjs} +30 -30
  109. package/.output/server/index.mjs +188 -188
  110. package/package.json +7 -7
  111. package/src/components/BundleIdDisplay.tsx +30 -3
  112. package/src/components/features/insights/ComparedBundlesChart.tsx +1 -0
  113. package/src/components/features/insights/InsightsControls.tsx +28 -4
  114. package/src/components/features/insights/InsightsOverview.tsx +3 -1
  115. package/src/components/features/insights/ReleaseCombobox.tsx +7 -2
  116. package/src/components/features/insights/RollbackButton.tsx +1 -1
  117. package/src/components/features/native-builds/BuiltInBundleCard.tsx +3 -2
  118. package/src/components/features/native-builds/NativeBuildDetailPage.tsx +9 -0
  119. package/src/components/features/native-builds/NativeBuildsTable.tsx +7 -4
  120. package/src/components/features/native-builds/ServedNowCard.tsx +6 -3
  121. package/src/components/features/releases/ReleaseEditorSheet.tsx +6 -3
  122. package/src/lib/native-builds.ts +28 -20
  123. package/src/lib/release-adoption.ts +2 -0
  124. package/src/lib/server/releaseAdoption.ts +1 -0
  125. package/src/routes/index.tsx +5 -1
  126. package/.output/public/assets/BundleIdDisplay-C0X-k49t.js +0 -1
  127. package/.output/public/assets/native-builds-B0zJ4wjg.js +0 -1
  128. package/.output/public/assets/native-builds-B_pQ4D5H.js +0 -1
  129. package/.output/public/assets/native-builds_._buildId-CSyC7YAA.js +0 -1
  130. package/.output/server/_ssr/BundleIdDisplay-CGdSiouM.mjs +0 -13
@@ -1,15 +1,15 @@
1
1
  import { n as DatabaseBundleNotFoundError, r as DatabaseRowReferencedError } from "./databaseJsonValue-DuUoft8j.mjs";
2
2
  import { a as getAssetBaseStorageUri, c as getManifestFileHash, i as RELEASE_CATALOG_FALLBACK_POLICY, l as getManifestStorageUri, n as MAX_COMPILED_CATALOG_BYTES, o as getBundlePatch } from "./dist-CiOq3ygH.mjs";
3
- import { i as rowToBundle, n as bundleToRow, r as releaseRowToRelease, t as bundleToPatchRows } from "./databaseRows-BZMFl5QV.mjs";
3
+ import { i as rowToBundle, n as bundleToRow, r as releaseRowToRelease, t as bundleToPatchRows } from "./databaseRows-D6bc51Xq.mjs";
4
4
  import { a as decodeChannelKey, c as parseReleaseCatalogScopeKey, i as createReleaseCatalogScopeKey, o as encodeChannelKey, r as canonicalizeAppVersion, s as isUUIDv7, t as NIL_UUID } from "./uuid-kZvLA0Ly-DNL0qBSj.mjs";
5
5
  import { t as ReleaseManagementError } from "./releaseManagement-CqIc-SDE.mjs";
6
6
  import { n as createUUIDv7After, t as createUUIDv7 } from "./uuidv7-C0jNe2Om.mjs";
7
7
  import { i as normalizeRange } from "./version-CQ98ZBpL-zW2fpHOZ.mjs";
8
- import { i as projectCompiledRollbackCatalog, n as compileReleaseCatalog, r as projectCompiledCatalog, t as ReleaseCatalogCompilationError } from "./releaseCatalogCompiler-CuL3ptgg.mjs";
8
+ import { i as projectCompiledRollbackCatalog, n as compileReleaseCatalog, r as projectCompiledCatalog, t as ReleaseCatalogCompilationError } from "./releaseCatalogCompiler-CLDa8DuR.mjs";
9
9
  import { t as isRemoteDatabase } from "./databaseConfig-B56IJxlu.mjs";
10
10
  import { n as defineTable, t as defineAggregate } from "./schema-CaIuQCXb.mjs";
11
11
  import { r as rangesIntersect } from "../_libs/verkit.mjs";
12
- //#region node_modules/.nitro/vite/services/ssr/assets/auth.server-NGj7G3bq.js
12
+ //#region node_modules/.nitro/vite/services/ssr/assets/auth.server-Cc0ZRXjk.js
13
13
  var SHA256_FILE_HASH_RE = /^[0-9a-f]{64}$/;
14
14
  var isContentAddressedAssetFileHash = (value) => {
15
15
  return typeof value === "string" && SHA256_FILE_HASH_RE.test(value);
@@ -893,7 +893,11 @@ var releases = defineTable({
893
893
  }
894
894
  },
895
895
  created_at_ms: { type: "integer" },
896
- updated_at_ms: { type: "integer" }
896
+ updated_at_ms: { type: "integer" },
897
+ label: {
898
+ type: "integer",
899
+ required: false
900
+ }
897
901
  }, {
898
902
  key: ["id"],
899
903
  indexes: {
@@ -930,9 +934,42 @@ var releases = defineTable({
930
934
  scopes: {
931
935
  eq: [],
932
936
  sort: ["scope_key"]
937
+ },
938
+ byLabel: {
939
+ eq: [
940
+ "channel_id",
941
+ "platform",
942
+ "label"
943
+ ],
944
+ sort: [],
945
+ unique: true
933
946
  }
934
947
  }
935
948
  });
949
+ /**
950
+ * One counter per sequence: `releases/<platform>/<channel ID>` holds the
951
+ * last label that channel and platform's releases took. A deploy or a
952
+ * promote reads it and writes the next value in the transaction that writes
953
+ * the release, so two writers never take one label. `is_filled` is true once
954
+ * every release of the sequence written before labels has one, in ID order;
955
+ * until then a writer fills them first. Deleting a channel deletes its
956
+ * counters, so a channel created again with the name starts at 1.
957
+ */
958
+ var labelSequences = defineTable({
959
+ id: {
960
+ type: "string",
961
+ maxLength: 1440,
962
+ ascii: true
963
+ },
964
+ last_label: { type: "integer" },
965
+ is_filled: { type: "boolean" }
966
+ }, {
967
+ key: ["id"],
968
+ indexes: { all: {
969
+ eq: [],
970
+ sort: ["id"]
971
+ } }
972
+ });
936
973
  /** One compiled catalog per scope; the update check reads exactly this row. */
937
974
  var releaseCatalogs = defineTable({
938
975
  scope_key: {
@@ -1302,7 +1339,8 @@ var coreModule = {
1302
1339
  }),
1303
1340
  native_builds: nativeBuilds,
1304
1341
  ios_devices: iosDevices,
1305
- ios_device_account: iosDeviceAccount
1342
+ ios_device_account: iosDeviceAccount,
1343
+ label_sequences: labelSequences
1306
1344
  }
1307
1345
  };
1308
1346
  var encoder = new TextEncoder();
@@ -3039,7 +3077,7 @@ var createEngine = (database, { plugins = [], now = Date.now } = {}) => {
3039
3077
  flush: () => engine.flush()
3040
3078
  };
3041
3079
  };
3042
- var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.50";
3080
+ var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.51";
3043
3081
  /**
3044
3082
  * `/version` on both mounts. The admin mount also lists the ids of the
3045
3083
  * plugins the server runs, sorted; apps never learn which plugins a server
@@ -3480,7 +3518,7 @@ var baseBundleIdsOf = (row, range, bundleId, limit) => {
3480
3518
  }
3481
3519
  return ids;
3482
3520
  };
3483
- var PAGE$2 = 500;
3521
+ var PAGE$3 = 500;
3484
3522
  var pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
3485
3523
  var toBundleRow = pick$2([
3486
3524
  "id",
@@ -3501,7 +3539,7 @@ var toPatchRow = pick$2([
3501
3539
  "byte_size",
3502
3540
  "order_index"
3503
3541
  ]);
3504
- var toReleaseRow = pick$2([
3542
+ var pickReleaseRow = pick$2([
3505
3543
  "id",
3506
3544
  "revision",
3507
3545
  "scope_key",
@@ -3522,6 +3560,13 @@ var toReleaseRow = pick$2([
3522
3560
  "created_at_ms",
3523
3561
  "updated_at_ms"
3524
3562
  ]);
3563
+ /** A release row; `label` null where the store holds none, as before the column. */
3564
+ var toReleaseRow = (row) => {
3565
+ return {
3566
+ ...pickReleaseRow(row),
3567
+ label: typeof row.label === "number" ? row.label : null
3568
+ };
3569
+ };
3525
3570
  var toCatalogRow = pick$2([
3526
3571
  "scope_key",
3527
3572
  "catalog_id",
@@ -3570,7 +3615,7 @@ var createCoreReads = (db, storage) => {
3570
3615
  const page = await db.findMany("bundle_patches", {
3571
3616
  index: "byBundle",
3572
3617
  where: { bundle_id: row.id },
3573
- limit: Math.min(count - patches.length, PAGE$2),
3618
+ limit: Math.min(count - patches.length, PAGE$3),
3574
3619
  ...cursor === void 0 ? {} : { cursor }
3575
3620
  });
3576
3621
  patches.push(...page.rows.map(toPatchRow));
@@ -3671,6 +3716,18 @@ var createCoreReads = (db, storage) => {
3671
3716
  const row = await db.findOne("releases", { id });
3672
3717
  return row === null ? null : toReleaseRow(row);
3673
3718
  },
3719
+ async getReleaseByLabel({ channel, platform, label }) {
3720
+ const found = await db.findOne("releases", {
3721
+ channel_id: `channel:${encodeChannelKey(channel)}`,
3722
+ platform,
3723
+ label
3724
+ });
3725
+ if (found === null) return null;
3726
+ const row = await db.findOne("releases", { id: found.id });
3727
+ if (row === null) return null;
3728
+ const release = toReleaseRow(row);
3729
+ return release.label === label && release.platform === platform ? release : null;
3730
+ },
3674
3731
  async listReleases(input) {
3675
3732
  const { filter } = input;
3676
3733
  const options = {
@@ -3762,7 +3819,7 @@ var createCoreReads = (db, storage) => {
3762
3819
  return (await drain((page) => db.findMany("channels", {
3763
3820
  index: "all",
3764
3821
  where: {},
3765
- limit: PAGE$2,
3822
+ limit: PAGE$3,
3766
3823
  ...page
3767
3824
  }))).map(toChannelRow);
3768
3825
  },
@@ -4085,6 +4142,311 @@ var NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
4085
4142
  ],
4086
4143
  ios: ["testflight"]
4087
4144
  };
4145
+ /**
4146
+ * The counter of a channel and platform's release labels: one
4147
+ * `label_sequences` row, which every writer of the pair reads and bumps.
4148
+ */
4149
+ var labelSequenceId = (channelId, platform) => `releases/${platform}/${channelId}`;
4150
+ /** The pairs a channel's counters belong to, which deleting it removes. */
4151
+ var LABEL_PLATFORMS = ["ios", "android"];
4152
+ /**
4153
+ * A channel and platform whose releases written before labels have none
4154
+ * yet, or that has no counter: the write stops before taking a label, the
4155
+ * core labels the pair with `fillLabels`, and the write runs again.
4156
+ */
4157
+ var NeedsLabelFill = class extends Error {
4158
+ channelId;
4159
+ platform;
4160
+ constructor(channelId, platform) {
4161
+ super(`Release labels of ${platform} ${channelId} need a fill first.`);
4162
+ this.channelId = channelId;
4163
+ this.platform = platform;
4164
+ }
4165
+ };
4166
+ var createLabelAllocator = (tx, used, caughtUp) => {
4167
+ const sequences = /* @__PURE__ */ new Map();
4168
+ return {
4169
+ async next(channelId, platform) {
4170
+ const id = labelSequenceId(channelId, platform);
4171
+ let sequence = sequences.get(id);
4172
+ if (sequence === void 0) {
4173
+ const row = await tx.findOne("label_sequences", { id });
4174
+ if (row === null || !row.is_filled) {
4175
+ const channel = row === null ? await tx.findOne("channels", { id: channelId }) : null;
4176
+ if (channel === null || (channel._refs_releases_channel_id ?? 0) > 0) throw new NeedsLabelFill(channelId, platform);
4177
+ }
4178
+ const read = row?.last_label ?? 0;
4179
+ sequence = {
4180
+ row,
4181
+ read,
4182
+ last: read
4183
+ };
4184
+ sequences.set(id, sequence);
4185
+ used.set(id, {
4186
+ channelId,
4187
+ platform,
4188
+ read
4189
+ });
4190
+ }
4191
+ sequence.last += 1;
4192
+ return sequence.last;
4193
+ },
4194
+ caughtUp(channelId, platform) {
4195
+ caughtUp.set(labelSequenceId(channelId, platform), {
4196
+ channelId,
4197
+ platform
4198
+ });
4199
+ },
4200
+ flush() {
4201
+ for (const [id, { row, read, last }] of sequences) if (row === null) tx.create("label_sequences", {
4202
+ id,
4203
+ last_label: last,
4204
+ is_filled: true
4205
+ });
4206
+ else if (last !== read) tx.update("label_sequences", row, { last_label: last });
4207
+ }
4208
+ };
4209
+ };
4210
+ var FILL_BATCH = 25;
4211
+ var PAGE$2 = 500;
4212
+ /**
4213
+ * Labels a channel and platform's releases that have none, in ID order,
4214
+ * which is the order they were created in, and marks its counter filled:
4215
+ * each batch reads the counter and its rows guarded, so a concurrent fill or
4216
+ * write serializes on the counter and skips what another labeled. With
4217
+ * `dryRun`, it only counts them. Answers how many it labeled.
4218
+ */
4219
+ var fillLabels = async (db, { channelId, platform }, { dryRun = false } = {}) => {
4220
+ const id = labelSequenceId(channelId, platform);
4221
+ let labeled = 0;
4222
+ let batchSize = FILL_BATCH;
4223
+ const label = async (ids) => {
4224
+ for (let at = 0; at < ids.length;) {
4225
+ const batch = ids.slice(at, at + batchSize);
4226
+ try {
4227
+ labeled += await db.transaction(async (tx) => {
4228
+ const counter = await tx.findOne("label_sequences", { id });
4229
+ let last = counter?.last_label ?? 0;
4230
+ let count = 0;
4231
+ for (const releaseId of batch) {
4232
+ const row = await tx.findOne("releases", { id: releaseId });
4233
+ if (row === null || typeof row.label === "number") continue;
4234
+ last += 1;
4235
+ count += 1;
4236
+ tx.update("releases", row, { label: last });
4237
+ }
4238
+ if (counter === null) tx.create("label_sequences", {
4239
+ id,
4240
+ last_label: last,
4241
+ is_filled: false
4242
+ });
4243
+ else if (last !== counter.last_label) tx.update("label_sequences", counter, { last_label: last });
4244
+ return count;
4245
+ });
4246
+ at += batch.length;
4247
+ } catch (error) {
4248
+ if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
4249
+ batchSize = Math.max(1, Math.floor(batchSize / 2));
4250
+ continue;
4251
+ }
4252
+ throw error;
4253
+ }
4254
+ }
4255
+ };
4256
+ let cursor;
4257
+ do {
4258
+ const page = await db.findMany("releases", {
4259
+ index: "byChannelPlatform",
4260
+ where: {
4261
+ channel_id: channelId,
4262
+ platform
4263
+ },
4264
+ limit: PAGE$2,
4265
+ ...cursor === void 0 ? {} : { cursor }
4266
+ });
4267
+ const unlabeled = page.rows.filter((row) => typeof row.label !== "number").map((row) => row.id);
4268
+ if (dryRun) labeled += unlabeled.length;
4269
+ else await label(unlabeled);
4270
+ cursor = page.next;
4271
+ } while (cursor !== void 0);
4272
+ if (dryRun) return labeled;
4273
+ await db.transaction(async (tx) => {
4274
+ const counter = await tx.findOne("label_sequences", { id });
4275
+ if (counter === null) tx.create("label_sequences", {
4276
+ id,
4277
+ last_label: 0,
4278
+ is_filled: true
4279
+ });
4280
+ else if (!counter.is_filled) tx.update("label_sequences", counter, { is_filled: true });
4281
+ });
4282
+ return labeled;
4283
+ };
4284
+ /**
4285
+ * Reads what a pair's fill writes, its counter and its label index, without
4286
+ * writing: a database without release labels' schema, such as one a 1.2
4287
+ * prerelease migrated, fails here as the fill would. The schema is the
4288
+ * database's, so one pair tells. Two reads.
4289
+ */
4290
+ var probeLabelSchema = async (db, { channelId, platform }) => {
4291
+ await db.findOne("label_sequences", { id: labelSequenceId(channelId, platform) });
4292
+ await db.findMany("releases", {
4293
+ index: "byLabel",
4294
+ where: {
4295
+ channel_id: channelId,
4296
+ platform,
4297
+ label: 0
4298
+ },
4299
+ limit: 1
4300
+ });
4301
+ };
4302
+ var REPAIRS = 4;
4303
+ var RACES = 32;
4304
+ /**
4305
+ * Runs a release write that takes labels, in one transaction with the
4306
+ * counters it bumps. A pair that still needs its fill is filled, and the
4307
+ * write runs again; so is a pair whose catch-up made the write too large for
4308
+ * the store. A label another row holds, such as an index item a release
4309
+ * deleted by a server of an earlier release left on a key-value store, is
4310
+ * skipped: its counters move past it and the write runs again.
4311
+ */
4312
+ var writeWithLabels = async (db, write) => {
4313
+ const filled = /* @__PURE__ */ new Set();
4314
+ const fill = async (pairs) => {
4315
+ for (const pair of pairs) {
4316
+ filled.add(labelSequenceId(pair.channelId, pair.platform));
4317
+ await fillLabels(db, pair);
4318
+ }
4319
+ };
4320
+ for (let repairs = 0, races = 0;;) {
4321
+ const used = /* @__PURE__ */ new Map();
4322
+ const caughtUp = /* @__PURE__ */ new Map();
4323
+ try {
4324
+ return await db.transaction(async (tx) => {
4325
+ used.clear();
4326
+ caughtUp.clear();
4327
+ const labels = createLabelAllocator(tx, used, caughtUp);
4328
+ const result = await write(tx, labels);
4329
+ labels.flush();
4330
+ return result;
4331
+ });
4332
+ } catch (error) {
4333
+ const needs = error instanceof NeedsLabelFill ? [error] : error instanceof DatabaseConstraintError && error.reason === "too_large" ? [...caughtUp.values()] : [];
4334
+ if (needs.length > 0) {
4335
+ const fresh = needs.some(({ channelId, platform }) => !filled.has(labelSequenceId(channelId, platform)));
4336
+ if (fresh || repairs < REPAIRS) {
4337
+ if (!fresh) repairs += 1;
4338
+ await fill(needs);
4339
+ continue;
4340
+ }
4341
+ }
4342
+ if (error instanceof DatabaseConstraintError && error.reason === "unique" && error.model === "releases" && used.size > 0) {
4343
+ if (await db.transaction(async (tx) => {
4344
+ const moves = [];
4345
+ for (const [id, { channelId, read }] of used) {
4346
+ const counter = await tx.findOne("label_sequences", { id });
4347
+ if (counter !== null) {
4348
+ if (counter.last_label !== read) return false;
4349
+ moves.push(() => tx.update("label_sequences", counter, { last_label: read + 1 }));
4350
+ continue;
4351
+ }
4352
+ const channel = await tx.findOne("channels", { id: channelId });
4353
+ if (channel === null || (channel._refs_releases_channel_id ?? 0) > 0) return false;
4354
+ moves.push(() => tx.create("label_sequences", {
4355
+ id,
4356
+ last_label: read + 1,
4357
+ is_filled: true
4358
+ }));
4359
+ }
4360
+ for (const move of moves) move();
4361
+ return true;
4362
+ }) ? (repairs += 1) <= REPAIRS : (races += 1) <= RACES) continue;
4363
+ }
4364
+ throw error;
4365
+ }
4366
+ }
4367
+ };
4368
+ /**
4369
+ * Labels a scope's releases a server of an earlier release wrote after its
4370
+ * newest labeled one, oldest first, before the write takes its own label:
4371
+ * `latest` is the scope's newest release, so a labeled one costs no read.
4372
+ * Answers the labels it gave, by release ID.
4373
+ */
4374
+ var catchUpLabels = async (tx, labels, latest) => {
4375
+ const given = /* @__PURE__ */ new Map();
4376
+ if (latest === null || typeof latest.label === "number") return given;
4377
+ const unlabeled = [];
4378
+ let cursor;
4379
+ scan: do {
4380
+ const page = await tx.findMany("releases", {
4381
+ index: "byScope",
4382
+ where: { scope_key: latest.scope_key },
4383
+ order: "desc",
4384
+ limit: FILL_BATCH,
4385
+ ...cursor === void 0 ? {} : { cursor }
4386
+ });
4387
+ for (const row of page.rows) {
4388
+ if (typeof row.label === "number") break scan;
4389
+ unlabeled.push(row);
4390
+ }
4391
+ cursor = page.next;
4392
+ } while (cursor !== void 0);
4393
+ labels.caughtUp(latest.channel_id, latest.platform);
4394
+ for (const row of unlabeled.reverse()) {
4395
+ const { id, channel_id, platform } = toReleaseRow(row);
4396
+ const label = await labels.next(channel_id, platform);
4397
+ tx.update("releases", row, { label });
4398
+ given.set(id, label);
4399
+ }
4400
+ return given;
4401
+ };
4402
+ /**
4403
+ * The channels and platforms whose releases need labels: a scope whose
4404
+ * newest release has none, or a pair without a filled counter. Releases a
4405
+ * server of an earlier release wrote in a filled pair come after its
4406
+ * labeled ones in their scope, so the newest release of each scope tells.
4407
+ * Two reads per scope, one per pair.
4408
+ */
4409
+ var pendingLabelPairs = async (db) => {
4410
+ const pairs = /* @__PURE__ */ new Map();
4411
+ for (let last = "";;) {
4412
+ const { rows } = await db.findMany("releases", {
4413
+ index: "scopes",
4414
+ where: {},
4415
+ limit: 1,
4416
+ range: { gt: last }
4417
+ });
4418
+ if (rows[0] === void 0) break;
4419
+ last = rows[0].scope_key;
4420
+ const { rows: newest } = await db.findMany("releases", {
4421
+ index: "byScope",
4422
+ where: { scope_key: last },
4423
+ order: "desc",
4424
+ limit: 1
4425
+ });
4426
+ if (newest[0] === void 0) continue;
4427
+ const { channel_id: channelId, platform, label } = toReleaseRow(newest[0]);
4428
+ const id = labelSequenceId(channelId, platform);
4429
+ const pair = pairs.get(id) ?? {
4430
+ channelId,
4431
+ platform,
4432
+ pending: false
4433
+ };
4434
+ pair.pending ||= label === null;
4435
+ pairs.set(id, pair);
4436
+ }
4437
+ const pending = [];
4438
+ for (const [id, { channelId, platform, pending: unlabeled }] of pairs) {
4439
+ if (!unlabeled) {
4440
+ const counter = await db.findOne("label_sequences", { id });
4441
+ if (counter !== null && counter.is_filled) continue;
4442
+ }
4443
+ pending.push({
4444
+ channelId,
4445
+ platform
4446
+ });
4447
+ }
4448
+ return pending;
4449
+ };
4088
4450
  var PAGE$1 = 500;
4089
4451
  /** Moves one bundle into or out of its platform's total and the overall total. */
4090
4452
  var countBundle = (tx, platform, delta) => {
@@ -4164,7 +4526,11 @@ var insertChannel = async (db, row) => {
4164
4526
  throw error;
4165
4527
  }
4166
4528
  };
4167
- /** Deletes a channel no release or native build uses: 1 read, 1 query, 1 write. */
4529
+ /**
4530
+ * Deletes a channel no release or native build uses, with its label
4531
+ * counters, so one created again with its name starts at 1: 3 reads,
4532
+ * 1 query, 1 write.
4533
+ */
4168
4534
  var deleteChannel = (db, id) => db.transaction(async (tx) => {
4169
4535
  const row = await tx.findOne("channels", { id });
4170
4536
  if (row === null) return {
@@ -4184,6 +4550,10 @@ var deleteChannel = (db, id) => db.transaction(async (tx) => {
4184
4550
  deleted: false,
4185
4551
  reason: "not_empty"
4186
4552
  };
4553
+ for (const platform of LABEL_PLATFORMS) {
4554
+ const counter = await tx.findOne("label_sequences", { id: labelSequenceId(id, platform) });
4555
+ if (counter !== null) await tx.delete("label_sequences", counter);
4556
+ }
4187
4557
  await tx.delete("channels", row);
4188
4558
  return { deleted: true };
4189
4559
  });
@@ -4716,15 +5086,15 @@ var enabledIn = (scopeKey, cursor) => ({
4716
5086
  });
4717
5087
  /** A scope's enabled releases, all of them, under the catalog's guard. */
4718
5088
  var enabledReleases = (tx, scopeKey) => drainReleases((cursor) => tx.findMany("releases", enabledIn(scopeKey, cursor)));
4719
- /** The scope's newest release id: `byScope` descending, limit 1. */
4720
- var latestReleaseId = async (tx, scopeKey) => {
5089
+ /** The scope's newest release: `byScope` descending, limit 1. */
5090
+ var latestRelease = async (tx, scopeKey) => {
4721
5091
  const { rows } = await tx.findMany("releases", {
4722
5092
  index: "byScope",
4723
5093
  where: { scope_key: scopeKey },
4724
5094
  order: "desc",
4725
5095
  limit: 1
4726
5096
  });
4727
- return rows[0]?.id ?? null;
5097
+ return rows[0] === void 0 ? null : toReleaseRow(rows[0]);
4728
5098
  };
4729
5099
  /** The scope's next catalog generation, compiled as `compilation`. */
4730
5100
  var nextCatalog = (scope, stored, compilation, updatedAtMs) => {
@@ -4786,11 +5156,16 @@ var readCatalog = async (tx, scopeKey) => {
4786
5156
  var assertHistory = (stored, hasReleases) => {
4787
5157
  if (stored.catalog === null && hasReleases) fail$1("CATALOG_IDENTITY_MISSING", "Catalog history is missing. Restore its catalog row from backup before rebuilding or deploying.");
4788
5158
  };
4789
- /** One release change and its scope's next catalog, inside `tx`. */
4790
- var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
5159
+ /**
5160
+ * One release change and its scope's next catalog, inside `tx`. An insert
5161
+ * takes its channel and platform's next label from `labels`, after labeling
5162
+ * the releases a server of an earlier release wrote in the scope since its
5163
+ * last labeled one.
5164
+ */
5165
+ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
4791
5166
  checkScope(scope);
4792
5167
  const stored = await readCatalog(tx, scope.scopeKey);
4793
- const enabled = await enabledReleases(tx, scope.scopeKey);
5168
+ let enabled = await enabledReleases(tx, scope.scopeKey);
4794
5169
  if (bundle !== void 0) {
4795
5170
  insertBundle(tx, bundle.row);
4796
5171
  for (const patch of bundle.patches) tx.create("bundle_patches", patch);
@@ -4798,14 +5173,22 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
4798
5173
  let before = null;
4799
5174
  let release;
4800
5175
  if (change.operation === "insert") {
4801
- const latest = await latestReleaseId(tx, scope.scopeKey);
5176
+ if (labels === void 0) throw new Error("A release insert takes its label from an allocator.");
5177
+ const newest = await latestRelease(tx, scope.scopeKey);
5178
+ const latest = newest?.id ?? null;
4802
5179
  assertHistory(stored, latest !== null);
4803
5180
  const floor = [latest, bundle && isUUIDv7(bundle.row.id) ? bundle.row.id : null].filter((id) => id !== null).sort().at(-1);
4804
5181
  const id = change.row.id ?? createUUIDv7After(floor ?? null);
4805
5182
  if (latest !== null && id <= latest) fail$1("NON_MONOTONIC_RELEASE_ID", `Release "${id}" must sort after "${latest}"`);
5183
+ const given = await catchUpLabels(tx, labels, newest);
5184
+ if (given.size > 0) enabled = enabled.map((row) => given.has(row.id) ? {
5185
+ ...row,
5186
+ label: given.get(row.id)
5187
+ } : row);
4806
5188
  release = {
4807
5189
  ...change.row,
4808
- id
5190
+ id,
5191
+ label: await labels.next(scope.channelId, scope.platform)
4809
5192
  };
4810
5193
  if (release.scope_key !== scope.scopeKey || release.channel_id !== scope.channelId || release.platform !== scope.platform || release.strategy !== scope.strategy || release.fingerprint_hash !== scope.fingerprintHash || release.revision !== 1) fail$1("INVALID_SCOPE", "Inserted Release does not match its catalog scope");
4811
5194
  tx.create("releases", release);
@@ -4818,8 +5201,9 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
4818
5201
  await tx.delete("releases", row);
4819
5202
  release = null;
4820
5203
  } else {
5204
+ const { label: _label, ...update } = change.update;
4821
5205
  const set = {
4822
- ...change.update,
5206
+ ...update,
4823
5207
  revision: before.revision + 1
4824
5208
  };
4825
5209
  tx.update("releases", row, set);
@@ -4846,14 +5230,27 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
4846
5230
  */
4847
5231
  var changeReleases = (db, inputs) => {
4848
5232
  if (new Set(inputs.map(({ scope }) => scope.scopeKey)).size !== inputs.length) fail$1("INVALID_SCOPE", "A batch cannot change one catalog scope twice");
4849
- return db.transaction(async (tx) => {
5233
+ return writeWithLabels(db, async (tx, labels) => {
4850
5234
  const results = [];
4851
- for (const input of inputs) results.push(await changeRelease(tx, input));
5235
+ for (const input of inputs) results.push(await changeRelease(tx, input, labels));
4852
5236
  return results;
4853
5237
  });
4854
5238
  };
4855
5239
  /** Whether `current` is what the scope's enabled releases compile to. */
4856
5240
  var isCurrent = (scope, current, compilation) => current.strategy === scope.strategy && current.channel_id === scope.channelId && current.channel_key === encodeChannelKey(scope.channelName) && current.platform === scope.platform && current.fingerprint_hash === scope.fingerprintHash && current.catalog_hash === compilation.catalogHash;
5241
+ /** A compiled payload with its descriptors' labels left out. */
5242
+ var withoutLabels = (payload) => {
5243
+ const parsed = JSON.parse(payload);
5244
+ return JSON.stringify({
5245
+ ...parsed,
5246
+ releaseDescriptors: (parsed.releaseDescriptors ?? []).map(({ label: _label, ...descriptor }) => descriptor)
5247
+ });
5248
+ };
5249
+ /**
5250
+ * Whether `projected` differs from `current` only by release labels, as a
5251
+ * catalog compiled before its releases had them does.
5252
+ */
5253
+ var differsInLabelsOnly = (current, projected) => current.payload !== projected.payload && current.strategy === projected.strategy && current.channel_id === projected.channel_id && current.channel_key === projected.channel_key && current.platform === projected.platform && current.fingerprint_hash === projected.fingerprint_hash && withoutLabels(current.payload) === withoutLabels(projected.payload);
4857
5254
  /** The scope a catalog row names. */
4858
5255
  var catalogRowScope = (row) => ({
4859
5256
  channelId: row.channel_id,
@@ -4878,18 +5275,20 @@ var preflightRebuild = async (db, scopeKey, updatedAtMs) => {
4878
5275
  checkScope(scope);
4879
5276
  const compilation = await compileScope(scope, await drainReleases((cursor) => db.findMany("releases", enabledIn(scopeKey, cursor))));
4880
5277
  const changed = !isCurrent(scope, current, compilation);
5278
+ const projectedCatalog = changed ? nextCatalog(scope, { catalog: current }, compilation, updatedAtMs) : current;
4881
5279
  return {
4882
5280
  changed,
5281
+ labelsOnly: changed && differsInLabelsOnly(current, projectedCatalog),
4883
5282
  currentCatalog: current,
4884
5283
  diagnostics: compilation.diagnostics,
4885
- projectedCatalog: changed ? nextCatalog(scope, { catalog: current }, compilation, updatedAtMs) : current
5284
+ projectedCatalog
4886
5285
  };
4887
5286
  };
4888
5287
  /** Recompiles a scope's catalog from its enabled releases inside `tx`; an unchanged catalog is not rewritten. */
4889
5288
  var rebuildScope = async (tx, scope, updatedAtMs) => {
4890
5289
  checkScope(scope);
4891
5290
  const stored = await readCatalog(tx, scope.scopeKey);
4892
- assertHistory(stored, await latestReleaseId(tx, scope.scopeKey) !== null);
5291
+ assertHistory(stored, await latestRelease(tx, scope.scopeKey) !== null);
4893
5292
  const enabled = await enabledReleases(tx, scope.scopeKey);
4894
5293
  const compilation = await compileScope(scope, enabled);
4895
5294
  const current = stored.catalog;
@@ -4907,6 +5306,7 @@ var rebuildScope = async (tx, scope, updatedAtMs) => {
4907
5306
  diagnostics: written.compilation.diagnostics
4908
5307
  };
4909
5308
  };
5309
+ var CATALOG_PAGE = 100;
4910
5310
  /** Carries a preflight's result out of the transaction it stops, so nothing is written. */
4911
5311
  var Preflight = class extends Error {
4912
5312
  result;
@@ -5138,7 +5538,7 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
5138
5538
  if (targetChannel.length === 0) throw new ReleaseManagementError("TARGET_RELEASE_INVALID", "Promotion requires a target channel.");
5139
5539
  const channel = await ensureChannel(targetChannel);
5140
5540
  const updatedAtMs = now();
5141
- return db.transaction(async (tx) => {
5541
+ return writeWithLabels(db, async (tx, labels) => {
5142
5542
  const { release: source, scope: sourceScope } = await loadTarget(tx, input);
5143
5543
  checkSource(source);
5144
5544
  const targetScope = scopeOf(channel, source.platform, source.fingerprint_hash);
@@ -5166,12 +5566,13 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
5166
5566
  },
5167
5567
  updatedAtMs
5168
5568
  }) : null;
5569
+ const { label: _label, ...copied } = source;
5169
5570
  const target = await changeRelease(tx, {
5170
5571
  scope: targetScope,
5171
5572
  change: {
5172
5573
  operation: "insert",
5173
5574
  row: {
5174
- ...source,
5575
+ ...copied,
5175
5576
  id: createUUIDv7After(floor ?? null, updatedAtMs),
5176
5577
  revision: 1,
5177
5578
  scope_key: targetScope.scopeKey,
@@ -5186,7 +5587,7 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
5186
5587
  }
5187
5588
  },
5188
5589
  updatedAtMs
5189
- });
5590
+ }, labels);
5190
5591
  return {
5191
5592
  source: moved === null ? null : mutationResult(moved),
5192
5593
  target: mutationResult(target)
@@ -5204,6 +5605,38 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
5204
5605
  });
5205
5606
  },
5206
5607
  preflightReleaseCatalogRebuild: (scopeKey) => preflightRebuild(db, scopeKey, now()),
5608
+ fillReleaseLabels: async ({ dryRun = false, catalogs = true } = {}) => {
5609
+ let releases = 0;
5610
+ const pairs = await pendingLabelPairs(db);
5611
+ if (dryRun && pairs[0] !== void 0) await probeLabelSchema(db, pairs[0]);
5612
+ for (const pair of pairs) releases += await fillLabels(db, pair, { dryRun });
5613
+ let rebuilt = 0;
5614
+ if (catalogs) {
5615
+ let cursor;
5616
+ do {
5617
+ const page = await db.findMany("release_catalogs", {
5618
+ index: "all",
5619
+ where: {},
5620
+ limit: CATALOG_PAGE,
5621
+ ...cursor === void 0 ? {} : { cursor }
5622
+ });
5623
+ for (const row of page.rows) {
5624
+ if (row.is_tombstone) continue;
5625
+ const preflight = await preflightRebuild(db, row.scope_key, now()).catch(() => null);
5626
+ if (preflight === null || !preflight.labelsOnly) continue;
5627
+ rebuilt += 1;
5628
+ if (dryRun) continue;
5629
+ const updatedAtMs = now();
5630
+ await db.transaction((tx) => rebuildScope(tx, catalogRowScope(toCatalogRow(row)), updatedAtMs));
5631
+ }
5632
+ cursor = page.next;
5633
+ } while (cursor !== void 0);
5634
+ }
5635
+ return {
5636
+ releases,
5637
+ catalogs: rebuilt
5638
+ };
5639
+ },
5207
5640
  ensureChannel,
5208
5641
  deleteChannel: (id) => deleteChannel(db, id),
5209
5642
  updateBundle: (id, update) => db.transaction(async (tx) => {
@@ -5749,6 +6182,26 @@ var createAdminRouteHandlers = () => ({
5749
6182
  return row === null ? notFound() : json({ data: row });
5750
6183
  }),
5751
6184
  rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
6185
+ getReleaseByLabel: onCore(async (core, request) => {
6186
+ const url = new URL(request.url);
6187
+ const channel = url.searchParams.get("channel");
6188
+ const platform = platformOf(url);
6189
+ const label = Number(url.searchParams.get("label"));
6190
+ if (channel === null || channel.length === 0 || platform === void 0 || !Number.isSafeInteger(label) || label < 1) throw new HandlerBadRequestError("A release label lookup takes channel, platform, and a label of 1 or more.");
6191
+ return json({ data: await core.getReleaseByLabel({
6192
+ channel,
6193
+ platform,
6194
+ label
6195
+ }) });
6196
+ }),
6197
+ fillReleaseLabels: onCore(async (core, request) => {
6198
+ const body = await request.json().catch(() => ({}));
6199
+ const input = body !== null && typeof body === "object" ? body : {};
6200
+ return json({ data: await core.fillReleaseLabels({
6201
+ dryRun: input.dryRun === true,
6202
+ catalogs: input.catalogs !== false
6203
+ }) });
6204
+ }),
5752
6205
  updateBundle: onCore(async (core, request, params) => {
5753
6206
  const bundleId = requireRouteParam(params, "id");
5754
6207
  const update = bundleUpdateOf(await request.json(), bundleId);
@@ -5975,6 +6428,16 @@ var ADMIN_ROUTES = [
5975
6428
  path: "/release-scopes",
5976
6429
  handler: "listReleaseScopeKeys"
5977
6430
  },
6431
+ {
6432
+ method: "GET",
6433
+ path: "/release-labels",
6434
+ handler: "getReleaseByLabel"
6435
+ },
6436
+ {
6437
+ method: "POST",
6438
+ path: "/release-labels/fill",
6439
+ handler: "fillReleaseLabels"
6440
+ },
5978
6441
  {
5979
6442
  method: "POST",
5980
6443
  path: "/release-catalogs/:scopeKey/rebuild",