@hot-updater/server 1.2.0-rc.4 → 1.2.0-rc.40
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/core/api.cjs +2 -0
- package/dist/core/api.d.cts +29 -0
- package/dist/core/api.d.mts +29 -0
- package/dist/core/api.mjs +2 -0
- package/dist/core/iosDevices.cjs +309 -0
- package/dist/core/iosDevices.mjs +306 -0
- package/dist/core/nativeBuildDestinations.cjs +13 -0
- package/dist/core/nativeBuildDestinations.mjs +13 -0
- package/dist/core/nativeBuilds.cjs +142 -24
- package/dist/core/nativeBuilds.mjs +142 -25
- package/dist/core/operations.cjs +6 -2
- package/dist/core/operations.mjs +7 -3
- package/dist/core/reads.cjs +9 -1
- package/dist/core/reads.mjs +9 -1
- package/dist/core/writes.cjs +4 -1
- package/dist/core/writes.mjs +4 -1
- package/dist/createHotUpdaterCore.d.cts +2 -4
- package/dist/createHotUpdaterCore.d.mts +2 -4
- package/dist/handlerAdminRoutes.cjs +149 -7
- package/dist/handlerAdminRoutes.mjs +149 -7
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +7 -14
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IosDeviceInputError } from "./core/iosDevices.mjs";
|
|
2
|
+
import { NATIVE_BUILD_SUBMISSION_DESTINATIONS } from "./core/nativeBuildDestinations.mjs";
|
|
1
3
|
import { NativeBuildInputError } from "./core/nativeBuilds.mjs";
|
|
2
4
|
import { HandlerBadRequestError } from "./handlerErrors.mjs";
|
|
3
5
|
import { decodeMaybe, isPlatform, parseBooleanSearchParam, requireRouteParam } from "./handlerParameters.mjs";
|
|
@@ -47,10 +49,12 @@ const keyset = (url, maxValue = LIMITS.maxValue) => {
|
|
|
47
49
|
const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
|
|
48
50
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
|
|
49
51
|
const cursor = url.searchParams.get("cursor");
|
|
52
|
+
const through = url.searchParams.get("through");
|
|
50
53
|
return {
|
|
51
54
|
order,
|
|
52
55
|
limit,
|
|
53
|
-
...cursor === null ? {} : { after: cursor }
|
|
56
|
+
...cursor === null ? {} : { after: cursor },
|
|
57
|
+
...through === null ? {} : { through }
|
|
54
58
|
};
|
|
55
59
|
};
|
|
56
60
|
/** A page and the cursor of the next one, when the page is full. */
|
|
@@ -165,11 +169,11 @@ const refusingInvalid = async (operation) => {
|
|
|
165
169
|
try {
|
|
166
170
|
return await operation();
|
|
167
171
|
} catch (error) {
|
|
168
|
-
if (error instanceof NativeBuildInputError) throw new HandlerBadRequestError(error.message);
|
|
172
|
+
if (error instanceof NativeBuildInputError || error instanceof IosDeviceInputError) throw new HandlerBadRequestError(error.message);
|
|
169
173
|
throw error;
|
|
170
174
|
}
|
|
171
175
|
};
|
|
172
|
-
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
176
|
+
const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText(value.channel) && isTextOrNull(value.fingerprintHash) && isTextOrNull(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull(value.gitCommitHash) && isTextOrNull(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull(value.sandboxUrlScheme)) && (value.exportMethod === void 0 || isTextOrNull(value.exportMethod)) && (value.nativeAppVersion === void 0 || isTextOrNull(value.nativeAppVersion)) && isRecord(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord(value.embeddedBundle) && isText(value.embeddedBundle.manifestStorageUri) && isText(value.embeddedBundle.manifestFileHash) && isText(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord(value.embeddedBundle.metadata));
|
|
173
177
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
174
178
|
/** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
|
|
175
179
|
const createAdminRouteHandlers = () => ({
|
|
@@ -251,7 +255,8 @@ const createAdminRouteHandlers = () => ({
|
|
|
251
255
|
rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
|
|
252
256
|
updateBundle: onCore(async (core, request, params) => {
|
|
253
257
|
const bundleId = requireRouteParam(params, "id");
|
|
254
|
-
|
|
258
|
+
const update = bundleUpdateOf(await request.json(), bundleId);
|
|
259
|
+
await refusingInvalid(() => core.updateBundle(bundleId, update));
|
|
255
260
|
return noContent();
|
|
256
261
|
}),
|
|
257
262
|
countBundles: onCore(async (core, request) => json({ data: await core.countBundles(platformOf(new URL(request.url))) })),
|
|
@@ -275,7 +280,7 @@ const createAdminRouteHandlers = () => ({
|
|
|
275
280
|
deployReleases: onCore(async (core, request) => {
|
|
276
281
|
const { deployments } = await body(request);
|
|
277
282
|
if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
|
|
278
|
-
return json({ data: await core.deploy(deployments) }, 201);
|
|
283
|
+
return json({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
|
|
279
284
|
}),
|
|
280
285
|
promoteRelease: onCore(async (core, request, params) => {
|
|
281
286
|
const input = await body(request);
|
|
@@ -298,7 +303,13 @@ const createAdminRouteHandlers = () => ({
|
|
|
298
303
|
const url = new URL(request.url);
|
|
299
304
|
const scope = nativeBuildScopeOf(url);
|
|
300
305
|
const buildKey = url.searchParams.get("buildKey");
|
|
301
|
-
|
|
306
|
+
const builtInOlderThan = url.searchParams.get("builtInOlderThan");
|
|
307
|
+
const options = {
|
|
308
|
+
...buildKey === null ? {} : { buildKey },
|
|
309
|
+
...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
|
|
310
|
+
...builtInOlderThan === null ? {} : { builtInOlderThan }
|
|
311
|
+
};
|
|
312
|
+
return json({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
|
|
302
313
|
}),
|
|
303
314
|
getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(requireRouteParam(params, "id")) })),
|
|
304
315
|
listNativeBuilds: onCore(async (core, request) => {
|
|
@@ -312,14 +323,95 @@ const createAdminRouteHandlers = () => ({
|
|
|
312
323
|
}),
|
|
313
324
|
recordNativeBuildSubmission: onCore(async (core, request, params) => {
|
|
314
325
|
const input = await body(request);
|
|
315
|
-
if (!isRecord(input) ||
|
|
326
|
+
if (!isRecord(input) || !Object.values(NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText(input.version)) throw new HandlerBadRequestError("A native build submission needs a valid store destination and version.");
|
|
316
327
|
const submission = {
|
|
317
328
|
destination: input.destination,
|
|
318
329
|
version: input.version
|
|
319
330
|
};
|
|
320
331
|
return json({ data: await refusingInvalid(() => core.recordNativeBuildSubmission(requireRouteParam(params, "id"), submission)) });
|
|
321
332
|
}),
|
|
333
|
+
markNativeBuild: onCore(async (core, request, params) => {
|
|
334
|
+
const input = await body(request);
|
|
335
|
+
if (!isRecord(input) || typeof input.storeBuild !== "boolean") throw new HandlerBadRequestError("A native build's store build mark needs storeBuild, true or false.");
|
|
336
|
+
const mark = { storeBuild: input.storeBuild };
|
|
337
|
+
return json({ data: await refusingInvalid(() => core.markNativeBuild(requireRouteParam(params, "id"), mark)) });
|
|
338
|
+
}),
|
|
322
339
|
deleteNativeBuild: onCore(async (core, _request, params) => json({ data: await core.deleteNativeBuild(requireRouteParam(params, "id")) })),
|
|
340
|
+
listIosDevices: onCore(async (core, request) => {
|
|
341
|
+
const url = new URL(request.url);
|
|
342
|
+
const input = keyset(url);
|
|
343
|
+
const status = url.searchParams.get("status");
|
|
344
|
+
return page(await refusingInvalid(() => core.listIosDevices({
|
|
345
|
+
...input,
|
|
346
|
+
...status === null ? {} : { status }
|
|
347
|
+
})), input, ({ id }) => id);
|
|
348
|
+
}),
|
|
349
|
+
findIosDevice: onCore(async (core, _request, params) => json({ data: await core.findIosDevice(requireRouteParam(params, "udid")) })),
|
|
350
|
+
requestIosDevice: onCore(async (core, request) => {
|
|
351
|
+
const input = await body(request);
|
|
352
|
+
if (!isText(input.udid) || !isText(input.name) || !isTextOrNull(input.requestedBy)) throw new HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
|
|
353
|
+
const device = {
|
|
354
|
+
udid: input.udid,
|
|
355
|
+
name: input.name,
|
|
356
|
+
requestedBy: input.requestedBy
|
|
357
|
+
};
|
|
358
|
+
return json({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
|
|
359
|
+
}),
|
|
360
|
+
approveIosDevice: onCore(async (core, request, params) => {
|
|
361
|
+
const input = await body(request);
|
|
362
|
+
if (!isTextOrNull(input.approvedBy) || input.name !== void 0 && !isText(input.name)) throw new HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
|
|
363
|
+
const approval = {
|
|
364
|
+
approvedBy: input.approvedBy,
|
|
365
|
+
...input.name === void 0 ? {} : { name: input.name }
|
|
366
|
+
};
|
|
367
|
+
return json({ data: await refusingInvalid(() => core.approveIosDevice(requireRouteParam(params, "id"), approval)) });
|
|
368
|
+
}),
|
|
369
|
+
renameIosDevice: onCore(async (core, request, params) => {
|
|
370
|
+
const input = await body(request);
|
|
371
|
+
if (!isText(input.name)) throw new HandlerBadRequestError("An iOS device's new name is required.");
|
|
372
|
+
const name = input.name;
|
|
373
|
+
return json({ data: await refusingInvalid(() => core.renameIosDevice(requireRouteParam(params, "id"), name)) });
|
|
374
|
+
}),
|
|
375
|
+
recordIosDeviceOutcome: onCore(async (core, request, params) => {
|
|
376
|
+
const input = await body(request);
|
|
377
|
+
const seen = input.seen;
|
|
378
|
+
if (!isRecord(seen) || typeof seen.status !== "string" || !(seen.approvedAtMs === null || Number.isSafeInteger(seen.approvedAtMs)) || !isText(input.issuerId) || typeof input.outcome !== "string" || input.reason !== void 0 && typeof input.reason !== "string") throw new HandlerBadRequestError("An iOS device outcome needs seen { status, approvedAtMs }, issuerId, outcome, and an optional reason.");
|
|
379
|
+
const outcome = {
|
|
380
|
+
id: requireRouteParam(params, "id"),
|
|
381
|
+
seen: {
|
|
382
|
+
status: seen.status,
|
|
383
|
+
approvedAtMs: seen.approvedAtMs
|
|
384
|
+
},
|
|
385
|
+
issuerId: input.issuerId,
|
|
386
|
+
outcome: input.outcome,
|
|
387
|
+
...input.reason === void 0 ? {} : { reason: input.reason }
|
|
388
|
+
};
|
|
389
|
+
return json({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
|
|
390
|
+
}),
|
|
391
|
+
claimIosDeviceAccount: onCore(async (core, request) => {
|
|
392
|
+
const { issuerId } = await body(request);
|
|
393
|
+
if (!isText(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
|
|
394
|
+
return json({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
|
|
395
|
+
}),
|
|
396
|
+
markIosDevicesInBuild: onCore(async (core, request) => {
|
|
397
|
+
const { buildId, ids } = await body(request);
|
|
398
|
+
if (!isText(buildId) || !Array.isArray(ids) || !ids.every((id) => isText(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
|
|
399
|
+
await core.markIosDevicesInBuild({
|
|
400
|
+
buildId,
|
|
401
|
+
ids
|
|
402
|
+
});
|
|
403
|
+
return noContent();
|
|
404
|
+
}),
|
|
405
|
+
deleteIosDevice: onCore(async (core, request, params) => {
|
|
406
|
+
const url = new URL(request.url);
|
|
407
|
+
const status = url.searchParams.get("status");
|
|
408
|
+
const requestedBy = url.searchParams.get("requestedBy");
|
|
409
|
+
const only = {
|
|
410
|
+
...status === null ? {} : { status },
|
|
411
|
+
...requestedBy === null ? {} : { requestedBy }
|
|
412
|
+
};
|
|
413
|
+
return json({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(requireRouteParam(params, "id")) : core.deleteIosDevice(requireRouteParam(params, "id"), only)) });
|
|
414
|
+
}),
|
|
323
415
|
deleteBundles: onCore(async (core, request) => {
|
|
324
416
|
const { ids } = await body(request);
|
|
325
417
|
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new HandlerBadRequestError("Bundle deletion needs ids");
|
|
@@ -464,10 +556,60 @@ const ADMIN_ROUTES = [
|
|
|
464
556
|
path: "/native-builds/:id/submission",
|
|
465
557
|
handler: "recordNativeBuildSubmission"
|
|
466
558
|
},
|
|
559
|
+
{
|
|
560
|
+
method: "POST",
|
|
561
|
+
path: "/native-builds/:id/store-build",
|
|
562
|
+
handler: "markNativeBuild"
|
|
563
|
+
},
|
|
467
564
|
{
|
|
468
565
|
method: "DELETE",
|
|
469
566
|
path: "/native-builds/:id",
|
|
470
567
|
handler: "deleteNativeBuild"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
method: "GET",
|
|
571
|
+
path: "/ios-devices",
|
|
572
|
+
handler: "listIosDevices"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
method: "POST",
|
|
576
|
+
path: "/ios-devices",
|
|
577
|
+
handler: "requestIosDevice"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
method: "GET",
|
|
581
|
+
path: "/ios-devices/udid/:udid",
|
|
582
|
+
handler: "findIosDevice"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
method: "POST",
|
|
586
|
+
path: "/ios-devices/in-build",
|
|
587
|
+
handler: "markIosDevicesInBuild"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
method: "POST",
|
|
591
|
+
path: "/ios-devices/account",
|
|
592
|
+
handler: "claimIosDeviceAccount"
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
method: "POST",
|
|
596
|
+
path: "/ios-devices/:id/approval",
|
|
597
|
+
handler: "approveIosDevice"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
method: "POST",
|
|
601
|
+
path: "/ios-devices/:id/outcome",
|
|
602
|
+
handler: "recordIosDeviceOutcome"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
method: "PATCH",
|
|
606
|
+
path: "/ios-devices/:id",
|
|
607
|
+
handler: "renameIosDevice"
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
method: "DELETE",
|
|
611
|
+
path: "/ios-devices/:id",
|
|
612
|
+
handler: "deleteIosDevice"
|
|
471
613
|
}
|
|
472
614
|
];
|
|
473
615
|
//#endregion
|
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/server",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"rou3": "0.7.9",
|
|
52
52
|
"verkit": "0.4.0",
|
|
53
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
54
|
-
"@hot-updater/plugin-
|
|
55
|
-
"@hot-updater/plugin-api-keys": "1.2.0-rc.
|
|
56
|
-
"@hot-updater/plugin-remote-config": "1.2.0-rc.
|
|
57
|
-
"@hot-updater/plugin-
|
|
53
|
+
"@hot-updater/protocol": "1.2.0-rc.40",
|
|
54
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.40",
|
|
55
|
+
"@hot-updater/plugin-api-keys": "1.2.0-rc.40",
|
|
56
|
+
"@hot-updater/plugin-remote-config": "1.2.0-rc.40",
|
|
57
|
+
"@hot-updater/plugin-core": "1.2.0-rc.40"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@prisma/client": "*",
|
|
@@ -94,14 +94,7 @@
|
|
|
94
94
|
"pg": "8.13.1",
|
|
95
95
|
"prisma": "6.19.3",
|
|
96
96
|
"uuidv7": "^1.0.2",
|
|
97
|
-
"wrangler": "^4.69.0"
|
|
98
|
-
"@hot-updater/standalone": "1.2.0-rc.4",
|
|
99
|
-
"@hot-updater/test-utils": "1.2.0-rc.4"
|
|
100
|
-
},
|
|
101
|
-
"nx": {
|
|
102
|
-
"implicitDependencies": [
|
|
103
|
-
"!@hot-updater/test-utils"
|
|
104
|
-
]
|
|
97
|
+
"wrangler": "^4.69.0"
|
|
105
98
|
},
|
|
106
99
|
"scripts": {
|
|
107
100
|
"build": "tsdown",
|