@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/Entity.ts CHANGED
@@ -4,12 +4,16 @@
4
4
 
5
5
  // @import-as-namespace
6
6
 
7
+ import * as Schema from 'effect/Schema';
8
+
7
9
  import type { ForeignKey } from '@dxos/echo-protocol';
8
- import type { DXN, ObjectId } from '@dxos/keys';
10
+ import type { EntityId, URI } from '@dxos/keys';
9
11
 
10
12
  import * as internal from './internal';
13
+ import type * as Ref from './Ref';
11
14
  import type * as Relation from './Relation';
12
- import type * as Type from './Type';
15
+ import type * as Tag from './Tag';
16
+ import * as Type from './Type';
13
17
 
14
18
  // Re-export KindId and SnapshotKindId from internal.
15
19
  export const KindId = internal.KindId;
@@ -31,7 +35,7 @@ export const KindSchema = internal.EntityKindSchema;
31
35
  */
32
36
  export interface OfKind<K extends Kind> {
33
37
  readonly [KindId]: K;
34
- readonly id: ObjectId;
38
+ readonly id: EntityId;
35
39
  }
36
40
 
37
41
  /**
@@ -39,7 +43,7 @@ export interface OfKind<K extends Kind> {
39
43
  */
40
44
  export interface SnapshotOfKind<K extends Kind> {
41
45
  readonly [SnapshotKindId]: K;
42
- readonly id: ObjectId;
46
+ readonly id: EntityId;
43
47
  }
44
48
 
45
49
  /**
@@ -52,6 +56,27 @@ export type Entity<Props> = OfKind<Kind> & Props;
52
56
  */
53
57
  export interface Unknown extends OfKind<Kind> {}
54
58
 
59
+ /**
60
+ * Effect Schema for any ECHO entity (object or relation).
61
+ *
62
+ * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates
63
+ * the structural shape (id + properties) without constraining `[KindId]`. Used
64
+ * in operation input schemas that accept any entity flavour (e.g.
65
+ * `Schema.Array(Entity.Unknown)`).
66
+ *
67
+ * The cast bridges the runtime structural schema to the branded `Unknown` type:
68
+ * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,
69
+ * so the entity guarantee is carried at the type level only (same approach as
70
+ * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it
71
+ * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no
72
+ * `TypeAnnotation`.
73
+ */
74
+ export const Unknown: Schema.Schema<Unknown> = Schema.Struct({
75
+ id: Schema.String,
76
+ }).pipe(
77
+ Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
78
+ ) as unknown as Schema.Schema<Unknown>;
79
+
55
80
  /**
56
81
  * Snapshot of an Obj or Relation.
57
82
  * Branded with SnapshotKindId instead of KindId.
@@ -80,12 +105,30 @@ export type Properties<T> = Omit<T, 'id' | KindId | Relation.Source | Relation.T
80
105
  * Check if a value is an ECHO entity (object or relation).
81
106
  * Returns `false` for snapshots.
82
107
  */
