@dxos/echo 0.8.4-main.72ec0f3 → 0.8.4-main.7ace549

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 (332) hide show
  1. package/dist/lib/browser/{chunk-BIDAASFK.mjs → chunk-7GH6RXJ3.mjs} +2246 -2290
  2. package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
  4. package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +18 -8
  6. package/dist/lib/browser/internal/index.mjs +45 -45
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +252 -191
  9. package/dist/lib/browser/testing/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
  11. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
  12. package/dist/lib/node-esm/{chunk-3SVRRCUU.mjs → chunk-M4B6BMD2.mjs} +2246 -2290
  13. package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
  14. package/dist/lib/node-esm/index.mjs +18 -8
  15. package/dist/lib/node-esm/internal/index.mjs +45 -45
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +252 -191
  18. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  19. package/dist/types/src/Annotation.d.ts +2 -0
  20. package/dist/types/src/Annotation.d.ts.map +1 -0
  21. package/dist/types/src/Database.d.ts +137 -0
  22. package/dist/types/src/Database.d.ts.map +1 -0
  23. package/dist/types/src/Entity.d.ts +36 -0
  24. package/dist/types/src/Entity.d.ts.map +1 -0
  25. package/dist/types/src/Format.d.ts +4 -0
  26. package/dist/types/src/Format.d.ts.map +1 -0
  27. package/dist/types/src/JsonSchema.d.ts +9 -0
  28. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  29. package/dist/types/src/Key.d.ts +1 -0
  30. package/dist/types/src/Key.d.ts.map +1 -1
  31. package/dist/types/src/Obj.d.ts +79 -70
  32. package/dist/types/src/Obj.d.ts.map +1 -1
  33. package/dist/types/src/Ref.d.ts +10 -10
  34. package/dist/types/src/Ref.d.ts.map +1 -1
  35. package/dist/types/src/Relation.d.ts +14 -11
  36. package/dist/types/src/Relation.d.ts.map +1 -1
  37. package/dist/types/src/Tag.d.ts +1 -1
  38. package/dist/types/src/Tag.d.ts.map +1 -1
  39. package/dist/types/src/Type.d.ts +39 -49
  40. package/dist/types/src/Type.d.ts.map +1 -1
  41. package/dist/types/src/index.d.ts +6 -3
  42. package/dist/types/src/index.d.ts.map +1 -1
  43. package/dist/types/src/internal/annotations/annotations.d.ts +174 -0
  44. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  45. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  46. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  47. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  48. package/dist/types/src/internal/annotations/util.d.ts +26 -0
  49. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  50. package/dist/types/src/internal/entities/entity.d.ts +10 -0
  51. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  52. package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
  53. package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
  54. package/dist/types/src/internal/entities/index.d.ts +6 -0
  55. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  56. package/dist/types/src/internal/entities/model.d.ts +70 -0
  57. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  58. package/dist/types/src/internal/entities/object.d.ts +11 -0
  59. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  60. package/dist/types/src/internal/entities/relation.d.ts +55 -0
  61. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  62. package/dist/types/src/internal/entities/util.d.ts +2 -0
  63. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  64. package/dist/types/src/internal/formats/format.d.ts +2 -0
  65. package/dist/types/src/internal/formats/format.d.ts.map +1 -1
  66. package/dist/types/src/internal/formats/types.d.ts +7 -7
  67. package/dist/types/src/internal/formats/types.d.ts.map +1 -1
  68. package/dist/types/src/internal/index.d.ts +6 -10
  69. package/dist/types/src/internal/index.d.ts.map +1 -1
  70. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  71. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  72. package/dist/types/src/internal/json-schema/index.d.ts +2 -0
  73. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
  74. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
  75. package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -1
  76. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  77. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  78. package/dist/types/src/internal/object/common.d.ts.map +1 -1
  79. package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +8 -9
  80. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  81. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  82. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  83. package/dist/types/src/internal/object/deleted.d.ts +2 -2
  84. package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
  85. package/dist/types/src/internal/object/ids.d.ts.map +1 -1
  86. package/dist/types/src/internal/object/index.d.ts +3 -11
  87. package/dist/types/src/internal/object/index.d.ts.map +1 -1
  88. package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
  89. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
  90. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
  91. package/dist/types/src/internal/object/typed-object.d.ts +1 -1
  92. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
  93. package/dist/types/src/internal/proxy/index.d.ts +3 -0
  94. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  95. package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
  96. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  97. package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
  98. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
  99. package/dist/types/src/internal/ref/ref.d.ts +15 -12
  100. package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
  101. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  102. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  103. package/dist/types/src/internal/schema/echo-schema.d.ts +9 -9
  104. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
  105. package/dist/types/src/internal/schema/index.d.ts +3 -4
  106. package/dist/types/src/internal/schema/index.d.ts.map +1 -1
  107. package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
  108. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  109. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
  110. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
  111. package/dist/types/src/internal/types/base.d.ts +37 -0
  112. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  113. package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
  114. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  115. package/dist/types/src/internal/types/index.d.ts +5 -2
  116. package/dist/types/src/internal/types/index.d.ts.map +1 -1
  117. package/dist/types/src/internal/{object → types}/meta.d.ts +20 -11
  118. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  119. package/dist/types/src/internal/types/typename.d.ts +13 -0
  120. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  121. package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
  122. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  123. package/dist/types/src/query/filter.d.ts +167 -0
  124. package/dist/types/src/query/filter.d.ts.map +1 -0
  125. package/dist/types/src/query/index.d.ts +3 -0
  126. package/dist/types/src/query/index.d.ts.map +1 -1
  127. package/dist/types/src/query/order.d.ts +12 -0
  128. package/dist/types/src/query/order.d.ts.map +1 -0
  129. package/dist/types/src/query/query.d.ts +9 -145
  130. package/dist/types/src/query/query.d.ts.map +1 -1
  131. package/dist/types/src/query/testing.d.ts +51 -0
  132. package/dist/types/src/query/testing.d.ts.map +1 -0
  133. package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
  134. package/dist/types/src/query/types.d.ts.map +1 -0
  135. package/dist/types/src/query/util.d.ts +8 -0
  136. package/dist/types/src/query/util.d.ts.map +1 -0
  137. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  138. package/dist/types/src/testing/index.d.ts +3 -3
  139. package/dist/types/src/testing/index.d.ts.map +1 -1
  140. package/dist/types/src/testing/test-data.d.ts +18 -0
  141. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  142. package/dist/types/src/testing/{types.d.ts → test-schema.d.ts} +166 -57
  143. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  144. package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
  145. package/dist/types/src/testing/util.d.ts.map +1 -0
  146. package/dist/types/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +46 -38
  148. package/src/Annotation.ts +17 -0
  149. package/src/Database.ts +189 -0
  150. package/src/Entity.ts +51 -0
  151. package/src/Format.ts +11 -0
  152. package/src/JsonSchema.ts +16 -0
  153. package/src/Key.ts +3 -0
  154. package/src/Obj.ts +248 -181
  155. package/src/Ref.ts +9 -9
  156. package/src/Relation.ts +58 -44
  157. package/src/Tag.ts +2 -1
  158. package/src/Type.ts +96 -83
  159. package/src/index.ts +9 -4
  160. package/src/internal/README.md +83 -0
  161. package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
  162. package/src/internal/annotations/annotations.ts +463 -0
  163. package/src/internal/annotations/index.ts +6 -0
  164. package/src/internal/annotations/util.ts +70 -0
  165. package/src/internal/entities/entity.ts +109 -0
  166. package/src/internal/{object → entities}/expando.ts +7 -5
  167. package/src/internal/entities/index.ts +9 -0
  168. package/src/internal/{object → entities}/model.ts +49 -90
  169. package/src/internal/entities/object.ts +45 -0
  170. package/src/internal/entities/relation.ts +155 -0
  171. package/src/internal/entities/util.ts +33 -0
  172. package/src/internal/formats/date.test.ts +1 -1
  173. package/src/internal/formats/date.ts +5 -5
  174. package/src/internal/formats/format.test.ts +5 -5
  175. package/src/internal/formats/format.ts +3 -0
  176. package/src/internal/formats/number.ts +5 -5
  177. package/src/internal/formats/object.ts +2 -2
  178. package/src/internal/formats/string.ts +9 -9
  179. package/src/internal/formats/types.ts +44 -39
  180. package/src/internal/index.ts +29 -13
  181. package/src/internal/{json → json-schema}/annotations.ts +1 -1
  182. package/src/internal/json-schema/index.ts +2 -0
  183. package/src/internal/json-schema/json-schema-type.ts +4 -3
  184. package/src/internal/{json → json-schema}/json-schema.test.ts +48 -38
  185. package/src/internal/{json → json-schema}/json-schema.ts +16 -7
  186. package/src/internal/object/common.ts +3 -4
  187. package/src/internal/object/{create.test.ts → create-object.test.ts} +30 -32
  188. package/src/internal/object/{create.ts → create-object.ts} +33 -34
  189. package/src/internal/object/deleted.ts +6 -6
  190. package/src/internal/object/ids.ts +1 -1
  191. package/src/internal/object/index.ts +3 -11
  192. package/src/internal/object/inspect.ts +3 -5
  193. package/src/internal/object/json-serializer.test.ts +33 -38
  194. package/src/internal/object/json-serializer.ts +43 -38
  195. package/src/internal/object/schema-validator.ts +3 -2
  196. package/src/internal/object/typed-object.test.ts +1 -1
  197. package/src/internal/object/typed-object.ts +11 -5
  198. package/src/internal/proxy/handler.test.ts +30 -20
  199. package/src/internal/proxy/index.ts +6 -0
  200. package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
  201. package/src/internal/proxy/schema.test.ts +5 -4
  202. package/src/internal/proxy/typed-handler.test.ts +28 -28
  203. package/src/internal/proxy/typed-handler.ts +8 -3
  204. package/src/internal/proxy/typed-object.test.ts +16 -11
  205. package/src/internal/ref/ref.test.ts +8 -7
  206. package/src/internal/ref/ref.ts +24 -20
  207. package/src/internal/{projection → schema}/compose.test.ts +5 -6
  208. package/src/internal/{projection → schema}/compose.ts +2 -1
  209. package/src/internal/schema/echo-schema.ts +30 -28
  210. package/src/internal/schema/index.ts +3 -4
  211. package/src/internal/schema/manipulation.ts +1 -1
  212. package/src/internal/schema/persistent-schema.ts +28 -0
  213. package/src/internal/schema/runtime-schema-registry.ts +4 -4
  214. package/src/internal/types/base.ts +58 -0
  215. package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
  216. package/src/internal/types/index.ts +5 -2
  217. package/src/internal/{object → types}/meta.ts +32 -17
  218. package/src/internal/types/typename.ts +45 -0
  219. package/src/internal/types/version.ts +20 -0
  220. package/src/query/filter.ts +455 -0
  221. package/src/query/index.ts +4 -1
  222. package/src/query/order.ts +34 -0
  223. package/src/query/query.test.ts +48 -115
  224. package/src/query/query.ts +16 -502
  225. package/src/query/testing.ts +64 -0
  226. package/src/query/util.ts +25 -0
  227. package/src/testing/api.test.ts +100 -0
  228. package/src/testing/index.ts +3 -3
  229. package/src/testing/test-data.ts +130 -0
  230. package/src/testing/test-schema.ts +213 -0
  231. package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
  232. package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
  233. package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
  234. package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
  236. package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
  237. package/dist/lib/browser/query/index.mjs +0 -13
  238. package/dist/lib/browser/query/index.mjs.map +0 -7
  239. package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
  240. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
  241. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
  242. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
  243. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
  244. package/dist/lib/node-esm/query/index.mjs +0 -13
  245. package/dist/lib/node-esm/query/index.mjs.map +0 -7
  246. package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
  247. package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
  248. package/dist/types/src/internal/ast/annotations.d.ts +0 -131
  249. package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
  250. package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
  251. package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
  252. package/dist/types/src/internal/ast/index.d.ts +0 -5
  253. package/dist/types/src/internal/ast/index.d.ts.map +0 -1
  254. package/dist/types/src/internal/ast/types.d.ts +0 -6
  255. package/dist/types/src/internal/ast/types.d.ts.map +0 -1
  256. package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
  257. package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
  258. package/dist/types/src/internal/json/index.d.ts +0 -2
  259. package/dist/types/src/internal/json/index.d.ts.map +0 -1
  260. package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
  261. package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
  262. package/dist/types/src/internal/object/accessors.d.ts +0 -37
  263. package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
  264. package/dist/types/src/internal/object/create.d.ts.map +0 -1
  265. package/dist/types/src/internal/object/create.test.d.ts +0 -2
  266. package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
  267. package/dist/types/src/internal/object/entity.d.ts +0 -33
  268. package/dist/types/src/internal/object/entity.d.ts.map +0 -1
  269. package/dist/types/src/internal/object/expando.d.ts.map +0 -1
  270. package/dist/types/src/internal/object/meta.d.ts.map +0 -1
  271. package/dist/types/src/internal/object/model.d.ts +0 -117
  272. package/dist/types/src/internal/object/model.d.ts.map +0 -1
  273. package/dist/types/src/internal/object/relation.d.ts +0 -17
  274. package/dist/types/src/internal/object/relation.d.ts.map +0 -1
  275. package/dist/types/src/internal/object/typename.d.ts +0 -15
  276. package/dist/types/src/internal/object/typename.d.ts.map +0 -1
  277. package/dist/types/src/internal/object/version.d.ts.map +0 -1
  278. package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
  279. package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
  280. package/dist/types/src/internal/projection/index.d.ts +0 -2
  281. package/dist/types/src/internal/projection/index.d.ts.map +0 -1
  282. package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
  283. package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
  284. package/dist/types/src/internal/query/index.d.ts +0 -2
  285. package/dist/types/src/internal/query/index.d.ts.map +0 -1
  286. package/dist/types/src/internal/query/query.d.ts.map +0 -1
  287. package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
  288. package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
  289. package/dist/types/src/internal/testing/index.d.ts +0 -3
  290. package/dist/types/src/internal/testing/index.d.ts.map +0 -1
  291. package/dist/types/src/internal/testing/types.d.ts +0 -381
  292. package/dist/types/src/internal/testing/types.d.ts.map +0 -1
  293. package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
  294. package/dist/types/src/internal/types/types.d.ts +0 -79
  295. package/dist/types/src/internal/types/types.d.ts.map +0 -1
  296. package/dist/types/src/internal/types/types.test.d.ts +0 -2
  297. package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
  298. package/dist/types/src/internal/types/util.d.ts +0 -5
  299. package/dist/types/src/internal/types/util.d.ts.map +0 -1
  300. package/dist/types/src/testing/echo-schema.d.ts +0 -7
  301. package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
  302. package/dist/types/src/testing/types.d.ts.map +0 -1
  303. package/src/internal/ast/annotation-helper.ts +0 -22
  304. package/src/internal/ast/annotations.ts +0 -226
  305. package/src/internal/ast/index.ts +0 -8
  306. package/src/internal/ast/types.ts +0 -17
  307. package/src/internal/json/index.ts +0 -5
  308. package/src/internal/object/accessors.ts +0 -153
  309. package/src/internal/object/entity.ts +0 -248
  310. package/src/internal/object/relation.ts +0 -24
  311. package/src/internal/object/typename.ts +0 -61
  312. package/src/internal/object/version.ts +0 -22
  313. package/src/internal/projection/index.ts +0 -5
  314. package/src/internal/query/index.ts +0 -5
  315. package/src/internal/schema/stored-schema.ts +0 -26
  316. package/src/internal/testing/index.ts +0 -6
  317. package/src/internal/testing/types.ts +0 -144
  318. package/src/internal/types/types.test.ts +0 -48
  319. package/src/internal/types/types.ts +0 -176
  320. package/src/internal/types/util.ts +0 -9
  321. package/src/test/api.test.ts +0 -180
  322. package/src/testing/echo-schema.ts +0 -39
  323. package/src/testing/types.ts +0 -108
  324. /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
  325. /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
  326. /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
  327. /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
  328. /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
  329. /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
  330. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
  331. /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
  332. /package/src/{internal/query/query.ts → query/types.ts} +0 -0
