@hot-updater/plugin-core 1.2.0-rc.3 → 1.2.0-rc.30

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 +142 -6
  2. package/dist/coreApi.d.mts +142 -6
  3. package/dist/engine/core/schema.cjs +157 -2
  4. package/dist/engine/core/schema.d.cts +111 -1
  5. package/dist/engine/core/schema.d.mts +111 -1
  6. package/dist/engine/core/schema.mjs +157 -2
  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 +60 -2
  28. package/dist/types/databaseRows.d.mts +60 -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. */
@@ -88,6 +90,22 @@ type NativeBuildRegistration = NativeBuildScope & {
88
90
  * `versionCode`, or null (or left out) when it can't be read.
89
91
  */
90
92
  readonly buildNumber?: string | null;
93
+ /**
94
+ * Whether the artifact is a sandbox build; left out, it isn't. It must agree
95
+ * with the channel: a sandbox build registers on a reserved `sandbox-*`
96
+ * channel, and only a sandbox build does.
97
+ */
98
+ readonly isSandbox?: boolean;
99
+ /**
100
+ * The URL scheme a sandbox build's artifact registers, which its preview
101
+ * links open; null or left out for any other build.
102
+ */
103
+ readonly sandboxUrlScheme?: string | null;
104
+ /**
105
+ * How an `.ipa` was exported, read from its embedded profile; null or left
106
+ * out for any other artifact, or an `.ipa` whose profile wasn't read.
107
+ */
108
+ readonly exportMethod?: NativeBuildExportMethod | null;
91
109
  readonly artifact: {
92
110
  readonly kind: NativeBuildArtifactKind;
93
111
  readonly storageUri: string;
@@ -104,6 +122,43 @@ type NativeBuildRegistration = NativeBuildScope & {
104
122
  readonly metadata?: DatabaseBundleMetadata;
105
123
  };
106
124
  };
125
+ /**
126
+ * What a build or `native-build devices add` learned from Apple about one
127
+ * registry row: Apple has it enabled (`registered`), refused to add it
128
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
129
+ * row says it registered (`missing`).
130
+ */
131
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
132
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
133
+ interface IosDeviceOutcomeInput {
134
+ readonly id: string;
135
+ /**
136
+ * The row as the caller read it before asking Apple: a row that changed
137
+ * since, such as one removed and requested again, is left alone.
138
+ */
139
+ readonly seen: {
140
+ readonly status: IosDeviceStatus;
141
+ readonly approvedAtMs: number | null;
142
+ };
143
+ /** The App Store Connect issuer of the key that asked Apple. */
144
+ readonly issuerId: string;
145
+ readonly outcome: IosDeviceOutcome;
146
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
147
+ readonly reason?: string;
148
+ }
149
+ /** The device registry's Apple account, after a build tried to claim it. */
150
+ interface IosDeviceAccountClaim {
151
+ /** The App Store Connect issuer the registry belongs to. */
152
+ readonly issuerId: string;
153
+ /** Whether that is the issuer that asked: false means another account's. */
154
+ readonly claimed: boolean;
155
+ }
156
+ /** A device request's row, and whether the request created it. */
157
+ interface IosDeviceRequestResult {
158
+ readonly device: IosDeviceRow;
159
+ /** False when the UDID was already in the registry, whose row is unchanged. */
160
+ readonly created: boolean;
161
+ }
107
162
  interface ReleaseTarget {
108
163
  readonly releaseId: string;
109
164
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +201,19 @@ interface HotUpdaterCoreApi {
146
201
  /** A native build by ID: one read of its key. */
147
202
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
203
  /**
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.
204
+ * The newest native build of a scope: the one registered last, in one read
205
+ * of its index. With `buildKey`, the newest of the scope registered with that
206
+ * native build key, also one read. With `storeBuild`, the scope's marked
207
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
208
+ * scope whose built-in bundle is older than that bundle: one read when the
209
+ * newest is, and then a page of older builds per read until one is, when
210
+ * builds made after the bundle are in the way. With `buildKey` too, only
211
+ * builds of that key.
152
212
  */
153
213
  findNativeBuild(scope: NativeBuildScope, options?: {
154
214
  readonly buildKey?: string;
215
+ readonly storeBuild?: true;
216
+ readonly builtInOlderThan?: string;
155
217
  }): Promise<NativeBuildRow | null>;
156
218
  /**
157
219
  * One page of native builds, by ID: oldest or newest first. With
@@ -217,6 +279,80 @@ interface HotUpdaterCoreApi {
217
279
  * full bundles. Its artifact stays in storage for the caller to delete.
218
280
  */
219
281
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
282
+ /**
283
+ * Marks a build as what the store sells, replacing its scope's mark in one
284
+ * write, or clears the mark it holds. Running it again changes nothing. Null
285
+ * for an unknown ID. A sandbox build can't be marked.
286
+ */
287
+ markNativeBuild(id: string, mark: {
288
+ readonly storeBuild: boolean;
289
+ }): Promise<NativeBuildMarkResult | null>;
290
+ /**
291
+ * One page of the iOS device registry, by ID: oldest or newest first. With
292
+ * `status`, only the rows in it, also one read.
293
+ */
294
+ listIosDevices(input: KeysetInput & {
295
+ readonly status?: IosDeviceStatus;
296
+ }): Promise<IosDeviceRow[]>;
297
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
298
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
299
+ /**
300
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
301
+ * row unchanged, so nobody takes over another person's request.
302
+ */
303
+ requestIosDevice(input: {
304
+ readonly udid: string;
305
+ readonly name: string;
306
+ /** Who asks, or null for the CLI. */
307
+ readonly requestedBy: string | null;
308
+ }): Promise<IosDeviceRequestResult>;
309
+ /**
310
+ * Approves a pending device, so the next ad hoc build registers it with
311
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
312
+ * Null for an unknown ID.
313
+ */
314
+ approveIosDevice(id: string, input: {
315
+ readonly name?: string;
316
+ /** Who approves: a Console email, or null for the CLI. */
317
+ readonly approvedBy: string | null;
318
+ }): Promise<IosDeviceRow | null>;
319
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
320
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
321
+ /**
322
+ * Records what Apple said of a device, only over the row the caller read
323
+ * (`seen`) and only for the account that registered it: null, with nothing
324
+ * written, for a row that changed, is gone, or belongs to another issuer.
325
+ * It never creates a row.
326
+ */
327
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
328
+ /**
329
+ * Claims the device registry for an Apple account before a build records
330
+ * or sends anything at Apple: the first claim wins, atomically, and holds
331
+ * for good. A registry with no claim yet whose rows already name an account
332
+ * (any status) goes to the earliest of them, not to the caller. Answers the
333
+ * registry's account and whether it is `issuerId`'s; a build of another
334
+ * account registers nothing.
335
+ */
336
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
337
+ /**
338
+ * Records that a native build's .ipa lists these devices, one write per
339
+ * row: a row removed meanwhile is skipped.
340
+ */
341
+ markIosDevicesInBuild(input: {
342
+ readonly buildId: string;
343
+ readonly ids: readonly string[];
344
+ }): Promise<void>;
345
+ /**
346
+ * Deletes a device from the registry. Apple keeps it: a device enabled
347
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
348
+ * while it still has that status and requester, read in the same
349
+ * transaction, such as a request its owner withdraws. Null, with nothing
350
+ * deleted, for an unknown ID or a row that no longer matches.
351
+ */
352
+ deleteIosDevice(id: string, only?: {
353
+ readonly status?: IosDeviceStatus;
354
+ readonly requestedBy?: string;
355
+ }): Promise<IosDeviceRow | null>;
220
356
  }
221
357
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
358
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildRegistration, 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. */
@@ -88,6 +90,22 @@ type NativeBuildRegistration = NativeBuildScope & {
88
90
  * `versionCode`, or null (or left out) when it can't be read.
89
91
  */
90
92
  readonly buildNumber?: string | null;
93
+ /**
94
+ * Whether the artifact is a sandbox build; left out, it isn't. It must agree
95
+ * with the channel: a sandbox build registers on a reserved `sandbox-*`
96
+ * channel, and only a sandbox build does.
97
+ */
98
+ readonly isSandbox?: boolean;
99
+ /**
100
+ * The URL scheme a sandbox build's artifact registers, which its preview
101
+ * links open; null or left out for any other build.
102
+ */
103
+ readonly sandboxUrlScheme?: string | null;
104
+ /**
105
+ * How an `.ipa` was exported, read from its embedded profile; null or left
106
+ * out for any other artifact, or an `.ipa` whose profile wasn't read.
107
+ */
108
+ readonly exportMethod?: NativeBuildExportMethod | null;
91
109
  readonly artifact: {
92
110
  readonly kind: NativeBuildArtifactKind;
93
111
  readonly storageUri: string;
@@ -104,6 +122,43 @@ type NativeBuildRegistration = NativeBuildScope & {
104
122
  readonly metadata?: DatabaseBundleMetadata;
105
123
  };
106
124
  };
125
+ /**
126
+ * What a build or `native-build devices add` learned from Apple about one
127
+ * registry row: Apple has it enabled (`registered`), refused to add it
128
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
129
+ * row says it registered (`missing`).
130
+ */
131
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
132
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
133
+ interface IosDeviceOutcomeInput {
134
+ readonly id: string;
135
+ /**
136
+ * The row as the caller read it before asking Apple: a row that changed
137
+ * since, such as one removed and requested again, is left alone.
138
+ */
139
+ readonly seen: {
140
+ readonly status: IosDeviceStatus;
141
+ readonly approvedAtMs: number | null;
142
+ };
143
+ /** The App Store Connect issuer of the key that asked Apple. */
144
+ readonly issuerId: string;
145
+ readonly outcome: IosDeviceOutcome;
146
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
147
+ readonly reason?: string;
148
+ }
149
+ /** The device registry's Apple account, after a build tried to claim it. */
150
+ interface IosDeviceAccountClaim {
151
+ /** The App Store Connect issuer the registry belongs to. */
152
+ readonly issuerId: string;
153
+ /** Whether that is the issuer that asked: false means another account's. */
154
+ readonly claimed: boolean;
155
+ }
156
+ /** A device request's row, and whether the request created it. */
157
+ interface IosDeviceRequestResult {
158
+ readonly device: IosDeviceRow;
159
+ /** False when the UDID was already in the registry, whose row is unchanged. */
160
+ readonly created: boolean;
161
+ }
107
162
  interface ReleaseTarget {
108
163
  readonly releaseId: string;
109
164
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +201,19 @@ interface HotUpdaterCoreApi {
146
201
  /** A native build by ID: one read of its key. */
147
202
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
203
  /**
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.
204
+ * The newest native build of a scope: the one registered last, in one read
205
+ * of its index. With `buildKey`, the newest of the scope registered with that
206
+ * native build key, also one read. With `storeBuild`, the scope's marked
207
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
208
+ * scope whose built-in bundle is older than that bundle: one read when the
209
+ * newest is, and then a page of older builds per read until one is, when
210
+ * builds made after the bundle are in the way. With `buildKey` too, only
211
+ * builds of that key.
152
212
  */
153
213
  findNativeBuild(scope: NativeBuildScope, options?: {
154
214
  readonly buildKey?: string;
215
+ readonly storeBuild?: true;
216
+ readonly builtInOlderThan?: string;
155
217
  }): Promise<NativeBuildRow | null>;
156
218
  /**
157
219
  * One page of native builds, by ID: oldest or newest first. With
@@ -217,6 +279,80 @@ interface HotUpdaterCoreApi {
217
279
  * full bundles. Its artifact stays in storage for the caller to delete.
218
280
  */
219
281
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
282
+ /**
283
+ * Marks a build as what the store sells, replacing its scope's mark in one
284
+ * write, or clears the mark it holds. Running it again changes nothing. Null
285
+ * for an unknown ID. A sandbox build can't be marked.
286
+ */
287
+ markNativeBuild(id: string, mark: {
288
+ readonly storeBuild: boolean;
289
+ }): Promise<NativeBuildMarkResult | null>;
290
+ /**
291
+ * One page of the iOS device registry, by ID: oldest or newest first. With
292
+ * `status`, only the rows in it, also one read.
293
+ */
294
+ listIosDevices(input: KeysetInput & {
295
+ readonly status?: IosDeviceStatus;
296
+ }): Promise<IosDeviceRow[]>;
297
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
298
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
299
+ /**
300
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
301
+ * row unchanged, so nobody takes over another person's request.
302
+ */
303
+ requestIosDevice(input: {
304
+ readonly udid: string;
305
+ readonly name: string;
306
+ /** Who asks, or null for the CLI. */
307
+ readonly requestedBy: string | null;
308
+ }): Promise<IosDeviceRequestResult>;
309
+ /**
310
+ * Approves a pending device, so the next ad hoc build registers it with
311
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
312
+ * Null for an unknown ID.
313
+ */
314
+ approveIosDevice(id: string, input: {
315
+ readonly name?: string;
316
+ /** Who approves: a Console email, or null for the CLI. */
317
+ readonly approvedBy: string | null;
318
+ }): Promise<IosDeviceRow | null>;
319
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
320
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
321
+ /**
322
+ * Records what Apple said of a device, only over the row the caller read
323
+ * (`seen`) and only for the account that registered it: null, with nothing
324
+ * written, for a row that changed, is gone, or belongs to another issuer.
325
+ * It never creates a row.
326
+ */
327
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
328
+ /**
329
+ * Claims the device registry for an Apple account before a build records
330
+ * or sends anything at Apple: the first claim wins, atomically, and holds
331
+ * for good. A registry with no claim yet whose rows already name an account
332
+ * (any status) goes to the earliest of them, not to the caller. Answers the
333
+ * registry's account and whether it is `issuerId`'s; a build of another
334
+ * account registers nothing.
335
+ */
336
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
337
+ /**
338
+ * Records that a native build's .ipa lists these devices, one write per
339
+ * row: a row removed meanwhile is skipped.
340
+ */
341
+ markIosDevicesInBuild(input: {
342
+ readonly buildId: string;
343
+ readonly ids: readonly string[];
344
+ }): Promise<void>;
345
+ /**
346
+ * Deletes a device from the registry. Apple keeps it: a device enabled
347
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
348
+ * while it still has that status and requester, read in the same
349
+ * transaction, such as a request its owner withdraws. Null, with nothing
350
+ * deleted, for an unknown ID or a row that no longer matches.
351
+ */
352
+ deleteIosDevice(id: string, only?: {
353
+ readonly status?: IosDeviceStatus;
354
+ readonly requestedBy?: string;
355
+ }): Promise<IosDeviceRow | null>;
220
356
  }
221
357
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
358
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
@@ -16,7 +16,10 @@ const CHANNEL_ID = {
16
16
  * every database's migrator creates missing tables and then records the
17
17
  * version, and none of them changes an existing table, so changing one
18
18
  * needs a migration step of its own first. The schema fence answers 503 on
19
- * a database whose row differs, until it runs.
19
+ * a database whose row differs, until it runs. Before a version is released,
20
+ * its tables change in place in its own migration, and a database one of its
21
+ * prereleases migrated takes the same change by hand: the fence compares this
22
+ * row, not columns, so nothing reports it.
20
23
  */
21
24
  const HOT_UPDATER_SCHEMA_VERSION = "1.2.0";
22
25
  const bundles = require_schema.defineTable({
@@ -280,6 +283,21 @@ const channels = require_schema.defineTable({
280
283
  * or `versionCode`. `submitted_to`, `submitted_at_ms` and
281
284
  * `submitted_version` record the store track a build went to, when, and
282
285
  * the store's label of the build; they stay null for a build no store took.
286
+ * `is_store_build` is true on the build a person or a job says the store
287
+ * sells, and false on every other: deploys patch from it over the scope's
288
+ * newest build. The engine copies the scope key into `store_build_scope_key`
289
+ * for that build alone, so `byStoreBuild` holds one entry per scope at most,
290
+ * on every store, while any number of a scope's builds hold none.
291
+ * `is_sandbox` is true on a sandbox build, set when it registers and never
292
+ * changed, and `sandbox_url_scheme` is the URL scheme its artifact registers,
293
+ * which its preview links open; null on any other build, and on a sandbox
294
+ * build registered before the column, which registered the derived one.
295
+ * `export_method` is how an `.ipa` was exported, read from its profile when
296
+ * it registers and never changed; null on any other artifact, on an `.ipa`
297
+ * whose profile couldn't be read, and on one registered before the column.
298
+ * Boolean columns follow one rule: `is_*` for a fact about the row or
299
+ * `should_*` for an instruction to the client, never null; a unique index over
300
+ * the rows where one is true keys a derived slot, not the boolean.
283
301
  */
284
302
  const nativeBuilds = require_schema.defineTable({
285
303
  id: {
@@ -356,9 +374,30 @@ const nativeBuilds = require_schema.defineTable({
356
374
  type: "string",
357
375
  maxLength: 255,
358
376
  required: false
377
+ },
378
+ is_store_build: { type: "boolean" },
379
+ is_sandbox: { type: "boolean" },
380
+ sandbox_url_scheme: {
381
+ type: "string",
382
+ maxLength: 255,
383
+ ascii: true,
384
+ required: false
385
+ },
386
+ export_method: {
387
+ type: "string",
388
+ maxLength: 16,
389
+ required: false
359
390
  }
360
391
  }, {
361
392
  key: ["id"],
393
+ derived: {
394
+ /** The scope this build is the store build of; null on every other. */
395
+ store_build_scope_key: {
396
+ type: "string",
397
+ maxLength: 2048,
398
+ ascii: true,
399
+ compute: (row) => row.is_store_build ? row.scope_key : null
400
+ } },
362
401
  indexes: {
363
402
  byScope: {
364
403
  eq: ["scope_key"],
@@ -368,6 +407,11 @@ const nativeBuilds = require_schema.defineTable({
368
407
  eq: ["scope_key", "build_key"],
369
408
  sort: ["id"]
370
409
  },
410
+ byStoreBuild: {
411
+ eq: ["store_build_scope_key"],
412
+ sort: [],
413
+ unique: true
414
+ },
371
415
  byChannel: {
372
416
  eq: ["channel_id"],
373
417
  sort: ["id"],
@@ -379,6 +423,115 @@ const nativeBuilds = require_schema.defineTable({
379
423
  }
380
424
  }
381
425
  });
426
+ /**
427
+ * The iPhones a team asks to install ad hoc builds on. A row decides what the
428
+ * CLI registers with Apple, not what an export includes: Xcode's automatic ad
429
+ * hoc profile lists every device the Apple account has enabled. `status` is
430
+ * `pending` until someone approves it, `approved` until a build or
431
+ * `native-build devices add` registers it with Apple, then `registered`;
432
+ * declining or removing one deletes its row. `udid` is the UDID in lower case.
433
+ * `apple_issuer_id` is the App Store Connect issuer whose key registered it,
434
+ * set once: a build signed by another account never registers these rows.
435
+ * `apple_error` is Apple's refusal of the device, or why it stopped counting
436
+ * it, cleared by the next success. `build_id` is the newest native build whose
437
+ * .ipa the CLI checked lists it; deleting that build never touches the row.
438
+ * It holds personal data: a UDID, a name, and the emails of who asked and who
439
+ * approved, null for the CLI.
440
+ */
441
+ const iosDevices = require_schema.defineTable({
442
+ id: {
443
+ type: "string",
444
+ maxLength: 36
445
+ },
446
+ udid: {
447
+ type: "string",
448
+ maxLength: 40,
449
+ ascii: true,
450
+ unique: true
451
+ },
452
+ name: {
453
+ type: "string",
454
+ maxLength: 100
455
+ },
456
+ status: {
457
+ type: "string",
458
+ maxLength: 16
459
+ },
460
+ requested_by: {
461
+ type: "string",
462
+ maxLength: 320,
463
+ required: false
464
+ },
465
+ created_at_ms: { type: "integer" },
466
+ approved_by: {
467
+ type: "string",
468
+ maxLength: 320,
469
+ required: false
470
+ },
471
+ approved_at_ms: {
472
+ type: "integer",
473
+ required: false
474
+ },
475
+ registered_at_ms: {
476
+ type: "integer",
477
+ required: false
478
+ },
479
+ apple_issuer_id: {
480
+ type: "string",
481
+ maxLength: 64,
482
+ ascii: true,
483
+ required: false
484
+ },
485
+ apple_error: {
486
+ type: "string",
487
+ maxLength: 512,
488
+ required: false
489
+ },
490
+ build_id: {
491
+ type: "string",
492
+ maxLength: 36,
493
+ required: false
494
+ }
495
+ }, {
496
+ key: ["id"],
497
+ indexes: {
498
+ byStatus: {
499
+ eq: ["status"],
500
+ sort: ["id"]
501
+ },
502
+ all: {
503
+ eq: [],
504
+ sort: ["id"]
505
+ }
506
+ }
507
+ });
508
+ /**
509
+ * The Apple account the iOS device registry belongs to: one row, keyed
510
+ * `registry`, holding the App Store Connect issuer that first registered a
511
+ * device. A build claims it before it sends Apple anything, and its key makes
512
+ * the claim atomic on every store, so two builds of two accounts can't both
513
+ * spend a slot; another account's build then registers nothing. Removing
514
+ * devices never releases it.
515
+ */
516
+ const iosDeviceAccount = require_schema.defineTable({
517
+ id: {
518
+ type: "string",
519
+ maxLength: 16,
520
+ ascii: true
521
+ },
522
+ apple_issuer_id: {
523
+ type: "string",
524
+ maxLength: 64,
525
+ ascii: true
526
+ },
527
+ claimed_at_ms: { type: "integer" }
528
+ }, {
529
+ key: ["id"],
530
+ indexes: { all: {
531
+ eq: [],
532
+ sort: ["id"]
533
+ } }
534
+ });
382
535
  const coreSchema = {
383
536
  bundles,
384
537
  bundle_patches: bundlePatches,
@@ -396,7 +549,9 @@ const coreSchema = {
396
549
  sort: []
397
550
  } }
398
551
  }),
399
- native_builds: nativeBuilds
552
+ native_builds: nativeBuilds,
553
+ ios_devices: iosDevices,
554
+ ios_device_account: iosDeviceAccount
400
555
  };
401
556
  /** Core's module: always installed, never a plugin. */
402
557
  const coreModule = {