83
- export const isEntity = (value: unknown): value is Unknown => {
84
- if (typeof value !== 'object' || value === null) {
85
- return false;
108
+ export const isEntity: (value: unknown) => value is Unknown = internal.isEntity;
109
+
110
+ /**
111
+ * Test if a value is an instance of a given object or relation type.
112
+ *
113
+ * Kind-agnostic counterpart to `Obj.instanceOf` / `Relation.instanceOf` —
114
+ * use this when the caller's input type is `Type.AnyObj | Type.AnyRelation`.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // Caller doesn't know whether `type` is object- or relation-kind.
119
+ * const matches = <T extends Type.AnyObj | Type.AnyRelation>(type: T, value: unknown) =>
120
+ * Entity.instanceOf(type, value);
121
+ * ```
122
+ */
123
+ export const instanceOf: {
124
+ <S extends Type.AnyEntity>(schema: S): (value: unknown) => value is Type.InstanceType<S>;
125
+ <S extends Type.AnyEntity>(schema: S, value: unknown): value is Type.InstanceType<S>;
126
+ } = ((...args: [schema: Type.AnyEntity, value?: unknown]) => {
127
+ if (args.length === 1) {
128
+ return (entity: unknown) => internal.isInstanceOf(args[0], entity);
86
129
  }
87
- return (value as any)[KindId] !== undefined;
88
- };
130
+ return internal.isInstanceOf(args[0], args[1]);
131
+ }) as any;
89
132
 
90
133
  /**
91
134
  * Check if a value is an ECHO entity snapshot.
@@ -123,25 +166,58 @@ export type Meta = typeof Meta;
123
166
  export type JSON = internal.ObjectJSON;
124
167
 
125
168
  /**
126
- * Get the DXN of an entity (object or relation).
169
+ * Whether the entity is a type-kind entity (a `Type.Type` produced by
170
+ * `Type.makeObject` / `Type.makeRelation`, or a persisted schema). Type entities
171
+ * carry their identity (typename/version) on themselves rather than referencing a
172
+ * separate type, so the accessors below route them through the `Type.*` module.
127
173
  */
128
- export const getDXN = (entity: Unknown | Snapshot): DXN => internal.getDXN(entity);
174
+ const isTypeEntity = (entity: unknown): boolean => internal.getEntityKindBrand(entity) === internal.EntityKind.Type;
129
175
 
130
176
  /**
131
- * Get the DXN of an entity's type.
177
+ * Any value the read accessors operate on: a reactive entity or a snapshot.
178
+ * Type entities (`Type.AnyEntity`) are also accepted — they're first-class
179
+ * entities, and `Unknown`'s kind-agnostic brand already subsumes them.
132
180
  */
133
- export const getTypeDXN = internal.getTypeDXN;
181
+ export type AnyInput = Unknown | Snapshot;
134
182
 
135
183
  /**
136
- * Get the schema of an entity.
137
- * Returns the branded ECHO schema used to create the entity.
184
+ * Get the canonical URI of an entity (object, relation, or type). Returns `URI.URI` —
185
+ * an `EID` for object/relation instances and persisted types, or a typename
186
+ * `DXN` for static type entities; narrow with `EID.parse(uri)` or
187
+ * `DXN.tryMake(uri)` at the point of use.
138
188
  */
139
- export const getSchema: (entity: Unknown | Snapshot) => Type.AnyEntity | undefined = internal.getSchema as any;
189
+ export const getURI = (entity: AnyInput): URI.URI =>
190
+ isTypeEntity(entity) ? Type.getURI(entity as Type.AnyEntity) : internal.getUri(entity as Unknown);
140
191
 
141
192
  /**
142
- * Get the typename of an entity's type.
193
+ * Get the DXN of an entity's type. For object/relation instances this is the URI
194
+ * of the type they were created from; for a type entity it is the URI of the
195
+ * meta-type ({@link Type.Type}, `dxn:org.dxos.type.schema:0.1.0`).
143
196
  */
144
- export const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);
197
+ export const getTypeURI = (entity: AnyInput): URI.URI | undefined =>
198
+ isTypeEntity(entity) ? Type.getURI(Type.Type) : internal.getTypeURI(entity as Unknown);
199
+
200
+ /**
201
+ * Get the type entity (`Type.AnyEntity`) the instance was created from.
202
+ *
203
+ * Returns `undefined` when the entity's type isn't registered in this runtime
204
+ * (e.g. a freshly deserialized snapshot whose type entity hasn't been wired
205
+ * up yet, or an entity loaded from storage before its schema is known). To
206
+ * get the Effect Schema from the returned entity, use `Type.getSchema(...)`.
207
+ *
208
+ * For a type entity, returns the meta-type {@link Type.Type} (a type entity's
209
+ * type is "Type").
210
+ */
211
+ export const getType = (entity: AnyInput): Type.AnyEntity | undefined =>
212
+ isTypeEntity(entity) ? Type.Type : (internal.getType(entity) as Type.AnyEntity | undefined);
213
+
214
+ /**
215
+ * Get the typename of an entity's type. For object/relation instances this is the
216
+ * typename of the type they were created from; for a type entity it is the type's
217
+ * own typename (e.g. `com.example.type.person`).
218
+ */
219
+ export const getTypename = (entity: AnyInput): string | undefined =>
220
+ isTypeEntity(entity) ? Type.getTypename(entity as Type.AnyEntity) : internal.getTypename(entity as Unknown);
145
221
 
