@astrale-os/kernel-client 0.5.0 → 0.6.0-beta.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.
Files changed (809) hide show
  1. package/dist/auth/auth.d.ts +19 -0
  2. package/dist/auth/auth.d.ts.map +1 -0
  3. package/dist/auth/auth.js +16 -0
  4. package/dist/auth/auth.js.map +1 -0
  5. package/dist/auth/authorization.d.ts +14 -0
  6. package/dist/auth/authorization.d.ts.map +1 -0
  7. package/dist/auth/authorization.js +18 -0
  8. package/dist/auth/authorization.js.map +1 -0
  9. package/dist/auth/credential.d.ts +20 -0
  10. package/dist/auth/credential.d.ts.map +1 -0
  11. package/dist/auth/credential.js +22 -0
  12. package/dist/auth/credential.js.map +1 -0
  13. package/dist/auth/identity.d.ts +15 -0
  14. package/dist/auth/identity.d.ts.map +1 -0
  15. package/dist/auth/identity.js +16 -0
  16. package/dist/auth/identity.js.map +1 -0
  17. package/dist/auth/index.d.ts +6 -15
  18. package/dist/auth/index.d.ts.map +1 -1
  19. package/dist/auth/index.js +5 -9
  20. package/dist/auth/index.js.map +1 -1
  21. package/dist/auth/provision.d.ts +9 -0
  22. package/dist/auth/provision.d.ts.map +1 -0
  23. package/dist/auth/provision.js +11 -0
  24. package/dist/auth/provision.js.map +1 -0
  25. package/dist/client/admission.d.ts +5 -0
  26. package/dist/client/admission.d.ts.map +1 -0
  27. package/dist/client/admission.js +35 -0
  28. package/dist/client/admission.js.map +1 -0
  29. package/dist/client/client.d.ts +21 -108
  30. package/dist/client/client.d.ts.map +1 -1
  31. package/dist/client/client.js +71 -380
  32. package/dist/client/client.js.map +1 -1
  33. package/dist/client/credential.d.ts +13 -0
  34. package/dist/client/credential.d.ts.map +1 -0
  35. package/dist/client/credential.js +52 -0
  36. package/dist/client/credential.js.map +1 -0
  37. package/dist/client/index.d.ts +6 -0
  38. package/dist/client/index.d.ts.map +1 -0
  39. package/dist/client/index.js +5 -0
  40. package/dist/client/index.js.map +1 -0
  41. package/dist/client/request.d.ts +24 -0
  42. package/dist/client/request.d.ts.map +1 -0
  43. package/dist/client/request.js +83 -0
  44. package/dist/client/request.js.map +1 -0
  45. package/dist/client/result.d.ts +5 -0
  46. package/dist/client/result.d.ts.map +1 -0
  47. package/dist/client/result.js +29 -0
  48. package/dist/client/result.js.map +1 -0
  49. package/dist/client/routing-control.d.ts +11 -0
  50. package/dist/client/routing-control.d.ts.map +1 -0
  51. package/dist/client/routing-control.js +24 -0
  52. package/dist/client/routing-control.js.map +1 -0
  53. package/dist/domain/binding.d.ts +25 -0
  54. package/dist/domain/binding.d.ts.map +1 -0
  55. package/dist/domain/binding.js +50 -0
  56. package/dist/domain/binding.js.map +1 -0
  57. package/dist/domain/callable.d.ts +23 -0
  58. package/dist/domain/callable.d.ts.map +1 -0
  59. package/dist/domain/callable.js +66 -0
  60. package/dist/domain/callable.js.map +1 -0
  61. package/dist/domain/domain.typecheck.d.ts +2 -0
  62. package/dist/domain/domain.typecheck.d.ts.map +1 -0
  63. package/dist/domain/domain.typecheck.js +69 -0
  64. package/dist/domain/domain.typecheck.js.map +1 -0
  65. package/dist/domain/index.d.ts +4 -0
  66. package/dist/domain/index.d.ts.map +1 -0
  67. package/dist/domain/index.js +2 -0
  68. package/dist/domain/index.js.map +1 -0
  69. package/dist/domain/node.d.ts +10 -0
  70. package/dist/domain/node.d.ts.map +1 -0
  71. package/dist/domain/node.js +6 -0
  72. package/dist/domain/node.js.map +1 -0
  73. package/dist/errors/client-error.d.ts +4 -0
  74. package/dist/errors/client-error.d.ts.map +1 -0
  75. package/dist/errors/client-error.js +7 -0
  76. package/dist/errors/client-error.js.map +1 -0
  77. package/dist/errors/index.d.ts +6 -5
  78. package/dist/errors/index.d.ts.map +1 -1
  79. package/dist/errors/index.js +6 -3
  80. package/dist/errors/index.js.map +1 -1
  81. package/dist/errors/miss-error.d.ts +7 -0
  82. package/dist/errors/miss-error.d.ts.map +1 -0
  83. package/dist/errors/miss-error.js +9 -0
  84. package/dist/errors/miss-error.js.map +1 -0
  85. package/dist/errors/protocol-error.d.ts +5 -0
  86. package/dist/errors/protocol-error.d.ts.map +1 -0
  87. package/dist/errors/protocol-error.js +8 -0
  88. package/dist/errors/protocol-error.js.map +1 -0
  89. package/dist/errors/response-error.d.ts +10 -0
  90. package/dist/errors/response-error.d.ts.map +1 -0
  91. package/dist/errors/response-error.js +15 -0
  92. package/dist/errors/response-error.js.map +1 -0
  93. package/dist/errors/stale-route-error.d.ts +9 -0
  94. package/dist/errors/stale-route-error.d.ts.map +1 -0
  95. package/dist/errors/stale-route-error.js +11 -0
  96. package/dist/errors/stale-route-error.js.map +1 -0
  97. package/dist/errors/transport-error.d.ts +15 -0
  98. package/dist/errors/transport-error.d.ts.map +1 -0
  99. package/dist/errors/transport-error.js +12 -0
  100. package/dist/errors/transport-error.js.map +1 -0
  101. package/dist/graph/errors.d.ts +9 -0
  102. package/dist/graph/errors.d.ts.map +1 -0
  103. package/dist/graph/errors.js +14 -0
  104. package/dist/graph/errors.js.map +1 -0
  105. package/dist/graph/graph.d.ts +26 -0
  106. package/dist/graph/graph.d.ts.map +1 -0
  107. package/dist/graph/graph.js +19 -0
  108. package/dist/graph/graph.js.map +1 -0
  109. package/dist/graph/index.d.ts +6 -25
  110. package/dist/graph/index.d.ts.map +1 -1
  111. package/dist/graph/index.js +5 -20
  112. package/dist/graph/index.js.map +1 -1
  113. package/dist/graph/mutation.d.ts +6 -0
  114. package/dist/graph/mutation.d.ts.map +1 -0
  115. package/dist/graph/mutation.js +18 -0
  116. package/dist/graph/mutation.js.map +1 -0
  117. package/dist/graph/page/index.d.ts +3 -0
  118. package/dist/graph/page/index.d.ts.map +1 -0
  119. package/dist/graph/page/index.js +2 -0
  120. package/dist/graph/page/index.js.map +1 -0
  121. package/dist/graph/page/neighbors.d.ts +10 -0
  122. package/dist/graph/page/neighbors.d.ts.map +1 -0
  123. package/dist/graph/page/neighbors.js +35 -0
  124. package/dist/graph/page/neighbors.js.map +1 -0
  125. package/dist/graph/page/page.d.ts +34 -0
  126. package/dist/graph/page/page.d.ts.map +1 -0
  127. package/dist/graph/page/page.js +56 -0
  128. package/dist/graph/page/page.js.map +1 -0
  129. package/dist/graph/query.d.ts +5 -0
  130. package/dist/graph/query.d.ts.map +1 -0
  131. package/dist/graph/query.js +57 -0
  132. package/dist/graph/query.js.map +1 -0
  133. package/dist/graph/read.d.ts +7 -0
  134. package/dist/graph/read.d.ts.map +1 -0
  135. package/dist/graph/read.js +18 -0
  136. package/dist/graph/read.js.map +1 -0
  137. package/dist/index.d.ts +6 -24
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +6 -20
  140. package/dist/index.js.map +1 -1
  141. package/dist/pacer/batcher/batcher.d.ts +8 -0
  142. package/dist/pacer/batcher/batcher.d.ts.map +1 -0
  143. package/dist/pacer/batcher/batcher.js +14 -0
  144. package/dist/pacer/batcher/batcher.js.map +1 -0
  145. package/dist/pacer/batcher/defaults.d.ts +3 -0
  146. package/dist/pacer/batcher/defaults.d.ts.map +1 -0
  147. package/dist/pacer/batcher/defaults.js +3 -0
  148. package/dist/pacer/batcher/defaults.js.map +1 -0
  149. package/dist/pacer/batcher/index.d.ts +2 -0
  150. package/dist/pacer/batcher/index.d.ts.map +1 -0
  151. package/dist/pacer/batcher/index.js +2 -0
  152. package/dist/pacer/batcher/index.js.map +1 -0
  153. package/dist/pacer/index.d.ts +4 -9
  154. package/dist/pacer/index.d.ts.map +1 -1
  155. package/dist/pacer/index.js +4 -10
  156. package/dist/pacer/index.js.map +1 -1
  157. package/dist/pacer/limiter/defaults.d.ts +3 -0
  158. package/dist/pacer/limiter/defaults.d.ts.map +1 -0
  159. package/dist/pacer/limiter/defaults.js +3 -0
  160. package/dist/pacer/limiter/defaults.js.map +1 -0
  161. package/dist/pacer/limiter/index.d.ts +2 -0
  162. package/dist/pacer/limiter/index.d.ts.map +1 -0
  163. package/dist/pacer/limiter/index.js +2 -0
  164. package/dist/pacer/limiter/index.js.map +1 -0
  165. package/dist/pacer/limiter/limiter.d.ts +8 -0
  166. package/dist/pacer/limiter/limiter.d.ts.map +1 -0
  167. package/dist/pacer/limiter/limiter.js +15 -0
  168. package/dist/pacer/limiter/limiter.js.map +1 -0
  169. package/dist/pacer/queue/defaults.d.ts +2 -0
  170. package/dist/pacer/queue/defaults.d.ts.map +1 -0
  171. package/dist/pacer/queue/defaults.js +2 -0
  172. package/dist/pacer/queue/defaults.js.map +1 -0
  173. package/dist/pacer/queue/index.d.ts +2 -0
  174. package/dist/pacer/queue/index.d.ts.map +1 -0
  175. package/dist/pacer/queue/index.js +2 -0
  176. package/dist/pacer/queue/index.js.map +1 -0
  177. package/dist/pacer/queue/queue.d.ts +7 -0
  178. package/dist/pacer/queue/queue.d.ts.map +1 -0
  179. package/dist/pacer/queue/queue.js +13 -0
  180. package/dist/pacer/queue/queue.js.map +1 -0
  181. package/dist/pacer/retry/defaults.d.ts +7 -0
  182. package/dist/pacer/retry/defaults.d.ts.map +1 -0
  183. package/dist/pacer/retry/defaults.js +17 -0
  184. package/dist/pacer/retry/defaults.js.map +1 -0
  185. package/dist/pacer/retry/index.d.ts +2 -0
  186. package/dist/pacer/retry/index.d.ts.map +1 -0
  187. package/dist/pacer/retry/index.js +2 -0
  188. package/dist/pacer/retry/index.js.map +1 -0
  189. package/dist/pacer/retry/retry.d.ts +10 -0
  190. package/dist/pacer/retry/retry.d.ts.map +1 -0
  191. package/dist/pacer/retry/retry.js +56 -0
  192. package/dist/pacer/retry/retry.js.map +1 -0
  193. package/dist/pool/index.d.ts +2 -3
  194. package/dist/pool/index.d.ts.map +1 -1
  195. package/dist/pool/index.js +0 -1
  196. package/dist/pool/index.js.map +1 -1
  197. package/dist/pool/pool.d.ts +19 -58
  198. package/dist/pool/pool.d.ts.map +1 -1
  199. package/dist/pool/pool.js +46 -63
  200. package/dist/pool/pool.js.map +1 -1
  201. package/dist/pool/target.d.ts +16 -0
  202. package/dist/pool/target.d.ts.map +1 -0
  203. package/dist/pool/target.js +50 -0
  204. package/dist/pool/target.js.map +1 -0
  205. package/dist/session/context/control.d.ts +6 -0
  206. package/dist/session/context/control.d.ts.map +1 -0
  207. package/dist/session/context/control.js +18 -0
  208. package/dist/session/context/control.js.map +1 -0
  209. package/dist/session/context/index.d.ts +5 -0
  210. package/dist/session/context/index.d.ts.map +1 -0
  211. package/dist/session/context/index.js +5 -0
  212. package/dist/session/context/index.js.map +1 -0
  213. package/dist/session/context/limits.d.ts +8 -0
  214. package/dist/session/context/limits.d.ts.map +1 -0
  215. package/dist/session/context/limits.js +19 -0
  216. package/dist/session/context/limits.js.map +1 -0
  217. package/dist/session/context/operation.d.ts +20 -0
  218. package/dist/session/context/operation.d.ts.map +1 -0
  219. package/dist/session/context/operation.js +70 -0
  220. package/dist/session/context/operation.js.map +1 -0
  221. package/dist/session/context/policy.d.ts +10 -0
  222. package/dist/session/context/policy.d.ts.map +1 -0
  223. package/dist/session/context/policy.js +63 -0
  224. package/dist/session/context/policy.js.map +1 -0
  225. package/dist/session/discovery/bundle.d.ts +18 -0
  226. package/dist/session/discovery/bundle.d.ts.map +1 -0
  227. package/dist/session/discovery/bundle.js +55 -0
  228. package/dist/session/discovery/bundle.js.map +1 -0
  229. package/dist/session/discovery/discovery.d.ts +27 -0
  230. package/dist/session/discovery/discovery.d.ts.map +1 -0
  231. package/dist/session/discovery/discovery.js +69 -0
  232. package/dist/session/discovery/discovery.js.map +1 -0
  233. package/dist/session/discovery/index.d.ts +24 -0
  234. package/dist/session/discovery/index.d.ts.map +1 -0
  235. package/dist/session/discovery/index.js +15 -0
  236. package/dist/session/discovery/index.js.map +1 -0
  237. package/dist/session/discovery/publication.d.ts +22 -0
  238. package/dist/session/discovery/publication.d.ts.map +1 -0
  239. package/dist/session/discovery/publication.js +124 -0
  240. package/dist/session/discovery/publication.js.map +1 -0
  241. package/dist/session/discovery/snapshot.d.ts +12 -0
  242. package/dist/session/discovery/snapshot.d.ts.map +1 -0
  243. package/dist/session/discovery/snapshot.js +4 -0
  244. package/dist/session/discovery/snapshot.js.map +1 -0
  245. package/dist/session/index.d.ts +5 -15
  246. package/dist/session/index.d.ts.map +1 -1
  247. package/dist/session/index.js +1 -8
  248. package/dist/session/index.js.map +1 -1
  249. package/dist/session/routing/auth.d.ts +19 -0
  250. package/dist/session/routing/auth.d.ts.map +1 -0
  251. package/dist/session/routing/auth.js +43 -0
  252. package/dist/session/routing/auth.js.map +1 -0
  253. package/dist/session/routing/cache.d.ts +20 -0
  254. package/dist/session/routing/cache.d.ts.map +1 -0
  255. package/dist/session/routing/cache.js +110 -0
  256. package/dist/session/routing/cache.js.map +1 -0
  257. package/dist/session/routing/dispatch.d.ts +35 -0
  258. package/dist/session/routing/dispatch.d.ts.map +1 -0
  259. package/dist/session/routing/dispatch.js +101 -0
  260. package/dist/session/routing/dispatch.js.map +1 -0
  261. package/dist/session/routing/envelope.d.ts +14 -0
  262. package/dist/session/routing/envelope.d.ts.map +1 -0
  263. package/dist/session/routing/envelope.js +36 -0
  264. package/dist/session/routing/envelope.js.map +1 -0
  265. package/dist/session/routing/index.d.ts +6 -0
  266. package/dist/session/routing/index.d.ts.map +1 -0
  267. package/dist/session/routing/index.js +6 -0
  268. package/dist/session/routing/index.js.map +1 -0
  269. package/dist/session/routing/request.d.ts +9 -0
  270. package/dist/session/routing/request.d.ts.map +1 -0
  271. package/dist/session/routing/request.js +26 -0
  272. package/dist/session/routing/request.js.map +1 -0
  273. package/dist/session/session.d.ts +56 -0
  274. package/dist/session/session.d.ts.map +1 -0
  275. package/dist/session/session.js +183 -0
  276. package/dist/session/session.js.map +1 -0
  277. package/dist/session/session.typecheck.d.ts +2 -0
  278. package/dist/session/session.typecheck.d.ts.map +1 -0
  279. package/dist/session/session.typecheck.js +10 -0
  280. package/dist/session/session.typecheck.js.map +1 -0
  281. package/dist/session/views/catalog.d.ts +16 -0
  282. package/dist/session/views/catalog.d.ts.map +1 -0
  283. package/dist/session/views/catalog.js +63 -0
  284. package/dist/session/views/catalog.js.map +1 -0
  285. package/dist/session/views/index.d.ts +3 -0
  286. package/dist/session/views/index.d.ts.map +1 -0
  287. package/dist/session/views/index.js +3 -0
  288. package/dist/session/views/index.js.map +1 -0
  289. package/dist/session/views/resolve.d.ts +13 -0
  290. package/dist/session/views/resolve.d.ts.map +1 -0
  291. package/dist/session/views/resolve.js +12 -0
  292. package/dist/session/views/resolve.js.map +1 -0
  293. package/dist/store/entity-index.d.ts +23 -0
  294. package/dist/store/entity-index.d.ts.map +1 -0
  295. package/dist/store/entity-index.js +95 -0
  296. package/dist/store/entity-index.js.map +1 -0
  297. package/dist/store/index.d.ts +1 -25
  298. package/dist/store/index.d.ts.map +1 -1
  299. package/dist/store/index.js +1 -18
  300. package/dist/store/index.js.map +1 -1
  301. package/dist/store/memory.d.ts +46 -96
  302. package/dist/store/memory.d.ts.map +1 -1
  303. package/dist/store/memory.js +346 -762
  304. package/dist/store/memory.js.map +1 -1
  305. package/dist/store/mutation.d.ts +6 -0
  306. package/dist/store/mutation.d.ts.map +1 -0
  307. package/dist/store/mutation.js +35 -0
  308. package/dist/store/mutation.js.map +1 -0
  309. package/dist/store/observe.d.ts +4 -0
  310. package/dist/store/observe.d.ts.map +1 -0
  311. package/dist/store/observe.js +18 -0
  312. package/dist/store/observe.js.map +1 -0
  313. package/dist/store/optimistic.d.ts +13 -0
  314. package/dist/store/optimistic.d.ts.map +1 -0
  315. package/dist/store/optimistic.js +44 -0
  316. package/dist/store/optimistic.js.map +1 -0
  317. package/dist/store/query-key.d.ts +6 -0
  318. package/dist/store/query-key.d.ts.map +1 -0
  319. package/dist/store/query-key.js +23 -0
  320. package/dist/store/query-key.js.map +1 -0
  321. package/dist/store/shape.d.ts +26 -0
  322. package/dist/store/shape.d.ts.map +1 -0
  323. package/dist/store/shape.js +30 -0
  324. package/dist/store/shape.js.map +1 -0
  325. package/dist/store/store.d.ts +69 -0
  326. package/dist/store/store.d.ts.map +1 -0
  327. package/dist/store/store.js +145 -0
  328. package/dist/store/store.js.map +1 -0
  329. package/dist/store/store.typecheck.d.ts +2 -0
  330. package/dist/store/store.typecheck.d.ts.map +1 -0
  331. package/dist/store/store.typecheck.js +41 -0
  332. package/dist/store/store.typecheck.js.map +1 -0
  333. package/dist/transport/auto/decision.d.ts +23 -0
  334. package/dist/transport/auto/decision.d.ts.map +1 -0
  335. package/dist/transport/auto/decision.js +49 -0
  336. package/dist/transport/auto/decision.js.map +1 -0
  337. package/dist/transport/auto/fallback.d.ts +17 -0
  338. package/dist/transport/auto/fallback.d.ts.map +1 -0
  339. package/dist/transport/auto/fallback.js +77 -0
  340. package/dist/transport/auto/fallback.js.map +1 -0
  341. package/dist/transport/auto/index.d.ts +3 -0
  342. package/dist/transport/auto/index.d.ts.map +1 -0
  343. package/dist/transport/auto/index.js +3 -0
  344. package/dist/transport/auto/index.js.map +1 -0
  345. package/dist/transport/auto/transport.d.ts +38 -0
  346. package/dist/transport/auto/transport.d.ts.map +1 -0
  347. package/dist/transport/auto/transport.js +141 -0
  348. package/dist/transport/auto/transport.js.map +1 -0
  349. package/dist/transport/auto/warning.d.ts +14 -0
  350. package/dist/transport/auto/warning.d.ts.map +1 -0
  351. package/dist/transport/auto/warning.js +19 -0
  352. package/dist/transport/auto/warning.js.map +1 -0
  353. package/dist/transport/deadline.d.ts +12 -0
  354. package/dist/transport/deadline.d.ts.map +1 -0
  355. package/dist/transport/deadline.js +40 -0
  356. package/dist/transport/deadline.js.map +1 -0
  357. package/dist/transport/http/index.d.ts +2 -0
  358. package/dist/transport/http/index.d.ts.map +1 -0
  359. package/dist/transport/http/index.js +2 -0
  360. package/dist/transport/http/index.js.map +1 -0
  361. package/dist/transport/http/response.d.ts +8 -0
  362. package/dist/transport/http/response.d.ts.map +1 -0
  363. package/dist/transport/http/response.js +79 -0
  364. package/dist/transport/http/response.js.map +1 -0
  365. package/dist/transport/http/stream.d.ts +25 -0
  366. package/dist/transport/http/stream.d.ts.map +1 -0
  367. package/dist/transport/http/stream.js +197 -0
  368. package/dist/transport/http/stream.js.map +1 -0
  369. package/dist/transport/http/transport.d.ts +33 -0
  370. package/dist/transport/http/transport.d.ts.map +1 -0
  371. package/dist/transport/http/transport.js +333 -0
  372. package/dist/transport/http/transport.js.map +1 -0
  373. package/dist/transport/index.d.ts +2 -7
  374. package/dist/transport/index.d.ts.map +1 -1
  375. package/dist/transport/index.js +1 -5
  376. package/dist/transport/index.js.map +1 -1
  377. package/dist/transport/transport.d.ts +29 -0
  378. package/dist/transport/transport.d.ts.map +1 -0
  379. package/dist/transport/transport.js +2 -0
  380. package/dist/transport/transport.js.map +1 -0
  381. package/dist/transport/websocket/connection.d.ts +38 -0
  382. package/dist/transport/websocket/connection.d.ts.map +1 -0
  383. package/dist/transport/websocket/connection.js +297 -0
  384. package/dist/transport/websocket/connection.js.map +1 -0
  385. package/dist/transport/websocket/exchange.d.ts +46 -0
  386. package/dist/transport/websocket/exchange.d.ts.map +1 -0
  387. package/dist/transport/websocket/exchange.js +288 -0
  388. package/dist/transport/websocket/exchange.js.map +1 -0
  389. package/dist/transport/websocket/index.d.ts +2 -0
  390. package/dist/transport/websocket/index.d.ts.map +1 -0
  391. package/dist/transport/websocket/index.js +2 -0
  392. package/dist/transport/websocket/index.js.map +1 -0
  393. package/dist/transport/websocket/transport.d.ts +47 -0
  394. package/dist/transport/websocket/transport.d.ts.map +1 -0
  395. package/dist/transport/websocket/transport.js +176 -0
  396. package/dist/transport/websocket/transport.js.map +1 -0
  397. package/package.json +29 -32
  398. package/dist/auth/addressing.d.ts +0 -32
  399. package/dist/auth/addressing.d.ts.map +0 -1
  400. package/dist/auth/addressing.js +0 -36
  401. package/dist/auth/addressing.js.map +0 -1
  402. package/dist/auth/api.d.ts +0 -70
  403. package/dist/auth/api.d.ts.map +0 -1
  404. package/dist/auth/api.js +0 -36
  405. package/dist/auth/api.js.map +0 -1
  406. package/dist/auth/batch.d.ts +0 -18
  407. package/dist/auth/batch.d.ts.map +0 -1
  408. package/dist/auth/batch.js +0 -25
  409. package/dist/auth/batch.js.map +0 -1
  410. package/dist/auth/composition.d.ts +0 -27
  411. package/dist/auth/composition.d.ts.map +0 -1
  412. package/dist/auth/composition.js +0 -83
  413. package/dist/auth/composition.js.map +0 -1
  414. package/dist/auth/defaults.d.ts +0 -3
  415. package/dist/auth/defaults.d.ts.map +0 -1
  416. package/dist/auth/defaults.js +0 -3
  417. package/dist/auth/defaults.js.map +0 -1
  418. package/dist/auth/minting.d.ts +0 -35
  419. package/dist/auth/minting.d.ts.map +0 -1
  420. package/dist/auth/minting.js +0 -31
  421. package/dist/auth/minting.js.map +0 -1
  422. package/dist/auth/permissions.d.ts +0 -55
  423. package/dist/auth/permissions.d.ts.map +0 -1
  424. package/dist/auth/permissions.js +0 -47
  425. package/dist/auth/permissions.js.map +0 -1
  426. package/dist/auth/principal.d.ts +0 -19
  427. package/dist/auth/principal.d.ts.map +0 -1
  428. package/dist/auth/principal.js +0 -46
  429. package/dist/auth/principal.js.map +0 -1
  430. package/dist/auth/shorthands.d.ts +0 -19
  431. package/dist/auth/shorthands.d.ts.map +0 -1
  432. package/dist/auth/shorthands.js +0 -27
  433. package/dist/auth/shorthands.js.map +0 -1
  434. package/dist/client/batch.d.ts +0 -26
  435. package/dist/client/batch.d.ts.map +0 -1
  436. package/dist/client/batch.js +0 -8
  437. package/dist/client/batch.js.map +0 -1
  438. package/dist/client/bound.d.ts +0 -27
  439. package/dist/client/bound.d.ts.map +0 -1
  440. package/dist/client/bound.js +0 -14
  441. package/dist/client/bound.js.map +0 -1
  442. package/dist/client/config.d.ts +0 -112
  443. package/dist/client/config.d.ts.map +0 -1
  444. package/dist/client/config.js +0 -10
  445. package/dist/client/config.js.map +0 -1
  446. package/dist/client/fn-map.d.ts +0 -61
  447. package/dist/client/fn-map.d.ts.map +0 -1
  448. package/dist/client/fn-map.js +0 -2
  449. package/dist/client/fn-map.js.map +0 -1
  450. package/dist/client/freeze.d.ts +0 -32
  451. package/dist/client/freeze.d.ts.map +0 -1
  452. package/dist/client/freeze.js +0 -42
  453. package/dist/client/freeze.js.map +0 -1
  454. package/dist/client/hooks.d.ts +0 -49
  455. package/dist/client/hooks.d.ts.map +0 -1
  456. package/dist/client/hooks.js +0 -2
  457. package/dist/client/hooks.js.map +0 -1
  458. package/dist/errors/errors.d.ts +0 -156
  459. package/dist/errors/errors.d.ts.map +0 -1
  460. package/dist/errors/errors.js +0 -238
  461. package/dist/errors/errors.js.map +0 -1
  462. package/dist/errors/guards.d.ts +0 -39
  463. package/dist/errors/guards.d.ts.map +0 -1
  464. package/dist/errors/guards.js +0 -127
  465. package/dist/errors/guards.js.map +0 -1
  466. package/dist/errors/session-error.d.ts +0 -21
  467. package/dist/errors/session-error.d.ts.map +0 -1
  468. package/dist/errors/session-error.js +0 -25
  469. package/dist/errors/session-error.js.map +0 -1
  470. package/dist/graph/api.d.ts +0 -85
  471. package/dist/graph/api.d.ts.map +0 -1
  472. package/dist/graph/api.js +0 -66
  473. package/dist/graph/api.js.map +0 -1
  474. package/dist/graph/mutate/builder.d.ts +0 -108
  475. package/dist/graph/mutate/builder.d.ts.map +0 -1
  476. package/dist/graph/mutate/builder.js +0 -127
  477. package/dist/graph/mutate/builder.js.map +0 -1
  478. package/dist/graph/mutate/index.d.ts +0 -5
  479. package/dist/graph/mutate/index.d.ts.map +0 -1
  480. package/dist/graph/mutate/index.js +0 -3
  481. package/dist/graph/mutate/index.js.map +0 -1
  482. package/dist/graph/mutate/shorthands.d.ts +0 -42
  483. package/dist/graph/mutate/shorthands.d.ts.map +0 -1
  484. package/dist/graph/mutate/shorthands.js +0 -65
  485. package/dist/graph/mutate/shorthands.js.map +0 -1
  486. package/dist/graph/named.d.ts +0 -38
  487. package/dist/graph/named.d.ts.map +0 -1
  488. package/dist/graph/named.js +0 -47
  489. package/dist/graph/named.js.map +0 -1
  490. package/dist/graph/query/builder.d.ts +0 -116
  491. package/dist/graph/query/builder.d.ts.map +0 -1
  492. package/dist/graph/query/builder.js +0 -136
  493. package/dist/graph/query/builder.js.map +0 -1
  494. package/dist/graph/query/edge-ref.d.ts +0 -13
  495. package/dist/graph/query/edge-ref.d.ts.map +0 -1
  496. package/dist/graph/query/edge-ref.js +0 -56
  497. package/dist/graph/query/edge-ref.js.map +0 -1
  498. package/dist/graph/query/edges.d.ts +0 -10
  499. package/dist/graph/query/edges.d.ts.map +0 -1
  500. package/dist/graph/query/edges.js +0 -11
  501. package/dist/graph/query/edges.js.map +0 -1
  502. package/dist/graph/query/errors.d.ts +0 -31
  503. package/dist/graph/query/errors.d.ts.map +0 -1
  504. package/dist/graph/query/errors.js +0 -28
  505. package/dist/graph/query/errors.js.map +0 -1
  506. package/dist/graph/query/filter.d.ts +0 -50
  507. package/dist/graph/query/filter.d.ts.map +0 -1
  508. package/dist/graph/query/filter.js +0 -32
  509. package/dist/graph/query/filter.js.map +0 -1
  510. package/dist/graph/query/index.d.ts +0 -12
  511. package/dist/graph/query/index.d.ts.map +0 -1
  512. package/dist/graph/query/index.js +0 -7
  513. package/dist/graph/query/index.js.map +0 -1
  514. package/dist/graph/query/lower.d.ts +0 -30
  515. package/dist/graph/query/lower.d.ts.map +0 -1
  516. package/dist/graph/query/lower.js +0 -171
  517. package/dist/graph/query/lower.js.map +0 -1
  518. package/dist/graph/query/shorthands.d.ts +0 -34
  519. package/dist/graph/query/shorthands.d.ts.map +0 -1
  520. package/dist/graph/query/shorthands.js +0 -71
  521. package/dist/graph/query/shorthands.js.map +0 -1
  522. package/dist/graph/query/traverse.d.ts +0 -59
  523. package/dist/graph/query/traverse.d.ts.map +0 -1
  524. package/dist/graph/query/traverse.js +0 -144
  525. package/dist/graph/query/traverse.js.map +0 -1
  526. package/dist/graph/reconcile/execute.d.ts +0 -8
  527. package/dist/graph/reconcile/execute.d.ts.map +0 -1
  528. package/dist/graph/reconcile/execute.js +0 -56
  529. package/dist/graph/reconcile/execute.js.map +0 -1
  530. package/dist/graph/reconcile/index.d.ts +0 -5
  531. package/dist/graph/reconcile/index.d.ts.map +0 -1
  532. package/dist/graph/reconcile/index.js +0 -3
  533. package/dist/graph/reconcile/index.js.map +0 -1
  534. package/dist/graph/reconcile/input.d.ts +0 -80
  535. package/dist/graph/reconcile/input.d.ts.map +0 -1
  536. package/dist/graph/reconcile/input.js +0 -5
  537. package/dist/graph/reconcile/input.js.map +0 -1
  538. package/dist/graph/reconcile/normalize.d.ts +0 -3
  539. package/dist/graph/reconcile/normalize.d.ts.map +0 -1
  540. package/dist/graph/reconcile/normalize.js +0 -144
  541. package/dist/graph/reconcile/normalize.js.map +0 -1
  542. package/dist/graph/reconcile/result.d.ts +0 -19
  543. package/dist/graph/reconcile/result.d.ts.map +0 -1
  544. package/dist/graph/reconcile/result.js +0 -95
  545. package/dist/graph/reconcile/result.js.map +0 -1
  546. package/dist/graph/reconcile/scope.d.ts +0 -6
  547. package/dist/graph/reconcile/scope.d.ts.map +0 -1
  548. package/dist/graph/reconcile/scope.js +0 -69
  549. package/dist/graph/reconcile/scope.js.map +0 -1
  550. package/dist/graph/result/envelope.d.ts +0 -37
  551. package/dist/graph/result/envelope.d.ts.map +0 -1
  552. package/dist/graph/result/envelope.js +0 -59
  553. package/dist/graph/result/envelope.js.map +0 -1
  554. package/dist/graph/result/index.d.ts +0 -6
  555. package/dist/graph/result/index.d.ts.map +0 -1
  556. package/dist/graph/result/index.js +0 -4
  557. package/dist/graph/result/index.js.map +0 -1
  558. package/dist/graph/result/next.d.ts +0 -16
  559. package/dist/graph/result/next.d.ts.map +0 -1
  560. package/dist/graph/result/next.js +0 -77
  561. package/dist/graph/result/next.js.map +0 -1
  562. package/dist/graph/result/paged.d.ts +0 -30
  563. package/dist/graph/result/paged.d.ts.map +0 -1
  564. package/dist/graph/result/paged.js +0 -41
  565. package/dist/graph/result/paged.js.map +0 -1
  566. package/dist/graph/wire.d.ts +0 -33
  567. package/dist/graph/wire.d.ts.map +0 -1
  568. package/dist/graph/wire.js +0 -16
  569. package/dist/graph/wire.js.map +0 -1
  570. package/dist/pacer/batcher.d.ts +0 -11
  571. package/dist/pacer/batcher.d.ts.map +0 -1
  572. package/dist/pacer/batcher.js +0 -15
  573. package/dist/pacer/batcher.js.map +0 -1
  574. package/dist/pacer/defaults.d.ts +0 -18
  575. package/dist/pacer/defaults.d.ts.map +0 -1
  576. package/dist/pacer/defaults.js +0 -18
  577. package/dist/pacer/defaults.js.map +0 -1
  578. package/dist/pacer/queue.d.ts +0 -11
  579. package/dist/pacer/queue.d.ts.map +0 -1
  580. package/dist/pacer/queue.js +0 -15
  581. package/dist/pacer/queue.js.map +0 -1
  582. package/dist/pacer/rate-limiter.d.ts +0 -11
  583. package/dist/pacer/rate-limiter.d.ts.map +0 -1
  584. package/dist/pacer/rate-limiter.js +0 -15
  585. package/dist/pacer/rate-limiter.js.map +0 -1
  586. package/dist/pacer/retry.d.ts +0 -14
  587. package/dist/pacer/retry.d.ts.map +0 -1
  588. package/dist/pacer/retry.js +0 -50
  589. package/dist/pacer/retry.js.map +0 -1
  590. package/dist/pool/errors.d.ts +0 -13
  591. package/dist/pool/errors.d.ts.map +0 -1
  592. package/dist/pool/errors.js +0 -16
  593. package/dist/pool/errors.js.map +0 -1
  594. package/dist/schema/bound/binder.d.ts +0 -49
  595. package/dist/schema/bound/binder.d.ts.map +0 -1
  596. package/dist/schema/bound/binder.js +0 -195
  597. package/dist/schema/bound/binder.js.map +0 -1
  598. package/dist/schema/bound/bound-node.d.ts +0 -105
  599. package/dist/schema/bound/bound-node.d.ts.map +0 -1
  600. package/dist/schema/bound/bound-node.js +0 -128
  601. package/dist/schema/bound/bound-node.js.map +0 -1
  602. package/dist/schema/bound/index.d.ts +0 -10
  603. package/dist/schema/bound/index.d.ts.map +0 -1
  604. package/dist/schema/bound/index.js +0 -5
  605. package/dist/schema/bound/index.js.map +0 -1
  606. package/dist/schema/bound/view.d.ts +0 -44
  607. package/dist/schema/bound/view.d.ts.map +0 -1
  608. package/dist/schema/bound/view.js +0 -117
  609. package/dist/schema/bound/view.js.map +0 -1
  610. package/dist/schema/bound/write-props.d.ts +0 -38
  611. package/dist/schema/bound/write-props.d.ts.map +0 -1
  612. package/dist/schema/bound/write-props.js +0 -2
  613. package/dist/schema/bound/write-props.js.map +0 -1
  614. package/dist/schema/call-args.d.ts +0 -6
  615. package/dist/schema/call-args.d.ts.map +0 -1
  616. package/dist/schema/call-args.js +0 -21
  617. package/dist/schema/call-args.js.map +0 -1
  618. package/dist/schema/class-proxy.d.ts +0 -11
  619. package/dist/schema/class-proxy.d.ts.map +0 -1
  620. package/dist/schema/class-proxy.js +0 -46
  621. package/dist/schema/class-proxy.js.map +0 -1
  622. package/dist/schema/extract.d.ts +0 -24
  623. package/dist/schema/extract.d.ts.map +0 -1
  624. package/dist/schema/extract.js +0 -45
  625. package/dist/schema/extract.js.map +0 -1
  626. package/dist/schema/from-entries.d.ts +0 -12
  627. package/dist/schema/from-entries.d.ts.map +0 -1
  628. package/dist/schema/from-entries.js +0 -39
  629. package/dist/schema/from-entries.js.map +0 -1
  630. package/dist/schema/index.d.ts +0 -16
  631. package/dist/schema/index.d.ts.map +0 -1
  632. package/dist/schema/index.js +0 -12
  633. package/dist/schema/index.js.map +0 -1
  634. package/dist/schema/known-dispatch.d.ts +0 -6
  635. package/dist/schema/known-dispatch.d.ts.map +0 -1
  636. package/dist/schema/known-dispatch.js +0 -39
  637. package/dist/schema/known-dispatch.js.map +0 -1
  638. package/dist/schema/node-proxy.d.ts +0 -21
  639. package/dist/schema/node-proxy.d.ts.map +0 -1
  640. package/dist/schema/node-proxy.js +0 -75
  641. package/dist/schema/node-proxy.js.map +0 -1
  642. package/dist/schema/persistence.d.ts +0 -31
  643. package/dist/schema/persistence.d.ts.map +0 -1
  644. package/dist/schema/persistence.js +0 -2
  645. package/dist/schema/persistence.js.map +0 -1
  646. package/dist/schema/proxy-types.d.ts +0 -131
  647. package/dist/schema/proxy-types.d.ts.map +0 -1
  648. package/dist/schema/proxy-types.js +0 -2
  649. package/dist/schema/proxy-types.js.map +0 -1
  650. package/dist/schema/registry.d.ts +0 -50
  651. package/dist/schema/registry.d.ts.map +0 -1
  652. package/dist/schema/registry.js +0 -110
  653. package/dist/schema/registry.js.map +0 -1
  654. package/dist/schema/resolve.d.ts +0 -26
  655. package/dist/schema/resolve.d.ts.map +0 -1
  656. package/dist/schema/resolve.js +0 -27
  657. package/dist/schema/resolve.js.map +0 -1
  658. package/dist/schema/typed-client.d.ts +0 -10
  659. package/dist/schema/typed-client.d.ts.map +0 -1
  660. package/dist/schema/typed-client.js +0 -26
  661. package/dist/schema/typed-client.js.map +0 -1
  662. package/dist/schema/types.d.ts +0 -9
  663. package/dist/schema/types.d.ts.map +0 -1
  664. package/dist/schema/types.js +0 -2
  665. package/dist/schema/types.js.map +0 -1
  666. package/dist/session/bound.d.ts +0 -11
  667. package/dist/session/bound.d.ts.map +0 -1
  668. package/dist/session/bound.js +0 -42
  669. package/dist/session/bound.js.map +0 -1
  670. package/dist/session/client-session.d.ts +0 -72
  671. package/dist/session/client-session.d.ts.map +0 -1
  672. package/dist/session/client-session.js +0 -673
  673. package/dist/session/client-session.js.map +0 -1
  674. package/dist/session/config.d.ts +0 -168
  675. package/dist/session/config.d.ts.map +0 -1
  676. package/dist/session/config.js +0 -2
  677. package/dist/session/config.js.map +0 -1
  678. package/dist/session/delegation/cache.d.ts +0 -139
  679. package/dist/session/delegation/cache.d.ts.map +0 -1
  680. package/dist/session/delegation/cache.js +0 -256
  681. package/dist/session/delegation/cache.js.map +0 -1
  682. package/dist/session/delegation/errors.d.ts +0 -44
  683. package/dist/session/delegation/errors.d.ts.map +0 -1
  684. package/dist/session/delegation/errors.js +0 -62
  685. package/dist/session/delegation/errors.js.map +0 -1
  686. package/dist/session/delegation/policy.d.ts +0 -183
  687. package/dist/session/delegation/policy.d.ts.map +0 -1
  688. package/dist/session/delegation/policy.js +0 -114
  689. package/dist/session/delegation/policy.js.map +0 -1
  690. package/dist/session/delegation/utils.d.ts +0 -4
  691. package/dist/session/delegation/utils.d.ts.map +0 -1
  692. package/dist/session/delegation/utils.js +0 -12
  693. package/dist/session/delegation/utils.js.map +0 -1
  694. package/dist/session/delegation-mint.d.ts +0 -13
  695. package/dist/session/delegation-mint.d.ts.map +0 -1
  696. package/dist/session/delegation-mint.js +0 -39
  697. package/dist/session/delegation-mint.js.map +0 -1
  698. package/dist/session/dispatch-routes.d.ts +0 -27
  699. package/dist/session/dispatch-routes.d.ts.map +0 -1
  700. package/dist/session/dispatch-routes.js +0 -77
  701. package/dist/session/dispatch-routes.js.map +0 -1
  702. package/dist/session/errors/index.d.ts +0 -6
  703. package/dist/session/errors/index.d.ts.map +0 -1
  704. package/dist/session/errors/index.js +0 -8
  705. package/dist/session/errors/index.js.map +0 -1
  706. package/dist/session/errors/session-errors.d.ts +0 -52
  707. package/dist/session/errors/session-errors.d.ts.map +0 -1
  708. package/dist/session/errors/session-errors.js +0 -70
  709. package/dist/session/errors/session-errors.js.map +0 -1
  710. package/dist/session/forward.d.ts +0 -15
  711. package/dist/session/forward.d.ts.map +0 -1
  712. package/dist/session/forward.js +0 -40
  713. package/dist/session/forward.js.map +0 -1
  714. package/dist/session/helpers.d.ts +0 -23
  715. package/dist/session/helpers.d.ts.map +0 -1
  716. package/dist/session/helpers.js +0 -56
  717. package/dist/session/helpers.js.map +0 -1
  718. package/dist/session/hooks.d.ts +0 -140
  719. package/dist/session/hooks.d.ts.map +0 -1
  720. package/dist/session/hooks.js +0 -2
  721. package/dist/session/hooks.js.map +0 -1
  722. package/dist/session/redirect/errors.d.ts +0 -45
  723. package/dist/session/redirect/errors.d.ts.map +0 -1
  724. package/dist/session/redirect/errors.js +0 -52
  725. package/dist/session/redirect/errors.js.map +0 -1
  726. package/dist/session/redirect/policy.d.ts +0 -79
  727. package/dist/session/redirect/policy.d.ts.map +0 -1
  728. package/dist/session/redirect/policy.js +0 -69
  729. package/dist/session/redirect/policy.js.map +0 -1
  730. package/dist/session/types.d.ts +0 -54
  731. package/dist/session/types.d.ts.map +0 -1
  732. package/dist/session/types.js +0 -2
  733. package/dist/session/types.js.map +0 -1
  734. package/dist/store/canonicalize.d.ts +0 -44
  735. package/dist/store/canonicalize.d.ts.map +0 -1
  736. package/dist/store/canonicalize.js +0 -0
  737. package/dist/store/canonicalize.js.map +0 -1
  738. package/dist/store/entities.d.ts +0 -81
  739. package/dist/store/entities.d.ts.map +0 -1
  740. package/dist/store/entities.js +0 -202
  741. package/dist/store/entities.js.map +0 -1
  742. package/dist/store/invalidate.d.ts +0 -66
  743. package/dist/store/invalidate.d.ts.map +0 -1
  744. package/dist/store/invalidate.js +0 -117
  745. package/dist/store/invalidate.js.map +0 -1
  746. package/dist/store/overlay.d.ts +0 -118
  747. package/dist/store/overlay.d.ts.map +0 -1
  748. package/dist/store/overlay.js +0 -237
  749. package/dist/store/overlay.js.map +0 -1
  750. package/dist/store/schedule.d.ts +0 -31
  751. package/dist/store/schedule.d.ts.map +0 -1
  752. package/dist/store/schedule.js +0 -76
  753. package/dist/store/schedule.js.map +0 -1
  754. package/dist/store/shapes.d.ts +0 -92
  755. package/dist/store/shapes.d.ts.map +0 -1
  756. package/dist/store/shapes.js +0 -369
  757. package/dist/store/shapes.js.map +0 -1
  758. package/dist/store/types.d.ts +0 -168
  759. package/dist/store/types.d.ts.map +0 -1
  760. package/dist/store/types.js +0 -7
  761. package/dist/store/types.js.map +0 -1
  762. package/dist/transport/binary.d.ts +0 -15
  763. package/dist/transport/binary.d.ts.map +0 -1
  764. package/dist/transport/binary.js +0 -2
  765. package/dist/transport/binary.js.map +0 -1
  766. package/dist/transport/contract.d.ts +0 -58
  767. package/dist/transport/contract.d.ts.map +0 -1
  768. package/dist/transport/contract.js +0 -11
  769. package/dist/transport/contract.js.map +0 -1
  770. package/dist/transport/fetch.d.ts +0 -31
  771. package/dist/transport/fetch.d.ts.map +0 -1
  772. package/dist/transport/fetch.js +0 -78
  773. package/dist/transport/fetch.js.map +0 -1
  774. package/dist/transport/http-envelope.d.ts +0 -49
  775. package/dist/transport/http-envelope.d.ts.map +0 -1
  776. package/dist/transport/http-envelope.js +0 -418
  777. package/dist/transport/http-envelope.js.map +0 -1
  778. package/dist/transport/http-routed.d.ts +0 -61
  779. package/dist/transport/http-routed.d.ts.map +0 -1
  780. package/dist/transport/http-routed.js +0 -409
  781. package/dist/transport/http-routed.js.map +0 -1
  782. package/dist/transport/request-id.d.ts +0 -9
  783. package/dist/transport/request-id.d.ts.map +0 -1
  784. package/dist/transport/request-id.js +0 -12
  785. package/dist/transport/request-id.js.map +0 -1
  786. package/dist/transport/ws-envelope.d.ts +0 -74
  787. package/dist/transport/ws-envelope.d.ts.map +0 -1
  788. package/dist/transport/ws-envelope.js +0 -567
  789. package/dist/transport/ws-envelope.js.map +0 -1
  790. package/dist/util/race-signal.d.ts +0 -12
  791. package/dist/util/race-signal.d.ts.map +0 -1
  792. package/dist/util/race-signal.js +0 -34
  793. package/dist/util/race-signal.js.map +0 -1
  794. package/dist/wire/controller.d.ts +0 -38
  795. package/dist/wire/controller.d.ts.map +0 -1
  796. package/dist/wire/controller.js +0 -38
  797. package/dist/wire/controller.js.map +0 -1
  798. package/dist/wire/index.d.ts +0 -7
  799. package/dist/wire/index.d.ts.map +0 -1
  800. package/dist/wire/index.js +0 -4
  801. package/dist/wire/index.js.map +0 -1
  802. package/dist/wire/meta.d.ts +0 -81
  803. package/dist/wire/meta.d.ts.map +0 -1
  804. package/dist/wire/meta.js +0 -44
  805. package/dist/wire/meta.js.map +0 -1
  806. package/dist/wire/sse.d.ts +0 -67
  807. package/dist/wire/sse.d.ts.map +0 -1
  808. package/dist/wire/sse.js +0 -170
  809. package/dist/wire/sse.js.map +0 -1
