@dxos/echo 0.8.4-main.5ea62a8 → 0.8.4-main.66e292d

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 (328) hide show
  1. package/dist/lib/browser/chunk-7GH6RXJ3.mjs +3683 -0
  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 +24 -1
  6. package/dist/lib/browser/internal/index.mjs +336 -0
  7. package/dist/lib/browser/internal/index.mjs.map +7 -0
  8. package/dist/lib/browser/meta.json +1 -1
  9. package/dist/lib/browser/testing/index.mjs +289 -31
  10. package/dist/lib/browser/testing/index.mjs.map +4 -4
  11. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
  12. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-M4B6BMD2.mjs +3683 -0
  14. package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +24 -1
  16. package/dist/lib/node-esm/internal/index.mjs +336 -0
  17. package/dist/lib/node-esm/internal/index.mjs.map +7 -0
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/testing/index.mjs +289 -31
  20. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  21. package/dist/types/src/Annotation.d.ts +2 -0
  22. package/dist/types/src/Annotation.d.ts.map +1 -0
  23. package/dist/types/src/Database.d.ts +137 -0
  24. package/dist/types/src/Database.d.ts.map +1 -0
  25. package/dist/types/src/Entity.d.ts +36 -0
  26. package/dist/types/src/Entity.d.ts.map +1 -0
  27. package/dist/types/src/Format.d.ts +4 -0
  28. package/dist/types/src/Format.d.ts.map +1 -0
  29. package/dist/types/src/JsonSchema.d.ts +9 -0
  30. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  31. package/dist/types/src/Key.d.ts +1 -0
  32. package/dist/types/src/Key.d.ts.map +1 -1
  33. package/dist/types/src/Obj.d.ts +121 -50
  34. package/dist/types/src/Obj.d.ts.map +1 -1
  35. package/dist/types/src/Ref.d.ts +10 -10
  36. package/dist/types/src/Ref.d.ts.map +1 -1
  37. package/dist/types/src/Relation.d.ts +18 -14
  38. package/dist/types/src/Relation.d.ts.map +1 -1
  39. package/dist/types/src/Tag.d.ts +17 -0
  40. package/dist/types/src/Tag.d.ts.map +1 -0
  41. package/dist/types/src/Type.d.ts +39 -50
  42. package/dist/types/src/Type.d.ts.map +1 -1
  43. package/dist/types/src/errors.d.ts +68 -0
  44. package/dist/types/src/errors.d.ts.map +1 -0
  45. package/dist/types/src/index.d.ts +9 -3
  46. package/dist/types/src/index.d.ts.map +1 -1
  47. package/dist/types/src/internal/annotations/annotations.d.ts +174 -0
  48. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  49. package/dist/types/src/internal/annotations/annotations.test.d.ts +2 -0
  50. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  51. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  52. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  53. package/dist/types/src/internal/annotations/util.d.ts +26 -0
  54. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  55. package/dist/types/src/internal/entities/entity.d.ts +10 -0
  56. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  57. package/dist/types/src/internal/entities/expando.d.ts +16 -0
  58. package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
  59. package/dist/types/src/internal/entities/index.d.ts +6 -0
  60. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  61. package/dist/types/src/internal/entities/model.d.ts +70 -0
  62. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  63. package/dist/types/src/internal/entities/object.d.ts +11 -0
  64. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  65. package/dist/types/src/internal/entities/relation.d.ts +55 -0
  66. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  67. package/dist/types/src/internal/entities/util.d.ts +2 -0
  68. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  69. package/dist/types/src/internal/formats/date.d.ts +63 -0
  70. package/dist/types/src/internal/formats/date.d.ts.map +1 -0
  71. package/dist/types/src/internal/formats/date.test.d.ts +2 -0
  72. package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
  73. package/dist/types/src/internal/formats/format.d.ts +32 -0
  74. package/dist/types/src/internal/formats/format.d.ts.map +1 -0
  75. package/dist/types/src/internal/formats/format.test.d.ts +2 -0
  76. package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
  77. package/dist/types/src/internal/formats/index.d.ts +8 -0
  78. package/dist/types/src/internal/formats/index.d.ts.map +1 -0
  79. package/dist/types/src/internal/formats/number.d.ts +31 -0
  80. package/dist/types/src/internal/formats/number.d.ts.map +1 -0
  81. package/dist/types/src/internal/formats/object.d.ts +35 -0
  82. package/dist/types/src/internal/formats/object.d.ts.map +1 -0
  83. package/dist/types/src/internal/formats/select.d.ts +11 -0
  84. package/dist/types/src/internal/formats/select.d.ts.map +1 -0
  85. package/dist/types/src/internal/formats/string.d.ts +38 -0
  86. package/dist/types/src/internal/formats/string.d.ts.map +1 -0
  87. package/dist/types/src/internal/formats/types.d.ts +68 -0
  88. package/dist/types/src/internal/formats/types.d.ts.map +1 -0
  89. package/dist/types/src/internal/index.d.ts +11 -0
  90. package/dist/types/src/internal/index.d.ts.map +1 -0
  91. package/dist/types/src/internal/json-schema/annotations.d.ts +19 -0
  92. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  93. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts +2 -0
  94. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  95. package/dist/types/src/internal/json-schema/index.d.ts +5 -0
  96. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
  97. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
  98. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
  99. package/dist/types/src/internal/json-schema/json-schema-type.d.ts +250 -0
  100. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
  101. package/dist/types/src/internal/json-schema/json-schema.d.ts +29 -0
  102. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  103. package/dist/types/src/internal/json-schema/json-schema.test.d.ts +2 -0
  104. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  105. package/dist/types/src/internal/object/common.d.ts +18 -0
  106. package/dist/types/src/internal/object/common.d.ts.map +1 -0
  107. package/dist/types/src/internal/object/create-object.d.ts +39 -0
  108. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  109. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  110. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  111. package/dist/types/src/internal/object/deleted.d.ts +6 -0
  112. package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
  113. package/dist/types/src/internal/object/ids.d.ts +6 -0
  114. package/dist/types/src/internal/object/ids.d.ts.map +1 -0
  115. package/dist/types/src/internal/object/index.d.ts +8 -0
  116. package/dist/types/src/internal/object/index.d.ts.map +1 -0
  117. package/dist/types/src/internal/object/inspect.d.ts +2 -0
  118. package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
  119. package/dist/types/src/internal/object/json-serializer.d.ts +31 -0
  120. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
  121. package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
  122. package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
  123. package/dist/types/src/internal/object/schema-validator.d.ts +15 -0
  124. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
  125. package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
  126. package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
  127. package/dist/types/src/internal/object/typed-object.d.ts +31 -0
  128. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
  129. package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
  130. package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
  131. package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
  132. package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
  133. package/dist/types/src/internal/proxy/index.d.ts +3 -0
  134. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  135. package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
  136. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  137. package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
  138. package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
  139. package/dist/types/src/internal/proxy/typed-handler.d.ts +44 -0
  140. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
  141. package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
  142. package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
  143. package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
  144. package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
  145. package/dist/types/src/internal/ref/index.d.ts +3 -0
  146. package/dist/types/src/internal/ref/index.d.ts.map +1 -0
  147. package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
  148. package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
  149. package/dist/types/src/internal/ref/ref.d.ts +209 -0
  150. package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
  151. package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
  152. package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
  153. package/dist/types/src/internal/schema/compose.d.ts +6 -0
  154. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  155. package/dist/types/src/internal/schema/compose.test.d.ts +2 -0
  156. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  157. package/dist/types/src/internal/schema/echo-schema.d.ts +168 -0
  158. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
  159. package/dist/types/src/internal/schema/index.d.ts +6 -0
  160. package/dist/types/src/internal/schema/index.d.ts.map +1 -0
  161. package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
  162. package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
  163. package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
  164. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  165. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +18 -0
  166. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -0
  167. package/dist/types/src/internal/schema/snapshot.d.ts +6 -0
  168. package/dist/types/src/internal/schema/snapshot.d.ts.map +1 -0
  169. package/dist/types/src/internal/types/base.d.ts +37 -0
  170. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  171. package/dist/types/src/internal/types/entity.d.ts +12 -0
  172. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  173. package/dist/types/src/internal/types/index.d.ts +6 -0
  174. package/dist/types/src/internal/types/index.d.ts.map +1 -0
  175. package/dist/types/src/internal/types/meta.d.ts +40 -0
  176. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  177. package/dist/types/src/internal/types/typename.d.ts +13 -0
  178. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  179. package/dist/types/src/internal/types/version.d.ts +15 -0
  180. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  181. package/dist/types/src/query/filter.d.ts +167 -0
  182. package/dist/types/src/query/filter.d.ts.map +1 -0
  183. package/dist/types/src/query/index.d.ts +4 -1
  184. package/dist/types/src/query/index.d.ts.map +1 -1
  185. package/dist/types/src/query/order.d.ts +12 -0
  186. package/dist/types/src/query/order.d.ts.map +1 -0
  187. package/dist/types/src/query/query.d.ts +112 -0
  188. package/dist/types/src/query/query.d.ts.map +1 -0
  189. package/dist/types/src/query/query.test.d.ts +2 -0
  190. package/dist/types/src/query/query.test.d.ts.map +1 -0
  191. package/dist/types/src/query/testing.d.ts +51 -0
  192. package/dist/types/src/query/testing.d.ts.map +1 -0
  193. package/dist/types/src/query/types.d.ts +17 -0
  194. package/dist/types/src/query/types.d.ts.map +1 -0
  195. package/dist/types/src/query/util.d.ts +8 -0
  196. package/dist/types/src/query/util.d.ts.map +1 -0
  197. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  198. package/dist/types/src/testing/index.d.ts +3 -1
  199. package/dist/types/src/testing/index.d.ts.map +1 -1
  200. package/dist/types/src/testing/test-data.d.ts +18 -0
  201. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  202. package/dist/types/src/testing/test-schema.d.ts +337 -0
  203. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  204. package/dist/types/src/testing/util.d.ts +16 -0
  205. package/dist/types/src/testing/util.d.ts.map +1 -0
  206. package/dist/types/tsconfig.tsbuildinfo +1 -1
  207. package/package.json +49 -29
  208. package/src/Annotation.ts +17 -0
  209. package/src/Database.ts +189 -0
  210. package/src/Entity.ts +51 -0
  211. package/src/Format.ts +11 -0
  212. package/src/JsonSchema.ts +16 -0
  213. package/src/Key.ts +3 -0
  214. package/src/Obj.ts +353 -107
  215. package/src/Ref.ts +9 -10
  216. package/src/Relation.ts +68 -43
  217. package/src/Tag.ts +40 -0
  218. package/src/Type.ts +97 -85
  219. package/src/errors.ts +18 -0
  220. package/src/index.ts +13 -4
  221. package/src/internal/README.md +83 -0
  222. package/src/internal/annotations/annotations.test.ts +96 -0
  223. package/src/internal/annotations/annotations.ts +463 -0
  224. package/src/internal/annotations/index.ts +6 -0
  225. package/src/internal/annotations/util.ts +70 -0
  226. package/src/internal/entities/entity.ts +109 -0
  227. package/src/internal/entities/expando.ts +23 -0
  228. package/src/internal/entities/index.ts +9 -0
  229. package/src/internal/entities/model.ts +129 -0
  230. package/src/internal/entities/object.ts +45 -0
  231. package/src/internal/entities/relation.ts +155 -0
  232. package/src/internal/entities/util.ts +33 -0
  233. package/src/internal/formats/date.test.ts +56 -0
  234. package/src/internal/formats/date.ts +217 -0
  235. package/src/internal/formats/format.test.ts +77 -0
  236. package/src/internal/formats/format.ts +55 -0
  237. package/src/internal/formats/index.ts +12 -0
  238. package/src/internal/formats/number.ts +89 -0
  239. package/src/internal/formats/object.ts +80 -0
  240. package/src/internal/formats/select.ts +16 -0
  241. package/src/internal/formats/string.ts +76 -0
  242. package/src/internal/formats/types.ts +180 -0
  243. package/src/internal/index.ts +38 -0
  244. package/src/internal/json-schema/annotations.ts +50 -0
  245. package/src/internal/json-schema/effect-schema.test.ts +143 -0
  246. package/src/internal/json-schema/index.ts +8 -0
  247. package/src/internal/json-schema/json-schema-normalize.ts +109 -0
  248. package/src/internal/json-schema/json-schema-type.ts +404 -0
  249. package/src/internal/json-schema/json-schema.test.ts +859 -0
  250. package/src/internal/json-schema/json-schema.ts +528 -0
  251. package/src/internal/object/common.ts +75 -0
  252. package/src/internal/object/create-object.test.ts +116 -0
  253. package/src/internal/object/create-object.ts +95 -0
  254. package/src/internal/object/deleted.ts +19 -0
  255. package/src/internal/object/ids.ts +12 -0
  256. package/src/internal/object/index.ts +11 -0
  257. package/src/internal/object/inspect.ts +46 -0
  258. package/src/internal/object/json-serializer.test.ts +94 -0
  259. package/src/internal/object/json-serializer.ts +230 -0
  260. package/src/internal/object/schema-validator.test.ts +186 -0
  261. package/src/internal/object/schema-validator.ts +242 -0
  262. package/src/internal/object/typed-object.test.ts +34 -0
  263. package/src/internal/object/typed-object.ts +94 -0
  264. package/src/internal/proxy/handler.test.ts +173 -0
  265. package/src/internal/proxy/index.ts +6 -0
  266. package/src/internal/proxy/make-object.ts +113 -0
  267. package/src/internal/proxy/schema.test.ts +137 -0
  268. package/src/internal/proxy/typed-handler.test.ts +102 -0
  269. package/src/internal/proxy/typed-handler.ts +233 -0
  270. package/src/internal/proxy/typed-object.test.ts +105 -0
  271. package/src/internal/ref/index.ts +6 -0
  272. package/src/internal/ref/ref-array.ts +39 -0
  273. package/src/internal/ref/ref.test.ts +101 -0
  274. package/src/internal/ref/ref.ts +525 -0
  275. package/src/internal/schema/compose.test.ts +42 -0
  276. package/src/internal/schema/compose.ts +37 -0
  277. package/src/internal/schema/echo-schema.ts +385 -0
  278. package/src/internal/schema/index.ts +9 -0
  279. package/src/internal/schema/manipulation.ts +92 -0
  280. package/src/internal/schema/persistent-schema.ts +28 -0
  281. package/src/internal/schema/runtime-schema-registry.ts +78 -0
  282. package/src/internal/schema/snapshot.ts +25 -0
  283. package/src/internal/types/base.ts +58 -0
  284. package/src/internal/types/entity.ts +23 -0
  285. package/src/internal/types/index.ts +9 -0
  286. package/src/internal/types/meta.ts +76 -0
  287. package/src/internal/types/typename.ts +45 -0
  288. package/src/internal/types/version.ts +20 -0
  289. package/src/query/filter.ts +455 -0
  290. package/src/query/index.ts +5 -1
  291. package/src/query/order.ts +34 -0
  292. package/src/query/query.test.ts +334 -0
  293. package/src/query/query.ts +303 -0
  294. package/src/query/testing.ts +64 -0
  295. package/src/query/types.ts +23 -0
  296. package/src/query/util.ts +25 -0
  297. package/src/testing/api.test.ts +100 -0
  298. package/src/testing/index.ts +3 -1
  299. package/src/testing/test-data.ts +130 -0
  300. package/src/testing/test-schema.ts +213 -0
  301. package/src/testing/util.ts +78 -0
  302. package/dist/lib/browser/chunk-2KNTYMIW.mjs +0 -697
  303. package/dist/lib/browser/chunk-2KNTYMIW.mjs.map +0 -7
  304. package/dist/lib/node-esm/chunk-EXNNC62J.mjs +0 -697
  305. package/dist/lib/node-esm/chunk-EXNNC62J.mjs.map +0 -7
  306. package/dist/types/src/experimental/database.d.ts +0 -8
  307. package/dist/types/src/experimental/database.d.ts.map +0 -1
  308. package/dist/types/src/experimental/index.d.ts +0 -1
  309. package/dist/types/src/experimental/index.d.ts.map +0 -1
  310. package/dist/types/src/experimental/queue.d.ts +0 -8
  311. package/dist/types/src/experimental/queue.d.ts.map +0 -1
  312. package/dist/types/src/experimental/space.d.ts +0 -8
  313. package/dist/types/src/experimental/space.d.ts.map +0 -1
  314. package/dist/types/src/query/dsl.d.ts +0 -218
  315. package/dist/types/src/query/dsl.d.ts.map +0 -1
  316. package/dist/types/src/query/dsl.test.d.ts +0 -2
  317. package/dist/types/src/query/dsl.test.d.ts.map +0 -1
  318. package/dist/types/src/testing/types.d.ts +0 -113
  319. package/dist/types/src/testing/types.d.ts.map +0 -1
  320. package/src/experimental/database.ts +0 -11
  321. package/src/experimental/index.ts +0 -7
  322. package/src/experimental/queue.ts +0 -11
  323. package/src/experimental/space.ts +0 -11
  324. package/src/query/dsl.test.ts +0 -324
  325. package/src/query/dsl.ts +0 -646
  326. package/src/test/api.test.ts +0 -173
  327. package/src/testing/types.ts +0 -91
  328. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
