@crvouga/mockingbird-runtime 0.1.0 → 0.2.1

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.
@@ -329,6 +329,8 @@ declare class Collection$1<T> {
329
329
  namespace: string,
330
330
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
331
331
  collectionName: string);
332
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
333
+ private journalRecord;
332
334
  private bumpCollectionSeq;
333
335
  nextSequence(): number;
334
336
  get(id: string): T | undefined;
@@ -18,11 +18,11 @@ import {
18
18
  import {
19
19
  Collection,
20
20
  bootSqlite
21
- } from "./chunk-J4M2I37S.js";
21
+ } from "./chunk-4BRVNPWR.js";
22
22
  import {
23
23
  clearNamespace
24
24
  } from "./chunk-2KDYLZXC.js";
25
- import "./chunk-XNS34BPF.js";
25
+ import "./chunk-LL6NKAJO.js";
26
26
  import {
27
27
  requestBaseUrl
28
28
  } from "./chunk-2Y25NPCV.js";
@@ -58,6 +58,8 @@ declare class Collection<T> {
58
58
  namespace: string,
59
59
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
60
60
  collectionName: string);
61
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
62
+ private journalRecord;
61
63
  private bumpCollectionSeq;
62
64
  nextSequence(): number;
63
65
  get(id: string): T | undefined;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  MAX_VARIABLE_BYTE_INTEGER,
3
3
  MQTT_WEBSOCKET_PATH
4
- } from "../chunk-SNMV36AZ.js";
5
- import "../chunk-J4M2I37S.js";
4
+ } from "../chunk-RO7FHXO3.js";
5
+ import "../chunk-4BRVNPWR.js";
6
6
  import "../chunk-2KDYLZXC.js";
7
- import "../chunk-XNS34BPF.js";
7
+ import "../chunk-LL6NKAJO.js";
8
8
  import "../chunk-2Y25NPCV.js";
9
9
  import "../chunk-EQLY2YOA.js";
10
10
  import "../chunk-HU6IOAFC.js";
@@ -333,6 +333,8 @@ declare class Collection<T> {
333
333
  namespace: string,
334
334
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
335
335
  collectionName: string);
336
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
337
+ private journalRecord;
336
338
  private bumpCollectionSeq;
337
339
  nextSequence(): number;
338
340
  get(id: string): T | undefined;
@@ -14,16 +14,16 @@ import {
14
14
  observeClock,
15
15
  takeConnackFault,
16
16
  webSocketNamespace
17
- } from "./chunk-SNMV36AZ.js";
17
+ } from "./chunk-RO7FHXO3.js";
18
18
  import {
19
19
  Collection,
20
20
  IdSequence
21
- } from "./chunk-J4M2I37S.js";
21
+ } from "./chunk-4BRVNPWR.js";
22
22
  import "./chunk-2KDYLZXC.js";
23
23
  import {
24
24
  fromBase64,
25
25
  toBase64
26
- } from "./chunk-XNS34BPF.js";
26
+ } from "./chunk-LL6NKAJO.js";
27
27
  import "./chunk-2Y25NPCV.js";
28
28
  import "./chunk-EQLY2YOA.js";
29
29
  import "./chunk-HU6IOAFC.js";
@@ -7,7 +7,7 @@ import {
7
7
  createMetrics,
8
8
  maskCredential,
9
9
  resolveAdminPrefix
10
- } from "../chunk-XNS34BPF.js";
10
+ } from "../chunk-LL6NKAJO.js";
11
11
  import "../chunk-2Y25NPCV.js";
12
12
 
13
13
  // ../service/core/dist/engine-admin.js
package/dist/service.d.ts CHANGED
@@ -561,6 +561,11 @@ type MockControls = NamespaceControls$1 & {
561
561
  credentials?: Record<string, string>;
562
562
  /** Overrides for named namespaces. A key given here replaces the shared value. */
563
563
  namespaces?: Record<string, NamespaceControls$1>;
564
+ /**
565
+ * Record a time-travel checkpoint after every accepted write. Default true. The runtime's own
566
+ * `checkpointMutations` option wins over this.
567
+ */
568
+ checkpointMutations?: boolean;
564
569
  };
565
570
  /** A latency rule in milliseconds. */
566
571
  type LatencyRule = {
@@ -595,6 +600,7 @@ type BootPlan = {
595
600
  shared: ControlPlan;
596
601
  namespaces: Record<string, ControlPlan>;
597
602
  credentials: Record<string, string>;
603
+ checkpointMutations?: boolean;
598
604
  };
599
605
  /** Validate a boot {@link MockControls} document. */
600
606
  declare const normalizeBootControls: (value: unknown, label?: string) => BootPlan;
@@ -1511,9 +1517,12 @@ declare const snapshotNamespace: (sqlite: SqliteClient, namespace: string) => Na
1511
1517
  */
1512
1518
  declare const restoreNamespace: (sqlite: SqliteClient, namespace: string, snapshot: NamespaceSnapshot) => void;
1513
1519
  /**
1514
- * Execute asynchronous service work atomically using the canonical Timeline rollback primitive.
1515
- * This is the prescribed escape hatch when the SQLite adapter cannot hold a transaction across
1516
- * `await`; service code should not coordinate raw namespace snapshots itself.
1520
+ * Execute asynchronous service work atomically: on a throw, every record and collection
1521
+ * sequence `run` wrote in `namespace` goes back to how it was. Only the rows the work touched
1522
+ * are saved and restored, so the cost follows the write, not the size of the namespace. Every
1523
+ * namespace write goes through {@link Collection}, which records into the open journal. This is
1524
+ * the prescribed escape hatch when the SQLite adapter cannot hold a transaction across `await`;
1525
+ * service code should not coordinate raw namespace snapshots itself.
1517
1526
  */
1518
1527
  declare const withNamespaceRollback: <T>(sqlite: SqliteClient, namespace: string, run: () => Promise<T>) => Promise<T>;
1519
1528
 
@@ -1545,6 +1554,8 @@ declare class Collection<T> {
1545
1554
  namespace: string,
1546
1555
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
1547
1556
  collectionName: string);
1557
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
1558
+ private journalRecord;
1548
1559
  private bumpCollectionSeq;
1549
1560
  nextSequence(): number;
1550
1561
  get(id: string): T | undefined;
@@ -2399,7 +2410,8 @@ type RuntimeOptions<T extends ServiceInstance> = {
2399
2410
  * Record a time-travel checkpoint after every accepted mutation and stamp its id in
2400
2411
  * `x-mockingbird-checkpoint`. Default true. Each checkpoint reads the whole namespace, so a
2401
2412
  * long-running mock that never travels back can turn this off to keep a write's cost its own;
2402
- * `checkpoint`, `snapshot`, `branch` and `checkout` still capture when called.
2413
+ * `checkpoint`, `snapshot`, `branch` and `checkout` still capture when called. Wins over
2414
+ * `adminControls.checkpointMutations`, which a fleet entry can set for any service.
2403
2415
  */
2404
2416
  checkpointMutations?: boolean;
2405
2417
  /** Injectable process IO used for observability and delays; logical service time uses `clock`. */
package/dist/service.js CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  verifyOperations,
66
66
  webhookAdminRoutes,
67
67
  withNamespaceRollback
68
- } from "./chunk-J4M2I37S.js";
68
+ } from "./chunk-4BRVNPWR.js";
69
69
  import "./chunk-2KDYLZXC.js";
70
70
  import {
71
71
  ADMIN_CONTROL_PAGES,
@@ -126,7 +126,7 @@ import {
126
126
  timingSafeEqual,
127
127
  toBase64,
128
128
  toHex
129
- } from "./chunk-XNS34BPF.js";
129
+ } from "./chunk-LL6NKAJO.js";
130
130
  import {
131
131
  requestBaseUrl
132
132
  } from "./chunk-2Y25NPCV.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-runtime",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "The shared Mockingbird runtime every emulator service depends on: router, admin API and page, snapshots, faults and clock, installed once however many emulators an application uses.",
5
5
  "license": "MIT",
6
6
  "type": "module",