package/src/Relation.ts CHANGED
@@ -6,50 +6,67 @@ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
  import { assertArgument, invariant } from '@dxos/invariant';
9
- import { DXN } from '@dxos/keys';
9
+ import { DXN, type ObjectId } from '@dxos/keys';
10
10
  import { type Live } from '@dxos/live-object';
11
11
  import { assumeType } from '@dxos/util';
12
12
 
13
- import { live } from './internal';
14
- import * as EchoSchema from './internal';
13
+ import * as Entity from './Entity';
14
+ import {
15
+ ATTR_RELATION_SOURCE,
16
+ ATTR_RELATION_TARGET,
17
+ type AnyEchoObject,
18
+ EntityKind,
19
+ type InternalObjectProps,
20
+ MetaId,
21
+ type ObjectMeta,
22
+ RelationSourceDXNId,
23
+ RelationSourceId,
24
+ RelationTargetDXNId,
25
+ RelationTargetId,
26
+ getObjectDXN,
27
+ getTypeAnnotation,
28
+ makeObject,
29
+ } from './internal';
15
30
  import * as Obj from './Obj';
16
31
  import * as Type from './Type';
17
32
 
18
33
  /**
19
- * NOTE: Don't export: Relation.Relation and Relation.Any form the public API.
34
+ * Base type for all ECHO relations.
35
+ * @private
20
36
  */