package/src/Relation.ts CHANGED
@@ -2,44 +2,71 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
- import * as EchoSchema from '@dxos/echo-schema';
9
8
  import { assertArgument, invariant } from '@dxos/invariant';
10
- import { DXN } from '@dxos/keys';
11
- import { type Live, live } from '@dxos/live-object';
9
+ import { DXN, type ObjectId } from '@dxos/keys';
10
+ import { type Live } from '@dxos/live-object';
12
11
  import { assumeType } from '@dxos/util';
13
12
 
14
- import type * as Obj from './Obj';
15
- import type * as Type from './Type';
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';
30
+ import * as Obj from './Obj';
31
+ import * as Type from './Type';
16
32
 
17
33
  /**
18
- * NOTE: Don't export: Relation.Relation and Relation.Any form the public API.
34
+ * Base type for all ECHO relations.
35
+ * @private
19
36
  */
20
37
  interface BaseRelation<Source, Target>
21
- extends EchoSchema.HasId,
38
+ extends AnyEchoObject,
22
39
  Type.Relation.Endpoints<Source, Target>,
23
- Type.OfKind<EchoSchema.EntityKind.Relation> {}
40
+ Entity.OfKind<EntityKind.Relation> {}
24
41
 
25
42
  /**
26
- * Relation type with specific properties.
43
+ * Base type for all Relations objects.
27
44
  */
