@hot-updater/plugin-core 1.2.0-rc.5 → 1.2.0-rc.50

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 (79) hide show
  1. package/dist/coreApi.d.cts +246 -10
  2. package/dist/coreApi.d.mts +246 -10
  3. package/dist/database/adapter.d.cts +12 -0
  4. package/dist/database/adapter.d.mts +12 -0
  5. package/dist/engine/core/schema.cjs +200 -5
  6. package/dist/engine/core/schema.d.cts +127 -1
  7. package/dist/engine/core/schema.d.mts +127 -1
  8. package/dist/engine/core/schema.mjs +200 -6
  9. package/dist/engine/createEngine.cjs +1 -2
  10. package/dist/engine/createEngine.d.cts +1 -6
  11. package/dist/engine/createEngine.d.mts +1 -6
  12. package/dist/engine/createEngine.mjs +1 -2
  13. package/dist/engine/database/aggregateBatching.cjs +87 -129
  14. package/dist/engine/database/aggregateBatching.mjs +87 -129
  15. package/dist/engine/database/database.cjs +1 -4
  16. package/dist/engine/database/database.mjs +1 -4
  17. package/dist/engine/database/engineTransaction.cjs +21 -1
  18. package/dist/engine/database/engineTransaction.d.cts +5 -1
  19. package/dist/engine/database/engineTransaction.d.mts +5 -1
  20. package/dist/engine/database/engineTransaction.mjs +21 -1
  21. package/dist/engine/database/kv/kvAdapter.cjs +80 -4
  22. package/dist/engine/database/kv/kvAdapter.mjs +80 -4
  23. package/dist/engine/database/resolveSchema.cjs +6 -3
  24. package/dist/engine/database/resolveSchema.mjs +6 -3
  25. package/dist/engine/database/sql/sqlAdapter.cjs +9 -4
  26. package/dist/engine/database/sql/sqlAdapter.mjs +9 -4
  27. package/dist/engine/database/sql/sqlSchema.cjs +24 -6
  28. package/dist/engine/database/sql/sqlSchema.d.cts +1 -1
  29. package/dist/engine/database/sql/sqlSchema.d.mts +1 -1
  30. package/dist/engine/database/sql/sqlSchema.mjs +24 -6
  31. package/dist/engine/db/coreDatabase.cjs +10 -5
  32. package/dist/engine/db/coreDatabase.d.cts +2 -1
  33. package/dist/engine/db/coreDatabase.d.mts +2 -1
  34. package/dist/engine/db/coreDatabase.mjs +10 -5
  35. package/dist/engine/db/engineMigrator.cjs +21 -16
  36. package/dist/engine/db/engineMigrator.mjs +22 -17
  37. package/dist/engine/db/engineSqlMigrator.cjs +53 -20
  38. package/dist/engine/db/engineSqlMigrator.d.cts +2 -0
  39. package/dist/engine/db/engineSqlMigrator.d.mts +2 -0
  40. package/dist/engine/db/engineSqlMigrator.mjs +55 -22
  41. package/dist/engine/db/schemaSettings.cjs +36 -5
  42. package/dist/engine/db/schemaSettings.d.cts +5 -2
  43. package/dist/engine/db/schemaSettings.d.mts +5 -2
  44. package/dist/engine/db/schemaSettings.mjs +36 -6
  45. package/dist/engine/db/settingsMigrator.cjs +92 -14
  46. package/dist/engine/db/settingsMigrator.d.cts +18 -8
  47. package/dist/engine/db/settingsMigrator.d.mts +18 -8
  48. package/dist/engine/db/settingsMigrator.mjs +89 -15
  49. package/dist/engine/db/sqlSchemaState.cjs +108 -0
  50. package/dist/engine/db/sqlSchemaState.mjs +104 -0
  51. package/dist/engine/db/types.d.cts +6 -0
  52. package/dist/engine/db/types.d.mts +6 -0
  53. package/dist/index.cjs +2 -8
  54. package/dist/index.d.cts +5 -6
  55. package/dist/index.d.mts +5 -6
  56. package/dist/index.mjs +3 -4
  57. package/dist/serverPlugin/coreReads.d.cts +10 -1
  58. package/dist/serverPlugin/coreReads.d.mts +10 -1
  59. package/dist/serverPlugin/definitions.d.cts +4 -0
  60. package/dist/serverPlugin/definitions.d.mts +4 -0
  61. package/dist/serverPlugin/schema.d.cts +4 -0
  62. package/dist/serverPlugin/schema.d.mts +4 -0
  63. package/dist/types/databaseConfig.d.cts +10 -20
  64. package/dist/types/databaseConfig.d.mts +10 -20
  65. package/dist/types/databaseRows.d.cts +70 -2
  66. package/dist/types/databaseRows.d.mts +70 -2
  67. package/dist/types/index.cjs +3 -0
  68. package/dist/types/index.d.cts +114 -56
  69. package/dist/types/index.d.mts +114 -56
  70. package/dist/types/index.mjs +3 -1
  71. package/dist/types/models.d.cts +9 -1
  72. package/dist/types/models.d.mts +9 -1
  73. package/dist/types/public.d.cts +3 -3
  74. package/dist/types/public.d.mts +3 -3
  75. package/package.json +3 -9
  76. package/dist/remoteBundleSigning.cjs +0 -357
  77. package/dist/remoteBundleSigning.d.cts +0 -38
  78. package/dist/remoteBundleSigning.d.mts +0 -38
  79. 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. */
