@hot-updater/azure 1.2.0-rc.27 → 1.2.0-rc.29

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.
@@ -6112,6 +6112,11 @@ const nativeBuilds = defineTable({
6112
6112
  maxLength: 255,
6113
6113
  ascii: true,
6114
6114
  required: false
6115
+ },
6116
+ export_method: {
6117
+ type: "string",
6118
+ maxLength: 16,
6119
+ required: false
6115
6120
  }
6116
6121
  }, {
6117
6122
  key: ["id"],
@@ -6146,6 +6151,92 @@ const nativeBuilds = defineTable({
6146
6151
  }
6147
6152
  }
6148
6153
  });
6154
+ const iosDevices = defineTable({
6155
+ id: {
6156
+ type: "string",
6157
+ maxLength: 36
6158
+ },
6159
+ udid: {
6160
+ type: "string",
6161
+ maxLength: 40,
6162
+ ascii: true,
6163
+ unique: true
6164
+ },
6165
+ name: {
6166
+ type: "string",
6167
+ maxLength: 100
6168
+ },
6169
+ status: {
6170
+ type: "string",
6171
+ maxLength: 16
6172
+ },
6173
+ requested_by: {
6174
+ type: "string",
6175
+ maxLength: 320,
6176
+ required: false
6177
+ },
6178
+ created_at_ms: { type: "integer" },
6179
+ approved_by: {
6180
+ type: "string",
6181
+ maxLength: 320,
6182
+ required: false
6183
+ },
6184
+ approved_at_ms: {
6185
+ type: "integer",
6186
+ required: false
6187
+ },
6188
+ registered_at_ms: {
6189
+ type: "integer",
6190
+ required: false
6191
+ },
6192
+ apple_issuer_id: {
6193
+ type: "string",
6194
+ maxLength: 64,
6195
+ ascii: true,
6196
+ required: false
6197
+ },
6198
+ apple_error: {
6199
+ type: "string",
6200
+ maxLength: 512,
6201
+ required: false
6202
+ },
6203
+ build_id: {
6204
+ type: "string",
6205
+ maxLength: 36,
6206
+ required: false
6207
+ }
6208
+ }, {
6209
+ key: ["id"],
6210
+ indexes: {
6211
+ byStatus: {
6212
+ eq: ["status"],
6213
+ sort: ["id"]
6214
+ },
6215
+ all: {
6216
+ eq: [],
6217
+ sort: ["id"]
6218
+ }
6219
+ }
6220
+ });
6221
+ const iosDeviceAccount = defineTable({
6222
+ id: {
6223
+ type: "string",
6224
+ maxLength: 16,
6225
+ ascii: true
6226
+ },
6227
+ apple_issuer_id: {
6228
+ type: "string",
6229
+ maxLength: 64,
6230
+ ascii: true
6231
+ },
6232
+ claimed_at_ms: { type: "integer" }
6233
+ }, {
6234
+ key: ["id"],
6235
+ indexes: { all: {
6236
+ eq: [],
6237
+ sort: ["id"]
6238
+ } }
6239
+ });
6149
6240
  const coreModule = {
6150
6241
  id: "core",
6151
6242
  schema: {
@@ -6165,7 +6256,9 @@ const coreModule = {
6165
6256
  sort: []
6166
6257
  } }
6167
6258
  }),
6168
- native_builds: nativeBuilds
6259
+ native_builds: nativeBuilds,
6260
+ ios_devices: iosDevices,
6261
+ ios_device_account: iosDeviceAccount
6169
6262
  }
6170
6263
  };
6171
6264
  //#endregion
@@ -8058,7 +8151,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
8058
8151
  };
8059
8152
  //#endregion
8060
8153
  //#region ../../packages/server/dist/version.mjs
8061
- const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.27";
8154
+ const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.29";
8062
8155
  //#endregion
8063
8156
  //#region ../../packages/server/dist/handlerVersionRoutes.mjs