146
222
  /**
147
223
  * Get the database an entity belongs to.
@@ -154,9 +230,9 @@ export const getDatabase = (entity: Unknown | Snapshot): any | undefined => inte
154
230
  * Returns read-only meta when passed a regular entity or snapshot.
155
231
  */
156
232
  // TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
157
- export function getMeta(entity: Mutable<Unknown>): internal.ObjectMeta;
233
+ export function getMeta(entity: Mutable<Unknown>): internal.EntityMeta;
158
234
  export function getMeta(entity: Unknown | Snapshot): internal.ReadonlyMeta;
159
- export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.ObjectMeta | internal.ReadonlyMeta {
235
+ export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.EntityMeta | internal.ReadonlyMeta {
160
236
  return internal.getMetaChecked(entity);
161
237
  }
162
238
 
@@ -172,14 +248,31 @@ export const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDel
172
248
 
173
249
  /**
174
250
  * Get the label of an entity.
251
+ *
252
+ * @param options.fallback `'typename'` returns the entity's typename when no
253
+ * label is set (e.g. `org.dxos.type.table`).
254
+ */
255
+ export const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>
256
+ internal.getLabel(entity, options);
257
+
258
+ /**
259
+ * Set the label of an entity.
260
+ * Must be called within an `Entity.update` / `Obj.update` / `Relation.update` callback.
175
261
  */
176
- export const getLabel = (entity: Unknown | Snapshot): string | undefined => internal.getLabel(entity);
262
+ export const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);
177
263
 
178
264
  /**
179
265
  * Get the description of an entity.
180
266
  */
181
267
  export const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);
182
268
 
269
+ /**
270
+ * Get the icon annotation for an entity (object or relation), resolved via its type-level
271
+ * `IconAnnotation`. Returns the full `{ icon, hue }` annotation so callers can use both
272
+ * the phosphor icon name and the suggested colour.
273
+ */
274
+ export const getIcon = (entity: Unknown | Snapshot): internal.IconAnnotation | undefined => internal.getIcon(entity);
275
+
183
276
  /**
184
277
  * Convert an entity to its JSON representation.
185
278
  */
@@ -234,10 +327,10 @@ export const update = <T extends Unknown>(entity: T, callback: internal.ChangeCa
234
327
  * Add a tag to an entity.
235
328
  * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.
236
329
  */
237
- export const addTag = (entity: Mutable<Unknown>, tag: string): void => internal.addTag(entity, tag);
330
+ export const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);
238
331
 
239
332
  /**
240
333
  * Remove a tag from an entity.
241
334
  * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.
242
335
  */
243
- export const removeTag = (entity: Mutable<Unknown>, tag: string): void => internal.removeTag(entity, tag);
336
+ export const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);
package/src/Err.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  // @import-as-namespace
6
6
 
7
7
  import { BaseError, type BaseErrorOptions } from '@dxos/errors';
8
- import { type DXN } from '@dxos/keys';
8
+ import { type URI } from '@dxos/keys';
9
9
 
10
10
  export class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {
11
11
  constructor(schema: string, options?: BaseErrorOptions) {
@@ -13,9 +13,9 @@ export class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError',
13
13
  }
14
14
  }
15
15
 
