@graphrefly/graphrefly 0.36.0 → 0.38.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 (249) hide show
  1. package/dist/{chunk-J6TGRQUP.js → chunk-2YFDSYEF.js} +1 -1
  2. package/dist/{chunk-JUJEPZOI.js → chunk-4BDQXBXE.js} +1 -1
  3. package/dist/chunk-5BGFS2XH.js +1 -0
  4. package/dist/chunk-6773HURD.js +1 -0
  5. package/dist/{chunk-AQC53OWG.js → chunk-6KZZ6XQE.js} +1 -1
  6. package/dist/{chunk-5CPPC75H.js → chunk-6VFC334U.js} +1 -1
  7. package/dist/{chunk-KUVDFOJH.js → chunk-7KZZLWZ6.js} +1 -1
  8. package/dist/{chunk-Q7EUZ6NN.js → chunk-B5S7KTGP.js} +1 -1
  9. package/dist/chunk-CMTN3KPT.js +80 -0
  10. package/dist/chunk-DQJLC6YY.js +1 -0
  11. package/dist/chunk-DSOVKKTI.js +1 -0
  12. package/dist/chunk-FAYEMS5M.js +1 -0
  13. package/dist/chunk-FWGIZP3W.js +1 -0
  14. package/dist/{chunk-5Z3AFBN7.js → chunk-G7JN6LCB.js} +1 -1
  15. package/dist/{chunk-PCD2MU7X.js → chunk-IBGE62GZ.js} +1 -1
  16. package/dist/{chunk-MYFR67PY.js → chunk-K5C67OGE.js} +1 -1
  17. package/dist/chunk-KJEAIIIY.js +43 -0
  18. package/dist/chunk-LV3ACS5J.js +1 -0
  19. package/dist/{chunk-7LYIKMW5.js → chunk-NBGPXQSP.js} +1 -1
  20. package/dist/chunk-NN3QPJ6U.js +1 -0
  21. package/dist/{chunk-T6RPUERH.js → chunk-NSAZ6PR6.js} +1 -1
  22. package/dist/{chunk-KCE6WWJE.js → chunk-NV63VQHI.js} +1 -1
  23. package/dist/{chunk-PYEIPRSZ.js → chunk-O245YLM5.js} +1 -1
  24. package/dist/{chunk-K5ZXJPWU.js → chunk-O2BLVQU4.js} +1 -1
  25. package/dist/chunk-PHXZRR6C.js +1 -0
  26. package/dist/{chunk-I57VSGRB.js → chunk-POCWFIJ7.js} +1 -1
  27. package/dist/{chunk-TQSTS3BY.js → chunk-QEVSIVSF.js} +1 -1
  28. package/dist/chunk-QMC2PLNM.js +7 -0
  29. package/dist/chunk-QOJFR6GS.js +1 -0
  30. package/dist/{chunk-MQZWA3DF.js → chunk-RZ5HKPGI.js} +1 -1
  31. package/dist/{chunk-XINLP35X.js → chunk-SFK7MN7S.js} +1 -1
  32. package/dist/{chunk-YOUAVGHJ.js → chunk-SP5O2MIX.js} +1 -1
  33. package/dist/chunk-TB7JKSVS.js +61 -0
  34. package/dist/{chunk-6G5YD37E.js → chunk-TMVY7OWG.js} +1 -1
  35. package/dist/{chunk-F36TA3ET.js → chunk-UAXFKMAG.js} +1 -1
  36. package/dist/{chunk-AACJX2L7.js → chunk-UVLZX2OU.js} +1 -1
  37. package/dist/chunk-XIMFHEKV.js +1 -0
  38. package/dist/{chunk-LO3LO2TO.js → chunk-XLMYQB6F.js} +1 -1
  39. package/dist/{chunk-44QWWUA3.js → chunk-XLYF4LBH.js} +1 -1
  40. package/dist/compat/index.cjs +9 -9
  41. package/dist/compat/index.d.cts +7 -7
  42. package/dist/compat/index.d.ts +7 -7
  43. package/dist/compat/index.js +1 -1
  44. package/dist/compat/nestjs/index.cjs +9 -9
  45. package/dist/compat/nestjs/index.d.cts +5 -5
  46. package/dist/compat/nestjs/index.d.ts +5 -5
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/zustand/index.cjs +7 -7
  49. package/dist/compat/zustand/index.d.cts +3 -3
  50. package/dist/compat/zustand/index.d.ts +3 -3
  51. package/dist/compat/zustand/index.js +1 -1
  52. package/dist/{composite-_XckYx2e.d.cts → composite-CgG0MqHm.d.cts} +8 -1
  53. package/dist/{composite-CT_mApQD.d.ts → composite-DTOlDuch.d.ts} +8 -1
  54. package/dist/core/index.cjs +1 -1
  55. package/dist/core/index.d.cts +2 -2
  56. package/dist/core/index.d.ts +2 -2
  57. package/dist/core/index.js +1 -1
  58. package/dist/extra/index.cjs +19 -19
  59. package/dist/extra/index.d.cts +5 -5
  60. package/dist/extra/index.d.ts +5 -5
  61. package/dist/extra/index.js +1 -1
  62. package/dist/extra/node.cjs +2 -2
  63. package/dist/extra/node.d.cts +107 -1
  64. package/dist/extra/node.d.ts +107 -1
  65. package/dist/extra/node.js +2 -2
  66. package/dist/extra/operators.cjs +1 -1
  67. package/dist/extra/operators.js +1 -1
  68. package/dist/extra/reactive.d.cts +1 -1
  69. package/dist/extra/reactive.d.ts +1 -1
  70. package/dist/extra/reactive.js +1 -1
  71. package/dist/extra/sources.cjs +1 -1
  72. package/dist/extra/sources.js +1 -1
  73. package/dist/extra/storage-tiers-browser.d.cts +76 -5
  74. package/dist/extra/storage-tiers-browser.d.ts +76 -5
  75. package/dist/extra/storage-tiers-node.d.cts +137 -13
  76. package/dist/extra/storage-tiers-node.d.ts +137 -13
  77. package/dist/extra/storage-tiers.d.cts +151 -23
  78. package/dist/extra/storage-tiers.d.ts +151 -23
  79. package/dist/graph/index.cjs +7 -7
  80. package/dist/graph/index.d.cts +4 -4
  81. package/dist/graph/index.d.ts +4 -4
  82. package/dist/graph/index.js +1 -1
  83. package/dist/{graph-Cv-8x0ZI.d.ts → graph-BjW1taJl.d.ts} +243 -11
  84. package/dist/{graph-kTltt95s.d.cts → graph-CHsVwf9S.d.cts} +243 -11
  85. package/dist/{index-CZAixNU3.d.ts → index-5dNRlW7J.d.ts} +3 -3
  86. package/dist/{index-DtSVSKnd.d.ts → index-AUqWe_fX.d.ts} +7 -4
  87. package/dist/{index-DLyQC5Ww.d.ts → index-B-ORMr3k.d.ts} +2 -2
  88. package/dist/{index-C4ig7whw.d.cts → index-B2IUcH13.d.cts} +2 -2
  89. package/dist/{index-KeBhbNg3.d.ts → index-BFaALJxR.d.ts} +2 -2
  90. package/dist/{index-CsD0fqnO.d.ts → index-BI1wMfyc.d.ts} +2 -2
  91. package/dist/{index-DxxvGTXp.d.ts → index-BUFCHvOR.d.ts} +2 -2
  92. package/dist/{index-HCp5ua_i.d.cts → index-BWUMIt7J.d.cts} +3 -3
  93. package/dist/{index-DHv2M7s8.d.cts → index-BaSy4L6w.d.cts} +37 -17
  94. package/dist/{index-BhkPzu-Z.d.cts → index-BgzPO43H.d.cts} +2 -2
  95. package/dist/{index-BsZlbHM5.d.cts → index-BhzwpIJc.d.cts} +1 -1
  96. package/dist/{index-BC-xjOrd.d.cts → index-BkQqf1EF.d.cts} +80 -7
  97. package/dist/{index-BBdwz2BW.d.ts → index-BmWuVdER.d.ts} +2 -2
  98. package/dist/{index-CVhBdCMf.d.ts → index-Bn0uZEL4.d.ts} +2 -2
  99. package/dist/{index-33mF4XyU.d.cts → index-BpMZzX9P.d.cts} +2 -2
  100. package/dist/{index-ZhKyR8co.d.cts → index-Bpr0Pwgl.d.cts} +2 -2
  101. package/dist/{index-2URa-V4S.d.cts → index-BqcgiSQg.d.cts} +2 -2
  102. package/dist/{index-DzYTXMBz.d.ts → index-BsZk9T8y.d.ts} +1 -1
  103. package/dist/{index-CvUrRb4m.d.cts → index-BsgxnHN8.d.cts} +2 -2
  104. package/dist/index-Bub6x_D4.d.cts +427 -0
  105. package/dist/{index-BZ1V5GzX.d.ts → index-BwOsJfLJ.d.ts} +2 -2
  106. package/dist/{index-BuMzxRO2.d.ts → index-Byp771zP.d.ts} +1 -1
  107. package/dist/{index-DKp1CIbG.d.cts → index-C-3UXnHT.d.cts} +1 -1
  108. package/dist/{index-GaW6Welt.d.cts → index-C56XZiDe.d.cts} +2 -2
  109. package/dist/{index-k67aNfqC.d.cts → index-CAV-3RpJ.d.cts} +2 -2
  110. package/dist/{index-DmtWMP0X.d.cts → index-CAbHN_rP.d.cts} +1 -1
  111. package/dist/{index-BTJxM-wZ.d.ts → index-CEVzBWeB.d.ts} +2 -2
  112. package/dist/{index-BVNGEX7d.d.cts → index-CM-i58FY.d.cts} +2 -2
  113. package/dist/{index-EfPb77rT.d.cts → index-CQsqqEVz.d.cts} +1 -1
  114. package/dist/{index-Cot94_82.d.ts → index-CijfwEWx.d.ts} +2 -2
  115. package/dist/{index-PluovH45.d.cts → index-Ckil6miL.d.cts} +2 -2
  116. package/dist/{index-XxSeddWP.d.cts → index-CpdnP-0y.d.cts} +1 -1
  117. package/dist/{index-Pu1Wa7en.d.ts → index-CrlHFsiT.d.ts} +37 -17
  118. package/dist/{index-BWH17rK_.d.cts → index-Czk3r0yA.d.cts} +37 -3
  119. package/dist/{index-BlRVj-7Q.d.cts → index-D-B7U42V.d.cts} +2 -2
  120. package/dist/{index-B4s70vYf.d.ts → index-D-HZ7sP4.d.ts} +2 -2
  121. package/dist/{index-Cjrpx2Mg.d.cts → index-D7-RSD93.d.cts} +2 -2
  122. package/dist/{index-kBUQj-rT.d.ts → index-D9vBTuzo.d.ts} +2 -2
  123. package/dist/{index-DzCQt2FJ.d.cts → index-DJNAWzcH.d.cts} +2 -2
  124. package/dist/{index-DSSsxS7B.d.ts → index-DJVQ-t07.d.ts} +2 -2
  125. package/dist/{index-BwYGLgmI.d.ts → index-DKrIuF-r.d.ts} +2 -2
  126. package/dist/{index-DXSLMoma.d.ts → index-DOU1Ee_k.d.ts} +1 -1
  127. package/dist/{index-DlccEIi3.d.ts → index-DTDVDzhA.d.ts} +37 -3
  128. package/dist/{index-B5UR87KG.d.ts → index-DY2f2b9z.d.ts} +4 -2
  129. package/dist/{index-D8IyqHvT.d.cts → index-DeSsvHDD.d.cts} +4 -2
  130. package/dist/index-Di7OdwlO.d.ts +427 -0
  131. package/dist/{index-isdlyeeO.d.ts → index-DqICM_I7.d.ts} +80 -7
  132. package/dist/{index-DFe2Pk2u.d.ts → index-ML6vHKXK.d.ts} +1 -1
  133. package/dist/{index-RJIY7QVW.d.cts → index-UsU9ptzs.d.cts} +7 -4
  134. package/dist/{index-jA_OwwNg.d.ts → index-Vz7KPfgz.d.ts} +1 -1
  135. package/dist/index.cjs +50 -50
  136. package/dist/index.d.cts +32 -32
  137. package/dist/index.d.ts +32 -32
  138. package/dist/index.js +1 -1
  139. package/dist/meta-BYqlATmg.d.ts +98 -0
  140. package/dist/meta-DreaEM_a.d.cts +98 -0
  141. package/dist/patterns/ai/browser.cjs +2 -2
  142. package/dist/patterns/ai/browser.js +1 -1
  143. package/dist/patterns/ai/index.cjs +21 -21
  144. package/dist/patterns/ai/index.d.cts +9 -9
  145. package/dist/patterns/ai/index.d.ts +9 -9
  146. package/dist/patterns/ai/index.js +1 -1
  147. package/dist/patterns/ai/node.js +1 -1
  148. package/dist/patterns/audit/index.cjs +7 -7
  149. package/dist/patterns/audit/index.d.cts +5 -5
  150. package/dist/patterns/audit/index.d.ts +5 -5
  151. package/dist/patterns/audit/index.js +1 -1
  152. package/dist/patterns/cqrs/index.cjs +7 -7
  153. package/dist/patterns/cqrs/index.d.cts +4 -4
  154. package/dist/patterns/cqrs/index.d.ts +4 -4
  155. package/dist/patterns/cqrs/index.js +1 -1
  156. package/dist/patterns/demo-shell/index.cjs +8 -8
  157. package/dist/patterns/demo-shell/index.d.cts +4 -4
  158. package/dist/patterns/demo-shell/index.d.ts +4 -4
  159. package/dist/patterns/demo-shell/index.js +1 -1
  160. package/dist/patterns/domain-templates/index.cjs +7 -7
  161. package/dist/patterns/domain-templates/index.d.cts +3 -3
  162. package/dist/patterns/domain-templates/index.d.ts +3 -3
  163. package/dist/patterns/domain-templates/index.js +1 -1
  164. package/dist/patterns/graphspec/index.cjs +21 -21
  165. package/dist/patterns/graphspec/index.d.cts +3 -3
  166. package/dist/patterns/graphspec/index.d.ts +3 -3
  167. package/dist/patterns/graphspec/index.js +1 -1
  168. package/dist/patterns/guarded-execution/index.cjs +7 -7
  169. package/dist/patterns/guarded-execution/index.d.cts +6 -6
  170. package/dist/patterns/guarded-execution/index.d.ts +6 -6
  171. package/dist/patterns/guarded-execution/index.js +1 -1
  172. package/dist/patterns/harness/index.cjs +12 -12
  173. package/dist/patterns/harness/index.d.cts +8 -8
  174. package/dist/patterns/harness/index.d.ts +8 -8
  175. package/dist/patterns/harness/index.js +1 -1
  176. package/dist/patterns/job-queue/index.cjs +7 -7
  177. package/dist/patterns/job-queue/index.d.cts +4 -4
  178. package/dist/patterns/job-queue/index.d.ts +4 -4
  179. package/dist/patterns/job-queue/index.js +1 -1
  180. package/dist/patterns/lens/index.cjs +7 -7
  181. package/dist/patterns/lens/index.d.cts +4 -4
  182. package/dist/patterns/lens/index.d.ts +4 -4
  183. package/dist/patterns/lens/index.js +1 -1
  184. package/dist/patterns/memory/index.cjs +7 -7
  185. package/dist/patterns/memory/index.d.cts +6 -4
  186. package/dist/patterns/memory/index.d.ts +6 -4
  187. package/dist/patterns/memory/index.js +1 -1
  188. package/dist/patterns/messaging/index.cjs +7 -7
  189. package/dist/patterns/messaging/index.d.cts +4 -4
  190. package/dist/patterns/messaging/index.d.ts +4 -4
  191. package/dist/patterns/messaging/index.js +1 -1
  192. package/dist/patterns/orchestration/index.cjs +7 -7
  193. package/dist/patterns/orchestration/index.d.cts +4 -4
  194. package/dist/patterns/orchestration/index.d.ts +4 -4
  195. package/dist/patterns/orchestration/index.js +1 -1
  196. package/dist/patterns/process/index.cjs +1 -1
  197. package/dist/patterns/process/index.d.cts +5 -5
  198. package/dist/patterns/process/index.d.ts +5 -5
  199. package/dist/patterns/process/index.js +1 -1
  200. package/dist/patterns/reactive-layout/index.cjs +8 -8
  201. package/dist/patterns/reactive-layout/index.d.cts +4 -4
  202. package/dist/patterns/reactive-layout/index.d.ts +4 -4
  203. package/dist/patterns/reactive-layout/index.js +1 -1
  204. package/dist/patterns/reduction/index.cjs +7 -7
  205. package/dist/patterns/reduction/index.d.cts +3 -3
  206. package/dist/patterns/reduction/index.d.ts +3 -3
  207. package/dist/patterns/reduction/index.js +1 -1
  208. package/dist/patterns/refine-loop/index.cjs +8 -8
  209. package/dist/patterns/refine-loop/index.d.cts +5 -5
  210. package/dist/patterns/refine-loop/index.d.ts +5 -5
  211. package/dist/patterns/refine-loop/index.js +1 -1
  212. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  213. package/dist/patterns/resilient-pipeline/index.d.cts +4 -4
  214. package/dist/patterns/resilient-pipeline/index.d.ts +4 -4
  215. package/dist/patterns/resilient-pipeline/index.js +1 -1
  216. package/dist/patterns/surface/index.cjs +14 -14
  217. package/dist/patterns/surface/index.d.cts +4 -4
  218. package/dist/patterns/surface/index.d.ts +4 -4
  219. package/dist/patterns/surface/index.js +1 -1
  220. package/dist/{pipeline-graph-DdBoRu37.d.ts → pipeline-graph-9JBbmRxA.d.ts} +2 -2
  221. package/dist/{pipeline-graph-BlLBWSZ2.d.cts → pipeline-graph-DuHpXSOn.d.cts} +2 -2
  222. package/dist/{reactive-layout-D9zqqaqK.d.cts → reactive-layout-BMLDB4Vd.d.cts} +1 -1
  223. package/dist/{reactive-layout-Btv0-efV.d.ts → reactive-layout-D-tRiNhg.d.ts} +1 -1
  224. package/dist/{reactive-log-jirQsxMY.d.ts → reactive-log-BgWSA1fg.d.ts} +28 -1
  225. package/dist/{reactive-log-ScpWyqny.d.cts → reactive-log-C3IMAGpT.d.cts} +28 -1
  226. package/dist/resilience-LGBK236C.js +1 -0
  227. package/dist/{topology-tree-CJsT24DP.d.ts → topology-tree-D47-nI6Z.d.ts} +1 -1
  228. package/dist/{topology-tree-C50l9ARE.d.cts → topology-tree-jrZue3ao.d.cts} +1 -1
  229. package/package.json +1 -1
  230. package/dist/chunk-3U7IIQB2.js +0 -1
  231. package/dist/chunk-533RQFF6.js +0 -1
  232. package/dist/chunk-5CZ3KIRJ.js +0 -1
  233. package/dist/chunk-5KPIYVCC.js +0 -7
  234. package/dist/chunk-5RTZ6DXG.js +0 -1
  235. package/dist/chunk-A5HZZYRK.js +0 -1
  236. package/dist/chunk-CGA5RXO6.js +0 -1
  237. package/dist/chunk-DBPFMCVH.js +0 -1
  238. package/dist/chunk-GWOKTENT.js +0 -1
  239. package/dist/chunk-JJTF75VS.js +0 -1
  240. package/dist/chunk-KL7CILPL.js +0 -1
  241. package/dist/chunk-M27MVZCP.js +0 -1
  242. package/dist/chunk-N2GCKKKH.js +0 -43
  243. package/dist/chunk-QKUWS7CO.js +0 -80
  244. package/dist/chunk-YBA5N4XY.js +0 -61
  245. package/dist/index-CI_yjtua.d.ts +0 -139
  246. package/dist/index-D9qoEOj_.d.cts +0 -139
  247. package/dist/meta-BGO6C7K9.d.cts +0 -41
  248. package/dist/meta-CC6EPdpK.d.ts +0 -41
  249. package/dist/resilience-OBU472D2.js +0 -1