28
- export type Relation<Source extends Obj.Any, Target extends Obj.Any, Props> = BaseRelation<Source, Target> & Props;
45
+ export interface Any extends BaseRelation<Obj.Any, Obj.Any> {}
46
+
47
+ export const Any = Schema.Struct({}).pipe(
48
+ Type.Relation({
49
+ typename: 'dxos.org/type/Any',
50
+ version: '0.1.0',
51
+ source: Obj.Any,
52
+ target: Obj.Any,
53
+ }),
54
+ );
29
55
 
30
56
  /**
31
- * Base type for all ECHO relations.
57
+ * Relation type with specific source and target types.
32
58
  */
33
- export interface Any extends BaseRelation<Obj.Any, Obj.Any> {}
59
+ export type Relation<Source extends Obj.Any, Target extends Obj.Any, Props> = BaseRelation<Source, Target> & Props;
34
60
 
35
- // TODO(dmaretskyi): Has to be `unique symbol`.
36
- export const Source: unique symbol = EchoSchema.RelationSourceId as any;
61
+ export const Source: unique symbol = RelationSourceId as any;
37
62
  export type Source = typeof Source;
38
- export const Target: unique symbol = EchoSchema.RelationTargetId as any;
63
+
64
+ export const Target: unique symbol = RelationTargetId as any;
39
65
  export type Target = typeof Target;