@@ -141,18 +239,69 @@ interface HotUpdaterCoreApi {
141
239
  }): Promise<ReleaseRow[]>;
142
240
  getReleaseCatalogRow(scopeKey: string): Promise<ReleaseCatalogRow | null>;
143
241
  listReleaseCatalogs(input: KeysetInput): Promise<ReleaseCatalogRow[]>;
144
- listChannels(): Promise<ChannelRow[]>;
242
+ /**
243
+ * Up to `limit` scope keys that have releases, ascending after `after`,
244
+ * with or without a catalog row: one limit-1 seek per scope, so the reads
245
+ * grow with scopes, not with releases. Doctor walks them to find a scope
246
+ * whose catalog row was lost.
247
+ */
248
+ listReleaseScopeKeys(input: {
249
+ readonly after?: string;
250
+ readonly limit: number;
251
+ }): Promise<string[]>;
252
+ /**
253
+ * Every channel, by name. With `input`, one keyset page of them, whose
254
+ * cursor is the last channel's name.
255
+ */
256
+ listChannels(input?: KeysetInput): Promise<ChannelRow[]>;
257
+ /**
258
+ * The channels of these IDs, in their order, without the IDs no channel
259
+ * has: one batch read of their keys.
260
+ */
261
+ getChannels(ids: readonly string[]): Promise<ChannelRow[]>;
145
262
  findChannelByName(name: string): Promise<ChannelRow | null>;
146
263
  /** A native build by ID: one read of its key. */
147
264
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
265
  /**
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.
266
+ * The native build whose built-in bundle is `bundleId`, the MIN_BUNDLE_ID
267
+ * it compiled in, or null: one read of its unique index.
268
+ */
269
+ findNativeBuildByBuiltInBundle(bundleId: string): Promise<NativeBuildRow | null>;
270
+ /**
271
+ * The newest native build of a scope: the one registered last, in one read
272
+ * of its index. With `buildKey`, the newest of the scope registered with that
273
+ * native build key, also one read. With `storeBuild`, the scope's marked
274
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
275
+ * scope whose built-in bundle is older than that bundle: one read when the
276
+ * newest is, and then a page of 20 older builds per read until one is, when
277
+ * builds made after the bundle are in the way. It reads at most 5 such
278
+ * pages, and answers null when none of those 100 builds is older than the
279
+ * bundle, as when the scope has none. With `buildKey` too, only
280
+ * builds of that key. With `scope.sandbox`, sandbox builds on any channel;
281
+ * without it, never one. A sandbox build's built-in bundle is no patch
282
+ * base, so with `builtInOlderThan` a sandbox scope answers null without a
283
+ * read. With `artifactKind`, only a build of that kind, with any other
284
+ * option. Alone, it reads the scope's builds of that kind, so a newer
285
+ * `.app` doesn't hide the scope's `.ipa`: one read, and when that finds
286
+ * none, a second of the scope's newest, kept only when it is of the kind.
287
+ * A key-value store holds no index copy of this for a row written before
288
+ * it, so such a row is found only while it is its scope's newest.
152
289
  */
