@dxos/echo 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

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 (378) hide show
  1. package/README.md +4 -4
  2. package/dist/lib/neutral/Annotation.mjs +27 -6
  3. package/dist/lib/neutral/Database.mjs +6 -11
  4. package/dist/lib/neutral/Entity.mjs +25 -16
  5. package/dist/lib/neutral/Err.mjs +3 -3
  6. package/dist/lib/neutral/Feed.mjs +19 -17
  7. package/dist/lib/neutral/Filter.mjs +13 -13
  8. package/dist/lib/neutral/Format.mjs +23 -3
  9. package/dist/lib/neutral/JsonSchema.mjs +7 -8
  10. package/dist/lib/neutral/Key.mjs +9 -5
  11. package/dist/lib/neutral/Migration.mjs +11 -10
  12. package/dist/lib/neutral/Obj.mjs +21 -18
  13. package/dist/lib/neutral/Query.mjs +17 -17
  14. package/dist/lib/neutral/QueryResult.mjs +1 -1
  15. package/dist/lib/neutral/Ref.mjs +10 -11
  16. package/dist/lib/neutral/Registry.mjs +14 -0
  17. package/dist/lib/neutral/Relation.mjs +24 -23
  18. package/dist/lib/neutral/Scope.mjs +12 -0
  19. package/dist/lib/neutral/Tag.mjs +17 -14
  20. package/dist/lib/neutral/Type.mjs +52 -26
  21. package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
  22. package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
  23. package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
  24. package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
  25. package/dist/lib/neutral/{chunk-PT37DG2F.mjs → chunk-4SFPZJVA.mjs} +82 -74
  26. package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
  27. package/dist/lib/neutral/{chunk-APHSOTIX.mjs → chunk-4Z6GET2X.mjs} +3 -3
  28. package/dist/lib/neutral/{chunk-APHSOTIX.mjs.map → chunk-4Z6GET2X.mjs.map} +2 -2
  29. package/dist/lib/neutral/{chunk-7RVZT53K.mjs → chunk-7LOUAPYZ.mjs} +9 -5
  30. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  31. package/dist/lib/neutral/{chunk-BMB7IHGB.mjs → chunk-7OAFN3OX.mjs} +70 -57
  32. package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
  33. package/dist/lib/neutral/{chunk-MLS7U7AT.mjs → chunk-7PRCIDHH.mjs} +41 -28
  34. package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
  35. package/dist/lib/neutral/{chunk-ZISMEVKD.mjs → chunk-BBFJWWAV.mjs} +6 -6
  36. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  37. package/dist/lib/neutral/{chunk-ZFACXBY6.mjs → chunk-BDQGMDIX.mjs} +30 -34
  38. package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
  39. package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
  40. package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
  41. package/dist/lib/neutral/{chunk-V72DY6LU.mjs → chunk-DKLUHO4T.mjs} +1 -1
  42. package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
  44. package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
  45. package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs → chunk-G6CFWUYH.mjs} +2 -2
  46. package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
  47. package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
  48. package/dist/lib/neutral/{chunk-N7VOEPSV.mjs → chunk-J3MNM65T.mjs} +9 -9
  49. package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
  50. package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
  51. package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
  52. package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
  53. package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
  54. package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
  55. package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
  56. package/dist/lib/neutral/{chunk-N4B7FHQT.mjs → chunk-O6BH7EPN.mjs} +30 -3
  57. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  58. package/dist/lib/neutral/{chunk-Q7ZL2P5H.mjs → chunk-OIYW7R2G.mjs} +62 -46
  59. package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
  60. package/dist/lib/neutral/{chunk-G54OX4IX.mjs → chunk-OYUG4FHF.mjs} +527 -847
  61. package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
  62. package/dist/lib/neutral/{chunk-J54QMAKF.mjs → chunk-Q5FKCVBC.mjs} +64 -59
  63. package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
  64. package/dist/lib/neutral/{chunk-FIWO2FZK.mjs → chunk-Q62IHV2N.mjs} +12 -7
  65. package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
  66. package/dist/lib/neutral/{chunk-SCPFDS2E.mjs → chunk-QVJDDG44.mjs} +65 -34
  67. package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
  68. package/dist/lib/neutral/{chunk-TRPZU2HV.mjs → chunk-TFEWTY5A.mjs} +155 -129
  69. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  70. package/dist/lib/neutral/{chunk-44HT3MEC.mjs → chunk-VKWOFXT2.mjs} +22 -2
  71. package/dist/lib/neutral/{chunk-44HT3MEC.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
  72. package/dist/lib/neutral/{chunk-APJKDGFL.mjs → chunk-ZACMEAYV.mjs} +24 -24
  73. package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
  74. package/dist/lib/neutral/index.mjs +50 -40
  75. package/dist/lib/neutral/internal/index.mjs +125 -64
  76. package/dist/lib/neutral/meta.json +1 -1
  77. package/dist/lib/neutral/testing/index.mjs +88 -99
  78. package/dist/lib/neutral/testing/index.mjs.map +3 -3
  79. package/dist/types/src/Annotation.d.ts +108 -4
  80. package/dist/types/src/Annotation.d.ts.map +1 -1
  81. package/dist/types/src/Annotation.test.d.ts +2 -0
  82. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  83. package/dist/types/src/Collection.d.ts +2 -3
  84. package/dist/types/src/Collection.d.ts.map +1 -1
  85. package/dist/types/src/Database.d.ts +50 -30
  86. package/dist/types/src/Database.d.ts.map +1 -1
  87. package/dist/types/src/Dataset.d.ts +16 -6
  88. package/dist/types/src/Dataset.d.ts.map +1 -1
  89. package/dist/types/src/Entity.d.ts +89 -19
  90. package/dist/types/src/Entity.d.ts.map +1 -1
  91. package/dist/types/src/Err.d.ts +9 -9
  92. package/dist/types/src/Err.d.ts.map +1 -1
  93. package/dist/types/src/Feed.d.ts +35 -12
  94. package/dist/types/src/Feed.d.ts.map +1 -1
  95. package/dist/types/src/Filter.d.ts +21 -8
  96. package/dist/types/src/Filter.d.ts.map +1 -1
  97. package/dist/types/src/Hypergraph.d.ts +13 -8
  98. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  99. package/dist/types/src/Json.d.ts.map +1 -1
  100. package/dist/types/src/JsonSchema.d.ts +1 -1
  101. package/dist/types/src/JsonSchema.d.ts.map +1 -1
  102. package/dist/types/src/Key.d.ts +1 -1
  103. package/dist/types/src/Key.d.ts.map +1 -1
  104. package/dist/types/src/Migration.d.ts +15 -12
  105. package/dist/types/src/Migration.d.ts.map +1 -1
  106. package/dist/types/src/Obj.d.ts +69 -40
  107. package/dist/types/src/Obj.d.ts.map +1 -1
  108. package/dist/types/src/Query.d.ts +24 -10
  109. package/dist/types/src/Query.d.ts.map +1 -1
  110. package/dist/types/src/QueryResult.d.ts +9 -0
  111. package/dist/types/src/QueryResult.d.ts.map +1 -1
  112. package/dist/types/src/Ref.d.ts +15 -8
  113. package/dist/types/src/Ref.d.ts.map +1 -1
  114. package/dist/types/src/Registry.d.ts +131 -0
  115. package/dist/types/src/Registry.d.ts.map +1 -0
  116. package/dist/types/src/Relation.d.ts +55 -26
  117. package/dist/types/src/Relation.d.ts.map +1 -1
  118. package/dist/types/src/Scope.d.ts +34 -0
  119. package/dist/types/src/Scope.d.ts.map +1 -0
  120. package/dist/types/src/StateMap.d.ts +32 -0
  121. package/dist/types/src/StateMap.d.ts.map +1 -0
  122. package/dist/types/src/StateMap.test.d.ts +2 -0
  123. package/dist/types/src/StateMap.test.d.ts.map +1 -0
  124. package/dist/types/src/Tag.d.ts +19 -3
  125. package/dist/types/src/Tag.d.ts.map +1 -1
  126. package/dist/types/src/TagIndex.d.ts +36 -0
  127. package/dist/types/src/TagIndex.d.ts.map +1 -0
  128. package/dist/types/src/TagIndex.test.d.ts +2 -0
  129. package/dist/types/src/TagIndex.test.d.ts.map +1 -0
  130. package/dist/types/src/Tagging.d.ts +31 -0
  131. package/dist/types/src/Tagging.d.ts.map +1 -0
  132. package/dist/types/src/Type.d.ts +356 -95
  133. package/dist/types/src/Type.d.ts.map +1 -1
  134. package/dist/types/src/View.d.ts +1 -4
  135. package/dist/types/src/View.d.ts.map +1 -1
  136. package/dist/types/src/index.d.ts +6 -3
  137. package/dist/types/src/index.d.ts.map +1 -1
  138. package/dist/types/src/internal/Annotation/annotations.d.ts +68 -36
  139. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  140. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  141. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  142. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  143. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  144. package/dist/types/src/internal/Annotation/index.d.ts +4 -2
  145. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
  146. package/dist/types/src/internal/Annotation/util.d.ts +13 -4
  147. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
  148. package/dist/types/src/internal/Entity/api.d.ts +3 -3
  149. package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
  150. package/dist/types/src/internal/Entity/entity.d.ts +72 -8
  151. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
  152. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  153. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  154. package/dist/types/src/internal/Entity/index.d.ts +2 -0
  155. package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
  156. package/dist/types/src/internal/Entity/model.d.ts +18 -17
  157. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  158. package/dist/types/src/internal/Entity/object.d.ts +3 -3
  159. package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
  160. package/dist/types/src/internal/Entity/relation.d.ts +30 -7
  161. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
  162. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  163. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  164. package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
  165. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  166. package/dist/types/src/internal/Format/date.d.ts.map +1 -1
  167. package/dist/types/src/internal/Format/format.d.ts +3 -2
  168. package/dist/types/src/internal/Format/format.d.ts.map +1 -1
  169. package/dist/types/src/internal/Format/index.d.ts +2 -2
  170. package/dist/types/src/internal/Format/index.d.ts.map +1 -1
  171. package/dist/types/src/internal/Format/object.d.ts +3 -1
  172. package/dist/types/src/internal/Format/object.d.ts.map +1 -1
  173. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +2 -1
  174. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  175. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
  176. package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
  177. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
  178. package/dist/types/src/internal/Obj/index.d.ts +0 -1
  179. package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
  180. package/dist/types/src/internal/Obj/json-serializer.d.ts +8 -8
  181. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  182. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
  183. package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
  184. package/dist/types/src/internal/Query.d.ts.map +1 -1
  185. package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
  186. package/dist/types/src/internal/Ref/ref.d.ts +29 -19
  187. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  188. package/dist/types/src/internal/Type/index.d.ts +1 -2
  189. package/dist/types/src/internal/Type/index.d.ts.map +1 -1
  190. package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
  191. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
  192. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  193. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  194. package/dist/types/src/internal/common/api/meta.d.ts +11 -8
  195. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
  196. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
  197. package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
  198. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  199. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
  200. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  201. package/dist/types/src/internal/common/types/base.d.ts +4 -4
  202. package/dist/types/src/internal/common/types/entity.d.ts +59 -2
  203. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
  204. package/dist/types/src/internal/common/types/index.d.ts +1 -1
  205. package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
  206. package/dist/types/src/internal/common/types/meta.d.ts +13 -7
  207. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
  208. package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
  209. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
  210. package/dist/types/src/internal/common/types/typename.d.ts +7 -0
  211. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
  212. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  213. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  214. package/dist/types/src/internal/index.d.ts +1 -0
  215. package/dist/types/src/internal/index.d.ts.map +1 -1
  216. package/dist/types/src/testing/test-schema.d.ts +32 -38
  217. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  218. package/dist/types/src/testing/util.d.ts +5 -3
  219. package/dist/types/src/testing/util.d.ts.map +1 -1
  220. package/dist/types/tsconfig.tsbuildinfo +1 -1
  221. package/package.json +21 -23
  222. package/src/Annotation.test.ts +439 -0
  223. package/src/Annotation.ts +151 -4
  224. package/src/Collection.ts +5 -9
  225. package/src/Database.ts +86 -61
  226. package/src/Dataset.ts +10 -2
  227. package/src/Entity.test.ts +116 -6
  228. package/src/Entity.ts +116 -23
  229. package/src/Err.ts +4 -4
  230. package/src/Feed.ts +57 -40
  231. package/src/Filter.ts +49 -27
  232. package/src/Hypergraph.ts +13 -8
  233. package/src/Json.test.ts +4 -4
  234. package/src/Json.ts +7 -6
  235. package/src/Key.ts +1 -1
  236. package/src/Migration.ts +27 -19
  237. package/src/Obj.test.ts +19 -8
  238. package/src/Obj.ts +131 -70
  239. package/src/Query.test.ts +147 -151
  240. package/src/Query.ts +133 -75
  241. package/src/QueryResult.ts +11 -0
  242. package/src/Ref.ts +21 -5
  243. package/src/Registry.ts +155 -0
  244. package/src/Relation.test.ts +10 -10
  245. package/src/Relation.ts +89 -52
  246. package/src/Scope.ts +50 -0
  247. package/src/StateMap.test.ts +56 -0
  248. package/src/StateMap.ts +99 -0
  249. package/src/Tag.md +88 -0
  250. package/src/Tag.ts +49 -6
  251. package/src/TagIndex.test.ts +57 -0
  252. package/src/TagIndex.ts +110 -0
  253. package/src/Tagging.ts +83 -0
  254. package/src/Type.test.ts +223 -18
  255. package/src/Type.ts +601 -131
  256. package/src/View.ts +10 -19
  257. package/src/index.ts +6 -4
  258. package/src/internal/Annotation/annotations.test.ts +31 -11
  259. package/src/internal/Annotation/annotations.ts +122 -103
  260. package/src/internal/Annotation/dictionary.ts +47 -0
  261. package/src/internal/Annotation/entity-dictionary.ts +40 -0
  262. package/src/internal/Annotation/index.ts +4 -2
  263. package/src/internal/Annotation/util.ts +17 -8
  264. package/src/internal/Entity/api.ts +7 -7
  265. package/src/internal/Entity/entity.ts +196 -47
  266. package/src/internal/Entity/guard.ts +26 -0
  267. package/src/internal/Entity/index.ts +2 -0
  268. package/src/internal/Entity/model.ts +35 -28
  269. package/src/internal/Entity/object.ts +21 -5
  270. package/src/internal/Entity/relation.ts +68 -34
  271. package/src/internal/Entity/type-kind.ts +75 -0
  272. package/src/internal/Entity/type-uri.ts +87 -0
  273. package/src/internal/Entity/util.ts +10 -9
  274. package/src/internal/Format/date.ts +0 -4
  275. package/src/internal/Format/format.test.ts +21 -0
  276. package/src/internal/Format/index.ts +2 -3
  277. package/src/internal/Format/object.ts +21 -4
  278. package/src/internal/Format/types.ts +1 -1
  279. package/src/internal/JsonSchema/annotations.ts +1 -1
  280. package/src/internal/JsonSchema/json-schema.test.ts +54 -140
  281. package/src/internal/JsonSchema/json-schema.ts +44 -30
  282. package/src/internal/Obj/clone.ts +9 -4
  283. package/src/internal/Obj/create-object.test.ts +12 -10
  284. package/src/internal/Obj/create-object.ts +67 -22
  285. package/src/internal/Obj/index.ts +0 -1
  286. package/src/internal/Obj/inspect.ts +4 -3
  287. package/src/internal/Obj/json-serializer.test.ts +100 -21
  288. package/src/internal/Obj/json-serializer.ts +93 -38
  289. package/src/internal/Obj/set-value.test.ts +7 -30
  290. package/src/internal/Obj/snapshot.ts +11 -4
  291. package/src/internal/Obj/typed-object.test.ts +9 -11
  292. package/src/internal/Obj/typed-object.ts +1 -1
  293. package/src/internal/Query.ts +14 -11
  294. package/src/internal/Ref/ref-array.ts +3 -3
  295. package/src/internal/Ref/ref.test.ts +17 -26
  296. package/src/internal/Ref/ref.ts +107 -59
  297. package/src/internal/Type/compose.test.ts +3 -1
  298. package/src/internal/Type/index.ts +1 -2
  299. package/src/internal/Type/manipulation.ts +0 -25
  300. package/src/internal/Type/type-schema.ts +60 -0
  301. package/src/internal/common/README.md +1 -1
  302. package/src/internal/common/api/meta.ts +16 -14
  303. package/src/internal/common/proxy/change.test.ts +35 -27
  304. package/src/internal/common/proxy/handler.test.ts +1 -1
  305. package/src/internal/common/proxy/json-serializer.ts +26 -16
  306. package/src/internal/common/proxy/make-object.ts +43 -20
  307. package/src/internal/common/proxy/ownership.ts +2 -2
  308. package/src/internal/common/proxy/schema.test.ts +48 -86
  309. package/src/internal/common/proxy/typed-handler.test.ts +12 -11
  310. package/src/internal/common/proxy/typed-handler.ts +71 -9
  311. package/src/internal/common/proxy/typed-object.test.ts +15 -27
  312. package/src/internal/common/types/base.ts +4 -4
  313. package/src/internal/common/types/entity.ts +80 -1
  314. package/src/internal/common/types/index.ts +6 -1
  315. package/src/internal/common/types/meta.ts +37 -14
  316. package/src/internal/common/types/model-symbols.ts +16 -4
  317. package/src/internal/common/types/typename.ts +39 -3
  318. package/src/internal/common/types/well-known-types.ts +15 -0
  319. package/src/internal/index.ts +5 -0
  320. package/src/testing/api.test.ts +15 -9
  321. package/src/testing/test-data.ts +24 -24
  322. package/src/testing/test-schema.ts +22 -58
  323. package/src/testing/util.ts +14 -11
  324. package/dist/lib/neutral/Extension.mjs +0 -18
  325. package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
  326. package/dist/lib/neutral/chunk-5SL5LDLD.mjs +0 -47
  327. package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +0 -7
  328. package/dist/lib/neutral/chunk-7RVZT53K.mjs.map +0 -7
  329. package/dist/lib/neutral/chunk-APJKDGFL.mjs.map +0 -7
  330. package/dist/lib/neutral/chunk-BICZKPQG.mjs +0 -7
  331. package/dist/lib/neutral/chunk-BICZKPQG.mjs.map +0 -7
  332. package/dist/lib/neutral/chunk-BMB7IHGB.mjs.map +0 -7
  333. package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +0 -7
  334. package/dist/lib/neutral/chunk-G54OX4IX.mjs.map +0 -7
  335. package/dist/lib/neutral/chunk-GWFFC34K.mjs +0 -50
  336. package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +0 -7
  337. package/dist/lib/neutral/chunk-I2DARWPX.mjs +0 -128
  338. package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +0 -7
  339. package/dist/lib/neutral/chunk-J54QMAKF.mjs.map +0 -7
  340. package/dist/lib/neutral/chunk-MGSQGHOD.mjs +0 -206
  341. package/dist/lib/neutral/chunk-MGSQGHOD.mjs.map +0 -7
  342. package/dist/lib/neutral/chunk-MLS7U7AT.mjs.map +0 -7
  343. package/dist/lib/neutral/chunk-N4B7FHQT.mjs.map +0 -7
  344. package/dist/lib/neutral/chunk-N7VOEPSV.mjs.map +0 -7
  345. package/dist/lib/neutral/chunk-PSZBLH53.mjs +0 -81
  346. package/dist/lib/neutral/chunk-PSZBLH53.mjs.map +0 -7
  347. package/dist/lib/neutral/chunk-PT37DG2F.mjs.map +0 -7
  348. package/dist/lib/neutral/chunk-Q2KKKJSV.mjs +0 -56
  349. package/dist/lib/neutral/chunk-Q2KKKJSV.mjs.map +0 -7
  350. package/dist/lib/neutral/chunk-Q7ZL2P5H.mjs.map +0 -7
  351. package/dist/lib/neutral/chunk-SCPFDS2E.mjs.map +0 -7
  352. package/dist/lib/neutral/chunk-TNBK56IN.mjs +0 -350
  353. package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +0 -7
  354. package/dist/lib/neutral/chunk-TRPZU2HV.mjs.map +0 -7
  355. package/dist/lib/neutral/chunk-V72DY6LU.mjs.map +0 -7
  356. package/dist/lib/neutral/chunk-ZFACXBY6.mjs.map +0 -7
  357. package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +0 -7
  358. package/dist/types/src/Extension.d.ts +0 -80
  359. package/dist/types/src/Extension.d.ts.map +0 -1
  360. package/dist/types/src/Extension.test.d.ts +0 -2
  361. package/dist/types/src/Extension.test.d.ts.map +0 -1
  362. package/dist/types/src/SchemaRegistry.d.ts +0 -84
  363. package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
  364. package/dist/types/src/internal/Obj/ids.d.ts +0 -6
  365. package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
  366. package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
  367. package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
  368. package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
  369. package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
  370. package/src/Extension.test.ts +0 -235
  371. package/src/Extension.ts +0 -122
  372. package/src/SchemaRegistry.ts +0 -106
  373. package/src/internal/Obj/ids.ts +0 -12
  374. package/src/internal/Type/echo-schema.ts +0 -423
  375. package/src/internal/Type/persistent-schema.ts +0 -33
  376. /package/dist/lib/neutral/{Extension.mjs.map → Registry.mjs.map} +0 -0
  377. /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Scope.mjs.map} +0 -0
  378. /package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
