@dxos/echo 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (567) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +10 -11
  3. package/dist/lib/neutral/Annotation.mjs +68 -0
  4. package/dist/lib/neutral/Database.mjs +38 -0
  5. package/dist/lib/neutral/Entity.mjs +72 -0
  6. package/dist/lib/neutral/Entity.mjs.map +7 -0
  7. package/dist/lib/neutral/Err.mjs +12 -0
  8. package/dist/lib/neutral/Err.mjs.map +7 -0
  9. package/dist/lib/neutral/Feed.mjs +54 -0
  10. package/dist/lib/neutral/Feed.mjs.map +7 -0
  11. package/dist/lib/neutral/Filter.mjs +70 -0
  12. package/dist/lib/neutral/Filter.mjs.map +7 -0
  13. package/dist/lib/neutral/Format.mjs +86 -0
  14. package/dist/lib/neutral/Format.mjs.map +7 -0
  15. package/dist/lib/neutral/JsonSchema.mjs +18 -0
  16. package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
  17. package/dist/lib/neutral/Key.mjs +16 -0
  18. package/dist/lib/neutral/Key.mjs.map +7 -0
  19. package/dist/lib/neutral/Migration.mjs +18 -0
  20. package/dist/lib/neutral/Migration.mjs.map +7 -0
  21. package/dist/lib/neutral/Obj.mjs +122 -0
  22. package/dist/lib/neutral/Obj.mjs.map +7 -0
  23. package/dist/lib/neutral/Order.mjs +16 -0
  24. package/dist/lib/neutral/Order.mjs.map +7 -0
  25. package/dist/lib/neutral/Query.mjs +38 -0
  26. package/dist/lib/neutral/Query.mjs.map +7 -0
  27. package/dist/lib/neutral/QueryResult.mjs +2 -0
  28. package/dist/lib/neutral/QueryResult.mjs.map +7 -0
  29. package/dist/lib/neutral/Ref.mjs +25 -0
  30. package/dist/lib/neutral/Ref.mjs.map +7 -0
  31. package/dist/lib/neutral/Registry.mjs +14 -0
  32. package/dist/lib/neutral/Registry.mjs.map +7 -0
  33. package/dist/lib/neutral/Relation.mjs +97 -0
  34. package/dist/lib/neutral/Relation.mjs.map +7 -0
  35. package/dist/lib/neutral/Scope.mjs +12 -0
  36. package/dist/lib/neutral/Scope.mjs.map +7 -0
  37. package/dist/lib/neutral/Tag.mjs +32 -0
  38. package/dist/lib/neutral/Tag.mjs.map +7 -0
  39. package/dist/lib/neutral/Type.mjs +65 -0
  40. package/dist/lib/neutral/Type.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-35INCYOE.mjs +7 -0
  42. package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
  44. package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
  45. package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
  46. package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
  47. package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
  48. package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
  49. package/dist/lib/neutral/chunk-5SUJPHAE.mjs +34 -0
  50. package/dist/lib/neutral/chunk-5SUJPHAE.mjs.map +7 -0
  51. package/dist/lib/neutral/chunk-6M2Z6WBH.mjs +93 -0
  52. package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
  53. package/dist/lib/neutral/chunk-6YDI3J37.mjs +346 -0
  54. package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
  55. package/dist/lib/neutral/chunk-7FPIAJIV.mjs +2279 -0
  56. package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
  57. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +25 -0
  58. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  59. package/dist/lib/neutral/chunk-7PI7C4EF.mjs +747 -0
  60. package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
  61. package/dist/lib/neutral/chunk-BBFJWWAV.mjs +51 -0
  62. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  63. package/dist/lib/neutral/chunk-EVK6XBXO.mjs +56 -0
  64. package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
  65. package/dist/lib/neutral/chunk-IGK6FN65.mjs +27 -0
  66. package/dist/lib/neutral/chunk-IGK6FN65.mjs.map +7 -0
  67. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  68. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  69. package/dist/lib/neutral/chunk-LWXVKPPW.mjs +281 -0
  70. package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
  71. package/dist/lib/neutral/chunk-MZ7K3MLL.mjs +48 -0
  72. package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
  73. package/dist/lib/neutral/chunk-O6BH7EPN.mjs +94 -0
  74. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  75. package/dist/lib/neutral/chunk-QQIYS74I.mjs +336 -0
  76. package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
  77. package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
  78. package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
  79. package/dist/lib/neutral/chunk-RIVWNMSF.mjs +41 -0
  80. package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
  81. package/dist/lib/neutral/chunk-SBVFRTST.mjs +160 -0
  82. package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
  83. package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
  84. package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
  85. package/dist/lib/neutral/chunk-TFEWTY5A.mjs +428 -0
  86. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  87. package/dist/lib/neutral/chunk-TYGKCRMK.mjs +437 -0
  88. package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
  89. package/dist/lib/neutral/chunk-UUP46KUQ.mjs +205 -0
  90. package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
  91. package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
  92. package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
  93. package/dist/lib/neutral/chunk-WTQJHC75.mjs +395 -0
  94. package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
  95. package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
  96. package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
  97. package/dist/lib/neutral/chunk-ZGNNFYHS.mjs +132 -0
  98. package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
  99. package/dist/lib/neutral/index.mjs +111 -0
  100. package/dist/lib/neutral/index.mjs.map +7 -0
  101. package/dist/lib/neutral/internal/index.mjs +539 -0
  102. package/dist/lib/neutral/internal/index.mjs.map +7 -0
  103. package/dist/lib/neutral/meta.json +1 -0
  104. package/dist/lib/neutral/testing/index.mjs +458 -0
  105. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  106. package/dist/types/src/Annotation.d.ts +128 -0
  107. package/dist/types/src/Annotation.d.ts.map +1 -0
  108. package/dist/types/src/Annotation.test.d.ts +2 -0
  109. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  110. package/dist/types/src/Collection.d.ts +15 -0
  111. package/dist/types/src/Collection.d.ts.map +1 -0
  112. package/dist/types/src/Database.d.ts +208 -0
  113. package/dist/types/src/Database.d.ts.map +1 -0
  114. package/dist/types/src/Dataset.d.ts +29 -0
  115. package/dist/types/src/Dataset.d.ts.map +1 -0
  116. package/dist/types/src/Entity.d.ts +247 -0
  117. package/dist/types/src/Entity.d.ts.map +1 -0
  118. package/dist/types/src/Entity.test.d.ts +2 -0
  119. package/dist/types/src/Entity.test.d.ts.map +1 -0
  120. package/dist/types/src/Err.d.ts +107 -0
  121. package/dist/types/src/Err.d.ts.map +1 -0
  122. package/dist/types/src/Feed.d.ts +229 -0
  123. package/dist/types/src/Feed.d.ts.map +1 -0
  124. package/dist/types/src/Filter.d.ts +175 -0
  125. package/dist/types/src/Filter.d.ts.map +1 -0
  126. package/dist/types/src/Filter.test.d.ts +2 -0
  127. package/dist/types/src/Filter.test.d.ts.map +1 -0
  128. package/dist/types/src/Format.d.ts +2 -0
  129. package/dist/types/src/Format.d.ts.map +1 -0
  130. package/dist/types/src/Hypergraph.d.ts +70 -0
  131. package/dist/types/src/Hypergraph.d.ts.map +1 -0
  132. package/dist/types/src/Json.d.ts +33 -0
  133. package/dist/types/src/Json.d.ts.map +1 -0
  134. package/dist/types/src/Json.test.d.ts +2 -0
  135. package/dist/types/src/Json.test.d.ts.map +1 -0
  136. package/dist/types/src/JsonSchema.d.ts +16 -0
  137. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  138. package/dist/types/src/Key.d.ts +2 -1
  139. package/dist/types/src/Key.d.ts.map +1 -1
  140. package/dist/types/src/Migration.d.ts +72 -0
  141. package/dist/types/src/Migration.d.ts.map +1 -0
  142. package/dist/types/src/Obj.d.ts +514 -53
  143. package/dist/types/src/Obj.d.ts.map +1 -1
  144. package/dist/types/src/Obj.test.d.ts +2 -0
  145. package/dist/types/src/Obj.test.d.ts.map +1 -0
  146. package/dist/types/src/Order.d.ts +26 -0
  147. package/dist/types/src/Order.d.ts.map +1 -0
  148. package/dist/types/src/Query.d.ts +231 -0
  149. package/dist/types/src/Query.d.ts.map +1 -0
  150. package/dist/types/src/Query.test.d.ts +2 -0
  151. package/dist/types/src/Query.test.d.ts.map +1 -0
  152. package/dist/types/src/QueryResult.d.ts +101 -0
  153. package/dist/types/src/QueryResult.d.ts.map +1 -0
  154. package/dist/types/src/Ref.d.ts +69 -11
  155. package/dist/types/src/Ref.d.ts.map +1 -1
  156. package/dist/types/src/Registry.d.ts +131 -0
  157. package/dist/types/src/Registry.d.ts.map +1 -0
  158. package/dist/types/src/Relation.d.ts +323 -24
  159. package/dist/types/src/Relation.d.ts.map +1 -1
  160. package/dist/types/src/Relation.test.d.ts +2 -0
  161. package/dist/types/src/Relation.test.d.ts.map +1 -0
  162. package/dist/types/src/Scope.d.ts +35 -0
  163. package/dist/types/src/Scope.d.ts.map +1 -0
  164. package/dist/types/src/Tag.d.ts +34 -0
  165. package/dist/types/src/Tag.d.ts.map +1 -0
  166. package/dist/types/src/Type.d.ts +397 -107
  167. package/dist/types/src/Type.d.ts.map +1 -1
  168. package/dist/types/src/Type.test.d.ts +2 -0
  169. package/dist/types/src/Type.test.d.ts.map +1 -0
  170. package/dist/types/src/View.d.ts +65 -0
  171. package/dist/types/src/View.d.ts.map +1 -0
  172. package/dist/types/src/exemplars.test.d.ts +2 -0
  173. package/dist/types/src/exemplars.test.d.ts.map +1 -0
  174. package/dist/types/src/hierarchy.test.d.ts +2 -0
  175. package/dist/types/src/hierarchy.test.d.ts.map +1 -0
  176. package/dist/types/src/index.d.ts +22 -3
  177. package/dist/types/src/index.d.ts.map +1 -1
  178. package/dist/types/src/internal/Annotation/annotations.d.ts +272 -0
  179. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
  180. package/dist/types/src/internal/Annotation/annotations.test.d.ts +2 -0
  181. package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
  182. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  183. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  184. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  185. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  186. package/dist/types/src/internal/Annotation/index.d.ts +6 -0
  187. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
  188. package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
  189. package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
  190. package/dist/types/src/internal/Annotation/util.d.ts +48 -0
  191. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
  192. package/dist/types/src/internal/Entity/api.d.ts +27 -0
  193. package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
  194. package/dist/types/src/internal/Entity/entity.d.ts +84 -0
  195. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
  196. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  197. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  198. package/dist/types/src/internal/Entity/index.d.ts +10 -0
  199. package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
  200. package/dist/types/src/internal/Entity/model.d.ts +59 -0
  201. package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
  202. package/dist/types/src/internal/Entity/object.d.ts +18 -0
  203. package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
  204. package/dist/types/src/internal/Entity/relation.d.ts +58 -0
  205. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
  206. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  207. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  208. package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
  209. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  210. package/dist/types/src/internal/Entity/util.d.ts +2 -0
  211. package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
  212. package/dist/types/src/internal/Entity/version.d.ts +42 -0
  213. package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
  214. package/dist/types/src/internal/Format/date.d.ts +63 -0
  215. package/dist/types/src/internal/Format/date.d.ts.map +1 -0
  216. package/dist/types/src/internal/Format/date.test.d.ts +2 -0
  217. package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
  218. package/dist/types/src/internal/Format/format.d.ts +33 -0
  219. package/dist/types/src/internal/Format/format.d.ts.map +1 -0
  220. package/dist/types/src/internal/Format/format.test.d.ts +2 -0
  221. package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
  222. package/dist/types/src/internal/Format/index.d.ts +8 -0
  223. package/dist/types/src/internal/Format/index.d.ts.map +1 -0
  224. package/dist/types/src/internal/Format/number.d.ts +31 -0
  225. package/dist/types/src/internal/Format/number.d.ts.map +1 -0
  226. package/dist/types/src/internal/Format/object.d.ts +37 -0
  227. package/dist/types/src/internal/Format/object.d.ts.map +1 -0
  228. package/dist/types/src/internal/Format/select.d.ts +13 -0
  229. package/dist/types/src/internal/Format/select.d.ts.map +1 -0
  230. package/dist/types/src/internal/Format/string.d.ts +42 -0
  231. package/dist/types/src/internal/Format/string.d.ts.map +1 -0
  232. package/dist/types/src/internal/Format/types.d.ts +72 -0
  233. package/dist/types/src/internal/Format/types.d.ts.map +1 -0
  234. package/dist/types/src/internal/JsonSchema/annotations.d.ts +19 -0
  235. package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
  236. package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts +2 -0
  237. package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
  238. package/dist/types/src/internal/JsonSchema/index.d.ts +5 -0
  239. package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
  240. package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts +7 -0
  241. package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
  242. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +351 -0
  243. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
  244. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +31 -0
  245. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
  246. package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts +2 -0
  247. package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
  248. package/dist/types/src/internal/Obj/atoms.d.ts +38 -0
  249. package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
  250. package/dist/types/src/internal/Obj/clone.d.ts +8 -0
  251. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
  252. package/dist/types/src/internal/Obj/common.d.ts +18 -0
  253. package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
  254. package/dist/types/src/internal/Obj/create-object.d.ts +39 -0
  255. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
  256. package/dist/types/src/internal/Obj/create-object.test.d.ts +2 -0
  257. package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
  258. package/dist/types/src/internal/Obj/deleted.d.ts +6 -0
  259. package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
  260. package/dist/types/src/internal/Obj/index.d.ts +11 -0
  261. package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
  262. package/dist/types/src/internal/Obj/inspect.d.ts +2 -0
  263. package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
  264. package/dist/types/src/internal/Obj/json-serializer.d.ts +45 -0
  265. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
  266. package/dist/types/src/internal/Obj/json-serializer.test.d.ts +2 -0
  267. package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
  268. package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
  269. package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
  270. package/dist/types/src/internal/Obj/schema-validator.test.d.ts +2 -0
  271. package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
  272. package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
  273. package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
  274. package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
  275. package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
  276. package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
  277. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
  278. package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
  279. package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
  280. package/dist/types/src/internal/Obj/typed-object.test.d.ts +2 -0
  281. package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
  282. package/dist/types/src/internal/Query/index.d.ts +2 -0
  283. package/dist/types/src/internal/Query/index.d.ts.map +1 -0
  284. package/dist/types/src/internal/Query/pretty.d.ts +10 -0
  285. package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
  286. package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
  287. package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
  288. package/dist/types/src/internal/Ref/index.d.ts +3 -0
  289. package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
  290. package/dist/types/src/internal/Ref/ref-array.d.ts +21 -0
  291. package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
  292. package/dist/types/src/internal/Ref/ref.d.ts +262 -0
  293. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
  294. package/dist/types/src/internal/Ref/ref.test.d.ts +2 -0
  295. package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
  296. package/dist/types/src/internal/Ref/utils.d.ts +8 -0
  297. package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
  298. package/dist/types/src/internal/Type/compose.d.ts +7 -0
  299. package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
  300. package/dist/types/src/internal/Type/compose.test.d.ts +2 -0
  301. package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
  302. package/dist/types/src/internal/Type/index.d.ts +3 -0
  303. package/dist/types/src/internal/Type/index.d.ts.map +1 -0
  304. package/dist/types/src/internal/Type/manipulation.d.ts +9 -0
  305. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
  306. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  307. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  308. package/dist/types/src/internal/common/api/index.d.ts +11 -0
  309. package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
  310. package/dist/types/src/internal/common/api/meta.d.ts +45 -0
  311. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
  312. package/dist/types/src/internal/common/index.d.ts +4 -0
  313. package/dist/types/src/internal/common/index.d.ts.map +1 -0
  314. package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
  315. package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
  316. package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
  317. package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
  318. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
  319. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
  320. package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
  321. package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
  322. package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
  323. package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
  324. package/dist/types/src/internal/common/proxy/handler.test.d.ts +2 -0
  325. package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
  326. package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
  327. package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
  328. package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
  329. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
  330. package/dist/types/src/internal/common/proxy/make-object.d.ts +20 -0
  331. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
  332. package/dist/types/src/internal/common/proxy/ownership.d.ts +57 -0
  333. package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
  334. package/dist/types/src/internal/common/proxy/proxy-types.d.ts +18 -0
  335. package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
  336. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +47 -0
  337. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
  338. package/dist/types/src/internal/common/proxy/reactive-array.d.ts +8 -0
  339. package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
  340. package/dist/types/src/internal/common/proxy/reactive.d.ts +39 -0
  341. package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
  342. package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
  343. package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
  344. package/dist/types/src/internal/common/proxy/schema-validator.d.ts +15 -0
  345. package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
  346. package/dist/types/src/internal/common/proxy/schema.test.d.ts +2 -0
  347. package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
  348. package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
  349. package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
  350. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +64 -0
  351. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
  352. package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts +2 -0
  353. package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
  354. package/dist/types/src/internal/common/proxy/typed-object.test.d.ts +2 -0
  355. package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
  356. package/dist/types/src/internal/common/types/base.d.ts +27 -0
  357. package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
  358. package/dist/types/src/internal/common/types/entity.d.ts +94 -0
  359. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
  360. package/dist/types/src/internal/common/types/index.d.ts +7 -0
  361. package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
  362. package/dist/types/src/internal/common/types/meta.d.ts +54 -0
  363. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
  364. package/dist/types/src/internal/common/types/model-symbols.d.ts +65 -0
  365. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
  366. package/dist/types/src/internal/common/types/typename.d.ts +28 -0
  367. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
  368. package/dist/types/src/internal/common/types/version.d.ts +15 -0
  369. package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
  370. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  371. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  372. package/dist/types/src/internal/index.d.ts +11 -0
  373. package/dist/types/src/internal/index.d.ts.map +1 -0
  374. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  375. package/dist/types/src/testing/index.d.ts +4 -1
  376. package/dist/types/src/testing/index.d.ts.map +1 -1
  377. package/dist/types/src/testing/registry.d.ts +9 -0
  378. package/dist/types/src/testing/registry.d.ts.map +1 -0
  379. package/dist/types/src/testing/test-data.d.ts +18 -0
  380. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  381. package/dist/types/src/testing/test-schema.d.ts +298 -0
  382. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  383. package/dist/types/src/testing/util.d.ts +23 -0
  384. package/dist/types/src/testing/util.d.ts.map +1 -0
  385. package/dist/types/tsconfig.tsbuildinfo +1 -1
  386. package/package.json +122 -57
  387. package/src/Annotation.test.ts +439 -0
  388. package/src/Annotation.ts +202 -0
  389. package/src/Collection.ts +33 -0
  390. package/src/Database.ts +345 -0
  391. package/src/Dataset.ts +34 -0
  392. package/src/Entity.test.ts +132 -0
  393. package/src/Entity.ts +345 -0
  394. package/src/Err.ts +40 -0
  395. package/src/Feed.ts +352 -0
  396. package/src/Filter.test.ts +90 -0
  397. package/src/Filter.ts +484 -0
  398. package/src/Format.ts +5 -0
  399. package/src/Hypergraph.ts +84 -0
  400. package/src/Json.test.ts +175 -0
  401. package/src/Json.ts +103 -0
  402. package/src/JsonSchema.ts +26 -0
  403. package/src/Key.ts +4 -1
  404. package/src/Migration.ts +114 -0
  405. package/src/Obj.test.ts +641 -0
  406. package/src/Obj.ts +836 -105
  407. package/src/Order.ts +68 -0
  408. package/src/Query.test.ts +835 -0
  409. package/src/Query.ts +634 -0
  410. package/src/QueryResult.ts +132 -0
  411. package/src/Ref.ts +97 -10
  412. package/src/Registry.ts +155 -0
  413. package/src/Relation.test.ts +88 -0
  414. package/src/Relation.ts +508 -61
  415. package/src/Scope.ts +50 -0
  416. package/src/Tag.md +88 -0
  417. package/src/Tag.ts +84 -0
  418. package/src/Type.test.ts +257 -0
  419. package/src/Type.ts +643 -152
  420. package/src/View.ts +98 -0
  421. package/src/exemplars.test.ts +21 -0
  422. package/src/hierarchy.test.ts +33 -0
  423. package/src/index.ts +24 -4
  424. package/src/internal/Annotation/annotations.test.ts +165 -0
  425. package/src/internal/Annotation/annotations.ts +609 -0
  426. package/src/internal/Annotation/dictionary.ts +47 -0
  427. package/src/internal/Annotation/entity-dictionary.ts +74 -0
  428. package/src/internal/Annotation/index.ts +9 -0
  429. package/src/internal/Annotation/sorting.ts +51 -0
  430. package/src/internal/Annotation/util.ts +94 -0
  431. package/src/internal/Entity/api.ts +77 -0
  432. package/src/internal/Entity/entity.ts +277 -0
  433. package/src/internal/Entity/guard.ts +26 -0
  434. package/src/internal/Entity/index.ts +13 -0
  435. package/src/internal/Entity/model.ts +119 -0
  436. package/src/internal/Entity/object.ts +73 -0
  437. package/src/internal/Entity/relation.ts +188 -0
  438. package/src/internal/Entity/type-kind.ts +75 -0
  439. package/src/internal/Entity/type-uri.ts +92 -0
  440. package/src/internal/Entity/util.ts +33 -0
  441. package/src/internal/Entity/version.ts +96 -0
  442. package/src/internal/Format/date.test.ts +55 -0
  443. package/src/internal/Format/date.ts +213 -0
  444. package/src/internal/Format/format.test.ts +97 -0
  445. package/src/internal/Format/format.ts +54 -0
  446. package/src/internal/Format/index.ts +11 -0
  447. package/src/internal/Format/number.ts +89 -0
  448. package/src/internal/Format/object.ts +97 -0
  449. package/src/internal/Format/select.ts +18 -0
  450. package/src/internal/Format/string.ts +81 -0
  451. package/src/internal/Format/types.ts +186 -0
  452. package/src/internal/JsonSchema/annotations.ts +50 -0
  453. package/src/internal/JsonSchema/effect-schema.test.ts +143 -0
  454. package/src/internal/JsonSchema/index.ts +8 -0
  455. package/src/internal/JsonSchema/json-schema-normalize.ts +111 -0
  456. package/src/internal/JsonSchema/json-schema-type.ts +403 -0
  457. package/src/internal/JsonSchema/json-schema.test.ts +786 -0
  458. package/src/internal/JsonSchema/json-schema.ts +547 -0
  459. package/src/internal/Obj/atoms.ts +244 -0
  460. package/src/internal/Obj/clone.ts +53 -0
  461. package/src/internal/Obj/common.ts +75 -0
  462. package/src/internal/Obj/create-object.test.ts +116 -0
  463. package/src/internal/Obj/create-object.ts +140 -0
  464. package/src/internal/Obj/deleted.ts +19 -0
  465. package/src/internal/Obj/index.ts +14 -0
  466. package/src/internal/Obj/inspect.ts +48 -0
  467. package/src/internal/Obj/json-serializer.test.ts +199 -0
  468. package/src/internal/Obj/json-serializer.ts +278 -0
  469. package/src/internal/Obj/schema-validator.test.ts +182 -0
  470. package/src/internal/Obj/schema-validator.ts +6 -0
  471. package/src/internal/Obj/set-value.test.ts +258 -0
  472. package/src/internal/Obj/set-value.ts +158 -0
  473. package/src/internal/Obj/snapshot.ts +114 -0
  474. package/src/internal/Obj/typed-object.test.ts +32 -0
  475. package/src/internal/Obj/typed-object.ts +30 -0
  476. package/src/{query → internal/Query}/index.ts +1 -1
  477. package/src/internal/Query/pretty.ts +162 -0
  478. package/src/internal/Ref/atoms.ts +20 -0
  479. package/src/internal/Ref/index.ts +6 -0
  480. package/src/internal/Ref/ref-array.ts +38 -0
  481. package/src/internal/Ref/ref.test.ts +91 -0
  482. package/src/internal/Ref/ref.ts +650 -0
  483. package/src/internal/Ref/utils.ts +45 -0
  484. package/src/internal/Type/compose.test.ts +43 -0
  485. package/src/internal/Type/compose.ts +41 -0
  486. package/src/internal/Type/index.ts +6 -0
  487. package/src/internal/Type/manipulation.ts +67 -0
  488. package/src/internal/Type/type-schema.ts +60 -0
  489. package/src/internal/common/README.md +102 -0
  490. package/src/internal/common/api/index.ts +15 -0
  491. package/src/internal/common/api/meta.ts +90 -0
  492. package/src/internal/common/index.ts +7 -0
  493. package/src/internal/common/proxy/change-context.ts +138 -0
  494. package/src/internal/common/proxy/change.test.ts +527 -0
  495. package/src/internal/common/proxy/define-hidden-property.ts +14 -0
  496. package/src/internal/common/proxy/errors.ts +42 -0
  497. package/src/internal/common/proxy/event-batch.ts +44 -0
  498. package/src/internal/common/proxy/handler.test.ts +121 -0
  499. package/src/internal/common/proxy/index.ts +17 -0
  500. package/src/internal/common/proxy/json-serializer.ts +101 -0
  501. package/src/internal/common/proxy/make-object.ts +129 -0
  502. package/src/internal/common/proxy/ownership.ts +252 -0
  503. package/src/internal/common/proxy/proxy-types.ts +23 -0
  504. package/src/internal/common/proxy/proxy-utils.ts +150 -0
  505. package/src/internal/common/proxy/reactive-array.ts +71 -0
  506. package/src/internal/common/proxy/reactive.test.ts +54 -0
  507. package/src/internal/common/proxy/reactive.ts +77 -0
  508. package/src/internal/common/proxy/schema-validator.ts +244 -0
  509. package/src/internal/common/proxy/schema.test.ts +107 -0
  510. package/src/internal/common/proxy/symbols.ts +7 -0
  511. package/src/internal/common/proxy/typed-handler.test.ts +314 -0
  512. package/src/internal/common/proxy/typed-handler.ts +509 -0
  513. package/src/internal/common/proxy/typed-object.test.ts +103 -0
  514. package/src/internal/common/types/base.ts +43 -0
  515. package/src/internal/common/types/entity.ts +133 -0
  516. package/src/internal/common/types/index.ts +15 -0
  517. package/src/internal/common/types/meta.ts +109 -0
  518. package/src/internal/common/types/model-symbols.ts +89 -0
  519. package/src/internal/common/types/typename.ts +91 -0
  520. package/src/internal/common/types/version.ts +19 -0
  521. package/src/internal/common/types/well-known-types.ts +15 -0
  522. package/src/internal/index.ts +19 -0
  523. package/src/testing/api.test.ts +131 -0
  524. package/src/testing/index.ts +4 -1
  525. package/src/testing/registry.ts +44 -0
  526. package/src/testing/test-data.ts +189 -0
  527. package/src/testing/test-schema.ts +204 -0
  528. package/src/testing/util.ts +88 -0
  529. package/dist/lib/browser/chunk-NLPBTYZV.mjs +0 -647
  530. package/dist/lib/browser/chunk-NLPBTYZV.mjs.map +0 -7
  531. package/dist/lib/browser/index.mjs +0 -22
  532. package/dist/lib/browser/meta.json +0 -1
  533. package/dist/lib/browser/testing/index.mjs +0 -70
  534. package/dist/lib/browser/testing/index.mjs.map +0 -7
  535. package/dist/lib/node-esm/chunk-BQZZRMFX.mjs +0 -647
  536. package/dist/lib/node-esm/chunk-BQZZRMFX.mjs.map +0 -7
  537. package/dist/lib/node-esm/index.mjs +0 -22
  538. package/dist/lib/node-esm/meta.json +0 -1
  539. package/dist/lib/node-esm/testing/index.mjs +0 -70
  540. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  541. package/dist/types/src/experimental/database.d.ts +0 -8
  542. package/dist/types/src/experimental/database.d.ts.map +0 -1
  543. package/dist/types/src/experimental/index.d.ts +0 -1
  544. package/dist/types/src/experimental/index.d.ts.map +0 -1
  545. package/dist/types/src/experimental/queue.d.ts +0 -8
  546. package/dist/types/src/experimental/queue.d.ts.map +0 -1
  547. package/dist/types/src/experimental/space.d.ts +0 -8
  548. package/dist/types/src/experimental/space.d.ts.map +0 -1
  549. package/dist/types/src/query/dsl.d.ts +0 -218
  550. package/dist/types/src/query/dsl.d.ts.map +0 -1
  551. package/dist/types/src/query/dsl.test.d.ts +0 -2
  552. package/dist/types/src/query/dsl.test.d.ts.map +0 -1
  553. package/dist/types/src/query/index.d.ts +0 -2
  554. package/dist/types/src/query/index.d.ts.map +0 -1
  555. package/dist/types/src/testing/types.d.ts +0 -113
  556. package/dist/types/src/testing/types.d.ts.map +0 -1
  557. package/src/experimental/database.ts +0 -11
  558. package/src/experimental/index.ts +0 -7
  559. package/src/experimental/queue.ts +0 -11
  560. package/src/experimental/space.ts +0 -11
  561. package/src/query/dsl.test.ts +0 -324
  562. package/src/query/dsl.ts +0 -646
  563. package/src/test/api.test.ts +0 -173
  564. package/src/testing/types.ts +0 -91
  565. /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
  566. /package/dist/lib/{node-esm/index.mjs.map → neutral/Database.mjs.map} +0 -0
  567. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