153
290
  findNativeBuild(scope: NativeBuildScope, options?: {
154
291
  readonly buildKey?: string;
292
+ readonly storeBuild?: true;
293
+ readonly builtInOlderThan?: string;
294
+ readonly artifactKind?: NativeBuildArtifactKind;
155
295
  }): Promise<NativeBuildRow | null>;
296
+ /**
297
+ * The newest build of the other install target of an iOS sandbox build's
298
+ * native code: its Simulator `.app` for a direct-install `.ipa`, or the
299
+ * reverse, of the same app ID, URL scheme and fingerprint or app version,
300
+ * on any channel. Null, with no read, for any other build, and for a store
301
+ * or store-marked build on either side. One read. The Console's build page
302
+ * offers it beside its install.
303
+ */
304
+ findNativeBuildSibling(build: NativeBuildRow): Promise<NativeBuildRow | null>;
156
305
  /**
157
306
  * One page of native builds, by ID: oldest or newest first. With
158
307
  * `channelId`, only the builds that embed that channel, also one read.
@@ -163,7 +312,9 @@ interface HotUpdaterCoreApi {
163
312
  /**
164
313
  * Writes each new bundle with its patches, and each release, with the next
165
314
  * catalog of each scope, in one transaction. A stored bundle's deployment
166
- * publishes a new release for it and writes no bundle.
315
+ * publishes a new release for it and writes no bundle. Like `updateBundle`,
316
+ * it refuses a patch from a sandbox build's built-in bundle: one read of
317
+ * each new bundle's patch base.
167
318
  */
168
319
  deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
169
320
  updateReleasePolicy(input: ReleaseTarget & {
@@ -186,7 +337,11 @@ interface HotUpdaterCoreApi {
186
337
  ensureChannel(name: string): Promise<ChannelRow>;
187
338
  /** Deletes a channel no release uses. */
188
339
  deleteChannel(id: string): Promise<ChannelDeleteResult>;
189
- /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
340
+ /**
341
+ * Changes a bundle's fields; `patches`, when given, replaces its patches.
342
+ * It refuses a new patch from a sandbox build's built-in bundle, which is
343
+ * no patch base: one read of each new patch's base.
344
+ */
190
345
  updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
191
346
  readonly patches?: Bundle["patches"];
192
347
  }): Promise<void>;
@@ -217,6 +372,87 @@ interface HotUpdaterCoreApi {
217
372
  * full bundles. Its artifact stays in storage for the caller to delete.
218
373
  */
219
374
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
375
+ /**
376
+ * Marks a build as what the store sells, replacing its scope's mark in one
377
+ * write, or clears the mark it holds. Running it again changes nothing. Null
378
+ * for an unknown ID. A sandbox build can't be marked.
379
+ */
380
+ markNativeBuild(id: string, mark: {
381
+ readonly storeBuild: boolean;
382
+ }): Promise<NativeBuildMarkResult | null>;
383
+ /**
384
+ * One page of the iOS device registry, by ID: oldest or newest first. With
385
+ * `status`, only the rows in it, also one read.
386
+ */
387
+ listIosDevices(input: KeysetInput & {
388
+ readonly status?: IosDeviceStatus;
389
+ }): Promise<IosDeviceRow[]>;
390
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
391
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
392
+ /**
393
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
394
+ * row unchanged, so nobody takes over another person's request.
395
+ */
396
+ requestIosDevice(input: {
397
+ readonly udid: string;
398
+ readonly name: string;
399
+ /** Who asks, or null for the CLI. */
400
+ readonly requestedBy: string | null;
401
+ }): Promise<IosDeviceRequestResult>;
402
+ /**
403
+ * Approves a pending device, so the next ad hoc build registers it with
404
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
405
+ * Null for an unknown ID.
406
+ */
407
+ approveIosDevice(id: string, input: {
408
+ readonly name?: string;
409
+ /** Who approves: a Console email, or null for the CLI. */
410
+ readonly approvedBy: string | null;
411
+ }): Promise<IosDeviceRow | null>;
412
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
413
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
414
+ /**
415
+ * Records what Apple said of a device, only over the row the caller read
416
+ * (`seen`) and only for the account that registered it: null, with nothing
417
+ * written, for a row that changed, is gone, or belongs to another issuer.
418
+ * It never creates a row.
419
+ */
420
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
421
+ /**
422
+ * Claims the device registry for an Apple account before a build records
423
+ * or sends anything at Apple: the first claim wins, atomically, and holds
424
+ * for good. A registry with no claim yet whose rows already name an account
425
+ * (any status) goes to the earliest of them, not to the caller. Answers the
426
+ * registry's account and whether it is `issuerId`'s; a build of another
427
+ * account registers nothing.
428
+ */
429
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
430
+ /**
431
+ * The Apple account the device registry belongs to, read without claiming
432
+ * it: the claimed account, or with no claim yet, the one
433
+ * `claimIosDeviceAccount` would give it, the earliest its rows name. Null
434
+ * while nothing names one, when the first claim takes it.
435
+ */
436
+ findIosDeviceAccount(): Promise<IosDeviceAccount | null>;
437
+ /**
438
+ * Records that a native build's .ipa lists these devices, one write per
439
+ * row: a row removed meanwhile is skipped.
440
+ */
441
+ markIosDevicesInBuild(input: {
442
+ readonly buildId: string;
443
+ readonly ids: readonly string[];
444
+ }): Promise<void>;
445
+ /**
446
+ * Deletes a device from the registry. Apple keeps it: a device enabled
447
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
448
+ * while it still has that status and requester, read in the same
449
+ * transaction, such as a request its owner withdraws. Null, with nothing
450
+ * deleted, for an unknown ID or a row that no longer matches.
451
+ */
452
+ deleteIosDevice(id: string, only?: {
453
+ readonly status?: IosDeviceStatus;
454
+ readonly requestedBy?: string;
455
+ }): Promise<IosDeviceRow | null>;
220
456
  }
221
457
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
458
+ 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. */
@@ -141,18 +239,69 @@ interface HotUpdaterCoreApi {
141
239
  }): Promise<ReleaseRow[]>;