21
37
  interface BaseRelation<Source, Target>
22
- extends EchoSchema.HasId,
38
+ extends AnyEchoObject,
23
39
  Type.Relation.Endpoints<Source, Target>,
24
- Type.OfKind<EchoSchema.EntityKind.Relation> {}
40
+ Entity.OfKind<EntityKind.Relation> {}
25
41
 
26
42
  /**
27
- * Relation type with specific properties.
28
- */
29
- export type Relation<Source extends Obj.Any, Target extends Obj.Any, Props> = BaseRelation<Source, Target> & Props;
30
-
31
- /**
32
- * Base type for all ECHO relations.
43
+ * Base type for all Relations objects.
33
44
  */
34
45
  export interface Any extends BaseRelation<Obj.Any, Obj.Any> {}
35
46
 
36
47
  export const Any = Schema.Struct({}).pipe(
37
48
  Type.Relation({
38
- typename: 'dxos.org/types/Any',
49
+ typename: 'dxos.org/type/Any',
39
50
  version: '0.1.0',
40
51
  source: Obj.Any,
41
52
  target: Obj.Any,
42
53
  }),
43
54
  );
44
55
 
45
- // TODO(dmaretskyi): Has to be `unique symbol`.
46
- export const Source: unique symbol = EchoSchema.RelationSourceId as any;
56
+ /**
57
+ * Relation type with specific source and target types.
58
+ */
59
+ export type Relation<Source extends Obj.Any, Target extends Obj.Any, Props> = BaseRelation<Source, Target> & Props;
60
+
61
+ export const Source: unique symbol = RelationSourceId as any;
47
62
  export type Source = typeof Source;