@@ -62,7 +62,26 @@ interface Codec<T = unknown> {
62
62
  * @category extra
63
63
  */
64
64
  declare const jsonCodec: Codec<unknown>;
65
- /** Build a `Codec<T>` over the default JSON encoding. Pure typing helper. */
65
+ /**
66
+ * Returns the default `jsonCodec` cast to `Codec<T>`.
67
+ *
68
+ * Pure typing helper — no runtime overhead. Use when a generic API requires a
69
+ * `Codec<T>` and the value is known to be JSON-serializable.
70
+ *
71
+ * @returns `Codec<T>` backed by the shared `jsonCodec` (UTF-8 JSON, stable key order).
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { memoryBackend, snapshotStorage, jsonCodecFor } from "@graphrefly/graphrefly/extra";
76
+ *
77
+ * type MyState = { count: number; label: string };
78
+ * const tier = snapshotStorage<MyState>(memoryBackend(), {
79
+ * codec: jsonCodecFor<MyState>(),
80
+ * });
81
+ * ```
82
+ *
83
+ * @category extra
84
+ */
66
85
  declare function jsonCodecFor<T>(): Codec<T>;
67
86
  /**
68
87
  * Common tier surface: name + cadence knobs + transaction lifecycle.
@@ -135,8 +154,21 @@ type AppendLoadResult<T> = {
135
154
  cursor: AppendCursor | undefined;
136
155
  };
137
156
  /**
138
- * In-process bytes backend backed by `Map<string, Uint8Array>`. Useful for
139
- * tests, hot tiers, and as a default for the convenience factories below.
157
+ * Creates an in-process bytes backend backed by `Map<string, Uint8Array>`.
158
+ *
159
+ * Useful for tests, hot tiers, and as the default backend for the convenience
160
+ * factories in this module. All operations are synchronous.
161
+ *
162
+ * @returns `StorageBackend` instance backed by an in-memory `Map`.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { memoryBackend, snapshotStorage } from "@graphrefly/graphrefly/extra";
167
+ *
168
+ * const backend = memoryBackend();
169
+ * const tier = snapshotStorage(backend, { name: "my-graph" });
170
+ * await tier.save({ name: "my-graph", data: { count: 1 } });
171
+ * ```
140
172
  *
141
173
  * @category extra
142
174
  */
@@ -150,13 +182,28 @@ type SnapshotStorageOptions<T> = {
150
182
  keyOf?: (snapshot: T) => string;
151
183
  };
152
184
  /**
153
- * Wrap a {@link StorageBackend} as a typed snapshot tier.
185
+ * Wraps a `StorageBackend` as a typed snapshot tier.
154
186
  *
155
187
  * Buffer model: `save(snapshot)` accumulates one pending snapshot in memory.
156
188
  * `flush()` encodes via codec and writes to the backend under
157
189
  * `keyOf(snapshot)` (default `name ?? "snapshot"`). `rollback()` discards
158
190
  * the pending write.
159
191
  *
192
+ * @param backend - Bytes-level backend to persist snapshots into.
193
+ * @param opts - Optional name, codec, debounce window, compaction interval, pre-save filter, and key extractor.
194
+ * @returns `SnapshotStorageTier<T>` that buffers one pending snapshot and flushes on wave-close.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { memoryBackend, snapshotStorage } from "@graphrefly/graphrefly/extra";
199
+ *
200
+ * const backend = memoryBackend();
201
+ * const tier = snapshotStorage<{ count: number }>(backend, { name: "counter" });
202
+ * await tier.save({ count: 42 });
203
+ * // Load back:
204
+ * const loaded = await tier.load?.();
205
+ * ```
206
+ *
160
207
  * @category extra
161
208
  */
162
209
  declare function snapshotStorage<T>(backend: StorageBackend, opts?: SnapshotStorageOptions<T>): SnapshotStorageTier<T>;
@@ -168,7 +215,7 @@ type AppendLogStorageOptions<T> = {
168
215
  compactEvery?: number;
169
216
  };
170
217
  /**
171
- * Wrap a {@link StorageBackend} as a typed append-log tier.
218
+ * Wraps a `StorageBackend` as a typed append-log tier.
172
219
  *
173
220
  * Buffer model: `appendEntries(entries)` accumulates per-key buckets in
174
221
  * memory. `flush()` encodes each bucket as a JSON array via codec and writes
@@ -178,6 +225,20 @@ type AppendLogStorageOptions<T> = {
178
225
  * partition, growing on every flush. Adapters that need true append semantics
179
226
  * (versus rewrite) should layer their own tier impl over the same backend.
180
227
  *
228
+ * @param backend - Bytes-level backend to persist log entries into.
229
+ * @param opts - Optional name, codec, per-entry key extractor, debounce window, and compaction interval.
230
+ * @returns `AppendLogStorageTier<T>` that buffers pending entries and flushes per-key buckets on wave-close.
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * import { memoryBackend, appendLogStorage } from "@graphrefly/graphrefly/extra";
235
+ *
236
+ * const backend = memoryBackend();
237
+ * const tier = appendLogStorage<{ type: string; payload: unknown }>(backend, { name: "events" });
238
+ * await tier.appendEntries([{ type: "created", payload: { id: 1 } }]);
239
+ * const result = await tier.loadEntries?.();
240
+ * ```
241
+ *
181
242
  * @category extra
182
243
  */
183
244
  declare function appendLogStorage<T>(backend: StorageBackend, opts?: AppendLogStorageOptions<T>): AppendLogStorageTier<T>;
@@ -206,17 +267,45 @@ type KvStorageOptions<T> = {
206
267
  filter?: (key: string, value: T) => boolean;
207
268
  };
208
269
  /**
209
- * Wrap a {@link StorageBackend} as a typed kv tier.
270
+ * Wraps a `StorageBackend` as a typed key-value tier.
210
271
  *
211
272
  * Buffer model: `save(k, v)` encodes via codec and writes to the backend
212
273
  * unless debounced. Pending writes are committed on `flush()` and discarded
213
274
  * on `rollback()` — the wave-as-transaction model.
214
275
  *
276
+ * @param backend - Bytes-level backend to persist records into.
277
+ * @param opts - Optional name, codec, debounce window, compaction interval, and pre-save filter.
278
+ * @returns `KvStorageTier<T>` that supports `save`, `load`, `delete`, and `list` operations.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * import { memoryBackend, kvStorage } from "@graphrefly/graphrefly/extra";
283
+ *
284
+ * const backend = memoryBackend();
285
+ * const kv = kvStorage<{ score: number }>(backend, { name: "scores" });
286
+ * await kv.save("player1", { score: 100 });
287
+ * const val = await kv.load("player1");
288
+ * ```
289
+ *
215
290
  * @category extra
216
291
  */
217
292
  declare function kvStorage<T>(backend: StorageBackend, opts?: KvStorageOptions<T>): KvStorageTier<T>;
218
293
  /**
219
- * In-memory snapshot tier `snapshotStorage(memoryBackend(), opts)`.
294
+ * Creates an in-memory snapshot tier backed by a fresh `memoryBackend`.
295
+ *
296
+ * Convenience wrapper for `snapshotStorage(memoryBackend(), opts)`. All writes
297
+ * are synchronous and in-process — useful for tests and hot-path caching.
298
+ *
299
+ * @param opts - Optional snapshot storage options (name, codec, filter, keyOf, debounce, compactEvery).
300
+ * @returns `SnapshotStorageTier<T>` backed by an in-memory store.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * import { memorySnapshot } from "@graphrefly/graphrefly/extra";
305
+ *
306
+ * const tier = memorySnapshot<{ count: number }>({ name: "counter" });
307
+ * await tier.save({ count: 1 });
308
+ * ```
220
309
  *
221
310
  * @category extra
222
311
  */
@@ -224,7 +313,21 @@ declare function memorySnapshot<T>(opts?: Omit<SnapshotStorageOptions<T>, "name"
224
313
  name?: string;
225
314
  }): SnapshotStorageTier<T>;