142
240
  getReleaseCatalogRow(scopeKey: string): Promise<ReleaseCatalogRow | null>;
143
241
  listReleaseCatalogs(input: KeysetInput): Promise<ReleaseCatalogRow[]>;
144
- listChannels(): Promise<ChannelRow[]>;
242
+ /**
243
+ * Up to `limit` scope keys that have releases, ascending after `after`,
244
+ * with or without a catalog row: one limit-1 seek per scope, so the reads
245
+ * grow with scopes, not with releases. Doctor walks them to find a scope
246
+ * whose catalog row was lost.
247
+ */
248
+ listReleaseScopeKeys(input: {
249
+ readonly after?: string;
250
+ readonly limit: number;
251
+ }): Promise<string[]>;
252
+ /**
253
+ * Every channel, by name. With `input`, one keyset page of them, whose
254
+ * cursor is the last channel's name.
255
+ */
256
+ listChannels(input?: KeysetInput): Promise<ChannelRow[]>;
257
+ /**
258
+ * The channels of these IDs, in their order, without the IDs no channel
259
+ * has: one batch read of their keys.
260
+ */
261
+ getChannels(ids: readonly string[]): Promise<ChannelRow[]>;
145
262
  findChannelByName(name: string): Promise<ChannelRow | null>;
146
263
  /** A native build by ID: one read of its key. */
147
264
  getNativeBuild(id: string): Promise<NativeBuildRow | null>;
148
265
  /**
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.
266
+ * The native build whose built-in bundle is `bundleId`, the MIN_BUNDLE_ID
267
+ * it compiled in, or null: one read of its unique index.
268
+ */
269
+ findNativeBuildByBuiltInBundle(bundleId: string): Promise<NativeBuildRow | null>;
270
+ /**
271
+ * The newest native build of a scope: the one registered last, in one read
272
+ * of its index. With `buildKey`, the newest of the scope registered with that
273
+ * native build key, also one read. With `storeBuild`, the scope's marked
274
+ * build or null, also one read. With `builtInOlderThan`, the newest of the
275
+ * scope whose built-in bundle is older than that bundle: one read when the
276
+ * newest is, and then a page of 20 older builds per read until one is, when
277
+ * builds made after the bundle are in the way. It reads at most 5 such
278
+ * pages, and answers null when none of those 100 builds is older than the
279
+ * bundle, as when the scope has none. With `buildKey` too, only
280
+ * builds of that key. With `scope.sandbox`, sandbox builds on any channel;
281
+ * without it, never one. A sandbox build's built-in bundle is no patch
282
+ * base, so with `builtInOlderThan` a sandbox scope answers null without a
283
+ * read. With `artifactKind`, only a build of that kind, with any other
284
+ * option. Alone, it reads the scope's builds of that kind, so a newer
285
+ * `.app` doesn't hide the scope's `.ipa`: one read, and when that finds
286
+ * none, a second of the scope's newest, kept only when it is of the kind.
287
+ * A key-value store holds no index copy of this for a row written before
288
+ * it, so such a row is found only while it is its scope's newest.
152
289
  */
