@hot-updater/server 1.2.0-rc.5 → 1.2.0-rc.50

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.
Files changed (49) hide show
  1. package/dist/adapters/drizzle.cjs +8 -4
  2. package/dist/adapters/drizzle.d.cts +3 -2
  3. package/dist/adapters/drizzle.d.mts +3 -2
  4. package/dist/adapters/drizzle.mjs +8 -4
  5. package/dist/adapters/drizzleExecutor.cjs +4 -2
  6. package/dist/adapters/drizzleExecutor.mjs +4 -2
  7. package/dist/adapters/kysely.cjs +3 -2
  8. package/dist/adapters/kysely.mjs +3 -2
  9. package/dist/adapters/mongodb.cjs +1 -1
  10. package/dist/adapters/mongodb.mjs +1 -1
  11. package/dist/adapters/mongodbAdapter.cjs +15 -3
  12. package/dist/adapters/mongodbAdapter.mjs +15 -3
  13. package/dist/adapters/prisma.cjs +9 -13
  14. package/dist/adapters/prisma.mjs +10 -14
  15. package/dist/adapters/prismaExecutor.cjs +25 -20
  16. package/dist/adapters/prismaExecutor.mjs +25 -20
  17. package/dist/core/api.cjs +2 -0
  18. package/dist/core/api.d.cts +39 -1
  19. package/dist/core/api.d.mts +39 -1
  20. package/dist/core/api.mjs +2 -0
  21. package/dist/core/iosDevices.cjs +306 -0
  22. package/dist/core/iosDevices.mjs +303 -0
  23. package/dist/core/nativeBuildDestinations.cjs +13 -0
  24. package/dist/core/nativeBuildDestinations.mjs +13 -0
  25. package/dist/core/nativeBuilds.cjs +291 -22
  26. package/dist/core/nativeBuilds.mjs +291 -23
  27. package/dist/core/operations.cjs +8 -22
  28. package/dist/core/operations.mjs +11 -25
  29. package/dist/core/reads.cjs +44 -4
  30. package/dist/core/reads.mjs +44 -4
  31. package/dist/core/releases.cjs +78 -26
  32. package/dist/core/releases.mjs +79 -29
  33. package/dist/core/writes.cjs +4 -1
  34. package/dist/core/writes.mjs +4 -1
  35. package/dist/createHotUpdaterCore.d.cts +2 -4
  36. package/dist/createHotUpdaterCore.d.mts +2 -4
  37. package/dist/db/engineDrizzleSchema.cjs +21 -5
  38. package/dist/db/engineDrizzleSchema.mjs +21 -6
  39. package/dist/db/enginePrismaSchema.cjs +6 -14
  40. package/dist/db/enginePrismaSchema.mjs +7 -15
  41. package/dist/db/releaseCatalog.cjs +13 -4
  42. package/dist/db/releaseCatalog.mjs +12 -5
  43. package/dist/handlerAdminRoutes.cjs +254 -16
  44. package/dist/handlerAdminRoutes.mjs +255 -17
  45. package/dist/handlerReleaseCatalogRoutes.cjs +43 -27
  46. package/dist/handlerReleaseCatalogRoutes.mjs +43 -27
  47. package/dist/package.cjs +1 -1
  48. package/dist/package.mjs +1 -1
  49. package/package.json +7 -14
@@ -20,10 +20,15 @@ const releaseCatalogScopeKeyOf = (input) => input.strategy === "APP_VERSION" ? c
20
20
  platform: input.platform,
21
21
  strategy: "FINGERPRINT"
22
22
  });