226
315
  /**
227
- * In-memory append-log tier `appendLogStorage(memoryBackend(), opts)`.
316
+ * Creates an in-memory append-log tier backed by a fresh `memoryBackend`.
317
+ *
318
+ * Convenience wrapper for `appendLogStorage(memoryBackend(), opts)`. All writes
319
+ * are synchronous and in-process — useful for tests and hot-path event buffering.
320
+ *
321
+ * @param opts - Optional append-log storage options (name, codec, keyOf, debounce, compactEvery).
322
+ * @returns `AppendLogStorageTier<T>` backed by an in-memory store.
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * import { memoryAppendLog } from "@graphrefly/graphrefly/extra";
327
+ *
328
+ * const tier = memoryAppendLog<{ type: string }>({ name: "events" });
329
+ * await tier.appendEntries([{ type: "init" }]);
330
+ * ```
228
331
  *
229
332
  * @category extra
230
333
  */
@@ -232,7 +335,22 @@ declare function memoryAppendLog<T>(opts?: Omit<AppendLogStorageOptions<T>, "nam
232
335
  name?: string;
233
336
  }): AppendLogStorageTier<T>;
234
337
  /**
235
- * In-memory kv tier `kvStorage(memoryBackend(), opts)`.
338
+ * Creates an in-memory key-value tier backed by a fresh `memoryBackend`.
339
+ *
340
+ * Convenience wrapper for `kvStorage(memoryBackend(), opts)`. All writes are
341
+ * synchronous and in-process — useful for tests and ephemeral record caches.
342
+ *
343
+ * @param opts - Optional kv storage options (name, codec, filter, debounce, compactEvery).
344
+ * @returns `KvStorageTier<T>` backed by an in-memory store.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * import { memoryKv } from "@graphrefly/graphrefly/extra";
349
+ *
350
+ * const kv = memoryKv<{ value: number }>();
351
+ * await kv.save("key1", { value: 42 });
352
+ * const loaded = await kv.load("key1");
353
+ * ```
236
354
  *
237
355
  * @category extra
238
356
  */