@@ -0,0 +1,133 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ // NOTE: String literals are used instead of unique symbols for both KindId and SchemaKindId.
8
+ // Unique symbols cause TS4023 "cannot be named" errors when external packages
9
+ // try to export types that reference this key (e.g., `export const Graph = ...`).
10
+ // TypeScript cannot emit declaration files that reference unique symbols from
11
+ // external modules. Using a string literal allows the type to be inlined in
12
+ // declaration files, making the API portable across package boundaries.
13
+
14
+ /**
15
+ * String key used to identify the kind of an entity instance (object or relation).
16
+ */
17
+ export const KindId = '~@dxos/echo/Kind' as const;
18
+ export type KindId = typeof KindId;
19
+
20
+ /**
21
+ * String key used to identify the kind of a schema (object schema or relation schema).
22
+ * Parallels KindId which identifies instance kinds.
23
+ */
24
+ export const SchemaKindId = '~@dxos/echo/SchemaKind' as const;
25
+ export type SchemaKindId = typeof SchemaKindId;
26
+
27
+ /**
28
+ * String key used to brand snapshot types.
29
+ * Snapshots have SnapshotKindId instead of KindId, making them
30
+ * distinguishable from reactive objects at the type level.
31
+ */
32
+ export const SnapshotKindId = '~@dxos/echo/SnapshotKind' as const;
33
+ export type SnapshotKindId = typeof SnapshotKindId;
34
+
35
+ /**
36
+ * Hidden slot on a static `Type.Type` entity that holds the source Effect
37
+ * Schema. `Type.getSchema(...)` reads this for static types; persisted types
38
+ * rebuild from `jsonSchema` instead. Stored as a string key for declaration
39
+ * portability (see KindId comment above).
40
+ */
41
+ export const StaticTypeSchemaSlot = '~@dxos/echo/Type.StaticSchema' as const;
42
+ export type StaticTypeSchemaSlot = typeof StaticTypeSchemaSlot;
43
+
44
+ /**
45
+ * Read the hidden `StaticTypeSchemaSlot` off any value that may carry one.
46
+ * Returns `undefined` for raw schemas (no slot) and non-object inputs.
47
+ * Single point-of-cast for the slot lookup.
48
+ */
49
+ export const getStaticTypeSchema = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
50
+ if (value == null || typeof value !== 'object') {
51
+ return undefined;
52
+ }
53
+ return (value as { [StaticTypeSchemaSlot]?: Schema.Schema.AnyNoContext })[StaticTypeSchemaSlot];
54
+ };
55
+
56
+ /**
57
+ * Read the `[SchemaKindId]` brand off a value. Returns `undefined` for raw
58
+ * schemas (which don't carry the brand on their static type) and non-object
59
+ * inputs. Single point-of-cast for the brand lookup.
60
+ */
61
+ export const getSchemaKind = (value: unknown): EntityKind | undefined => {
62
+ if (value == null || typeof value !== 'object') {
63
+ return undefined;
64
+ }
65
+ return (value as { [SchemaKindId]?: EntityKind })[SchemaKindId];
66
+ };
67
+
68
+ /**
69
+ * Read the `[KindId]` brand off a value. Returns `undefined` for raw schemas
70
+ * and non-object inputs. Companion to {@link getSchemaKind}.
71
+ */
72
+ export const getEntityKindBrand = (value: unknown): EntityKind | undefined => {
73
+ if (value == null || typeof value !== 'object') {
74
+ return undefined;
75
+ }
76
+ return (value as { [KindId]?: EntityKind })[KindId];
77
+ };
78
+
79
+ /**
80
+ * Phantom string key on `Type<A>` entities that carries the instance type `A`.
81
+ * Lets internal helpers (`makeObject`, `createObject`, etc.) pattern-match the
82
+ * instance type from an entity input without importing from the top-level
83
+ * `Type` module. Mirrors `Type.InstancePhantomId` (declared in `Type.ts`).
84
+ *
85
+ * Stored as a string key so declarations remain portable across packages
86
+ * (see KindId comment above).
87
+ */
88
+ export const InstancePhantomId = '~@dxos/echo/Type.Instance' as const;
89
+ export type InstancePhantomId = typeof InstancePhantomId;
90
+
91
+ /**
92
+ * Nominal brand carried by the well-known "any object" / "any relation"
93
+ * schemas (`Obj.Unknown`, `Relation.Unknown`). The brand lets `Ref.Ref`,
94
+ * `Filter.type`, and `Query.type` accept these schemas in addition to
95
+ * `Type.Type` entities, without opening the door to arbitrary raw schemas.
96
+ *
97
+ * Stored as a string key so declarations remain portable across packages
98
+ * (see KindId comment above).
99
+ */
100
+ export const UnknownTypeSchemaBrandId = '~@dxos/echo/UnknownTypeSchemaBrand' as const;
101
+ export type UnknownTypeSchemaBrandId = typeof UnknownTypeSchemaBrandId;
102
+
103
+ /**
104
+ * Schema-side companion to `Type.Type` entities for the "any object" /
105
+ * "any relation" cases. Branded so `Ref.Ref` / `Filter.type` / `Query.type`
106
+ * can pattern-match on it; arbitrary `Schema.Schema` values do not satisfy
107
+ * this shape.
108
+ */
109
+ export interface UnknownTypeSchema<A, K extends EntityKind> extends Schema.Schema<A, any, never> {
110
+ readonly [UnknownTypeSchemaBrandId]: K;
111
+ }
112
+
113
+ /**
114
+ * Kinds of entities stored in ECHO: objects, relations, and types.
115
+ */
116
+ export enum EntityKind {
117
+ Object = 'object',
118
+ Relation = 'relation',
119
+ Type = 'type',
120
+ }
121
+
122
+ export const EntityKindSchema = Schema.Enums(EntityKind);
123
+
124
+ /**
125
+ * Typename for generic object references (Type.Obj / Ref.Ref(Obj.Unknown)).
126
+ * Used when referencing any object without a specific schema.
127
+ */
128
+ export const ANY_OBJECT_TYPENAME = 'org.dxos.schema.anyObject';
129
+
130
+ /**
131
+ * Version for generic object references.
132
+ */
133
+ export const ANY_OBJECT_VERSION = '0.0.0';
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './base';
6
+ export * from './entity';
7
+ // NOTE: `./meta` is intentionally NOT re-exported here. It depends on the Ref schema (`Ref/ref`),
8
+ // which transitively pulls in `Annotation` + `Database`; re-exporting it from this low-level barrel
9
+ // — imported by `Annotation/util`, `Annotation/annotations`, `Entity/type-uri`, and `Ref/ref` —
10
+ // would create an eval-order cycle (TDZ on `createAnnotationHelper`). Import meta from `./meta`
11
+ // directly, or from the top-level `@dxos/echo/internal` barrel (re-exported there after Ref loads).
12
+ export * from './model-symbols';
13
+ export * from './typename';
14
+ export * from './version';
15
+ export * from './well-known-types';
@@ -0,0 +1,109 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { type EncodedReference, ForeignKey } from '@dxos/echo-protocol';
8
+ import { invariant } from '@dxos/invariant';
9
+ import { DXN } from '@dxos/keys';
10
+ import { type Comparator, intersection } from '@dxos/util';
11
+
12
+ import type * as Tag from '../../../Tag';
13
+ import { Dictionary } from '../../Annotation/dictionary';
14
+ // `meta` is no longer re-exported from the `common/types` barrel (see ./index.ts), so importing the
15
+ // Ref schema builder here no longer forms an eval-order cycle with `Annotation`/`Database`.
16
+ import { type Ref, createEchoReferenceSchema } from '../../Ref/ref';
17
+ import { type AnyProperties } from './base';
18
+ import { MetaId } from './model-symbols';
19
+ import { TagTypeDXN } from './well-known-types';
20
+
21
+ /**
22
+ * Property name for meta when object is serialized to JSON.
23
+ */
24
+ export const ATTR_META = '@meta';
25
+
26
+ //
27
+ // EntityMeta
28
+ //
29
+
30
+ /**
31
+ * Schema for references to {@link Tag} objects stored in {@link EntityMetaSchema.tags}.
32
+ *
33
+ * Built from the shared {@link createEchoReferenceSchema} (the same builder `Ref.Ref` uses) via
34
+ * `Schema.suspend`, so it reuses the canonical ref codec rather than duplicating it. The Tag type
35
+ * identity comes from the shared {@link TagTypeDXN} constant; `suspend` defers construction until
36
+ * first use, and `Tag` is referenced type-only, so no `Tag` value import is needed.
37
+ */
38
+ const TagRefSchema = Schema.suspend(
39
+ (): Schema.Schema<Ref<Tag.Tag>, EncodedReference> =>
40
+ // The factory yields a loosely-typed `Ref<any>` schema; narrow it to the Tag-typed ref.
41
+ createEchoReferenceSchema(undefined, DXN.getName(TagTypeDXN), DXN.getVersion(TagTypeDXN)) as Schema.Schema<
42
+ Ref<Tag.Tag>,
43
+ EncodedReference
44
+ >,
45
+ );
46
+
47
+ export const EntityMetaSchema = Schema.Struct({
48
+ keys: Schema.Array(ForeignKey),
49
+
50
+ /**
51
+ * Tags applied to this entity, as references to {@link Tag} objects.
52
+ */
53
+ tags: Schema.Array(TagRefSchema),
54
+
55
+ /**
56
+ * Fully-qualified registry key for the object (FQN format, e.g. `org.example.type.foo`).
57
+ * Identifies the canonical registry entry the object instance was created from.
58
+ */
59
+ key: Schema.optional(Schema.String),
60
+
61
+ /**
62
+ * Semantic version of the registry entry the object was created from.
63
+ * Must be a valid semver string (e.g. `1.2.3`).
64
+ */
65
+ version: Schema.optional(Schema.String),
66
+
67
+ /**
68
+ * Dictionary of annotations to this entity.
69
+ */
70
+ annotations: Dictionary,
71
+
72
+ /**
73
+ * Unix ms timestamp when this entity was created.
74
+ * Read-only; sourced from the system section of the automerge document — not stored in meta.
75
+ */
76
+ createdAt: Schema.optional(Schema.Number),
77
+
78
+ /**
79
+ * Unix ms timestamp of the last automerge change on this entity's document.
80
+ * Read-only; derived from the automerge change graph — not stored in meta.
81
+ */
82
+ updatedAt: Schema.optional(Schema.Number),
83
+ });
84
+
85
+ export type EntityMeta = Schema.Schema.Type<typeof EntityMetaSchema>;
86
+
87
+ /*
88
+ * Get metadata from object.
89
+ * Only callable on the object root.
90
+ *
91
+ * @internal (use Obj.getMeta or Relation.getMeta)
92
+ */
93
+ // TODO(burdon): Refine type to BaseObj.
94
+ export const getMeta = (obj: AnyProperties): EntityMeta => {
95
+ const metadata = (obj as any)[MetaId];
96
+ invariant(metadata, 'EntityMeta not found.');
97
+ return metadata;
98
+ };
99
+
100
+ //
101
+ // Foreign keys
102
+ //
103
+
104
+ export const foreignKey = (source: string, id: string): ForeignKey => ({ source, id });
105
+ export const foreignKeyEquals = (a: ForeignKey, b: ForeignKey) => a.source === b.source && a.id === b.id;
106
+
107
+ // TODO(dmaretskyi): Move to echo-schema.
108
+ export const compareForeignKeys: Comparator<AnyProperties> = (a: AnyProperties, b: AnyProperties) =>
109
+ intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;
@@ -0,0 +1,89 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // TODO(rename): These internal entity-wide symbols/types still use the `Object*` prefix but apply
6
+ // to all entities (objects AND relations). Rename to `Entity*` in a follow-up pass (deferred from the
7
+ // EchoURI→EID / ObjectId→EntityId / ObjectMeta→EntityMeta rename, which covered only public SDK API):
8
+ // ObjectCore, ObjectInternals, ObjectVersion, ObjectVersionId, ObjectDeletedId, ObjectDatabaseId,
9
+ // ObjectLoader, ObjectDocumentLoaded, ObjectUnavailable.
10
+ // (ObjectMigration / ObjectMigrationContext intentionally excluded — object-only, not entity-wide.)
11
+
12
+ /**
13
+ * Internal symbol/string constants for the echo object model.
14
+ * Defined in common/ so proxy/ can use them without importing from Entity/.
15
+ * Entity/ re-exports these for external consumers.
16
+ */
17
+
18
+ /**
19
+ * Property name for the object's own URI when serialized to JSON.
20
+ */
21
+ export const ATTR_SELF_URI = '@uri';
22
+
23
+ /**
24
+ * @deprecated Legacy JSON property name accepted on read for backward compat.
25
+ */
26
+ export const ATTR_SELF_URI_LEGACY = '@dxn';
27
+
28
+ /**
29
+ * Symbol carrying the object's own URI on live entities.
30
+ */
31
+ export const SelfURIId = Symbol.for('@dxos/echo/URI');
32
+
33
+ /**
34
+ * Property name for deleted when object is serialized to JSON.
35
+ */
36
+ export const ATTR_DELETED = '@deleted';
37
+
38
+ /**
39
+ * Deletion marker.
40
+ */
41
+ export const ObjectDeletedId = Symbol.for('@dxos/echo/Deleted');
42
+
43
+ /**
44
+ * Object version accessor symbol.
45
+ */
46
+ export const ObjectVersionId: unique symbol = Symbol.for('@dxos/echo/Version');
47
+
48
+ /**
49
+ * Object database accessor symbol.
50
+ */
51
+ export const ObjectDatabaseId = Symbol.for('@dxos/echo/Database');
52
+
53
+ /**
54
+ * Property name for relation source when object is serialized to JSON.
55
+ */
56
+ export const ATTR_RELATION_SOURCE = '@relationSource';
57
+
58
+ /**
59
+ * Used to access relation source ref on live ECHO objects.
60
+ */
61
+ export const RelationSourceId: unique symbol = Symbol.for('@dxos/echo/RelationSource');
62
+
63
+ /**
64
+ * Used to access relation source DXN on live ECHO objects.
65
+ */
66
+ export const RelationSourceDXNId: unique symbol = Symbol.for('@dxos/echo/RelationSourceDXN');
67
+
68
+ /**
69
+ * Property name for relation target when object is serialized to JSON.
70
+ */
71
+ export const ATTR_RELATION_TARGET = '@relationTarget';
72
+
73
+ /**
74
+ * Used to access relation target ref on live ECHO objects.
75
+ */
76
+ export const RelationTargetId: unique symbol = Symbol.for('@dxos/echo/RelationTarget');
77
+
78
+ /**
79
+ * Used to access relation target DXN on live ECHO objects.
80
+ */
81
+ export const RelationTargetDXNId: unique symbol = Symbol.for('@dxos/echo/RelationTargetDXN');
82
+
83
+ /**
84
+ * Symbol carrying the entity metadata (EntityMeta) on live ECHO entities.
85
+ * Must be importable by both meta.ts (which depends on the Ref schema) and
86
+ * Entity/api.ts (which is transitively imported by the Ref schema), so it
87
+ * cannot live in either of those files without creating an import cycle.
88
+ */
89
+ export const MetaId = Symbol.for('@dxos/echo/Meta');
@@ -0,0 +1,91 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import type * as Schema from 'effect/Schema';
6
+
7
+ /**
8
+ * Property name for typename when object is serialized to JSON.
9
+ */
10
+ export const ATTR_TYPE = '@type';
11
+
12
+ /**
13
+ * DXN to the object type.
14
+ */
15
+ export const TypeId = Symbol.for('@dxos/echo/Type');
16
+
17
+ /**
18
+ * Reference to the object schema.
19
+ */
20
+ export const SchemaId = Symbol.for('@dxos/echo/Schema');
21
+
22
+ /**
23
+ * Property name for parent when object is serialized to JSON.
24
+ */
25
+ export const ATTR_PARENT = '@parent';
26
+
27
+ /**
28
+ * Reference to the object parent.
29
+ */
30
+ export const ParentId = Symbol.for('@dxos/echo/Parent');
31
+
32
+ /**
33
+ * Reference to the object's type entity (`Type.Obj`, `Type.Relation`, or
34
+ * `Type.Type`). Set at instance creation by `createObject` / `makeObject`
35
+ * when the entity is known. Public read-back via `Obj.getType` / `Relation.getType`
36
+ * / `Entity.getType`.
37
+ */
38
+ export const TypeEntityId = Symbol.for('@dxos/echo/TypeEntity');
39
+
40
+ /**
41
+ * Returns the Effect Schema for the given object if one is defined.
42
+ *
43
+ * @internal
44
+ * Internal callers needing schema-side validation read from `SchemaId`.
45
+ * Public callers should use `Type.getSchema(Obj.getType(obj))` instead.
46
+ */
47
+ // TODO(dmaretskyi): For echo objects, this always returns the root schema.
48
+ export const getSchema = (obj: unknown | undefined): Schema.Schema.AnyNoContext | undefined => {
49
+ if (obj) {
50
+ return (obj as any)[SchemaId];
51
+ }
52
+ };
53
+
54
+ /**
55
+ * @internal
56
+ */
57
+ export const setSchema = (obj: any, schema: Schema.Schema.AnyNoContext): void => {
58
+ Object.defineProperty(obj, SchemaId, {
59
+ value: schema,
60
+ writable: false,
61
+ enumerable: false,
62
+ configurable: false,
63
+ });
64
+ };
65
+
66
+ /**
67
+ * Returns the type entity (`Type.AnyEntity`) for the given instance.
68
+ * Set at instance creation; every entity has a type. Defensive: returns
69
+ * undefined for null/undefined input so callers can safely probe arbitrary
70
+ * values via this helper.
71
+ *
72
+ * @internal Re-exported via `Obj.getType` / `Relation.getType` / `Entity.getType`.
73
+ */
74
+ export const getType = (obj: unknown): unknown => {
75
+ if (obj == null) {
76
+ return undefined;
77
+ }
78
+ return (obj as any)[TypeEntityId];
79
+ };
80
+
81
+ /**
82
+ * @internal
83
+ */
84
+ export const setType = (obj: any, type: unknown): void => {
85
+ Object.defineProperty(obj, TypeEntityId, {
86
+ value: type,
87
+ writable: false,
88
+ enumerable: false,
89
+ configurable: true,
90
+ });
91
+ };
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * Version type identifier.
7
+ */
8
+ export const VersionTypeId = '~@dxos/echo/VersionTypeId' as const;
9
+ export type VersionTypeId = typeof VersionTypeId;
10
+
11
+ /**
12
+ * Represents the object version.
13
+ * May be backed by Automerge.
14
+ * Objects with no history are not versioned.
15
+ */
16
+ export interface Version {
17
+ [VersionTypeId]: {};
18
+ automergeHeads?: string[];
19
+ }
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { DXN } from '@dxos/keys';
6
+
7
+ /**
8
+ * DXN identity of the system {@link Tag} type.
9
+ *
10
+ * Defined in this low-level leaf so it can be shared by the public `Tag` type (which brands the
11
+ * schema with this DXN) and by `EntityMetaSchema.tags` (which builds a `Ref<Tag>` schema from it)
12
+ * without either importing the other — `Tag` is top-level and `meta` is deep-internal, so a direct
13
+ * dependency between them would form an eval-order cycle.
14
+ */
15
+ export const TagTypeDXN = DXN.make('org.dxos.type.tag', '0.1.0');
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './Annotation';
6
+ export * from './common';
7
+ export * from './Entity';
8
+ export * from './Format';
9
+ export * from './JsonSchema';
10
+ // TODO(wittjosiah): Required to ensure types are portable (need to export all types required for downstream inference).
11
+ export * from './Obj';
12
+ export { prettyFilter, prettyQuery } from './Query/pretty';
13
+ export * from './Ref';
14
+ export * from './Type';
15
+
16
+ // Re-exported here (not from the low-level `common/types` barrel) so consumers keep importing meta
17
+ // from `@dxos/echo/internal`, while that barrel stays free of the Ref/Annotation eval cycle. Placed
18
+ // after `./Ref` so the ref schema `meta` depends on is initialized first.
19
+ export * from './common/types/meta';
@@ -0,0 +1,131 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import { describe, test } from 'vitest';
7
+
8
+ import { raise } from '@dxos/debug';
9
+
10
+ import { Entity, Obj, Ref, Relation, Type } from '../index';
11
+ import { TestSchema } from './test-schema';
12
+
13
+ describe('Experimental API review', () => {
14
+ test('type checks', ({ expect }) => {
15
+ const contact = Obj.make(TestSchema.Person, { name: 'Test' });
16
+ const type = Obj.getType(contact) ?? raise(new Error('No type found'));
17
+
18
+ expect(Type.getTypename(type)).to.eq(Type.getTypename(TestSchema.Person));
19
+ expect(Type.getTypename(type)).to.eq('com.example.type.person');
20
+ expect(Type.getVersion(type)).to.eq('0.1.0');
21
+ // `Type.getMeta` returns `EntityMeta` (`{ keys, tags?, key?, version? }`) —
22
+ // the same shape `Obj.getMeta` and `Relation.getMeta` return. The
23
+ // schema-kind brand lives on `[SchemaKindId]`, not in meta.
24
+ expect(Type.getMeta(type)).to.deep.eq({
25
+ keys: [],
26
+ tags: [],
27
+ annotations: {},
28
+ key: 'com.example.type.person',
29
+ version: '0.1.0',
30
+ });
31
+ expect(Type.isObject(type)).to.be.true;
32
+ });
33
+
34
+ test('instance checks', ({ expect }) => {
35
+ const organization = Obj.make(TestSchema.Organization, { name: 'DXOS' });
36
+ const contact = Obj.make(TestSchema.Person, {
37
+ name: 'Test',
38
+ employer: Ref.make(organization),
39
+ });
40
+
41
+ expect(Schema.is(Type.getSchema(TestSchema.Person))(contact)).to.be.true;
42
+ expect(Obj.instanceOf(TestSchema.Person, contact)).to.be.true;
43
+ expect(Obj.instanceOf(TestSchema.Organization, organization)).to.be.true;
44
+
45
+ const isPerson = Obj.instanceOf(TestSchema.Person);
46
+ const x: any = {};
47
+ if (isPerson(x)) {
48
+ x.name;
49
+ }
50
+ });
51
+
52
+ test('default props', ({ expect }) => {
53
+ const message = Obj.make(TestSchema.Message, TestSchema.MessageStruct.make({}));
54
+ expect(message.timestamp).to.exist;
55
+ });
56
+
57
+ test('Obj.isObject', ({ expect }) => {
58
+ const guy = Obj.make(TestSchema.Person, { name: 'Test' });
59
+ expect(Obj.isObject(guy)).to.be.true;
60
+ expect(Obj.isObject(null)).to.be.false;
61
+ expect(Obj.isObject(undefined)).to.be.false;
62
+ expect(Obj.isObject(1)).to.be.false;
63
+ expect(Obj.isObject('string')).to.be.false;
64
+ });
65
+
66
+ test('create relation', ({ expect }) => {
67
+ const person = Obj.make(TestSchema.Person, { name: 'Test' });
68
+ const organization = Obj.make(TestSchema.Organization, { name: 'DXOS' });
69
+ const worksFor = Relation.make(TestSchema.EmployedBy, {
70
+ [Relation.Source]: person,
71
+ [Relation.Target]: organization,
72
+ role: 'CEO',
73
+ });
74
+ expect(Relation.getSource(worksFor)).to.eq(person);
75
+ expect(Relation.getTarget(worksFor)).to.eq(organization);
76
+ });
77
+
78
+ test('version', ({ expect }) => {
79
+ const person = Obj.make(TestSchema.Person, { name: 'Test' });
80
+ const version = Obj.version(person);
81
+ expect(Obj.isVersion(version)).to.be.true;
82
+ expect(Obj.versionValid(version)).to.be.false;
83
+ });
84
+
85
+ // TODO(burdon): Implement test.
86
+ test.skip('type narrowing', () => {
87
+ const any: Entity.Unknown = null as any;
88
+
89
+ {
90
+ if (Obj.isObject(any)) {
91
+ any;
92
+ } else {
93
+ any;
94
+ }
95
+ }
96
+
97
+ {
98
+ if (Relation.isRelation(any)) {
99
+ any;
100
+ } else {
101
+ any;
102
+ }
103
+ }
104
+ });
105
+
106
+ /**
107
+ * Test that Obj.make return types are clean and don't expose internal markers like OfKind.
108
+ * The return type of Obj.make(Schema, props) should be assignable to Obj.Obj<InstanceType>.
109
+ */
110
+ describe('Obj.make return type', () => {
111
+ test('Obj.make with custom schema should be assignable to Obj.Obj<Person>', ({ expect }) => {
112
+ {
113
+ const expando = Obj.make(TestSchema.Expando, { content: 'Test' });
114
+ expect(Obj.isObject(expando)).to.be.true;
115
+ expect(expando.content).to.eq('Test');
116
+
117
+ // This should work: assign to Obj.Obj of the schema's instance type
118
+ const _typed: Obj.OfShape<TestSchema.Expando> = expando;
119
+ }
120
+
121
+ {
122
+ const person = Obj.make(TestSchema.Person, { name: 'Test' });
123
+ expect(Obj.isObject(person)).to.be.true;
124
+ expect(person.name).to.eq('Test');
125
+
126
+ // This should work: assign to Obj.Obj of the schema's instance type
127
+ const _typed: Obj.OfShape<TestSchema.Person> = person;
128
+ }
129
+ });
130
+ });
131
+ });
@@ -2,4 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './types';
5
+ export * from './registry';
6
+ export * from './test-data';
7
+ export * from './test-schema';
8
+ export * from './util';
@@ -0,0 +1,44 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Atom from '@effect-atom/atom/Atom';
6
+ import * as Layer from 'effect/Layer';
7
+
8
+ import { Event } from '@dxos/async';
9
+
10
+ import * as Registry from '../Registry';
11
+
12
+ /**
13
+ * Noop `Registry.Service` layer for testing — always returns empty query results.
14
+ * Use this in test layer stacks that require `Registry.Service` but don't need
15
+ * actual registry contents.
16
+ */
17
+ export const registryLayerNoop: Layer.Layer<Registry.Service> = Layer.succeed(Registry.Service, {
18
+ [Registry.TypeId]: Registry.TypeId,
19
+ id: 'noop-registry',
20
+ changed: new Event<void>(),
21
+ local: [],
22
+ add: () => {},
23
+ remove: () => false,
24
+ clear: () => {},
25
+ get: () => undefined,
26
+ getByURI: () => undefined,
27
+ list: () => [],
28
+ // QueryFn is an overloaded interface — a single generic function cannot satisfy both overload
29
+ // signatures without a cast. This is the intentional type-system boundary.
30
+ query: ((_queryOrFilter: unknown) => ({
31
+ results: [],
32
+ entries: [],
33
+ run: async () => [],
34
+ runEntries: async () => [],
35
+ runSync: () => [],
36
+ runSyncEntries: () => [],
37
+ first: async (): Promise<never> => {
38
+ throw new Error('registryLayerNoop: registry is empty');
39
+ },
40
+ firstOrUndefined: async () => undefined,
41
+ subscribe: () => () => {},
42
+ atom: Atom.make((): never[] => []),
43
+ })) as Registry.Registry['query'],
44
+ } satisfies Registry.Registry);