16
- export class ObjectNotFoundError extends BaseError.extend('ObjectNotFoundError', 'Object not found') {
17
- constructor(dxn: DXN, options?: BaseErrorOptions) {
18
- super({ context: { dxn }, ...options });
16
+ export class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {
17
+ constructor(uri: URI.URI, options?: BaseErrorOptions) {
18
+ super({ context: { uri }, ...options });
19
19
  }
20
20
  }
21
21
 
package/src/Feed.ts CHANGED
@@ -10,7 +10,7 @@ import * as Layer from 'effect/Layer';
10
10
  import type * as Option from 'effect/Option';
11
11
  import * as Schema from 'effect/Schema';
12
12
 
13
- import { DXN } from '@dxos/keys';
13
+ import { DXN, EID } from '@dxos/keys';
14
14
 
15
15
  import * as Annotation from './Annotation';
16
16
  import type * as Entity from './Entity';
@@ -43,21 +43,15 @@ export const Feed = Schema.Struct({
43
43
  */
44
44
  namespace: Schema.optional(Schema.Literal('data', 'trace')),
45
45
  }).pipe(
46
- Type.object({
47
- typename: 'org.dxos.type.feed',
48
- version: '0.1.0',
49
- }),
50
- internal.SystemTypeAnnotation.set(true),
51
- Annotation.IconAnnotation.set({
52
- icon: 'ph--rows--regular',
53
- hue: 'yellow',
54
- }),
46
+ internal.HiddenAnnotation.set(true),
47
+ Annotation.IconAnnotation.set({ icon: 'ph--rows--regular', hue: 'yellow' }),
48
+ Type.makeObject(DXN.make('org.dxos.type.feed', '0.1.0')),
55
49
  );
56
50
 
57
51
  /**
58
52
  * TypeScript instance type for a Feed object.
59
53
  */
60
- export interface Feed extends Schema.Schema.Type<typeof Feed> {}
54
+ export type Feed = Type.InstanceType<typeof Feed>;
61
55
 
62
56
  //
63
57
  // Types
@@ -90,6 +84,19 @@ export interface SyncOptions {
90
84
  shouldPull?: boolean;
91
85
  }
92
86
 
87
+ /**
88
+ * Queue replication backlog for a feed namespace.
89
+ * `0` / `0` means caught up on pull and push.
90
+ */
91
+ export interface SyncState {
92
+ /** Blocks still to pull from remote. */
93
+ blocksToPull: number;
94
+ /** Unpositioned blocks still to push to remote. */
95
+ blocksToPush: number;
96
+ /** Total blocks stored locally for the feed namespace. */
97
+ totalBlocks: number;
98
+ }
99
+
93
100
  //
94
101
  // Factory
95
102
  //
@@ -106,18 +113,11 @@ export interface SyncOptions {
106
113
  export const make = (props: Obj.MakeProps<typeof Feed> = {}): Feed => Obj.make(Feed, props);
107
114
 
108
115
  /**
109
- * Derives the queue DXN from the feed object's DXN.
110
- * Returns `undefined` when the feed is not stored in a space yet.
116
+ * Returns the feed object's EID when the feed is stored in a space.
111
117
  *
112
118
  * Used internally by the feed service layer.
113
119
  */
114
- export const getQueueDxn = (feed: Feed): DXN | undefined => {
115
- const self = Obj.getDXN(feed).asEchoDXN();
116
- if (!self || !self.spaceId) {
117
- return undefined;
118
- }
119
- return new DXN(DXN.kind.QUEUE, [feed.namespace ?? 'data', self.spaceId, self.echoId]);
120
- };
120
+ export const getQueueUri = (feed: Feed): EID.EID | undefined => EID.tryParse(Obj.getURI(feed));
121
121
 
122
122
  //
123
123
  // Service
@@ -139,7 +139,6 @@ export class FeedService extends Context.Tag('@dxos/echo/Feed/FeedService')<
139
139
  /**
140
140
  * Removes items from a feed by ID.
141
141
  */
142
- // TODO(dmaretskyi): Change type to ObjectId.
143
142
  remove(feed: Feed, ids: string[]): Promise<void>;
144
143
 
145
144
  /**
@@ -154,6 +153,11 @@ export class FeedService extends Context.Tag('@dxos/echo/Feed/FeedService')<
154
153
  * Syncs the feed with the server.
155
154
  */
156
155
  sync(feed: Feed, options?: SyncOptions): Promise<void>;
156
+
157
+ /**
158
+ * Returns queue replication backlog for the feed's namespace.
159
+ */
160
+ getSyncState(feed: Feed): Promise<SyncState>;
157
161
  }
158
162
  >() {}
159
163
 
@@ -167,6 +171,21 @@ export type Service = FeedService;
167
171
  */
168
172
  export const Service = FeedService;
169
173
 
174
+ /**
175
+ * Effect context service that holds the current feed for a scoped operation.
176
+ *
177
+ * @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures
178
+ * over hiding it behind a context service.
179
+ */
180
+ export class ContextFeedService extends Context.Tag('@dxos/echo/Feed/ContextFeedService')<
181
+ ContextFeedService,
182
+ {
183
+ readonly feed: Feed;
184
+ }
185
+ >() {
186
+ static layer = (feed: Feed): Layer.Layer<ContextFeedService> => Layer.succeed(ContextFeedService, { feed });
187
+ }
188
+
170
189
  /**
171
190
  * Layer that provides a Feed service that throws when accessed.
172
191
  * Useful as a default layer when no feed service is available.
@@ -184,27 +203,11 @@ export const notAvailable: Layer.Layer<FeedService> = Layer.succeed(FeedService,
184
203
  sync: () => {
185
204
  throw new Error('Feed.FeedService not available');
186
205
  },
206
+ getSyncState: () => {
207
+ throw new Error('Feed.FeedService not available');
208
+ },
187
209
  } as Context.Tag.Service<FeedService>);
188
210
 
189
- //
190
- // Context (per-call) service
191
- //
192
-
193
- /**
194
- * Effect service exposing a single `Feed.Feed` as the "current" feed for a call site.
195
- *
196
- * @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures
197
- * over hiding it behind a context service.
198
- */
199
- export class ContextFeedService extends Context.Tag('@dxos/echo/Feed/ContextFeedService')<
200
- ContextFeedService,
201
- {
202
- readonly feed: Feed;
203
- }
204
- >() {
205
- static layer = (feed: Feed): Layer.Layer<ContextFeedService> => Layer.succeed(ContextFeedService, { feed });
206
- }
207
-
208
211
  //
209
212
  // Operations
210
213
  //
@@ -293,6 +296,20 @@ export const sync = (feed: Feed, options?: SyncOptions): Effect.Effect<void, nev
293
296
  yield* Effect.promise(() => service.sync(feed, options));
294
297
  });