153
290
  findNativeBuild(scope: NativeBuildScope, options?: {
154
291
  readonly buildKey?: string;
292
+ readonly storeBuild?: true;
293
+ readonly builtInOlderThan?: string;
294
+ readonly artifactKind?: NativeBuildArtifactKind;
155
295
  }): Promise<NativeBuildRow | null>;
296
+ /**
297
+ * The newest build of the other install target of an iOS sandbox build's
298
+ * native code: its Simulator `.app` for a direct-install `.ipa`, or the
299
+ * reverse, of the same app ID, URL scheme and fingerprint or app version,
300
+ * on any channel. Null, with no read, for any other build, and for a store
301
+ * or store-marked build on either side. One read. The Console's build page
302
+ * offers it beside its install.
303
+ */
304
+ findNativeBuildSibling(build: NativeBuildRow): Promise<NativeBuildRow | null>;
156
305
  /**
157
306
  * One page of native builds, by ID: oldest or newest first. With
158
307
  * `channelId`, only the builds that embed that channel, also one read.
@@ -163,7 +312,9 @@ interface HotUpdaterCoreApi {
163
312
  /**
164
313
  * Writes each new bundle with its patches, and each release, with the next
165
314
  * catalog of each scope, in one transaction. A stored bundle's deployment
166
- * publishes a new release for it and writes no bundle.
315
+ * publishes a new release for it and writes no bundle. Like `updateBundle`,
316
+ * it refuses a patch from a sandbox build's built-in bundle: one read of
317
+ * each new bundle's patch base.
167
318
  */
168
319
  deploy(deployments: readonly Deployment[]): Promise<ReleaseCatalogMutationResult[]>;
