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

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 +148 -6
  2. package/dist/coreApi.d.mts +148 -6
  3. package/dist/engine/core/schema.cjs +167 -2
  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 +167 -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 +69 -2
  28. package/dist/types/databaseRows.d.mts +69 -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,28 @@ 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;
109
+ /**
110
+ * The app version the artifact reports, its `CFBundleShortVersionString`
111
+ * or `versionName`, whatever the update strategy; null or left out when it
112
+ * wasn't read.
113
+ */
114
+ readonly nativeAppVersion?: string | null;
91
115
  readonly artifact: {
92
116
  readonly kind: NativeBuildArtifactKind;
93
117
  readonly storageUri: string;
@@ -104,6 +128,43 @@ type NativeBuildRegistration = NativeBuildScope & {
104
128
  readonly metadata?: DatabaseBundleMetadata;
105
129
  };
106
130
  };
131
+ /**
132
+ * What a build or `native-build devices add` learned from Apple about one
133
+ * registry row: Apple has it enabled (`registered`), refused to add it
134
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
135
+ * row says it registered (`missing`).
136
+ */
137
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
138
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
139
+ interface IosDeviceOutcomeInput {
140
+ readonly id: string;
141
+ /**
142
+ * The row as the caller read it before asking Apple: a row that changed
143
+ * since, such as one removed and requested again, is left alone.
144
+ */
145
+ readonly seen: {
146
+ readonly status: IosDeviceStatus;
147
+ readonly approvedAtMs: number | null;
148
+ };
149
+ /** The App Store Connect issuer of the key that asked Apple. */
150
+ readonly issuerId: string;
151
+ readonly outcome: IosDeviceOutcome;
152
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
153
+ readonly reason?: string;
154
+ }
155
+ /** The device registry's Apple account, after a build tried to claim it. */
156
+ interface IosDeviceAccountClaim {
157
+ /** The App Store Connect issuer the registry belongs to. */
158
+ readonly issuerId: string;
159
+ /** Whether that is the issuer that asked: false means another account's. */
160
+ readonly claimed: boolean;
161
+ }
162
+ /** A device request's row, and whether the request created it. */
163
+ interface IosDeviceRequestResult {
164
+ readonly device: IosDeviceRow;
165
+ /** False when the UDID was already in the registry, whose row is unchanged. */
166
+ readonly created: boolean;
167
+ }
107
168
  interface ReleaseTarget {
108
169
  readonly releaseId: string;
109
170
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +207,19 @@ interface HotUpdaterCoreApi {
146
207
  /** A native build by ID: one read of its key. */
147
208
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
209
  /**
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.
210
+ * The newest native build of a scope: the one registered last, in one read
211
+ * of its index. With `buildKey`, the newest of the scope registered with that
212
+ * native build key, also one read. With `storeBuild`, the scope's marked
213
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
214
+ * scope whose built-in bundle is older than that bundle: one read when the
215
+ * newest is, and then a page of older builds per read until one is, when
216
+ * builds made after the bundle are in the way. With `buildKey` too, only
217
+ * builds of that key.
152
218
  */
153
219
  findNativeBuild(scope: NativeBuildScope, options?: {
154
220
  readonly buildKey?: string;
221
+ readonly storeBuild?: true;
222
+ readonly builtInOlderThan?: string;
155
223
  }): Promise<NativeBuildRow | null>;
156
224
  /**
157
225
  * One page of native builds, by ID: oldest or newest first. With
@@ -217,6 +285,80 @@ interface HotUpdaterCoreApi {
217
285
  * full bundles. Its artifact stays in storage for the caller to delete.
218
286
  */
219
287
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
288
+ /**
289
+ * Marks a build as what the store sells, replacing its scope's mark in one
290
+ * write, or clears the mark it holds. Running it again changes nothing. Null
291
+ * for an unknown ID. A sandbox build can't be marked.
292
+ */
293
+ markNativeBuild(id: string, mark: {
294
+ readonly storeBuild: boolean;
295
+ }): Promise<NativeBuildMarkResult | null>;
296
+ /**
297
+ * One page of the iOS device registry, by ID: oldest or newest first. With
298
+ * `status`, only the rows in it, also one read.
299
+ */
300
+ listIosDevices(input: KeysetInput & {
301
+ readonly status?: IosDeviceStatus;
302
+ }): Promise<IosDeviceRow[]>;
303
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
304
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
305
+ /**
306
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
307
+ * row unchanged, so nobody takes over another person's request.
308
+ */
309
+ requestIosDevice(input: {
310
+ readonly udid: string;
311
+ readonly name: string;
312
+ /** Who asks, or null for the CLI. */
313
+ readonly requestedBy: string | null;
314
+ }): Promise<IosDeviceRequestResult>;
315
+ /**
316
+ * Approves a pending device, so the next ad hoc build registers it with
317
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
318
+ * Null for an unknown ID.
319
+ */
320
+ approveIosDevice(id: string, input: {
321
+ readonly name?: string;
322
+ /** Who approves: a Console email, or null for the CLI. */
323
+ readonly approvedBy: string | null;
324
+ }): Promise<IosDeviceRow | null>;
325
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
326
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
327
+ /**
328
+ * Records what Apple said of a device, only over the row the caller read
329
+ * (`seen`) and only for the account that registered it: null, with nothing
330
+ * written, for a row that changed, is gone, or belongs to another issuer.
331
+ * It never creates a row.
332
+ */
333
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
334
+ /**
335
+ * Claims the device registry for an Apple account before a build records
336
+ * or sends anything at Apple: the first claim wins, atomically, and holds
337
+ * for good. A registry with no claim yet whose rows already name an account
338
+ * (any status) goes to the earliest of them, not to the caller. Answers the
339
+ * registry's account and whether it is `issuerId`'s; a build of another
340
+ * account registers nothing.
341
+ */
342
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
343
+ /**
344
+ * Records that a native build's .ipa lists these devices, one write per
345
+ * row: a row removed meanwhile is skipped.
346
+ */
347
+ markIosDevicesInBuild(input: {
348
+ readonly buildId: string;
349
+ readonly ids: readonly string[];
350
+ }): Promise<void>;
351
+ /**
352
+ * Deletes a device from the registry. Apple keeps it: a device enabled
353
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
354
+ * while it still has that status and requester, read in the same
355
+ * transaction, such as a request its owner withdraws. Null, with nothing
356
+ * deleted, for an unknown ID or a row that no longer matches.
357
+ */
358
+ deleteIosDevice(id: string, only?: {
359
+ readonly status?: IosDeviceStatus;
360
+ readonly requestedBy?: string;
361
+ }): Promise<IosDeviceRow | null>;
220
362
  }
221
363
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
364
+ 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,28 @@ 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;
109
+ /**
110
+ * The app version the artifact reports, its `CFBundleShortVersionString`
111
+ * or `versionName`, whatever the update strategy; null or left out when it
112
+ * wasn't read.
113
+ */
114
+ readonly nativeAppVersion?: string | null;
91
115
  readonly artifact: {
92
116
  readonly kind: NativeBuildArtifactKind;
93
117
  readonly storageUri: string;
@@ -104,6 +128,43 @@ type NativeBuildRegistration = NativeBuildScope & {
104
128
  readonly metadata?: DatabaseBundleMetadata;
105
129
  };
106
130
  };
131
+ /**
132
+ * What a build or `native-build devices add` learned from Apple about one
133
+ * registry row: Apple has it enabled (`registered`), refused to add it
134
+ * (`refused`), has it disabled (`disabled`), or no longer lists a device the
135
+ * row says it registered (`missing`).
136
+ */
137
+ type IosDeviceOutcome = "registered" | "refused" | "disabled" | "missing";
138
+ /** A device registry row's outcome at Apple, written only over the row the caller read. */
139
+ interface IosDeviceOutcomeInput {
140
+ readonly id: string;
141
+ /**
142
+ * The row as the caller read it before asking Apple: a row that changed
143
+ * since, such as one removed and requested again, is left alone.
144
+ */
145
+ readonly seen: {
146
+ readonly status: IosDeviceStatus;
147
+ readonly approvedAtMs: number | null;
148
+ };
149
+ /** The App Store Connect issuer of the key that asked Apple. */
150
+ readonly issuerId: string;
151
+ readonly outcome: IosDeviceOutcome;
152
+ /** Apple's words for `refused`, kept as the row's `apple_error`. */
153
+ readonly reason?: string;
154
+ }
155
+ /** The device registry's Apple account, after a build tried to claim it. */
156
+ interface IosDeviceAccountClaim {
157
+ /** The App Store Connect issuer the registry belongs to. */
158
+ readonly issuerId: string;
159
+ /** Whether that is the issuer that asked: false means another account's. */
160
+ readonly claimed: boolean;
161
+ }
162
+ /** A device request's row, and whether the request created it. */
163
+ interface IosDeviceRequestResult {
164
+ readonly device: IosDeviceRow;
165
+ /** False when the UDID was already in the registry, whose row is unchanged. */
166
+ readonly created: boolean;
167
+ }
107
168
  interface ReleaseTarget {
108
169
  readonly releaseId: string;
109
170
  /** Refuses the change when the release is at another revision. */
@@ -146,12 +207,19 @@ interface HotUpdaterCoreApi {
146
207
  /** A native build by ID: one read of its key. */
147
208
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
209
  /**
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.
210
+ * The newest native build of a scope: the one registered last, in one read
211
+ * of its index. With `buildKey`, the newest of the scope registered with that
212
+ * native build key, also one read. With `storeBuild`, the scope's marked
213
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
214
+ * scope whose built-in bundle is older than that bundle: one read when the
215
+ * newest is, and then a page of older builds per read until one is, when
216
+ * builds made after the bundle are in the way. With `buildKey` too, only
217
+ * builds of that key.
152
218
  */
153
219
  findNativeBuild(scope: NativeBuildScope, options?: {
154
220
  readonly buildKey?: string;
221
+ readonly storeBuild?: true;
222
+ readonly builtInOlderThan?: string;
155
223
  }): Promise<NativeBuildRow | null>;
156
224
  /**
157
225
  * One page of native builds, by ID: oldest or newest first. With
@@ -217,6 +285,80 @@ interface HotUpdaterCoreApi {
217
285
  * full bundles. Its artifact stays in storage for the caller to delete.
218
286
  */
219
287
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
288
+ /**
289
+ * Marks a build as what the store sells, replacing its scope's mark in one
290
+ * write, or clears the mark it holds. Running it again changes nothing. Null
291
+ * for an unknown ID. A sandbox build can't be marked.
292
+ */
293
+ markNativeBuild(id: string, mark: {
294
+ readonly storeBuild: boolean;
295
+ }): Promise<NativeBuildMarkResult | null>;
296
+ /**
297
+ * One page of the iOS device registry, by ID: oldest or newest first. With
298
+ * `status`, only the rows in it, also one read.
299
+ */
300
+ listIosDevices(input: KeysetInput & {
301
+ readonly status?: IosDeviceStatus;
302
+ }): Promise<IosDeviceRow[]>;
303
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
304
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
305
+ /**
306
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
307
+ * row unchanged, so nobody takes over another person's request.
308
+ */
309
+ requestIosDevice(input: {
310
+ readonly udid: string;
311
+ readonly name: string;
312
+ /** Who asks, or null for the CLI. */
313
+ readonly requestedBy: string | null;
314
+ }): Promise<IosDeviceRequestResult>;
315
+ /**
316
+ * Approves a pending device, so the next ad hoc build registers it with
317
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
318
+ * Null for an unknown ID.
319
+ */
320
+ approveIosDevice(id: string, input: {
321
+ readonly name?: string;
322
+ /** Who approves: a Console email, or null for the CLI. */
323
+ readonly approvedBy: string | null;
324
+ }): Promise<IosDeviceRow | null>;
325
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
326
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
327
+ /**
328
+ * Records what Apple said of a device, only over the row the caller read
329
+ * (`seen`) and only for the account that registered it: null, with nothing
330
+ * written, for a row that changed, is gone, or belongs to another issuer.
331
+ * It never creates a row.
332
+ */
333
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
334
+ /**
335
+ * Claims the device registry for an Apple account before a build records
336
+ * or sends anything at Apple: the first claim wins, atomically, and holds
337
+ * for good. A registry with no claim yet whose rows already name an account
338
+ * (any status) goes to the earliest of them, not to the caller. Answers the
339
+ * registry's account and whether it is `issuerId`'s; a build of another
340
+ * account registers nothing.
341
+ */
342
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
343
+ /**
344
+ * Records that a native build's .ipa lists these devices, one write per
345
+ * row: a row removed meanwhile is skipped.
346
+ */
347
+ markIosDevicesInBuild(input: {
348
+ readonly buildId: string;
349
+ readonly ids: readonly string[];
350
+ }): Promise<void>;
351
+ /**
352
+ * Deletes a device from the registry. Apple keeps it: a device enabled
353
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
354
+ * while it still has that status and requester, read in the same
355
+ * transaction, such as a request its owner withdraws. Null, with nothing
356
+ * deleted, for an unknown ID or a row that no longer matches.
357
+ */
358
+ deleteIosDevice(id: string, only?: {
359
+ readonly status?: IosDeviceStatus;
360
+ readonly requestedBy?: string;
361
+ }): Promise<IosDeviceRow | null>;
220
362
  }
221
363
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
364
+ 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,27 @@ 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
+ * `native_app_version` is the app version the artifact itself reports, its
299
+ * `CFBundleShortVersionString` or `versionName`, read from the artifact when
300
+ * it registers and never changed, whatever the update strategy; `app_version`
301
+ * stays the version OTAs target, null on a fingerprint build. It is null
302
+ * when the artifact's can't be read, and on a build registered before the
303
+ * column.
304
+ * Boolean columns follow one rule: `is_*` for a fact about the row or
305
+ * `should_*` for an instruction to the client, never null; a unique index over
306
+ * the rows where one is true keys a derived slot, not the boolean.
283
307
  */
284
308
  const nativeBuilds = require_schema.defineTable({
285
309
  id: {
@@ -356,9 +380,34 @@ const nativeBuilds = require_schema.defineTable({
356
380
  type: "string",
357
381
  maxLength: 255,
358
382
  required: false
383
+ },
384
+ is_store_build: { type: "boolean" },
385
+ is_sandbox: { type: "boolean" },
386
+ sandbox_url_scheme: {
387
+ type: "string",
388
+ maxLength: 255,
389
+ ascii: true,
390
+ required: false
391
+ },
392
+ export_method: {
393
+ type: "string",
394
+ maxLength: 16,
395
+ required: false
396
+ },
397
+ native_app_version: {
398
+ type: "string",
399
+ required: false
359
400
  }
360
401
  }, {
361
402
  key: ["id"],
403
+ derived: {
404
+ /** The scope this build is the store build of; null on every other. */
405
+ store_build_scope_key: {
406
+ type: "string",
407
+ maxLength: 2048,
408
+ ascii: true,
409
+ compute: (row) => row.is_store_build ? row.scope_key : null
410
+ } },
362
411
  indexes: {
363
412
  byScope: {
364
413
  eq: ["scope_key"],
@@ -368,6 +417,11 @@ const nativeBuilds = require_schema.defineTable({
368
417
  eq: ["scope_key", "build_key"],
369
418
  sort: ["id"]
370
419
  },
420
+ byStoreBuild: {
421
+ eq: ["store_build_scope_key"],
422
+ sort: [],
423
+ unique: true
424
+ },
371
425
  byChannel: {
372
426
  eq: ["channel_id"],
373
427
  sort: ["id"],
@@ -379,6 +433,115 @@ const nativeBuilds = require_schema.defineTable({
379
433
  }
380
434
  }
381
435
  });
436
+ /**
437
+ * The iPhones a team asks to install ad hoc builds on. A row decides what the
438
+ * CLI registers with Apple, not what an export includes: Xcode's automatic ad
439
+ * hoc profile lists every device the Apple account has enabled. `status` is
440
+ * `pending` until someone approves it, `approved` until a build or
441
+ * `native-build devices add` registers it with Apple, then `registered`;
442
+ * declining or removing one deletes its row. `udid` is the UDID in lower case.
443
+ * `apple_issuer_id` is the App Store Connect issuer whose key registered it,
444
+ * set once: a build signed by another account never registers these rows.
445
+ * `apple_error` is Apple's refusal of the device, or why it stopped counting
446
+ * it, cleared by the next success. `build_id` is the newest native build whose
447
+ * .ipa the CLI checked lists it; deleting that build never touches the row.
448
+ * It holds personal data: a UDID, a name, and the emails of who asked and who
449
+ * approved, null for the CLI.
450
+ */
451
+ const iosDevices = require_schema.defineTable({
452
+ id: {
453
+ type: "string",
454
+ maxLength: 36
455
+ },
456
+ udid: {
457
+ type: "string",
458
+ maxLength: 40,
459
+ ascii: true,
460
+ unique: true
461
+ },
462
+ name: {
463
+ type: "string",
464
+ maxLength: 100
465
+ },
466
+ status: {
467
+ type: "string",
468
+ maxLength: 16
469
+ },
470
+ requested_by: {
471
+ type: "string",
472
+ maxLength: 320,
473
+ required: false
474
+ },
475
+ created_at_ms: { type: "integer" },
476
+ approved_by: {
477
+ type: "string",
478
+ maxLength: 320,
479
+ required: false
480
+ },
481
+ approved_at_ms: {
482
+ type: "integer",
483
+ required: false
484
+ },
485
+ registered_at_ms: {
486
+ type: "integer",
487
+ required: false
488
+ },
489
+ apple_issuer_id: {
490
+ type: "string",
491
+ maxLength: 64,
492
+ ascii: true,
493
+ required: false
494
+ },
495
+ apple_error: {
496
+ type: "string",
497
+ maxLength: 512,
498
+ required: false
499
+ },
500
+ build_id: {
501
+ type: "string",
502
+ maxLength: 36,
503
+ required: false
504
+ }
505
+ }, {
506
+ key: ["id"],
507
+ indexes: {
508
+ byStatus: {
509
+ eq: ["status"],
510
+ sort: ["id"]
511
+ },
512
+ all: {
513
+ eq: [],
514
+ sort: ["id"]
515
+ }
516
+ }
517
+ });
518
+ /**
519
+ * The Apple account the iOS device registry belongs to: one row, keyed
520
+ * `registry`, holding the App Store Connect issuer that first registered a
521
+ * device. A build claims it before it sends Apple anything, and its key makes
522
+ * the claim atomic on every store, so two builds of two accounts can't both
523
+ * spend a slot; another account's build then registers nothing. Removing
524
+ * devices never releases it.
525
+ */
526
+ const iosDeviceAccount = require_schema.defineTable({
527
+ id: {
528
+ type: "string",
529
+ maxLength: 16,
530
+ ascii: true
531
+ },
532
+ apple_issuer_id: {
533
+ type: "string",
534
+ maxLength: 64,
535
+ ascii: true
536
+ },
537
+ claimed_at_ms: { type: "integer" }
538
+ }, {
539
+ key: ["id"],
540
+ indexes: { all: {
541
+ eq: [],
542
+ sort: ["id"]
543
+ } }
544
+ });
382
545
  const coreSchema = {
383
546
  bundles,
384
547
  bundle_patches: bundlePatches,
@@ -396,7 +559,9 @@ const coreSchema = {
396
559
  sort: []
397
560
  } }
398
561
  }),
399
- native_builds: nativeBuilds
562
+ native_builds: nativeBuilds,
563
+ ios_devices: iosDevices,
564
+ ios_device_account: iosDeviceAccount
400
565
  };
401
566
  /** Core's module: always installed, never a plugin. */
402
567
  const coreModule = {