@@ -240,19 +358,24 @@ declare function memoryKv<T>(opts?: Omit<KvStorageOptions<T>, "name"> & {
240
358
  name?: string;
241
359
  }): KvStorageTier<T>;
242
360
  /**
243
- * Dict-backed kv tier wraps a caller-owned plain object as a
244
- * {@link StorageBackend} and returns a kv tier over it. Useful for
245
- * embedding in a parent state shape or for tests that need access to the
246
- * raw bytes.
361
+ * Creates a kv tier backed by a caller-owned plain object (`Record<string, Uint8Array>`).
362
+ *
363
+ * Useful for embedding storage inside a parent state shape or for tests that
364
+ * need direct access to the raw bytes. The dict stores raw encoded bytes as
365
+ * `Uint8Array`. Use `opts.name` to control the tier's diagnostic name
366
+ * (defaults to `"dict-kv"`).
247
367
  *
248
- * The dict stores raw encoded bytes as `Uint8Array`. Use `opts.name` to
249
- * control the tier's diagnostic name (defaults to `"dict-kv"`).
368
+ * @param storage - Caller-owned `Record<string, Uint8Array>` to use as the backing store.
369
+ * @param opts - Optional kv storage options (name, codec, filter, debounce, compactEvery).
370
+ * @returns `KvStorageTier<T>` backed by the provided dict object.
250
371
  *
251
372
  * @example
252
373
  * ```ts
374
+ * import { dictKv } from "@graphrefly/graphrefly/extra";
375
+ *
253
376
  * const store: Record<string, Uint8Array> = {};
254
- * const tier = dictKv<MyRecord>(store);
255
- * await tier.save("key1", myRecord);
377
+ * const tier = dictKv<{ score: number }>(store);
378
+ * await tier.save("player1", { score: 100 });
256
379
  * ```
257
380
  *
258
381
  * @category extra
@@ -261,16 +384,21 @@ declare function dictKv<T>(storage: Record<string, Uint8Array>, opts?: Omit<KvSt
261
384
  name?: string;
262
385
  }): KvStorageTier<T>;
263
386
  /**
264
- * Dict-backed snapshot tier wraps a caller-owned plain object as a
265
- * {@link StorageBackend} and returns a snapshot tier over it. Useful for
266
- * embedding checkpoints inside a parent state shape or for tests that need
267
- * access to the raw bytes.
387
+ * Creates a snapshot tier backed by a caller-owned plain object (`Record<string, Uint8Array>`).
388
+ *
389
+ * Useful for embedding checkpoints inside a parent state shape or for tests
390
+ * that need direct access to the raw bytes. The dict stores raw JSON bytes as
391
+ * `Uint8Array`. Use `opts.name` to control the storage key (defaults to
392
+ * `"snapshot"`).
268
393
  *
269
- * The dict stores raw JSON bytes as `Uint8Array`. Use `opts.name` to control
270
- * the storage key (defaults to `"snapshot"`).
394
+ * @param storage - Caller-owned `Record<string, Uint8Array>` to use as the backing store.
395
+ * @param opts - Optional snapshot storage options (name, codec, filter, keyOf, debounce, compactEvery).
396
+ * @returns `SnapshotStorageTier<T>` backed by the provided dict object.
271
397
  *
272
398
  * @example
273
399
  * ```ts
400
+ * import { dictSnapshot } from "@graphrefly/graphrefly/extra";
401
+ *
274
402
  * const store: Record<string, Uint8Array> = {};
275
403
  * graph.attachSnapshotStorage([dictSnapshot(store, { name: graph.name })]);
276
404
  * ```
@@ -62,7 +62,26 @@ interface Codec<T = unknown> {
62
62
  * @category extra
63
63
  */
