@hot-updater/firebase 1.0.0-rc.45 → 1.0.0-rc.46
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/dist/firebase/functions/index.cjs +46 -52
- package/dist/init/index.cjs +11 -6
- package/dist/init/index.mjs +12 -7
- package/package.json +7 -7
|
@@ -216,6 +216,13 @@ const isDatabaseJsonValue = (value) => {
|
|
|
216
216
|
const isDatabaseJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && isDatabaseJsonValue(value);
|
|
217
217
|
const isDatabaseMetadataObject = (value) => isDatabaseJsonObject(value) && (!Object.hasOwn(value, "app_version") || typeof value["app_version"] === "string");
|
|
218
218
|
//#endregion
|
|
219
|
+
//#region ../plugin-core/dist/databaseMetadata.mjs
|
|
220
|
+
const bundleMetadataToRow = (metadata) => {
|
|
221
|
+
if (metadata === void 0) return {};
|
|
222
|
+
if (!isDatabaseMetadataObject(metadata)) throw new DatabaseAdapterInputError("invalid-data");
|
|
223
|
+
return metadata;
|
|
224
|
+
};
|
|
225
|
+
//#endregion
|
|
219
226
|
//#region ../../packages/protocol/dist/index.mjs
|
|
220
227
|
const LETTER_DASH_NUMBER$2 = "[a-zA-Z0-9-]";
|
|
221
228
|
const NUMERIC_IDENTIFIER$2 = String.raw`0|[1-9]\d*`;
|
|
@@ -329,7 +336,6 @@ function canonicalizeAppVersion(appVersion) {
|
|
|
329
336
|
const version = coerce$1(appVersion);
|
|
330
337
|
return version ? normalizeFull(version) : null;
|
|
331
338
|
}
|
|
332
|
-
const stripBundleArtifactMetadata = (metadata) => metadata;
|
|
333
339
|
const getManifestStorageUri = (bundle) => bundle.manifestStorageUri;
|
|
334
340
|
const getManifestFileHash = (bundle) => bundle.manifestFileHash;
|
|
335
341
|
const getAssetBaseStorageUri = (bundle) => bundle.assetBaseStorageUri;
|
|
@@ -576,14 +582,6 @@ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
|
576
582
|
const UUID_V7_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
577
583
|
const isUUIDv7 = (value) => typeof value === "string" && UUID_V7_PATTERN.test(value);
|
|
578
584
|
//#endregion
|
|
579
|
-
//#region ../plugin-core/dist/databaseMetadata.mjs
|
|
580
|
-
const bundleMetadataToRow = (metadata) => {
|
|
581
|
-
const value = stripBundleArtifactMetadata(metadata);
|
|
582
|
-
if (value === void 0) return {};
|
|
583
|
-
if (!isDatabaseMetadataObject(value)) throw new DatabaseAdapterInputError("invalid-data");
|
|
584
|
-
return value;
|
|
585
|
-
};
|
|
586
|
-
//#endregion
|
|
587
585
|
//#region ../plugin-core/dist/databaseRows.mjs
|
|
588
586
|
const releaseRowToRelease = (row) => ({
|
|
589
587
|
id: row.id,
|
|
@@ -641,7 +639,7 @@ const rowToBundle = (row, patchRows = []) => {
|
|
|
641
639
|
id: row.id,
|
|
642
640
|
platform: row.platform,
|
|
643
641
|
gitCommitHash: row.git_commit_hash,
|
|
644
|
-
metadata:
|
|
642
|
+
metadata: row.metadata,
|
|
645
643
|
manifestStorageUri: row.manifest_storage_uri,
|
|
646
644
|
manifestFileHash: row.manifest_file_hash,
|
|
647
645
|
assetBaseStorageUri: row.asset_base_storage_uri,
|
|
@@ -649,6 +647,35 @@ const rowToBundle = (row, patchRows = []) => {
|
|
|
649
647
|
};
|
|
650
648
|
};
|
|
651
649
|
//#endregion
|
|
650
|
+
//#region ../plugin-core/dist/uuidv7.mjs
|
|
651
|
+
const extractTimestampFromUUIDv7 = (uuid) => {
|
|
652
|
+
if (!isUUIDv7(uuid)) throw new TypeError("Expected a canonical lowercase UUIDv7");
|
|
653
|
+
const timestampHex = uuid.split("-").join("").slice(0, 12);
|
|
654
|
+
return Number.parseInt(timestampHex, 16);
|
|
655
|
+
};
|
|
656
|
+
function createUUIDv7FromTimestampHex(timestampHex) {
|
|
657
|
+
const randomBytes = /* @__PURE__ */ new Uint8Array(10);
|
|
658
|
+
crypto.getRandomValues(randomBytes);
|
|
659
|
+
const randomHex = Array.from(randomBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
660
|
+
const randA = randomHex.slice(0, 3);
|
|
661
|
+
const randBHex = randomHex.slice(3, 19);
|
|
662
|
+
const versionAndRandA = `7${randA}`;
|
|
663
|
+
const variantAndFirstRandB = (128 | parseInt(randBHex.slice(0, 2), 16) & 63).toString(16).padStart(2, "0");
|
|
664
|
+
return [
|
|
665
|
+
timestampHex.slice(0, 8),
|
|
666
|
+
timestampHex.slice(8, 12),
|
|
667
|
+
versionAndRandA,
|
|
668
|
+
variantAndFirstRandB + randBHex.slice(2, 4),
|
|
669
|
+
randBHex.slice(4, 16)
|
|
670
|
+
].join("-");
|
|
671
|
+
}
|
|
672
|
+
const createUUIDv7 = () => createUUIDv7FromTimestampHex(Date.now().toString(16).padStart(12, "0"));
|
|
673
|
+
const createUUIDv7After = (floor, nowMs = Date.now()) => {
|
|
674
|
+
const timestamp = Math.max(nowMs, floor === null ? 0 : extractTimestampFromUUIDv7(floor) + 1);
|
|
675
|
+
if (!Number.isSafeInteger(timestamp) || timestamp < 0 || timestamp >= 2 ** 48) throw new RangeError("UUIDv7 timestamp is out of range");
|
|
676
|
+
return createUUIDv7FromTimestampHex(timestamp.toString(16).padStart(12, "0"));
|
|
677
|
+
};
|
|
678
|
+
//#endregion
|
|
652
679
|
//#region ../plugin-core/dist/node_modules/.pnpm/verkit@0.4.0/node_modules/verkit/dist/comparison-DenM3wCn.mjs
|
|
653
680
|
const LETTER_DASH_NUMBER$1 = "[a-zA-Z0-9-]";
|
|
654
681
|
const NUMERIC_IDENTIFIER$1 = String.raw`0|[1-9]\d*`;
|
|
@@ -995,42 +1022,6 @@ function coerce(value, options = {}) {
|
|
|
995
1022
|
return tryParse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
996
1023
|
}
|
|
997
1024
|
//#endregion
|
|
998
|
-
//#region ../plugin-core/dist/semverSatisfies.mjs
|
|
999
|
-
const semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
1000
|
-
const currentCoerce = coerce(currentVersion);
|
|
1001
|
-
if (!currentCoerce) return false;
|
|
1002
|
-
return satisfies(currentCoerce, targetAppVersion);
|
|
1003
|
-
};
|
|
1004
|
-
//#endregion
|
|
1005
|
-
//#region ../plugin-core/dist/uuidv7.mjs
|
|
1006
|
-
const extractTimestampFromUUIDv7 = (uuid) => {
|
|
1007
|
-
if (!isUUIDv7(uuid)) throw new TypeError("Expected a canonical lowercase UUIDv7");
|
|
1008
|
-
const timestampHex = uuid.split("-").join("").slice(0, 12);
|
|
1009
|
-
return Number.parseInt(timestampHex, 16);
|
|
1010
|
-
};
|
|
1011
|
-
function createUUIDv7FromTimestampHex(timestampHex) {
|
|
1012
|
-
const randomBytes = /* @__PURE__ */ new Uint8Array(10);
|
|
1013
|
-
crypto.getRandomValues(randomBytes);
|
|
1014
|
-
const randomHex = Array.from(randomBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1015
|
-
const randA = randomHex.slice(0, 3);
|
|
1016
|
-
const randBHex = randomHex.slice(3, 19);
|
|
1017
|
-
const versionAndRandA = `7${randA}`;
|
|
1018
|
-
const variantAndFirstRandB = (128 | parseInt(randBHex.slice(0, 2), 16) & 63).toString(16).padStart(2, "0");
|
|
1019
|
-
return [
|
|
1020
|
-
timestampHex.slice(0, 8),
|
|
1021
|
-
timestampHex.slice(8, 12),
|
|
1022
|
-
versionAndRandA,
|
|
1023
|
-
variantAndFirstRandB + randBHex.slice(2, 4),
|
|
1024
|
-
randBHex.slice(4, 16)
|
|
1025
|
-
].join("-");
|
|
1026
|
-
}
|
|
1027
|
-
const createUUIDv7 = () => createUUIDv7FromTimestampHex(Date.now().toString(16).padStart(12, "0"));
|
|
1028
|
-
const createUUIDv7After = (floor, nowMs = Date.now()) => {
|
|
1029
|
-
const timestamp = Math.max(nowMs, floor === null ? 0 : extractTimestampFromUUIDv7(floor) + 1);
|
|
1030
|
-
if (!Number.isSafeInteger(timestamp) || timestamp < 0 || timestamp >= 2 ** 48) throw new RangeError("UUIDv7 timestamp is out of range");
|
|
1031
|
-
return createUUIDv7FromTimestampHex(timestamp.toString(16).padStart(12, "0"));
|
|
1032
|
-
};
|
|
1033
|
-
//#endregion
|
|
1034
1025
|
//#region ../plugin-core/dist/releaseCatalogCompiler.mjs
|
|
1035
1026
|
var ReleaseCatalogCompilationError = class extends Error {
|
|
1036
1027
|
code;
|
|
@@ -1426,6 +1417,13 @@ var ReleaseCatalogMutationError = class extends Error {
|
|
|
1426
1417
|
}
|
|
1427
1418
|
};
|
|
1428
1419
|
//#endregion
|
|
1420
|
+
//#region ../plugin-core/dist/semverSatisfies.mjs
|
|
1421
|
+
const semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
1422
|
+
const currentCoerce = coerce(currentVersion);
|
|
1423
|
+
if (!currentCoerce) return false;
|
|
1424
|
+
return satisfies(currentCoerce, targetAppVersion);
|
|
1425
|
+
};
|
|
1426
|
+
//#endregion
|
|
1429
1427
|
//#region ../plugin-core/dist/serverPlugin/definePlugin.mjs
|
|
1430
1428
|
/** Declares a plugin; Hot Updater's own plugins and third-party ones use the same contract. */
|
|
1431
1429
|
const definePlugin = (plugin) => plugin;
|
|
@@ -2373,9 +2371,6 @@ const getEmptyMigrationResult = () => ({
|
|
|
2373
2371
|
execute: async () => {},
|
|
2374
2372
|
getSQL: () => ""
|
|
2375
2373
|
});
|
|
2376
|
-
const assertSupportedMigrationMode = (options) => {
|
|
2377
|
-
if (options.mode === "from-database") throw new Error("Hot Updater migrations support only mode: 'from-schema'.");
|
|
2378
|
-
};
|
|
2379
2374
|
//#endregion
|
|
2380
2375
|
//#region ../plugin-core/dist/engine/db/settingsMigrator.mjs
|
|
2381
2376
|
/** `schema.core`, or a v0 database's `version`. */
|
|
@@ -3459,7 +3454,6 @@ const resolveSchema = (modules) => {
|
|
|
3459
3454
|
const createEngineMigrator = (options) => {
|
|
3460
3455
|
const getVersion = async () => storedSchemaVersion(await options.readSettings());
|
|
3461
3456
|
const makeResult = async (migrate = {}) => {
|
|
3462
|
-
assertSupportedMigrationMode(migrate);
|
|
3463
3457
|
const stored = await options.readSettings();
|
|
3464
3458
|
refusePreEngineDatabase(options.adapterName, stored);
|
|
3465
3459
|
if (Object.entries(options.settings).every(([key, value]) => stored.get(key) === value)) return getEmptyMigrationResult();
|
|
@@ -4566,7 +4560,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
4566
4560
|
};
|
|
4567
4561
|
//#endregion
|
|
4568
4562
|
//#region ../../packages/server/dist/version.mjs
|
|
4569
|
-
const HOT_UPDATER_SERVER_VERSION = "1.0.0-rc.
|
|
4563
|
+
const HOT_UPDATER_SERVER_VERSION = "1.0.0-rc.46";
|
|
4570
4564
|
//#endregion
|
|
4571
4565
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
4572
4566
|
/**
|
|
@@ -7112,7 +7106,7 @@ const databaseOf = (value) => {
|
|
|
7112
7106
|
if (isAdapter(value.adapter)) return value;
|
|
7113
7107
|
if ("core" in value && "fetchAdmin" in value) throw new HotUpdaterConfigError("standaloneRepository reaches a server's admin API from the CLI and console. createHotUpdater needs the server's own database, such as kyselyAdapter(...).");
|
|
7114
7108
|
}
|
|
7115
|
-
throw new HotUpdaterConfigError("database must be a Hot Updater
|
|
7109
|
+
throw new HotUpdaterConfigError("database must be a Hot Updater database adapter, such as kyselyAdapter(...) or postgres(...).");
|
|
7116
7110
|
};
|
|
7117
7111
|
/** The configured storage, when it is a storage adapter. */
|
|
7118
7112
|
const storageOf = (value) => {
|
package/dist/init/index.cjs
CHANGED
|
@@ -6995,12 +6995,17 @@ const assertFirebaseFunctionCanInitialize = async ({ fetchImpl, functions }) =>
|
|
|
6995
6995
|
for (const existingFunction of existingFunctions) {
|
|
6996
6996
|
if (!existingFunction.uri) throw new _hot_updater_cli_tools.InitError(`Could not verify the Firebase infrastructure generation at Function ${FIREBASE_V1_FUNCTION_NAME}: endpoint URL was not reported.`);
|
|
6997
6997
|
const versionUrl = new URL("version", `${existingFunction.uri.replace(/\/$/u, "")}/`).toString();
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
6998
|
+
try {
|
|
6999
|
+
await (0, _hot_updater_cli_tools.assertInfrastructureGenerationAtUrl)({
|
|
7000
|
+
fetchImpl,
|
|
7001
|
+
provider: "Firebase",
|
|
7002
|
+
resource: `Function ${FIREBASE_V1_FUNCTION_NAME}`,
|
|
7003
|
+
versionUrl
|
|
7004
|
+
});
|
|
7005
|
+
} catch (error) {
|
|
7006
|
+
if (!(error instanceof _hot_updater_cli_tools.LegacyInfrastructureError)) throw error;
|
|
7007
|
+
throw new _hot_updater_cli_tools.InitError(`Function ${FIREBASE_V1_FUNCTION_NAME}, which init deploys, already exists in this Firebase project and is incompatible: its /version does not report Hot Updater infrastructure generation 1. Delete the function or use another Firebase project, then rerun init. The existing function was not changed.`);
|
|
7008
|
+
}
|
|
7004
7009
|
}
|
|
7005
7010
|
};
|
|
7006
7011
|
//#endregion
|
package/dist/init/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveHotUpdaterServerVersion, resolveInitProviderInput, resolvePackageVersion, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
4
|
+
import { ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, InitError, LegacyInfrastructureError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveHotUpdaterServerVersion, resolveInitProviderInput, resolvePackageVersion, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
5
5
|
import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
|
|
@@ -6988,12 +6988,17 @@ const assertFirebaseFunctionCanInitialize = async ({ fetchImpl, functions }) =>
|
|
|
6988
6988
|
for (const existingFunction of existingFunctions) {
|
|
6989
6989
|
if (!existingFunction.uri) throw new InitError(`Could not verify the Firebase infrastructure generation at Function ${FIREBASE_V1_FUNCTION_NAME}: endpoint URL was not reported.`);
|
|
6990
6990
|
const versionUrl = new URL("version", `${existingFunction.uri.replace(/\/$/u, "")}/`).toString();
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6991
|
+
try {
|
|
6992
|
+
await assertInfrastructureGenerationAtUrl({
|
|
6993
|
+
fetchImpl,
|
|
6994
|
+
provider: "Firebase",
|
|
6995
|
+
resource: `Function ${FIREBASE_V1_FUNCTION_NAME}`,
|
|
6996
|
+
versionUrl
|
|
6997
|
+
});
|
|
6998
|
+
} catch (error) {
|
|
6999
|
+
if (!(error instanceof LegacyInfrastructureError)) throw error;
|
|
7000
|
+
throw new InitError(`Function ${FIREBASE_V1_FUNCTION_NAME}, which init deploys, already exists in this Firebase project and is incompatible: its /version does not report Hot Updater infrastructure generation 1. Delete the function or use another Firebase project, then rerun init. The existing function was not changed.`);
|
|
7001
|
+
}
|
|
6997
7002
|
}
|
|
6998
7003
|
};
|
|
6999
7004
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.46",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
|
-
"@hot-updater/cli-tools": "1.0.0-rc.
|
|
41
|
-
"@hot-updater/protocol": "1.0.0-rc.
|
|
42
|
-
"@hot-updater/plugin-core": "1.0.0-rc.
|
|
43
|
-
"@hot-updater/server": "1.0.0-rc.
|
|
40
|
+
"@hot-updater/cli-tools": "1.0.0-rc.46",
|
|
41
|
+
"@hot-updater/protocol": "1.0.0-rc.46",
|
|
42
|
+
"@hot-updater/plugin-core": "1.0.0-rc.46",
|
|
43
|
+
"@hot-updater/server": "1.0.0-rc.46"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"firebase-tools": "15.29.0",
|
|
56
56
|
"fkill": "^9.0.0",
|
|
57
57
|
"mime": "^4.0.4",
|
|
58
|
-
"@hot-updater/mock": "1.0.0-rc.
|
|
59
|
-
"@hot-updater/test-utils": "1.0.0-rc.
|
|
58
|
+
"@hot-updater/mock": "1.0.0-rc.46",
|
|
59
|
+
"@hot-updater/test-utils": "1.0.0-rc.46"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"firebase-admin": "*",
|