23
- /** Projects a stored catalog row for one update check; null when the row is not this scope's. */
24
- const projectReleaseCatalogRow = (row, input, scopeKey = releaseCatalogScopeKeyOf(input)) => {
25
- if (row === null || row.platform !== input.platform || row.strategy !== input.strategy || row.channel_key !== input.channelKey || row.scope_key !== scopeKey || row.fingerprint_hash !== (input.strategy === "FINGERPRINT" ? input.fingerprintHash : null)) return null;
26
- const compiled = parseCompiledCatalog(row.payload, input.strategy);
23
+ const parseReleaseCatalogRow = ({ payload, ...row }) => ({
24
+ row,
25
+ compiled: parseCompiledCatalog(payload, row.strategy)
26
+ });
27
+ /** Projects a parsed catalog row for one update check; null when the row is not this scope's. */
28
+ const projectParsedReleaseCatalogRow = (parsed, input, scopeKey = releaseCatalogScopeKeyOf(input)) => {
29
+ if (parsed === null) return null;
30
+ const { row, compiled } = parsed;
31
+ if (row.platform !== input.platform || row.strategy !== input.strategy || row.channel_key !== input.channelKey || row.scope_key !== scopeKey || row.fingerprint_hash !== (input.strategy === "FINGERPRINT" ? input.fingerprintHash : null)) return null;
27
32
  const appVersion = input.strategy === "APP_VERSION" ? input.appVersion : void 0;
28
33
  return {
29
34
  catalogId: row.catalog_id,
@@ -36,5 +41,7 @@ const projectReleaseCatalogRow = (row, input, scopeKey = releaseCatalogScopeKeyO
36
41
  scopeKey
37
42
  };
38
43
  };
44
+ /** Projects a stored catalog row for one update check; null when the row is not this scope's. */
45
+ const projectReleaseCatalogRow = (row, input, scopeKey = releaseCatalogScopeKeyOf(input)) => projectParsedReleaseCatalogRow(row === null ? null : parseReleaseCatalogRow(row), input, scopeKey);
39
46
  //#endregion
40
- export { parseCompiledCatalog, projectReleaseCatalogRow, releaseCatalogScopeKeyOf };
47
+ export { parseCompiledCatalog, parseReleaseCatalogRow, projectParsedReleaseCatalogRow, projectReleaseCatalogRow, releaseCatalogScopeKeyOf };
@@ -1,3 +1,5 @@
1
+ const require_iosDevices = require("./core/iosDevices.cjs");
2
+ const require_nativeBuildDestinations = require("./core/nativeBuildDestinations.cjs");
1
3
  const require_nativeBuilds = require("./core/nativeBuilds.cjs");
2
4
  const require_handlerErrors = require("./handlerErrors.cjs");
3
5
  const require_handlerParameters = require("./handlerParameters.cjs");
@@ -20,6 +22,10 @@ const answer = async (operation) => {
20
22
  error: error.message
21
23
  }, status);
22
24
  }