@@ -1,813 +1,397 @@
1
- /**
2
- * createMemory (FRONTEND §4.5, SHELL_REACT §5) — the framework-free memory
3
- * facade over a `GraphApi`.
4
- *
5
- * One partial client copy of the graph per scope (= principal): entity store +
6
- * shape store + optimistic overlay. Reads are shape-keyed, deduped, and
7
- * stale-while-revalidate; a `subscribe`/`getSnapshot` pair gives
8
- * useSyncExternalStore semantics (tear-free, referentially stable when
9
- * unchanged) and `promise` a cold-shape handle for React suspense.
10
- *
11
- * SAFE MODE (§5.7 — ratified until the §6 wire amendments land). One rule:
12
- * **confirmed state comes only from server responses; client predictions live
13
- * only in a display layer guaranteed to be discarded and replaced by server
14
- * truth.** Concretely:
15
- * - Confirmed state (EntityStore + shape membership) is written ONLY by read
16
- * responses (`integrate` / `integrateShape`).
17
- * - Every write DISPATCHES, then marks the shapes it touched stale and
18
- * REVALIDATES them (refetch = reconcile). "Slow but never wrong."
19
- * - The optimistic overlay is DISPLAY-ONLY. Prop updates on cached nodes and
20
- * deletes get an overlay (no-flicker prediction); creates/links/unlinks are
21
- * reconcile-only (a create/link misprediction is a phantom, forbidden; a
22
- * delete misprediction is loud — a brief reappearance). The overlay is held
23
- * from apply until the reconciling refetch lands, then dropped — never
24
- * folded into confirmed state.
25
- * - Ordering: the logical merge clock is stamped at response ARRIVAL, and a
26
- * per-scope mutation EPOCH closes the read-straddles-commit window (a
27
- * response older than a commit is integrated-then-restaled).
28
- * - Isolation: the `with` lens partitions the ENTITY store, not just the
29
- * shape key — lenses never share entities.
30
- *
31
- * The public surface (`GraphMemory`/`LiveResult`, `createMemory`) is stable:
32
- * when seq/rev/delta/watch (§6/§7) land, this becomes "fast and never wrong"
33
- * with no surface change (`commitOverlay` is already the server-delta seam).
34
- */
35
- import { Graph, rawOf } from '@astrale-os/kernel-core';
36
- import { edgeKey } from '../graph/index.js';
37
- import { mintedId, PatchBuilderImpl } from '../graph/mutate/index.js';
38
- import { HAS_PARENT_CLASS } from '../graph/query/edges.js';
39
- import { shapeInputToAST, shapeKey, stripCursors } from './canonicalize.js';
40
- import { EntityStore } from './entities.js';
41
- import { affectedShapes } from './invalidate.js';
42
- import { normalizePatch, Overlay } from './overlay.js';
43
- import { TaskQueue } from './schedule.js';
44
- import { integrateShape, materialize, ShapeStore, shapeViewOf } from './shapes.js';
45
- /** Bind the memory onto a `GraphApi`. */
46
- export function createMemory(api, opts) {
47
- return new Memory(api, opts).facade(opts?.scope ?? 'default');
48
- }
49
- class Memory {
50
- defaultApi;
51
- scopes = new Map();
52
- apis = new Map();
53
- now;
54
- ttlMs;
55
- tombstoneTtlMs;
56
- onError;
57
- dev;
58
- sweepEvery;
59
- scheduler;
60
- clock = 0;
61
- mutationSeq = 0;
62
- opCount = 0;
63
- constructor(defaultApi, opts) {
64
- this.defaultApi = defaultApi;
65
- this.now = opts?.now ?? Date.now;
66
- this.ttlMs = opts?.ttlMs ?? 30_000;
67
- this.tombstoneTtlMs = opts?.tombstoneTtlMs ?? 300_000;
68
- this.onError = opts?.onError;
69
- this.dev = opts?.dev ?? false;
70
- this.sweepEvery = opts?.sweepEvery ?? 128;
71
- this.scheduler = new TaskQueue(opts?.concurrency ?? 4);
72
- }
73
- facade(scope) {
74
- return {
75
- scope,
76
- api: this.apiFor(scope),
77
- query: (shape, o) => this.query(scope, shape, o),
78
- peek: (shape, o) => this.peek(scope, shape, o),
79
- preload: (shape, o) => this.preload(scope, shape, o),
80
- subscribe: (shape, cb, o) => this.subscribe(scope, shape, cb, o),
81
- getSnapshot: (shape, o) => this.getSnapshot(scope, shape, o),
82
- promise: (shape, o) => this.promise(scope, shape, o),
83
- watch: (shape, cb, o) => this.watchShape(scope, shape, cb, o),
84
- mutate: (arg, o) => this.mutate(scope, arg, o),
85
- reconcile: (input) => this.runReconcile(scope, input),
86
- update: (node, props, o) => this.update(scope, node, props, o),
87
- create: (cls, at, props, o) => this.create(scope, cls, at, props, o),
88
- remove: (node, o) => this.remove(scope, node, o),
89
- link: (edge, o) => this.link(scope, edge, o),
90
- unlink: (edge, o) => this.unlink(scope, edge, o),
91
- overlay: (build, o) => this.openOverlay(o?.scope ?? scope, build),
92
- forScope: (s, a) => {
93
- if (a !== undefined)
94
- this.apis.set(s, a);
95
- return this.facade(s);
96
- },
97
- sweep: () => this.sweep(),
98
- };
99
- }
100
- // ── Scope + key plumbing ────────────────────────────────────────────────────
101
- apiFor(scope) {
102
- return this.apis.get(scope) ?? this.defaultApi;
103
- }
104
- /**
105
- * The isolation key partitions the store by `(principal, with-lens)` (§5.7):
106
- * two lenses over the same principal never share entities, shapes, or overlay.
107
- */
108
- isoKey(principal, withPerm) {
109
- return withPerm === undefined ? principal : `${principal}::with=${withPerm}`;
110
- }
111
- state(principal, withPerm) {
112
- const key = this.isoKey(principal, withPerm);
113
- let s = this.scopes.get(key);
114
- if (s === undefined) {
115
- s = {
116
- principal,
117
- isoKey: key,
118
- entities: new EntityStore(),
119
- shapes: new ShapeStore(),
120
- overlay: new Overlay(),
121
- epoch: 0,
122
- };
123
- this.scopes.set(key, s);
1
+ import { encodeEdgeKey } from '@astrale-os/kernel-core/graph/edge';
2
+ import { ClientError } from '../errors/index.js';
3
+ import { edgeIdentity, EntityIndex } from './entity-index.js';
4
+ import { OptimisticOverlay } from './optimistic.js';
5
+ import { COLD_SNAPSHOT, QueryShape } from './shape.js';
6
+ export class GraphMemory {
7
+ options;
8
+ entities = new EntityIndex();
9
+ overlay = new OptimisticOverlay();
10
+ shapes = new Map();
11
+ pending = [];
12
+ active = 0;
13
+ constructor(options) {
14
+ this.options = options;
15
+ }
16
+ ensure(key, ast, page) {
17
+ const existing = this.shapes.get(key);
18
+ const now = this.options.now();
19
+ if (existing !== undefined) {
20
+ this.touch(existing, now);
21
+ return existing;
124
22
  }
125
- return s;
126
- }
127
- /** Every lens partition of a principal — a write reconciles across all of them. */
128
- partitionsOf(principal) {
129
- return [...this.scopes.values()].filter((s) => s.principal === principal);
130
- }
131
- keyOf(state, scope, ast) {
132
- return shapeKey(ast, scope, (raw) => state.entities.resolvePathToId(raw));
133
- }
134
- /** Normalize an input to its AST, folding a per-read `with` onto it so it keys the shape. */
135
- astFor(input, opts) {
136
- const ast = shapeInputToAST(input);
137
- if (opts?.with !== undefined && ast.with !== opts.with)
138
- return { ...ast, with: opts.with };
139
- return ast;
140
- }
141
- /** Resolve (and create) the entry for a shape input. */
142
- entryFor(state, scope, input, opts) {
143
- const ast = this.astFor(input, opts);
144
- const key = this.keyOf(state, scope, ast);
145
- const created = state.shapes.get(key) === undefined;
146
- const entry = state.shapes.ensure(key, scope, stripCursors(ast), ast.from.map(rawOf));
147
- // window is per-shape and fixed at creation — a later caller's option can't
148
- // retune a shape other observers already read under.
149
- if (created && opts?.window !== undefined)
150
- entry.window = opts.window;
151
- if (entry.observers === 0 && entry.releasedAt === null)
152
- entry.releasedAt = this.now();
153
- return entry;
154
- }
155
- /** Look up an existing entry without creating one (peek / render-pure getSnapshot). */
156
- lookup(state, scope, input, opts) {
157
- return state.shapes.get(this.keyOf(state, scope, this.astFor(input, opts)));
158
- }
159
- /** Follow the provisional→resolved alias to a subscription's live entry (post-merge). */
160
- live(state, entry) {
161
- return state.shapes.get(entry.key) ?? entry;
162
- }
163
- // ── Reads ────────────────────────────────────────────────────────────────────
164
- async query(scope, input, opts) {
165
- const state = this.state(scope, opts?.with);
166
- let entry = this.entryFor(state, scope, input, opts);
167
- this.tick();
168
- if (!entry.hasData || entry.stale) {
169
- try {
170
- await this.revalidate(state, entry, entry.hasData ? 'reconcile' : 'fresh');
171
- }
172
- catch (error) {
173
- // Warm shape: keep last-good data + `error` (§5.5); only a cold read throws.
174
- if (!this.live(state, entry).hasData)
175
- throw error;
176
- }
177
- entry = this.live(state, entry);
23
+ this.releaseExpired(now);
24
+ if (this.shapes.size >= this.options.maximumShapes)
25
+ this.evictLeastRecentlyUsed();
26
+ if (this.shapes.size >= this.options.maximumShapes) {
27
+ throw new ClientError('GraphStore shape capacity is exhausted by observed or in-flight queries.');
178
28
  }
179
- return this.snapshot(state, entry);
180
- }
181
- peek(scope, input, opts) {
182
- const state = this.state(scope, opts?.with);
183
- const entry = this.lookup(state, scope, input, opts);
184
- if (entry === undefined || !entry.hasData)
185
- return null;
186
- return this.snapshot(state, entry);
187
- }
188
- async preload(scope, input, opts) {
189
- const state = this.state(scope, opts?.with);
190
- const entry = this.entryFor(state, scope, input, opts);
191
- this.tick();
192
- if (!entry.hasData)
193
- await this.revalidate(state, entry, 'fresh').catch(() => { });
194
- }
195
- subscribe(scope, input, onStoreChange, opts) {
196
- const state = this.state(scope, opts?.with);
197
- const entry = this.entryFor(state, scope, input, opts);
198
- entry.observers++;
199
- entry.releasedAt = null;
200
- entry.listeners.add(onStoreChange);
201
- this.tick();
202
- // Fetch when cold, and revalidate when known-stale (a prior write or a failed
203
- // refresh left it stale) — §5.5. Reconcile preserves the accumulated window.
204
- if ((!entry.hasData || entry.stale) && entry.inflight === null && opts?.live !== false) {
205
- void this.revalidate(state, entry, entry.hasData ? 'reconcile' : 'fresh').catch(() => { });
206
- }
207
- return () => {
208
- // A merge (rehome) may have moved this subscription onto the surviving
209
- // entry — re-resolve so the count/listener land on the live one.
210
- const e = this.live(state, entry);
211
- e.listeners.delete(onStoreChange);
212
- e.observers = Math.max(0, e.observers - 1);
213
- if (e.observers === 0)
214
- e.releasedAt = this.now();
215
- };
216
- }
217
- /**
218
- * Render-pure (§5.7): reads an EXISTING entry, never creates one (entry
219
- * creation is a subscribe/query concern — creating here double-mints entries
220
- * under StrictMode's double render). A cold shape returns a shared, stable
221
- * placeholder so useSyncExternalStore sees a referentially constant snapshot.
222
- */
223
- getSnapshot(scope, input, opts) {
224
- const state = this.state(scope, opts?.with);
225
- const entry = this.lookup(state, scope, input, opts);
226
- if (entry === undefined)
227
- return COLD;
228
- return this.snapshot(state, entry);
229
- }
230
- promise(scope, input, opts) {
231
- const state = this.state(scope, opts?.with);
232
- const entry = this.entryFor(state, scope, input, opts);
233
- if (entry.hasData)
234
- return Promise.resolve(this.snapshot(state, entry));
235
- return this.revalidate(state, entry, 'fresh').then(() => this.snapshot(state, this.live(state, entry)));
236
- }
237
- watchShape(scope, input, cb, opts) {
238
- const state = this.state(scope, opts?.with);
239
- const entry = this.entryFor(state, scope, input, opts);
240
- const unsub = this.subscribe(scope, input, () => cb(this.snapshot(state, this.live(state, entry))), opts);
241
- cb(this.snapshot(state, this.live(state, entry)));
242
- return unsub;
243
- }
244
- // ── Fetch / integrate ─────────────────────────────────────────────────────────
245
- /** The AST + membership mode a revalidation intent requests (§5.7 window-preserving). */
246
- fetchPlan(entry, intent) {
247
- if (intent === 'more') {
248
- return {
249
- ast: entry.contAst ?? entry.baseAst,
250
- mode: entry.window === 'paged' ? 'replace' : 'append',
251
- };
29
+ const shape = new QueryShape(key, ast, page, now);
30
+ shape.releasedAt = now;
31
+ this.shapes.set(key, shape);
32
+ return shape;
33
+ }
34
+ get(key) {
35
+ const shape = this.shapes.get(key);
36
+ if (shape !== undefined)
37
+ this.touch(shape, this.options.now());
38
+ return shape;
39
+ }
40
+ async read(shape, options) {
41
+ this.options.requireOpen();
42
+ requireReadLive(options.signal, this.options.lifecycle);
43
+ const reusable = shape.response !== undefined &&
44
+ shape.state === 'ready' &&
45
+ shape.refreshedAt !== undefined &&
46
+ this.options.now() - shape.refreshedAt < this.options.ttlMs;
47
+ if (options.freshness !== 'refresh' && reusable)
48
+ return shape.response;
49
+ if (shape.inflight !== undefined) {
50
+ return observeRead(shape.inflight, options, this.options.lifecycle);
252
51
  }
253
- // A reconcile re-requests the whole accumulated window so an 'append' window
254
- // never collapses to page 1 on a write; a fresh eval resets to page 1.
255
- if (intent === 'reconcile')
256
- return { ast: windowAst(entry.baseAst, entry.windowPages), mode: 'replace' };
257
- return { ast: entry.baseAst, mode: 'replace' };
258
- }
259
- /**
260
- * Fetch a page and fold it in. Deduped on `entry.inflight` (two identical
261
- * in-flight shapes share ONE api call). The merge clock is stamped at response
262
- * ARRIVAL, and a response older than a committed mutation (dispatch-epoch <
263
- * current epoch) is integrated-then-restaled to close the straddle window.
264
- */
265
- revalidate(state, entry, intent) {
266
- if (entry.inflight !== null)
267
- return entry.inflight;
268
- const { ast, mode } = this.fetchPlan(entry, intent);
269
- const dispatchEpoch = state.epoch;
270
- const p = this.apiFor(entry.scope)
271
- .query(ast)
272
- .then((result) => {
273
- const wire = result.wire;
274
- const seq = ++this.clock; // ARRIVAL order (§5.7), not dispatch order
275
- state.entities.integrate(wire, seq);
276
- const resolvedKey = this.keyOf(state, entry.scope, entry.baseAst);
277
- const live = state.shapes.rehome(entry, resolvedKey);
278
- live.inflight = null;
279
- if (intent === 'more' && mode === 'append')
280
- live.windowPages++;
281
- else if (intent === 'fresh')
282
- live.windowPages = 1;
283
- integrateShape(live, wire, seq, mode);
284
- if (dispatchEpoch < state.epoch) {
285
- // Read straddled a commit: integrate (so a cold shape still gets data
286
- // and continuous writes can't starve it) THEN restale (so it converges
287
- // — at quiescence the last refetch's epoch matches). Chosen over
288
- // discard for those two reasons.
289
- live.stale = true;
290
- void this.scheduleReconcile(state, live);
52
+ const prior = shape.response;
53
+ this.publish(shape, prior === undefined ? 'loading' : this.overlay.hasAny() ? 'optimistic' : 'refreshing');
54
+ const inflight = this.schedule(async () => {
55
+ const result = await this.options.graph.query(shape.ast, queryOptions(shape.page, this.options.lifecycle));
56
+ this.options.requireOpen();
57
+ const integration = this.entities.integrate(result.result);
58
+ shape.references = integration.references;
59
+ shape.confirmed = result;
60
+ shape.response = this.materialize(result, integration.references);
61
+ shape.refreshedAt = this.options.now();
62
+ this.touch(shape, shape.refreshedAt);
63
+ this.publish(shape, this.overlay.hasAny() ? 'optimistic' : 'ready');
64
+ for (const other of this.shapes.values()) {
65
+ if (other === shape || other.response === undefined)
66
+ continue;
67
+ if (other.referencesAny(integration.changedNodes, integration.changedEdges)) {
68
+ other.response = this.materialize(other.confirmed, other.references);
69
+ this.publish(other, other.state);
70
+ }
291
71
  }
292
- this.notify(live);
293
- this.audit(state);
294
- return wire;
72
+ return shape.response;
295
73
  })
296
74
  .catch((error) => {
297
- const live = state.shapes.get(entry.key) ?? entry;
298
- live.inflight = null;
299
- live.error = error;
300
- live.stale = true;
301
- live.dirty = true;
302
- this.emit({ kind: 'refresh', shape: live.key, error });
303
- this.notify(live);
75
+ if (prior === undefined)
76
+ this.publish(shape, 'failed', error);
77
+ else {
78
+ shape.response = prior;
79
+ this.publish(shape, this.overlay.hasAny() ? 'optimistic' : 'stale');
80
+ }
304
81
  throw error;
82
+ })
83
+ .finally(() => {
84
+ if (shape.inflight === inflight)
85
+ shape.inflight = undefined;
305
86
  });
306
- entry.inflight = p;
307
- entry.dirty = true;
308
- this.notify(entry);
309
- return p;
87
+ shape.inflight = inflight;
88
+ return observeRead(inflight, options, this.options.lifecycle);
310
89
  }
311
- /** Coalesced, concurrency-capped reconcile refetch — resolves when it lands (§5.7). */
312
- scheduleReconcile(state, entry) {
313
- return this.scheduler.request(entry, () => this.revalidate(state, this.live(state, entry), 'reconcile').then(() => undefined, () => undefined));
90
+ snapshot(shape) {
91
+ return shape?.snapshot ?? COLD_SNAPSHOT;
314
92
  }
315
- // ── Snapshot (referential stability) ──────────────────────────────────────────
316
- /** The live result, rebuilt only when the shape is dirty (stable ref otherwise). */
317
- snapshot(state, entry) {
318
- if (!entry.dirty && entry.result !== null)
319
- return entry.result;
320
- const mat = materialize(entry, state.entities, state.overlay);
321
- const result = {
322
- graph: mat.graph,
323
- roots: mat.roots,
324
- nodes: mat.nodes,
325
- first: mat.first,
326
- node: mat.first,
327
- children: mat.children,
328
- gathered: (alias) => mat.gathered(alias),
329
- pending: entry.inflight !== null,
330
- stale: entry.stale,
331
- error: entry.error,
332
- live: entry.observers > 0,
333
- seq: 0,
334
- more: {
335
- has: !entry.exhausted && entry.contAst !== null,
336
- pending: entry.inflight !== null,
337
- load: async () => {
338
- const e = this.live(state, entry);
339
- if (e.exhausted || e.contAst === null)
340
- return;
341
- await this.revalidate(state, e, 'more');
342
- },
343
- },
344
- refetch: async () => {
345
- const e = this.live(state, entry);
346
- e.stale = true;
347
- await this.revalidate(state, e, 'reconcile'); // window-preserving
348
- },
93
+ subscribe(shape, listener) {
94
+ this.options.requireOpen();
95
+ shape.listeners.add(listener);
96
+ shape.accessedAt = this.options.now();
97
+ shape.releasedAt = undefined;
98
+ return () => {
99
+ shape.listeners.delete(listener);
100
+ if (!shape.observed)
101
+ shape.releasedAt = this.options.now();
349
102
  };
350
- entry.result = result;
351
- entry.dirty = false;
352
- return result;
353
103
  }
354
- notify(entry) {
355
- entry.dirty = true;
356
- for (const listener of entry.listeners)
357
- listener();
358
- }
359
- // ── Writes (dispatch → reconcile; display-only overlay) ─────────────────────────
360
- async mutate(scope, arg, opts) {
361
- if (typeof arg === 'function') {
362
- const builder = new PatchBuilderImpl();
363
- await arg(builder);
364
- const patch = builder.build();
365
- const result = await this.applyWrite(scope, patch, opts);
366
- builder.resolve(result.createdNodes);
367
- return result;
368
- }
369
- return this.applyWrite(scope, arg, opts);
370
- }
371
- async runReconcile(scope, input) {
372
- const result = await this.apiFor(scope).reconcile(input);
373
- if (!result.applied)
374
- return result;
375
- const dispatched = normalizePatch(result.patch);
376
- if (!patchHasOperations(dispatched))
377
- return result;
378
- for (const part of this.partitionsOf(scope)) {
379
- part.epoch++;
380
- for (const p of this.markStaleByPatch(part, dispatched))
381
- void p;
104
+ invalidate(shape) {
105
+ this.options.requireOpen();
106
+ for (const candidate of shape === undefined ? this.shapes.values() : [shape]) {
107
+ if (candidate.response === undefined)
108
+ continue;
109
+ this.publish(candidate, this.overlay.hasAny() ? 'optimistic' : 'stale');
110
+ if (candidate.observed && candidate.inflight === undefined) {
111
+ void this.read(candidate, { page: candidate.page }).catch((error) => this.report(error));
112
+ }
382
113
  }
383
- return result;
384
- }
385
- async update(scope, node, props, opts) {
386
- const state = this.state(scope);
387
- const patch = {
388
- nodes: { update: [{ class: this.classOf(state, node), path: refPathRaw(node), props }] },
389
- };
390
- await this.applyWrite(scope, patch, opts);
391
114
  }
392
- async create(scope, cls, at, props, opts) {
393
- const atRaw = rawOf(at);
394
- const patch = {
395
- nodes: { create: [{ class: rawOf(cls), at: atRaw, props: props ?? {} }] },
396
- };
397
- const result = await this.applyWrite(scope, patch, opts);
398
- return mintedId(result.createdNodes, atRaw, 'node');
399
- }
400
- async remove(scope, node, opts) {
401
- const state = this.state(scope);
402
- const patch = {
403
- nodes: { delete: [{ class: this.classOf(state, node), path: refPathRaw(node) }] },
404
- };
405
- await this.applyWrite(scope, patch, opts);
406
- }
407
- async link(scope, edge, opts) {
408
- const { props, ...identity } = edge;
409
- const patch = {
410
- edges: { create: [{ ...rawIdentity(identity), props: props ?? {} }] },
411
- };
412
- const result = await this.applyWrite(scope, patch, opts);
413
- return mintedId(result.createdEdges, edgeKey(identity), 'edge');
414
- }
415
- async unlink(scope, edge, opts) {
416
- const patch = { edges: { delete: [rawIdentity(edge)] } };
417
- await this.applyWrite(scope, patch, opts);
418
- }
419
- /**
420
- * SAFE MODE write (§5.7): dispatch, then reconcile the touched shapes by
421
- * refetch. `optimistic` selects the DISPLAY overlay (never folded): `'auto'`
422
- * (default) overlays the display-safe arms of the authored patch (prop updates
423
- * on cached nodes + deletes); a function overlays a manually-built patch's
424
- * display-safe arms; `false` skips the overlay. Creates/links/unlinks are
425
- * always reconcile-only — no structural membership is ever predicted.
426
- */
427
- async applyWrite(scope, patch, opts) {
428
- const home = this.state(scope);
429
- const mode = opts?.optimistic ?? 'auto';
430
- const dispatched = normalizePatch(patch);
431
- const display = mode === false
432
- ? null
433
- : this.displayArms(home, mode === 'auto' ? dispatched : normalizePatch(this.buildPatch(mode)));
434
- const txn = display !== null && display.has ? this.beginOverlay(home, display.patch) : null;
435
- this.tick();
436
- try {
437
- const result = await this.apiFor(scope).mutate(patch);
438
- // Commit acked (§5.7 ordering): bump every lens partition's epoch so any
439
- // read now in flight (dispatched pre-commit) is caught as a straddle.
440
- for (const part of this.partitionsOf(scope))
441
- part.epoch++;
442
- this.reconcile(scope, dispatched, home, txn);
443
- opts?.onCommit?.(result);
444
- return result;
445
- }
446
- catch (error) {
447
- if (txn !== null && opts?.rollback !== false)
448
- this.rollbackOverlay(home, txn);
449
- opts?.onError?.(error);
450
- this.emit({ kind: 'mutation', mutationId: txn?.mutationId ?? '(none)', error });
451
- throw error;
115
+ optimistic() {
116
+ for (const shape of this.shapes.values()) {
117
+ if (shape.response === undefined)
118
+ continue;
119
+ shape.response = this.materialize(shape.confirmed, shape.references);
120
+ this.publish(shape, 'optimistic');
452
121
  }
453
122
  }
454
- /**
455
- * The display-safe subset of a patch: prop updates on ALREADY-CACHED nodes
456
- * whose every key is unambiguously qualifiable, plus deletes. Creates, edges,
457
- * uncached/ambiguous updates are dropped (reconcile-only) — a create/link
458
- * misprediction would be a phantom (forbidden); a delete misprediction is
459
- * merely loud (§5.7).
460
- */
461
- displayArms(state, dispatched) {
462
- const update = [];
463
- for (const u of dispatched.nodes.update) {
464
- const id = state.entities.resolvePathToId(u.path);
465
- if (id === undefined)
466
- continue; // not cached → reconcile-only (can't predict blind)
467
- const ref = state.entities.node(id)?.wire.props;
468
- const q = qualifyKeys(u.props, ref);
469
- if (q.unresolved)
470
- continue; // ambiguous/unqualifiable key → reconcile-only
471
- update.push({ ...u, props: q.props });
123
+ settleOptimistic() {
124
+ for (const shape of this.shapes.values()) {
125
+ if (shape.response === undefined)
126
+ continue;
127
+ shape.response = this.materialize(shape.confirmed, shape.references);
128
+ this.publish(shape, this.overlay.hasAny() ? 'optimistic' : 'stale');
472
129
  }
473
- const del = dispatched.nodes.delete;
474
- const patch = {
475
- nodes: { create: [], update, delete: del },
476
- edges: { create: [], update: [], delete: [] },
477
- };
478
- return { patch, has: update.length > 0 || del.length > 0 };
479
130
  }
480
- /** Apply a display overlay unit (no membership mutation) and notify its shapes. */
481
- beginOverlay(state, displayPatch) {
482
- const mutationId = `m${++this.mutationSeq}`;
483
- state.overlay.add({
484
- mutationId,
485
- patch: displayPatch,
486
- provisionalNodes: new Map(),
487
- provisionalEdges: new Map(),
488
- });
489
- const affected = this.affectedEntries(state, displayPatch);
490
- for (const entry of affected)
491
- this.notify(entry);
492
- this.audit(state);
493
- return { mutationId, patch: displayPatch, affected };
494
- }
495
- /** Drop a rolled-back display overlay (the dispatch failed). No membership to undo. */
496
- rollbackOverlay(state, txn) {
497
- state.overlay.drop(txn.mutationId);
498
- for (const entry of txn.affected)
499
- this.notify(entry);
500
- this.audit(state);
131
+ sweep() {
132
+ this.options.requireOpen();
133
+ this.releaseExpired(this.options.now());
501
134
  }
502
- /**
503
- * After a commit ACK: mark every shape the write touched stale and revalidate
504
- * the observed ones (across all lens partitions). Then HOLD the display overlay
505
- * until those reconciling refetches land, and DROP it — server truth has
506
- * replaced the prediction.
507
- */
508
- reconcile(scope, dispatched, home, txn) {
509
- const promises = [];
510
- for (const part of this.partitionsOf(scope)) {
511
- for (const p of this.markStaleByPatch(part, dispatched))
512
- promises.push(p);
135
+ releaseExpired(now) {
136
+ for (const [key, shape] of this.shapes) {
137
+ if (this.releasable(shape) && now - shape.releasedAt >= this.options.ttlMs) {
138
+ this.shapes.delete(key);
139
+ }
513
140
  }
514
- if (txn === null)
515
- return;
516
- void Promise.allSettled(promises).then(() => this.dropOverlay(home, txn));
517
- }
518
- /**
519
- * Drop a held overlay once its reconciling refetch has landed, emitting a
520
- * DIVERGENCE event if what it displayed differs from the refetched truth
521
- * (a delete whose node the server still returns; an update the server didn't
522
- * apply). This is the Tier-0 tripwire that a prediction was wrong.
523
- */
524
- dropOverlay(state, txn) {
525
- this.detectDivergence(state, txn);
526
- state.overlay.drop(txn.mutationId);
527
- for (const entry of txn.affected)
528
- this.notify(entry);
529
- this.audit(state);
141
+ this.sweepEntities();
530
142
  }
531
- detectDivergence(state, txn) {
532
- if (this.onError === undefined)
533
- return;
534
- const shape = firstKey(txn.affected);
535
- const eff = state.overlay.effects(state.entities);
536
- for (const u of txn.patch.nodes.update) {
537
- const id = state.entities.resolvePathToId(u.path);
538
- if (id === undefined)
143
+ evictLeastRecentlyUsed() {
144
+ let oldest;
145
+ for (const shape of this.shapes.values()) {
146
+ if (!this.releasable(shape))
539
147
  continue;
540
- const predicted = state.overlay.effectiveNode(id, state.entities, eff);
541
- const confirmed = state.entities.node(id)?.wire ?? null;
542
- for (const key of Object.keys(u.props)) {
543
- if (!Object.is(predicted?.props[key], confirmed?.props[key])) {
544
- this.emit({ kind: 'divergence', shape, id: String(id), detail: `update:${key}` });
545
- break;
546
- }
547
- }
148
+ if (oldest === undefined || shape.accessedAt < oldest.accessedAt)
149
+ oldest = shape;
548
150
  }
549
- for (const d of txn.patch.nodes.delete) {
550
- const id = state.entities.resolvePathToId(d.path);
551
- // The predicted absence diverges iff a reconciled shape still holds it.
552
- if (id !== undefined && [...txn.affected].some((e) => e.memberSet.has(id))) {
553
- this.emit({ kind: 'divergence', shape, id: String(id), detail: 'delete:still-present' });
554
- }
151
+ if (oldest !== undefined) {
152
+ this.shapes.delete(oldest.key);
153
+ this.sweepEntities();
555
154
  }
556
155
  }
557
- /** The set of shape entries a patch affects (§5.6 matcher over this partition). */
558
- affectedEntries(state, patch) {
559
- const ctx = {
560
- hasParentClass: HAS_PARENT_CLASS,
561
- resolve: (raw) => state.entities.resolvePathToId(raw),
562
- };
563
- const entries = [...state.shapes.all()];
564
- const ids = affectedShapes(patch, entries.map((e) => shapeViewOf(e, state.entities)), ctx);
565
- return new Set(entries.filter((e) => ids.has(e.key)));
156
+ releasable(shape) {
157
+ return !shape.observed && shape.inflight === undefined && shape.releasedAt !== undefined;
566
158
  }
567
- /**
568
- * Mark shapes a write affects stale and coalesce a reconcile refetch for the
569
- * observed ones (§5.5) — server-computed effects and every reconcile-only op
570
- * land here. Unobserved shapes revalidate lazily on their next subscribe/query.
571
- * Returns the observed shapes' reconcile promises so a held overlay knows when
572
- * to drop.
573
- */
574
- markStaleByPatch(state, patch) {
575
- const promises = [];
576
- for (const entry of this.affectedEntries(state, patch)) {
577
- entry.stale = true;
578
- this.notify(entry);
579
- if (entry.observers > 0)
580
- promises.push(this.scheduleReconcile(state, entry));
159
+ touch(shape, now) {
160
+ shape.accessedAt = now;
161
+ if (!shape.observed)
162
+ shape.releasedAt = now;
163
+ }
164
+ sweepEntities() {
165
+ const nodes = new Set();
166
+ const edges = new Set();
167
+ for (const shape of this.shapes.values()) {
168
+ shape.references?.nodes.forEach((id) => nodes.add(id));
169
+ shape.references?.edges.forEach((key) => edges.add(key));
581
170
  }
582
- return promises;
171
+ this.entities.sweep(nodes, edges);
583
172
  }
584
- /** Build a wire patch from a manual overlay builder callback. */
585
- buildPatch(build) {
586
- const b = new PatchBuilderImpl();
587
- build(b);
588
- return b.build();
173
+ close(error) {
174
+ for (const shape of this.shapes.values()) {
175
+ shape.listeners.clear();
176
+ shape.inflight?.catch(() => undefined);
177
+ }
178
+ this.shapes.clear();
179
+ this.entities.clear();
180
+ this.overlay.clear();
181
+ while (this.pending.length > 0)
182
+ this.pending.shift()?.reject(error);
183
+ }
184
+ materialize(template, references) {
185
+ return Object.freeze({
186
+ result: this.materializeResult(template.result, references),
187
+ page: template.page,
188
+ });
589
189
  }
590
- /**
591
- * Open a manual display overlay decoupled from any dispatch (§1.6). The caller
592
- * dispatches its own call (e.g. a domain method) and then `commit`s (reconcile
593
- * the touched shapes from the server, drop the display) or `rollback`s.
594
- */
595
- openOverlay(scope, build) {
596
- const state = this.state(scope);
597
- const display = this.displayArms(state, normalizePatch(this.buildPatch(build)));
598
- const txn = display.has ? this.beginOverlay(state, display.patch) : null;
599
- let settled = false;
600
- return {
601
- commit: (_result) => {
602
- if (settled)
603
- return;
604
- settled = true;
605
- for (const part of this.partitionsOf(scope))
606
- part.epoch++;
607
- if (txn === null)
608
- return;
609
- const promises = [];
610
- for (const entry of txn.affected) {
611
- entry.stale = true;
612
- this.notify(entry);
613
- if (entry.observers > 0)
614
- promises.push(this.scheduleReconcile(state, entry));
190
+ materializeResult(template, references) {
191
+ if (template.kind === 'nodes') {
192
+ const nodes = [];
193
+ for (const projection of template.nodes) {
194
+ if (projection.kind === 'reference') {
195
+ nodes.push(projection);
196
+ continue;
615
197
  }
616
- void Promise.allSettled(promises).then(() => this.dropOverlay(state, txn));
617
- },
618
- rollback: () => {
619
- if (settled)
620
- return;
621
- settled = true;
622
- if (txn !== null)
623
- this.rollbackOverlay(state, txn);
624
- },
625
- };
626
- }
627
- classOf(state, node) {
628
- if (isNodeValue(node))
629
- return rawOf(node.class);
630
- const id = state.entities.resolvePathToId(rawOf(node));
631
- const cls = id !== undefined ? state.entities.node(id)?.wire.class : undefined;
632
- if (cls === undefined) {
633
- throw new Error(`memory: cannot resolve the class of "${rawOf(node)}" for a write — ` +
634
- 'pass the Node value (not a bare path) for a node not yet in the memory.');
198
+ const node = this.overlay.node(projection.value.id, this.entities);
199
+ if (node !== undefined)
200
+ nodes.push(Object.freeze({ kind: 'value', value: node }));
201
+ }
202
+ return Object.freeze({
203
+ kind: 'nodes',
204
+ nodes: Object.freeze(nodes),
205
+ });
635
206
  }
636
- return cls;
637
- }
638
- // ── GC / dev invariants ──────────────────────────────────────────────────────
639
- /** Amortized housekeeping — sweep GC every `sweepEvery` ops (§5.7, no binding trust). */
640
- tick() {
641
- if (++this.opCount % this.sweepEvery === 0)
642
- this.sweep();
643
- }
644
- sweep() {
645
- const now = this.now();
646
- for (const state of this.scopes.values()) {
647
- const expired = [];
648
- for (const entry of state.shapes.all()) {
649
- if (entry.observers === 0 &&
650
- entry.releasedAt !== null &&
651
- now - entry.releasedAt > this.ttlMs) {
652
- expired.push(entry);
207
+ if (template.kind === 'edges') {
208
+ const edges = [];
209
+ for (const item of template.edges) {
210
+ const edge = item.edge.kind === 'reference'
211
+ ? item.edge
212
+ : (() => {
213
+ const value = this.entities.edge(edgeIdentity(item.edge.value));
214
+ return value === undefined
215
+ ? undefined
216
+ : Object.freeze({ kind: 'value', value });
217
+ })();
218
+ const source = item.source.kind === 'reference'
219
+ ? item.source
220
+ : (() => {
221
+ const value = this.overlay.node(item.source.value.id, this.entities);
222
+ return value === undefined
223
+ ? undefined
224
+ : Object.freeze({ kind: 'value', value });
225
+ })();
226
+ const target = item.target.kind === 'reference'
227
+ ? item.target
228
+ : (() => {
229
+ const value = this.overlay.node(item.target.value.id, this.entities);
230
+ return value === undefined
231
+ ? undefined
232
+ : Object.freeze({ kind: 'value', value });
233
+ })();
234
+ if (edge !== undefined && source !== undefined && target !== undefined) {
235
+ edges.push(Object.freeze({ edge, source, target }));
653
236
  }
654
237
  }
655
- for (const entry of expired)
656
- state.shapes.delete(entry);
657
- const reach = state.shapes.reachable();
658
- state.entities.gc(reach.nodes, reach.edges, now, this.tombstoneTtlMs);
238
+ return Object.freeze({
239
+ kind: 'edges',
240
+ edges: Object.freeze(edges),
241
+ });
659
242
  }
660
- }
661
- /**
662
- * Dev-mode invariants after a notify batch (§5.7 loudness): no optimistic id
663
- * survives in SETTLED confirmed membership, every settled membership id
664
- * resolves in the entity store, and listener count == observer count. Off by
665
- * default; violations surface on the event channel as `{ kind: 'invariant' }`.
666
- */
667
- audit(state) {
668
- if (!this.dev)
243
+ const nodes = references.nodes
244
+ .map((id) => this.overlay.node(id, this.entities))
245
+ .filter((node) => node !== undefined);
246
+ const visibleNodeIds = new Set(nodes.map(({ id }) => id));
247
+ const edges = references.edges
248
+ .map((key) => this.entities.edge(key))
249
+ .filter((edge) => edge !== undefined && visibleNodeIds.has(edge.source) && visibleNodeIds.has(edge.target));
250
+ const graph = Object.freeze({ nodes: Object.freeze(nodes), edges: Object.freeze(edges) });
251
+ const selection = materializeSelection(template.selection, visibleNodeIds, edges);
252
+ return selection.kind === 'node'
253
+ ? Object.freeze({ kind: 'graph', graph, selection })
254
+ : Object.freeze({ kind: 'graph', graph, selection });
255
+ }
256
+ publish(shape, state, error) {
257
+ const next = snapshotFor(state, shape.response, error);
258
+ if (sameSnapshot(shape.snapshot, next))
669
259
  return;
670
- for (const entry of state.shapes.all()) {
671
- if (entry.listeners.size !== entry.observers) {
672
- this.emit({
673
- kind: 'invariant',
674
- shape: entry.key,
675
- detail: `listeners ${entry.listeners.size} != observers ${entry.observers}`,
676
- });
677
- }
678
- if (entry.inflight !== null)
679
- continue; // only settled shapes are checked
680
- for (const id of entry.nodeMembers) {
681
- if (String(id).startsWith('optimistic:')) {
682
- this.emit({
683
- kind: 'invariant',
684
- shape: entry.key,
685
- detail: `optimistic id ${id} in membership`,
686
- });
687
- }
260
+ shape.state = state;
261
+ shape.snapshot = next;
262
+ for (const listener of Array.from(shape.listeners)) {
263
+ try {
264
+ listener();
688
265
  }
689
- if (state.overlay.size === 0) {
690
- for (const id of entry.nodeMembers) {
691
- if (state.entities.node(id) === undefined && !state.entities.isNodeTombstoned(id)) {
692
- this.emit({
693
- kind: 'invariant',
694
- shape: entry.key,
695
- detail: `dangling membership id ${id}`,
696
- });
697
- }
698
- }
266
+ catch (error) {
267
+ this.report(error);
699
268
  }
700
269
  }
701
270
  }
702
- emit(event) {
703
- this.onError?.(event);
271
+ schedule(task) {
272
+ return new Promise((resolve, reject) => {
273
+ const run = () => {
274
+ this.active += 1;
275
+ void task()
276
+ .then(resolve, reject)
277
+ .finally(() => {
278
+ this.active -= 1;
279
+ this.drain();
280
+ });
281
+ };
282
+ this.pending.push({ run, reject });
283
+ this.drain();
284
+ });
285
+ }
286
+ drain() {
287
+ while (this.active < this.options.concurrency && this.pending.length > 0) {
288
+ this.pending.shift().run();
289
+ }
290
+ }
291
+ report(error) {
292
+ try {
293
+ this.options.onError?.(error);
294
+ }
295
+ catch {
296
+ // Error observers cannot replace the operation's public outcome.
297
+ }
704
298
  }
705
299
  }
706
- // ── COLD placeholder (render-pure getSnapshot) ─────────────────────────────────
707
- /**
708
- * The stable snapshot a cold shape returns from `getSnapshot` (§5.7). One frozen
709
- * value shared across all cold shapes so useSyncExternalStore never tears on a
710
- * fresh object; subscribe/query create the real entry, after which snapshots are
711
- * per-entry and memoized.
712
- */
713
- const COLD = Object.freeze({
714
- graph: Graph.fromWire({ nodes: [], edges: [] }),
715
- roots: [],
716
- nodes: [],
717
- first: null,
718
- node: null,
719
- children: [],
720
- gathered: () => ({ nodes: [], first: null }),
721
- pending: false,
722
- stale: false,
723
- error: undefined,
724
- live: false,
725
- seq: 0,
726
- more: Object.freeze({ has: false, pending: false, load: async () => { } }),
727
- refetch: async () => { },
728
- });
729
- // ── ref helpers ────────────────────────────────────────────────────────────────
730
- function firstKey(entries) {
731
- for (const e of entries)
732
- return e.key;
733
- return '';
734
- }
735
- function isNodeValue(x) {
736
- return typeof x === 'object' && x !== null && 'id' in x && 'class' in x && 'path' in x;
737
- }
738
- function refPathRaw(x) {
739
- return isNodeValue(x) ? rawOf(x.path) : rawOf(x);
740
- }
741
- function rawIdentity(edge) {
742
- return {
743
- class: rawOf(edge.class),
744
- source: rawOf(edge.source),
745
- ...(edge.slug !== undefined ? { slug: edge.slug } : {}),
746
- target: rawOf(edge.target),
747
- };
300
+ function materializeSelection(selection, visibleNodes, visibleEdges) {
301
+ if (selection.kind === 'node') {
302
+ return Object.freeze({
303
+ kind: selection.kind,
304
+ ids: Object.freeze(selection.ids.filter((id) => visibleNodes.has(id))),
305
+ });
306
+ }
307
+ const edges = new Set(visibleEdges.map(encodeEdgeKey));
308
+ return Object.freeze({
309
+ kind: selection.kind,
310
+ keys: Object.freeze(selection.keys.filter((key) => edges.has(encodeEdgeKey(key)))),
311
+ });
748
312
  }
749
- function patchHasOperations(patch) {
750
- return (patch.nodes.create.length > 0 ||
751
- patch.nodes.update.length > 0 ||
752
- patch.nodes.delete.length > 0 ||
753
- patch.edges.create.length > 0 ||
754
- patch.edges.update.length > 0 ||
755
- patch.edges.delete.length > 0);
313
+ function queryOptions(page, lifecycle) {
314
+ return Object.freeze({
315
+ signal: lifecycle,
316
+ page,
317
+ });
756
318
  }
757
- /**
758
- * Fold the accumulated window into a reconcile AST (§5.7): each paged expand's
759
- * limit grows to `baseLimit × windowPages`, so a post-write refetch re-requests
760
- * everything the window had scrolled to instead of collapsing to page 1. An
761
- * unbounded (no-limit) expand already covers its whole selection — left as is.
762
- */
763
- function windowAst(base, pages) {
764
- if (pages <= 1 || base.steps === undefined)
765
- return base;
766
- const steps = base.steps.map((step) => {
767
- if (!('expand' in step))
768
- return step;
769
- const limit = step.expand.page?.limit;
770
- if (limit === undefined)
771
- return step;
772
- return { expand: { ...step.expand, page: { ...step.expand.page, limit: limit * pages } } };
319
+ function observeRead(pending, options, lifecycle) {
320
+ try {
321
+ requireReadLive(options.signal, lifecycle);
322
+ }
323
+ catch (error) {
324
+ return Promise.reject(error);
325
+ }
326
+ return new Promise((resolve, reject) => {
327
+ let timeout;
328
+ const callerCancelled = () => settleReject(cancellation(options.signal.reason));
329
+ const storeClosed = () => settleReject(cancellation(lifecycle.reason));
330
+ let settled = false;
331
+ const cleanup = () => {
332
+ if (timeout !== undefined)
333
+ clearTimeout(timeout);
334
+ options.signal?.removeEventListener('abort', callerCancelled);
335
+ lifecycle.removeEventListener('abort', storeClosed);
336
+ };
337
+ const settleResolve = (result) => {
338
+ if (settled)
339
+ return;
340
+ settled = true;
341
+ cleanup();
342
+ resolve(result);
343
+ };
344
+ function settleReject(error) {
345
+ if (settled)
346
+ return;
347
+ settled = true;
348
+ cleanup();
349
+ reject(error);
350
+ }
351
+ options.signal?.addEventListener('abort', callerCancelled, { once: true });
352
+ lifecycle.addEventListener('abort', storeClosed, { once: true });
353
+ if (options.timeoutMs !== undefined) {
354
+ timeout = setTimeout(() => settleReject(new ClientError('Store read timed out.')), options.timeoutMs);
355
+ }
356
+ void pending.then(settleResolve, settleReject);
773
357
  });
774
- return { ...base, steps };
775
358
  }
776
- // ── prop-key canonicalization ────────────────────────────────────────────────
777
- /** A fully-qualified prop key carries both a domain origin (`:`) and `.property.`. */
778
- function isQualifiedKey(key) {
779
- return key.includes(':') && key.includes('.property.');
359
+ function requireReadLive(signal, lifecycle) {
360
+ if (lifecycle.aborted)
361
+ throw cancellation(lifecycle.reason);
362
+ if (signal?.aborted === true)
363
+ throw cancellation(signal.reason);
780
364
  }
781
- /** The prop leaf — the final dot-segment (`title` from `…​.property.title`, or a bare key). */
782
- function leafOf(key) {
783
- return key.slice(key.lastIndexOf('.') + 1);
365
+ function cancellation(reason) {
366
+ return reason instanceof Error
367
+ ? reason
368
+ : new ClientError('Store read was cancelled.', { cause: reason });
784
369
  }
785
- /**
786
- * Rewrite non-qualified write keys to the fully-qualified key the reference node
787
- * already carries with the same leaf. A key with NO match, or with MORE THAN ONE
788
- * match (two qualified keys sharing a leaf — ambiguous, never first-match-wins,
789
- * §5.7 7a), passes through and flags `unresolved` so the write is reconcile-only
790
- * rather than mispredicted.
791
- */
792
- function qualifyKeys(props, ref) {
793
- let unresolved = false;
794
- const out = {};
795
- for (const [k, v] of Object.entries(props)) {
796
- if (isQualifiedKey(k)) {
797
- out[k] = v;
798
- continue;
799
- }
800
- const leaf = leafOf(k);
801
- const matches = ref !== undefined
802
- ? Object.keys(ref).filter((rk) => isQualifiedKey(rk) && leafOf(rk) === leaf)
803
- : [];
804
- if (matches.length === 1)
805
- out[matches[0]] = v;
806
- else {
807
- out[k] = v;
808
- unresolved = true; // 0 matches OR >1 (ambiguous) → reconcile, don't guess
370
+ function snapshotFor(state, response, error) {
371
+ switch (state) {
372
+ case 'cold':
373
+ return Object.freeze({ state });
374
+ case 'loading':
375
+ return Object.freeze({ state });
376
+ case 'failed':
377
+ return Object.freeze({ state, error, ...(response === undefined ? {} : { response }) });
378
+ case 'ready':
379
+ case 'stale':
380
+ case 'refreshing':
381
+ case 'optimistic':
382
+ if (response === undefined)
383
+ throw new TypeError(`Store ${state} snapshot requires a response.`);
384
+ return Object.freeze({ state, response });
385
+ }
386
+ }
387
+ function sameSnapshot(left, right) {
388
+ if (left.state !== right.state)
389
+ return false;
390
+ if ('response' in left || 'response' in right) {
391
+ if (!('response' in left) || !('response' in right) || left.response !== right.response) {
392
+ return false;
809
393
  }
810
394
  }
811
- return { props: out, unresolved };
395
+ return left.state !== 'failed' || right.state !== 'failed' || left.error === right.error;
812
396
  }
813
397
  //# sourceMappingURL=memory.js.map