64
64
  declare const jsonCodec: Codec<unknown>;
65
- /** Build a `Codec<T>` over the default JSON encoding. Pure typing helper. */
65
+ /**
66
+ * Returns the default `jsonCodec` cast to `Codec<T>`.
67
+ *
68
+ * Pure typing helper — no runtime overhead. Use when a generic API requires a
69
+ * `Codec<T>` and the value is known to be JSON-serializable.
70
+ *
71
+ * @returns `Codec<T>` backed by the shared `jsonCodec` (UTF-8 JSON, stable key order).
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { memoryBackend, snapshotStorage, jsonCodecFor } from "@graphrefly/graphrefly/extra";
76
+ *
77
+ * type MyState = { count: number; label: string };
78
+ * const tier = snapshotStorage<MyState>(memoryBackend(), {
79
+ * codec: jsonCodecFor<MyState>(),
80
+ * });
81
+ * ```
82
+ *
83
+ * @category extra
84
+ */
66
85
  declare function jsonCodecFor<T>(): Codec<T>;
67
86
  /**
68
87
  * Common tier surface: name + cadence knobs + transaction lifecycle.
@@ -135,8 +154,21 @@ type AppendLoadResult<T> = {
135
154
  cursor: AppendCursor | undefined;
136
155
  };
137
156
  /**
138
- * In-process bytes backend backed by `Map<string, Uint8Array>`. Useful for
139
- * tests, hot tiers, and as a default for the convenience factories below.
157
+ * Creates an in-process bytes backend backed by `Map<string, Uint8Array>`.
158
+ *
159
+ * Useful for tests, hot tiers, and as the default backend for the convenience
160
+ * factories in this module. All operations are synchronous.
161
+ *
162
+ * @returns `StorageBackend` instance backed by an in-memory `Map`.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { memoryBackend, snapshotStorage } from "@graphrefly/graphrefly/extra";
167
+ *
168
+ * const backend = memoryBackend();
169
+ * const tier = snapshotStorage(backend, { name: "my-graph" });
170
+ * await tier.save({ name: "my-graph", data: { count: 1 } });
171
+ * ```
140
172
  *
141
173
  * @category extra
142
174
  */
