@hot-updater/plugin-core 1.2.0-rc.4 → 1.2.0-rc.41

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 (41) hide show
  1. package/dist/coreApi.d.cts +204 -9
  2. package/dist/coreApi.d.mts +204 -9
  3. package/dist/engine/core/schema.cjs +171 -3
  4. package/dist/engine/core/schema.d.cts +115 -1
  5. package/dist/engine/core/schema.d.mts +115 -1
  6. package/dist/engine/core/schema.mjs +171 -3
  7. package/dist/engine/createEngine.cjs +1 -2
  8. package/dist/engine/createEngine.d.cts +1 -6
  9. package/dist/engine/createEngine.d.mts +1 -6
  10. package/dist/engine/createEngine.mjs +1 -2
  11. package/dist/engine/database/aggregateBatching.cjs +24 -116
  12. package/dist/engine/database/aggregateBatching.mjs +24 -116
  13. package/dist/engine/database/database.cjs +1 -4
  14. package/dist/engine/database/database.mjs +1 -4
  15. package/dist/engine/database/resolveSchema.cjs +6 -3
  16. package/dist/engine/database/resolveSchema.mjs +6 -3
  17. package/dist/index.cjs +1 -7
  18. package/dist/index.d.cts +5 -6
  19. package/dist/index.d.mts +5 -6
  20. package/dist/index.mjs +2 -3
  21. package/dist/serverPlugin/definitions.d.cts +4 -0
  22. package/dist/serverPlugin/definitions.d.mts +4 -0
  23. package/dist/serverPlugin/schema.d.cts +4 -0
  24. package/dist/serverPlugin/schema.d.mts +4 -0
  25. package/dist/types/databaseConfig.d.cts +8 -19
  26. package/dist/types/databaseConfig.d.mts +8 -19
  27. package/dist/types/databaseRows.d.cts +70 -2
  28. package/dist/types/databaseRows.d.mts +70 -2
  29. package/dist/types/index.cjs +3 -0
  30. package/dist/types/index.d.cts +118 -60
  31. package/dist/types/index.d.mts +118 -60
  32. package/dist/types/index.mjs +3 -1
  33. package/dist/types/models.d.cts +9 -1
  34. package/dist/types/models.d.mts +9 -1
  35. package/dist/types/public.d.cts +3 -3
  36. package/dist/types/public.d.mts +3 -3
  37. package/package.json +3 -9
  38. package/dist/remoteBundleSigning.cjs +0 -357
  39. package/dist/remoteBundleSigning.d.cts +0 -38
  40. package/dist/remoteBundleSigning.d.mts +0 -38
  41. package/dist/remoteBundleSigning.mjs +0 -352
@@ -1,5 +1,5 @@
1
- import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
2
- import { ChannelDeleteResult, NativeBuildDeleteResult } from "./types/models.cjs";
1
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
2
+ import { ChannelDeleteResult, NativeBuildDeleteResult, NativeBuildMarkResult } from "./types/models.cjs";
3
3
  import { Bundle, Platform } from "./types/index.cjs";
4
4
  import { ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult } from "./releaseCatalogMutation.cjs";
5
5
  import { PromoteReleaseResult, ReleasePolicyPatch } from "./releaseManagement.cjs";
@@ -9,6 +9,8 @@ interface KeysetInput {
9
9
  readonly order?: "asc" | "desc";
10
10
  /** The last key a previous page returned. */
11
11
  readonly after?: string;
12
+ /** The last key this read may return: it ends with that key, if present. */
13
+ readonly through?: string;
12
14
  readonly limit: number;
13
15
  }
14
16
  /** A release list's filter: exactly the sets the release indexes serve. */
@@ -55,14 +57,39 @@ interface StoredBundleDeployment {
55
57
  readonly release: DeployReleasePolicy;
56
58
  }
57
59
  type Deployment = BundleDeployment | StoredBundleDeployment;