295
298
 
299
+ /**
300
+ * Returns queue replication backlog for the feed's namespace.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * const { blocksToPull, blocksToPush } = yield* Feed.getSyncState(feed);
305
+ * ```
306
+ */
307
+ export const getSyncState = (feed: Feed): Effect.Effect<SyncState, never, FeedService> =>
308
+ Effect.gen(function* () {
309
+ const service = yield* FeedService;
310
+ return yield* Effect.promise(() => service.getSyncState(feed));
311
+ });
312
+
296
313
  /**
297
314
  * Creates a cursor for iterating over feed items.
298
315
  * Currently stubbed — cursor operations are not yet implemented.
package/src/Filter.ts CHANGED
@@ -11,11 +11,13 @@ import type * as Types from 'effect/Types';
11
11
 
12
12
  import { type ForeignKey, type QueryAST } from '@dxos/echo-protocol';
13
13
  import { assertArgument } from '@dxos/invariant';
14
- import { DXN, ObjectId } from '@dxos/keys';
14
+ import { DXN, EID, EntityId, type URI } from '@dxos/keys';
15
15
 
16
16
  import * as internal from './internal';
17
17
  import type * as Obj from './Obj';
18
18
  import * as Ref from './Ref';
19
+ // eslint-disable-next-line @dxos/rules/import-as-namespace
20
+ import type * as Type$ from './Type';
19
21
 
20
22
  export interface Filter<T> {
21
23
  // TODO(dmaretskyi): See new effect-schema approach to variance.
@@ -77,11 +79,11 @@ export const nothing = (): FilterClass => {
77
79
  };
78
80
 
79
81
  /*
80
- * Filter by ObjectId.
82
+ * Filter by EntityId.
81
83
  */