package/src/Query.ts CHANGED
@@ -19,6 +19,8 @@ import * as Obj from './Obj';
19
19
  import type * as Order from './Order';
20
20
  import type * as Ref from './Ref';
21
21
  import type * as Relation from './Relation';
22
+ // eslint-disable-next-line @dxos/rules/import-as-namespace
23
+ import type * as Type$ from './Type';
22
24
  import type * as View from './View';
23
25
 
24
26
  // TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
@@ -69,11 +71,11 @@ export interface Query<T> {
69
71
  */
70
72
  // TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
71
73
  // TODO(dmaretskyi): Ability to go through arrays of references.
72
- 'referencedBy'<S extends Schema.Schema.All>(
74
+ 'referencedBy'<S extends Type$.AnyEntity>(
73
75
  target: S | string,
74
- key: RefPropKey<Schema.Schema.Type<S>>,
75
- ): Query<Schema.Schema.Type<S>>;
76
- 'referencedBy'<S extends Schema.Schema.All>(target: S | string): Query<Schema.Schema.Type<S>>;
76
+ key: RefPropKey<Type$.InstanceType<S>>,
77
+ ): Query<Type$.InstanceType<S>>;
78
+ 'referencedBy'<S extends Type$.AnyEntity>(target: S | string): Query<Type$.InstanceType<S>>;
77
79
  'referencedBy'(): Query<any>;
78
80
 
79
81
  /**
@@ -82,21 +84,21 @@ export interface Query<T> {
82
84
  * @param relation - Schema of the relation.
83
85
  * @param predicates - Predicates to filter the relation objects.
84
86
  */
85
- 'sourceOf'<S extends Schema.Schema.All>(
86
- relation?: S | string,
87
- predicates?: Filter.Props<Schema.Schema.Type<S>>,
88
- ): Query<Schema.Schema.Type<S>>;
87
+ 'sourceOf'<R extends Type$.AnyRelation>(
88
+ relation?: R | string,
89
+ predicates?: Filter.Props<Type$.InstanceType<R>>,
90
+ ): Query<Type$.InstanceType<R>>;
89
91
 
90
92
  /**
91
93
  * Find relations where this object is the target.
92
94
  * @returns Query for the relation objects.
93
- * @param relation - Schema of the relation.
95
+ * @param relation - Type entity of the relation.
94
96
  * @param predicates - Predicates to filter the relation objects.
95
97
  */
96
- 'targetOf'<S extends Schema.Schema.All>(
97
- relation?: S | string,
98
- predicates?: Filter.Props<Schema.Schema.Type<S>>,
99
- ): Query<Schema.Schema.Type<S>>;
98
+ 'targetOf'<R extends Type$.AnyRelation>(
99
+ relation?: R | string,
100
+ predicates?: Filter.Props<Type$.InstanceType<R>>,
101
+ ): Query<Type$.InstanceType<R>>;
100
102
 
101
103
  /**
102
104
  * For a query for relations, get the source objects.
@@ -199,9 +201,20 @@ export interface Query<T> {
199
201
  'from'(query: Any): Query<T>;
200
202
 
201
203
  /**
202
- * Query from a raw scope specification.
204
+ * Query from one or more raw scopes.
205
+ *
206
+ * Use the {@link Scope} constructors rather than raw tagged objects:
207
+ *
208
+ * ```ts
209
+ * Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry());
210
+ * ```
211
+ */
212
+ 'from'(...scopes: QueryAST.Scope[]): Query<T>;
213
+
214
+ /**
215
+ * Query from a raw scope or array of scopes.
203
216
  */
204
- 'from'(scope: QueryAST.Scope): Query<T>;
217
+ 'from'(scope: QueryAST.Scope | QueryAST.Scope[]): Query<T>;
205
218
 
206
219
  /**
207
220
  * Add options to a query.
@@ -249,17 +262,17 @@ class QueryClass implements Any {
249
262
  });
250
263
  }
251
264
 
252
- referencedBy(target?: Schema.Schema.All | string, key?: string): Any {
253
- const dxn = target !== undefined ? internal.getTypeDXNFromSpecifier(target) : null;
265
+ referencedBy(target?: Type$.AnyEntity | string, key?: string): Any {
266
+ const uri = target !== undefined ? internal.getTypeURIFromSpecifier(target) : null;
254
267
  return new QueryClass({
255
268
  type: 'incoming-references',
256
269
  anchor: this.ast,
257
270
  property: key ?? null,
258
- typename: dxn?.toString() ?? null,
271
+ typename: uri ?? null,
259
272
  });
260
273
  }
261
274
 
262
- sourceOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
275
+ sourceOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
263
276
  return new QueryClass({
264
277
  type: 'relation',
265
278
  anchor: this.ast,
@@ -268,7 +281,7 @@ class QueryClass implements Any {
268
281
  });
269
282
  }
270
283
 
271
- targetOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
284
+ targetOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
272
285
  return new QueryClass({
273
286
  type: 'relation',
274
287
  anchor: this.ast,
@@ -326,18 +339,48 @@ class QueryClass implements Any {
326
339
  }
327
340
 
328
341
  from(
329
- arg:
330
- | Database.Database
331
- | Database.Database[]
332
- | Feed.Feed
333
- | Feed.Feed[]
334
- | Collection.Collection
335
- | View.View
336
- | Any
337
- | QueryAST.Scope
338
- | 'all-accessible-spaces',
339
- options?: { includeFeeds?: boolean },
342
+ ...args:
343
+ | [
344
+ (
345
+ | Database.Database
346
+ | Database.Database[]
347
+ | Feed.Feed
348
+ | Feed.Feed[]
349
+ | Collection.Collection
350
+ | View.View
351
+ | Any
352
+ | QueryAST.Scope
353
+ | QueryAST.Scope[]
354
+ | 'all-accessible-spaces'
355
+ ),
356
+ { includeFeeds?: boolean }?,
357
+ ]
358
+ | QueryAST.Scope[]
340
359
  ): Any {
360
+ // Variadic raw scopes: `.from(Scope.space(), Scope.registry())`.
361
+ if (args.length > 1 && args.every(_isRawScope)) {
362
+ return new QueryClass({
363
+ type: 'from',
364
+ query: this.ast,
365
+ from: { _tag: 'scope', scopes: args as QueryAST.Scope[] },
366
+ });
367
+ }
368
+
369
+ const [arg, options] = args as [
370
+ (
371
+ | Database.Database
372
+ | Database.Database[]
373
+ | Feed.Feed
374
+ | Feed.Feed[]
375
+ | Collection.Collection
376
+ | View.View
377
+ | Any
378
+ | QueryAST.Scope
379
+ | QueryAST.Scope[]
380
+ | 'all-accessible-spaces'
381
+ ),
382
+ { includeFeeds?: boolean }?,
383
+ ];
341
384
  if (arg == null) {
342
385
  throw new TypeError(
343
386
  'Query.from() requires a valid data source argument (database, feed, query, scope, or "all-accessible-spaces").',
@@ -356,20 +399,23 @@ class QueryClass implements Any {
356
399
  return new QueryClass({
357
400
  type: 'from',
358
401
  query: this.ast,
359
- from: {
360
- _tag: 'scope',
361
- scope: {
362
- ...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
363
- },
364
- },
402
+ from: { _tag: 'scope', scopes: [] },
365
403
  });
366
404
  }
367
405
 
368
- if (_isScope(arg)) {
406
+ // Raw scope(s): tagged union objects with _tag 'space' | 'feed' | 'registry'.
407
+ if (Array.isArray(arg) && arg.every(_isRawScope)) {
408
+ return new QueryClass({
409
+ type: 'from',
410
+ query: this.ast,
411
+ from: { _tag: 'scope', scopes: arg as QueryAST.Scope[] },
412
+ });
413
+ }
414
+ if (_isRawScope(arg)) {
369
415
  return new QueryClass({
370
416
  type: 'from',
371
417
  query: this.ast,
372
- from: { _tag: 'scope', scope: arg },
418
+ from: { _tag: 'scope', scopes: [arg] },
373
419
  });
374
420
  }
375
421
 
@@ -382,10 +428,11 @@ class QueryClass implements Any {
382
428
  query: this.ast,
383
429
  from: {
384
430
  _tag: 'scope',
385
- scope: {
386
- spaceIds: databases.map((db) => db.spaceId),
387
- ...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
388
- },
431
+ scopes: databases.map((db) => ({
432
+ _tag: 'space' as const,
433
+ spaceId: db.spaceId,
434
+ ...(options?.includeFeeds ? { includeAllFeeds: true } : {}),
435
+ })),
389
436
  },
390
437
  });
391
438
  }
@@ -411,24 +458,19 @@ class QueryClass implements Any {
411
458
  }
412
459
 
413
460
  const feedItems = items as Feed.Feed[];
414
- const feedDXNs = feedItems.map((feed) => {
415
- const dxn = Feed.getQueueDxn(feed);
416
- if (!dxn) {
461
+ const feedScopes = feedItems.map((feed) => {
462
+ const uri = Feed.getQueueUri(feed);
463
+ if (!uri) {
417
464
  throw new TypeError(
418
- `Query.from() expects persisted Feed objects with a queue DXN; got feed without a space (id=${Obj.getDXN(feed).toString()}).`,
465
+ `Query.from() expects persisted Feed objects with a queue URI; got feed without a space (id=${Obj.getURI(feed)}).`,
419
466
  );
420
467
  }
421
- return dxn.toString();
468
+ return { _tag: 'feed' as const, feedUri: String(uri) };
422
469
  });
423
470
  return new QueryClass({
424
471
  type: 'from',
425
472
  query: this.ast,
426
- from: {
427
- _tag: 'scope',
428
- scope: {
429
- feeds: feedDXNs,
430
- },
431
- },
473
+ from: { _tag: 'scope', scopes: feedScopes },
432
474
  });
433
475
  }
434
476
 
@@ -486,15 +528,21 @@ export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> =
486
528
  * Shorthand for: `Query.select(Filter.type(schema, predicates))`.
487
529
  */
488
530
  export const type: {
489
- <S extends Schema.Schema.All>(
531
+ <T extends Type$.AnyEntity>(type: T, predicates?: Filter.Props<Type$.InstanceType<T>>): Query<Type$.InstanceType<T>>;
532
+ // Brand-narrowed schema overload — only well-known unknown schemas pass.
533
+ <S extends internal.UnknownTypeSchema<any, any>>(
490
534
  schema: S,
491
535
  predicates?: Filter.Props<Schema.Schema.Type<S>>,
492
536
  ): Query<Schema.Schema.Type<S>>;
537
+ <S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(
538
+ union: S,
539
+ predicates?: Filter.Props<Schema.Schema.Type<S>>,
540
+ ): Query<Schema.Schema.Type<S>>;
493
541
  (schema: string, predicates?: Filter.Props<unknown>): Query<any>;
494
- } = (schema: Schema.Schema.All | string, predicates?: Filter.Props<unknown>): Any => {
542
+ } = (type: Type$.AnyEntity | string, predicates?: Filter.Props<unknown>): Any => {
495
543
  return new QueryClass({
496
544
  type: 'select',
497
- filter: Filter.type(schema, predicates).ast,
545
+ filter: Filter.type(type, predicates).ast,
498
546
  });
499
547
  };
500
548
 
@@ -538,32 +586,42 @@ export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
538
586
  * @returns Query scoped to the given source.
539
587
  */
540
588
  export const from = (
541
- source:
542
- | Database.Database
543
- | Database.Database[]
544
- | Feed.Feed
545
- | Feed.Feed[]
546
- | Any
547
- | QueryAST.Scope
548
- | 'all-accessible-spaces',
549
- options?: { includeFeeds?: boolean },
589
+ ...args:
590
+ | [
591
+ (
592
+ | Database.Database
593
+ | Database.Database[]
594
+ | Feed.Feed
595
+ | Feed.Feed[]
596
+ | Any
597
+ | QueryAST.Scope
598
+ | QueryAST.Scope[]
599
+ | 'all-accessible-spaces'
600
+ ),
601
+ { includeFeeds?: boolean }?,
602
+ ]
603
+ | QueryAST.Scope[]
550
604
  ): Any => {
551
605
  const baseQuery: QueryAST.Query = {
552
606
  type: 'select',
553
607
  filter: Filter.everything().ast,
554
608
  };
555
609
  const wrapper = new QueryClass(baseQuery);
556
- return wrapper.from(source as any, options);
610
+ return (wrapper.from as (...args: unknown[]) => Any)(...args);
557
611
  };
558
612
 
559
- const SCOPE_KEYS = new Set(['spaceIds', 'feeds', 'allFeedsFromSpaces']);
560
-
561
- /** Detect a raw Scope object (plain object with only Scope-valid keys). */
562
- const _isScope = (value: unknown): value is QueryAST.Scope => {
563
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
564
- return false;
565
- }
566
- return Object.keys(value).every((key) => SCOPE_KEYS.has(key));
613
+ const SCOPE_TAGS = new Set<string>(['space', 'feed', 'registry']);
614
+
615
+ /** Detect a raw Scope tagged-union object. */
616
+ const _isRawScope = (value: unknown): value is QueryAST.Scope => {
617
+ return (
618
+ typeof value === 'object' &&
619
+ value !== null &&
620
+ !Array.isArray(value) &&
621
+ '_tag' in value &&
622
+ typeof value._tag === 'string' &&
623
+ SCOPE_TAGS.has(value._tag)
624
+ );
567
625
  };
568
626
 
569
627
  /**
@@ -2,6 +2,9 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
7
+
5
8
  import { type CleanupFn } from '@dxos/async';
6
9
 
7
10
  import type * as Entity from './Entity';
@@ -104,3 +107,11 @@ export interface QueryResult<T> {
104
107
  */
105
108
  subscribe(callback?: (query: QueryResult<T>) => void, opts?: SubscriptionOptions): CleanupFn;
106
109
  }
110
+
111
+ /**
112
+ * Effect that returns a QueryResult when evaluated, but also has shorthand methods for running the query or getting the first result.
113
+ */
114
+ export interface QueryResultEffect<T, E, R> extends Effect.Effect<QueryResult<T>, E, R> {
115
+ run: Effect.Effect<T[], E, R>;
116
+ first: Effect.Effect<Option.Option<T>, E, R>;
117
+ }
package/src/Ref.ts CHANGED
@@ -8,10 +8,15 @@ import * as Option from 'effect/Option';
8
8
  import type * as Schema from 'effect/Schema';
9
9
  import * as SchemaAST from 'effect/SchemaAST';
10
10
 
11
+ import { type URI } from '@dxos/keys';
12
+
11
13
  import type * as Entity from './Entity';
14
+ import type * as internal from './internal';
12
15
  import * as refInternal from './internal/Ref';
13
16
  import type * as JsonSchema from './JsonSchema';
14
17
  import type * as Obj from './Obj';
18
+ // eslint-disable-next-line @dxos/rules/import-as-namespace
19
+ import type * as TypeNs from './Type';
15
20
 
16
21
  /**
17
22
  * Instance type for a reference.
@@ -42,10 +47,21 @@ export type Unknown = refInternal.Ref<Obj.Unknown>;
42
47
  * ```ts
43
48
  * const Task = Schema.Struct({
44
49
  * assignee: Ref.Ref(Person), // Creates a Ref schema
45
- * }).pipe(Type.object({ typename: 'Task', version: '0.1.0' }));
50
+ * }).pipe(Type.makeObject(DXN.make('com.example.type.task', '0.1.0')));
46
51
  * ```
47
52
  */
48
- export const Ref: <S extends Schema.Schema.Any>(schema: S) => RefSchema<Schema.Schema.Type<S>> = refInternal.Ref;
53
+ export const Ref: {
54
+ <S extends TypeNs.AnyObj | TypeNs.AnyRelation>(type: S): RefSchema<TypeNs.InstanceType<S> & Obj.Unknown>;
55
+
56
+ // `Type.Type` entities (the meta-schema kind) can be referenced too — e.g. a
57
+ // trigger that points to a stored function/workflow definition.
58
+ <T extends TypeNs.Type<any>>(type: T): RefSchema<TypeNs.InstanceType<T>>;
59
+
60
+ // Schema-side overload for the well-known "any object" / "any relation" schemas.
61
+ // Other raw `Schema.Schema` values are intentionally rejected — callers should
62
+ // pass a `Type.Type` entity instead.
63
+ <S extends internal.UnknownTypeSchema<any, any>>(schema: S): RefSchema<Schema.Schema.Type<S> & Obj.Unknown>;
64
+ } = refInternal.Ref as any;
49
65
 
50
66
  export const Array = refInternal.RefArray;
51
67
 
@@ -82,10 +98,10 @@ export const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef
82
98
 
83
99
  export const make = refInternal.Ref.make;
84
100
 
85
- // TODO(dmaretskyi): Consider just allowing `make` to accept DXN.
86
- export const fromDXN = refInternal.Ref.fromDXN;
101
+ // TODO(dmaretskyi): Consider just allowing `make` to accept URI.
102
+ export const fromURI = (uri: URI.URI): refInternal.Ref<any> => refInternal.Ref.fromURI(uri);
87
103
 
88
- export const hasObjectId = refInternal.Ref.hasObjectId;
104
+ export const hasEntityId = refInternal.Ref.hasEntityId;
89
105
 
90
106
  // TODO(wittjosiah): Factor out?
91
107
  export const isRefType = (ast: SchemaAST.AST): boolean => {
@@ -0,0 +1,155 @@
1
+ // Copyright 2026 DXOS.org
2
+
3
+ // @import-as-namespace
4
+
5
+ import * as Context from 'effect/Context';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { type ReadOnlyEvent } from '@dxos/async';
9
+
10
+ import type * as Database from './Database';
11
+ import * as Entity from './Entity';
12
+ import type * as Filter from './Filter';
13
+ import type * as Query from './Query';
14
+
15
+ /**
16
+ * Identifier denoting an ECHO Registry.
17
+ */
18
+ export const TypeId = Symbol.for('@dxos/echo/Registry');
19
+ export type TypeId = typeof TypeId;
20
+
21
+ /**
22
+ * Composable, in-memory registry of keyed ECHO entities.
23
+ *
24
+ * Entities are stored by id and queried via the standard ECHO Query API.
25
+ * A registry may delegate to an optional upstream registry: results from the local
26
+ * registry take precedence and upstream results fill in anything not found locally.
27
+ *
28
+ * Intended use cases include caches of schemas, operations, blueprints, routines, plugins,
29
+ * etc., sourced from 3rd-party plugins, local code, or local space objects.
30
+ *
31
+ * Types (schema-definition entities produced by `Type.makeObject` / `Type.makeRelation`) are
32
+ * stored the same way as any other entity — via `add()`. Use `list().filter(Type.isType)` to
33
+ * retrieve them.
34
+ *
35
+ * Scope: a Registry is independent of any ECHO space or Hypergraph — it is a process-local,
36
+ * in-memory cache. Wire one per space (e.g. as a Layer scoped to the space's Effect runtime)
37
+ * or share a single instance across spaces depending on the use case.
38
+ *
39
+ * The concrete implementation (and the `makeRegistry` / `registryLayer` factories) lives in
40
+ * `@dxos/echo-db`; this module declares only the interface so that the `@dxos/echo` API surface
41
+ * stays free of query-matching dependencies.
42
+ */
43
+ export interface Registry {
44
+ readonly [TypeId]: TypeId;
45
+
46
+ /**
47
+ * Stable per-instance identifier. Used to key process-local resources (e.g. memoized
48
+ * reactive atoms) to a specific registry instance, analogous to {@link Database.spaceId}.
49
+ */
50
+ readonly id: string;
51
+
52
+ /**
53
+ * Fires whenever local registry contents change (add, remove, or clear).
54
+ */
55
+ readonly changed: ReadOnlyEvent<void>;
56
+
57
+ /**
58
+ * All locally-stored entities.
59
+ * Does not include upstream entities — use {@link list} for that.
60
+ */
61
+ readonly local: readonly Entity.Unknown[];
62
+
63
+ /**
64
+ * Add or replace one or more entities in the local registry.
65
+ * Existing entries with the same id are replaced.
66
+ * Also indexes type entities by DXN for fast lookup.
67
+ */
68
+ add(entities: readonly Entity.Unknown[]): void;
69
+
70
+ /**
71
+ * Remove an entity by id from the local registry.
72
+ * @returns true if an entity was removed, false if it was not found.
73
+ */
74
+ remove(id: string): boolean;
75
+
76
+ /**
77
+ * Remove all locally-stored entities.
78
+ * Does not affect the upstream registry.
79
+ */
80
+ clear(): void;
81
+
82
+ /**
83
+ * Get an entity by id.
84
+ * Searches the local registry first, then falls back to the upstream registry.
85
+ */
86
+ get(id: string): Entity.Unknown | undefined;
87
+
88
+ /**
89
+ * Get an entity by one of its addressing URIs — a type entity by its typename DXN (or, when
90
+ * persisted, its identifier EID), a keyed entity by its `dxn:<key>[:<version>]`. Accepts legacy
91
+ * DXN forms (normalized internally). Searches the local registry first, then falls back to the
92
+ * upstream registry. Narrow the result with `Type.isType` when a type entity is required.
93
+ */
94
+ getByURI(uri: string): Entity.Unknown | undefined;
95
+
96
+ /**
97
+ * List all entities.
98
+ * Local entities take precedence over upstream entities with the same id.
99
+ */
100
+ list(): Entity.Unknown[];
101
+
102
+ /**
103
+ * Run an ECHO query against the registry's entities (implements {@link Database.Queryable}).
104
+ *
105
+ * Matching happens in-memory over {@link list}. Scope (`from`) clauses are unwrapped and
106
+ * ignored — a direct registry query always targets the registry's own entities. The primary
107
+ * way to query registry contents is still through the database (`db.query(...).from(Scope.registry())`),
108
+ * which fans the database and registry together; this method is for querying a registry directly.
109
+ *
110
+ * Only locally-evaluable AST nodes are supported: `select`, `filter`, `limit`, `from`, `options`,
111
+ * and boolean combinators. Server-side concerns (order, traversal, text/timestamp filters) throw.
112
+ */
113
+ query: Database.QueryFn;
114
+ }
115
+
116
+ /**
117
+ * Type guard for {@link Registry}.
118
+ */
119
+ export const isRegistry = (obj: unknown): obj is Registry =>
120
+ obj != null && typeof obj === 'object' && TypeId in obj && (obj as { [TypeId]?: unknown })[TypeId] === TypeId;
121
+
122
+ /**
123
+ * Options for the registry factory (`makeRegistry` in `@dxos/echo-db`).
124
+ */
125
+ export type Options = {
126
+ /**
127
+ * Optional upstream registry. Queries fall back to upstream when an entity
128
+ * is not present in the local registry.
129
+ */
130
+ upstream?: Registry;
131
+
132
+ /**
133
+ * Initial set of entities to seed the local registry with.
134
+ */
135
+ initial?: readonly Entity.Unknown[];
136
+ };
137
+
138
+ /**
139
+ * Effect Context tag for {@link Registry}.
140
+ * Use this to inject a registry into Effect-based code.
141
+ */
142
+ export class Service extends Context.Tag('@dxos/echo/Registry/Service')<Service, Registry>() {}
143
+
144
+ /**
145
+ * Executes a query against the registry and returns the results.
146
+ * Analogous to {@link Database.runQuery} for the in-process registry.
147
+ */
148
+ export const runQuery: {
149
+ <Q extends Query.Any>(query: Q): Effect.Effect<Query.Type<Q>[], never, Service>;
150
+ <F extends Filter.Any>(filter: F): Effect.Effect<Filter.Type<F>[], never, Service>;
151
+ } = (queryOrFilter: Query.Any | Filter.Any) =>
152
+ Effect.gen(function* () {
153
+ const registry = yield* Service;
154
+ return (yield* Effect.promise(() => registry.query(queryOrFilter as any).run())) as any;
155
+ });
@@ -44,13 +44,13 @@ describe('Relation', () => {
44
44
  });
45
45
  const snapshot = Relation.getSnapshot(rel);
46
46
 
47
- // getSourceDXN - works with both.
48
- expect(Relation.getSourceDXN(rel)).toBeDefined();
49
- expect(Relation.getSourceDXN(snapshot)).toBeDefined();
47
+ // getSourceURI - works with both.
48
+ expect(Relation.getSourceURI(rel)).toBeDefined();
49
+ expect(Relation.getSourceURI(snapshot)).toBeDefined();
50
50
 
51
- // getTargetDXN - works with both.
52
- expect(Relation.getTargetDXN(rel)).toBeDefined();
53
- expect(Relation.getTargetDXN(snapshot)).toBeDefined();
51
+ // getTargetURI - works with both.
52
+ expect(Relation.getTargetURI(rel)).toBeDefined();
53
+ expect(Relation.getTargetURI(snapshot)).toBeDefined();
54
54
 
55
55
  // getSource - works with both.
56
56
  expect(Relation.getSource(rel)).toBeDefined();
@@ -61,12 +61,12 @@ describe('Relation', () => {
61
61
  expect(Relation.getTarget(snapshot)).toBeDefined();
62
62
 
63
63
  // getDXN - works with both.
64
- expect(Relation.getDXN(rel)).toBeDefined();
65
- expect(Relation.getDXN(snapshot)).toBeDefined();
64
+ expect(Relation.getURI(rel)).toBeDefined();
65
+ expect(Relation.getURI(snapshot)).toBeDefined();
66
66
 
67
67
  // getTypename - works with both.
68
- expect(Relation.getTypename(rel)).toBe('com.example.type.has-manager');
69
- expect(Relation.getTypename(snapshot)).toBe('com.example.type.has-manager');
68
+ expect(Relation.getTypename(rel)).toBe('com.example.type.hasManager');
69
+ expect(Relation.getTypename(snapshot)).toBe('com.example.type.hasManager');
70
70
 
71
71
  // getMeta - works with both.
72
72
  expect(Relation.getMeta(rel)).toBeDefined();