@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
@@ -385,7 +385,26 @@ 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
+ }, {
406
+ store_build_scope_key: "string";
407
+ }, {
389
408
  readonly byScope: {
390
409
  readonly eq: readonly ["scope_key"];
391
410
  readonly sort: readonly ["id"];
@@ -394,6 +413,11 @@ declare const coreSchema: {
394
413
  readonly eq: readonly ["scope_key", "build_key"];
395
414
  readonly sort: readonly ["id"];
396
415
  };
416
+ readonly byStoreBuild: {
417
+ readonly eq: readonly ["store_build_scope_key"];
418
+ readonly sort: readonly [];
419
+ readonly unique: true;
420
+ };
397
421
  readonly byChannel: {
398
422
  readonly eq: readonly ["channel_id"];
399
423
  readonly sort: readonly ["id"];
@@ -406,6 +430,92 @@ declare const coreSchema: {
406
430
  readonly sort: readonly ["id"];
407
431
  };
408
432
  }, readonly ["id"]>;
433
+ readonly ios_devices: TableDefinition<{
434
+ readonly id: {
435
+ readonly type: "string";
436
+ readonly maxLength: 36;
437
+ };
438
+ readonly udid: {
439
+ readonly type: "string";
440
+ readonly maxLength: 40;
441
+ readonly ascii: true;
442
+ readonly unique: true;
443
+ };
444
+ readonly name: {
445
+ readonly type: "string";
446
+ readonly maxLength: 100;
447
+ };
448
+ readonly status: {
449
+ readonly type: "string";
450
+ readonly maxLength: 16;
451
+ };
452
+ readonly requested_by: {
453
+ readonly type: "string";
454
+ readonly maxLength: 320;
455
+ readonly required: false;
456
+ };
457
+ readonly created_at_ms: {
458
+ readonly type: "integer";
459
+ };
460
+ readonly approved_by: {
461
+ readonly type: "string";
462
+ readonly maxLength: 320;
463
+ readonly required: false;
464
+ };
465
+ readonly approved_at_ms: {
466
+ readonly type: "integer";
467
+ readonly required: false;
468
+ };
469
+ readonly registered_at_ms: {
470
+ readonly type: "integer";
471
+ readonly required: false;
472
+ };
473
+ readonly apple_issuer_id: {
474
+ readonly type: "string";
475
+ readonly maxLength: 64;
476
+ readonly ascii: true;
477
+ readonly required: false;
478
+ };
479
+ readonly apple_error: {
480
+ readonly type: "string";
481
+ readonly maxLength: 512;
482
+ readonly required: false;
483
+ };
484
+ readonly build_id: {
485
+ readonly type: "string";
486
+ readonly maxLength: 36;
487
+ readonly required: false;
488
+ };
489
+ }, {}, {
490
+ readonly byStatus: {
491
+ readonly eq: readonly ["status"];
492
+ readonly sort: readonly ["id"];
493
+ };
494
+ readonly all: {
495
+ readonly eq: readonly [];
496
+ readonly sort: readonly ["id"];
497
+ };
498
+ }, readonly ["id"]>;
499
+ readonly ios_device_account: TableDefinition<{
500
+ readonly id: {
501
+ readonly type: "string";
502
+ readonly maxLength: 16;
503
+ readonly ascii: true;
504
+ };
505
+ readonly apple_issuer_id: {
506
+ readonly type: "string";
507
+ readonly maxLength: 64;
508
+ readonly ascii: true;
509
+ };
510
+ readonly claimed_at_ms: {
511
+ readonly type: "integer";
512
+ };
513
+ }, {}, {
514
+ readonly all: {
515
+ readonly eq: readonly [];
516
+ readonly sort: readonly ["id"];
517
+ };
518
+ }, readonly ["id"]>;
409
519
  };
410
520
  /**
411
521
  * Core's tables as the engine types them: the type of `createEngine`'s
@@ -385,7 +385,26 @@ 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
+ }, {
406
+ store_build_scope_key: "string";
407
+ }, {
389
408
  readonly byScope: {
390
409
  readonly eq: readonly ["scope_key"];
391
410
  readonly sort: readonly ["id"];
@@ -394,6 +413,11 @@ declare const coreSchema: {
394
413
  readonly eq: readonly ["scope_key", "build_key"];
395
414
  readonly sort: readonly ["id"];
396
415
  };
416
+ readonly byStoreBuild: {
417
+ readonly eq: readonly ["store_build_scope_key"];
418
+ readonly sort: readonly [];
419
+ readonly unique: true;
420
+ };
397
421
  readonly byChannel: {
398
422
  readonly eq: readonly ["channel_id"];
399
423
  readonly sort: readonly ["id"];
@@ -406,6 +430,92 @@ declare const coreSchema: {
406
430
  readonly sort: readonly ["id"];
407
431
  };
408
432
  }, readonly ["id"]>;
433
+ readonly ios_devices: TableDefinition<{
434
+ readonly id: {
435
+ readonly type: "string";
436
+ readonly maxLength: 36;
437
+ };
438
+ readonly udid: {
439
+ readonly type: "string";
440
+ readonly maxLength: 40;
441
+ readonly ascii: true;
442
+ readonly unique: true;
443
+ };
444
+ readonly name: {
445
+ readonly type: "string";
446
+ readonly maxLength: 100;
447
+ };
448
+ readonly status: {
449
+ readonly type: "string";
450
+ readonly maxLength: 16;
451
+ };
452
+ readonly requested_by: {
453
+ readonly type: "string";
454
+ readonly maxLength: 320;
455
+ readonly required: false;
456
+ };
457
+ readonly created_at_ms: {
458
+ readonly type: "integer";
459
+ };
460
+ readonly approved_by: {
461
+ readonly type: "string";
462
+ readonly maxLength: 320;
463
+ readonly required: false;
464
+ };
465
+ readonly approved_at_ms: {
466
+ readonly type: "integer";
467
+ readonly required: false;
468
+ };
469
+ readonly registered_at_ms: {
470
+ readonly type: "integer";
471
+ readonly required: false;
472
+ };
473
+ readonly apple_issuer_id: {
474
+ readonly type: "string";
475
+ readonly maxLength: 64;
476
+ readonly ascii: true;
477
+ readonly required: false;
478
+ };
479
+ readonly apple_error: {
480
+ readonly type: "string";
481
+ readonly maxLength: 512;
482
+ readonly required: false;
483
+ };
484
+ readonly build_id: {
485
+ readonly type: "string";
486
+ readonly maxLength: 36;
487
+ readonly required: false;
488
+ };
489
+ }, {}, {
490
+ readonly byStatus: {
491
+ readonly eq: readonly ["status"];
492
+ readonly sort: readonly ["id"];
493
+ };
494
+ readonly all: {
495
+ readonly eq: readonly [];
496
+ readonly sort: readonly ["id"];
497
+ };
498
+ }, readonly ["id"]>;
499
+ readonly ios_device_account: TableDefinition<{
500
+ readonly id: {
501
+ readonly type: "string";
502
+ readonly maxLength: 16;
503
+ readonly ascii: true;
504
+ };
505
+ readonly apple_issuer_id: {
506
+ readonly type: "string";
507
+ readonly maxLength: 64;
508
+ readonly ascii: true;
509
+ };
510
+ readonly claimed_at_ms: {
511
+ readonly type: "integer";
512
+ };
513
+ }, {}, {
514
+ readonly all: {
515
+ readonly eq: readonly [];
516
+ readonly sort: readonly ["id"];
517
+ };
518
+ }, readonly ["id"]>;
409
519
  };
410
520
  /**
411
521
  * 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,21 @@ 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
+ * 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 = defineTable({
285
303
  id: {
@@ -356,9 +374,30 @@ const nativeBuilds = 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 = 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 = 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 = 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 = 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 = {
@@ -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