40
66
 
41
67
  type MakeProps<T extends Any> = {
42
- id?: EchoSchema.ObjectId;
68
+ id?: ObjectId;
69
+ [MetaId]?: ObjectMeta;
43
70
  [Source]: T[Source];
44
71
  [Target]: T[Target];
45
72
  } & Type.Properties<T>;
@@ -56,36 +83,34 @@ type MakeProps<T extends Any> = {
56
83
  export const make = <S extends Type.Relation.Any>(
57
84
  schema: S,
58
85
  props: NoInfer<MakeProps<Schema.Schema.Type<S>>>,
59
- meta?: EchoSchema.ObjectMeta,
60
- ): Live<Schema.Schema.Type<S> & Type.OfKind<EchoSchema.EntityKind.Relation>> => {
61
- assertArgument(
62
- EchoSchema.getTypeAnnotation(schema)?.kind === EchoSchema.EntityKind.Relation,
63
- 'Expected a relation schema',
64
- );
65
-
66
- if (props[EchoSchema.MetaId] != null) {
67
- meta = props[EchoSchema.MetaId] as any;
68
- 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];
69
93
  }
70
94
 
71
- const sourceDXN = EchoSchema.getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
72
- const targetDXN = EchoSchema.getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
73
- (props as any)[EchoSchema.RelationSourceDXNId] = sourceDXN;
74
- (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;
75
100
 
76
- return live<Schema.Schema.Type<S>>(schema, props as any, meta);
101
+ return makeObject<Schema.Schema.Type<S>>(schema, props as any, meta);
77
102
  };
78
103
 
79
104
  export const isRelation = (value: unknown): value is Any => {
80
105
  if (typeof value !== 'object' || value === null) {
81
106
  return false;
82
107
  }
83
- 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) {
84
109
  return true;
85
110
  }
86
111
 
87
- const kind = (value as any)[EchoSchema.EntityKindId];
88
- return kind === EchoSchema.EntityKind.Relation;
112
+ const kind = (value as any)[Entity.KindId];
113
+ return kind === EntityKind.Relation;
89
114
  };