82
- export const id = (...ids: ObjectId[]): Any => {
84
+ export const id = (...ids: EntityId[]): Any => {
83
85
  assertArgument(
84
- ids.every((id) => ObjectId.isValid(id)),
86
+ ids.every((id) => EntityId.isValid(id)),
85
87
  'ids',
86
88
  'ids must be valid',
87
89
  );
@@ -100,27 +102,46 @@ export const id = (...ids: ObjectId[]): Any => {
100
102
 
101
103
  /**
102
104
  * Filter by type.
105
+ *
106
+ * Accepts a `Type.Type` entity (the value produced by `Type.makeObject` /
107
+ * `Type.makeRelation`), a `Schema.Union` of such entities (for filtering across a
108
+ * union of ECHO types), or a non-qualified typename string.
103
109
  */
104
- export const type = <S extends Schema.Schema.All>(
105
- schema: S | string,
106
- props?: Props<Schema.Schema.Type<S>>,
107
- ): Filter<Schema.Schema.Type<S>> => {
108
- if (Schema.isSchema(schema) && SchemaAST.isUnion(schema.ast)) {
109
- const typenames = schema.ast.types.map((type) => internal.getTypeDXNFromSpecifier(Schema.make(type)));
110
+ export const type: {
111
+ <T extends Type$.AnyEntity>(type: T, props?: Props<Type$.InstanceType<T>>): Filter<Type$.InstanceType<T>>;
112
+ // Schema-side overload restricted to the well-known unknown schemas and to
113
+ // `Schema.Union(...)` of `Type.Type` entities (for filtering across a union
114
+ // of ECHO types). Other raw schemas are rejected.
115
+ <S extends internal.UnknownTypeSchema<any, any>>(
116
+ schema: S,
117
+ props?: Props<Schema.Schema.Type<S>>,
118
+ ): Filter<Schema.Schema.Type<S>>;
119
+ <S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(
120
+ union: S,
121
+ props?: Props<Schema.Schema.Type<S>>,
122
+ ): Filter<Schema.Schema.Type<S>>;
123
+ (schema: string, props?: Props<unknown>): Filter<any>;
124
+ // Passthrough overload for callers that hold a `Type.AnyEntity | string` union
125
+ // (e.g. Query.type / Query.sourceOf / Query.targetOf impls). Listed last so the
126
+ // typed overloads above still win for monomorphic inputs.
127
+ (input: Type$.AnyEntity | string, props?: Props<unknown>): Filter<unknown>;
128
+ } = (input: Type$.AnyEntity | Schema.Schema.AnyNoContext | string, props?: Props<unknown>): any => {
129
+ if (Schema.isSchema(input) && SchemaAST.isUnion(input.ast)) {
130
+ const typenames = input.ast.types.map((t) => internal.getTypeURIFromSpecifier(Schema.make(t)));
110
131
  return new FilterClass({
111
132
  type: 'or',
112
133
  filters: typenames.map((typename) => ({
113
134
  type: 'object',
114
- typename: typename.toString(),
135
+ typename,
115
136
  props: {},
116
137
  })),
117
138
  });
118
139
  }
119
140
 
120
- const dxn = internal.getTypeDXNFromSpecifier(schema);
141
+ const uri = internal.getTypeURIFromSpecifier(input);
121
142
  return new FilterClass({
122
143
  type: 'object',
123
- typename: dxn.toString(),
144
+ typename: uri,
124
145
  ...propsFilterToAst(props ?? {}),
125
146
  });
126
147
  };
@@ -132,18 +153,19 @@ export const typename = (typename: string): Any => {
132
153
  assertArgument(!typename.startsWith('dxn:'), 'typename', 'Typename must no be qualified');
133
154
  return new FilterClass({
134
155
  type: 'object',
135
- typename: DXN.fromTypename(typename).toString(),
156
+ typename: DXN.make(typename),
136
157
  props: {},
137
158
  });
138
159
  };
139
160
 
140
161
  /**
141
- * Filter by fully qualified type DXN.
162
+ * Filter by fully qualified type URI — either a typename DXN (for static schemas) or
163
+ * a schema-as-object EID (for stored dynamic schemas). See `getSchemaURI`.
142
164
  */
143
- export const typeDXN = (dxn: DXN): Any => {
165
+ export const typeURI = (uri: URI.URI): Any => {
144
166
  return new FilterClass({
145
167
  type: 'object',
146
- typename: dxn.toString(),
168
+ typename: uri,
147
169
  props: {},
148
170
  });
149
171
  };
@@ -223,14 +245,14 @@ export const text = (
223
245
  /**
224
246
  * Filter by foreign keys.
225
247
  */
226
- export const foreignKeys = <S extends Schema.Schema.All>(
227
- schema: S | string,
248
+ export const foreignKeys = <S extends Type$.AnyEntity | string>(
249
+ schema: S,
228
250
  keys: ForeignKey[],
229
- ): Filter<Schema.Schema.Type<S>> => {
230
- const dxn = internal.getTypeDXNFromSpecifier(schema);
251
+ ): Filter<S extends Type$.AnyEntity ? Type$.InstanceType<S> : unknown> => {
252
+ const uri = internal.getTypeURIFromSpecifier(schema);
231
253
  return new FilterClass({
232
254
  type: 'object',
233
- typename: dxn.toString(),
255
+ typename: uri,
234
256
  props: {},
235
257
  foreignKeys: keys,
236
258
  });
@@ -378,7 +400,7 @@ export type ChildOfOptions = {
378
400
  /**
379
401
  * Filter objects that are children of the specified parent(s).
380
402
  * Accepts ECHO objects, Refs, or arrays of either.
381
- * Refs are resolved to DXNs without loading; objects use {@link Obj.getDXN}.
403
+ * Refs are resolved to DXNs without loading; objects use {@link Obj.getURI}.
382
404
  * With transitive=true (default), also matches grandchildren and beyond.
383
405
  */
384
406
  export const childOf = (
@@ -388,9 +410,9 @@ export const childOf = (
388
410
  const items = Array.isArray(parents) ? parents : [parents];
389
411
  const dxns = items.map((item) => {
390
412
  if (Ref.isRef(item)) {
391
- return item.dxn.toString();
413
+ return EID.parse(item.uri);
392
414
  }
393
- return internal.getDXN(item).toString();
415
+ return internal.getUri(item);
394
416
  });
395
417
  return new FilterClass({
396
418
  type: 'child-of',
@@ -432,7 +454,7 @@ export const or = <Filters extends readonly Any[]>(...filters: Filters): Filter<
432
454
  // TODO(dmaretskyi): Add `Filter.match` to support pattern matching on string props.
433
455
 
434
456
  const propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {
435
- let idFilter: readonly ObjectId[] | undefined;
457
+ let idFilter: readonly EntityId[] | undefined;
436
458
  if ('id' in predicates) {
437
459
  assertArgument(
438
460
  typeof predicates.id === 'string' || Array.isArray(predicates.id),
@@ -440,7 +462,7 @@ const propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, '
440
462
  'invalid id filter',
441
463
  );
442
464
  idFilter = typeof predicates.id === 'string' ? [predicates.id] : predicates.id;
443
- Schema.Array(ObjectId).pipe(Schema.validateSync)(idFilter);
465
+ Schema.Array(EntityId).pipe(Schema.validateSync)(idFilter);
444
466
  }
445
467
 
446
468
  return {
package/src/Hypergraph.ts CHANGED
@@ -2,14 +2,14 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type DXN } from '@dxos/keys';
5
+ import { type URI } from '@dxos/keys';
6
6
 
7
7
  import type * as Database from './Database';
8
8
  import type * as Entity from './Entity';
9
9
  import type * as internal from './internal';
10
10
  import type * as Key from './Key';
11
11
  import type * as Ref from './Ref';
12
- import type * as SchemaRegistry from './SchemaRegistry';
12
+ import type * as Registry from './Registry';
13
13
 
14
14
  /**
15
15
  * Resolution context.
@@ -22,10 +22,10 @@ export interface RefResolutionContext {
22
22
  space?: Key.SpaceId;
23
23
 
24
24
  /**
25
- * Feed that the resolution is happening from (as the underlying queue DXN).
25
+ * Feed that the resolution is happening from.
26
26
  * This feed will be searched first, and then the space it belongs to.
27
27
  */
28
- feed?: DXN;
28
+ feed?: URI.URI;
29
29
  }
30
30
 
31
31
  export interface RefResolverOptions {
@@ -46,7 +46,12 @@ export interface RefResolverOptions {
46
46
  * Manages cross-space database interactions.
47
47
  */
48
48
  export interface Hypergraph extends Database.Queryable {
49
- get schemaRegistry(): SchemaRegistry.SchemaRegistry;
49
+ /**
50
+ * In-process registry of keyed objects and static schema types.
51
+ * Populated at startup via `registry.add(objects)` / `registry.add(schemas)`.
52
+ * Queries that include no explicit from() clause will fan out to this registry automatically.
53
+ */
54
+ get registry(): Registry.Registry;
50
55
 
51
56
  /**
52
57
  * Query objects.
@@ -57,11 +62,11 @@ export interface Hypergraph extends Database.Queryable {
57
62
  * Creates a reference to an existing object in the database.
58
63
  *
59
64
  * NOTE: The reference may be dangling if the object is not present in the database.
60
- * NOTE: Difference from `Ref.fromDXN`
61
- * `Ref.fromDXN(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
65
+ * NOTE: Difference from `Ref.fromURI`
66
+ * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
62
67
  * `db.makeRef(dxn)` is preferable in cases with access to the database.
63
68
  */
64
- makeRef<T extends Entity.Unknown = Entity.Unknown>(dxn: DXN): Ref.Ref<T>;
69
+ makeRef<T extends Entity.Unknown = Entity.Unknown>(uri: URI.URI): Ref.Ref<T>;
65
70
 
66
71
  /**
67
72
  * @param hostDb Host database for reference resolution.
package/src/Json.test.ts CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { DXN, ObjectId } from '@dxos/keys';
7
+ import { DXN, EID, EntityId } from '@dxos/keys';
8
8
  import { safeStringify } from '@dxos/util';
9
9
 
10
10
  import * as Database from './Database';
11
11
  import * as Json from './Json';
12
12
 
13
13
  /** Mint a random ECHO object id usable as both a stub-db key and a DXN payload. */
14
- const newId = (): string => ObjectId.random();
14
+ const newId = (): string => EntityId.random();
15
15
 
16
16
  /** Build a fake encoded ref for a local-space object id. */
17
- const encodeRef = (id: string): { '/': string } => ({ '/': DXN.fromLocalObjectId(id).toString() });
17
+ const encodeRef = (id: string): { '/': string } => ({ '/': EID.make({ entityId: id }) });
18
18
 
19
19
  /** Minimal stub: `createRefReplacer` only touches `db.getObjectById`. */
20
20
  const makeStubDb = (objects: Record<string, unknown>): Database.Database => {
@@ -93,7 +93,7 @@ describe('createRefReplacer', () => {
93
93
 
94
94
  test('leaves non-echo dxns untouched (e.g. type DXN)', () => {
95
95
  // Type DXNs share the `dxn:` prefix but `asEchoDXN()` returns undefined.
96
- const typeRef = { '/': DXN.fromTypename('com.example.Thing').toString() };
96
+ const typeRef = { '/': DXN.make('com.example.Thing') };
97
97
  const replacer = Json.createRefReplacer({ db: makeStubDb({}) });
98
98
  expect(stringifyWith(replacer, { ref: typeRef })).toEqual({ ref: typeRef });
99
99
  });