25
+ if (error instanceof _hot_updater_plugin_core.ReleaseCatalogCompilationError && error.code === "CATALOG_OVERSIZE") return json({
26
+ code: error.code,
27
+ error: error.message
28
+ }, 400);
23
29
  if (error instanceof _hot_updater_plugin_core.DatabaseBundleNotFoundError) return json({
24
30
  code: "BUNDLE_NOT_FOUND",
25
31
  error: error.message
@@ -39,18 +45,22 @@ const LIMITS = {
39
45
  defaultValue: 50,
40
46
  maxValue: 500
41
47
  };
48
+ /** The most IDs one request names: a lookup's, or a write's. */
49
+ const MAX_IDS = 100;
42
50
  /** `order`, `cursor`, and `limit`: one keyset page. */
43
- const keyset = (url, maxValue = LIMITS.maxValue) => {
44
- const order = url.searchParams.get("order") ?? "desc";
51
+ const keyset = (url, maxValue = LIMITS.maxValue, defaultOrder = "desc") => {
52
+ const order = url.searchParams.get("order") ?? defaultOrder;
45
53
  if (order !== "asc" && order !== "desc") throw new require_handlerErrors.HandlerBadRequestError("order must be 'asc' or 'desc'.");
46
54
  const limitParam = url.searchParams.get("limit");
47
55
  const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
48
56
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new require_handlerErrors.HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
49
57
  const cursor = url.searchParams.get("cursor");
58
+ const through = url.searchParams.get("through");
50
59
  return {
51
60
  order,
52
61
  limit,
53
- ...cursor === null ? {} : { after: cursor }
62
+ ...cursor === null ? {} : { after: cursor },
63
+ ...through === null ? {} : { through }
54
64
  };
55
65
  };
56
66
  /** A page and the cursor of the next one, when the page is full. */
@@ -148,7 +158,8 @@ const nativeBuildScopeOf = (url) => {
148
158
  const fingerprintHash = params.get("fingerprintHash");
149
159
  const appVersion = params.get("appVersion");
150
160
  if (platform === void 0 || !isText(channel) || fingerprintHash === null === (appVersion === null) || fingerprintHash === "" || appVersion === "") throw new require_handlerErrors.HandlerBadRequestError("A native build lookup needs platform, channel, and fingerprintHash or appVersion.");
151
- return fingerprintHash !== null ? {
161
+ const sandbox = sandboxScopeOf(params);
162
+ const scope = fingerprintHash !== null ? {
152
163
  platform,
153
164
  channel,
154
165
  fingerprintHash,
@@ -159,17 +170,49 @@ const nativeBuildScopeOf = (url) => {
159
170
  fingerprintHash: null,
160
171
  appVersion
161
172
  };
173
+ return sandbox === null ? scope : {
174
+ ...scope,
175
+ sandbox
176
+ };
177
+ };
178
+ /** The query parameters a sandbox lookup names, all four or none. */
179
+ const SANDBOX_SCOPE_PARAMS = [
180
+ "sandboxAppId",
181
+ "sandboxUrlScheme",
182
+ "artifactKind",
183
+ "distribution"
184
+ ];
185
+ /**
186
+ * A lookup's sandbox scope: null without one, and a bad request for one
187
+ * named in part. Core checks each value.
188
+ */
189
+ const sandboxScopeOf = (params) => {
190
+ const [appId, urlScheme, artifactKind, distribution] = SANDBOX_SCOPE_PARAMS.map((name) => params.get(name));
191
+ const named = [
192
+ appId,
193
+ urlScheme,
194
+ artifactKind,
195
+ distribution
196
+ ].filter((value) => value !== null).length;
197
+ if (named === 0) return null;
198
+ if (named !== SANDBOX_SCOPE_PARAMS.length) throw new require_handlerErrors.HandlerBadRequestError(`A sandbox build lookup needs ${SANDBOX_SCOPE_PARAMS.join(", ")}.`);
199
+ return {
200
+ appId,
201
+ urlScheme,
202
+ artifactKind,
203
+ distribution
204
+ };
162
205
  };
163
206
  /** A native build or scope core refuses: a bad request. */
164
207
  const refusingInvalid = async (operation) => {
165
208
  try {
166
209
  return await operation();
167
210
  } catch (error) {
168
- if (error instanceof require_nativeBuilds.NativeBuildInputError) throw new require_handlerErrors.HandlerBadRequestError(error.message);
211
+ if (error instanceof require_nativeBuilds.NativeBuildInputError || error instanceof require_iosDevices.IosDeviceInputError) throw new require_handlerErrors.HandlerBadRequestError(error.message);
169
212
  throw error;
170
213
  }
171
214
  };
172
- const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && require_handlerParameters.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));
215
+ const isNativeBuildRegistration = (value) => isRecord(value) && isText(value.id) && isText(value.minBundleId) && typeof value.platform === "string" && require_handlerParameters.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.sandboxAppId === void 0 || isTextOrNull(value.sandboxAppId)) && (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
216
  const scopeKeyOf = (params) => require_handlerParameters.decodeMaybe(require_handlerParameters.requireRouteParam(params, "scopeKey")) ?? "";
174
217
  /** Every admin route's handler, by the name `ADMIN_ROUTES` mounts it under. */
175
218
  const createAdminRouteHandlers = () => ({
@@ -202,12 +245,40 @@ const createAdminRouteHandlers = () => ({
202
245
  const rows = await core.listReleaseCatalogs(input);
203
246
  return page(rows, input, (row) => row.scope_key);
204
247
  }),
205
- /** With `name`, the one channel of that name: 1 read. */
248
+ /** Up to 100 scope keys that have releases, after `cursor`: one seek each. */
249
+ listReleaseScopeKeys: onCore(async (core, request) => {
250
+ const input = keyset(new URL(request.url), 100, "asc");
251
+ if (input.order !== "asc" || input.through !== void 0) throw new require_handlerErrors.HandlerBadRequestError("Release scopes are listed ascending, by limit and cursor only.");
252
+ const rows = await core.listReleaseScopeKeys({
253
+ limit: input.limit,
254
+ ...input.after === void 0 ? {} : { after: input.after }
255
+ });
256
+ return page(rows, input, (scopeKey) => scopeKey);
257
+ }),
258
+ /**
259
+ * With `name`, the one channel of that name: 1 read. With `ids`, the
260
+ * channels of up to 100 IDs: 1 batch read. With `limit` or `cursor`, one
261
+ * page by name. With none, every channel, as servers before pages answered.
262
+ */
206
263
  getChannels: onCore(async (core, request) => {
207
- const name = new URL(request.url).searchParams.get("name");
208
- if (name === null) return json({ data: await core.listChannels() });
209
- const channel = await core.findChannelByName(name);
210
- return channel === null ? notFound() : json({ data: channel });
264
+ const url = new URL(request.url);
265
+ const name = url.searchParams.get("name");
266
+ if (name !== null) {
267
+ const channel = await core.findChannelByName(name);
268
+ return channel === null ? notFound() : json({ data: channel });
269
+ }
270
+ const ids = url.searchParams.get("ids");
271
+ if (ids !== null) {
272
+ const list = ids.split(",").filter((id) => id.length > 0);
273
+ if (list.length === 0 || list.length > MAX_IDS) throw new require_handlerErrors.HandlerBadRequestError(`Channels by ID take ids=<channel id>,... with 1 to ${MAX_IDS} ids.`);
274
+ return json({ data: await core.getChannels(list) });
275
+ }
276
+ if (url.searchParams.has("limit") || url.searchParams.has("cursor")) {
277
+ const input = keyset(url, LIMITS.maxValue, "asc");
278
+ const rows = await core.listChannels(input);
279
+ return page(rows, input, (row) => row.name);
280
+ }
281
+ return json({ data: await core.listChannels() });
211
282
  }),
212
283
  /** The channel named in the body, created when missing. */
213
284
  createChannel: onCore(async (core, request) => {
@@ -251,13 +322,14 @@ const createAdminRouteHandlers = () => ({
251
322
  rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
252
323
  updateBundle: onCore(async (core, request, params) => {
253
324
  const bundleId = require_handlerParameters.requireRouteParam(params, "id");
254
- await core.updateBundle(bundleId, bundleUpdateOf(await request.json(), bundleId));
325
+ const update = bundleUpdateOf(await request.json(), bundleId);
326
+ await refusingInvalid(() => core.updateBundle(bundleId, update));
255
327
  return noContent();
256
328
  }),
257
329
  countBundles: onCore(async (core, request) => json({ data: await core.countBundles(platformOf(new URL(request.url))) })),
258
330
  countBundleChildren: onCore(async (core, request) => {
259
331
  const ids = (new URL(request.url).searchParams.get("ids") ?? "").split(",").filter((id) => id.length > 0);
260
- if (ids.length === 0 || ids.length > 100) throw new require_handlerErrors.HandlerBadRequestError("Bundle child counts take ids=<bundle id>,... with 1 to 100 ids.");
332
+ if (ids.length === 0 || ids.length > MAX_IDS) throw new require_handlerErrors.HandlerBadRequestError(`Bundle child counts take ids=<bundle id>,... with 1 to ${MAX_IDS} ids.`);
261
333
  return json({ data: await core.countBundleChildren(ids) });
262
334
  }),
263
335
  listBundleChildren: onCore(async (core, request, params) => {
@@ -275,7 +347,7 @@ const createAdminRouteHandlers = () => ({
275
347
  deployReleases: onCore(async (core, request) => {
276
348
  const { deployments } = await body(request);
277
349
  if (!Array.isArray(deployments) || deployments.length === 0 || !deployments.every(isDeployment)) throw new require_handlerErrors.HandlerBadRequestError("Deploy needs deployments, each a bundle and its release policy.");
278
- return json({ data: await core.deploy(deployments) }, 201);
350
+ return json({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
279
351
  }),
280
352
  promoteRelease: onCore(async (core, request, params) => {
281
353
  const input = await body(request);
@@ -298,9 +370,22 @@ const createAdminRouteHandlers = () => ({
298
370
  const url = new URL(request.url);
299
371
  const scope = nativeBuildScopeOf(url);
300
372
  const buildKey = url.searchParams.get("buildKey");
301
- return json({ data: await refusingInvalid(() => buildKey === null ? core.findNativeBuild(scope) : core.findNativeBuild(scope, { buildKey })) });
373
+ const builtInOlderThan = url.searchParams.get("builtInOlderThan");
374
+ const kind = url.searchParams.get("kind");
375
+ const options = {
376
+ ...buildKey === null ? {} : { buildKey },
377
+ ...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
378
+ ...builtInOlderThan === null ? {} : { builtInOlderThan },
379
+ ...kind === null ? {} : { artifactKind: kind }
380
+ };
381
+ return json({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
382
+ }),
383
+ findNativeBuildSibling: onCore(async (core, _request, params) => {
384
+ const build = await core.getNativeBuild(require_handlerParameters.requireRouteParam(params, "id"));
385
+ return json({ data: build === null ? null : await core.findNativeBuildSibling(build) });
302
386
  }),
303
387
  getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(require_handlerParameters.requireRouteParam(params, "id")) })),
388
+ findNativeBuildByBuiltInBundle: onCore(async (core, _request, params) => json({ data: await core.findNativeBuildByBuiltInBundle(require_handlerParameters.requireRouteParam(params, "bundleId")) })),
304
389
  listNativeBuilds: onCore(async (core, request) => {
305
390
  const url = new URL(request.url);
306
391
  const input = keyset(url);
@@ -312,14 +397,97 @@ const createAdminRouteHandlers = () => ({
312
397
  }),
313
398
  recordNativeBuildSubmission: onCore(async (core, request, params) => {
314
399
  const input = await body(request);
315
- if (!isRecord(input) || input.destination !== "testflight" && input.destination !== "play-internal" || !isText(input.version)) throw new require_handlerErrors.HandlerBadRequestError("A native build submission needs destination (testflight or play-internal) and version.");
400
+ if (!isRecord(input) || !Object.values(require_nativeBuildDestinations.NATIVE_BUILD_SUBMISSION_DESTINATIONS).flat().includes(input.destination) || !isText(input.version)) throw new require_handlerErrors.HandlerBadRequestError("A native build submission needs a valid store destination and version.");
316
401
  const submission = {
317
402
  destination: input.destination,
318
403
  version: input.version
319
404
  };
320
405
  return json({ data: await refusingInvalid(() => core.recordNativeBuildSubmission(require_handlerParameters.requireRouteParam(params, "id"), submission)) });
321
406
  }),
407
+ markNativeBuild: onCore(async (core, request, params) => {
408
+ const input = await body(request);
409
+ if (!isRecord(input) || typeof input.storeBuild !== "boolean") throw new require_handlerErrors.HandlerBadRequestError("A native build's store build mark needs storeBuild, true or false.");
410
+ const mark = { storeBuild: input.storeBuild };
411
+ return json({ data: await refusingInvalid(() => core.markNativeBuild(require_handlerParameters.requireRouteParam(params, "id"), mark)) });
412
+ }),
322
413
  deleteNativeBuild: onCore(async (core, _request, params) => json({ data: await core.deleteNativeBuild(require_handlerParameters.requireRouteParam(params, "id")) })),
414
+ listIosDevices: onCore(async (core, request) => {
415
+ const url = new URL(request.url);
416
+ const input = keyset(url);
417
+ const status = url.searchParams.get("status");
418
+ return page(await refusingInvalid(() => core.listIosDevices({
419
+ ...input,
420
+ ...status === null ? {} : { status }
421
+ })), input, ({ id }) => id);
422
+ }),
423
+ findIosDevice: onCore(async (core, _request, params) => json({ data: await core.findIosDevice(require_handlerParameters.requireRouteParam(params, "udid")) })),
424
+ requestIosDevice: onCore(async (core, request) => {
425
+ const input = await body(request);
426
+ if (!isText(input.udid) || !isText(input.name) || !isTextOrNull(input.requestedBy)) throw new require_handlerErrors.HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
427
+ const device = {
428
+ udid: input.udid,
429
+ name: input.name,
430
+ requestedBy: input.requestedBy
431
+ };
432
+ return json({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
433
+ }),
434
+ approveIosDevice: onCore(async (core, request, params) => {
435
+ const input = await body(request);
436
+ if (!isTextOrNull(input.approvedBy) || input.name !== void 0 && !isText(input.name)) throw new require_handlerErrors.HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
437
+ const approval = {
438
+ approvedBy: input.approvedBy,
439
+ ...input.name === void 0 ? {} : { name: input.name }
440
+ };
441
+ return json({ data: await refusingInvalid(() => core.approveIosDevice(require_handlerParameters.requireRouteParam(params, "id"), approval)) });
442
+ }),
443
+ renameIosDevice: onCore(async (core, request, params) => {
444
+ const input = await body(request);
445
+ if (!isText(input.name)) throw new require_handlerErrors.HandlerBadRequestError("An iOS device's new name is required.");
446
+ const name = input.name;
447
+ return json({ data: await refusingInvalid(() => core.renameIosDevice(require_handlerParameters.requireRouteParam(params, "id"), name)) });
448
+ }),
449
+ recordIosDeviceOutcome: onCore(async (core, request, params) => {
450
+ const input = await body(request);
451
+ const seen = input.seen;
452
+ 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 require_handlerErrors.HandlerBadRequestError("An iOS device outcome needs seen { status, approvedAtMs }, issuerId, outcome, and an optional reason.");
453
+ const outcome = {
454
+ id: require_handlerParameters.requireRouteParam(params, "id"),
455
+ seen: {
456
+ status: seen.status,
457
+ approvedAtMs: seen.approvedAtMs
458
+ },
459
+ issuerId: input.issuerId,
460
+ outcome: input.outcome,
461
+ ...input.reason === void 0 ? {} : { reason: input.reason }
462
+ };
463
+ return json({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
464
+ }),
465
+ claimIosDeviceAccount: onCore(async (core, request) => {
466
+ const { issuerId } = await body(request);
467
+ if (!isText(issuerId)) throw new require_handlerErrors.HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
468
+ return json({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
469
+ }),
470
+ findIosDeviceAccount: onCore(async (core) => json({ data: await core.findIosDeviceAccount() })),
471
+ markIosDevicesInBuild: onCore(async (core, request) => {
472
+ const { buildId, ids } = await body(request);
473
+ if (!isText(buildId) || !Array.isArray(ids) || !ids.every((id) => isText(id))) throw new require_handlerErrors.HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
474
+ if (ids.length > MAX_IDS) throw new require_handlerErrors.HandlerBadRequestError(`Marking iOS devices in a build takes at most ${MAX_IDS} ids a request.`);
475
+ await core.markIosDevicesInBuild({
476
+ buildId,
477
+ ids
478
+ });
479
+ return noContent();
480
+ }),
481
+ deleteIosDevice: onCore(async (core, request, params) => {
482
+ const url = new URL(request.url);
483
+ const status = url.searchParams.get("status");
484
+ const requestedBy = url.searchParams.get("requestedBy");
485
+ const only = {
486
+ ...status === null ? {} : { status },
487
+ ...requestedBy === null ? {} : { requestedBy }
488
+ };
489
+ return json({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(require_handlerParameters.requireRouteParam(params, "id")) : core.deleteIosDevice(require_handlerParameters.requireRouteParam(params, "id"), only)) });
490
+ }),
323
491
  deleteBundles: onCore(async (core, request) => {
324
492
  const { ids } = await body(request);
325
493
  if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new require_handlerErrors.HandlerBadRequestError("Bundle deletion needs ids");
@@ -374,6 +542,11 @@ const ADMIN_ROUTES = [
374
542
  path: "/release-catalogs",
375
543
  handler: "listReleaseCatalogs"
376
544
  },
545
+ {
546
+ method: "GET",
547
+ path: "/release-scopes",
548
+ handler: "listReleaseScopeKeys"
549
+ },
377
550
  {
378
551
  method: "POST",
379
552
  path: "/release-catalogs/:scopeKey/rebuild",
@@ -449,6 +622,16 @@ const ADMIN_ROUTES = [
449
622
  path: "/native-builds/latest",
450
623
  handler: "findNativeBuild"
451
624
  },
625
+ {
626
+ method: "GET",
627
+ path: "/native-builds/built-in/:bundleId",
628
+ handler: "findNativeBuildByBuiltInBundle"
629
+ },
630
+ {
631
+ method: "GET",
632
+ path: "/native-builds/:id/sibling",
633
+ handler: "findNativeBuildSibling"
634
+ },
452
635
  {
453
636
  method: "GET",
454
637
  path: "/native-builds/:id",
@@ -464,10 +647,65 @@ const ADMIN_ROUTES = [
464
647
  path: "/native-builds/:id/submission",
465
648
  handler: "recordNativeBuildSubmission"
466
649
  },
650
+ {
651
+ method: "POST",
652
+ path: "/native-builds/:id/store-build",
653
+ handler: "markNativeBuild"
654
+ },
467
655
  {
468
656
  method: "DELETE",
469
657
  path: "/native-builds/:id",
470
658
  handler: "deleteNativeBuild"
659
+ },
660
+ {
661
+ method: "GET",
662
+ path: "/ios-devices",
663
+ handler: "listIosDevices"
664
+ },
665
+ {
666
+ method: "POST",
667
+ path: "/ios-devices",
668
+ handler: "requestIosDevice"
669
+ },
670
+ {
671
+ method: "GET",
672
+ path: "/ios-devices/udid/:udid",
673
+ handler: "findIosDevice"
674
+ },
675
+ {
676
+ method: "POST",
677
+ path: "/ios-devices/in-build",
678
+ handler: "markIosDevicesInBuild"
679
+ },
680
+ {
681
+ method: "GET",
682
+ path: "/ios-devices/account",
683
+ handler: "findIosDeviceAccount"
684
+ },
685
+ {
686
+ method: "POST",
687
+ path: "/ios-devices/account",
688
+ handler: "claimIosDeviceAccount"
689
+ },
690
+ {
691
+ method: "POST",
692
+ path: "/ios-devices/:id/approval",
693
+ handler: "approveIosDevice"
694
+ },
695
+ {
696
+ method: "POST",
697
+ path: "/ios-devices/:id/outcome",
698
+ handler: "recordIosDeviceOutcome"
699
+ },
700
+ {
701
+ method: "PATCH",
702
+ path: "/ios-devices/:id",
703
+ handler: "renameIosDevice"
704
+ },
705
+ {
706
+ method: "DELETE",
707
+ path: "/ios-devices/:id",
708
+ handler: "deleteIosDevice"
471
709
  }
472
710
  ];
473
711
  //#endregion