@@ -150,13 +182,28 @@ type SnapshotStorageOptions<T> = {
150
182
  keyOf?: (snapshot: T) => string;
151
183
  };
152
184
  /**
153
- * Wrap a {@link StorageBackend} as a typed snapshot tier.
185
+ * Wraps a `StorageBackend` as a typed snapshot tier.
154
186
  *
155
187
  * Buffer model: `save(snapshot)` accumulates one pending snapshot in memory.
156
188
  * `flush()` encodes via codec and writes to the backend under
157
189
  * `keyOf(snapshot)` (default `name ?? "snapshot"`). `rollback()` discards
158
190
  * the pending write.
159
191
  *
192
+ * @param backend - Bytes-level backend to persist snapshots into.
193
+ * @param opts - Optional name, codec, debounce window, compaction interval, pre-save filter, and key extractor.
194
+ * @returns `SnapshotStorageTier<T>` that buffers one pending snapshot and flushes on wave-close.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { memoryBackend, snapshotStorage } from "@graphrefly/graphrefly/extra";
199
+ *
200
+ * const backend = memoryBackend();
201
+ * const tier = snapshotStorage<{ count: number }>(backend, { name: "counter" });
202
+ * await tier.save({ count: 42 });
203
+ * // Load back:
204
+ * const loaded = await tier.load?.();
205
+ * ```
206
+ *
160
207
  * @category extra
161
208
  */
