@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
@@ -385,7 +385,30 @@ declare const coreSchema: {
385
385
  readonly maxLength: 255;
386
386
  readonly required: false;
387
387
  };
388
- }, {}, {
388
+ readonly is_store_build: {
389
+ readonly type: "boolean";
390
+ };
391
+ readonly is_sandbox: {
392
+ readonly type: "boolean";
393
+ };
394
+ readonly sandbox_url_scheme: {
395
+ readonly type: "string";
396
+ readonly maxLength: 255;
397
+ readonly ascii: true;
398
+ readonly required: false;
399
+ };
400
+ readonly export_method: {
401
+ readonly type: "string";
402
+ readonly maxLength: 16;
403
+ readonly required: false;
404
+ };
405
+ readonly native_app_version: {
406
+ readonly type: "string";
407
+ readonly required: false;
408
+ };
409
+ }, {
410
+ store_build_scope_key: "string";
411
+ }, {
389
412
  readonly byScope: {
390
413
  readonly eq: readonly ["scope_key"];
391
414
  readonly sort: readonly ["id"];
@@ -394,6 +417,11 @@ declare const coreSchema: {
394
417
  readonly eq: readonly ["scope_key", "build_key"];
395
418
  readonly sort: readonly ["id"];
396
419
  };
420
+ readonly byStoreBuild: {
421
+ readonly eq: readonly ["store_build_scope_key"];
422
+ readonly sort: readonly [];
423
+ readonly unique: true;
424
+ };
397
425
  readonly byChannel: {
398
426
  readonly eq: readonly ["channel_id"];
399
427
  readonly sort: readonly ["id"];
@@ -406,6 +434,92 @@ declare const coreSchema: {
406
434
  readonly sort: readonly ["id"];
407
435
  };
408
436
  }, readonly ["id"]>;
437
+ readonly ios_devices: TableDefinition<{
438
+ readonly id: {
439
+ readonly type: "string";
440
+ readonly maxLength: 36;
441
+ };
442
+ readonly udid: {
443
+ readonly type: "string";
444
+ readonly maxLength: 40;
445
+ readonly ascii: true;
446
+ readonly unique: true;
447
+ };
448
+ readonly name: {
449
+ readonly type: "string";
450
+ readonly maxLength: 100;
451
+ };
452
+ readonly status: {
453
+ readonly type: "string";
454
+ readonly maxLength: 16;
455
+ };
456
+ readonly requested_by: {
457
+ readonly type: "string";
458
+ readonly maxLength: 320;
459
+ readonly required: false;
460
+ };
461
+ readonly created_at_ms: {
462
+ readonly type: "integer";
463
+ };
464
+ readonly approved_by: {
465
+ readonly type: "string";
466
+ readonly maxLength: 320;
467
+ readonly required: false;
468
+ };
469
+ readonly approved_at_ms: {
470
+ readonly type: "integer";
471
+ readonly required: false;
472
+ };
473
+ readonly registered_at_ms: {
474
+ readonly type: "integer";
475
+ readonly required: false;
476
+ };
477
+ readonly apple_issuer_id: {
478
+ readonly type: "string";
479
+ readonly maxLength: 64;
480
+ readonly ascii: true;
481
+ readonly required: false;
482
+ };
483
+ readonly apple_error: {
484
+ readonly type: "string";
485
+ readonly maxLength: 512;
486
+ readonly required: false;
487
+ };
488
+ readonly build_id: {
489
+ readonly type: "string";
490
+ readonly maxLength: 36;
491
+ readonly required: false;
492
+ };
493
+ }, {}, {
494
+ readonly byStatus: {
495
+ readonly eq: readonly ["status"];
496
+ readonly sort: readonly ["id"];
497
+ };
498
+ readonly all: {
499
+ readonly eq: readonly [];
500
+ readonly sort: readonly ["id"];
501
+ };
502
+ }, readonly ["id"]>;
503
+ readonly ios_device_account: TableDefinition<{
504
+ readonly id: {
505
+ readonly type: "string";
506
+ readonly maxLength: 16;
507
+ readonly ascii: true;
508
+ };
509
+ readonly apple_issuer_id: {
510
+ readonly type: "string";
511
+ readonly maxLength: 64;
512
+ readonly ascii: true;
513
+ };
514
+ readonly claimed_at_ms: {
515
+ readonly type: "integer";
516
+ };
517
+ }, {}, {
518
+ readonly all: {
519
+ readonly eq: readonly [];
520
+ readonly sort: readonly ["id"];
521
+ };
522
+ }, readonly ["id"]>;
409
523
  };
410
524
  /**
411
525
  * Core's tables as the engine types them: the type of `createEngine`'s
@@ -385,7 +385,30 @@ declare const coreSchema: {
385
385
  readonly maxLength: 255;
386
386
  readonly required: false;
387
387
  };
388
- }, {}, {
388
+ readonly is_store_build: {
389
+ readonly type: "boolean";
390
+ };
391
+ readonly is_sandbox: {
392
+ readonly type: "boolean";
393
+ };
394
+ readonly sandbox_url_scheme: {
395
+ readonly type: "string";
396
+ readonly maxLength: 255;
397
+ readonly ascii: true;
398
+ readonly required: false;
399
+ };
400
+ readonly export_method: {
401
+ readonly type: "string";
402
+ readonly maxLength: 16;
403
+ readonly required: false;
404
+ };
405
+ readonly native_app_version: {
406
+ readonly type: "string";
407
+ readonly required: false;
408
+ };
409
+ }, {
410
+ store_build_scope_key: "string";
411
+ }, {
389
412
  readonly byScope: {
390
413
  readonly eq: readonly ["scope_key"];
391
414
  readonly sort: readonly ["id"];
@@ -394,6 +417,11 @@ declare const coreSchema: {
394
417
  readonly eq: readonly ["scope_key", "build_key"];
395
418
  readonly sort: readonly ["id"];
396
419
  };
420
+ readonly byStoreBuild: {
421
+ readonly eq: readonly ["store_build_scope_key"];
422
+ readonly sort: readonly [];
423
+ readonly unique: true;
424
+ };
397
425
  readonly byChannel: {
398
426
  readonly eq: readonly ["channel_id"];
399
427
  readonly sort: readonly ["id"];
@@ -406,6 +434,92 @@ declare const coreSchema: {
406
434
  readonly sort: readonly ["id"];
407
435
  };
408
436
  }, readonly ["id"]>;
437
+ readonly ios_devices: TableDefinition<{
438
+ readonly id: {
439
+ readonly type: "string";
440
+ readonly maxLength: 36;
441
+ };
442
+ readonly udid: {
443
+ readonly type: "string";
444
+ readonly maxLength: 40;
445
+ readonly ascii: true;
446
+ readonly unique: true;
447
+ };
448
+ readonly name: {
449
+ readonly type: "string";
450
+ readonly maxLength: 100;
451
+ };
452
+ readonly status: {
453
+ readonly type: "string";
454
+ readonly maxLength: 16;
455
+ };
456
+ readonly requested_by: {
457
+ readonly type: "string";
458
+ readonly maxLength: 320;
459
+ readonly required: false;
460
+ };
461
+ readonly created_at_ms: {
462
+ readonly type: "integer";
463
+ };
464
+ readonly approved_by: {
465
+ readonly type: "string";
466
+ readonly maxLength: 320;
467
+ readonly required: false;
468
+ };
469
+ readonly approved_at_ms: {
470
+ readonly type: "integer";
471
+ readonly required: false;
472
+ };
473
+ readonly registered_at_ms: {
474
+ readonly type: "integer";
475
+ readonly required: false;
476
+ };
477
+ readonly apple_issuer_id: {
478
+ readonly type: "string";
479
+ readonly maxLength: 64;
480
+ readonly ascii: true;
481
+ readonly required: false;
482
+ };
483
+ readonly apple_error: {
484
+ readonly type: "string";
485
+ readonly maxLength: 512;
486
+ readonly required: false;
487
+ };
488
+ readonly build_id: {
489
+ readonly type: "string";
490
+ readonly maxLength: 36;
491
+ readonly required: false;
492
+ };
493
+ }, {}, {
494
+ readonly byStatus: {
495
+ readonly eq: readonly ["status"];
496
+ readonly sort: readonly ["id"];
497
+ };
498
+ readonly all: {
499
+ readonly eq: readonly [];
500
+ readonly sort: readonly ["id"];
501
+ };
502
+ }, readonly ["id"]>;
503
+ readonly ios_device_account: TableDefinition<{
504
+ readonly id: {
505
+ readonly type: "string";
506
+ readonly maxLength: 16;
507
+ readonly ascii: true;
508
+ };
509
+ readonly apple_issuer_id: {
510
+ readonly type: "string";
511
+ readonly maxLength: 64;
512
+ readonly ascii: true;
513
+ };
514
+ readonly claimed_at_ms: {
515
+ readonly type: "integer";
516
+ };
517
+ }, {}, {
518
+ readonly all: {
519
+ readonly eq: readonly [];
520
+ readonly sort: readonly ["id"];
521
+ };
522
+ }, readonly ["id"]>;
409
523
  };
410
524
  /**
411
525
  * Core's tables as the engine types them: the type of `createEngine`'s
@@ -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 = defineTable({
@@ -280,6 +283,27 @@ const channels = 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 = defineTable({
285
309
  id: {
@@ -356,9 +380,34 @@ const nativeBuilds = 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 = 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 = 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 = 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 = 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 = {
@@ -64,8 +64,7 @@ const createEngine = (database, { plugins = [], now = Date.now } = {}) => {
64
64
  if (module === void 0) throw new require_configError.HotUpdaterConfigError(`Plugin "${plugin.id}" is not one of this engine's plugins.`);
65
65
  return engine.database(module);
66
66
  },
67
- flush: () => engine.flush(),
68
- dispose: () => engine.dispose()
67
+ flush: () => engine.flush()
69
68
  };
70
69
  };
71
70
  //#endregion
@@ -23,13 +23,8 @@ interface Engine {
23
23
  readonly id: string;
24
24
  readonly schema: TSchema;
25
25
  }): HotUpdaterDatabase<TSchema>;
26
- /**
27
- * Applies aggregate changes the database batches that are still pending:
28
- * this process's buffer, and the log rows no compaction has merged yet.
29
- */
26
+ /** Applies the log rows of batched aggregates that no compaction has merged yet. */
30
27
  flush(): Promise<void>;
31
- /** Stops batching's timer after a last flush. */
32
- dispose(): Promise<void>;
33
28
  }
34
29
  /**
35
30
  * The storage engine over a database, as a server runs it: core's tables
@@ -23,13 +23,8 @@ interface Engine {
23
23
  readonly id: string;
24
24
  readonly schema: TSchema;
25
25
  }): HotUpdaterDatabase<TSchema>;
26
- /**
27
- * Applies aggregate changes the database batches that are still pending:
28
- * this process's buffer, and the log rows no compaction has merged yet.
29
- */
26
+ /** Applies the log rows of batched aggregates that no compaction has merged yet. */
30
27
  flush(): Promise<void>;
31
- /** Stops batching's timer after a last flush. */
32
- dispose(): Promise<void>;
33
28
  }
34
29
  /**
35
30
  * The storage engine over a database, as a server runs it: core's tables
@@ -64,8 +64,7 @@ const createEngine = (database, { plugins = [], now = Date.now } = {}) => {
64
64
  if (module === void 0) throw new HotUpdaterConfigError(`Plugin "${plugin.id}" is not one of this engine's plugins.`);
65
65
  return engine.database(module);
66
66
  },
67
- flush: () => engine.flush(),
68
- dispose: () => engine.dispose()
67
+ flush: () => engine.flush()
69
68
  };
70
69
  };
71
70
  //#endregion