60
+ /**
61
+ * How a native build's artifact reaches a device: installed directly (an
62
+ * APK, a simulator `.app`, or an ad hoc, development or enterprise `.ipa`),
63
+ * or through a store (an AAB, or an App Store `.ipa`). Part of the core API
64
+ * a standalone server's client implements.
65
+ */
66
+ type NativeBuildDistribution = "direct" | "store";
67
+ /**
68
+ * What tells sandbox builds apart in place of the channel, which pull requests
69
+ * reuse a sandbox build across: the app ID its artifact reports (its bundle
70
+ * identifier or application ID, with Android's `.sandbox` suffix), the URL
71
+ * scheme its preview links open, its artifact's kind, and how that installs.
72
+ * Part of the core API a standalone server's client implements.
73
+ */
74
+ interface NativeBuildSandboxScope {
75
+ readonly appId: string;
76
+ readonly urlScheme: string;
77
+ readonly artifactKind: NativeBuildArtifactKind;
78
+ readonly distribution: NativeBuildDistribution;
79
+ }
58
80
  /**
59
81
  * A native build's scope: its platform, the default channel it compiled in,
60
82
  * and whichever of the fingerprint and the app version the update strategy
61
- * selects by.
83
+ * selects by. With `sandbox`, the scope of sandbox builds of that fingerprint
84
+ * or app version, on any channel: `channel` is then the one a new build would
85
+ * embed, and no lookup reads it. A registration ignores `sandbox`: its own
86
+ * `isSandbox`, `sandboxAppId`, `sandboxUrlScheme`, `exportMethod` and
87
+ * artifact decide its scope.
62
88
  */