162
209
  declare function snapshotStorage<T>(backend: StorageBackend, opts?: SnapshotStorageOptions<T>): SnapshotStorageTier<T>;
@@ -168,7 +215,7 @@ type AppendLogStorageOptions<T> = {
168
215
  compactEvery?: number;
169
216
  };
170
217
  /**
171
- * Wrap a {@link StorageBackend} as a typed append-log tier.
218
+ * Wraps a `StorageBackend` as a typed append-log tier.
172
219
  *
173
220
  * Buffer model: `appendEntries(entries)` accumulates per-key buckets in
174
221
  * memory. `flush()` encodes each bucket as a JSON array via codec and writes
@@ -178,6 +225,20 @@ type AppendLogStorageOptions<T> = {
178
225
  * partition, growing on every flush. Adapters that need true append semantics
179
226
  * (versus rewrite) should layer their own tier impl over the same backend.
180
227
  *
228
+ * @param backend - Bytes-level backend to persist log entries into.
229
+ * @param opts - Optional name, codec, per-entry key extractor, debounce window, and compaction interval.
230
+ * @returns `AppendLogStorageTier<T>` that buffers pending entries and flushes per-key buckets on wave-close.
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * import { memoryBackend, appendLogStorage } from "@graphrefly/graphrefly/extra";
235
+ *
236
+ * const backend = memoryBackend();
237
+ * const tier = appendLogStorage<{ type: string; payload: unknown }>(backend, { name: "events" });
238
+ * await tier.appendEntries([{ type: "created", payload: { id: 1 } }]);
239
+ * const result = await tier.loadEntries?.();
240
+ * ```
241
+ *
181
242
  * @category extra
182
243
  */
183
244
  declare function appendLogStorage<T>(backend: StorageBackend, opts?: AppendLogStorageOptions<T>): AppendLogStorageTier<T>;
@@ -206,17 +267,45 @@ type KvStorageOptions<T> = {
206
267
  filter?: (key: string, value: T) => boolean;
207
268
  };
208
269
  /**
209
- * Wrap a {@link StorageBackend} as a typed kv tier.
270
+ * Wraps a `StorageBackend` as a typed key-value tier.
210
271
  *
211
272
  * Buffer model: `save(k, v)` encodes via codec and writes to the backend
212
273
  * unless debounced. Pending writes are committed on `flush()` and discarded
213
274
  * on `rollback()` — the wave-as-transaction model.
214
275
  *
276
+ * @param backend - Bytes-level backend to persist records into.
277
+ * @param opts - Optional name, codec, debounce window, compaction interval, and pre-save filter.
278
+ * @returns `KvStorageTier<T>` that supports `save`, `load`, `delete`, and `list` operations.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * import { memoryBackend, kvStorage } from "@graphrefly/graphrefly/extra";
283
+ *
284
+ * const backend = memoryBackend();
285
+ * const kv = kvStorage<{ score: number }>(backend, { name: "scores" });
286
+ * await kv.save("player1", { score: 100 });
287
+ * const val = await kv.load("player1");
288
+ * ```
289
+ *
215
290
  * @category extra
216
291
  */
217
292
  declare function kvStorage<T>(backend: StorageBackend, opts?: KvStorageOptions<T>): KvStorageTier<T>;
218
293
  /**
219
- * In-memory snapshot tier `snapshotStorage(memoryBackend(), opts)`.
294
+ * Creates an in-memory snapshot tier backed by a fresh `memoryBackend`.
295
+ *
296
+ * Convenience wrapper for `snapshotStorage(memoryBackend(), opts)`. All writes
297
+ * are synchronous and in-process — useful for tests and hot-path caching.
298
+ *
299
+ * @param opts - Optional snapshot storage options (name, codec, filter, keyOf, debounce, compactEvery).
300
+ * @returns `SnapshotStorageTier<T>` backed by an in-memory store.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * import { memorySnapshot } from "@graphrefly/graphrefly/extra";
305
+ *
306
+ * const tier = memorySnapshot<{ count: number }>({ name: "counter" });
307
+ * await tier.save({ count: 1 });
308
+ * ```
220
309
  *
221
310
  * @category extra
222
311
  */
