@graphrefly/graphrefly 0.21.0 → 0.23.0

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 (101) hide show
  1. package/README.md +7 -5
  2. package/dist/chunk-263BEJJO.js +115 -0
  3. package/dist/chunk-263BEJJO.js.map +1 -0
  4. package/dist/chunk-2GQLMQVJ.js +47 -0
  5. package/dist/chunk-2GQLMQVJ.js.map +1 -0
  6. package/dist/chunk-32N5A454.js +36 -0
  7. package/dist/chunk-32N5A454.js.map +1 -0
  8. package/dist/chunk-7TAQJHQV.js +103 -0
  9. package/dist/chunk-7TAQJHQV.js.map +1 -0
  10. package/dist/{chunk-VOQFK7YN.js → chunk-CWYPA63G.js} +109 -259
  11. package/dist/chunk-CWYPA63G.js.map +1 -0
  12. package/dist/{chunk-7IGHIFTT.js → chunk-HVBX5KIW.js} +15 -26
  13. package/dist/chunk-HVBX5KIW.js.map +1 -0
  14. package/dist/chunk-JFONSPNF.js +391 -0
  15. package/dist/chunk-JFONSPNF.js.map +1 -0
  16. package/dist/chunk-NZMBRXQV.js +2330 -0
  17. package/dist/chunk-NZMBRXQV.js.map +1 -0
  18. package/dist/{chunk-XWBVAO2R.js → chunk-PNUZM7PC.js} +20 -30
  19. package/dist/chunk-PNUZM7PC.js.map +1 -0
  20. package/dist/{chunk-ZTCDY5NQ.js → chunk-PX6PDUJ5.js} +34 -50
  21. package/dist/chunk-PX6PDUJ5.js.map +1 -0
  22. package/dist/chunk-XRFJJ2IU.js +2417 -0
  23. package/dist/chunk-XRFJJ2IU.js.map +1 -0
  24. package/dist/chunk-XTLYW4FR.js +6829 -0
  25. package/dist/chunk-XTLYW4FR.js.map +1 -0
  26. package/dist/compat/nestjs/index.cjs +3489 -2286
  27. package/dist/compat/nestjs/index.cjs.map +1 -1
  28. package/dist/compat/nestjs/index.d.cts +6 -4
  29. package/dist/compat/nestjs/index.d.ts +6 -4
  30. package/dist/compat/nestjs/index.js +10 -8
  31. package/dist/core/index.cjs +1706 -1217
  32. package/dist/core/index.cjs.map +1 -1
  33. package/dist/core/index.d.cts +3 -2
  34. package/dist/core/index.d.ts +3 -2
  35. package/dist/core/index.js +37 -34
  36. package/dist/extra/index.cjs +7519 -6125
  37. package/dist/extra/index.cjs.map +1 -1
  38. package/dist/extra/index.d.cts +4 -4
  39. package/dist/extra/index.d.ts +4 -4
  40. package/dist/extra/index.js +63 -34
  41. package/dist/graph/index.cjs +3199 -2212
  42. package/dist/graph/index.cjs.map +1 -1
  43. package/dist/graph/index.d.cts +5 -3
  44. package/dist/graph/index.d.ts +5 -3
  45. package/dist/graph/index.js +24 -11
  46. package/dist/graph-BtdSRHUc.d.cts +1128 -0
  47. package/dist/graph-CEO2FkLY.d.ts +1128 -0
  48. package/dist/{index-DuN3bhtm.d.ts → index-B0tfuXwV.d.cts} +1697 -586
  49. package/dist/index-BFGjXbiP.d.cts +315 -0
  50. package/dist/{index-CgSiUouz.d.ts → index-BPlWVAKY.d.cts} +4 -4
  51. package/dist/index-BUj3ASVe.d.cts +406 -0
  52. package/dist/{index-VHA43cGP.d.cts → index-C59uSJAH.d.cts} +2 -2
  53. package/dist/index-CkElcUY6.d.ts +315 -0
  54. package/dist/index-DSPc5rkv.d.ts +406 -0
  55. package/dist/{index-BjtlNirP.d.cts → index-DgscL7v0.d.ts} +4 -4
  56. package/dist/{index-SFzE_KTa.d.cts → index-RXN94sHK.d.ts} +1697 -586
  57. package/dist/{index-8a605sg9.d.ts → index-jEtF4N7L.d.ts} +2 -2
  58. package/dist/index.cjs +9947 -7949
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +214 -37
  61. package/dist/index.d.ts +214 -37
  62. package/dist/index.js +919 -648
  63. package/dist/index.js.map +1 -1
  64. package/dist/meta-3QjzotRv.d.ts +41 -0
  65. package/dist/meta-B-Lbs4-O.d.cts +41 -0
  66. package/dist/node-C7PD3sn9.d.cts +1188 -0
  67. package/dist/node-C7PD3sn9.d.ts +1188 -0
  68. package/dist/{observable-DcBwQY7t.d.ts → observable-EyO-moQY.d.ts} +1 -1
  69. package/dist/{observable-C8Kx_O6k.d.cts → observable-axpzv1K2.d.cts} +1 -1
  70. package/dist/patterns/reactive-layout/index.cjs +3205 -2138
  71. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  72. package/dist/patterns/reactive-layout/index.d.cts +5 -3
  73. package/dist/patterns/reactive-layout/index.d.ts +5 -3
  74. package/dist/patterns/reactive-layout/index.js +7 -4
  75. package/dist/storage-CHT5WE9m.d.ts +182 -0
  76. package/dist/storage-DIgAr7M_.d.cts +182 -0
  77. package/package.json +2 -1
  78. package/dist/chunk-2UDLYZHT.js +0 -2117
  79. package/dist/chunk-2UDLYZHT.js.map +0 -1
  80. package/dist/chunk-4MQ2J6IG.js +0 -1631
  81. package/dist/chunk-4MQ2J6IG.js.map +0 -1
  82. package/dist/chunk-7IGHIFTT.js.map +0 -1
  83. package/dist/chunk-DOSLSFKL.js +0 -162
  84. package/dist/chunk-DOSLSFKL.js.map +0 -1
  85. package/dist/chunk-ECN37NVS.js +0 -6227
  86. package/dist/chunk-ECN37NVS.js.map +0 -1
  87. package/dist/chunk-G66H6ZRK.js +0 -111
  88. package/dist/chunk-G66H6ZRK.js.map +0 -1
  89. package/dist/chunk-VOQFK7YN.js.map +0 -1
  90. package/dist/chunk-WZ2Z2CRV.js +0 -32
  91. package/dist/chunk-WZ2Z2CRV.js.map +0 -1
  92. package/dist/chunk-XWBVAO2R.js.map +0 -1
  93. package/dist/chunk-ZTCDY5NQ.js.map +0 -1
  94. package/dist/graph-KsTe57nI.d.cts +0 -750
  95. package/dist/graph-mILUUqW8.d.ts +0 -750
  96. package/dist/index-B2SvPEbc.d.ts +0 -257
  97. package/dist/index-BHfg_Ez3.d.ts +0 -629
  98. package/dist/index-Bc_diYYJ.d.cts +0 -629
  99. package/dist/index-UudxGnzc.d.cts +0 -257
  100. package/dist/meta-BnG7XAaE.d.cts +0 -778
  101. package/dist/meta-BnG7XAaE.d.ts +0 -778
@@ -1,3 +1,5 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CharPosition, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, I as ImageMeasurer, g as ImageSizeAdapter, L as LayoutLine, h as LineBreaksResult, j as MeasuredBlock, M as MeasurementAdapter, N as NodeCanvasMeasureAdapter, P as PositionedBlock, k as PrecomputedAdapter, l as PrecomputedAdapterOptions, m as PreparedSegment, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveLayoutBundle, p as ReactiveLayoutOptions, S as SegmentBreakKind, q as SegmentMeasureStats, r as SvgBoundsAdapter, s as SvgMeasurer, t as analyzeAndMeasure, u as computeBlockFlow, v as computeCharPositions, w as computeLineBreaks, x as computeTotalHeight, y as measureBlock, z as measureBlocks, A as reactiveBlockLayout, D as reactiveLayout } from '../../index-VHA43cGP.cjs';
2
- import '../../meta-BnG7XAaE.cjs';
3
- import '../../graph-KsTe57nI.cjs';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CharPosition, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, I as ImageMeasurer, g as ImageSizeAdapter, L as LayoutLine, h as LineBreaksResult, j as MeasuredBlock, M as MeasurementAdapter, N as NodeCanvasMeasureAdapter, P as PositionedBlock, k as PrecomputedAdapter, l as PrecomputedAdapterOptions, m as PreparedSegment, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveLayoutBundle, p as ReactiveLayoutOptions, S as SegmentBreakKind, q as SegmentMeasureStats, r as SvgBoundsAdapter, s as SvgMeasurer, t as analyzeAndMeasure, u as computeBlockFlow, v as computeCharPositions, w as computeLineBreaks, x as computeTotalHeight, y as measureBlock, z as measureBlocks, A as reactiveBlockLayout, D as reactiveLayout } from '../../index-C59uSJAH.cjs';
2
+ import '../../node-C7PD3sn9.cjs';
3
+ import '../../graph-BtdSRHUc.cjs';
4
+ import '../../meta-B-Lbs4-O.cjs';
5
+ import '../../storage-DIgAr7M_.cjs';
@@ -1,3 +1,5 @@
1
- export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CharPosition, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, I as ImageMeasurer, g as ImageSizeAdapter, L as LayoutLine, h as LineBreaksResult, j as MeasuredBlock, M as MeasurementAdapter, N as NodeCanvasMeasureAdapter, P as PositionedBlock, k as PrecomputedAdapter, l as PrecomputedAdapterOptions, m as PreparedSegment, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveLayoutBundle, p as ReactiveLayoutOptions, S as SegmentBreakKind, q as SegmentMeasureStats, r as SvgBoundsAdapter, s as SvgMeasurer, t as analyzeAndMeasure, u as computeBlockFlow, v as computeCharPositions, w as computeLineBreaks, x as computeTotalHeight, y as measureBlock, z as measureBlocks, A as reactiveBlockLayout, D as reactiveLayout } from '../../index-8a605sg9.js';
2
- import '../../meta-BnG7XAaE.js';
3
- import '../../graph-mILUUqW8.js';
1
+ export { B as BlockAdapters, C as CanvasMeasureAdapter, a as CanvasMeasureAdapterOptions, b as CanvasModule, c as CharPosition, d as CliMeasureAdapter, e as CliMeasureAdapterOptions, f as ContentBlock, I as ImageMeasurer, g as ImageSizeAdapter, L as LayoutLine, h as LineBreaksResult, j as MeasuredBlock, M as MeasurementAdapter, N as NodeCanvasMeasureAdapter, P as PositionedBlock, k as PrecomputedAdapter, l as PrecomputedAdapterOptions, m as PreparedSegment, R as ReactiveBlockLayoutBundle, n as ReactiveBlockLayoutOptions, o as ReactiveLayoutBundle, p as ReactiveLayoutOptions, S as SegmentBreakKind, q as SegmentMeasureStats, r as SvgBoundsAdapter, s as SvgMeasurer, t as analyzeAndMeasure, u as computeBlockFlow, v as computeCharPositions, w as computeLineBreaks, x as computeTotalHeight, y as measureBlock, z as measureBlocks, A as reactiveBlockLayout, D as reactiveLayout } from '../../index-jEtF4N7L.js';
2
+ import '../../node-C7PD3sn9.js';
3
+ import '../../graph-CEO2FkLY.js';
4
+ import '../../meta-3QjzotRv.js';
5
+ import '../../storage-CHT5WE9m.js';
@@ -14,10 +14,13 @@ import {
14
14
  measureBlocks,
15
15
  reactiveBlockLayout,
16
16
  reactiveLayout
17
- } from "../../chunk-ZTCDY5NQ.js";
18
- import "../../chunk-2UDLYZHT.js";
19
- import "../../chunk-7IGHIFTT.js";
20
- import "../../chunk-4MQ2J6IG.js";
17
+ } from "../../chunk-PX6PDUJ5.js";
18
+ import "../../chunk-32N5A454.js";
19
+ import "../../chunk-CWYPA63G.js";
20
+ import "../../chunk-XRFJJ2IU.js";
21
+ import "../../chunk-HVBX5KIW.js";
22
+ import "../../chunk-7TAQJHQV.js";
23
+ import "../../chunk-NZMBRXQV.js";
21
24
  export {
22
25
  CanvasMeasureAdapter,
23
26
  CliMeasureAdapter,
@@ -0,0 +1,182 @@
1
+ import { N as Node } from './node-C7PD3sn9.js';
2
+
3
+ /**
4
+ * Storage tier primitive — unified persistence surface (roadmap §3.1).
5
+ *
6
+ * A {@link StorageTier} is the single abstraction used by:
7
+ * - {@link Graph.attachStorage} — snapshot cascade with per-tier cadence
8
+ * - {@link Graph.fromStorage} — hot-boot from the first tier that hits
9
+ * - {@link cascadingCache} — keyed lookup cache with auto-promotion
10
+ *
11
+ * Factory functions cover the common backends: {@link memoryStorage},
12
+ * {@link dictStorage}, {@link fileStorage}, {@link sqliteStorage} (sync), and
13
+ * {@link indexedDbStorage} (async). {@link fromIDBRequest} /
14
+ * {@link fromIDBTransaction} wrap raw IndexedDB primitives as reactive sources
15
+ * — they belong here as the browser-runtime neighbors of `indexedDbStorage`.
16
+ */
17
+
18
+ /**
19
+ * Single persistence primitive — supports sync and async backends alike via
20
+ * `void | Promise<void>` returns. `debounceMs` / `compactEvery` / `filter`
21
+ * are per-tier cadence controls honored by {@link Graph.attachStorage};
22
+ * {@link cascadingCache} ignores them (it has its own eviction policy).
23
+ */
24
+ interface StorageTier {
25
+ /** Read a value. Returns `null` (or resolves to `null`) on miss. */
26
+ load(key: string): unknown | Promise<unknown>;
27
+ /** Write a record. Sync tiers return `void`; async tiers return `Promise<void>`. */
28
+ save(key: string, data: unknown): void | Promise<void>;
29
+ /** Delete a value. Optional — tiers without `clear` are append/overwrite-only. */
30
+ clear?(key: string): void | Promise<void>;
31
+ /**
32
+ * Debounce saves on this tier (ms). Hot tier: `0` (sync-through).
33
+ * Warm: `1000`. Cold: `60000`. Each tier holds its own last-save baseline,
34
+ * so cold flushes aren't penalized by hot flushes.
35
+ */
36
+ debounceMs?: number;
37
+ /**
38
+ * Every Nth record is a full snapshot; others are diffs against this
39
+ * tier's own baseline. Default `10`. Set `1` for always-full;
40
+ * `Number.POSITIVE_INFINITY` is unsafe — WAL replay needs periodic anchors.
41
+ */
42
+ compactEvery?: number;
43
+ /** Pre-save filter — return `false` to skip this record on this tier. */
44
+ filter?: (key: string, record: unknown) => boolean;
45
+ }
46
+ /** Handle returned by {@link Graph.attachStorage} — dispose to stop observing. */
47
+ interface StorageHandle {
48
+ dispose(): void;
49
+ }
50
+ /**
51
+ * In-memory storage tier (process-local; useful for tests and hot tier).
52
+ *
53
+ * @returns Sync {@link StorageTier} with JSON-cloned isolation.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { memoryStorage } from "@graphrefly/graphrefly-ts";
58
+ *
59
+ * const hot = memoryStorage();
60
+ * graph.attachStorage([hot]);
61
+ * ```
62
+ *
63
+ * @category extra
64
+ */
65
+ declare function memoryStorage(): StorageTier;
66
+ /**
67
+ * Dict-backed storage tier — stores JSON-cloned values under caller keys in
68
+ * a caller-owned plain object. Useful for embedding in a parent state shape.
69
+ *
70
+ * @param storage - Caller-owned object used as the backing store.
71
+ * @returns Sync {@link StorageTier}.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { dictStorage } from "@graphrefly/graphrefly-ts";
76
+ *
77
+ * const state: Record<string, unknown> = {};
78
+ * graph.attachStorage([dictStorage(state)]);
79
+ * ```
80
+ *
81
+ * @category extra
82
+ */
83
+ declare function dictStorage(storage: Record<string, unknown>): StorageTier;
84
+ /**
85
+ * Atomic JSON file storage tier (one file per key in a directory, temp + rename).
86
+ *
87
+ * Keys are sanitized to filesystem-safe names (`[^a-zA-Z0-9_-]` → `%<hex>`).
88
+ * `load` returns `null` for missing files, empty files, or invalid JSON.
89
+ *
90
+ * @param dir - Directory where per-key JSON files are written.
91
+ * @returns Sync {@link StorageTier}.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { fileStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
96
+ *
97
+ * graph.attachStorage([memoryStorage(), fileStorage("./checkpoints")]);
98
+ * ```
99
+ *
100
+ * @category extra
101
+ */
102
+ declare function fileStorage(dir: string): StorageTier;
103
+ /**
104
+ * SQLite storage tier using Node.js `node:sqlite` ({@link DatabaseSync}).
105
+ *
106
+ * Returns a {@link StorageTier} extended with `close()` — the caller owns the
107
+ * connection and should close it when discarding the tier.
108
+ *
109
+ * **Runtime:** Requires Node 22.5+ with `node:sqlite` enabled.
110
+ *
111
+ * @param path - SQLite database file path.
112
+ * @returns Sync {@link StorageTier} with an idempotent `close()` method.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * import { sqliteStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
117
+ *
118
+ * const cold = sqliteStorage("./graphs.sqlite");
119
+ * graph.attachStorage([memoryStorage(), cold]);
120
+ * // ... later, on shutdown:
121
+ * cold.close();
122
+ * ```
123
+ *
124
+ * @category extra
125
+ */
126
+ declare function sqliteStorage(path: string): StorageTier & {
127
+ close(): void;
128
+ };
129
+ type IndexedDbStorageSpec = {
130
+ dbName: string;
131
+ storeName: string;
132
+ /** Object-store key under which snapshots are written. @default `"graphrefly_checkpoint"`. */
133
+ key?: string;
134
+ version?: number;
135
+ };
136
+ /**
137
+ * Wraps an `IDBRequest` as a one-shot reactive source.
138
+ *
139
+ * @param req - Request whose callbacks are converted to protocol messages.
140
+ * @returns `Node<T>` that emits `DATA` once on success then `COMPLETE`;
141
+ * emits `ERROR` on failure.
142
+ *
143
+ * @category extra
144
+ */
145
+ declare function fromIDBRequest<T>(req: IDBRequest<T>): Node<T>;
146
+ /**
147
+ * Wraps an `IDBTransaction` terminal lifecycle as a one-shot reactive source.
148
+ *
149
+ * @param tx - Transaction to observe.
150
+ * @returns `Node<void>` that emits `DATA` (`undefined`) then `COMPLETE` on
151
+ * success; emits `ERROR` on `error`/`abort`.
152
+ *
153
+ * @category extra
154
+ */
155
+ declare function fromIDBTransaction(tx: IDBTransaction): Node<void>;
156
+ /**
157
+ * IndexedDB-backed async storage tier (browser runtime).
158
+ *
159
+ * All three methods return `Promise`s — pairs naturally with a warm/cold
160
+ * cadence where async writes are debounced per tier via
161
+ * {@link Graph.attachStorage}. Writes use `readwrite` transactions; reads use
162
+ * `readonly`. Missing records resolve to `null`.
163
+ *
164
+ * @param spec - Database name, store name, optional `key` (default
165
+ * `"graphrefly_checkpoint"`) and schema `version` (default `1`).
166
+ * @returns Async {@link StorageTier}.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { indexedDbStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
171
+ *
172
+ * graph.attachStorage([
173
+ * memoryStorage(),
174
+ * indexedDbStorage({ dbName: "myApp", storeName: "checkpoints" }),
175
+ * ]);
176
+ * ```
177
+ *
178
+ * @category extra
179
+ */
180
+ declare function indexedDbStorage(spec: IndexedDbStorageSpec): StorageTier;
181
+
182
+ export { type IndexedDbStorageSpec as I, type StorageHandle as S, type StorageTier as a, fromIDBRequest as b, fromIDBTransaction as c, dictStorage as d, fileStorage as f, indexedDbStorage as i, memoryStorage as m, sqliteStorage as s };
@@ -0,0 +1,182 @@
1
+ import { N as Node } from './node-C7PD3sn9.cjs';
2
+
3
+ /**
4
+ * Storage tier primitive — unified persistence surface (roadmap §3.1).
5
+ *
6
+ * A {@link StorageTier} is the single abstraction used by:
7
+ * - {@link Graph.attachStorage} — snapshot cascade with per-tier cadence
8
+ * - {@link Graph.fromStorage} — hot-boot from the first tier that hits
9
+ * - {@link cascadingCache} — keyed lookup cache with auto-promotion
10
+ *
11
+ * Factory functions cover the common backends: {@link memoryStorage},
12
+ * {@link dictStorage}, {@link fileStorage}, {@link sqliteStorage} (sync), and
13
+ * {@link indexedDbStorage} (async). {@link fromIDBRequest} /
14
+ * {@link fromIDBTransaction} wrap raw IndexedDB primitives as reactive sources
15
+ * — they belong here as the browser-runtime neighbors of `indexedDbStorage`.
16
+ */
17
+
18
+ /**
19
+ * Single persistence primitive — supports sync and async backends alike via
20
+ * `void | Promise<void>` returns. `debounceMs` / `compactEvery` / `filter`
21
+ * are per-tier cadence controls honored by {@link Graph.attachStorage};
22
+ * {@link cascadingCache} ignores them (it has its own eviction policy).
23
+ */
24
+ interface StorageTier {
25
+ /** Read a value. Returns `null` (or resolves to `null`) on miss. */
26
+ load(key: string): unknown | Promise<unknown>;
27
+ /** Write a record. Sync tiers return `void`; async tiers return `Promise<void>`. */
28
+ save(key: string, data: unknown): void | Promise<void>;
29
+ /** Delete a value. Optional — tiers without `clear` are append/overwrite-only. */
30
+ clear?(key: string): void | Promise<void>;
31
+ /**
32
+ * Debounce saves on this tier (ms). Hot tier: `0` (sync-through).
33
+ * Warm: `1000`. Cold: `60000`. Each tier holds its own last-save baseline,
34
+ * so cold flushes aren't penalized by hot flushes.
35
+ */
36
+ debounceMs?: number;
37
+ /**
38
+ * Every Nth record is a full snapshot; others are diffs against this
39
+ * tier's own baseline. Default `10`. Set `1` for always-full;
40
+ * `Number.POSITIVE_INFINITY` is unsafe — WAL replay needs periodic anchors.
41
+ */
42
+ compactEvery?: number;
43
+ /** Pre-save filter — return `false` to skip this record on this tier. */
44
+ filter?: (key: string, record: unknown) => boolean;
45
+ }
46
+ /** Handle returned by {@link Graph.attachStorage} — dispose to stop observing. */
47
+ interface StorageHandle {
48
+ dispose(): void;
49
+ }
50
+ /**
51
+ * In-memory storage tier (process-local; useful for tests and hot tier).
52
+ *
53
+ * @returns Sync {@link StorageTier} with JSON-cloned isolation.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { memoryStorage } from "@graphrefly/graphrefly-ts";
58
+ *
59
+ * const hot = memoryStorage();
60
+ * graph.attachStorage([hot]);
61
+ * ```
62
+ *
63
+ * @category extra
64
+ */
65
+ declare function memoryStorage(): StorageTier;
66
+ /**
67
+ * Dict-backed storage tier — stores JSON-cloned values under caller keys in
68
+ * a caller-owned plain object. Useful for embedding in a parent state shape.
69
+ *
70
+ * @param storage - Caller-owned object used as the backing store.
71
+ * @returns Sync {@link StorageTier}.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { dictStorage } from "@graphrefly/graphrefly-ts";
76
+ *
77
+ * const state: Record<string, unknown> = {};
78
+ * graph.attachStorage([dictStorage(state)]);
79
+ * ```
80
+ *
81
+ * @category extra
82
+ */
83
+ declare function dictStorage(storage: Record<string, unknown>): StorageTier;
84
+ /**
85
+ * Atomic JSON file storage tier (one file per key in a directory, temp + rename).
86
+ *
87
+ * Keys are sanitized to filesystem-safe names (`[^a-zA-Z0-9_-]` → `%<hex>`).
88
+ * `load` returns `null` for missing files, empty files, or invalid JSON.
89
+ *
90
+ * @param dir - Directory where per-key JSON files are written.
91
+ * @returns Sync {@link StorageTier}.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * import { fileStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
96
+ *
97
+ * graph.attachStorage([memoryStorage(), fileStorage("./checkpoints")]);
98
+ * ```
99
+ *
100
+ * @category extra
101
+ */
102
+ declare function fileStorage(dir: string): StorageTier;
103
+ /**
104
+ * SQLite storage tier using Node.js `node:sqlite` ({@link DatabaseSync}).
105
+ *
106
+ * Returns a {@link StorageTier} extended with `close()` — the caller owns the
107
+ * connection and should close it when discarding the tier.
108
+ *
109
+ * **Runtime:** Requires Node 22.5+ with `node:sqlite` enabled.
110
+ *
111
+ * @param path - SQLite database file path.
112
+ * @returns Sync {@link StorageTier} with an idempotent `close()` method.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * import { sqliteStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
117
+ *
118
+ * const cold = sqliteStorage("./graphs.sqlite");
119
+ * graph.attachStorage([memoryStorage(), cold]);
120
+ * // ... later, on shutdown:
121
+ * cold.close();
122
+ * ```
123
+ *
124
+ * @category extra
125
+ */
126
+ declare function sqliteStorage(path: string): StorageTier & {
127
+ close(): void;
128
+ };
129
+ type IndexedDbStorageSpec = {
130
+ dbName: string;
131
+ storeName: string;
132
+ /** Object-store key under which snapshots are written. @default `"graphrefly_checkpoint"`. */
133
+ key?: string;
134
+ version?: number;
135
+ };
136
+ /**
137
+ * Wraps an `IDBRequest` as a one-shot reactive source.
138
+ *
139
+ * @param req - Request whose callbacks are converted to protocol messages.
140
+ * @returns `Node<T>` that emits `DATA` once on success then `COMPLETE`;
141
+ * emits `ERROR` on failure.
142
+ *
143
+ * @category extra
144
+ */
145
+ declare function fromIDBRequest<T>(req: IDBRequest<T>): Node<T>;
146
+ /**
147
+ * Wraps an `IDBTransaction` terminal lifecycle as a one-shot reactive source.
148
+ *
149
+ * @param tx - Transaction to observe.
150
+ * @returns `Node<void>` that emits `DATA` (`undefined`) then `COMPLETE` on
151
+ * success; emits `ERROR` on `error`/`abort`.
152
+ *
153
+ * @category extra
154
+ */
155
+ declare function fromIDBTransaction(tx: IDBTransaction): Node<void>;
156
+ /**
157
+ * IndexedDB-backed async storage tier (browser runtime).
158
+ *
159
+ * All three methods return `Promise`s — pairs naturally with a warm/cold
160
+ * cadence where async writes are debounced per tier via
161
+ * {@link Graph.attachStorage}. Writes use `readwrite` transactions; reads use
162
+ * `readonly`. Missing records resolve to `null`.
163
+ *
164
+ * @param spec - Database name, store name, optional `key` (default
165
+ * `"graphrefly_checkpoint"`) and schema `version` (default `1`).
166
+ * @returns Async {@link StorageTier}.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { indexedDbStorage, memoryStorage } from "@graphrefly/graphrefly-ts";
171
+ *
172
+ * graph.attachStorage([
173
+ * memoryStorage(),
174
+ * indexedDbStorage({ dbName: "myApp", storeName: "checkpoints" }),
175
+ * ]);
176
+ * ```
177
+ *
178
+ * @category extra
179
+ */
180
+ declare function indexedDbStorage(spec: IndexedDbStorageSpec): StorageTier;
181
+
182
+ export { type IndexedDbStorageSpec as I, type StorageHandle as S, type StorageTier as a, fromIDBRequest as b, fromIDBTransaction as c, dictStorage as d, fileStorage as f, indexedDbStorage as i, memoryStorage as m, sqliteStorage as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphrefly/graphrefly",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
5
5
  "description": "Reactive harness layer for agent workflows. Describe automations in plain language, trace every decision, enforce policies, persist checkpoints. Zero dependencies.",
6
6
  "repository": {
@@ -257,6 +257,7 @@
257
257
  "@types/node": "^25.5.0",
258
258
  "@types/react": "^19.2.14",
259
259
  "@types/react-dom": "^19.2.3",
260
+ "fast-check": "^4.7.0",
260
261
  "jsdom": "^29.0.1",
261
262
  "openai": "^6.34.0",
262
263
  "react": "^19.2.4",