63
89
  type NativeBuildScope = {
64
90
  readonly platform: Platform;
65
91
  readonly channel: string;
92
+ readonly sandbox?: NativeBuildSandboxScope | null;
66
93
  } & ({
67
94
  readonly fingerprintHash: string;
68
95
  readonly appVersion: null;
@@ -88,6 +115,35 @@ type NativeBuildRegistration = NativeBuildScope & {
88
115
  * `versionCode`, or null (or left out) when it can't be read.
89
116
  */
90
117
  readonly buildNumber?: string | null;
118
+ /**
119
+ * Whether the artifact is a sandbox build, as the artifact says; left out,
120
+ * it isn't. A sandbox build registers on any channel, and is found through
121
+ * its sandbox scope, never a normal one.
122
+ */
123
+ readonly isSandbox?: boolean;
124
+ /**
125
+ * The URL scheme a sandbox build's artifact registers, which its preview
126
+ * links open: required for a sandbox build, and null or left out for any
127
+ * other.
128
+ */
129
+ readonly sandboxUrlScheme?: string | null;
130
+ /**
131
+ * The app ID a sandbox build's artifact reports, its bundle identifier or
132
+ * application ID: required for a sandbox build, and null or left out for
133
+ * any other.
134
+ */
135
+ readonly sandboxAppId?: string | null;
136
+ /**
137
+ * How an `.ipa` was exported, read from its embedded profile; null or left
138
+ * out for any other artifact, or an `.ipa` whose profile wasn't read.
139
+ */
140
+ readonly exportMethod?: NativeBuildExportMethod | null;
141
+ /**
142
+ * The app version the artifact reports, its `CFBundleShortVersionString`
143
+ * or `versionName`, whatever the update strategy; null or left out when it
144
+ * wasn't read.
145
+ */
146
+ readonly nativeAppVersion?: string | null;
91
147
  readonly artifact: {
92
148
  readonly kind: NativeBuildArtifactKind;
93
149
  readonly storageUri: string;
@@ -104,6 +160,48 @@ type NativeBuildRegistration = NativeBuildScope & {
104
160
  readonly metadata?: DatabaseBundleMetadata;
105
161
  };
106
162
  };
163
+ /**
164
+ * What a build or `native-build devices add` learned from Apple about one
165
+ * registry row: Apple has it enabled (`registered`), refused to add it
166
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
167
+ * row says it registered (`missing`).
168
+ */
169
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
170
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
171
+ interface IosDeviceOutcomeInput {
172
+ readonly id: string;
173
+ /**
174
+ * The row as the caller read it before asking Apple: a row that changed
175
+ * since, such as one removed and requested again, is left alone.
176
+ */
177
+ readonly seen: {
178
+ readonly status: IosDeviceStatus;
179
+ readonly approvedAtMs: number | null;
180
+ };
181
+ /** The App Store Connect issuer of the key that asked Apple. */
182
+ readonly issuerId: string;
183
+ readonly outcome: IosDeviceOutcome;
184
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
185
+ readonly reason?: string;
186
+ }
187
+ /** The Apple account a device registry belongs to. */
188
+ interface IosDeviceAccount {
189
+ /** The App Store Connect issuer of the account. */
190
+ readonly issuerId: string;
191
+ }
192
+ /** The device registry's Apple account, after a build tried to claim it. */
193
+ interface IosDeviceAccountClaim {
194
+ /** The App Store Connect issuer the registry belongs to. */
195
+ readonly issuerId: string;
196
+ /** Whether that is the issuer that asked: false means another account's. */
197
+ readonly claimed: boolean;
198
+ }
199
+ /** A device request's row, and whether the request created it. */
200
+ interface IosDeviceRequestResult {
201
+ readonly device: IosDeviceRow;
202
+ /** False when the UDID was already in the registry, whose row is unchanged. */
203
+ readonly created: boolean;
204
+ }
107
205
  interface ReleaseTarget {
108
206
  readonly releaseId: string;
109
207
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +244,22 @@ interface HotUpdaterCoreApi {
146
244
  /** A native build by ID: one read of its key. */
147
245
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
246
  /**
149
- * The newest native build of a scope: one read of its index. With
150
- * `buildKey`, the newest of the scope registered with that native build
151
- * key, also one read.
247
+ * The newest native build of a scope: the one registered last, in one read
248
+ * of its index. With `buildKey`, the newest of the scope registered with that
249
+ * native build key, also one read. With `storeBuild`, the scope's marked
250
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
251
+ * scope whose built-in bundle is older than that bundle: one read when the
252
+ * newest is, and then a page of older builds per read until one is, when
253
+ * builds made after the bundle are in the way. With `buildKey` too, only
254
+ * builds of that key. With `scope.sandbox`, sandbox builds on any channel;
255
+ * without it, never one. A sandbox build's built-in bundle is no patch
256
+ * base, so with `builtInOlderThan` a sandbox scope answers null without a
257
+ * read.
152
258
  */
153
259
  findNativeBuild(scope: NativeBuildScope, options?: {
154
260
  readonly buildKey?: string;
261
+ readonly storeBuild?: true;
262
+ readonly builtInOlderThan?: string;
155
263
  }): Promise<NativeBuildRow | null>;
156
264
  /**
157
265
  * One page of native builds, by ID: oldest or newest first. With
@@ -163,7 +271,9 @@ interface HotUpdaterCoreApi {
163
271
  /**
164
272
  * Writes each new bundle with its patches, and each release, with the next
165
273
  * catalog of each scope, in one transaction. A stored bundle's deployment
166
- * publishes a new release for it and writes no bundle.
274
+ * publishes a new release for it and writes no bundle. Like `updateBundle`,
275
+ * it refuses a patch from a sandbox build's built-in bundle: one read of
276
+ * each new bundle's patch base.
167
277
  */
168
278
  deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
169
279
  updateReleasePolicy(input: ReleaseTarget & {
@@ -186,7 +296,11 @@ interface HotUpdaterCoreApi {
186
296
  ensureChannel(name: string): Promise<ChannelRow>;
187
297
  /** Deletes a channel no release uses. */
188
298
  deleteChannel(id: string): Promise<ChannelDeleteResult>;
189
- /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
299
+ /**
300
+ * Changes a bundle's fields; `patches`, when given, replaces its patches.
301
+ * It refuses a new patch from a sandbox build's built-in bundle, which is
302
+ * no patch base: one read of each new patch's base.
303
+ */
190
304
  updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
191
305
  readonly patches?: Bundle["patches"];
192
306
  }): Promise<void>;
@@ -217,6 +331,87 @@ interface HotUpdaterCoreApi {
217
331
  * full bundles. Its artifact stays in storage for the caller to delete.
218
332
  */
219
333
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
334
+ /**
335
+ * Marks a build as what the store sells, replacing its scope's mark in one
336
+ * write, or clears the mark it holds. Running it again changes nothing. Null
337
+ * for an unknown ID. A sandbox build can't be marked.
338
+ */
339
+ markNativeBuild(id: string, mark: {
340
+ readonly storeBuild: boolean;
341
+ }): Promise<NativeBuildMarkResult | null>;
342
+ /**
343
+ * One page of the iOS device registry, by ID: oldest or newest first. With
344
+ * `status`, only the rows in it, also one read.
345
+ */
346
+ listIosDevices(input: KeysetInput & {
347
+ readonly status?: IosDeviceStatus;
348
+ }): Promise<IosDeviceRow[]>;
349
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
350
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
351
+ /**
352
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
353
+ * row unchanged, so nobody takes over another person's request.
354
+ */
355
+ requestIosDevice(input: {
356
+ readonly udid: string;
357
+ readonly name: string;
358
+ /** Who asks, or null for the CLI. */
359
+ readonly requestedBy: string | null;
360
+ }): Promise<IosDeviceRequestResult>;
361
+ /**
362
+ * Approves a pending device, so the next ad hoc build registers it with
363
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
364
+ * Null for an unknown ID.
365
+ */
366
+ approveIosDevice(id: string, input: {
367
+ readonly name?: string;
368
+ /** Who approves: a Console email, or null for the CLI. */
369
+ readonly approvedBy: string | null;
370
+ }): Promise<IosDeviceRow | null>;
371
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
372
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
373
+ /**
374
+ * Records what Apple said of a device, only over the row the caller read
375
+ * (`seen`) and only for the account that registered it: null, with nothing
376
+ * written, for a row that changed, is gone, or belongs to another issuer.
377
+ * It never creates a row.
378
+ */
379
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
380
+ /**
381
+ * Claims the device registry for an Apple account before a build records
382
+ * or sends anything at Apple: the first claim wins, atomically, and holds
383
+ * for good. A registry with no claim yet whose rows already name an account
384
+ * (any status) goes to the earliest of them, not to the caller. Answers the
385
+ * registry's account and whether it is `issuerId`'s; a build of another
386
+ * account registers nothing.
387
+ */
388
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
389
+ /**
390
+ * The Apple account the device registry belongs to, read without claiming
391
+ * it: the claimed account, or with no claim yet, the one
392
+ * `claimIosDeviceAccount` would give it, the earliest its rows name. Null
393
+ * while nothing names one, when the first claim takes it.
394
+ */
395
+ findIosDeviceAccount(): Promise<IosDeviceAccount | null>;
396
+ /**
397
+ * Records that a native build's .ipa lists these devices, one write per
398
+ * row: a row removed meanwhile is skipped.
399
+ */
400
+ markIosDevicesInBuild(input: {
401
+ readonly buildId: string;
402
+ readonly ids: readonly string[];
403
+ }): Promise<void>;
404
+ /**
405
+ * Deletes a device from the registry. Apple keeps it: a device enabled
406
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
407
+ * while it still has that status and requester, read in the same
408
+ * transaction, such as a request its owner withdraws. Null, with nothing
409
+ * deleted, for an unknown ID or a row that no longer matches.
410
+ */
411
+ deleteIosDevice(id: string, only?: {
412
+ readonly status?: IosDeviceStatus;
413
+ readonly requestedBy?: string;
414
+ }): Promise<IosDeviceRow | null>;
220
415
  }
221
416
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
417
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
@@ -1,5 +1,5 @@
1
- import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
2
- import { ChannelDeleteResult, NativeBuildDeleteResult } from "./types/models.mjs";
1
+ import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, IosDeviceRow, IosDeviceStatus, NativeBuildArtifactKind, NativeBuildExportMethod, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
2
+ import { ChannelDeleteResult, NativeBuildDeleteResult, NativeBuildMarkResult } from "./types/models.mjs";
3
3
  import { Bundle, Platform } from "./types/index.mjs";
4
4
  import { ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult } from "./releaseCatalogMutation.mjs";
5
5
  import { PromoteReleaseResult, ReleasePolicyPatch } from "./releaseManagement.mjs";
@@ -9,6 +9,8 @@ interface KeysetInput {
9
9
  readonly order?: "asc" | "desc";
10
10
  /** The last key a previous page returned. */
11
11
  readonly after?: string;
12
+ /** The last key this read may return: it ends with that key, if present. */
13
+ readonly through?: string;
12
14
  readonly limit: number;
13
15
  }
14
16
  /** A release list's filter: exactly the sets the release indexes serve. */
@@ -55,14 +57,39 @@ interface StoredBundleDeployment {
55
57
  readonly release: DeployReleasePolicy;
56
58
  }
57
59
  type Deployment = BundleDeployment | StoredBundleDeployment;
60
+ /**
61
+ * How a native build's artifact reaches a device: installed directly (an
62
+ * APK, a simulator `.app`, or an ad hoc, development or enterprise `.ipa`),
63
+ * or through a store (an AAB, or an App Store `.ipa`). Part of the core API
64
+ * a standalone server's client implements.
65
+ */
66
+ type NativeBuildDistribution = "direct" | "store";
67
+ /**
68
+ * What tells sandbox builds apart in place of the channel, which pull requests
69
+ * reuse a sandbox build across: the app ID its artifact reports (its bundle
70
+ * identifier or application ID, with Android's `.sandbox` suffix), the URL
71
+ * scheme its preview links open, its artifact's kind, and how that installs.
72
+ * Part of the core API a standalone server's client implements.
73
+ */
74
+ interface NativeBuildSandboxScope {
75
+ readonly appId: string;
76
+ readonly urlScheme: string;
77
+ readonly artifactKind: NativeBuildArtifactKind;
78
+ readonly distribution: NativeBuildDistribution;
79
+ }
58
80
  /**
59
81
  * A native build's scope: its platform, the default channel it compiled in,
60
82
  * and whichever of the fingerprint and the app version the update strategy
61
- * selects by.
83
+ * selects by. With `sandbox`, the scope of sandbox builds of that fingerprint
84
+ * or app version, on any channel: `channel` is then the one a new build would
85
+ * embed, and no lookup reads it. A registration ignores `sandbox`: its own
86
+ * `isSandbox`, `sandboxAppId`, `sandboxUrlScheme`, `exportMethod` and
87
+ * artifact decide its scope.
62
88
  */
63
89
  type NativeBuildScope = {
64
90
  readonly platform: Platform;
65
91
  readonly channel: string;
92
+ readonly sandbox?: NativeBuildSandboxScope | null;
66
93
  } & ({
67
94
  readonly fingerprintHash: string;
68
95
  readonly appVersion: null;
@@ -88,6 +115,35 @@ type NativeBuildRegistration = NativeBuildScope & {
88
115
  * `versionCode`, or null (or left out) when it can't be read.
89
116
  */
90
117
  readonly buildNumber?: string | null;
118
+ /**
119
+ * Whether the artifact is a sandbox build, as the artifact says; left out,
120
+ * it isn't. A sandbox build registers on any channel, and is found through
121
+ * its sandbox scope, never a normal one.
122
+ */
123
+ readonly isSandbox?: boolean;
124
+ /**
125
+ * The URL scheme a sandbox build's artifact registers, which its preview
126
+ * links open: required for a sandbox build, and null or left out for any
127
+ * other.
128
+ */
129
+ readonly sandboxUrlScheme?: string | null;
130
+ /**
131
+ * The app ID a sandbox build's artifact reports, its bundle identifier or
132
+ * application ID: required for a sandbox build, and null or left out for
133
+ * any other.
134
+ */
135
+ readonly sandboxAppId?: string | null;
136
+ /**
137
+ * How an `.ipa` was exported, read from its embedded profile; null or left
138
+ * out for any other artifact, or an `.ipa` whose profile wasn't read.
139
+ */
140
+ readonly exportMethod?: NativeBuildExportMethod | null;
141
+ /**
142
+ * The app version the artifact reports, its `CFBundleShortVersionString`
143
+ * or `versionName`, whatever the update strategy; null or left out when it
144
+ * wasn't read.
145
+ */
146
+ readonly nativeAppVersion?: string | null;
91
147
  readonly artifact: {
92
148
  readonly kind: NativeBuildArtifactKind;
93
149
  readonly storageUri: string;
@@ -104,6 +160,48 @@ type NativeBuildRegistration = NativeBuildScope & {
104
160
  readonly metadata?: DatabaseBundleMetadata;
105
161
  };
106
162
  };
163
+ /**
164
+ * What a build or `native-build devices add` learned from Apple about one
165
+ * registry row: Apple has it enabled (`registered`), refused to add it
166
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
167
+ * row says it registered (`missing`).
168
+ */
169
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
170
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
171
+ interface IosDeviceOutcomeInput {
172
+ readonly id: string;
173
+ /**
174
+ * The row as the caller read it before asking Apple: a row that changed
175
+ * since, such as one removed and requested again, is left alone.
176
+ */
177
+ readonly seen: {
178
+ readonly status: IosDeviceStatus;
179
+ readonly approvedAtMs: number | null;
180
+ };
181
+ /** The App Store Connect issuer of the key that asked Apple. */
182
+ readonly issuerId: string;
183
+ readonly outcome: IosDeviceOutcome;
184
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
185
+ readonly reason?: string;
186
+ }
187
+ /** The Apple account a device registry belongs to. */
188
+ interface IosDeviceAccount {
189
+ /** The App Store Connect issuer of the account. */
190
+ readonly issuerId: string;
191
+ }
192
+ /** The device registry's Apple account, after a build tried to claim it. */
193
+ interface IosDeviceAccountClaim {
194
+ /** The App Store Connect issuer the registry belongs to. */
195
+ readonly issuerId: string;
196
+ /** Whether that is the issuer that asked: false means another account's. */
197
+ readonly claimed: boolean;
198
+ }
199
+ /** A device request's row, and whether the request created it. */
200
+ interface IosDeviceRequestResult {
201
+ readonly device: IosDeviceRow;
202
+ /** False when the UDID was already in the registry, whose row is unchanged. */
203
+ readonly created: boolean;
204
+ }
107
205
  interface ReleaseTarget {
108
206
  readonly releaseId: string;
109
207
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +244,22 @@ interface HotUpdaterCoreApi {
146
244
  /** A native build by ID: one read of its key. */
147
245
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
246
  /**
149
- * The newest native build of a scope: one read of its index. With
150
- * `buildKey`, the newest of the scope registered with that native build
151
- * key, also one read.
247
+ * The newest native build of a scope: the one registered last, in one read
248
+ * of its index. With `buildKey`, the newest of the scope registered with that
249
+ * native build key, also one read. With `storeBuild`, the scope's marked
250
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
251
+ * scope whose built-in bundle is older than that bundle: one read when the
252
+ * newest is, and then a page of older builds per read until one is, when
253
+ * builds made after the bundle are in the way. With `buildKey` too, only
254
+ * builds of that key. With `scope.sandbox`, sandbox builds on any channel;
255
+ * without it, never one. A sandbox build's built-in bundle is no patch
256
+ * base, so with `builtInOlderThan` a sandbox scope answers null without a
257
+ * read.
152
258
  */
153
259
  findNativeBuild(scope: NativeBuildScope, options?: {
154
260
  readonly buildKey?: string;
261
+ readonly storeBuild?: true;
262
+ readonly builtInOlderThan?: string;
155
263
  }): Promise<NativeBuildRow | null>;
156
264
  /**
157
265
  * One page of native builds, by ID: oldest or newest first. With
@@ -163,7 +271,9 @@ interface HotUpdaterCoreApi {
163
271
  /**
164
272
  * Writes each new bundle with its patches, and each release, with the next
165
273
  * catalog of each scope, in one transaction. A stored bundle's deployment
166
- * publishes a new release for it and writes no bundle.
274
+ * publishes a new release for it and writes no bundle. Like `updateBundle`,
275
+ * it refuses a patch from a sandbox build's built-in bundle: one read of
276
+ * each new bundle's patch base.
167
277
  */
168
278
  deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
169
279
  updateReleasePolicy(input: ReleaseTarget & {
@@ -186,7 +296,11 @@ interface HotUpdaterCoreApi {
186
296
  ensureChannel(name: string): Promise<ChannelRow>;
187
297
  /** Deletes a channel no release uses. */
188
298
  deleteChannel(id: string): Promise<ChannelDeleteResult>;
189
- /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
299
+ /**
300
+ * Changes a bundle's fields; `patches`, when given, replaces its patches.
301
+ * It refuses a new patch from a sandbox build's built-in bundle, which is
302
+ * no patch base: one read of each new patch's base.
303
+ */
190
304
  updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
191
305
  readonly patches?: Bundle["patches"];
192
306
  }): Promise<void>;
@@ -217,6 +331,87 @@ interface HotUpdaterCoreApi {
217
331
  * full bundles. Its artifact stays in storage for the caller to delete.
218
332
  */
219
333
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
334
+ /**
335
+ * Marks a build as what the store sells, replacing its scope's mark in one
336
+ * write, or clears the mark it holds. Running it again changes nothing. Null
337
+ * for an unknown ID. A sandbox build can't be marked.
338
+ */
339
+ markNativeBuild(id: string, mark: {
340
+ readonly storeBuild: boolean;
341
+ }): Promise<NativeBuildMarkResult | null>;
342
+ /**
343
+ * One page of the iOS device registry, by ID: oldest or newest first. With
344
+ * `status`, only the rows in it, also one read.
345
+ */
346
+ listIosDevices(input: KeysetInput & {
347
+ readonly status?: IosDeviceStatus;
348
+ }): Promise<IosDeviceRow[]>;
349
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
350
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
351
+ /**
352
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
353
+ * row unchanged, so nobody takes over another person's request.
354
+ */
355
+ requestIosDevice(input: {
356
+ readonly udid: string;
357
+ readonly name: string;
358
+ /** Who asks, or null for the CLI. */
359
+ readonly requestedBy: string | null;
360
+ }): Promise<IosDeviceRequestResult>;
361
+ /**
362
+ * Approves a pending device, so the next ad hoc build registers it with
363
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
364
+ * Null for an unknown ID.
365
+ */
366
+ approveIosDevice(id: string, input: {
367
+ readonly name?: string;
368
+ /** Who approves: a Console email, or null for the CLI. */
369
+ readonly approvedBy: string | null;
370
+ }): Promise<IosDeviceRow | null>;
371
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
372
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
373
+ /**
374
+ * Records what Apple said of a device, only over the row the caller read
375
+ * (`seen`) and only for the account that registered it: null, with nothing
376
+ * written, for a row that changed, is gone, or belongs to another issuer.
377
+ * It never creates a row.
378
+ */
379
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
380
+ /**
381
+ * Claims the device registry for an Apple account before a build records
382
+ * or sends anything at Apple: the first claim wins, atomically, and holds
383
+ * for good. A registry with no claim yet whose rows already name an account
384
+ * (any status) goes to the earliest of them, not to the caller. Answers the
385
+ * registry's account and whether it is `issuerId`'s; a build of another
386
+ * account registers nothing.
387
+ */
388
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
389
+ /**
390
+ * The Apple account the device registry belongs to, read without claiming
391
+ * it: the claimed account, or with no claim yet, the one
392
+ * `claimIosDeviceAccount` would give it, the earliest its rows name. Null
393
+ * while nothing names one, when the first claim takes it.
394
+ */
395
+ findIosDeviceAccount(): Promise<IosDeviceAccount | null>;
396
+ /**
397
+ * Records that a native build's .ipa lists these devices, one write per
398
+ * row: a row removed meanwhile is skipped.
399
+ */
400
+ markIosDevicesInBuild(input: {
401
+ readonly buildId: string;
402
+ readonly ids: readonly string[];
403
+ }): Promise<void>;
404
+ /**
405
+ * Deletes a device from the registry. Apple keeps it: a device enabled
406
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
407
+ * while it still has that status and requester, read in the same
408
+ * transaction, such as a request its owner withdraws. Null, with nothing
409
+ * deleted, for an unknown ID or a row that no longer matches.
410
+ */
411
+ deleteIosDevice(id: string, only?: {
412
+ readonly status?: IosDeviceStatus;
413
+ readonly requestedBy?: string;
414
+ }): Promise<IosDeviceRow | null>;
220
415
  }
221
416
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
417
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };