@hot-updater/server 1.2.0-rc.6 → 1.2.0-rc.61

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 (53) 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 +48 -1
  19. package/dist/core/api.d.mts +48 -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/labels.cjs +325 -0
  24. package/dist/core/labels.mjs +318 -0
  25. package/dist/core/nativeBuildDestinations.cjs +13 -0
  26. package/dist/core/nativeBuildDestinations.mjs +13 -0
  27. package/dist/core/nativeBuilds.cjs +291 -22
  28. package/dist/core/nativeBuilds.mjs +291 -23
  29. package/dist/core/operations.cjs +45 -24
  30. package/dist/core/operations.mjs +48 -27
  31. package/dist/core/reads.cjs +69 -5
  32. package/dist/core/reads.mjs +70 -6
  33. package/dist/core/releases.cjs +138 -38
  34. package/dist/core/releases.mjs +138 -41
  35. package/dist/core/writes.cjs +14 -2
  36. package/dist/core/writes.mjs +14 -2
  37. package/dist/createHotUpdaterCore.d.cts +2 -4
  38. package/dist/createHotUpdaterCore.d.mts +2 -4
  39. package/dist/db/engineDrizzleSchema.cjs +21 -5
  40. package/dist/db/engineDrizzleSchema.mjs +21 -6
  41. package/dist/db/enginePrismaSchema.cjs +6 -14
  42. package/dist/db/enginePrismaSchema.mjs +7 -15
  43. package/dist/db/releaseCatalog.cjs +13 -4
  44. package/dist/db/releaseCatalog.mjs +12 -5
  45. package/dist/handler.cjs +2 -1
  46. package/dist/handler.mjs +2 -1
  47. package/dist/handlerAdminRoutes.cjs +288 -16
  48. package/dist/handlerAdminRoutes.mjs +289 -17
  49. package/dist/handlerReleaseCatalogRoutes.cjs +43 -27
  50. package/dist/handlerReleaseCatalogRoutes.mjs +43 -27
  51. package/dist/package.cjs +1 -1
  52. package/dist/package.mjs +1 -1
  53. package/package.json +7 -14
package/dist/handler.mjs CHANGED
@@ -42,7 +42,8 @@ const createRequestHandler = ({ api, clientPolicy, privateResponses = false, rou
42
42
  let authenticated;
43
43
  try {
44
44
  authenticated = await clientPolicy.authenticate(request);
45
- } catch {
45
+ } catch (error) {
46
+ console.error("Hot Updater client authentication error:", error);
46
47
  return errorResponse("Service unavailable", 503);
47
48
  }
48
49
  if (!authenticated) return errorResponse("Unauthorized", 401);
@@ -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) => {
@@ -249,15 +320,40 @@ const createAdminRouteHandlers = () => ({
249
320
  return row === null ? notFound() : json({ data: row });
250
321
  }),
251
322
  rebuildReleaseCatalog: onCore(async (core, _request, params) => json({ data: await core.rebuildReleaseCatalog(scopeKeyOf(params)) })),
323
+ /**
324
+ * The release a label names, or `null`: never 404, which tells a client
325
+ * the server has no such route.
326
+ */
327
+ getReleaseByLabel: onCore(async (core, request) => {
328
+ const url = new URL(request.url);
329
+ const channel = url.searchParams.get("channel");
330
+ const platform = platformOf(url);
331
+ const label = Number(url.searchParams.get("label"));
332
+ if (channel === null || channel.length === 0 || platform === void 0 || !Number.isSafeInteger(label) || label < 1) throw new require_handlerErrors.HandlerBadRequestError("A release label lookup takes channel, platform, and a label of 1 or more.");
333
+ return json({ data: await core.getReleaseByLabel({
334
+ channel,
335
+ platform,
336
+ label
337
+ }) });
338
+ }),
339
+ fillReleaseLabels: onCore(async (core, request) => {
340
+ const body = await request.json().catch(() => ({}));
341
+ const input = body !== null && typeof body === "object" ? body : {};
342
+ return json({ data: await core.fillReleaseLabels({
343
+ dryRun: input.dryRun === true,
344
+ catalogs: input.catalogs !== false
345
+ }) });
346
+ }),
252
347
  updateBundle: onCore(async (core, request, params) => {
253
348
  const bundleId = require_handlerParameters.requireRouteParam(params, "id");
254
- await core.updateBundle(bundleId, bundleUpdateOf(await request.json(), bundleId));
349
+ const update = bundleUpdateOf(await request.json(), bundleId);
350
+ await refusingInvalid(() => core.updateBundle(bundleId, update));
255
351
  return noContent();
256
352
  }),
257
353
  countBundles: onCore(async (core, request) => json({ data: await core.countBundles(platformOf(new URL(request.url))) })),
258
354
  countBundleChildren: onCore(async (core, request) => {
259
355
  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.");
356
+ 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
357
  return json({ data: await core.countBundleChildren(ids) });
262
358
  }),
263
359
  listBundleChildren: onCore(async (core, request, params) => {
@@ -275,7 +371,7 @@ const createAdminRouteHandlers = () => ({
275
371
  deployReleases: onCore(async (core, request) => {
276
372
  const { deployments } = await body(request);
277
373
  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);
374
+ return json({ data: await refusingInvalid(() => core.deploy(deployments)) }, 201);
279
375
  }),
280
376
  promoteRelease: onCore(async (core, request, params) => {
281
377
  const input = await body(request);
@@ -298,9 +394,22 @@ const createAdminRouteHandlers = () => ({
298
394
  const url = new URL(request.url);
299
395
  const scope = nativeBuildScopeOf(url);
300
396
  const buildKey = url.searchParams.get("buildKey");
301
- return json({ data: await refusingInvalid(() => buildKey === null ? core.findNativeBuild(scope) : core.findNativeBuild(scope, { buildKey })) });
397
+ const builtInOlderThan = url.searchParams.get("builtInOlderThan");
398
+ const kind = url.searchParams.get("kind");
399
+ const options = {
400
+ ...buildKey === null ? {} : { buildKey },
401
+ ...url.searchParams.get("storeBuild") === "true" ? { storeBuild: true } : {},
402
+ ...builtInOlderThan === null ? {} : { builtInOlderThan },
403
+ ...kind === null ? {} : { artifactKind: kind }
404
+ };
405
+ return json({ data: await refusingInvalid(() => Object.keys(options).length === 0 ? core.findNativeBuild(scope) : core.findNativeBuild(scope, options)) });
406
+ }),
407
+ findNativeBuildSibling: onCore(async (core, _request, params) => {
408
+ const build = await core.getNativeBuild(require_handlerParameters.requireRouteParam(params, "id"));
409
+ return json({ data: build === null ? null : await core.findNativeBuildSibling(build) });
302
410
  }),
303
411
  getNativeBuild: onCore(async (core, _request, params) => json({ data: await core.getNativeBuild(require_handlerParameters.requireRouteParam(params, "id")) })),
412
+ findNativeBuildByBuiltInBundle: onCore(async (core, _request, params) => json({ data: await core.findNativeBuildByBuiltInBundle(require_handlerParameters.requireRouteParam(params, "bundleId")) })),
304
413
  listNativeBuilds: onCore(async (core, request) => {
305
414
  const url = new URL(request.url);
306
415
  const input = keyset(url);
@@ -312,14 +421,97 @@ const createAdminRouteHandlers = () => ({
312
421
  }),
313
422
  recordNativeBuildSubmission: onCore(async (core, request, params) => {
314
423
  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.");
424
+ 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
425
  const submission = {
317
426
  destination: input.destination,
318
427
  version: input.version
319
428
  };
320
429
  return json({ data: await refusingInvalid(() => core.recordNativeBuildSubmission(require_handlerParameters.requireRouteParam(params, "id"), submission)) });
321
430
  }),
431
+ markNativeBuild: onCore(async (core, request, params) => {
432
+ const input = await body(request);
433
+ if (!isRecord(input) || typeof input.storeBuild !== "boolean") throw new require_handlerErrors.HandlerBadRequestError("A native build's store build mark needs storeBuild, true or false.");
434
+ const mark = { storeBuild: input.storeBuild };
435
+ return json({ data: await refusingInvalid(() => core.markNativeBuild(require_handlerParameters.requireRouteParam(params, "id"), mark)) });
436
+ }),
322
437
  deleteNativeBuild: onCore(async (core, _request, params) => json({ data: await core.deleteNativeBuild(require_handlerParameters.requireRouteParam(params, "id")) })),
438
+ listIosDevices: onCore(async (core, request) => {
439
+ const url = new URL(request.url);
440
+ const input = keyset(url);
441
+ const status = url.searchParams.get("status");
442
+ return page(await refusingInvalid(() => core.listIosDevices({
443
+ ...input,
444
+ ...status === null ? {} : { status }
445
+ })), input, ({ id }) => id);
446
+ }),
447
+ findIosDevice: onCore(async (core, _request, params) => json({ data: await core.findIosDevice(require_handlerParameters.requireRouteParam(params, "udid")) })),
448
+ requestIosDevice: onCore(async (core, request) => {
449
+ const input = await body(request);
450
+ 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.");
451
+ const device = {
452
+ udid: input.udid,
453
+ name: input.name,
454
+ requestedBy: input.requestedBy
455
+ };
456
+ return json({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
457
+ }),
458
+ approveIosDevice: onCore(async (core, request, params) => {
459
+ const input = await body(request);
460
+ 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.");
461
+ const approval = {
462
+ approvedBy: input.approvedBy,
463
+ ...input.name === void 0 ? {} : { name: input.name }
464
+ };
465
+ return json({ data: await refusingInvalid(() => core.approveIosDevice(require_handlerParameters.requireRouteParam(params, "id"), approval)) });
466
+ }),
467
+ renameIosDevice: onCore(async (core, request, params) => {
468
+ const input = await body(request);
469
+ if (!isText(input.name)) throw new require_handlerErrors.HandlerBadRequestError("An iOS device's new name is required.");
470
+ const name = input.name;
471
+ return json({ data: await refusingInvalid(() => core.renameIosDevice(require_handlerParameters.requireRouteParam(params, "id"), name)) });
472
+ }),
473
+ recordIosDeviceOutcome: onCore(async (core, request, params) => {
474
+ const input = await body(request);
475
+ const seen = input.seen;
476
+ 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.");
477
+ const outcome = {
478
+ id: require_handlerParameters.requireRouteParam(params, "id"),
479
+ seen: {
480
+ status: seen.status,
481
+ approvedAtMs: seen.approvedAtMs
482
+ },
483
+ issuerId: input.issuerId,
484
+ outcome: input.outcome,
485
+ ...input.reason === void 0 ? {} : { reason: input.reason }
486
+ };
487
+ return json({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
488
+ }),
489
+ claimIosDeviceAccount: onCore(async (core, request) => {
490
+ const { issuerId } = await body(request);
491
+ if (!isText(issuerId)) throw new require_handlerErrors.HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
492
+ return json({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
493
+ }),
494
+ findIosDeviceAccount: onCore(async (core) => json({ data: await core.findIosDeviceAccount() })),
495
+ markIosDevicesInBuild: onCore(async (core, request) => {
496
+ const { buildId, ids } = await body(request);
497
+ 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.");
498
+ if (ids.length > MAX_IDS) throw new require_handlerErrors.HandlerBadRequestError(`Marking iOS devices in a build takes at most ${MAX_IDS} ids a request.`);
499
+ await core.markIosDevicesInBuild({
500
+ buildId,
501
+ ids
502
+ });
503
+ return noContent();
504
+ }),
505
+ deleteIosDevice: onCore(async (core, request, params) => {
506
+ const url = new URL(request.url);
507
+ const status = url.searchParams.get("status");
508
+ const requestedBy = url.searchParams.get("requestedBy");
509
+ const only = {
510
+ ...status === null ? {} : { status },
511
+ ...requestedBy === null ? {} : { requestedBy }
512
+ };
513
+ 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)) });
514
+ }),
323
515
  deleteBundles: onCore(async (core, request) => {
324
516
  const { ids } = await body(request);
325
517
  if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new require_handlerErrors.HandlerBadRequestError("Bundle deletion needs ids");
@@ -374,6 +566,21 @@ const ADMIN_ROUTES = [
374
566
  path: "/release-catalogs",
375
567
  handler: "listReleaseCatalogs"
376
568
  },
569
+ {
570
+ method: "GET",
571
+ path: "/release-scopes",
572
+ handler: "listReleaseScopeKeys"
573
+ },
574
+ {
575
+ method: "GET",
576
+ path: "/release-labels",
577
+ handler: "getReleaseByLabel"
578
+ },
579
+ {
580
+ method: "POST",
581
+ path: "/release-labels/fill",
582
+ handler: "fillReleaseLabels"
583
+ },
377
584
  {
378
585
  method: "POST",
379
586
  path: "/release-catalogs/:scopeKey/rebuild",
@@ -449,6 +656,16 @@ const ADMIN_ROUTES = [
449
656
  path: "/native-builds/latest",
450
657
  handler: "findNativeBuild"
451
658
  },
659
+ {
660
+ method: "GET",
661
+ path: "/native-builds/built-in/:bundleId",
662
+ handler: "findNativeBuildByBuiltInBundle"
663
+ },
664
+ {
665
+ method: "GET",
666
+ path: "/native-builds/:id/sibling",
667
+ handler: "findNativeBuildSibling"
668
+ },
452
669
  {
453
670
  method: "GET",
454
671
  path: "/native-builds/:id",
@@ -464,10 +681,65 @@ const ADMIN_ROUTES = [
464
681
  path: "/native-builds/:id/submission",
465
682
  handler: "recordNativeBuildSubmission"
466
683
  },
684
+ {
685
+ method: "POST",
686
+ path: "/native-builds/:id/store-build",
687
+ handler: "markNativeBuild"
688
+ },
467
689
  {
468
690
  method: "DELETE",
469
691
  path: "/native-builds/:id",
470
692
  handler: "deleteNativeBuild"
693
+ },
694
+ {
695
+ method: "GET",
696
+ path: "/ios-devices",
697
+ handler: "listIosDevices"
698
+ },
699
+ {
700
+ method: "POST",
701
+ path: "/ios-devices",
702
+ handler: "requestIosDevice"
703
+ },
704
+ {
705
+ method: "GET",
706
+ path: "/ios-devices/udid/:udid",
707
+ handler: "findIosDevice"
708
+ },
709
+ {
710
+ method: "POST",
711
+ path: "/ios-devices/in-build",
712
+ handler: "markIosDevicesInBuild"
713
+ },
714
+ {
715
+ method: "GET",
716
+ path: "/ios-devices/account",
717
+ handler: "findIosDeviceAccount"
718
+ },
719
+ {
720
+ method: "POST",
721
+ path: "/ios-devices/account",
722
+ handler: "claimIosDeviceAccount"
723
+ },
724
+ {
725
+ method: "POST",
726
+ path: "/ios-devices/:id/approval",
727
+ handler: "approveIosDevice"
728
+ },
729
+ {
730
+ method: "POST",
731
+ path: "/ios-devices/:id/outcome",
732
+ handler: "recordIosDeviceOutcome"
733
+ },
734
+ {
735
+ method: "PATCH",
736
+ path: "/ios-devices/:id",
737
+ handler: "renameIosDevice"
738
+ },
739
+ {
740
+ method: "DELETE",
741
+ path: "/ios-devices/:id",
742
+ handler: "deleteIosDevice"
471
743
  }
472
744
  ];
473
745
  //#endregion