@hot-updater/azure 1.2.0-rc.41 → 1.2.0-rc.43
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/functions/index.mjs +89 -12
- package/package.json +6 -6
package/dist/functions/index.mjs
CHANGED
|
@@ -6139,6 +6139,10 @@ const nativeBuilds = defineTable({
|
|
|
6139
6139
|
eq: ["scope_key", "build_key"],
|
|
6140
6140
|
sort: ["id"]
|
|
6141
6141
|
},
|
|
6142
|
+
byScopeKind: {
|
|
6143
|
+
eq: ["scope_key", "artifact_kind"],
|
|
6144
|
+
sort: ["id"]
|
|
6145
|
+
},
|
|
6142
6146
|
byStoreBuild: {
|
|
6143
6147
|
eq: ["store_build_scope_key"],
|
|
6144
6148
|
sort: [],
|
|
@@ -8155,7 +8159,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
8155
8159
|
};
|
|
8156
8160
|
//#endregion
|
|
8157
8161
|
//#region ../../packages/server/dist/version.mjs
|
|
8158
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
8162
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.43";
|
|
8159
8163
|
//#endregion
|
|
8160
8164
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
8161
8165
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -9681,6 +9685,39 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
|
|
|
9681
9685
|
if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
|
|
9682
9686
|
return null;
|
|
9683
9687
|
};
|
|
9688
|
+
const SIBLING_KINDS = {
|
|
9689
|
+
app: "ipa",
|
|
9690
|
+
ipa: "app"
|
|
9691
|
+
};
|
|
9692
|
+
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");
|
|
9693
|
+
const siblingSandboxScopeKey = (build, artifactKind) => {
|
|
9694
|
+
const [version, sandbox, platform, appId, urlScheme] = build.scope_key.split(":");
|
|
9695
|
+
if (version !== "v1" || sandbox !== "sandbox" || platform !== build.platform || appId === void 0 || urlScheme === void 0) return null;
|
|
9696
|
+
const target = build.fingerprint_hash === null ? {
|
|
9697
|
+
platform: build.platform,
|
|
9698
|
+
fingerprintHash: null,
|
|
9699
|
+
appVersion: build.app_version ?? ""
|
|
9700
|
+
} : {
|
|
9701
|
+
platform: build.platform,
|
|
9702
|
+
fingerprintHash: build.fingerprint_hash,
|
|
9703
|
+
appVersion: null
|
|
9704
|
+
};
|
|
9705
|
+
try {
|
|
9706
|
+
return sandboxScopeKey(target, {
|
|
9707
|
+
appId,
|
|
9708
|
+
urlScheme,
|
|
9709
|
+
artifactKind: build.artifact_kind,
|
|
9710
|
+
distribution: registeredDistribution(build.artifact_kind, build.export_method)
|
|
9711
|
+
}) === build.scope_key ? sandboxScopeKey(target, {
|
|
9712
|
+
appId,
|
|
9713
|
+
urlScheme,
|
|
9714
|
+
artifactKind,
|
|
9715
|
+
distribution: "direct"
|
|
9716
|
+
}) : null;
|
|
9717
|
+
} catch {
|
|
9718
|
+
return null;
|
|
9719
|
+
}
|
|
9720
|
+
};
|
|
9684
9721
|
const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
9685
9722
|
async registerNativeBuild(registration) {
|
|
9686
9723
|
const problem = problemOf(registration);
|
|
@@ -9748,9 +9785,12 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
9748
9785
|
const scopeKey = nativeBuildScopeKey(scope);
|
|
9749
9786
|
const buildKey = options?.buildKey;
|
|
9750
9787
|
if (buildKey !== void 0 && !BUILD_KEY.test(buildKey)) throw new NativeBuildInputError("Invalid native build key: it must be nbk1: and a SHA-256.");
|
|
9788
|
+
const artifactKind = options?.artifactKind;
|
|
9789
|
+
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 ")}.`);
|
|
9790
|
+
const ofKind = (row) => artifactKind === void 0 || row.artifact_kind === artifactKind;
|
|
9751
9791
|
if (options?.storeBuild) {
|
|
9752
9792
|
const marked = await db.findOne("native_builds", { store_build_scope_key: scopeKey });
|
|
9753
|
-
return marked === null ? null : pick(marked);
|
|
9793
|
+
return marked === null || !ofKind(marked) ? null : pick(marked);
|
|
9754
9794
|
}
|
|
9755
9795
|
const read = (limit, before) => {
|
|
9756
9796
|
const page = {
|
|
@@ -9758,34 +9798,60 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
9758
9798
|
limit,
|
|
9759
9799
|
...before === void 0 ? {} : { range: { lt: before } }
|
|
9760
9800
|
};
|
|
9761
|
-
return buildKey
|
|
9762
|
-
index: "byScope",
|
|
9763
|
-
where: { scope_key: scopeKey },
|
|
9764
|
-
...page
|
|
9765
|
-
}) : db.findMany("native_builds", {
|
|
9801
|
+
return buildKey !== void 0 ? db.findMany("native_builds", {
|
|
9766
9802
|
index: "byBuildKey",
|
|
9767
9803
|
where: {
|
|
9768
9804
|
scope_key: scopeKey,
|
|
9769
9805
|
build_key: buildKey
|
|
9770
9806
|
},
|
|
9771
9807
|
...page
|
|
9808
|
+
}) : artifactKind !== void 0 ? db.findMany("native_builds", {
|
|
9809
|
+
index: "byScopeKind",
|
|
9810
|
+
where: {
|
|
9811
|
+
scope_key: scopeKey,
|
|
9812
|
+
artifact_kind: artifactKind
|
|
9813
|
+
},
|
|
9814
|
+
...page
|
|
9815
|
+
}) : db.findMany("native_builds", {
|
|
9816
|
+
index: "byScope",
|
|
9817
|
+
where: { scope_key: scopeKey },
|
|
9818
|
+
...page
|
|
9772
9819
|
});
|
|
9773
9820
|
};
|
|
9774
9821
|
const bundleId = options?.builtInOlderThan;
|
|
9775
9822
|
if (bundleId !== void 0 && scope.sandbox !== void 0 && scope.sandbox !== null) return null;
|
|
9776
9823
|
const { rows } = await read(1);
|
|
9777
|
-
const newest = rows[0]
|
|
9778
|
-
|
|
9779
|
-
|
|
9824
|
+
const newest = (rows[0] === void 0 ? void 0 : pick(rows[0])) ?? (artifactKind !== void 0 && buildKey === void 0 ? await db.findMany("native_builds", {
|
|
9825
|
+
index: "byScope",
|
|
9826
|
+
where: { scope_key: scopeKey },
|
|
9827
|
+
order: "desc",
|
|
9828
|
+
limit: 1
|
|
9829
|
+
}).then(({ rows: [row] }) => row?.artifact_kind === artifactKind ? pick(row) : void 0) : void 0);
|
|
9830
|
+
if (newest === void 0 || !ofKind(newest)) return null;
|
|
9831
|
+
if (bundleId === void 0 || newest.min_bundle_id < bundleId) return newest;
|
|
9780
9832
|
for (let before = newest.id;;) {
|
|
9781
9833
|
const { rows: older } = await read(OLDER_BUILDS_PAGE, before);
|
|
9782
9834
|
const usable = older.find(({ min_bundle_id }) => min_bundle_id < bundleId);
|
|
9783
|
-
if (usable !== void 0) return pick(usable);
|
|
9835
|
+
if (usable !== void 0) return ofKind(usable) ? pick(usable) : null;
|
|
9784
9836
|
const last = older.at(-1);
|
|
9785
9837
|
if (older.length < OLDER_BUILDS_PAGE || last === void 0) return null;
|
|
9786
9838
|
before = last.id;
|
|
9787
9839
|
}
|
|
9788
9840
|
},
|
|
9841
|
+
async findNativeBuildSibling(build) {
|
|
9842
|
+
const artifactKind = SIBLING_KINDS[build.artifact_kind];
|
|
9843
|
+
if (build.platform !== "ios" || !build.is_sandbox || artifactKind === void 0 || !isInstallTarget(build)) return null;
|
|
9844
|
+
const scopeKey = siblingSandboxScopeKey(build, artifactKind);
|
|
9845
|
+
if (scopeKey === null) return null;
|
|
9846
|
+
const { rows } = await db.findMany("native_builds", {
|
|
9847
|
+
index: "byScope",
|
|
9848
|
+
where: { scope_key: scopeKey },
|
|
9849
|
+
order: "desc",
|
|
9850
|
+
limit: 1
|
|
9851
|
+
});
|
|
9852
|
+
const sibling = rows[0] === void 0 ? null : pick(rows[0]);
|
|
9853
|
+
return sibling !== null && isInstallTarget(sibling) ? sibling : null;
|
|
9854
|
+
},
|
|
9789
9855
|
async recordNativeBuildSubmission(id, { destination, version }) {
|
|
9790
9856
|
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.`);
|
|
9791
9857
|
return db.transaction(async (tx) => {
|
|
@@ -10909,13 +10975,19 @@ const createAdminRouteHandlers = () => ({
|
|
|
10909
10975
|
const scope = nativeBuildScopeOf(url);
|
|
10910
10976
|
const buildKey = url.searchParams.get("buildKey");
|
|
10911
10977
|
const builtInOlderThan = url.searchParams.get("builtInOlderThan");
|
|
10978
|
+
const kind = url.searchParams.get("kind");
|
|
10912
10979
|
const options = {
|
|
10913
10980
|
...buildKey === null ? {} : { buildKey },
|
|
10914
10981
|
...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
|
|
10915
|
-
...builtInOlderThan === null ? {} : { builtInOlderThan }
|
|
10982
|
+
...builtInOlderThan === null ? {} : { builtInOlderThan },
|
|
10983
|
+
...kind === null ? {} : { artifactKind: kind }
|
|
10916
10984
|
};
|
|
10917
10985
|
return json$2({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
|
|
10918
10986
|
}),
|
|
10987
|
+
findNativeBuildSibling: onCore(async (core, _request, params) => {
|
|
10988
|
+
const build = await core.getNativeBuild(requireRouteParam(params, "id"));
|
|
10989
|
+
return json$2({ data: build === null ? null : await core.findNativeBuildSibling(build) });
|
|
10990
|
+
}),
|
|
10919
10991
|
getNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
10920
10992
|
listNativeBuilds: onCore(async (core, request) => {
|
|
10921
10993
|
const url = new URL(request.url);
|
|
@@ -11146,6 +11218,11 @@ const ADMIN_ROUTES = [
|
|
|
11146
11218
|
path: "/native-builds/latest",
|
|
11147
11219
|
handler: "findNativeBuild"
|
|
11148
11220
|
},
|
|
11221
|
+
{
|
|
11222
|
+
method: "GET",
|
|
11223
|
+
path: "/native-builds/:id/sibling",
|
|
11224
|
+
handler: "findNativeBuildSibling"
|
|
11225
|
+
},
|
|
11149
11226
|
{
|
|
11150
11227
|
method: "GET",
|
|
11151
11228
|
path: "/native-builds/:id",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/azure",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.43",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@azure/identity": "4.14.0",
|
|
45
45
|
"@azure/keyvault-secrets": "4.11.2",
|
|
46
46
|
"@azure/storage-blob": "12.34.0",
|
|
47
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
48
|
-
"@hot-updater/
|
|
49
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
50
|
-
"@hot-updater/
|
|
47
|
+
"@hot-updater/cli-tools": "1.2.0-rc.43",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.43",
|
|
49
|
+
"@hot-updater/protocol": "1.2.0-rc.43",
|
|
50
|
+
"@hot-updater/plugin-core": "1.2.0-rc.43"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@azure/functions": "4.16.5",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"execa": "9.5.2",
|
|
56
56
|
"jszip": "^3.10.1",
|
|
57
57
|
"vitest": "4.1.4",
|
|
58
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
58
|
+
"@hot-updater/test-utils": "1.2.0-rc.43"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsdown",
|