8064
8157
  const createVersionRouteHandlers = (plugins = []) => {
@@ -8791,8 +8884,8 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
8791
8884
  //#endregion
8792
8885
  //#region ../../packages/server/dist/core/reads.mjs
8793
8886
  const PAGE$3 = 500;
8794
- const pick$1 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
8795
- const toBundleRow = pick$1([
8887
+ const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
8888
+ const toBundleRow = pick$2([
8796
8889
  "id",
8797
8890
  "platform",
8798
8891
  "git_commit_hash",
@@ -8801,7 +8894,7 @@ const toBundleRow = pick$1([
8801
8894
  "manifest_file_hash",
8802
8895
  "asset_base_storage_uri"
8803
8896
  ]);
8804
- const toPatchRow = pick$1([
8897
+ const toPatchRow = pick$2([
8805
8898
  "id",
8806
8899
  "bundle_id",
8807
8900
  "base_bundle_id",
@@ -8811,7 +8904,7 @@ const toPatchRow = pick$1([
8811
8904
  "byte_size",
8812
8905
  "order_index"
8813
8906
  ]);
8814
- const toReleaseRow = pick$1([
8907
+ const toReleaseRow = pick$2([
8815
8908
  "id",
8816
8909
  "revision",
8817
8910
  "scope_key",
@@ -8832,7 +8925,7 @@ const toReleaseRow = pick$1([
8832
8925
  "created_at_ms",
8833
8926
  "updated_at_ms"
8834
8927
  ]);
8835
- const toCatalogRow = pick$1([
8928
+ const toCatalogRow = pick$2([
8836
8929
  "scope_key",
8837
8930
  "catalog_id",
8838
8931
  "strategy",
@@ -8847,7 +8940,7 @@ const toCatalogRow = pick$1([
8847
8940
  "is_tombstone",
8848
8941
  "updated_at_ms"
8849
8942
  ]);
8850
- const toChannelRow = pick$1(["id", "name"]);
8943
+ const toChannelRow = pick$2(["id", "name"]);
8851
8944
  const drain$1 = async (read) => {
8852
8945
  const rows = [];
8853
8946
  let cursor;
@@ -8858,7 +8951,14 @@ const drain$1 = async (read) => {
8858
8951
  } while (cursor !== void 0);
8859
8952
  return rows;
8860
8953
  };
8861
- const after = (input) => input.after === void 0 ? {} : { range: (input.order ?? "asc") === "asc" ? { gt: input.after } : { lt: input.after } };
8954
+ const after = (input) => {
8955
+ const asc = (input.order ?? "asc") === "asc";
8956
+ const range = {
8957
+ ...input.after === void 0 ? {} : asc ? { gt: input.after } : { lt: input.after },
8958
+ ...input.through === void 0 ? {} : asc ? { lte: input.through } : { gte: input.through }
8959
+ };
8960
+ return Object.keys(range).length === 0 ? {} : { range };
8961
+ };
8862
8962
  const createCoreReads = (db, storage) => {
8863
8963
  const detail = async (row) => {
8864
8964
  const count = row._refs_bundle_patches_bundle_id ?? 0;
@@ -9049,6 +9149,282 @@ const createCoreReads = (db, storage) => {
9049
9149
  };
9050
9150
  };
9051
9151
  //#endregion
9152
+ //#region ../../packages/server/dist/core/iosDevices.mjs
9153
+ const UDID = /^(?:[0-9a-f]{40}|[0-9a-f]{8}-[0-9a-f]{16})$/iu;
9154
+ const normalizeIosUdid = (value) => {
9155
+ const trimmed = value.trim();
9156
+ return UDID.test(trimmed) ? trimmed.toLowerCase() : null;
9157
+ };
9158
+ const NAME_MAX_LENGTH = 100;
9159
+ const EMAIL_MAX_LENGTH = 320;
9160
+ const ISSUER_MAX_LENGTH = 64;
9161
+ const ACCOUNT_SCAN_PAGE = 200;
9162
+ const ACCOUNT_ROW = "registry";
9163
+ const ERROR_MAX_LENGTH = 512;
9164
+ const STATUSES = [
9165
+ "pending",
9166
+ "approved",
9167
+ "registered"
9168
+ ];
9169
+ const OUTCOMES = [
9170
+ "registered",
9171
+ "refused",
9172
+ "disabled",
9173
+ "missing"
9174
+ ];
9175
+ const IOS_DEVICE_DISABLED_ERROR = "Disabled in the Apple account.";
9176
+ const IOS_DEVICE_MISSING_ERROR = "Gone from the Apple account. Approve it again to register it.";
9177
+ var IosDeviceInputError = class extends TypeError {
9178
+ name = "IosDeviceInputError";
9179
+ };
9180
+ const pick$1 = (row) => ({
9181
+ id: row.id,
9182
+ udid: row.udid,
9183
+ name: row.name,
9184
+ status: row.status,
9185
+ requested_by: row.requested_by ?? null,
9186
+ created_at_ms: row.created_at_ms,
9187
+ approved_by: row.approved_by ?? null,
9188
+ approved_at_ms: row.approved_at_ms ?? null,
9189
+ registered_at_ms: row.registered_at_ms ?? null,
9190
+ apple_issuer_id: row.apple_issuer_id ?? null,
9191
+ apple_error: row.apple_error ?? null,
9192
+ build_id: row.build_id ?? null
9193
+ });
9194
+ const udidOf = (udid) => {
9195
+ const key = typeof udid === "string" ? normalizeIosUdid(udid) : null;
9196
+ if (key === null) throw new IosDeviceInputError("Invalid iOS device: udid must be 40 hex digits, or 8 and 16 joined by a hyphen.");
9197
+ return key;
9198
+ };
9199
+ const nameOf = (name) => {
9200
+ const trimmed = typeof name === "string" ? name.trim() : "";
9201
+ if (trimmed.length === 0 || trimmed.length > NAME_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: name must be 1 to ${NAME_MAX_LENGTH} characters.`);
9202
+ return trimmed;
9203
+ };
9204
+ const personOf = (value, field) => {
9205
+ if (value === null) return null;
9206
+ const email = typeof value === "string" ? value.trim().toLowerCase() : "";
9207
+ if (email.length === 0 || email.length > EMAIL_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: ${field} must be an email of at most ${EMAIL_MAX_LENGTH} characters, or null.`);
9208
+ return email;
9209
+ };
9210
+ const errorText = (text) => {
9211
+ const line = text.replace(/\s+/gu, " ").trim();
9212
+ return line.length > ERROR_MAX_LENGTH ? `${line.slice(0, 511)}…` : line;
9213
+ };
9214
+ const createIosDeviceApi = (db, { now = Date.now } = {}) => {
9215
+ const findIosDevice = async (udid) => {
9216
+ const key = normalizeIosUdid(udid);
9217
+ if (key === null) return null;
9218
+ const row = await db.findOne("ios_devices", { udid: key });
9219
+ return row === null ? null : pick$1(row);
9220
+ };
9221
+ const accountOfRows = async () => {
9222
+ let earliest = null;
9223
+ for (let after;;) {
9224
+ const { rows } = await db.findMany("ios_devices", {
9225
+ index: "all",
9226
+ where: {},
9227
+ order: "asc",
9228
+ limit: ACCOUNT_SCAN_PAGE,
9229
+ ...after === void 0 ? {} : { range: { gt: after } }
9230
+ });
9231
+ for (const row of rows.map(pick$1)) {
9232
+ if (row.apple_issuer_id === null) continue;
9233
+ if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
9234
+ }
9235
+ if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
9236
+ after = rows.at(-1).id;
9237
+ }
9238
+ };
9239
+ return {
9240
+ async listIosDevices(input) {
9241
+ if (input.status !== void 0 && !STATUSES.includes(input.status)) throw new IosDeviceInputError(`Invalid iOS device status: ${String(input.status)}. Expected ${STATUSES.join(", ")}.`);
9242
+ const page = {
9243
+ order: input.order ?? "asc",
9244
+ limit: input.limit,
9245
+ ...after(input)
9246
+ };
9247
+ const { rows } = input.status === void 0 ? await db.findMany("ios_devices", {
9248
+ index: "all",
9249
+ where: {},
9250
+ ...page
9251
+ }) : await db.findMany("ios_devices", {
9252
+ index: "byStatus",
9253
+ where: { status: input.status },
9254
+ ...page
9255
+ });
9256
+ return rows.map(pick$1);
9257
+ },
9258
+ findIosDevice,
9259
+ async requestIosDevice(input) {
9260
+ const udid = udidOf(input.udid);
9261
+ const name = nameOf(input.name);
9262
+ const requestedBy = personOf(input.requestedBy, "requestedBy");
9263
+ const existing = await db.findOne("ios_devices", { udid });
9264
+ if (existing !== null) return {
9265
+ device: pick$1(existing),
9266
+ created: false
9267
+ };
9268
+ const device = {
9269
+ id: createUUIDv7(),
9270
+ udid,
9271
+ name,
9272
+ status: "pending",
9273
+ requested_by: requestedBy,
9274
+ created_at_ms: now(),
9275
+ approved_by: null,
9276
+ approved_at_ms: null,
9277
+ registered_at_ms: null,
9278
+ apple_issuer_id: null,
9279
+ apple_error: null,
9280
+ build_id: null
9281
+ };
9282
+ try {
9283
+ await db.transaction(async (tx) => {
9284
+ tx.create("ios_devices", device);
9285
+ });
9286
+ } catch (error) {
9287
+ if (error instanceof DatabaseConstraintError && error.reason === "unique") {
9288
+ const winner = await db.findOne("ios_devices", { udid });
9289
+ if (winner !== null) return {
9290
+ device: pick$1(winner),
9291
+ created: false
9292
+ };
9293
+ }
9294
+ throw error;
9295
+ }
9296
+ return {
9297
+ device,
9298
+ created: true
9299
+ };
9300
+ },
9301
+ async approveIosDevice(id, input) {
9302
+ const name = input.name === void 0 ? void 0 : nameOf(input.name);
9303
+ const approvedBy = personOf(input.approvedBy, "approvedBy");
9304
+ return db.transaction(async (tx) => {
9305
+ const row = await tx.findOne("ios_devices", { id });
9306
+ if (row === null) return null;
9307
+ const device = pick$1(row);
9308
+ const set = {
9309
+ ...name === void 0 || name === device.name ? {} : { name },
9310
+ ...device.status === "pending" ? {
9311
+ status: "approved",
9312
+ approved_by: approvedBy,
9313
+ approved_at_ms: now()
9314
+ } : {}
9315
+ };
9316
+ if (Object.keys(set).length === 0) return device;
9317
+ tx.update("ios_devices", row, set);
9318
+ return {
9319
+ ...device,
9320
+ ...set
9321
+ };
9322
+ });
9323
+ },
9324
+ async renameIosDevice(id, input) {
9325
+ const name = nameOf(input);
9326
+ return db.transaction(async (tx) => {
9327
+ const row = await tx.findOne("ios_devices", { id });
9328
+ if (row === null) return null;
9329
+ const device = pick$1(row);
9330
+ if (device.name === name) return device;
9331
+ tx.update("ios_devices", row, { name });
9332
+ return {
9333
+ ...device,
9334
+ name
9335
+ };
9336
+ });
9337
+ },
9338
+ async recordIosDeviceOutcome({ id, seen, issuerId, outcome, reason }) {
9339
+ if (!OUTCOMES.includes(outcome)) throw new IosDeviceInputError(`Invalid iOS device outcome: ${String(outcome)}. Expected ${OUTCOMES.join(", ")}.`);
9340
+ if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device outcome: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
9341
+ return db.transaction(async (tx) => {
9342
+ const row = await tx.findOne("ios_devices", { id });
9343
+ if (row === null) return null;
9344
+ const device = pick$1(row);
9345
+ if (device.status !== seen.status || device.approved_at_ms !== seen.approvedAtMs || device.apple_issuer_id !== null && device.apple_issuer_id !== issuerId) return null;
9346
+ let set;
9347
+ switch (outcome) {
9348
+ case "registered":
9349
+ if (device.status === "pending") return null;
9350
+ set = {
9351
+ status: "registered",
9352
+ registered_at_ms: device.registered_at_ms ?? now(),
9353
+ apple_issuer_id: issuerId,
9354
+ apple_error: null
9355
+ };
9356
+ break;
9357
+ case "refused":
9358
+ if (device.status !== "approved") return null;
9359
+ set = { apple_error: errorText(reason === void 0 || reason.trim() === "" ? "Apple refused it." : reason) };
9360
+ break;
9361
+ case "disabled":
9362
+ if (device.status === "pending") return null;
9363
+ set = { apple_error: IOS_DEVICE_DISABLED_ERROR };
9364
+ break;
9365
+ case "missing":
9366
+ if (device.status !== "registered") return null;
9367
+ set = {
9368
+ status: "pending",
9369
+ approved_by: null,
9370
+ approved_at_ms: null,
9371
+ apple_error: IOS_DEVICE_MISSING_ERROR
9372
+ };
9373
+ }
9374
+ if (Object.entries(set).some(([column, value]) => device[column] !== (value ?? null))) tx.update("ios_devices", row, set);
9375
+ return {
9376
+ ...device,
9377
+ ...set
9378
+ };
9379
+ });
9380
+ },
9381
+ async markIosDevicesInBuild({ buildId, ids }) {
9382
+ for (const id of new Set(ids)) await db.transaction(async (tx) => {
9383
+ const row = await tx.findOne("ios_devices", { id });
9384
+ if (row === null || typeof row.build_id === "string" && row.build_id >= buildId) return;
9385
+ tx.update("ios_devices", row, { build_id: buildId });
9386
+ });
9387
+ },
9388
+ async claimIosDeviceAccount(issuerId) {
9389
+ if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device account: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
9390
+ const answer = (held) => ({
9391
+ issuerId: held,
9392
+ claimed: held === issuerId
9393
+ });
9394
+ const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
9395
+ if (existing !== null) return answer(existing.apple_issuer_id);
9396
+ const holder = await accountOfRows() ?? issuerId;
9397
+ try {
9398
+ await db.transaction(async (tx) => {
9399
+ tx.create("ios_device_account", {
9400
+ id: ACCOUNT_ROW,
9401
+ apple_issuer_id: holder,
9402
+ claimed_at_ms: now()
9403
+ });
9404
+ });
9405
+ return answer(holder);
9406
+ } catch (error) {
9407
+ if (error instanceof DatabaseConstraintError && (error.reason === "exists" || error.reason === "unique")) {
9408
+ const winner = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
9409
+ if (winner !== null) return answer(winner.apple_issuer_id);
9410
+ }
9411
+ throw error;
9412
+ }
9413
+ },
9414
+ async deleteIosDevice(id, only) {
9415
+ const requestedBy = only?.requestedBy === void 0 ? void 0 : personOf(only.requestedBy, "requestedBy");
9416
+ return db.transaction(async (tx) => {
9417
+ const row = await tx.findOne("ios_devices", { id });
9418
+ if (row === null) return null;
9419
+ const device = pick$1(row);
9420
+ if (only?.status !== void 0 && device.status !== only.status || requestedBy !== void 0 && device.requested_by !== requestedBy) return null;
9421
+ await tx.delete("ios_devices", row);
9422
+ return device;
9423
+ });
9424
+ }
9425
+ };
9426
+ };
9427
+ //#endregion
9052
9428
  //#region ../../packages/server/dist/core/nativeBuildDestinations.mjs
9053
9429
  const NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
9054
9430
  android: [
@@ -9182,8 +9558,15 @@ const pick = (row) => ({
9182
9558
  submitted_version: row.submitted_version ?? null,
9183
9559
  is_store_build: row.is_store_build === true,
9184
9560
  is_sandbox: row.is_sandbox === true,
9185
- sandbox_url_scheme: row.sandbox_url_scheme ?? null
9561
+ sandbox_url_scheme: row.sandbox_url_scheme ?? null,
9562
+ export_method: row.export_method ?? null
9186
9563
  });
9564
+ const EXPORT_METHODS = /* @__PURE__ */ new Set([
9565
+ "app-store",
9566
+ "ad-hoc",
9567
+ "development",
9568
+ "enterprise"
9569
+ ]);
9187
9570
  const SANDBOX_CHANNEL_PREFIX = "sandbox-";
9188
9571
  const OLDER_BUILDS_PAGE = 20;
9189
9572
  const MARK_ATTEMPTS = 8;
@@ -9210,7 +9593,7 @@ const nativeBuildScopeKey = (scope) => {
9210
9593
  return scopeKey;
9211
9594
  };
9212
9595
  const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
9213
- const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, artifact }) => {
9596
+ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, artifact }) => {
9214
9597
  if (!isUUIDv7(id)) return "id must be a UUIDv7";
9215
9598
  if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
9216
9599
  if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
@@ -9229,6 +9612,10 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
9229
9612
  if (buildNumber !== void 0 && buildNumber !== null && (buildNumber.trim().length === 0 || buildNumber.length > BUILD_NUMBER_MAX_LENGTH)) return `buildNumber must be the artifact's build number, up to ${BUILD_NUMBER_MAX_LENGTH} characters, or null`;
9230
9613
  const kinds = ARTIFACT_KINDS[platform];
9231
9614
  if (!kinds.includes(artifact.kind)) return `artifact.kind of an ${platform} build must be ${kinds.join(" or ")}`;
9615
+ if (exportMethod !== void 0 && exportMethod !== null) {
9616
+ if (artifact.kind !== "ipa") return "exportMethod is an .ipa's, and this artifact isn't one";
9617
+ if (!EXPORT_METHODS.has(exportMethod)) return `exportMethod must be ${[...EXPORT_METHODS].join(", ")}, or null`;
9618
+ }
9232
9619
  if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
9233
9620
  return null;
9234
9621
  };
@@ -9259,7 +9646,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
9259
9646
  submitted_version: null,
9260
9647
  is_store_build: false,
9261
9648
  is_sandbox: registration.isSandbox === true,
9262
- sandbox_url_scheme: registration.sandboxUrlScheme ?? null
9649
+ sandbox_url_scheme: registration.sandboxUrlScheme ?? null,
9650
+ export_method: registration.exportMethod ?? null
9263
9651
  };
9264
9652
  for (let attempt = 1;; attempt += 1) {
9265
9653
  await insertChannel(db, {
@@ -9973,6 +10361,7 @@ const createCoreApi = (db, storage, options = {}) => {
9973
10361
  ...reads,
9974
10362
  ...createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
9975
10363
  ...createNativeBuildApi(db, options),
10364
+ ...createIosDeviceApi(db, options),
9976
10365
  ready: async () => {
9977
10366
  await reads.listReleaseCatalogs({ limit: 1 });
9978
10367
  }
@@ -10182,10 +10571,12 @@ const keyset = (url, maxValue = LIMITS.maxValue) => {
10182
10571
  const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
10183
10572
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
10184
10573
  const cursor = url.searchParams.get("cursor");
10574
+ const through = url.searchParams.get("through");
10185
10575
  return {
10186
10576
  order,
10187
10577
  limit,
10188
- ...cursor === null ? {} : { after: cursor }
10578
+ ...cursor === null ? {} : { after: cursor },
10579
+ ...through === null ? {} : { through }
10189
10580
  };
10190
10581
  };
10191
10582
  const page = (rows, { limit }, keyOf, extra = {}) => json$2({
@@ -10292,11 +10683,11 @@ const refusingInvalid = async (operation) => {
10292
10683
  try {
10293
10684
  return await operation();
10294
10685
  } catch (error) {
10295
- if (error instanceof NativeBuildInputError) throw new HandlerBadRequestError(error.message);
10686
+ if (error instanceof NativeBuildInputError || error instanceof IosDeviceInputError) throw new HandlerBadRequestError(error.message);
10296
10687
  throw error;
10297
10688
  }
10298
10689
  };
10299
- const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
10690
+ const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && (value.exportMethod === void 0 || isTextOrNull$1(value.exportMethod)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
10300
10691
  const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
10301
10692
  const createAdminRouteHandlers = () => ({
10302
10693
  listBundles: onCore(async (core, request) => {
@@ -10454,6 +10845,81 @@ const createAdminRouteHandlers = () => ({
10454
10845
  return json$2({ data: await refusingInvalid(() => core.markNativeBuild(requireRouteParam(params, "id"), mark)) });
10455
10846
  }),
10456
10847
  deleteNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.deleteNativeBuild(requireRouteParam(params, "id")) })),
10848
+ listIosDevices: onCore(async (core, request) => {
10849
+ const url = new URL(request.url);
10850
+ const input = keyset(url);
10851
+ const status = url.searchParams.get("status");
10852
+ return page(await refusingInvalid(() => core.listIosDevices({
10853
+ ...input,
10854
+ ...status === null ? {} : { status }
10855
+ })), input, ({ id }) => id);
10856
+ }),
10857
+ findIosDevice: onCore(async (core, _request, params) => json$2({ data: await core.findIosDevice(requireRouteParam(params, "udid")) })),
10858
+ requestIosDevice: onCore(async (core, request) => {
10859
+ const input = await body$1(request);
10860
+ if (!isText$2(input.udid) || !isText$2(input.name) || !isTextOrNull$1(input.requestedBy)) throw new HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
10861
+ const device = {
10862
+ udid: input.udid,
10863
+ name: input.name,
10864
+ requestedBy: input.requestedBy
10865
+ };
10866
+ return json$2({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
10867
+ }),
10868
+ approveIosDevice: onCore(async (core, request, params) => {
10869
+ const input = await body$1(request);
10870
+ if (!isTextOrNull$1(input.approvedBy) || input.name !== void 0 && !isText$2(input.name)) throw new HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
10871
+ const approval = {
10872
+ approvedBy: input.approvedBy,
10873
+ ...input.name === void 0 ? {} : { name: input.name }
10874
+ };
10875
+ return json$2({ data: await refusingInvalid(() => core.approveIosDevice(requireRouteParam(params, "id"), approval)) });
10876
+ }),
10877
+ renameIosDevice: onCore(async (core, request, params) => {
10878
+ const input = await body$1(request);
10879
+ if (!isText$2(input.name)) throw new HandlerBadRequestError("An iOS device's new name is required.");
10880
+ const name = input.name;
10881
+ return json$2({ data: await refusingInvalid(() => core.renameIosDevice(requireRouteParam(params, "id"), name)) });
10882
+ }),
10883
+ recordIosDeviceOutcome: onCore(async (core, request, params) => {
10884
+ const input = await body$1(request);
10885
+ const seen = input.seen;
10886
+ if (!isRecord$5(seen) || typeof seen.status !== "string" || !(seen.approvedAtMs === null || Number.isSafeInteger(seen.approvedAtMs)) || !isText$2(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.");
10887
+ const outcome = {
10888
+ id: requireRouteParam(params, "id"),
10889
+ seen: {
10890
+ status: seen.status,
10891
+ approvedAtMs: seen.approvedAtMs
10892
+ },
10893
+ issuerId: input.issuerId,
10894
+ outcome: input.outcome,
10895
+ ...input.reason === void 0 ? {} : { reason: input.reason }
10896
+ };
10897
+ return json$2({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
10898
+ }),
10899
+ claimIosDeviceAccount: onCore(async (core, request) => {
10900
+ const { issuerId } = await body$1(request);
10901
+ if (!isText$2(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
10902
+ return json$2({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
10903
+ }),
10904
+ markIosDevicesInBuild: onCore(async (core, request) => {
10905
+ const { buildId, ids } = await body$1(request);
10906
+ if (!isText$2(buildId) || !Array.isArray(ids) || !ids.every((id) => isText$2(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
10907
+ await core.markIosDevicesInBuild({
10908
+ buildId,
10909
+ ids
10910
+ });
10911
+ return noContent();
10912
+ }),
10913
+ deleteIosDevice: onCore(async (core, request, params) => {
10914
+ const url = new URL(request.url);
10915
+ const status = url.searchParams.get("status");
10916
+ const requestedBy = url.searchParams.get("requestedBy");
10917
+ const only = {
10918
+ ...status === null ? {} : { status },
10919
+ ...requestedBy === null ? {} : { requestedBy }
10920
+ };
10921
+ return json$2({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(requireRouteParam(params, "id")) : core.deleteIosDevice(requireRouteParam(params, "id"), only)) });
10922
+ }),
10457
10923
  deleteBundles: onCore(async (core, request) => {
10458
10924
  const { ids } = await body$1(request);
10459
10925
  if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new HandlerBadRequestError("Bundle deletion needs ids");
@@ -10606,6 +11072,51 @@ const ADMIN_ROUTES = [
10606
11072
  method: "DELETE",
10607
11073
  path: "/native-builds/:id",
10608
11074
  handler: "deleteNativeBuild"
11075
+ },
11076
+ {
11077
+ method: "GET",
11078
+ path: "/ios-devices",
11079
+ handler: "listIosDevices"
11080
+ },
11081
+ {
11082
+ method: "POST",
11083
+ path: "/ios-devices",
11084
+ handler: "requestIosDevice"
11085
+ },
11086
+ {
11087
+ method: "GET",
11088
+ path: "/ios-devices/udid/:udid",
11089
+ handler: "findIosDevice"
11090
+ },
11091
+ {
11092
+ method: "POST",
11093
+ path: "/ios-devices/in-build",
11094
+ handler: "markIosDevicesInBuild"
11095
+ },
11096
+ {
11097
+ method: "POST",
11098
+ path: "/ios-devices/account",
11099
+ handler: "claimIosDeviceAccount"
11100
+ },
11101
+ {
11102
+ method: "POST",
11103
+ path: "/ios-devices/:id/approval",
11104
+ handler: "approveIosDevice"
11105
+ },
11106
+ {
11107
+ method: "POST",
11108
+ path: "/ios-devices/:id/outcome",
11109
+ handler: "recordIosDeviceOutcome"
11110
+ },
11111
+ {
11112
+ method: "PATCH",
11113
+ path: "/ios-devices/:id",
11114
+ handler: "renameIosDevice"
11115
+ },
11116
+ {
11117
+ method: "DELETE",
11118
+ path: "/ios-devices/:id",
11119
+ handler: "deleteIosDevice"
10609
11120
  }
10610
11121
  ];
10611
11122
  //#endregion
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.27",
4
+ "version": "1.2.0-rc.29",
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.27",
48
- "@hot-updater/plugin-core": "1.2.0-rc.27",
49
- "@hot-updater/protocol": "1.2.0-rc.27",
50
- "@hot-updater/server": "1.2.0-rc.27"
47
+ "@hot-updater/cli-tools": "1.2.0-rc.29",
48
+ "@hot-updater/protocol": "1.2.0-rc.29",
49
+ "@hot-updater/server": "1.2.0-rc.29",
50
+ "@hot-updater/plugin-core": "1.2.0-rc.29"
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.27"
58
+ "@hot-updater/test-utils": "1.2.0-rc.29"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsdown",