@graphrefly/graphrefly 0.21.0 → 0.22.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 (97) hide show
  1. package/README.md +7 -5
  2. package/dist/chunk-44HD4BTA.js +47 -0
  3. package/dist/chunk-44HD4BTA.js.map +1 -0
  4. package/dist/chunk-7TAQJHQV.js +103 -0
  5. package/dist/chunk-7TAQJHQV.js.map +1 -0
  6. package/dist/chunk-BLD3IFYF.js +6827 -0
  7. package/dist/chunk-BLD3IFYF.js.map +1 -0
  8. package/dist/{chunk-ZTCDY5NQ.js → chunk-EQUZ5NLD.js} +34 -45
  9. package/dist/chunk-EQUZ5NLD.js.map +1 -0
  10. package/dist/{chunk-VOQFK7YN.js → chunk-IR3KMOLX.js} +358 -128
  11. package/dist/chunk-IR3KMOLX.js.map +1 -0
  12. package/dist/{chunk-XWBVAO2R.js → chunk-MQBQOFDS.js} +20 -11
  13. package/dist/chunk-MQBQOFDS.js.map +1 -0
  14. package/dist/chunk-NXC35KC5.js +2417 -0
  15. package/dist/chunk-NXC35KC5.js.map +1 -0
  16. package/dist/chunk-QA3RP5NH.js +2234 -0
  17. package/dist/chunk-QA3RP5NH.js.map +1 -0
  18. package/dist/chunk-RHI3GHZW.js +115 -0
  19. package/dist/chunk-RHI3GHZW.js.map +1 -0
  20. package/dist/{chunk-7IGHIFTT.js → chunk-TH6COGOP.js} +15 -26
  21. package/dist/chunk-TH6COGOP.js.map +1 -0
  22. package/dist/compat/nestjs/index.cjs +3366 -2259
  23. package/dist/compat/nestjs/index.cjs.map +1 -1
  24. package/dist/compat/nestjs/index.d.cts +6 -4
  25. package/dist/compat/nestjs/index.d.ts +6 -4
  26. package/dist/compat/nestjs/index.js +8 -8
  27. package/dist/core/index.cjs +1611 -1218
  28. package/dist/core/index.cjs.map +1 -1
  29. package/dist/core/index.d.cts +3 -2
  30. package/dist/core/index.d.ts +3 -2
  31. package/dist/core/index.js +37 -34
  32. package/dist/extra/index.cjs +7387 -6089
  33. package/dist/extra/index.cjs.map +1 -1
  34. package/dist/extra/index.d.cts +4 -4
  35. package/dist/extra/index.d.ts +4 -4
  36. package/dist/extra/index.js +57 -30
  37. package/dist/graph/index.cjs +3107 -2216
  38. package/dist/graph/index.cjs.map +1 -1
  39. package/dist/graph/index.d.cts +5 -3
  40. package/dist/graph/index.d.ts +5 -3
  41. package/dist/graph/index.js +24 -11
  42. package/dist/graph-DFr0diXB.d.ts +1128 -0
  43. package/dist/graph-ab1yPwIB.d.cts +1128 -0
  44. package/dist/{index-8a605sg9.d.ts → index-BHm3Ba5q.d.ts} +2 -2
  45. package/dist/{index-DuN3bhtm.d.ts → index-BbYZma8G.d.ts} +1697 -586
  46. package/dist/{index-SFzE_KTa.d.cts → index-BvWfZCTt.d.cts} +1697 -586
  47. package/dist/index-C9z6rU9P.d.cts +388 -0
  48. package/dist/{index-BjtlNirP.d.cts → index-D36MAQ3f.d.ts} +4 -4
  49. package/dist/{index-VHA43cGP.d.cts → index-DLE1Sp-L.d.cts} +2 -2
  50. package/dist/{index-CgSiUouz.d.ts → index-DrJq9B1T.d.cts} +4 -4
  51. package/dist/index-DsGxLfwL.d.ts +315 -0
  52. package/dist/index-Dy04P4W3.d.cts +315 -0
  53. package/dist/index-HdJx_BjO.d.ts +388 -0
  54. package/dist/index.cjs +9781 -7878
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts +214 -37
  57. package/dist/index.d.ts +214 -37
  58. package/dist/index.js +905 -638
  59. package/dist/index.js.map +1 -1
  60. package/dist/meta--fr9sxRM.d.cts +41 -0
  61. package/dist/meta-n3FoVWML.d.ts +41 -0
  62. package/dist/node-C5UD5MGq.d.cts +1146 -0
  63. package/dist/node-C5UD5MGq.d.ts +1146 -0
  64. package/dist/{observable-DcBwQY7t.d.ts → observable-CQRBtEbq.d.ts} +1 -1
  65. package/dist/{observable-C8Kx_O6k.d.cts → observable-DWydVy5b.d.cts} +1 -1
  66. package/dist/patterns/reactive-layout/index.cjs +3102 -2132
  67. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  68. package/dist/patterns/reactive-layout/index.d.cts +5 -3
  69. package/dist/patterns/reactive-layout/index.d.ts +5 -3
  70. package/dist/patterns/reactive-layout/index.js +5 -4
  71. package/dist/storage-Bew05Xy6.d.cts +182 -0
  72. package/dist/storage-C9fZfMfM.d.ts +182 -0
  73. package/package.json +1 -1
  74. package/dist/chunk-2UDLYZHT.js +0 -2117
  75. package/dist/chunk-2UDLYZHT.js.map +0 -1
  76. package/dist/chunk-4MQ2J6IG.js +0 -1631
  77. package/dist/chunk-4MQ2J6IG.js.map +0 -1
  78. package/dist/chunk-7IGHIFTT.js.map +0 -1
  79. package/dist/chunk-DOSLSFKL.js +0 -162
  80. package/dist/chunk-DOSLSFKL.js.map +0 -1
  81. package/dist/chunk-ECN37NVS.js +0 -6227
  82. package/dist/chunk-ECN37NVS.js.map +0 -1
  83. package/dist/chunk-G66H6ZRK.js +0 -111
  84. package/dist/chunk-G66H6ZRK.js.map +0 -1
  85. package/dist/chunk-VOQFK7YN.js.map +0 -1
  86. package/dist/chunk-WZ2Z2CRV.js +0 -32
  87. package/dist/chunk-WZ2Z2CRV.js.map +0 -1
  88. package/dist/chunk-XWBVAO2R.js.map +0 -1
  89. package/dist/chunk-ZTCDY5NQ.js.map +0 -1
  90. package/dist/graph-KsTe57nI.d.cts +0 -750
  91. package/dist/graph-mILUUqW8.d.ts +0 -750
  92. package/dist/index-B2SvPEbc.d.ts +0 -257
  93. package/dist/index-BHfg_Ez3.d.ts +0 -629
  94. package/dist/index-Bc_diYYJ.d.cts +0 -629
  95. package/dist/index-UudxGnzc.d.cts +0 -257
  96. package/dist/meta-BnG7XAaE.d.cts +0 -778
  97. 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-DLE1Sp-L.cjs';
2
+ import '../../node-C5UD5MGq.cjs';
3
+ import '../../graph-ab1yPwIB.cjs';
4
+ import '../../meta--fr9sxRM.cjs';
5
+ import '../../storage-Bew05Xy6.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-BHm3Ba5q.js';
2
+ import '../../node-C5UD5MGq.js';
3
+ import '../../graph-DFr0diXB.js';
4
+ import '../../meta-n3FoVWML.js';
5
+ import '../../storage-C9fZfMfM.js';
@@ -14,10 +14,11 @@ 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-EQUZ5NLD.js";
18
+ import "../../chunk-NXC35KC5.js";
19
+ import "../../chunk-TH6COGOP.js";
20
+ import "../../chunk-7TAQJHQV.js";
21
+ import "../../chunk-QA3RP5NH.js";
21
22
  export {
22
23
  CanvasMeasureAdapter,
23
24
  CliMeasureAdapter,
@@ -0,0 +1,182 @@
1
+ import { N as Node } from './node-C5UD5MGq.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 };
@@ -0,0 +1,182 @@
1
+ import { N as Node } from './node-C5UD5MGq.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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphrefly/graphrefly",
3
- "version": "0.21.0",
3
+ "version": "0.22.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": {