@@ -224,7 +313,21 @@ declare function memorySnapshot<T>(opts?: Omit<SnapshotStorageOptions<T>, "name"
224
313
  name?: string;
225
314
  }): SnapshotStorageTier<T>;
226
315
  /**
227
- * In-memory append-log tier `appendLogStorage(memoryBackend(), opts)`.
316
+ * Creates an in-memory append-log tier backed by a fresh `memoryBackend`.
317
+ *
318
+ * Convenience wrapper for `appendLogStorage(memoryBackend(), opts)`. All writes
319
+ * are synchronous and in-process — useful for tests and hot-path event buffering.
320
+ *
321
+ * @param opts - Optional append-log storage options (name, codec, keyOf, debounce, compactEvery).
322
+ * @returns `AppendLogStorageTier<T>` backed by an in-memory store.
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * import { memoryAppendLog } from "@graphrefly/graphrefly/extra";
327
+ *
328
+ * const tier = memoryAppendLog<{ type: string }>({ name: "events" });
329
+ * await tier.appendEntries([{ type: "init" }]);
330
+ * ```
228
331
  *
229
332
  * @category extra
230
333
  */
@@ -232,7 +335,22 @@ declare function memoryAppendLog<T>(opts?: Omit<AppendLogStorageOptions<T>, "nam
232
335
  name?: string;
233
336
  }): AppendLogStorageTier<T>;
234
337
  /**
235
- * In-memory kv tier `kvStorage(memoryBackend(), opts)`.
338
+ * Creates an in-memory key-value tier backed by a fresh `memoryBackend`.
339
+ *
340
+ * Convenience wrapper for `kvStorage(memoryBackend(), opts)`. All writes are
341
+ * synchronous and in-process — useful for tests and ephemeral record caches.
342
+ *
343
+ * @param opts - Optional kv storage options (name, codec, filter, debounce, compactEvery).
344
+ * @returns `KvStorageTier<T>` backed by an in-memory store.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * import { memoryKv } from "@graphrefly/graphrefly/extra";
349
+ *
350
+ * const kv = memoryKv<{ value: number }>();
351
+ * await kv.save("key1", { value: 42 });
352
+ * const loaded = await kv.load("key1");
353
+ * ```
236
354
  *
237
355
  * @category extra
238
356
  */
@@ -240,19 +358,24 @@ declare function memoryKv<T>(opts?: Omit<KvStorageOptions<T>, "name"> & {
240
358
  name?: string;
241
359
  }): KvStorageTier<T>;
242
360
  /**
243
- * Dict-backed kv tier wraps a caller-owned plain object as a
244
- * {@link StorageBackend} and returns a kv tier over it. Useful for
245
- * embedding in a parent state shape or for tests that need access to the
246
- * raw bytes.
361
+ * Creates a kv tier backed by a caller-owned plain object (`Record<string, Uint8Array>`).
362
+ *
363
+ * Useful for embedding storage inside a parent state shape or for tests that
364
+ * need direct access to the raw bytes. The dict stores raw encoded bytes as
365
+ * `Uint8Array`. Use `opts.name` to control the tier's diagnostic name
366
+ * (defaults to `"dict-kv"`).
247
367
  *
248
- * The dict stores raw encoded bytes as `Uint8Array`. Use `opts.name` to
249
- * control the tier's diagnostic name (defaults to `"dict-kv"`).
368
+ * @param storage - Caller-owned `Record<string, Uint8Array>` to use as the backing store.
369
+ * @param opts - Optional kv storage options (name, codec, filter, debounce, compactEvery).
370
+ * @returns `KvStorageTier<T>` backed by the provided dict object.
250
371
  *
251
372
  * @example
252
373
  * ```ts
374
+ * import { dictKv } from "@graphrefly/graphrefly/extra";
375
+ *
253
376
  * const store: Record<string, Uint8Array> = {};
254
- * const tier = dictKv<MyRecord>(store);
255
- * await tier.save("key1", myRecord);
377
+ * const tier = dictKv<{ score: number }>(store);
378
+ * await tier.save("player1", { score: 100 });
256
379
  * ```
257
380
  *
258
381
  * @category extra
@@ -261,16 +384,21 @@ declare function dictKv<T>(storage: Record<string, Uint8Array>, opts?: Omit<KvSt
261
384
  name?: string;
262
385
  }): KvStorageTier<T>;
263
386
  /**
264
- * Dict-backed snapshot tier wraps a caller-owned plain object as a
265
- * {@link StorageBackend} and returns a snapshot tier over it. Useful for
266
- * embedding checkpoints inside a parent state shape or for tests that need
267
- * access to the raw bytes.
387
+ * Creates a snapshot tier backed by a caller-owned plain object (`Record<string, Uint8Array>`).
388
+ *
389
+ * Useful for embedding checkpoints inside a parent state shape or for tests
390
+ * that need direct access to the raw bytes. The dict stores raw JSON bytes as
391
+ * `Uint8Array`. Use `opts.name` to control the storage key (defaults to
392
+ * `"snapshot"`).
268
393
  *
269
- * The dict stores raw JSON bytes as `Uint8Array`. Use `opts.name` to control
270
- * the storage key (defaults to `"snapshot"`).
394
+ * @param storage - Caller-owned `Record<string, Uint8Array>` to use as the backing store.
395
+ * @param opts - Optional snapshot storage options (name, codec, filter, keyOf, debounce, compactEvery).
396
+ * @returns `SnapshotStorageTier<T>` backed by the provided dict object.
271
397
  *
272
398
  * @example
273
399
  * ```ts
400
+ * import { dictSnapshot } from "@graphrefly/graphrefly/extra";
401
+ *
274
402
  * const store: Record<string, Uint8Array> = {};
275
403
  * graph.attachSnapshotStorage([dictSnapshot(store, { name: graph.name })]);
276
404
  * ```