90
115
 
91
116
  /**
@@ -94,8 +119,8 @@ export const isRelation = (value: unknown): value is Any => {
94
119
  */
95
120
  export const getSourceDXN = (value: Any): DXN => {
96
121
  assertArgument(isRelation(value), 'Expected a relation');
97
- assumeType<EchoSchema.InternalObjectProps>(value);
98
- const dxn = (value as EchoSchema.InternalObjectProps)[EchoSchema.RelationSourceDXNId];
122
+ assumeType<InternalObjectProps>(value);
123
+ const dxn = (value as InternalObjectProps)[RelationSourceDXNId];
99
124
  invariant(dxn instanceof DXN);
100
125
  return dxn;
101
126
  };
@@ -106,8 +131,8 @@ export const getSourceDXN = (value: Any): DXN => {
106
131
  */
107
132
  export const getTargetDXN = (value: Any): DXN => {
108
133
  assertArgument(isRelation(value), 'Expected a relation');
109
- assumeType<EchoSchema.InternalObjectProps>(value);
110
- const dxn = (value as EchoSchema.InternalObjectProps)[EchoSchema.RelationTargetDXNId];
134
+ assumeType<InternalObjectProps>(value);
135
+ const dxn = (value as InternalObjectProps)[RelationTargetDXNId];
111
136
  invariant(dxn instanceof DXN);
112
137
  return dxn;
113
138
  };
@@ -118,8 +143,8 @@ export const getTargetDXN = (value: Any): DXN => {
118
143
  */
119
144
  export const getSource = <T extends Any>(relation: T): Type.Relation.Source<T> => {
120
145
  assertArgument(isRelation(relation), 'Expected a relation');
121
- assumeType<EchoSchema.InternalObjectProps>(relation);
122
- const obj = (relation as EchoSchema.InternalObjectProps)[EchoSchema.RelationSourceId];
146
+ assumeType<InternalObjectProps>(relation);
147
+ const obj = (relation as InternalObjectProps)[RelationSourceId];
123
148
  invariant(obj !== undefined, `Invalid source: ${relation.id}`);
124
149
  return obj as Type.Relation.Source<T>;
125
150
  };
@@ -130,8 +155,8 @@ export const getSource = <T extends Any>(relation: T): Type.Relation.Source<T> =
130
155
  */
131
156
  export const getTarget = <T extends Any>(relation: T): Type.Relation.Target<T> => {
132
157
  assertArgument(isRelation(relation), 'Expected a relation');
133
- assumeType<EchoSchema.InternalObjectProps>(relation);
134
- const obj = (relation as EchoSchema.InternalObjectProps)[EchoSchema.RelationTargetId];
158
+ assumeType<InternalObjectProps>(relation);
159
+ const obj = (relation as InternalObjectProps)[RelationTargetId];
135
160
  invariant(obj !== undefined, `Invalid target: ${relation.id}`);
136
161
  return obj as Type.Relation.Target<T>;
137
162
  };
package/src/Tag.ts ADDED
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { LabelAnnotation, SystemTypeAnnotation } from './internal';
8
+ import * as Obj from './Obj';
9
+ import * as Type from './Type';
10
+
11
+ export const Tag = Schema.Struct({
12
+ label: Schema.String,
13
+ hue: Schema.optional(Schema.String), // TODO(burdon): Color name?
14
+ }).pipe(
15
+ Type.Obj({
16
+ typename: 'dxos.org/type/Tag',
17
+ version: '0.1.0',
18
+ }),
19
+ LabelAnnotation.set(['label']),
20
+ SystemTypeAnnotation.set(true),
21
+ );
22
+
23
+ export type Tag = Schema.Schema.Type<typeof Tag>;
24
+
25
+ export const make = (props: Obj.MakeProps<typeof Tag>) => Obj.make(Tag, props);
26
+
27
+ // TODO(burdon): Rename Map.
28
+ export type Map = Record<string, Tag>;
29
+
30
+ export const sortTags = ({ label: a }: Tag, { label: b }: Tag) => a.localeCompare(b);
31
+
32
+ export const createTagList = (tags: Map): Tag[] =>
33
+ Object.entries(tags)
34
+ .map(([id, tag]) => ({ ...tag, id }))
35
+ .sort(sortTags);
36
+
37
+ export const findTagByLabel = (tags: Map | undefined, name: string): Tag | undefined => {
38
+ const entry = Object.entries(tags ?? {}).find(([_, tag]) => tag.label.toLowerCase() === name.toLowerCase());
39
+ return entry ? { ...entry[1], id: entry[0] } : undefined;
40
+ };
package/src/Type.ts CHANGED
@@ -2,45 +2,59 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
6
- import { type Simplify } from 'effect/Schema';
5
+ import type * as Schema$ from 'effect/Schema';
7
6
 
8
7
  import { type EncodedReference } from '@dxos/echo-protocol';
9
- import * as EchoSchema from '@dxos/echo-schema';
10
- import { type ToMutable } from '@dxos/echo-schema';
11
8
  import { invariant } from '@dxos/invariant';
12
- 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 };
13
41
 
14
- 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>;
15
46
 
16
47
  //
17
- // Kind
48
+ // Entity
18
49
  //
19
50
 
20
- export const KindId: unique symbol = EchoSchema.EntityKindId as any;
21
- export type KindId = typeof KindId;
22
-
23
- export const Kind = EchoSchema.EntityKind;
24
-
25
- /**
26
- * Assigns a kind to an Object or Relation instance.
27
- */
28
- // NOTE: Needed to make `isRelation` and `isObject` checks work.
29
- export interface OfKind<Kind extends EchoSchema.EntityKind> {
30
- readonly id: Keys.ObjectId;
31
- readonly [KindId]: Kind;
51
+ export namespace Entity {
52
+ /**
53
+ * Type.Obj.Any | Type.Relation.Any.
54
+ */
55
+ export type Any = Obj.Any | Relation.Any;
32
56
  }
33
57
 
34
- /**
35
- * Base ECHO schema type.
36
- */
37
- export type Schema = EchoSchema.EchoSchema;
38
-
39
- /**
40
- * Returns all properties of an object or relation except for the id and kind.
41
- */
42
- export type Properties<T = any> = Omit<T, 'id' | KindId | RelationModule.Source | RelationModule.Target>;
43
-
44
58
  //
45
59
  // Obj
46
60
  //
@@ -55,47 +69,50 @@ interface ObjJsonProps {
55
69
  * This typedef avoids `TS4023` error (name from external module cannot be used named).
56
70
  * See Effect's note on interface types.
57
71
  */
58
- export interface obj<Self extends Schema.Schema.Any>
59
- extends EchoSchema.TypeMeta,
60
- Schema.AnnotableClass<
72
+ export interface obj<Self extends Schema$.Schema.Any>
73
+ extends TypeMeta,
74
+ Schema$.AnnotableClass<
61
75
  obj<Self>,
62
- OfKind<EchoSchema.EntityKind.Object> & ToMutable<Schema.Schema.Type<Self>>,
63
- Simplify<ObjJsonProps & ToMutable<Schema.Schema.Encoded<Self>>>,
64
- Schema.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>
65
79
  > {}
66
80
 
67
81
  /**
68
82
  * Object schema.
69
83
  */
70
84
  export const Obj: {
71
- (opts: EchoSchema.TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => obj<Self>;
72
- } = EchoSchema.EchoObject as any;
85
+ (opts: TypeMeta): <Self extends Schema$.Schema.Any>(self: Self) => obj<Self>;
86
+ } = EchoObjectSchema as any;
73
87
 
74
88
  /**
75
89
  * Object schema type definitions.
76
90
  */
77
- export namespace Obj {
91
+ export declare namespace Obj {
78
92
  /**
79
93
  * Type that represents an arbitrary schema type of an object.
80
94
  * NOTE: This is not an instance type.
81
95
  */
82
96
  // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
83
97
  // TODO(burdon): This erases the ECHO type info (e.g., id, typename).
84
- export type Any = Schema.Schema.AnyNoContext;
98
+ export type Any = obj<Schema$.Schema.AnyNoContext>;
85
99
  }
86
100
 
87
101
  //
88
102
  // Expando
89
103
  //
90
104
 
91
- // TODO(burdon): We're using Expando in many places as a base type.
92
- export interface Expando extends OfKind<EchoSchema.EntityKind.Object> {
93
- [key: string]: any;
94
- }
105
+ export const Expando: obj<Schema$.Schema<Expando$, ExpandoEncoded>> = Expando$ as any;
106
+ export type Expando = obj<Schema$.Schema<Expando$, ExpandoEncoded>>;
95
107
 
96
- type ExpandoEncoded = 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>>;
97
114
 
98
- export const Expando: Schema.Schema<Expando, ExpandoEncoded, never> = EchoSchema.Expando as any;
115
+ export { EchoSchema as RuntimeType };
99
116
 
100
117
  //
101
118
  // Relation
@@ -103,8 +120,8 @@ export const Expando: Schema.Schema<Expando, ExpandoEncoded, never> = EchoSchema
103
120
 
104
121
  interface RelationJsonProps {
105
122
  id: string;
106
- [EchoSchema.ATTR_RELATION_SOURCE]: string;
107
- [EchoSchema.ATTR_RELATION_TARGET]: string;
123
+ [ATTR_RELATION_SOURCE]: string;
124
+ [ATTR_RELATION_TARGET]: string;
108
125
  }
109
126
 
110
127
  /**
@@ -114,28 +131,29 @@ interface RelationJsonProps {
114
131
  * See Effect's note on interface types.
115
132
  */
116
133
  export interface relation<
117
- Self extends Schema.Schema.Any,
118
- SourceSchema extends Schema.Schema.Any,
119
- TargetSchema extends Schema.Schema.Any,
120
- > extends EchoSchema.TypeMeta,
121
- Schema.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<
122
139
  relation<Self, SourceSchema, TargetSchema>,
123
- OfKind<EchoSchema.EntityKind.Relation> &
124
- Relation.Endpoints<Schema.Schema.Type<SourceSchema>, Schema.Schema.Type<TargetSchema>> &
125
- ToMutable<Schema.Schema.Type<Self>>,
126
- Simplify<RelationJsonProps & ToMutable<Schema.Schema.Encoded<Self>>>,
127
- Schema.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>
128
145
  > {}
129
146
 
130
147
  /**
131
148
  * Relation schema.
132
149
  */
133
150
  // TODO(dmaretskyi): I have to redefine the type here so that the definition uses symbols from @dxos/echo/Relation.
151
+ // TODO(burdon): Remove?
134
152
  export const Relation: {
135
- <Source extends Schema.Schema.AnyNoContext, Target extends Schema.Schema.AnyNoContext>(
136
- opts: EchoSchema.EchoRelationOptions<Source, Target>,
137
- ): <Self extends Schema.Schema.Any>(self: Self) => relation<Self, Source, Target>;
138
- } = 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;
139
157
 
140
158
  /**
141
159
  * Relation schema type definitions.
@@ -146,7 +164,7 @@ export namespace Relation {
146
164
  * NOTE: This is not an instance type.
147
165
  */
148
166
  // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.
149
- export type Any = Schema.Schema.AnyNoContext;
167
+ export type Any = Schema$.Schema.AnyNoContext;
150
168
 
151
169
  /**
152
170
  * Get relation source type.
@@ -159,13 +177,14 @@ export namespace Relation {
159
177
  export type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;
160
178
 
161
179
  export type Endpoints<Source, Target> = {
162
- [RelationModule.Source]: Source;
163
- [RelationModule.Target]: Target;
180
+ [Relation$.Source]: Source;
181
+ [Relation$.Target]: Target;
164
182
  };
165
183
  }
166
184
 
167
185
  //
168
186
  // Ref
187
+ // TODO(burdon): Reconcile Type.Ref with Ref.Ref.
169
188
  //
170
189
 
171
190
  /**
@@ -174,23 +193,21 @@ export namespace Relation {
174
193
  * This typedef avoids `TS4023` error (name from external module cannot be used named).
175
194
  * See Effect's note on interface types.
176
195
  */
177
- export interface ref<TargetSchema extends Schema.Schema.Any>
178
- extends EchoSchema.Ref$<Schema.Schema.Type<TargetSchema>> {}
196
+ export interface ref<TargetSchema extends Schema$.Schema.Any> extends RefSchema<Schema$.Schema.Type<TargetSchema>> {}
179
197
 
180
198
  /**
181
199
  * Ref schema.
182
200
  */
183
- export const Ref: <S extends Obj.Any>(schema: S) => ref<S> = EchoSchema.Ref;
201
+ export const Ref: RefFn = Ref$;
184
202
 
185
- export interface Ref<T> extends Schema.SchemaClass<EchoSchema.Ref<T>, EncodedReference> {}
203
+ export interface Ref<T> extends Schema$.SchemaClass<Ref$<T>, EncodedReference> {}
186
204
 
187
- // TODO(buurdon): Move to Ref?
188
205
  export namespace Ref {
189
206
  /**
190
207
  * Type that represents an arbitrary schema type of a reference.
191
208
  * NOTE: This is not an instance type.
192
209
  */
193
- export type Any = Schema.Schema<EchoSchema.Ref<any>, EncodedReference>;
210
+ export type Any = Schema$.Schema<Ref$<any>, EncodedReference>;
194
211
  }
195
212
 
196
213
  /**
@@ -199,16 +216,16 @@ export namespace Ref {
199
216
  * @example "dxn:example.com/type/Person:0.1.0"
200
217
  * @example "dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX"
201
218
  */
202
- export const getDXN = (schema: Obj.Any | Relation.Any): Keys.DXN | undefined => {
203
- return EchoSchema.getSchemaDXN(schema);
219
+ export const getDXN = (schema: Entity.Any): DXN | undefined => {
220
+ return getSchemaDXN(schema);
204
221
  };
205
222
 
206
223
  /**
207
224
  * @param schema - Schema to get the typename from.
208
225
  * @returns The typename of the schema. Example: `example.com/type/Person`.
209
226
  */
210
- export const getTypename = (schema: Obj.Any | Relation.Any): string => {
211
- const typename = EchoSchema.getSchemaTypename(schema);
227
+ export const getTypename = (schema: Entity.Any): string => {
228
+ const typename = getSchemaTypename(schema);
212
229
  invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');
213
230
  return typename;
214
231
  };
@@ -217,8 +234,8 @@ export const getTypename = (schema: Obj.Any | Relation.Any): string => {
217
234
  * Gets the version of the schema.
218
235
  * @example 0.1.0
219
236
  */
220
- export const getVersion = (schema: Obj.Any | Relation.Any): string => {
221
- const version = EchoSchema.getSchemaVersion(schema);
237
+ export const getVersion = (schema: Entity.Any): string => {
238
+ const version = getSchemaVersion(schema);
222
239
  invariant(typeof version === 'string' && version.match(/^\d+\.\d+\.\d+$/), 'Invalid version');
223
240
  return version;
224
241
  };
@@ -226,21 +243,16 @@ export const getVersion = (schema: Obj.Any | Relation.Any): string => {
226
243
  /**
227
244
  * @returns True if the schema is mutable.
228
245
  */
229
- export const isMutable = EchoSchema.isMutable;
246
+ export const isMutable = isMutable$;
230
247
 
231
248
  /**
232
249
  * ECHO type metadata.
233
250
  */
234
- export type Meta = EchoSchema.TypeAnnotation;
251
+ export type Meta = TypeAnnotation;
235
252
 
236
253
  /**
237
254
  * Gets the meta data of the schema.
238
255
  */
239
- export const getMeta = (schema: Obj.Any | Relation.Any): Meta | undefined => {
240
- return EchoSchema.getTypeAnnotation(schema);
256
+ export const getMeta = (schema: Entity.Any): Meta | undefined => {
257
+ return getTypeAnnotation(schema);
241
258
  };
242
-
243
- // TODO(dmaretskyi): Remove re-exports.
244
- export { SpaceId, ObjectId, DXN } from '@dxos/keys';
245
-
246
- export { Format, JsonSchemaType as JsonSchema, toEffectSchema, toJsonSchema } from '@dxos/echo-schema';
package/src/errors.ts ADDED
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { BaseError, type BaseErrorOptions } from '@dxos/errors';
6
+ import { type DXN } from '@dxos/keys';
7
+
8
+ export class SchemaNotFoundError extends BaseError.extend('SCHEMA_NOT_FOUND', 'Schema not found') {
9
+ constructor(schema: string, options?: BaseErrorOptions) {
10
+ super({ context: { schema }, ...options });
11
+ }
12
+ }
13
+
14
+ export class ObjectNotFoundError extends BaseError.extend('OBJECT_NOT_FOUND', 'Object not found') {
15
+ constructor(dxn: DXN, options?: BaseErrorOptions) {
16
+ super({ context: { dxn }, ...options });
17
+ }
18
+ }
package/src/index.ts CHANGED
@@ -2,12 +2,21 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ export { DXN } from '@dxos/keys';
6
+
7
+ export * from './errors';
8
+
9
+ // TODO(burdon): Separate namesapces for Query (Query.Query, Query.Filter, etc.)
10
+ export * from './query';
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';
5
17
  export * as Key from './Key';
6
18
  export * as Obj from './Obj';
7
19
  export * as Ref from './Ref';
8
20
  export * as Relation from './Relation';
21
+ export * as Tag from './Tag';
9
22
  export * as Type from './Type';
10
-
11
- export { DXN } from '@dxos/keys';
12
- export { Filter, Query } from './query';
13
- 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?)