48
- export const Target: unique symbol = EchoSchema.RelationTargetId as any;
63
+
64
+ export const Target: unique symbol = RelationTargetId as any;
49
65
  export type Target = typeof Target;
50
66
 
51
67
  type MakeProps<T extends Any> = {
52
- id?: EchoSchema.ObjectId;
68
+ id?: ObjectId;
69
+ [MetaId]?: ObjectMeta;
53
70
  [Source]: T[Source];
54
71
  [Target]: T[Target];
55
72
  } & Type.Properties<T>;
@@ -66,37 +83,34 @@ type MakeProps<T extends Any> = {
66
83
  export const make = <S extends Type.Relation.Any>(
67
84
  schema: S,
68
85
  props: NoInfer<MakeProps<Schema.Schema.Type<S>>>,
69
- meta?: EchoSchema.ObjectMeta,
70
- ): Live<Schema.Schema.Type<S> & Type.OfKind<EchoSchema.EntityKind.Relation>> => {
71
- assertArgument(
72
- EchoSchema.getTypeAnnotation(schema)?.kind === EchoSchema.EntityKind.Relation,
73
- 'schema',
74
- 'Expected a relation schema',
75
- );
76
-
77
- if (props[EchoSchema.MetaId] != null) {
78
- meta = props[EchoSchema.MetaId] as any;
79
- delete props[EchoSchema.MetaId];
86
+ meta?: ObjectMeta,
87
+ ): Live<Schema.Schema.Type<S> & Entity.OfKind<typeof Entity.Kind.Relation>> => {
88
+ assertArgument(getTypeAnnotation(schema)?.kind === EntityKind.Relation, 'schema', 'Expected a relation schema');
89
+
90
+ if (props[MetaId] != null) {
91
+ meta = props[MetaId] as any;
92
+ delete props[MetaId];
80
93
  }
81
94
 
82
- const sourceDXN = EchoSchema.getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
83
- const targetDXN = EchoSchema.getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
84
- (props as any)[EchoSchema.RelationSourceDXNId] = sourceDXN;
85
- (props as any)[EchoSchema.RelationTargetDXNId] = targetDXN;
95
+ const sourceDXN = getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
96
+ const targetDXN = getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
97
+
98
+ (props as any)[RelationSourceDXNId] = sourceDXN;
99
+ (props as any)[RelationTargetDXNId] = targetDXN;
86
100
 
87
- return live<Schema.Schema.Type<S>>(schema, props as any, meta);
101
+ return makeObject<Schema.Schema.Type<S>>(schema, props as any, meta);
88
102
  };
89
103
 
90
104
  export const isRelation = (value: unknown): value is Any => {
91
105
  if (typeof value !== 'object' || value === null) {
92
106
  return false;
93
107
  }
94
- if (EchoSchema.ATTR_RELATION_SOURCE in value || EchoSchema.ATTR_RELATION_TARGET in value) {
108
+ if (ATTR_RELATION_SOURCE in value || ATTR_RELATION_TARGET in value) {
95
109
  return true;
96
110
  }
97
111
 
98
- const kind = (value as any)[EchoSchema.EntityKindId];
99
- return kind === EchoSchema.EntityKind.Relation;
112
+ const kind = (value as any)[Entity.KindId];
113
+ return kind === EntityKind.Relation;
100
114
  };
101
115
 
102
116
  /**
@@ -105,8 +119,8 @@ export const isRelation = (value: unknown): value is Any => {
105
119
  */
106
120
  export const getSourceDXN = (value: Any): DXN => {
107
121
  assertArgument(isRelation(value), 'Expected a relation');
108
- assumeType<EchoSchema.InternalObjectProps>(value);
109
- const dxn = (value as EchoSchema.InternalObjectProps)[EchoSchema.RelationSourceDXNId];
122
+ assumeType<InternalObjectProps>(value);
123
+ const dxn = (value as InternalObjectProps)[RelationSourceDXNId];
110
124
  invariant(dxn instanceof DXN);
111
125
  return dxn;
112
126
  };
@@ -117,8 +131,8 @@ export const getSourceDXN = (value: Any): DXN => {
117
131
  */
118
132
  export const getTargetDXN = (value: Any): DXN => {
119
133
  assertArgument(isRelation(value), 'Expected a relation');
120
- assumeType<EchoSchema.InternalObjectProps>(value);
121
- const dxn = (value as EchoSchema.InternalObjectProps)[EchoSchema.RelationTargetDXNId];
134
+ assumeType<InternalObjectProps>(value);
135
+ const dxn = (value as InternalObjectProps)[RelationTargetDXNId];
122
136
  invariant(dxn instanceof DXN);
123
137
  return dxn;
124
138
  };
@@ -129,8 +143,8 @@ export const getTargetDXN = (value: Any): DXN => {
129
143
  */
130
144
  export const getSource = <T extends Any>(relation: T): Type.Relation.Source<T> => {
131
145
  assertArgument(isRelation(relation), 'Expected a relation');
132
- assumeType<EchoSchema.InternalObjectProps>(relation);
133
- const obj = (relation as EchoSchema.InternalObjectProps)[EchoSchema.RelationSourceId];
146
+ assumeType<InternalObjectProps>(relation);
147
+ const obj = (relation as InternalObjectProps)[RelationSourceId];
134
148
  invariant(obj !== undefined, `Invalid source: ${relation.id}`);
135
149
  return obj as Type.Relation.Source<T>;
136
150
  };
@@ -141,8 +155,8 @@ export const getSource = <T extends Any>(relation: T): Type.Relation.Source<T> =
141
155
  */
142
156
  export const getTarget = <T extends Any>(relation: T): Type.Relation.Target<T> => {
143
157
  assertArgument(isRelation(relation), 'Expected a relation');
144
- assumeType<EchoSchema.InternalObjectProps>(relation);
145
- const obj = (relation as EchoSchema.InternalObjectProps)[EchoSchema.RelationTargetId];
158
+ assumeType<InternalObjectProps>(relation);
159
+ const obj = (relation as InternalObjectProps)[RelationTargetId];
146
160
  invariant(obj !== undefined, `Invalid target: ${relation.id}`);
147
161
  return obj as Type.Relation.Target<T>;
148
162
  };
package/src/Tag.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { LabelAnnotation } from './internal';
7
+ import { LabelAnnotation, SystemTypeAnnotation } from './internal';
8
8
  import * as Obj from './Obj';
9
9
  import * as Type from './Type';
10
10
 
@@ -17,6 +17,7 @@ export const Tag = Schema.Struct({
17
17
  version: '0.1.0',
18
18
  }),
19
19
  LabelAnnotation.set(['label']),
20
+ SystemTypeAnnotation.set(true),
20
21
  );
21
22
 
22
23
  export type Tag = Schema.Schema.Type<typeof Tag>;
package/src/Type.ts CHANGED
@@ -2,44 +2,59 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import type * as EffectSchema from 'effect/Schema';
5
+ import type * as Schema$ from 'effect/Schema';
6
6
 
7
7
  import { type EncodedReference } from '@dxos/echo-protocol';
8
8
  import { invariant } from '@dxos/invariant';
9
- import type * as Keys from '@dxos/keys';
9
+ import { type DXN } from '@dxos/keys';
10
+ import { type ToMutable } from '@dxos/util';
11
+
12
+ import type * as Entity$ from './Entity';
13
+ import {
14
+ type ATTR_RELATION_SOURCE,
15
+ type ATTR_RELATION_TARGET,
16
+ EchoObjectSchema,
17
+ EchoRelationSchema,
18
+ type EchoRelationSchemaOptions,
19
+ EchoSchema,
20
+ Expando as Expando$,
21
+ type ExpandoEncoded,
22
+ PersistentSchema,
23
+ type PersistentSchemaEncoded,
24
+ Ref as Ref$,
25
+ type RefFn,
26
+ type RefSchema,
27
+ type TypeAnnotation,
28
+ type TypeMeta,
29
+ getSchemaDXN,
30
+ getSchemaTypename,
31
+ getSchemaVersion,
32
+ getTypeAnnotation,
33
+ isMutable as isMutable$,
34
+ toEffectSchema,
35
+ toJsonSchema,
36
+ } from './internal';
37
+ import type * as Relation$ from './Relation';
38
+
39
+ // TODO(burdon): Remove toEffectSchema, toJsonSchema (moved to JsonSchema export).
40
+ export { toEffectSchema, toJsonSchema };
10
41
 
11
- import { type ToMutable } from './internal';
12
- import * as EchoSchema from './internal';
13
- import type * as RelationModule from './Relation';
42
+ /**
43
+ * Returns all properties of an object or relation except for the id and kind.
44
+ */
45
+ export type Properties<T = any> = Omit<T, 'id' | Entity$.KindId | Relation$.Source | Relation$.Target>;
14
46
 
15
47
  //
16
- // Kind
48
+ // Entity
17
49
  //
18
50
 
19
- export const KindId: unique symbol = EchoSchema.EntityKindId as any;
20
- export type KindId = typeof KindId;
21
-
22
- export const Kind = EchoSchema.EntityKind;
23
-
24
- /**
25
- * Assigns a kind to an Object or Relation instance.
26
- */
27
- // NOTE: Needed to make `isRelation` and `isObject` checks work.
28
- export interface OfKind<Kind extends EchoSchema.EntityKind> {
29
- readonly id: Keys.ObjectId;
30
- readonly [KindId]: Kind;
51
+ export namespace Entity {
52
+ /**
53
+ * Type.Obj.Any | Type.Relation.Any.
54
+ */
55
+ export type Any = Obj.Any | Relation.Any;
31
56
  }
32
57
 
33
- /**
34
- * Base ECHO schema type.
35
- */
36
- export type Schema = EchoSchema.EchoSchema;
37
-
38
- /**
39
- * Returns all properties of an object or relation except for the id and kind.
40
- */
41
- export type Properties<T = any> = Omit<T, 'id' | KindId | RelationModule.Source | RelationModule.Target>;
42
-
43
58
  //
44
59
  // Obj
45
60
  //
@@ -54,21 +69,21 @@ interface ObjJsonProps {
54
69
  * This typedef avoids `TS4023` error (name from external module cannot be used named).
55
70
  * See Effect's note on interface types.
56
71
  */
57
- export interface obj<Self extends EffectSchema.Schema.Any>
58
- extends EchoSchema.TypeMeta,
59
- EffectSchema.AnnotableClass<
72
+ export interface obj<Self extends Schema$.Schema.Any>
73
+ extends TypeMeta,
74
+ Schema$.AnnotableClass<
60
75
  obj<Self>,
61
- OfKind<EchoSchema.EntityKind.Object> & ToMutable<EffectSchema.Schema.Type<Self>>,
62
- EffectSchema.Simplify<ObjJsonProps & ToMutable<EffectSchema.Schema.Encoded<Self>>>,
63
- EffectSchema.Schema.Context<Self>
76
+ Entity$.OfKind<typeof Entity$.Kind.Object> & ToMutable<Schema$.Schema.Type<Self>>,
77
+ Schema$.Simplify<ObjJsonProps & ToMutable<Schema$.Schema.Encoded<Self>>>,
78
+ Schema$.Schema.Context<Self>
64
79
  > {}
65
80
 
66
81
  /**
67
82
  * Object schema.
68
83
  */
69
84
  export const Obj: {
70
- (opts: EchoSchema.TypeMeta): <Self extends EffectSchema.Schema.Any>(self: Self) => obj<Self>;
71
- } = EchoSchema.EchoObject as any;
85
+ (opts: TypeMeta): <Self extends Schema$.Schema.Any>(self: Self) => obj<Self>;
86
+ } = EchoObjectSchema as any;
72
87
 
73
88
  /**
74
89
  * Object schema type definitions.
@@ -80,21 +95,24 @@ export declare namespace Obj {
80
95
  */
81
96
  // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
82
97
  // TODO(burdon): This erases the ECHO type info (e.g., id, typename).
83
- export type Any = EffectSchema.Schema.AnyNoContext;
98
+ export type Any = obj<Schema$.Schema.AnyNoContext>;
84
99
  }
85
100
 
86
101
  //
87
102
  // Expando
88
103
  //
89
104
 
90
- // TODO(burdon): We're using Expando in many places as a base type.
91
- export interface Expando extends OfKind<EchoSchema.EntityKind.Object> {
92
- [key: string]: any;
93
- }
105
+ export const Expando: obj<Schema$.Schema<Expando$, ExpandoEncoded>> = Expando$ as any;
106
+ export type Expando = obj<Schema$.Schema<Expando$, ExpandoEncoded>>;
94
107
 
95
- type ExpandoEncoded = EffectSchema.Simplify<ObjJsonProps & { [key: string]: any }>;
108
+ //
109
+ // Schema
110
+ //
111
+
112
+ export const PersistentType: obj<Schema$.Schema<PersistentSchema, PersistentSchemaEncoded>> = PersistentSchema as any;
113
+ export type PersistentType = obj<Schema$.Schema<PersistentSchema, PersistentSchemaEncoded>>;
96
114
 
97
- export const Expando: EffectSchema.Schema<Expando, ExpandoEncoded, never> = EchoSchema.Expando as any;
115
+ export { EchoSchema as RuntimeType };
98
116
 
99
117
  //
100
118
  // Relation
@@ -102,8 +120,8 @@ export const Expando: EffectSchema.Schema<Expando, ExpandoEncoded, never> = Echo
102
120
 
103
121
  interface RelationJsonProps {
104
122
  id: string;
105
- [EchoSchema.ATTR_RELATION_SOURCE]: string;
106
- [EchoSchema.ATTR_RELATION_TARGET]: string;
123
+ [ATTR_RELATION_SOURCE]: string;
124
+ [ATTR_RELATION_TARGET]: string;
107
125
  }
108
126
 
109
127
  /**
@@ -113,28 +131,29 @@ interface RelationJsonProps {
113
131
  * See Effect's note on interface types.
114
132
  */
115
133
  export interface relation<
116
- Self extends EffectSchema.Schema.Any,
117
- SourceSchema extends EffectSchema.Schema.Any,
118
- TargetSchema extends EffectSchema.Schema.Any,
119
- > extends EchoSchema.TypeMeta,
120
- EffectSchema.AnnotableClass<
134
+ Self extends Schema$.Schema.Any,
135
+ SourceSchema extends Schema$.Schema.Any,
136
+ TargetSchema extends Schema$.Schema.Any,
137
+ > extends TypeMeta,
138
+ Schema$.AnnotableClass<
121
139
  relation<Self, SourceSchema, TargetSchema>,
122
- OfKind<EchoSchema.EntityKind.Relation> &
123
- Relation.Endpoints<EffectSchema.Schema.Type<SourceSchema>, EffectSchema.Schema.Type<TargetSchema>> &
124
- ToMutable<EffectSchema.Schema.Type<Self>>,
125
- EffectSchema.Simplify<RelationJsonProps & ToMutable<EffectSchema.Schema.Encoded<Self>>>,
126
- EffectSchema.Schema.Context<Self>
140
+ Entity$.OfKind<typeof Entity$.Kind.Relation> &
141
+ Relation.Endpoints<Schema$.Schema.Type<SourceSchema>, Schema$.Schema.Type<TargetSchema>> &
142
+ ToMutable<Schema$.Schema.Type<Self>>,
143
+ Schema$.Simplify<RelationJsonProps & ToMutable<Schema$.Schema.Encoded<Self>>>,
144
+ Schema$.Schema.Context<Self>
127
145
  > {}
128
146
 
129
147
  /**
130
148
  * Relation schema.
131
149
  */
132
150
  // TODO(dmaretskyi): I have to redefine the type here so that the definition uses symbols from @dxos/echo/Relation.
151
+ // TODO(burdon): Remove?
133
152
  export const Relation: {
134
- <Source extends EffectSchema.Schema.AnyNoContext, Target extends EffectSchema.Schema.AnyNoContext>(
135
- opts: EchoSchema.EchoRelationOptions<Source, Target>,
136
- ): <Self extends EffectSchema.Schema.Any>(self: Self) => relation<Self, Source, Target>;
137
- } = EchoSchema.EchoRelation as any;
153
+ <Source extends Schema$.Schema.AnyNoContext, Target extends Schema$.Schema.AnyNoContext>(
154
+ opts: EchoRelationSchemaOptions<Source, Target>,
155
+ ): <Self extends Schema$.Schema.Any>(self: Self) => relation<Self, Source, Target>;
156
+ } = EchoRelationSchema as any;
138
157
 
139
158
  /**
140
159
  * Relation schema type definitions.
@@ -145,7 +164,7 @@ export namespace Relation {
145
164
  * NOTE: This is not an instance type.
146
165
  */
147
166
  // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
148
- export type Any = EffectSchema.Schema.AnyNoContext;
167
+ export type Any = Schema$.Schema.AnyNoContext;
149
168
 
150
169
  /**
151
170
  * Get relation source type.
@@ -158,13 +177,14 @@ export namespace Relation {
158
177
  export type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;
159
178
 
160
179
  export type Endpoints<Source, Target> = {
161
- [RelationModule.Source]: Source;
162
- [RelationModule.Target]: Target;
180
+ [Relation$.Source]: Source;
181
+ [Relation$.Target]: Target;
163
182
  };
164
183
  }
165
184
 
166
185
  //
167
186
  // Ref
187
+ // TODO(burdon): Reconcile Type.Ref with Ref.Ref.
168
188
  //
169
189
 
170
190
  /**
@@ -173,23 +193,21 @@ export namespace Relation {
173
193
  * This typedef avoids `TS4023` error (name from external module cannot be used named).
174
194
  * See Effect's note on interface types.
175
195
  */
176
- export interface ref<TargetSchema extends EffectSchema.Schema.Any>
177
- extends EchoSchema.Ref$<EffectSchema.Schema.Type<TargetSchema>> {}
196
+ export interface ref<TargetSchema extends Schema$.Schema.Any> extends RefSchema<Schema$.Schema.Type<TargetSchema>> {}
178
197
 
179
198
  /**
180
199
  * Ref schema.
181
200
  */
182
- export const Ref: <S extends Obj.Any>(schema: S) => ref<S> = EchoSchema.Ref;
201
+ export const Ref: RefFn = Ref$;
183
202
 
184
- export interface Ref<T> extends EffectSchema.SchemaClass<EchoSchema.Ref<T>, EncodedReference> {}
203
+ export interface Ref<T> extends Schema$.SchemaClass<Ref$<T>, EncodedReference> {}
185
204
 
186
- // TODO(buurdon): Move to Ref?
187
205
  export namespace Ref {
188
206
  /**
189
207
  * Type that represents an arbitrary schema type of a reference.
190
208
  * NOTE: This is not an instance type.
191
209
  */
192
- export type Any = EffectSchema.Schema<EchoSchema.Ref<any>, EncodedReference>;
210
+ export type Any = Schema$.Schema<Ref$<any>, EncodedReference>;
193
211
  }
194
212
 
195
213
  /**
@@ -198,16 +216,16 @@ export namespace Ref {
198
216
  * @example "dxn:example.com/type/Person:0.1.0"
199
217
  * @example "dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX"
200
218
  */
201
- export const getDXN = (schema: Obj.Any | Relation.Any): Keys.DXN | undefined => {
202
- return EchoSchema.getSchemaDXN(schema);
219
+ export const getDXN = (schema: Entity.Any): DXN | undefined => {
220
+ return getSchemaDXN(schema);
203
221
  };
204
222
 
205
223
  /**
206
224
  * @param schema - Schema to get the typename from.
207
225
  * @returns The typename of the schema. Example: `example.com/type/Person`.
208
226
  */
209
- export const getTypename = (schema: Obj.Any | Relation.Any): string => {
210
- const typename = EchoSchema.getSchemaTypename(schema);
227
+ export const getTypename = (schema: Entity.Any): string => {
228
+ const typename = getSchemaTypename(schema);
211
229
  invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');
212
230
  return typename;
213
231
  };
@@ -216,8 +234,8 @@ export const getTypename = (schema: Obj.Any | Relation.Any): string => {
216
234
  * Gets the version of the schema.
217
235
  * @example 0.1.0
218
236
  */
219
- export const getVersion = (schema: Obj.Any | Relation.Any): string => {
220
- const version = EchoSchema.getSchemaVersion(schema);
237
+ export const getVersion = (schema: Entity.Any): string => {
238
+ const version = getSchemaVersion(schema);
221
239
  invariant(typeof version === 'string' && version.match(/^\d+\.\d+\.\d+$/), 'Invalid version');
222
240
  return version;
223
241
  };
@@ -225,21 +243,16 @@ export const getVersion = (schema: Obj.Any | Relation.Any): string => {
225
243
  /**
226
244
  * @returns True if the schema is mutable.
227
245
  */
228
- export const isMutable = EchoSchema.isMutable;
246
+ export const isMutable = isMutable$;
229
247
 
230
248
  /**
231
249
  * ECHO type metadata.
232
250
  */
233
- export type Meta = EchoSchema.TypeAnnotation;
251
+ export type Meta = TypeAnnotation;
234
252
 
235
253
  /**
236
254
  * Gets the meta data of the schema.
237
255
  */
238
- export const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {
239
- return EchoSchema.getTypeAnnotation(schema);
256
+ export const getMeta = (schema: Entity.Any): Meta | undefined => {
257
+ return getTypeAnnotation(schema);
240
258
  };
241
-
242
- // TODO(dmaretskyi): Remove re-exports.
243
- export { SpaceId, ObjectId, DXN } from '@dxos/keys';
244
-
245
- export { Format, JsonSchemaType as JsonSchema, toEffectSchema, toJsonSchema } from './internal';
package/src/index.ts CHANGED
@@ -2,16 +2,21 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ export { DXN } from '@dxos/keys';
6
+
5
7
  export * from './errors';
8
+
9
+ // TODO(burdon): Separate namesapces for Query (Query.Query, Query.Filter, etc.)
6
10
  export * from './query';
7
11
 
12
+ export * as Annotation from './Annotation';
13
+ export * as Database from './Database';
14
+ export * as Entity from './Entity';
15
+ export * as Format from './Format';
16
+ export * as JsonSchema from './JsonSchema';
8
17
  export * as Key from './Key';
9
18
  export * as Obj from './Obj';
10
19
  export * as Ref from './Ref';
11
20
  export * as Relation from './Relation';
12
21
  export * as Tag from './Tag';
13
22
  export * as Type from './Type';
14
-
15
- export { QueryAST } from '@dxos/echo-protocol';
16
- export { DXN } from '@dxos/keys';
17
- export { type Live } from '@dxos/live-object';
@@ -0,0 +1,83 @@
1
+ ## Refactor
2
+
3
+ 1. Remove access from outisde of @dxos/echo-db
4
+
5
+ - [x] completely restructure @dxos/echo src/internal
6
+ - [x] Remove import "." and ".."! (create lint rule).
7
+ - [x] Unify FOUR different nests of test schema.
8
+ - [x] Remove @deprecated from internal methods and mark @internal (e.g., getSchemaDXN).
9
+ - NOTE: Internal methods should not use the import \* from Obj/Type APIs.
10
+ - [x] import ObjectId => @dxos/keys
11
+ - [x] Entity.Any = Obj.Any | Relation.Any
12
+ - NOTE: Relation does not extend (in not polymorphic with) Obj.
13
+ - [x] import LabelAnnotation => Annotation.LabelAnnotation
14
+ - [x] import Expando => Type.Expando
15
+ - [x] live => Obj.make
16
+ - [x] Rename live => makeObject
17
+ - [x] Rename {EchoObject, EchoRelation} => {EchoObjecSchema, EchoRelationSchema}
18
+ - [x] Rename AnyProperties => AnyProperties
19
+ - [x] Created Entity.Any (=> AnyEchoObject).
20
+ - [x] TypeFormat => TypeFormat
21
+ - [x] JsonSchemaType defs
22
+ - [x] Fix database.add() input/output types and search for "Obj.Any = db.add" (also QueryResult types).
23
+ - [x] TODO(burdon): FIX!!!
24
+ - [x] Fix failing tests.
25
+ - [x] Reconcile types/version with entities/model/version
26
+ - [x] Type.Expando => Obj.Any
27
+ - [x] Narrow QueryResult and match Schema and Object generics.
28
+
29
+ 2. Clean-up
30
+
31
+ - [ ] TODO(wittjosiah): Find a simpler way to define this type.
32
+ - [ ] TODO(wittjosiah): Should be Type.obj<...> or equivalent.
33
+ - [ ] Fix Obj.instanceOf(Type.Expando...
34
+ - [ ] Add Obj.Unknown and Relation.Unknown to match Entity.Unknown.
35
+ - [ ] Ref.Array.targets doesn't satisfy Obj.Any because it uses AnyEchoObject.
36
+ - [ ] Add Relation.MakeProps
37
+ - [ ] Schema registry should return Type.Entity.Any instead of Schema.Schema.AnyNoContext.
38
+ - [ ] Remove echo-db/AnyLiveObject<T> => Obj.Obj<T>
39
+ - [ ] Narrow QueryResult and match Schema and Object generics.
40
+ - [ ] Directly import JSONPath, etc. from @dxos/effect.
41
+ - [ ] DISCUSS: Standradize $ suffix to disambuguate imports (GPT recommended).
42
+ - [ ] Reconcile Type.Ref with Ref.Ref
43
+ - [ ] Promote parts of src/internal/ref to Ref.ts
44
+ - [ ] Rename AnyEchoObject => AnyEntity? (or accept that Object != Obj from naming perspective.)
45
+ - [ ] Remove WithId => AnyEchoObject
46
+ - [ ] Remove WithMeta => AnyEchoObject
47
+ - [ ] BaseSchema
48
+ - [ ] JsonPath, JsonProp, getValue, setValue => Json.Path?
49
+ - [ ] Move EchoSchemaRegistry into hypergraph
50
+
51
+ 3. Audit usage from @dxos/echo-db
52
+
53
+ - [ ] Ability to extract Struct from Type.Obj
54
+ - [ ] created/updated system props (const { created } = Obj.getTimestamps)?
55
+ - [ ] QueryFn, QueryOptions => Database
56
+ - [ ] Datatbase.query() options?
57
+ - [ ] Expando type is used as a fallback in many plance.
58
+ - [ ] Standardize '@automerge/automerge' imports (A vs. next).
59
+
60
+ ## NOTES
61
+
62
+ - Marking types as @internal (even for unexported types) erases type information.
63
+
64
+ ## 0.9.0
65
+
66
+ - [ ] Database, Queue, Space, Type, namespaces.
67
+ - [ ] Support class variant for types.
68
+ - [ ] Support defaults.
69
+ - [ ] Support effect Date, Timestamp formats.
70
+ - [ ] Metadata for created, updated timestamps.
71
+ - [ ] Effect team design review.
72
+ - [ ] @category annotations to group types in the API.
73
+ - [ ] TSdoc and LLM training for function generation.
74
+ - [ ] Rename TypeFormat => Primitive?
75
+ - [ ] Don't re-export effect?
76
+
77
+ ## Issues
78
+
79
+ - [ ] Build error when changing from TypedObject using Ref$: Type 'Task' does not satisfy the constraint 'WithId' (see echo-schema/testing/schema.ts)
80
+ - [ ] Reconcile all schema variants (Base, Immutable, TypedObject, EchoObject, etc.)
81
+ - [ ] Consolidate getters (getType, getSchema, getTypename, getSchemaTypename, etc.)
82
+ - [ ] ReactiveObject should specify id property? Reconcile AnyProperties, ReactiveObject, HasId, WithId, etc.
83
+ - [ ] Can we us S.is(MyType) to detect objects with our types system? (Branding?)