@hot-updater/console 1.2.0-rc.50 → 1.2.0-rc.52
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/.output/nitro.json +1 -1
- package/.output/public/assets/BundleIdDisplay-CtbmyR7f.js +1 -0
- package/.output/public/assets/{FoldedRows-1NvB9gAS.js → FoldedRows-ClHLI-NM.js} +1 -1
- package/.output/public/assets/{IosInstall-BRuSakxm.js → IosInstall-1a_GRSNg.js} +1 -1
- package/.output/public/assets/{RelativeTime-m-FKh1Jb.js → RelativeTime-BQErgQRj.js} +1 -1
- package/.output/public/assets/{TargetDisplay-Ctuz3qIp.js → TargetDisplay-D0dVdFCk.js} +1 -1
- package/.output/public/assets/{index-oTXLdUR-.js → index-B8BpJ73Y.js} +2 -2
- package/.output/public/assets/{insights-BL6Z8zFv.js → insights-BrdBpqda.js} +2 -2
- package/.output/public/assets/{insights-BMjBMtJU.js → insights-DsmTCDix.js} +2 -2
- package/.output/public/assets/{insights_.distribution-C4E-JuVI.js → insights_.distribution-BHmK7ufZ.js} +1 -1
- package/.output/public/assets/{insights_.distribution-Br_CW9s9.js → insights_.distribution-BNNw0whH.js} +2 -2
- package/.output/public/assets/native-builds-B6t0ZxKP.js +1 -0
- package/.output/public/assets/{native-builds-BC0sjxPC.js → native-builds-CgPSpNsA.js} +2 -2
- package/.output/public/assets/native-builds-TF9BhYrQ.js +1 -0
- package/.output/public/assets/{native-builds_._buildId-GPlkI_2m.js → native-builds_._buildId-2rPrtz9-.js} +2 -2
- package/.output/public/assets/native-builds_._buildId-BqUOY1Az.js +1 -0
- package/.output/public/assets/{native-builds_.devices-Cox001IR.js → native-builds_.devices-B9kLHngv.js} +2 -2
- package/.output/public/assets/{native-builds_.devices-DAW19hcQ.js → native-builds_.devices-COFYZcaA.js} +1 -1
- package/.output/public/assets/{routes-C7Pv3Cfg.js → routes-DMooqgLf.js} +1 -1
- package/.output/public/assets/{routes-JJGRGqsf.js → routes-Z2IGj8MK.js} +2 -2
- package/.output/server/{__23tanstack-start-server-fn-resolver-DY-niJR4.mjs → __23tanstack-start-server-fn-resolver-5-sH58Zz.mjs} +58 -58
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +1 -1
- package/.output/server/_libs/_.mjs +1 -1
- package/.output/server/_ssr/BundleIdDisplay-BckrkdA8.mjs +26 -0
- package/.output/server/_ssr/{ChannelPicker-J5HfKxSS.mjs → ChannelPicker-D6t_05Qj.mjs} +4 -4
- package/.output/server/_ssr/{ConsoleFeatureUnavailable-C52o4oew.mjs → ConsoleFeatureUnavailable-DO9N_oMb.mjs} +6 -6
- package/.output/server/_ssr/{EventDetails-CDLSkVNA.mjs → EventDetails-eHJBruoj.mjs} +6 -6
- package/.output/server/_ssr/{FoldedRows-CrRYEVkd.mjs → FoldedRows-CVbAvnm9.mjs} +4 -4
- package/.output/server/_ssr/{HashValueDisplay-BrT2wgxk.mjs → HashValueDisplay-B8AYphB-.mjs} +2 -2
- package/.output/server/_ssr/{InsightsPageHeader-DVrudLMJ.mjs → InsightsPageHeader-BFzDTBgX.mjs} +6 -6
- package/.output/server/_ssr/{IosInstall-DcKlZU_q.mjs → IosInstall-BlvkrktH.mjs} +8 -8
- package/.output/server/_ssr/{NativeBuildsNav-BC1WIQ1W.mjs → NativeBuildsNav-AfTTpjkh.mjs} +3 -3
- package/.output/server/_ssr/{NotFoundPage-CEhZtcst.mjs → NotFoundPage-r-7WnJzQ.mjs} +2 -2
- package/.output/server/_ssr/{QrCode-Dj9BKV3l.mjs → QrCode-DEZJJw2v.mjs} +2 -2
- package/.output/server/_ssr/{RelativeTime-Dgbh4UPb.mjs → RelativeTime-D31YzeJa.mjs} +3 -3
- package/.output/server/_ssr/{RolloutPercentageBadge-BYEDUW1d.mjs → RolloutPercentageBadge-DGQCzLwL.mjs} +3 -3
- package/.output/server/_ssr/{RowReason-BweNBWkA.mjs → RowReason-XXsqcV8M.mjs} +3 -3
- package/.output/server/_ssr/{SandboxBadge-O8-kbXAw.mjs → SandboxBadge-Dsbfs84l.mjs} +2 -2
- package/.output/server/_ssr/{TargetDisplay-D3JAXwcF.mjs → TargetDisplay-Cnnda7gi.mjs} +3 -3
- package/.output/server/_ssr/{alert-dialog-CxEcyUb6.mjs → alert-dialog-CeW-6rPj.mjs} +1 -1
- package/.output/server/_ssr/{api-IIqxWeDx.mjs → api-BCfNV622.mjs} +4 -4
- package/.output/server/_ssr/{api-keys-wFak2vKN.mjs → api-keys-D41INr2x.mjs} +9 -9
- package/.output/server/_ssr/{api-keys-CYefExfc.mjs → api-keys-Pl9fE3ov.mjs} +2 -2
- package/.output/server/_ssr/{api-keys-rpc-qkGQ3Sp3.mjs → api-keys-rpc-Dc63Z5sL.mjs} +3 -3
- package/.output/server/_ssr/{api-rpc-3NKc545A.mjs → api-rpc-CBxVNmSb.mjs} +16 -16
- package/.output/server/_ssr/{auth-rpc-PCSJzNJf.mjs → auth-rpc-DUiSq0md.mjs} +4 -4
- package/.output/server/_ssr/{auth.server-NGj7G3bq.mjs → auth.server-COR78Byc.mjs} +532 -31
- package/.output/server/_ssr/{badge-CxSJ-pjU.mjs → badge-jJUdKmgf.mjs} +1 -1
- package/.output/server/_ssr/{card-BDXDcrk_.mjs → card-lbRho9mB.mjs} +1 -1
- package/.output/server/_ssr/{config.server-CwUGPk-F.mjs → config.server-C72Rcb2P.mjs} +3 -3
- package/.output/server/_ssr/{console-access-BOt-Xxd7.mjs → console-access-B6GCF0Pq.mjs} +2 -2
- package/.output/server/_ssr/{console-features-api-Dw_Tktev.mjs → console-features-api-GXe67Tju.mjs} +5 -5
- package/.output/server/_ssr/{console-features-rpc-D8VFHwYj.mjs → console-features-rpc-BB8bGBmb.mjs} +3 -3
- package/.output/server/_ssr/{databaseRows-BZMFl5QV.mjs → databaseRows-D6bc51Xq.mjs} +3 -2
- package/.output/server/_ssr/{dialog-CJ4zMagm.mjs → dialog-DLiITzNb.mjs} +1 -1
- package/.output/server/_ssr/{empty-DYy36pwa.mjs → empty-CRonI6yG.mjs} +2 -2
- package/.output/server/_ssr/{field-MI8oNc5n.mjs → field-CPlXgkpQ.mjs} +2 -2
- package/.output/server/_ssr/{getBundleChildren-CnOf4Frp.mjs → getBundleChildren-DDqsd1pL.mjs} +2 -2
- package/.output/server/_ssr/{input-group-Bf7wHa21.mjs → input-group-B0s6OlWV.mjs} +1 -1
- package/.output/server/_ssr/{insights-b3XeQlzF.mjs → insights-Bukk9Qg8.mjs} +52 -33
- package/.output/server/_ssr/{insights-CbGG5htV.mjs → insights-CVUqkV9I.mjs} +2 -2
- package/.output/server/_ssr/{insights-CKTR62Ox.mjs → insights-ToswhUey.mjs} +5 -5
- package/.output/server/_ssr/{insights-api-CqjIxe1A.mjs → insights-api-CA17vWZa.mjs} +3 -3
- package/.output/server/_ssr/{insights-failures-rpc-fmWHkLhL.mjs → insights-failures-rpc-DQ15P_rm.mjs} +4 -4
- package/.output/server/_ssr/{insights-recovery-rpc-BpwoS9XL.mjs → insights-recovery-rpc-CW4mfXig.mjs} +3 -3
- package/.output/server/_ssr/{insights-rpc-qwXzuBUQ.mjs → insights-rpc-C4Xpuj96.mjs} +3 -3
- package/.output/server/_ssr/{insights-search-B_8PizlM.mjs → insights-search-BULxEDkP.mjs} +2 -2
- package/.output/server/_ssr/{insights-usage-rpc-D8lgk1Sk.mjs → insights-usage-rpc-BJXlIwCd.mjs} +3 -3
- package/.output/server/_ssr/{insights-usage-rpc-Cbg82l2g.mjs → insights-usage-rpc-BO2bIBYf.mjs} +3 -3
- package/.output/server/_ssr/{insights_.distribution-Ed2vqrwP.mjs → insights_.distribution-DRI0VBdO.mjs} +5 -5
- package/.output/server/_ssr/{insights_.distribution--XTBM-oT.mjs → insights_.distribution-PeRcluc-.mjs} +14 -14
- package/.output/server/_ssr/{insights_.distribution-DTaKryjw.mjs → insights_.distribution-SGWggxSh.mjs} +2 -2
- package/.output/server/_ssr/{installations-Ce_9dNq0.mjs → installations-B2QcWG6B.mjs} +2 -2
- package/.output/server/_ssr/{installations-W8W7AYwn.mjs → installations-C692ehbS.mjs} +4 -4
- package/.output/server/_ssr/{installations-DyfuFp3L.mjs → installations-CJjMPoSX.mjs} +11 -11
- package/.output/server/_ssr/{ios-devices-rpc-5kZM1bgU.mjs → ios-devices-rpc-C0ksMG0_.mjs} +7 -7
- package/.output/server/_ssr/{iosDeviceCookie-BTfPOUhS.mjs → iosDeviceCookie-D32VPfkD.mjs} +3 -3
- package/.output/server/_ssr/{iosDeviceProfile-BAoo32s_.mjs → iosDeviceProfile-Ci_-qRZG.mjs} +3 -3
- package/.output/server/_ssr/{iosDevices-DuNmS3td.mjs → iosDevices-Bk-459x2.mjs} +3 -3
- package/.output/server/_ssr/{native-builds-1s5DIHa2.mjs → native-builds-2zov7e9h.mjs} +2 -2
- package/.output/server/_ssr/{native-builds-lEyKQemV.mjs → native-builds-C2xGyB-t.mjs} +19 -8
- package/.output/server/_ssr/{native-builds-DEyFHKDa.mjs → native-builds-D8wSoxxF.mjs} +21 -19
- package/.output/server/_ssr/{native-builds_._buildId-mJ8i0pL8.mjs → native-builds_._buildId-B3rk9gG4.mjs} +2 -2
- package/.output/server/_ssr/{native-builds_._buildId-ElCXKaXI.mjs → native-builds_._buildId-Do6W7jm2.mjs} +50 -40
- package/.output/server/_ssr/{native-builds_.devices-Dz8b48Fo.mjs → native-builds_.devices-KlAzG0Zy.mjs} +2 -2
- package/.output/server/_ssr/{native-builds_.devices-DNWZLCra.mjs → native-builds_.devices-lv3e5WXD.mjs} +17 -17
- package/.output/server/_ssr/{nativeBuildDownloadLink-D8Se_CCi.mjs → nativeBuildDownloadLink-C9WaekZx.mjs} +2 -2
- package/.output/server/_ssr/{nativeBuildInstall-DemC_4Zc.mjs → nativeBuildInstall-SCpQShAb.mjs} +5 -5
- package/.output/server/_ssr/{nativeBuilds-BFSeuC75.mjs → nativeBuilds-yTOa0vdF.mjs} +5 -5
- package/.output/server/_ssr/{release-adoption-rpc-1mKibOdV.mjs → release-adoption-rpc-CC35TIiN.mjs} +6 -6
- package/.output/server/_ssr/{releaseAdoption-DfEYq7I4.mjs → releaseAdoption-BNp2LKR5.mjs} +2 -1
- package/.output/server/_ssr/{releaseCatalogCompiler-CuL3ptgg.mjs → releaseCatalogCompiler-B7k_Eask.mjs} +90 -9
- package/.output/server/_ssr/{remote-config-q9fegj-G.mjs → remote-config-B3udiYoT.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-D2Cohnwn.mjs → remote-config-Erbkr_jI.mjs} +2 -2
- package/.output/server/_ssr/{remote-config-rpc-6hfHFrO6.mjs → remote-config-rpc-BNwGDXiU.mjs} +3 -3
- package/.output/server/_ssr/{remote-config-C_HNYPZ_.mjs → remote-config-u5wKgmdI.mjs} +18 -18
- package/.output/server/_ssr/{router-DODxASKG.mjs → router-BdIR78Dg.mjs} +35 -35
- package/.output/server/_ssr/{routes-C-nYThl0.mjs → routes-DiZ2ak9R.mjs} +10 -10
- package/.output/server/_ssr/{routes-BJjTUNSe.mjs → routes-DsdrQwy2.mjs} +31 -27
- package/.output/server/_ssr/{schema-migration-rpc-C31JquTn.mjs → schema-migration-rpc-C1KyK4Vo.mjs} +3 -3
- package/.output/server/_ssr/{select-CjACvu9s.mjs → select-E27bwyIg.mjs} +1 -1
- package/.output/server/_ssr/{server-Dyw2qgSR.mjs → server-3Oa4eaU_.mjs} +3 -3
- package/.output/server/_ssr/{sidebar-DQkRAO_e.mjs → sidebar-Di_cdJt9.mjs} +2 -2
- package/.output/server/_ssr/ssr.mjs +1 -1
- package/.output/server/_ssr/{switch-DZJSRVl3.mjs → switch-BYzRl3rt.mjs} +2 -2
- package/.output/server/_ssr/{table-BA-6GQFs.mjs → table-BbpblfLX.mjs} +1 -1
- package/.output/server/_ssr/{tabs-CtB3PIts.mjs → tabs-CUBGKQ4v.mjs} +2 -2
- package/.output/server/{_tanstack-start-manifest_v-Bfv6fYk6.mjs → _tanstack-start-manifest_v-MJAIGQWT.mjs} +30 -30
- package/.output/server/index.mjs +177 -177
- package/package.json +7 -7
- package/src/components/BundleIdDisplay.tsx +30 -3
- package/src/components/features/insights/ComparedBundlesChart.tsx +1 -0
- package/src/components/features/insights/InsightsControls.tsx +28 -4
- package/src/components/features/insights/InsightsOverview.tsx +3 -1
- package/src/components/features/insights/ReleaseCombobox.tsx +7 -2
- package/src/components/features/insights/RollbackButton.tsx +1 -1
- package/src/components/features/native-builds/BuiltInBundleCard.tsx +3 -2
- package/src/components/features/native-builds/NativeBuildDetailPage.tsx +9 -0
- package/src/components/features/native-builds/NativeBuildsTable.tsx +7 -4
- package/src/components/features/native-builds/ServedNowCard.tsx +6 -3
- package/src/components/features/releases/ReleaseEditorSheet.tsx +6 -3
- package/src/lib/native-builds.ts +28 -20
- package/src/lib/release-adoption.ts +2 -0
- package/src/lib/server/releaseAdoption.ts +1 -0
- package/src/routes/index.tsx +5 -1
- package/.output/public/assets/BundleIdDisplay-C0X-k49t.js +0 -1
- package/.output/public/assets/native-builds-B0zJ4wjg.js +0 -1
- package/.output/public/assets/native-builds-B_pQ4D5H.js +0 -1
- package/.output/public/assets/native-builds_._buildId-CSyC7YAA.js +0 -1
- 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-
|
|
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-
|
|
8
|
+
import { a as readCompiledCatalogPayload, i as projectCompiledRollbackCatalog, n as compileReleaseCatalog, r as projectCompiledCatalog, t as ReleaseCatalogCompilationError } from "./releaseCatalogCompiler-B7k_Eask.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-
|
|
12
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/auth.server-COR78Byc.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);
|
|
@@ -600,6 +600,23 @@ var SETTINGS_TABLE = {
|
|
|
600
600
|
/** The engine's storage-layout generation; it changes only with a migration. */
|
|
601
601
|
var ENGINE_SCHEMA_KEY = "schema.engine";
|
|
602
602
|
var CORE_SCHEMA_KEY = "schema.core";
|
|
603
|
+
/** Compares dotted numeric versions, such as "1" and "1.2.0"; NaN when either is not one. */
|
|
604
|
+
var compareVersions = (left, right) => {
|
|
605
|
+
const parse = (version) => /^\d+(?:\.\d+)*$/u.test(version) ? version.split(".").map(Number) : [NaN];
|
|
606
|
+
const [a, b] = [parse(left), parse(right)];
|
|
607
|
+
if ([...a, ...b].some(Number.isNaN)) return NaN;
|
|
608
|
+
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
609
|
+
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
610
|
+
if (difference !== 0) return difference;
|
|
611
|
+
}
|
|
612
|
+
return 0;
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* The `schema.core` a newer release recorded, which `hot-updater db migrate`
|
|
616
|
+
* never moves back: the fix is to upgrade, not to migrate.
|
|
617
|
+
*/
|
|
618
|
+
var newerCore = (settings) => settings.find(({ key, expected, found }) => key === CORE_SCHEMA_KEY && found !== null && compareVersions(found, expected) > 0);
|
|
619
|
+
var newerMessage = (adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is "${found}"; expected "${expected}". The database was migrated by Hot Updater ${found}: upgrade hot-updater and the @hot-updater packages to ${found} or later.`;
|
|
603
620
|
var stored = ({ key, expected, found }) => `"${key}" is ${found === null ? "missing" : `"${found}"`}; expected "${expected}"`;
|
|
604
621
|
/**
|
|
605
622
|
* How to migrate a database the fence refused: doctor names the command for
|
|
@@ -613,7 +630,10 @@ var pluginOf = ({ key }) => key.startsWith("schema.") && key !== "schema.engine"
|
|
|
613
630
|
var listed = (items) => items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
614
631
|
var settingsMessage = (adapterName, settings) => `Hot Updater schema settings for ${adapterName} are not migrated: ${settings.map(stored).join(", and ")}. ${MIGRATE_SCHEMA_FIX}`;
|
|
615
632
|
var pluginsMessage = (adapterName, plugins, settings, fix) => `The tables of ${plugins.length === 1 ? "plugin" : "plugins"} ${listed(plugins.map((id) => `"${id}"`))} are not migrated on ${adapterName}: schema ${settings.length === 1 ? "setting" : "settings"} ${settings.map(stored).join(", and ")}. ${fix}`;
|
|
616
|
-
/**
|
|
633
|
+
/**
|
|
634
|
+
* The database needs `hot-updater db migrate`, a new database, or a newer
|
|
635
|
+
* Hot Updater; the handler answers 503.
|
|
636
|
+
*/
|
|
617
637
|
var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
618
638
|
adapterName;
|
|
619
639
|
currentVersion;
|
|
@@ -628,7 +648,8 @@ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
|
628
648
|
constructor(adapterName, currentVersion, setting, options) {
|
|
629
649
|
const settings = options?.settings ?? (setting === void 0 ? [] : [setting]);
|
|
630
650
|
const plugins = settings.flatMap((mismatch) => pluginOf(mismatch) ?? []);
|
|
631
|
-
|
|
651
|
+
const newer = newerCore(settings);
|
|
652
|
+
super(newer !== void 0 ? newerMessage(adapterName, newer) : setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. ${MIGRATE_SCHEMA_FIX}` : `Hot Updater v1 cannot migrate schema ${currentVersion} in place. Create a new empty database and run \`hot-updater db migrate\`.` : plugins.length > 0 && plugins.length === settings.length ? pluginsMessage(adapterName, plugins, settings, options?.fix ?? MIGRATE_SCHEMA_FIX) : settings.length > 1 && !(setting.key === "schema.engine" && setting.found === null) ? settingsMessage(adapterName, settings) : settingMessage(adapterName, setting), options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
632
653
|
this.adapterName = adapterName;
|
|
633
654
|
this.currentVersion = currentVersion;
|
|
634
655
|
this.setting = setting;
|
|
@@ -893,7 +914,11 @@ var releases = defineTable({
|
|
|
893
914
|
}
|
|
894
915
|
},
|
|
895
916
|
created_at_ms: { type: "integer" },
|
|
896
|
-
updated_at_ms: { type: "integer" }
|
|
917
|
+
updated_at_ms: { type: "integer" },
|
|
918
|
+
label: {
|
|
919
|
+
type: "integer",
|
|
920
|
+
required: false
|
|
921
|
+
}
|
|
897
922
|
}, {
|
|
898
923
|
key: ["id"],
|
|
899
924
|
indexes: {
|
|
@@ -930,9 +955,42 @@ var releases = defineTable({
|
|
|
930
955
|
scopes: {
|
|
931
956
|
eq: [],
|
|
932
957
|
sort: ["scope_key"]
|
|
958
|
+
},
|
|
959
|
+
byLabel: {
|
|
960
|
+
eq: [
|
|
961
|
+
"channel_id",
|
|
962
|
+
"platform",
|
|
963
|
+
"label"
|
|
964
|
+
],
|
|
965
|
+
sort: [],
|
|
966
|
+
unique: true
|
|
933
967
|
}
|
|
934
968
|
}
|
|
935
969
|
});
|
|
970
|
+
/**
|
|
971
|
+
* One counter per sequence: `releases/<platform>/<channel ID>` holds the
|
|
972
|
+
* last label that channel and platform's releases took. A deploy or a
|
|
973
|
+
* promote reads it and writes the next value in the transaction that writes
|
|
974
|
+
* the release, so two writers never take one label. `is_filled` is true once
|
|
975
|
+
* every release of the sequence written before labels has one, in ID order;
|
|
976
|
+
* until then a writer fills them first. Deleting a channel deletes its
|
|
977
|
+
* counters, so a channel created again with the name starts at 1.
|
|
978
|
+
*/
|
|
979
|
+
var labelSequences = defineTable({
|
|
980
|
+
id: {
|
|
981
|
+
type: "string",
|
|
982
|
+
maxLength: 1440,
|
|
983
|
+
ascii: true
|
|
984
|
+
},
|
|
985
|
+
last_label: { type: "integer" },
|
|
986
|
+
is_filled: { type: "boolean" }
|
|
987
|
+
}, {
|
|
988
|
+
key: ["id"],
|
|
989
|
+
indexes: { all: {
|
|
990
|
+
eq: [],
|
|
991
|
+
sort: ["id"]
|
|
992
|
+
} }
|
|
993
|
+
});
|
|
936
994
|
/** One compiled catalog per scope; the update check reads exactly this row. */
|
|
937
995
|
var releaseCatalogs = defineTable({
|
|
938
996
|
scope_key: {
|
|
@@ -1302,7 +1360,8 @@ var coreModule = {
|
|
|
1302
1360
|
}),
|
|
1303
1361
|
native_builds: nativeBuilds,
|
|
1304
1362
|
ios_devices: iosDevices,
|
|
1305
|
-
ios_device_account: iosDeviceAccount
|
|
1363
|
+
ios_device_account: iosDeviceAccount,
|
|
1364
|
+
label_sequences: labelSequences
|
|
1306
1365
|
}
|
|
1307
1366
|
};
|
|
1308
1367
|
var encoder = new TextEncoder();
|
|
@@ -3039,7 +3098,7 @@ var createEngine = (database, { plugins = [], now = Date.now } = {}) => {
|
|
|
3039
3098
|
flush: () => engine.flush()
|
|
3040
3099
|
};
|
|
3041
3100
|
};
|
|
3042
|
-
var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
3101
|
+
var HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.52";
|
|
3043
3102
|
/**
|
|
3044
3103
|
* `/version` on both mounts. The admin mount also lists the ids of the
|
|
3045
3104
|
* plugins the server runs, sorted; apps never learn which plugins a server
|
|
@@ -3480,7 +3539,7 @@ var baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
3480
3539
|
}
|
|
3481
3540
|
return ids;
|
|
3482
3541
|
};
|
|
3483
|
-
var PAGE$
|
|
3542
|
+
var PAGE$3 = 500;
|
|
3484
3543
|
var pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
3485
3544
|
var toBundleRow = pick$2([
|
|
3486
3545
|
"id",
|
|
@@ -3501,7 +3560,7 @@ var toPatchRow = pick$2([
|
|
|
3501
3560
|
"byte_size",
|
|
3502
3561
|
"order_index"
|
|
3503
3562
|
]);
|
|
3504
|
-
var
|
|
3563
|
+
var pickReleaseRow = pick$2([
|
|
3505
3564
|
"id",
|
|
3506
3565
|
"revision",
|
|
3507
3566
|
"scope_key",
|
|
@@ -3522,6 +3581,13 @@ var toReleaseRow = pick$2([
|
|
|
3522
3581
|
"created_at_ms",
|
|
3523
3582
|
"updated_at_ms"
|
|
3524
3583
|
]);
|
|
3584
|
+
/** A release row; `label` null where the store holds none, as before the column. */
|
|
3585
|
+
var toReleaseRow = (row) => {
|
|
3586
|
+
return {
|
|
3587
|
+
...pickReleaseRow(row),
|
|
3588
|
+
label: typeof row.label === "number" ? row.label : null
|
|
3589
|
+
};
|
|
3590
|
+
};
|
|
3525
3591
|
var toCatalogRow = pick$2([
|
|
3526
3592
|
"scope_key",
|
|
3527
3593
|
"catalog_id",
|
|
@@ -3570,7 +3636,7 @@ var createCoreReads = (db, storage) => {
|
|
|
3570
3636
|
const page = await db.findMany("bundle_patches", {
|
|
3571
3637
|
index: "byBundle",
|
|
3572
3638
|
where: { bundle_id: row.id },
|
|
3573
|
-
limit: Math.min(count - patches.length, PAGE$
|
|
3639
|
+
limit: Math.min(count - patches.length, PAGE$3),
|
|
3574
3640
|
...cursor === void 0 ? {} : { cursor }
|
|
3575
3641
|
});
|
|
3576
3642
|
patches.push(...page.rows.map(toPatchRow));
|
|
@@ -3671,6 +3737,18 @@ var createCoreReads = (db, storage) => {
|
|
|
3671
3737
|
const row = await db.findOne("releases", { id });
|
|
3672
3738
|
return row === null ? null : toReleaseRow(row);
|
|
3673
3739
|
},
|
|
3740
|
+
async getReleaseByLabel({ channel, platform, label }) {
|
|
3741
|
+
const found = await db.findOne("releases", {
|
|
3742
|
+
channel_id: `channel:${encodeChannelKey(channel)}`,
|
|
3743
|
+
platform,
|
|
3744
|
+
label
|
|
3745
|
+
});
|
|
3746
|
+
if (found === null) return null;
|
|
3747
|
+
const row = await db.findOne("releases", { id: found.id });
|
|
3748
|
+
if (row === null) return null;
|
|
3749
|
+
const release = toReleaseRow(row);
|
|
3750
|
+
return release.label === label && release.platform === platform ? release : null;
|
|
3751
|
+
},
|
|
3674
3752
|
async listReleases(input) {
|
|
3675
3753
|
const { filter } = input;
|
|
3676
3754
|
const options = {
|
|
@@ -3762,7 +3840,7 @@ var createCoreReads = (db, storage) => {
|
|
|
3762
3840
|
return (await drain((page) => db.findMany("channels", {
|
|
3763
3841
|
index: "all",
|
|
3764
3842
|
where: {},
|
|
3765
|
-
limit: PAGE$
|
|
3843
|
+
limit: PAGE$3,
|
|
3766
3844
|
...page
|
|
3767
3845
|
}))).map(toChannelRow);
|
|
3768
3846
|
},
|
|
@@ -4085,6 +4163,311 @@ var NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
|
|
|
4085
4163
|
],
|
|
4086
4164
|
ios: ["testflight"]
|
|
4087
4165
|
};
|
|
4166
|
+
/**
|
|
4167
|
+
* The counter of a channel and platform's release labels: one
|
|
4168
|
+
* `label_sequences` row, which every writer of the pair reads and bumps.
|
|
4169
|
+
*/
|
|
4170
|
+
var labelSequenceId = (channelId, platform) => `releases/${platform}/${channelId}`;
|
|
4171
|
+
/** The pairs a channel's counters belong to, which deleting it removes. */
|
|
4172
|
+
var LABEL_PLATFORMS = ["ios", "android"];
|
|
4173
|
+
/**
|
|
4174
|
+
* A channel and platform whose releases written before labels have none
|
|
4175
|
+
* yet, or that has no counter: the write stops before taking a label, the
|
|
4176
|
+
* core labels the pair with `fillLabels`, and the write runs again.
|
|
4177
|
+
*/
|
|
4178
|
+
var NeedsLabelFill = class extends Error {
|
|
4179
|
+
channelId;
|
|
4180
|
+
platform;
|
|
4181
|
+
constructor(channelId, platform) {
|
|
4182
|
+
super(`Release labels of ${platform} ${channelId} need a fill first.`);
|
|
4183
|
+
this.channelId = channelId;
|
|
4184
|
+
this.platform = platform;
|
|
4185
|
+
}
|
|
4186
|
+
};
|
|
4187
|
+
var createLabelAllocator = (tx, used, caughtUp) => {
|
|
4188
|
+
const sequences = /* @__PURE__ */ new Map();
|
|
4189
|
+
return {
|
|
4190
|
+
async next(channelId, platform) {
|
|
4191
|
+
const id = labelSequenceId(channelId, platform);
|
|
4192
|
+
let sequence = sequences.get(id);
|
|
4193
|
+
if (sequence === void 0) {
|
|
4194
|
+
const row = await tx.findOne("label_sequences", { id });
|
|
4195
|
+
if (row === null || !row.is_filled) {
|
|
4196
|
+
const channel = row === null ? await tx.findOne("channels", { id: channelId }) : null;
|
|
4197
|
+
if (channel === null || (channel._refs_releases_channel_id ?? 0) > 0) throw new NeedsLabelFill(channelId, platform);
|
|
4198
|
+
}
|
|
4199
|
+
const read = row?.last_label ?? 0;
|
|
4200
|
+
sequence = {
|
|
4201
|
+
row,
|
|
4202
|
+
read,
|
|
4203
|
+
last: read
|
|
4204
|
+
};
|
|
4205
|
+
sequences.set(id, sequence);
|
|
4206
|
+
used.set(id, {
|
|
4207
|
+
channelId,
|
|
4208
|
+
platform,
|
|
4209
|
+
read
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
sequence.last += 1;
|
|
4213
|
+
return sequence.last;
|
|
4214
|
+
},
|
|
4215
|
+
caughtUp(channelId, platform) {
|
|
4216
|
+
caughtUp.set(labelSequenceId(channelId, platform), {
|
|
4217
|
+
channelId,
|
|
4218
|
+
platform
|
|
4219
|
+
});
|
|
4220
|
+
},
|
|
4221
|
+
flush() {
|
|
4222
|
+
for (const [id, { row, read, last }] of sequences) if (row === null) tx.create("label_sequences", {
|
|
4223
|
+
id,
|
|
4224
|
+
last_label: last,
|
|
4225
|
+
is_filled: true
|
|
4226
|
+
});
|
|
4227
|
+
else if (last !== read) tx.update("label_sequences", row, { last_label: last });
|
|
4228
|
+
}
|
|
4229
|
+
};
|
|
4230
|
+
};
|
|
4231
|
+
var FILL_BATCH = 25;
|
|
4232
|
+
var PAGE$2 = 500;
|
|
4233
|
+
/**
|
|
4234
|
+
* Labels a channel and platform's releases that have none, in ID order,
|
|
4235
|
+
* which is the order they were created in, and marks its counter filled:
|
|
4236
|
+
* each batch reads the counter and its rows guarded, so a concurrent fill or
|
|
4237
|
+
* write serializes on the counter and skips what another labeled. With
|
|
4238
|
+
* `dryRun`, it only counts them. Answers how many it labeled.
|
|
4239
|
+
*/
|
|
4240
|
+
var fillLabels = async (db, { channelId, platform }, { dryRun = false } = {}) => {
|
|
4241
|
+
const id = labelSequenceId(channelId, platform);
|
|
4242
|
+
let labeled = 0;
|
|
4243
|
+
let batchSize = FILL_BATCH;
|
|
4244
|
+
const label = async (ids) => {
|
|
4245
|
+
for (let at = 0; at < ids.length;) {
|
|
4246
|
+
const batch = ids.slice(at, at + batchSize);
|
|
4247
|
+
try {
|
|
4248
|
+
labeled += await db.transaction(async (tx) => {
|
|
4249
|
+
const counter = await tx.findOne("label_sequences", { id });
|
|
4250
|
+
let last = counter?.last_label ?? 0;
|
|
4251
|
+
let count = 0;
|
|
4252
|
+
for (const releaseId of batch) {
|
|
4253
|
+
const row = await tx.findOne("releases", { id: releaseId });
|
|
4254
|
+
if (row === null || typeof row.label === "number") continue;
|
|
4255
|
+
last += 1;
|
|
4256
|
+
count += 1;
|
|
4257
|
+
tx.update("releases", row, { label: last });
|
|
4258
|
+
}
|
|
4259
|
+
if (counter === null) tx.create("label_sequences", {
|
|
4260
|
+
id,
|
|
4261
|
+
last_label: last,
|
|
4262
|
+
is_filled: false
|
|
4263
|
+
});
|
|
4264
|
+
else if (last !== counter.last_label) tx.update("label_sequences", counter, { last_label: last });
|
|
4265
|
+
return count;
|
|
4266
|
+
});
|
|
4267
|
+
at += batch.length;
|
|
4268
|
+
} catch (error) {
|
|
4269
|
+
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
4270
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
4271
|
+
continue;
|
|
4272
|
+
}
|
|
4273
|
+
throw error;
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
};
|
|
4277
|
+
let cursor;
|
|
4278
|
+
do {
|
|
4279
|
+
const page = await db.findMany("releases", {
|
|
4280
|
+
index: "byChannelPlatform",
|
|
4281
|
+
where: {
|
|
4282
|
+
channel_id: channelId,
|
|
4283
|
+
platform
|
|
4284
|
+
},
|
|
4285
|
+
limit: PAGE$2,
|
|
4286
|
+
...cursor === void 0 ? {} : { cursor }
|
|
4287
|
+
});
|
|
4288
|
+
const unlabeled = page.rows.filter((row) => typeof row.label !== "number").map((row) => row.id);
|
|
4289
|
+
if (dryRun) labeled += unlabeled.length;
|
|
4290
|
+
else await label(unlabeled);
|
|
4291
|
+
cursor = page.next;
|
|
4292
|
+
} while (cursor !== void 0);
|
|
4293
|
+
if (dryRun) return labeled;
|
|
4294
|
+
await db.transaction(async (tx) => {
|
|
4295
|
+
const counter = await tx.findOne("label_sequences", { id });
|
|
4296
|
+
if (counter === null) tx.create("label_sequences", {
|
|
4297
|
+
id,
|
|
4298
|
+
last_label: 0,
|
|
4299
|
+
is_filled: true
|
|
4300
|
+
});
|
|
4301
|
+
else if (!counter.is_filled) tx.update("label_sequences", counter, { is_filled: true });
|
|
4302
|
+
});
|
|
4303
|
+
return labeled;
|
|
4304
|
+
};
|
|
4305
|
+
/**
|
|
4306
|
+
* Reads what a pair's fill writes, its counter and its label index, without
|
|
4307
|
+
* writing: a database without release labels' schema, such as one a 1.2
|
|
4308
|
+
* prerelease migrated, fails here as the fill would. The schema is the
|
|
4309
|
+
* database's, so one pair tells. Two reads.
|
|
4310
|
+
*/
|
|
4311
|
+
var probeLabelSchema = async (db, { channelId, platform }) => {
|
|
4312
|
+
await db.findOne("label_sequences", { id: labelSequenceId(channelId, platform) });
|
|
4313
|
+
await db.findMany("releases", {
|
|
4314
|
+
index: "byLabel",
|
|
4315
|
+
where: {
|
|
4316
|
+
channel_id: channelId,
|
|
4317
|
+
platform,
|
|
4318
|
+
label: 0
|
|
4319
|
+
},
|
|
4320
|
+
limit: 1
|
|
4321
|
+
});
|
|
4322
|
+
};
|
|
4323
|
+
var REPAIRS = 4;
|
|
4324
|
+
var RACES = 32;
|
|
4325
|
+
/**
|
|
4326
|
+
* Runs a release write that takes labels, in one transaction with the
|
|
4327
|
+
* counters it bumps. A pair that still needs its fill is filled, and the
|
|
4328
|
+
* write runs again; so is a pair whose catch-up made the write too large for
|
|
4329
|
+
* the store. A label another row holds, such as an index item a release
|
|
4330
|
+
* deleted by a server of an earlier release left on a key-value store, is
|
|
4331
|
+
* skipped: its counters move past it and the write runs again.
|
|
4332
|
+
*/
|
|
4333
|
+
var writeWithLabels = async (db, write) => {
|
|
4334
|
+
const filled = /* @__PURE__ */ new Set();
|
|
4335
|
+
const fill = async (pairs) => {
|
|
4336
|
+
for (const pair of pairs) {
|
|
4337
|
+
filled.add(labelSequenceId(pair.channelId, pair.platform));
|
|
4338
|
+
await fillLabels(db, pair);
|
|
4339
|
+
}
|
|
4340
|
+
};
|
|
4341
|
+
for (let repairs = 0, races = 0;;) {
|
|
4342
|
+
const used = /* @__PURE__ */ new Map();
|
|
4343
|
+
const caughtUp = /* @__PURE__ */ new Map();
|
|
4344
|
+
try {
|
|
4345
|
+
return await db.transaction(async (tx) => {
|
|
4346
|
+
used.clear();
|
|
4347
|
+
caughtUp.clear();
|
|
4348
|
+
const labels = createLabelAllocator(tx, used, caughtUp);
|
|
4349
|
+
const result = await write(tx, labels);
|
|
4350
|
+
labels.flush();
|
|
4351
|
+
return result;
|
|
4352
|
+
});
|
|
4353
|
+
} catch (error) {
|
|
4354
|
+
const needs = error instanceof NeedsLabelFill ? [error] : error instanceof DatabaseConstraintError && error.reason === "too_large" ? [...caughtUp.values()] : [];
|
|
4355
|
+
if (needs.length > 0) {
|
|
4356
|
+
const fresh = needs.some(({ channelId, platform }) => !filled.has(labelSequenceId(channelId, platform)));
|
|
4357
|
+
if (fresh || repairs < REPAIRS) {
|
|
4358
|
+
if (!fresh) repairs += 1;
|
|
4359
|
+
await fill(needs);
|
|
4360
|
+
continue;
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
if (error instanceof DatabaseConstraintError && error.reason === "unique" && error.model === "releases" && used.size > 0) {
|
|
4364
|
+
if (await db.transaction(async (tx) => {
|
|
4365
|
+
const moves = [];
|
|
4366
|
+
for (const [id, { channelId, read }] of used) {
|
|
4367
|
+
const counter = await tx.findOne("label_sequences", { id });
|
|
4368
|
+
if (counter !== null) {
|
|
4369
|
+
if (counter.last_label !== read) return false;
|
|
4370
|
+
moves.push(() => tx.update("label_sequences", counter, { last_label: read + 1 }));
|
|
4371
|
+
continue;
|
|
4372
|
+
}
|
|
4373
|
+
const channel = await tx.findOne("channels", { id: channelId });
|
|
4374
|
+
if (channel === null || (channel._refs_releases_channel_id ?? 0) > 0) return false;
|
|
4375
|
+
moves.push(() => tx.create("label_sequences", {
|
|
4376
|
+
id,
|
|
4377
|
+
last_label: read + 1,
|
|
4378
|
+
is_filled: true
|
|
4379
|
+
}));
|
|
4380
|
+
}
|
|
4381
|
+
for (const move of moves) move();
|
|
4382
|
+
return true;
|
|
4383
|
+
}) ? (repairs += 1) <= REPAIRS : (races += 1) <= RACES) continue;
|
|
4384
|
+
}
|
|
4385
|
+
throw error;
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
};
|
|
4389
|
+
/**
|
|
4390
|
+
* Labels a scope's releases a server of an earlier release wrote after its
|
|
4391
|
+
* newest labeled one, oldest first, before the write takes its own label:
|
|
4392
|
+
* `latest` is the scope's newest release, so a labeled one costs no read.
|
|
4393
|
+
* Answers the labels it gave, by release ID.
|
|
4394
|
+
*/
|
|
4395
|
+
var catchUpLabels = async (tx, labels, latest) => {
|
|
4396
|
+
const given = /* @__PURE__ */ new Map();
|
|
4397
|
+
if (latest === null || typeof latest.label === "number") return given;
|
|
4398
|
+
const unlabeled = [];
|
|
4399
|
+
let cursor;
|
|
4400
|
+
scan: do {
|
|
4401
|
+
const page = await tx.findMany("releases", {
|
|
4402
|
+
index: "byScope",
|
|
4403
|
+
where: { scope_key: latest.scope_key },
|
|
4404
|
+
order: "desc",
|
|
4405
|
+
limit: FILL_BATCH,
|
|
4406
|
+
...cursor === void 0 ? {} : { cursor }
|
|
4407
|
+
});
|
|
4408
|
+
for (const row of page.rows) {
|
|
4409
|
+
if (typeof row.label === "number") break scan;
|
|
4410
|
+
unlabeled.push(row);
|
|
4411
|
+
}
|
|
4412
|
+
cursor = page.next;
|
|
4413
|
+
} while (cursor !== void 0);
|
|
4414
|
+
labels.caughtUp(latest.channel_id, latest.platform);
|
|
4415
|
+
for (const row of unlabeled.reverse()) {
|
|
4416
|
+
const { id, channel_id, platform } = toReleaseRow(row);
|
|
4417
|
+
const label = await labels.next(channel_id, platform);
|
|
4418
|
+
tx.update("releases", row, { label });
|
|
4419
|
+
given.set(id, label);
|
|
4420
|
+
}
|
|
4421
|
+
return given;
|
|
4422
|
+
};
|
|
4423
|
+
/**
|
|
4424
|
+
* The channels and platforms whose releases need labels: a scope whose
|
|
4425
|
+
* newest release has none, or a pair without a filled counter. Releases a
|
|
4426
|
+
* server of an earlier release wrote in a filled pair come after its
|
|
4427
|
+
* labeled ones in their scope, so the newest release of each scope tells.
|
|
4428
|
+
* Two reads per scope, one per pair.
|
|
4429
|
+
*/
|
|
4430
|
+
var pendingLabelPairs = async (db) => {
|
|
4431
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
4432
|
+
for (let last = "";;) {
|
|
4433
|
+
const { rows } = await db.findMany("releases", {
|
|
4434
|
+
index: "scopes",
|
|
4435
|
+
where: {},
|
|
4436
|
+
limit: 1,
|
|
4437
|
+
range: { gt: last }
|
|
4438
|
+
});
|
|
4439
|
+
if (rows[0] === void 0) break;
|
|
4440
|
+
last = rows[0].scope_key;
|
|
4441
|
+
const { rows: newest } = await db.findMany("releases", {
|
|
4442
|
+
index: "byScope",
|
|
4443
|
+
where: { scope_key: last },
|
|
4444
|
+
order: "desc",
|
|
4445
|
+
limit: 1
|
|
4446
|
+
});
|
|
4447
|
+
if (newest[0] === void 0) continue;
|
|
4448
|
+
const { channel_id: channelId, platform, label } = toReleaseRow(newest[0]);
|
|
4449
|
+
const id = labelSequenceId(channelId, platform);
|
|
4450
|
+
const pair = pairs.get(id) ?? {
|
|
4451
|
+
channelId,
|
|
4452
|
+
platform,
|
|
4453
|
+
pending: false
|
|
4454
|
+
};
|
|
4455
|
+
pair.pending ||= label === null;
|
|
4456
|
+
pairs.set(id, pair);
|
|
4457
|
+
}
|
|
4458
|
+
const pending = [];
|
|
4459
|
+
for (const [id, { channelId, platform, pending: unlabeled }] of pairs) {
|
|
4460
|
+
if (!unlabeled) {
|
|
4461
|
+
const counter = await db.findOne("label_sequences", { id });
|
|
4462
|
+
if (counter !== null && counter.is_filled) continue;
|
|
4463
|
+
}
|
|
4464
|
+
pending.push({
|
|
4465
|
+
channelId,
|
|
4466
|
+
platform
|
|
4467
|
+
});
|
|
4468
|
+
}
|
|
4469
|
+
return pending;
|
|
4470
|
+
};
|
|
4088
4471
|
var PAGE$1 = 500;
|
|
4089
4472
|
/** Moves one bundle into or out of its platform's total and the overall total. */
|
|
4090
4473
|
var countBundle = (tx, platform, delta) => {
|
|
@@ -4164,7 +4547,11 @@ var insertChannel = async (db, row) => {
|
|
|
4164
4547
|
throw error;
|
|
4165
4548
|
}
|
|
4166
4549
|
};
|
|
4167
|
-
/**
|
|
4550
|
+
/**
|
|
4551
|
+
* Deletes a channel no release or native build uses, with its label
|
|
4552
|
+
* counters, so one created again with its name starts at 1: 3 reads,
|
|
4553
|
+
* 1 query, 1 write.
|
|
4554
|
+
*/
|
|
4168
4555
|
var deleteChannel = (db, id) => db.transaction(async (tx) => {
|
|
4169
4556
|
const row = await tx.findOne("channels", { id });
|
|
4170
4557
|
if (row === null) return {
|
|
@@ -4184,6 +4571,10 @@ var deleteChannel = (db, id) => db.transaction(async (tx) => {
|
|
|
4184
4571
|
deleted: false,
|
|
4185
4572
|
reason: "not_empty"
|
|
4186
4573
|
};
|
|
4574
|
+
for (const platform of LABEL_PLATFORMS) {
|
|
4575
|
+
const counter = await tx.findOne("label_sequences", { id: labelSequenceId(id, platform) });
|
|
4576
|
+
if (counter !== null) await tx.delete("label_sequences", counter);
|
|
4577
|
+
}
|
|
4187
4578
|
await tx.delete("channels", row);
|
|
4188
4579
|
return { deleted: true };
|
|
4189
4580
|
});
|
|
@@ -4716,15 +5107,15 @@ var enabledIn = (scopeKey, cursor) => ({
|
|
|
4716
5107
|
});
|
|
4717
5108
|
/** A scope's enabled releases, all of them, under the catalog's guard. */
|
|
4718
5109
|
var enabledReleases = (tx, scopeKey) => drainReleases((cursor) => tx.findMany("releases", enabledIn(scopeKey, cursor)));
|
|
4719
|
-
/** The scope's newest release
|
|
4720
|
-
var
|
|
5110
|
+
/** The scope's newest release: `byScope` descending, limit 1. */
|
|
5111
|
+
var latestRelease = async (tx, scopeKey) => {
|
|
4721
5112
|
const { rows } = await tx.findMany("releases", {
|
|
4722
5113
|
index: "byScope",
|
|
4723
5114
|
where: { scope_key: scopeKey },
|
|
4724
5115
|
order: "desc",
|
|
4725
5116
|
limit: 1
|
|
4726
5117
|
});
|
|
4727
|
-
return rows[0]
|
|
5118
|
+
return rows[0] === void 0 ? null : toReleaseRow(rows[0]);
|
|
4728
5119
|
};
|
|
4729
5120
|
/** The scope's next catalog generation, compiled as `compilation`. */
|
|
4730
5121
|
var nextCatalog = (scope, stored, compilation, updatedAtMs) => {
|
|
@@ -4782,15 +5173,28 @@ var readCatalog = async (tx, scopeKey) => {
|
|
|
4782
5173
|
catalog: row === null ? null : toCatalogRow(row)
|
|
4783
5174
|
};
|
|
4784
5175
|
};
|
|
5176
|
+
/**
|
|
5177
|
+
* Refuses to rewrite a catalog a later release compiled: this release's
|
|
5178
|
+
* compiler would drop the fields that release added.
|
|
5179
|
+
*/
|
|
5180
|
+
var refuseLaterCatalog = (scope, catalog) => {
|
|
5181
|
+
if (catalog !== null && readCompiledCatalogPayload(catalog.payload).fromLaterRelease) fail$1("CATALOG_FROM_LATER_RELEASE", `The ${scope.platform} release catalog of channel "${scope.channelName}" was written by a later Hot Updater.\nUpgrade hot-updater, then try again.`);
|
|
5182
|
+
};
|
|
4785
5183
|
/** A scope with releases and no compiled catalog lost its history. */
|
|
4786
5184
|
var assertHistory = (stored, hasReleases) => {
|
|
4787
5185
|
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
5186
|
};
|
|
4789
|
-
/**
|
|
4790
|
-
|
|
5187
|
+
/**
|
|
5188
|
+
* One release change and its scope's next catalog, inside `tx`. An insert
|
|
5189
|
+
* takes its channel and platform's next label from `labels`, after labeling
|
|
5190
|
+
* the releases a server of an earlier release wrote in the scope since its
|
|
5191
|
+
* last labeled one.
|
|
5192
|
+
*/
|
|
5193
|
+
var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }, labels) => {
|
|
4791
5194
|
checkScope(scope);
|
|
4792
5195
|
const stored = await readCatalog(tx, scope.scopeKey);
|
|
4793
|
-
|
|
5196
|
+
refuseLaterCatalog(scope, stored.catalog);
|
|
5197
|
+
let enabled = await enabledReleases(tx, scope.scopeKey);
|
|
4794
5198
|
if (bundle !== void 0) {
|
|
4795
5199
|
insertBundle(tx, bundle.row);
|
|
4796
5200
|
for (const patch of bundle.patches) tx.create("bundle_patches", patch);
|
|
@@ -4798,14 +5202,22 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
|
|
|
4798
5202
|
let before = null;
|
|
4799
5203
|
let release;
|
|
4800
5204
|
if (change.operation === "insert") {
|
|
4801
|
-
|
|
5205
|
+
if (labels === void 0) throw new Error("A release insert takes its label from an allocator.");
|
|
5206
|
+
const newest = await latestRelease(tx, scope.scopeKey);
|
|
5207
|
+
const latest = newest?.id ?? null;
|
|
4802
5208
|
assertHistory(stored, latest !== null);
|
|
4803
5209
|
const floor = [latest, bundle && isUUIDv7(bundle.row.id) ? bundle.row.id : null].filter((id) => id !== null).sort().at(-1);
|
|
4804
5210
|
const id = change.row.id ?? createUUIDv7After(floor ?? null);
|
|
4805
5211
|
if (latest !== null && id <= latest) fail$1("NON_MONOTONIC_RELEASE_ID", `Release "${id}" must sort after "${latest}"`);
|
|
5212
|
+
const given = await catchUpLabels(tx, labels, newest);
|
|
5213
|
+
if (given.size > 0) enabled = enabled.map((row) => given.has(row.id) ? {
|
|
5214
|
+
...row,
|
|
5215
|
+
label: given.get(row.id)
|
|
5216
|
+
} : row);
|
|
4806
5217
|
release = {
|
|
4807
5218
|
...change.row,
|
|
4808
|
-
id
|
|
5219
|
+
id,
|
|
5220
|
+
label: await labels.next(scope.channelId, scope.platform)
|
|
4809
5221
|
};
|
|
4810
5222
|
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
5223
|
tx.create("releases", release);
|
|
@@ -4818,8 +5230,9 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
|
|
|
4818
5230
|
await tx.delete("releases", row);
|
|
4819
5231
|
release = null;
|
|
4820
5232
|
} else {
|
|
5233
|
+
const { label: _label, ...update } = change.update;
|
|
4821
5234
|
const set = {
|
|
4822
|
-
...
|
|
5235
|
+
...update,
|
|
4823
5236
|
revision: before.revision + 1
|
|
4824
5237
|
};
|
|
4825
5238
|
tx.update("releases", row, set);
|
|
@@ -4846,14 +5259,35 @@ var changeRelease = async (tx, { scope, change, bundle, updatedAtMs }) => {
|
|
|
4846
5259
|
*/
|
|
4847
5260
|
var changeReleases = (db, inputs) => {
|
|
4848
5261
|
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
|
|
5262
|
+
return writeWithLabels(db, async (tx, labels) => {
|
|
4850
5263
|
const results = [];
|
|
4851
|
-
for (const input of inputs) results.push(await changeRelease(tx, input));
|
|
5264
|
+
for (const input of inputs) results.push(await changeRelease(tx, input, labels));
|
|
4852
5265
|
return results;
|
|
4853
5266
|
});
|
|
4854
5267
|
};
|
|
4855
|
-
/**
|
|
4856
|
-
|
|
5268
|
+
/**
|
|
5269
|
+
* Whether `current` is what the scope's enabled releases compile to, in the
|
|
5270
|
+
* fields this release compiles: a later release's catalog may add others.
|
|
5271
|
+
*/
|
|
5272
|
+
var isCurrent = (scope, current, compilation) => {
|
|
5273
|
+
if (current.strategy !== scope.strategy || current.channel_id !== scope.channelId || current.channel_key !== encodeChannelKey(scope.channelName) || current.platform !== scope.platform || current.fingerprint_hash !== scope.fingerprintHash) return false;
|
|
5274
|
+
if (current.catalog_hash === compilation.catalogHash) return true;
|
|
5275
|
+
const read = readCompiledCatalogPayload(current.payload);
|
|
5276
|
+
return read.fromLaterRelease && read.canonicalPayload === compilation.canonicalPayload;
|
|
5277
|
+
};
|
|
5278
|
+
/** A compiled payload with its descriptors' labels left out. */
|
|
5279
|
+
var withoutLabels = (payload) => {
|
|
5280
|
+
const parsed = JSON.parse(payload);
|
|
5281
|
+
return JSON.stringify({
|
|
5282
|
+
...parsed,
|
|
5283
|
+
releaseDescriptors: (parsed.releaseDescriptors ?? []).map(({ label: _label, ...descriptor }) => descriptor)
|
|
5284
|
+
});
|
|
5285
|
+
};
|
|
5286
|
+
/**
|
|
5287
|
+
* Whether `projected` differs from `current` only by release labels, as a
|
|
5288
|
+
* catalog compiled before its releases had them does.
|
|
5289
|
+
*/
|
|
5290
|
+
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
5291
|
/** The scope a catalog row names. */
|
|
4858
5292
|
var catalogRowScope = (row) => ({
|
|
4859
5293
|
channelId: row.channel_id,
|
|
@@ -4878,18 +5312,20 @@ var preflightRebuild = async (db, scopeKey, updatedAtMs) => {
|
|
|
4878
5312
|
checkScope(scope);
|
|
4879
5313
|
const compilation = await compileScope(scope, await drainReleases((cursor) => db.findMany("releases", enabledIn(scopeKey, cursor))));
|
|
4880
5314
|
const changed = !isCurrent(scope, current, compilation);
|
|
5315
|
+
const projectedCatalog = changed ? nextCatalog(scope, { catalog: current }, compilation, updatedAtMs) : current;
|
|
4881
5316
|
return {
|
|
4882
5317
|
changed,
|
|
5318
|
+
labelsOnly: changed && differsInLabelsOnly(current, projectedCatalog),
|
|
4883
5319
|
currentCatalog: current,
|
|
4884
5320
|
diagnostics: compilation.diagnostics,
|
|
4885
|
-
projectedCatalog
|
|
5321
|
+
projectedCatalog
|
|
4886
5322
|
};
|
|
4887
5323
|
};
|
|
4888
5324
|
/** Recompiles a scope's catalog from its enabled releases inside `tx`; an unchanged catalog is not rewritten. */
|
|
4889
5325
|
var rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
4890
5326
|
checkScope(scope);
|
|
4891
5327
|
const stored = await readCatalog(tx, scope.scopeKey);
|
|
4892
|
-
assertHistory(stored, await
|
|
5328
|
+
assertHistory(stored, await latestRelease(tx, scope.scopeKey) !== null);
|
|
4893
5329
|
const enabled = await enabledReleases(tx, scope.scopeKey);
|
|
4894
5330
|
const compilation = await compileScope(scope, enabled);
|
|
4895
5331
|
const current = stored.catalog;
|
|
@@ -4899,6 +5335,7 @@ var rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
|
4899
5335
|
changed: false,
|
|
4900
5336
|
diagnostics: compilation.diagnostics
|
|
4901
5337
|
};
|
|
5338
|
+
refuseLaterCatalog(scope, current);
|
|
4902
5339
|
const written = await writeCatalog(tx, scope, stored, enabled, updatedAtMs);
|
|
4903
5340
|
return {
|
|
4904
5341
|
catalog: written.catalog,
|
|
@@ -4907,6 +5344,7 @@ var rebuildScope = async (tx, scope, updatedAtMs) => {
|
|
|
4907
5344
|
diagnostics: written.compilation.diagnostics
|
|
4908
5345
|
};
|
|
4909
5346
|
};
|
|
5347
|
+
var CATALOG_PAGE = 100;
|
|
4910
5348
|
/** Carries a preflight's result out of the transaction it stops, so nothing is written. */
|
|
4911
5349
|
var Preflight = class extends Error {
|
|
4912
5350
|
result;
|
|
@@ -5138,7 +5576,7 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
5138
5576
|
if (targetChannel.length === 0) throw new ReleaseManagementError("TARGET_RELEASE_INVALID", "Promotion requires a target channel.");
|
|
5139
5577
|
const channel = await ensureChannel(targetChannel);
|
|
5140
5578
|
const updatedAtMs = now();
|
|
5141
|
-
return db
|
|
5579
|
+
return writeWithLabels(db, async (tx, labels) => {
|
|
5142
5580
|
const { release: source, scope: sourceScope } = await loadTarget(tx, input);
|
|
5143
5581
|
checkSource(source);
|
|
5144
5582
|
const targetScope = scopeOf(channel, source.platform, source.fingerprint_hash);
|
|
@@ -5166,12 +5604,13 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
5166
5604
|
},
|
|
5167
5605
|
updatedAtMs
|
|
5168
5606
|
}) : null;
|
|
5607
|
+
const { label: _label, ...copied } = source;
|
|
5169
5608
|
const target = await changeRelease(tx, {
|
|
5170
5609
|
scope: targetScope,
|
|
5171
5610
|
change: {
|
|
5172
5611
|
operation: "insert",
|
|
5173
5612
|
row: {
|
|
5174
|
-
...
|
|
5613
|
+
...copied,
|
|
5175
5614
|
id: createUUIDv7After(floor ?? null, updatedAtMs),
|
|
5176
5615
|
revision: 1,
|
|
5177
5616
|
scope_key: targetScope.scopeKey,
|
|
@@ -5186,7 +5625,7 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
5186
5625
|
}
|
|
5187
5626
|
},
|
|
5188
5627
|
updatedAtMs
|
|
5189
|
-
});
|
|
5628
|
+
}, labels);
|
|
5190
5629
|
return {
|
|
5191
5630
|
source: moved === null ? null : mutationResult(moved),
|
|
5192
5631
|
target: mutationResult(target)
|
|
@@ -5204,6 +5643,38 @@ var createCoreOperations = (db, { now = Date.now } = {}) => {
|
|
|
5204
5643
|
});
|
|
5205
5644
|
},
|
|
5206
5645
|
preflightReleaseCatalogRebuild: (scopeKey) => preflightRebuild(db, scopeKey, now()),
|
|
5646
|
+
fillReleaseLabels: async ({ dryRun = false, catalogs = true } = {}) => {
|
|
5647
|
+
let releases = 0;
|
|
5648
|
+
const pairs = await pendingLabelPairs(db);
|
|
5649
|
+
if (dryRun && pairs[0] !== void 0) await probeLabelSchema(db, pairs[0]);
|
|
5650
|
+
for (const pair of pairs) releases += await fillLabels(db, pair, { dryRun });
|
|
5651
|
+
let rebuilt = 0;
|
|
5652
|
+
if (catalogs) {
|
|
5653
|
+
let cursor;
|
|
5654
|
+
do {
|
|
5655
|
+
const page = await db.findMany("release_catalogs", {
|
|
5656
|
+
index: "all",
|
|
5657
|
+
where: {},
|
|
5658
|
+
limit: CATALOG_PAGE,
|
|
5659
|
+
...cursor === void 0 ? {} : { cursor }
|
|
5660
|
+
});
|
|
5661
|
+
for (const row of page.rows) {
|
|
5662
|
+
if (row.is_tombstone) continue;
|
|
5663
|
+
const preflight = await preflightRebuild(db, row.scope_key, now()).catch(() => null);
|
|
5664
|
+
if (preflight === null || !preflight.labelsOnly) continue;
|
|
5665
|
+
rebuilt += 1;
|
|
5666
|
+
if (dryRun) continue;
|
|
5667
|
+
const updatedAtMs = now();
|
|
5668
|
+
await db.transaction((tx) => rebuildScope(tx, catalogRowScope(toCatalogRow(row)), updatedAtMs));
|
|
5669
|
+
}
|
|
5670
|
+
cursor = page.next;
|
|
5671
|
+
} while (cursor !== void 0);
|
|
5672
|
+
}
|
|
5673
|
+
return {
|
|
5674
|
+
releases,
|
|
5675
|
+
catalogs: rebuilt
|
|
5676
|
+
};
|
|
5677
|
+
},
|
|
5207
5678
|
ensureChannel,
|
|
5208
5679
|
deleteChannel: (id) => deleteChannel(db, id),
|
|
5209
5680
|
updateBundle: (id, update) => db.transaction(async (tx) => {
|
|
@@ -5749,6 +6220,26 @@ var createAdminRouteHandlers = () => ({
|
|
|
5749
6220
|
return row === null ? notFound() : json({ data: row });
|
|
5750
6221
|
}),
|
|
5751
6222
|
rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
6223
|
+
getReleaseByLabel: onCore(async (core, request) => {
|
|
6224
|
+
const url = new URL(request.url);
|
|
6225
|
+
const channel = url.searchParams.get("channel");
|
|
6226
|
+
const platform = platformOf(url);
|
|
6227
|
+
const label = Number(url.searchParams.get("label"));
|
|
6228
|
+
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.");
|
|
6229
|
+
return json({ data: await core.getReleaseByLabel({
|
|
6230
|
+
channel,
|
|
6231
|
+
platform,
|
|
6232
|
+
label
|
|
6233
|
+
}) });
|
|
6234
|
+
}),
|
|
6235
|
+
fillReleaseLabels: onCore(async (core, request) => {
|
|
6236
|
+
const body = await request.json().catch(() => ({}));
|
|
6237
|
+
const input = body !== null && typeof body === "object" ? body : {};
|
|
6238
|
+
return json({ data: await core.fillReleaseLabels({
|
|
6239
|
+
dryRun: input.dryRun === true,
|
|
6240
|
+
catalogs: input.catalogs !== false
|
|
6241
|
+
}) });
|
|
6242
|
+
}),
|
|
5752
6243
|
updateBundle: onCore(async (core, request, params) => {
|
|
5753
6244
|
const bundleId = requireRouteParam(params, "id");
|
|
5754
6245
|
const update = bundleUpdateOf(await request.json(), bundleId);
|
|
@@ -5975,6 +6466,16 @@ var ADMIN_ROUTES = [
|
|
|
5975
6466
|
path: "/release-scopes",
|
|
5976
6467
|
handler: "listReleaseScopeKeys"
|
|
5977
6468
|
},
|
|
6469
|
+
{
|
|
6470
|
+
method: "GET",
|
|
6471
|
+
path: "/release-labels",
|
|
6472
|
+
handler: "getReleaseByLabel"
|
|
6473
|
+
},
|
|
6474
|
+
{
|
|
6475
|
+
method: "POST",
|
|
6476
|
+
path: "/release-labels/fill",
|
|
6477
|
+
handler: "fillReleaseLabels"
|
|
6478
|
+
},
|
|
5978
6479
|
{
|
|
5979
6480
|
method: "POST",
|
|
5980
6481
|
path: "/release-catalogs/:scopeKey/rebuild",
|