169
320
  updateReleasePolicy(input: ReleaseTarget & {
@@ -186,7 +337,11 @@ interface HotUpdaterCoreApi {
186
337
  ensureChannel(name: string): Promise<ChannelRow>;
187
338
  /** Deletes a channel no release uses. */
188
339
  deleteChannel(id: string): Promise<ChannelDeleteResult>;
189
- /** Changes a bundle's fields; `patches`, when given, replaces its patches. */
340
+ /**
341
+ * Changes a bundle's fields; `patches`, when given, replaces its patches.
342
+ * It refuses a new patch from a sandbox build's built-in bundle, which is
343
+ * no patch base: one read of each new patch's base.
344
+ */
190
345
  updateBundle(id: string, update: Partial<Omit<Bundle, "id" | "patches">> & {
191
346
  readonly patches?: Bundle["patches"];
192
347
  }): Promise<void>;
@@ -217,6 +372,87 @@ interface HotUpdaterCoreApi {
217
372
  * full bundles. Its artifact stays in storage for the caller to delete.
218
373
  */
219
374
  deleteNativeBuild(id: string): Promise<NativeBuildDeleteResult>;
375
+ /**
376
+ * Marks a build as what the store sells, replacing its scope's mark in one
377
+ * write, or clears the mark it holds. Running it again changes nothing. Null
378
+ * for an unknown ID. A sandbox build can't be marked.
379
+ */
380
+ markNativeBuild(id: string, mark: {
381
+ readonly storeBuild: boolean;
382
+ }): Promise<NativeBuildMarkResult | null>;
383
+ /**
384
+ * One page of the iOS device registry, by ID: oldest or newest first. With
385
+ * `status`, only the rows in it, also one read.
386
+ */
387
+ listIosDevices(input: KeysetInput & {
388
+ readonly status?: IosDeviceStatus;
389
+ }): Promise<IosDeviceRow[]>;
390
+ /** The registry's row of a UDID, in either case: one read. Null for none. */
391
+ findIosDevice(udid: string): Promise<IosDeviceRow | null>;
392
+ /**
393
+ * Adds a UDID to the registry as `pending`. A UDID already there keeps its
394
+ * row unchanged, so nobody takes over another person's request.
395
+ */
396
+ requestIosDevice(input: {
397
+ readonly udid: string;
398
+ readonly name: string;
399
+ /** Who asks, or null for the CLI. */
400
+ readonly requestedBy: string | null;
401
+ }): Promise<IosDeviceRequestResult>;
402
+ /**
403
+ * Approves a pending device, so the next ad hoc build registers it with
404
+ * Apple. A device past `pending` stays as it is. With `name`, renames it.
405
+ * Null for an unknown ID.
406
+ */
407
+ approveIosDevice(id: string, input: {
408
+ readonly name?: string;
409
+ /** Who approves: a Console email, or null for the CLI. */
410
+ readonly approvedBy: string | null;
411
+ }): Promise<IosDeviceRow | null>;
412
+ /** Renames a device in the registry, whatever its status. Null for an unknown ID. */
413
+ renameIosDevice(id: string, name: string): Promise<IosDeviceRow | null>;
414
+ /**
415
+ * Records what Apple said of a device, only over the row the caller read
416
+ * (`seen`) and only for the account that registered it: null, with nothing
417
+ * written, for a row that changed, is gone, or belongs to another issuer.
418
+ * It never creates a row.
419
+ */
420
+ recordIosDeviceOutcome(input: IosDeviceOutcomeInput): Promise<IosDeviceRow | null>;
421
+ /**
422
+ * Claims the device registry for an Apple account before a build records
423
+ * or sends anything at Apple: the first claim wins, atomically, and holds
424
+ * for good. A registry with no claim yet whose rows already name an account
425
+ * (any status) goes to the earliest of them, not to the caller. Answers the
426
+ * registry's account and whether it is `issuerId`'s; a build of another
427
+ * account registers nothing.
428
+ */
429
+ claimIosDeviceAccount(issuerId: string): Promise<IosDeviceAccountClaim>;
430
+ /**
431
+ * The Apple account the device registry belongs to, read without claiming
432
+ * it: the claimed account, or with no claim yet, the one
433
+ * `claimIosDeviceAccount` would give it, the earliest its rows name. Null
434
+ * while nothing names one, when the first claim takes it.
435
+ */
436
+ findIosDeviceAccount(): Promise<IosDeviceAccount | null>;
437
+ /**
438
+ * Records that a native build's .ipa lists these devices, one write per
439
+ * row: a row removed meanwhile is skipped.
440
+ */
441
+ markIosDevicesInBuild(input: {
442
+ readonly buildId: string;
443
+ readonly ids: readonly string[];
444
+ }): Promise<void>;
445
+ /**
446
+ * Deletes a device from the registry. Apple keeps it: a device enabled
447
+ * there stays in new ad hoc builds. With `only`, it deletes the row only
448
+ * while it still has that status and requester, read in the same
449
+ * transaction, such as a request its owner withdraws. Null, with nothing
450
+ * deleted, for an unknown ID or a row that no longer matches.
451
+ */
452
+ deleteIosDevice(id: string, only?: {
453
+ readonly status?: IosDeviceStatus;
454
+ readonly requestedBy?: string;
455
+ }): Promise<IosDeviceRow | null>;
220
456
  }
221
457
  //#endregion
222
- export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
458
+ export { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, IosDeviceAccount, IosDeviceAccountClaim, IosDeviceOutcome, IosDeviceOutcomeInput, IosDeviceRequestResult, KeysetInput, NativeBuildDistribution, NativeBuildRegistration, NativeBuildSandboxScope, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment };
@@ -156,6 +156,18 @@ interface DatabaseAdapter {
156
156
  /** Called only by migration tooling, such as `hot-updater db migrate`. */
157
157
  readonly migrations?: {
158
158
  apply(tables: readonly PhysicalTable[]): Promise<void>;
159
+ /**
160
+ * For a store that keeps index items of its own: writes the items of
161
+ * `index` that rows of `table` lack, or with `dryRun` only counts them,
162
+ * and returns how many rows lacked one. Migrations call it for an index
163
+ * declared on a table rows of a released schema were written to, such
164
+ * as core's `releases.scopes`, whose server may still write rows
165
+ * without the index's items. A store whose indexes cover every row
166
+ * itself, such as SQL or MongoDB, leaves it out.
167
+ */
168
+ fillIndex?(table: PhysicalTable, index: string, options?: {
169
+ readonly dryRun?: boolean;
170
+ }): Promise<number>;
159
171
  };
160
172
  dispose?(): Promise<void>;
161
173
  }