@hot-updater/firebase 1.2.0-rc.42 → 1.2.0-rc.44
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 +101 -12
- package/package.json +7 -7
|
@@ -2506,6 +2506,10 @@ store_build_scope_key: {
|
|
|
2506
2506
|
eq: ["scope_key", "build_key"],
|
|
2507
2507
|
sort: ["id"]
|
|
2508
2508
|
},
|
|
2509
|
+
byScopeKind: {
|
|
2510
|
+
eq: ["scope_key", "artifact_kind"],
|
|
2511
|
+
sort: ["id"]
|
|
2512
|
+
},
|
|
2509
2513
|
byStoreBuild: {
|
|
2510
2514
|
eq: ["store_build_scope_key"],
|
|
2511
2515
|
sort: [],
|
|
@@ -4758,7 +4762,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
4758
4762
|
};
|
|
4759
4763
|
//#endregion
|
|
4760
4764
|
//#region ../../packages/server/dist/version.mjs
|
|
4761
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
4765
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.44";
|
|
4762
4766
|
//#endregion
|
|
4763
4767
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
4764
4768
|
/**
|
|
@@ -6460,6 +6464,51 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
|
|
|
6460
6464
|
if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
|
|
6461
6465
|
return null;
|
|
6462
6466
|
};
|
|
6467
|
+
/** The other install target of an iOS sandbox build's native code. */
|
|
6468
|
+
const SIBLING_KINDS = {
|
|
6469
|
+
app: "ipa",
|
|
6470
|
+
ipa: "app"
|
|
6471
|
+
};
|
|
6472
|
+
/**
|
|
6473
|
+
* Whether a build is one a person installs from its file: a Simulator `.app`,
|
|
6474
|
+
* or an `.ipa` exported for direct install, that no store took and that isn't
|
|
6475
|
+
* the store build. One rule for a sibling and the build it is found from, so
|
|
6476
|
+
* a build that shows its sibling is shown by it.
|
|
6477
|
+
*/
|
|
6478
|
+
const isInstallTarget = (build) => !build.is_store_build && build.submitted_to === null && (build.artifact_kind === "app" || build.artifact_kind === "ipa" && build.export_method !== null && build.export_method !== "app-store");
|
|
6479
|
+
/**
|
|
6480
|
+
* The scope key of the other install target of a sandbox build, from its own
|
|
6481
|
+
* key's app ID and URL scheme, which hold no colon, and its row's fingerprint
|
|
6482
|
+
* or app version, through `sandboxScopeKey`; null for a key it didn't make.
|
|
6483
|
+
*/
|
|
6484
|
+
const siblingSandboxScopeKey = (build, artifactKind) => {
|
|
6485
|
+
const [version, sandbox, platform, appId, urlScheme] = build.scope_key.split(":");
|
|
6486
|
+
if (version !== "v1" || sandbox !== "sandbox" || platform !== build.platform || appId === void 0 || urlScheme === void 0) return null;
|
|
6487
|
+
const target = build.fingerprint_hash === null ? {
|
|
6488
|
+
platform: build.platform,
|
|
6489
|
+
fingerprintHash: null,
|
|
6490
|
+
appVersion: build.app_version ?? ""
|
|
6491
|
+
} : {
|
|
6492
|
+
platform: build.platform,
|
|
6493
|
+
fingerprintHash: build.fingerprint_hash,
|
|
6494
|
+
appVersion: null
|
|
6495
|
+
};
|
|
6496
|
+
try {
|
|
6497
|
+
return sandboxScopeKey(target, {
|
|
6498
|
+
appId,
|
|
6499
|
+
urlScheme,
|
|
6500
|
+
artifactKind: build.artifact_kind,
|
|
6501
|
+
distribution: registeredDistribution(build.artifact_kind, build.export_method)
|
|
6502
|
+
}) === build.scope_key ? sandboxScopeKey(target, {
|
|
6503
|
+
appId,
|
|
6504
|
+
urlScheme,
|
|
6505
|
+
artifactKind,
|
|
6506
|
+
distribution: "direct"
|
|
6507
|
+
}) : null;
|
|
6508
|
+
} catch {
|
|
6509
|
+
return null;
|
|
6510
|
+
}
|
|
6511
|
+
};
|
|
6463
6512
|
/** The native build registry: core's `native_builds` and the built-in bundle rows. */
|
|
6464
6513
|
const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
6465
6514
|
async registerNativeBuild(registration) {
|
|
@@ -6528,9 +6577,12 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6528
6577
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
6529
6578
|
const buildKey = options?.buildKey;
|
|
6530
6579
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
6580
|
+
const artifactKind = options?.artifactKind;
|
|
6581
|
+
if (artifactKind !== void 0 && !ARTIFACT_KINDS[scope.platform].includes(artifactKind)) throw new NativeBuildInputError(`Invalid native build kind: an ${scope.platform} build is ${ARTIFACT_KINDS[scope.platform].join(" or ")}.`);
|
|
6582
|
+
const ofKind = (row) => artifactKind === void 0 || row.artifact_kind === artifactKind;
|
|
6531
6583
|
if (options?.storeBuild) {
|
|
6532
6584
|
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
6533
|
-
return marked === null ? null : pick(marked);
|
|
6585
|
+
return marked === null || !ofKind(marked) ? null : pick(marked);
|
|
6534
6586
|
}
|
|
6535
6587
|
const read = (limit, before) => {
|
|
6536
6588
|
const page = {
|
|
@@ -6538,34 +6590,60 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
6538
6590
|
limit,
|
|
6539
6591
|
...before === void 0 ? {} : { range: { lt: before } }
|
|
6540
6592
|
};
|
|
6541
|
-
return buildKey
|
|
6542
|
-
index: "byScope",
|
|
6543
|
-
where: { scope_key: scopeKey },
|
|
6544
|
-
...page
|
|
6545
|
-
}) : db.findMany("native_builds", {
|
|
6593
|
+
return buildKey !== void 0 ? db.findMany("native_builds", {
|
|
6546
6594
|
index: "byBuildKey",
|
|
6547
6595
|
where: {
|
|
6548
6596
|
scope_key: scopeKey,
|
|
6549
6597
|
build_key: buildKey
|
|
6550
6598
|
},
|
|
6551
6599
|
...page
|
|
6600
|
+
}) : artifactKind !== void 0 ? db.findMany("native_builds", {
|
|
6601
|
+
index: "byScopeKind",
|
|
6602
|
+
where: {
|
|
6603
|
+
scope_key: scopeKey,
|
|
6604
|
+
artifact_kind: artifactKind
|
|
6605
|
+
},
|
|
6606
|
+
...page
|
|
6607
|
+
}) : db.findMany("native_builds", {
|
|
6608
|
+
index: "byScope",
|
|
6609
|
+
where: { scope_key: scopeKey },
|
|
6610
|
+
...page
|
|
6552
6611
|
});
|
|
6553
6612
|
};
|
|
6554
6613
|
const bundleId = options?.builtInOlderThan;
|
|
6555
6614
|
if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
|
|
6556
6615
|
const { rows } = await read(1);
|
|
6557
|
-
const newest = rows[0]
|
|
6558
|
-
|
|
6559
|
-
|
|
6616
|
+
const newest = (rows[0] === void 0 ? void 0 : pick(rows[0])) ?? (artifactKind !== void 0 && buildKey === void 0 ? await db.findMany("native_builds", {
|
|
6617
|
+
index: "byScope",
|
|
6618
|
+
where: { scope_key: scopeKey },
|
|
6619
|
+
order: "desc",
|
|
6620
|
+
limit: 1
|
|
6621
|
+
}).then(({ rows: [row] }) => row?.artifact_kind === artifactKind ? pick(row) : void 0) : void 0);
|
|
6622
|
+
if (newest === void 0 || !ofKind(newest)) return null;
|
|
6623
|
+
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return newest;
|
|
6560
6624
|
for (let before = newest.id;;) {
|
|
6561
6625
|
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
6562
6626
|
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
6563
|
-
if (usable !== void 0) return pick(usable);
|
|
6627
|
+
if (usable !== void 0) return ofKind(usable) ? pick(usable) : null;
|
|
6564
6628
|
const last = older.at(-1);
|
|
6565
6629
|
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
6566
6630
|
before = last.id;
|
|
6567
6631
|
}
|
|
6568
6632
|
},
|
|
6633
|
+
async findNativeBuildSibling(build) {
|
|
6634
|
+
const artifactKind = SIBLING_KINDS[build.artifact_kind];
|
|
6635
|
+
if (build.platform !== "ios" || !build.is_sandbox || artifactKind === void 0 || !isInstallTarget(build)) return null;
|
|
6636
|
+
const scopeKey = siblingSandboxScopeKey(build, artifactKind);
|
|
6637
|
+
if (scopeKey === null) return null;
|
|
6638
|
+
const { rows } = await db.findMany("native_builds", {
|
|
6639
|
+
index: "byScope",
|
|
6640
|
+
where: { scope_key: scopeKey },
|
|
6641
|
+
order: "desc",
|
|
6642
|
+
limit: 1
|
|
6643
|
+
});
|
|
6644
|
+
const sibling = rows[0] === void 0 ? null : pick(rows[0]);
|
|
6645
|
+
return sibling !== null && isInstallTarget(sibling) ? sibling : null;
|
|
6646
|
+
},
|
|
6569
6647
|
async recordNativeBuildSubmission(id, { destination, version }) {
|
|
6570
6648
|
if (version.trim().length === 0 || version.length > SUBMITTED_VERSION_MAX_LENGTH) throw new NativeBuildInputError(`Invalid native build submission: version must be the store's label of the build, up to ${SUBMITTED_VERSION_MAX_LENGTH} characters.`);
|
|
6571
6649
|
return db.transaction(async (tx) => {
|
|
@@ -7750,13 +7828,19 @@ const createAdminRouteHandlers = () => ({
|
|
|
7750
7828
|
const scope = nativeBuildScopeOf(url);
|
|
7751
7829
|
const buildKey = url.searchParams.get("buildKey");
|
|
7752
7830
|
const builtInOlderThan = url.searchParams.get("builtInOlderThan");
|
|
7831
|
+
const kind = url.searchParams.get("kind");
|
|
7753
7832
|
const options = {
|
|
7754
7833
|
...buildKey === null ? {} : { buildKey },
|
|
7755
7834
|
...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
|
|
7756
|
-
...builtInOlderThan === null ? {} : { builtInOlderThan }
|
|
7835
|
+
...builtInOlderThan === null ? {} : { builtInOlderThan },
|
|
7836
|
+
...kind === null ? {} : { artifactKind: kind }
|
|
7757
7837
|
};
|
|
7758
7838
|
return json$2({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
|
|
7759
7839
|
}),
|
|
7840
|
+
findNativeBuildSibling: onCore(async (core, _request, params) => {
|
|
7841
|
+
const build = await core.getNativeBuild(requireRouteParam(params, "id"));
|
|
7842
|
+
return json$2({ data: build === null ? null : await core.findNativeBuildSibling(build) });
|
|
7843
|
+
}),
|
|
7760
7844
|
getNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
7761
7845
|
listNativeBuilds: onCore(async (core, request) => {
|
|
7762
7846
|
const url = new URL(request.url);
|
|
@@ -7988,6 +8072,11 @@ const ADMIN_ROUTES = [
|
|
|
7988
8072
|
path: "/native-builds/latest",
|
|
7989
8073
|
handler: "findNativeBuild"
|
|
7990
8074
|
},
|
|
8075
|
+
{
|
|
8076
|
+
method: "GET",
|
|
8077
|
+
path: "/native-builds/:id/sibling",
|
|
8078
|
+
handler: "findNativeBuildSibling"
|
|
8079
|
+
},
|
|
7991
8080
|
{
|
|
7992
8081
|
method: "GET",
|
|
7993
8082
|
path: "/native-builds/:id",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.44",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
40
|
"google-auth-library": "10.7.0",
|
|
41
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
42
|
-
"@hot-updater/server": "1.2.0-rc.
|
|
43
|
-
"@hot-updater/
|
|
44
|
-
"@hot-updater/
|
|
41
|
+
"@hot-updater/cli-tools": "1.2.0-rc.44",
|
|
42
|
+
"@hot-updater/server": "1.2.0-rc.44",
|
|
43
|
+
"@hot-updater/protocol": "1.2.0-rc.44",
|
|
44
|
+
"@hot-updater/plugin-core": "1.2.0-rc.44"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"firebase-tools": "15.29.0",
|
|
57
57
|
"fkill": "^9.0.0",
|
|
58
58
|
"mime": "^4.0.4",
|
|
59
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
60
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
59
|
+
"@hot-updater/mock": "1.2.0-rc.44",
|
|
60
|
+
"@hot-updater/test-utils": "1.2.0-rc.44"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"firebase-admin": ">=11.10.0",
|