@dxos/echo 0.8.4-main.40e3dcdf1b → 0.8.4-main.43cb759274

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 (428) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +7 -7
  3. package/dist/lib/neutral/Annotation.mjs +29 -6
  4. package/dist/lib/neutral/Database.mjs +8 -9
  5. package/dist/lib/neutral/Entity.mjs +29 -18
  6. package/dist/lib/neutral/Err.mjs +3 -3
  7. package/dist/lib/neutral/Feed.mjs +27 -19
  8. package/dist/lib/neutral/Filter.mjs +25 -15
  9. package/dist/lib/neutral/Format.mjs +23 -3
  10. package/dist/lib/neutral/JsonSchema.mjs +7 -8
  11. package/dist/lib/neutral/Key.mjs +9 -5
  12. package/dist/lib/neutral/Migration.mjs +18 -0
  13. package/dist/lib/neutral/Obj.mjs +25 -19
  14. package/dist/lib/neutral/Order.mjs +1 -1
  15. package/dist/lib/neutral/Query.mjs +19 -16
  16. package/dist/lib/neutral/QueryResult.mjs +1 -1
  17. package/dist/lib/neutral/Ref.mjs +10 -9
  18. package/dist/lib/neutral/Registry.mjs +14 -0
  19. package/dist/lib/neutral/Registry.mjs.map +7 -0
  20. package/dist/lib/neutral/Relation.mjs +26 -24
  21. package/dist/lib/neutral/Scope.mjs +12 -0
  22. package/dist/lib/neutral/Scope.mjs.map +7 -0
  23. package/dist/lib/neutral/Tag.mjs +17 -13
  24. package/dist/lib/neutral/Type.mjs +52 -26
  25. package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
  26. package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
  27. package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
  28. package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
  29. package/dist/lib/neutral/{chunk-CIRHIEMW.mjs → chunk-4SFPZJVA.mjs} +92 -112
  30. package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
  31. package/dist/lib/neutral/{chunk-YWXWXIE5.mjs → chunk-4Z6GET2X.mjs} +3 -3
  32. package/dist/lib/neutral/chunk-4Z6GET2X.mjs.map +7 -0
  33. package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
  34. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  35. package/dist/lib/neutral/{chunk-43Y5DOS6.mjs → chunk-7OAFN3OX.mjs} +75 -112
  36. package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
  37. package/dist/lib/neutral/{chunk-BOZZPUXE.mjs → chunk-7PRCIDHH.mjs} +41 -81
  38. package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
  39. package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
  40. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-BDQGMDIX.mjs +132 -0
  42. package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
  44. package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
  45. package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-DKLUHO4T.mjs} +1 -1
  46. package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
  47. package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
  48. package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
  49. package/dist/lib/neutral/{chunk-UTBRYVQC.mjs → chunk-G6CFWUYH.mjs} +2 -2
  50. package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
  51. package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
  52. package/dist/lib/neutral/{chunk-FXEG7EOK.mjs → chunk-J3MNM65T.mjs} +9 -6
  53. package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
  54. package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
  55. package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
  56. package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
  57. package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
  58. package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
  59. package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
  60. package/dist/lib/neutral/{chunk-WYOKA6AE.mjs → chunk-O6BH7EPN.mjs} +31 -4
  61. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  62. package/dist/lib/neutral/{chunk-KTAWP7GI.mjs → chunk-OIYW7R2G.mjs} +99 -46
  63. package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
  64. package/dist/lib/neutral/{chunk-TQQZLKB7.mjs → chunk-OYUG4FHF.mjs} +648 -1228
  65. package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
  66. package/dist/lib/neutral/{chunk-NQRLRYJM.mjs → chunk-Q5FKCVBC.mjs} +173 -60
  67. package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
  68. package/dist/lib/neutral/chunk-Q62IHV2N.mjs +41 -0
  69. package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
  70. package/dist/lib/neutral/{chunk-UFDK26FO.mjs → chunk-QVJDDG44.mjs} +69 -34
  71. package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
  72. package/dist/lib/neutral/{chunk-B5OXLWZL.mjs → chunk-TFEWTY5A.mjs} +155 -129
  73. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  74. package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-TTCSATUD.mjs} +1 -1
  75. package/dist/lib/neutral/{chunk-FZO7LQO7.mjs → chunk-VKWOFXT2.mjs} +22 -2
  76. package/dist/lib/neutral/{chunk-FZO7LQO7.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
  77. package/dist/lib/neutral/{chunk-NXMFBIT5.mjs → chunk-ZACMEAYV.mjs} +89 -23
  78. package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
  79. package/dist/lib/neutral/index.mjs +58 -38
  80. package/dist/lib/neutral/internal/index.mjs +131 -64
  81. package/dist/lib/neutral/meta.json +1 -1
  82. package/dist/lib/neutral/testing/index.mjs +222 -177
  83. package/dist/lib/neutral/testing/index.mjs.map +3 -3
  84. package/dist/types/src/Annotation.d.ts +108 -4
  85. package/dist/types/src/Annotation.d.ts.map +1 -1
  86. package/dist/types/src/Annotation.test.d.ts +2 -0
  87. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  88. package/dist/types/src/Collection.d.ts +2 -3
  89. package/dist/types/src/Collection.d.ts.map +1 -1
  90. package/dist/types/src/Database.d.ts +56 -24
  91. package/dist/types/src/Database.d.ts.map +1 -1
  92. package/dist/types/src/Dataset.d.ts +17 -6
  93. package/dist/types/src/Dataset.d.ts.map +1 -1
  94. package/dist/types/src/Entity.d.ts +102 -26
  95. package/dist/types/src/Entity.d.ts.map +1 -1
  96. package/dist/types/src/Err.d.ts +27 -27
  97. package/dist/types/src/Err.d.ts.map +1 -1
  98. package/dist/types/src/Feed.d.ts +89 -25
  99. package/dist/types/src/Feed.d.ts.map +1 -1
  100. package/dist/types/src/Filter.d.ts +74 -11
  101. package/dist/types/src/Filter.d.ts.map +1 -1
  102. package/dist/types/src/Filter.test.d.ts +2 -0
  103. package/dist/types/src/Filter.test.d.ts.map +1 -0
  104. package/dist/types/src/Hypergraph.d.ts +14 -9
  105. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  106. package/dist/types/src/Json.d.ts +33 -0
  107. package/dist/types/src/Json.d.ts.map +1 -0
  108. package/dist/types/src/Json.test.d.ts +2 -0
  109. package/dist/types/src/Json.test.d.ts.map +1 -0
  110. package/dist/types/src/JsonSchema.d.ts +2 -2
  111. package/dist/types/src/JsonSchema.d.ts.map +1 -1
  112. package/dist/types/src/Key.d.ts +1 -1
  113. package/dist/types/src/Key.d.ts.map +1 -1
  114. package/dist/types/src/Migration.d.ts +72 -0
  115. package/dist/types/src/Migration.d.ts.map +1 -0
  116. package/dist/types/src/Obj.d.ts +108 -65
  117. package/dist/types/src/Obj.d.ts.map +1 -1
  118. package/dist/types/src/Order.d.ts.map +1 -1
  119. package/dist/types/src/Query.d.ts +35 -10
  120. package/dist/types/src/Query.d.ts.map +1 -1
  121. package/dist/types/src/QueryResult.d.ts +9 -0
  122. package/dist/types/src/QueryResult.d.ts.map +1 -1
  123. package/dist/types/src/Ref.d.ts +15 -7
  124. package/dist/types/src/Ref.d.ts.map +1 -1
  125. package/dist/types/src/Registry.d.ts +131 -0
  126. package/dist/types/src/Registry.d.ts.map +1 -0
  127. package/dist/types/src/Relation.d.ts +72 -44
  128. package/dist/types/src/Relation.d.ts.map +1 -1
  129. package/dist/types/src/Scope.d.ts +34 -0
  130. package/dist/types/src/Scope.d.ts.map +1 -0
  131. package/dist/types/src/StateMap.d.ts +32 -0
  132. package/dist/types/src/StateMap.d.ts.map +1 -0
  133. package/dist/types/src/StateMap.test.d.ts +2 -0
  134. package/dist/types/src/StateMap.test.d.ts.map +1 -0
  135. package/dist/types/src/Tag.d.ts +21 -5
  136. package/dist/types/src/Tag.d.ts.map +1 -1
  137. package/dist/types/src/TagIndex.d.ts +36 -0
  138. package/dist/types/src/TagIndex.d.ts.map +1 -0
  139. package/dist/types/src/TagIndex.test.d.ts +2 -0
  140. package/dist/types/src/TagIndex.test.d.ts.map +1 -0
  141. package/dist/types/src/Tagging.d.ts +31 -0
  142. package/dist/types/src/Tagging.d.ts.map +1 -0
  143. package/dist/types/src/Type.d.ts +357 -96
  144. package/dist/types/src/Type.d.ts.map +1 -1
  145. package/dist/types/src/View.d.ts +2 -5
  146. package/dist/types/src/View.d.ts.map +1 -1
  147. package/dist/types/src/exemplars.test.d.ts +2 -0
  148. package/dist/types/src/exemplars.test.d.ts.map +1 -0
  149. package/dist/types/src/index.d.ts +8 -2
  150. package/dist/types/src/index.d.ts.map +1 -1
  151. package/dist/types/src/internal/Annotation/annotations.d.ts +79 -37
  152. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  153. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  154. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  155. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  156. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  157. package/dist/types/src/internal/Annotation/index.d.ts +4 -2
  158. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
  159. package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
  160. package/dist/types/src/internal/Annotation/util.d.ts +14 -5
  161. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
  162. package/dist/types/src/internal/Entity/api.d.ts +3 -3
  163. package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
  164. package/dist/types/src/internal/Entity/entity.d.ts +72 -8
  165. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
  166. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  167. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  168. package/dist/types/src/internal/Entity/index.d.ts +2 -0
  169. package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
  170. package/dist/types/src/internal/Entity/model.d.ts +20 -17
  171. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  172. package/dist/types/src/internal/Entity/object.d.ts +3 -3
  173. package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
  174. package/dist/types/src/internal/Entity/relation.d.ts +30 -7
  175. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
  176. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  177. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  178. package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
  179. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  180. package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
  181. package/dist/types/src/internal/Format/date.d.ts.map +1 -1
  182. package/dist/types/src/internal/Format/format.d.ts +3 -2
  183. package/dist/types/src/internal/Format/format.d.ts.map +1 -1
  184. package/dist/types/src/internal/Format/index.d.ts +2 -2
  185. package/dist/types/src/internal/Format/index.d.ts.map +1 -1
  186. package/dist/types/src/internal/Format/number.d.ts.map +1 -1
  187. package/dist/types/src/internal/Format/object.d.ts +3 -1
  188. package/dist/types/src/internal/Format/object.d.ts.map +1 -1
  189. package/dist/types/src/internal/Format/types.d.ts.map +1 -1
  190. package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
  191. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +28 -28
  192. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
  193. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
  194. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  195. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
  196. package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
  197. package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
  198. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
  199. package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
  200. package/dist/types/src/internal/Obj/index.d.ts +0 -1
  201. package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
  202. package/dist/types/src/internal/Obj/json-serializer.d.ts +11 -10
  203. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  204. package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
  205. package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
  206. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
  207. package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
  208. package/dist/types/src/internal/Query.d.ts +10 -0
  209. package/dist/types/src/internal/Query.d.ts.map +1 -0
  210. package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
  211. package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -1
  212. package/dist/types/src/internal/Ref/ref.d.ts +42 -19
  213. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  214. package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
  215. package/dist/types/src/internal/Type/index.d.ts +1 -2
  216. package/dist/types/src/internal/Type/index.d.ts.map +1 -1
  217. package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
  218. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
  219. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  220. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  221. package/dist/types/src/internal/common/api/meta.d.ts +14 -11
  222. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
  223. package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
  224. package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
  225. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
  226. package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
  227. package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
  228. package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
  229. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
  230. package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
  231. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  232. package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
  233. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
  234. package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
  235. package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
  236. package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
  237. package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
  238. package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
  239. package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
  240. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
  241. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  242. package/dist/types/src/internal/common/types/base.d.ts +4 -4
  243. package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
  244. package/dist/types/src/internal/common/types/entity.d.ts +63 -6
  245. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
  246. package/dist/types/src/internal/common/types/index.d.ts +1 -1
  247. package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
  248. package/dist/types/src/internal/common/types/meta.d.ts +23 -7
  249. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
  250. package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
  251. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
  252. package/dist/types/src/internal/common/types/typename.d.ts +7 -0
  253. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
  254. package/dist/types/src/internal/common/types/version.d.ts +1 -1
  255. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  256. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  257. package/dist/types/src/internal/index.d.ts +2 -0
  258. package/dist/types/src/internal/index.d.ts.map +1 -1
  259. package/dist/types/src/testing/test-data.d.ts +8 -8
  260. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  261. package/dist/types/src/testing/test-schema.d.ts +83 -89
  262. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  263. package/dist/types/src/testing/util.d.ts +5 -3
  264. package/dist/types/src/testing/util.d.ts.map +1 -1
  265. package/dist/types/tsconfig.tsbuildinfo +1 -1
  266. package/package.json +27 -19
  267. package/src/Annotation.test.ts +439 -0
  268. package/src/Annotation.ts +152 -4
  269. package/src/Collection.ts +6 -5
  270. package/src/Database.ts +117 -57
  271. package/src/Dataset.ts +10 -2
  272. package/src/Entity.test.ts +116 -6
  273. package/src/Entity.ts +130 -31
  274. package/src/Err.ts +4 -4
  275. package/src/Feed.ts +138 -43
  276. package/src/Filter.test.ts +90 -0
  277. package/src/Filter.ts +143 -27
  278. package/src/Hypergraph.ts +14 -9
  279. package/src/Json.test.ts +175 -0
  280. package/src/Json.ts +103 -0
  281. package/src/Key.ts +1 -1
  282. package/src/Migration.ts +114 -0
  283. package/src/Obj.test.ts +122 -19
  284. package/src/Obj.ts +279 -97
  285. package/src/Query.test.ts +317 -131
  286. package/src/Query.ts +181 -73
  287. package/src/QueryResult.ts +11 -0
  288. package/src/Ref.ts +22 -4
  289. package/src/Registry.ts +155 -0
  290. package/src/Relation.test.ts +10 -10
  291. package/src/Relation.ts +112 -71
  292. package/src/Scope.ts +50 -0
  293. package/src/StateMap.test.ts +56 -0
  294. package/src/StateMap.ts +99 -0
  295. package/src/Tag.md +88 -0
  296. package/src/Tag.ts +49 -6
  297. package/src/TagIndex.test.ts +57 -0
  298. package/src/TagIndex.ts +110 -0
  299. package/src/Tagging.ts +83 -0
  300. package/src/Type.test.ts +223 -18
  301. package/src/Type.ts +602 -132
  302. package/src/View.ts +11 -15
  303. package/src/exemplars.test.ts +21 -0
  304. package/src/index.ts +9 -3
  305. package/src/internal/Annotation/annotations.test.ts +82 -13
  306. package/src/internal/Annotation/annotations.ts +153 -115
  307. package/src/internal/Annotation/dictionary.ts +47 -0
  308. package/src/internal/Annotation/entity-dictionary.ts +40 -0
  309. package/src/internal/Annotation/index.ts +4 -2
  310. package/src/internal/Annotation/sorting.ts +0 -1
  311. package/src/internal/Annotation/util.ts +17 -8
  312. package/src/internal/Entity/api.ts +7 -8
  313. package/src/internal/Entity/entity.ts +196 -47
  314. package/src/internal/Entity/guard.ts +26 -0
  315. package/src/internal/Entity/index.ts +2 -0
  316. package/src/internal/Entity/model.ts +37 -28
  317. package/src/internal/Entity/object.ts +21 -6
  318. package/src/internal/Entity/relation.ts +68 -34
  319. package/src/internal/Entity/type-kind.ts +75 -0
  320. package/src/internal/Entity/type-uri.ts +87 -0
  321. package/src/internal/Entity/util.ts +10 -9
  322. package/src/internal/Entity/version.ts +0 -1
  323. package/src/internal/Format/date.test.ts +0 -1
  324. package/src/internal/Format/date.ts +0 -4
  325. package/src/internal/Format/format.test.ts +21 -1
  326. package/src/internal/Format/index.ts +2 -3
  327. package/src/internal/Format/object.ts +21 -4
  328. package/src/internal/Format/types.ts +1 -1
  329. package/src/internal/JsonSchema/annotations.ts +1 -1
  330. package/src/internal/JsonSchema/json-schema-type.ts +1 -1
  331. package/src/internal/JsonSchema/json-schema.test.ts +55 -142
  332. package/src/internal/JsonSchema/json-schema.ts +44 -31
  333. package/src/internal/Obj/clone.ts +9 -4
  334. package/src/internal/Obj/create-object.test.ts +13 -13
  335. package/src/internal/Obj/create-object.ts +68 -24
  336. package/src/internal/Obj/deleted.ts +1 -1
  337. package/src/internal/Obj/index.ts +0 -1
  338. package/src/internal/Obj/inspect.ts +4 -3
  339. package/src/internal/Obj/json-serializer.test.ts +102 -24
  340. package/src/internal/Obj/json-serializer.ts +105 -43
  341. package/src/internal/Obj/set-value.test.ts +31 -54
  342. package/src/internal/Obj/set-value.ts +1 -1
  343. package/src/internal/Obj/snapshot.ts +11 -4
  344. package/src/internal/Obj/typed-object.test.ts +9 -11
  345. package/src/internal/Obj/typed-object.ts +1 -1
  346. package/src/internal/Query.ts +159 -0
  347. package/src/internal/Ref/ref-array.ts +3 -4
  348. package/src/internal/Ref/ref.test.ts +17 -27
  349. package/src/internal/Ref/ref.ts +124 -59
  350. package/src/internal/Type/compose.test.ts +3 -2
  351. package/src/internal/Type/index.ts +1 -2
  352. package/src/internal/Type/manipulation.ts +0 -25
  353. package/src/internal/Type/type-schema.ts +60 -0
  354. package/src/internal/common/README.md +2 -2
  355. package/src/internal/common/api/meta.ts +19 -17
  356. package/src/internal/common/proxy/change-context.ts +1 -1
  357. package/src/internal/common/proxy/change.test.ts +118 -110
  358. package/src/internal/common/proxy/errors.ts +2 -2
  359. package/src/internal/common/proxy/handler.test.ts +1 -3
  360. package/src/internal/common/proxy/json-serializer.ts +26 -16
  361. package/src/internal/common/proxy/make-object.ts +43 -21
  362. package/src/internal/common/proxy/ownership.ts +2 -3
  363. package/src/internal/common/proxy/reactive-array.ts +1 -1
  364. package/src/internal/common/proxy/reactive.test.ts +54 -0
  365. package/src/internal/common/proxy/reactive.ts +11 -3
  366. package/src/internal/common/proxy/schema.test.ts +48 -86
  367. package/src/internal/common/proxy/typed-handler.test.ts +12 -12
  368. package/src/internal/common/proxy/typed-handler.ts +79 -19
  369. package/src/internal/common/proxy/typed-object.test.ts +16 -29
  370. package/src/internal/common/types/base.ts +4 -4
  371. package/src/internal/common/types/entity.ts +81 -2
  372. package/src/internal/common/types/index.ts +6 -1
  373. package/src/internal/common/types/meta.ts +49 -15
  374. package/src/internal/common/types/model-symbols.ts +16 -4
  375. package/src/internal/common/types/typename.ts +39 -3
  376. package/src/internal/common/types/well-known-types.ts +15 -0
  377. package/src/internal/index.ts +6 -0
  378. package/src/testing/api.test.ts +15 -10
  379. package/src/testing/test-data.ts +159 -100
  380. package/src/testing/test-schema.ts +22 -58
  381. package/src/testing/util.ts +14 -11
  382. package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
  383. package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +0 -7
  384. package/dist/lib/neutral/chunk-724GQYEN.mjs +0 -56
  385. package/dist/lib/neutral/chunk-724GQYEN.mjs.map +0 -7
  386. package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
  387. package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +0 -7
  388. package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
  389. package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
  390. package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +0 -7
  391. package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +0 -7
  392. package/dist/lib/neutral/chunk-DYDJBZEG.mjs +0 -102
  393. package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +0 -7
  394. package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +0 -7
  395. package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +0 -7
  396. package/dist/lib/neutral/chunk-NEGC54NE.mjs +0 -130
  397. package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +0 -7
  398. package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +0 -7
  399. package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +0 -7
  400. package/dist/lib/neutral/chunk-OENWMTE6.mjs +0 -45
  401. package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +0 -7
  402. package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
  403. package/dist/lib/neutral/chunk-RMLF7JOZ.mjs +0 -97
  404. package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +0 -7
  405. package/dist/lib/neutral/chunk-SEMVAGBM.mjs +0 -355
  406. package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +0 -7
  407. package/dist/lib/neutral/chunk-TQQZLKB7.mjs.map +0 -7
  408. package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
  409. package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +0 -7
  410. package/dist/lib/neutral/chunk-VA2F47ZC.mjs +0 -152
  411. package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +0 -7
  412. package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +0 -7
  413. package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +0 -7
  414. package/dist/types/src/SchemaRegistry.d.ts +0 -84
  415. package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
  416. package/dist/types/src/internal/Obj/ids.d.ts +0 -6
  417. package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
  418. package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
  419. package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
  420. package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
  421. package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
  422. package/src/SchemaRegistry.ts +0 -106
  423. package/src/internal/Obj/ids.ts +0 -12
  424. package/src/internal/Type/echo-schema.ts +0 -424
  425. package/src/internal/Type/persistent-schema.ts +0 -33
  426. /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Migration.mjs.map} +0 -0
  427. /package/dist/lib/neutral/{chunk-UTBRYVQC.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
  428. /package/dist/lib/neutral/{chunk-UI6MWK5W.mjs.map → chunk-TTCSATUD.mjs.map} +0 -0
@@ -20,9 +20,25 @@ import { FormatAnnotation, TypeFormat } from './types';
20
20
  * }
21
21
  * Note: optional third element for altitude.
22
22
  */
23
+ /** Decimal places retained for stored coordinates (~1.1cm at the equator). */
24
+ export const GEO_PRECISION = 7;
25
+
26
+ const roundCoordinate = (value: number): number => {
27
+ const factor = 10 ** GEO_PRECISION;
28
+ return Math.round(value * factor) / factor;
29
+ };
30
+
31
+ /** Longitude/latitude clamped to range and rounded to {@link GEO_PRECISION} decimal places. */
32
+ const Coordinate = (min: number, max: number, title: string) =>
33
+ Schema.transform(Schema.Number.pipe(Schema.clamp(min, max)), Schema.Number, {
34
+ strict: true,
35
+ decode: roundCoordinate,
36
+ encode: roundCoordinate,
37
+ }).annotations({ title });
38
+
23
39
  export const GeoPoint = Schema.Tuple(
24
- Schema.Number.pipe(Schema.annotations({ title: 'Longitude' }), Schema.clamp(-180, 180), Schema.multipleOf(0.000001)),
25
- Schema.Number.pipe(Schema.annotations({ title: 'Latitude' }), Schema.clamp(-90, 90), Schema.multipleOf(0.000001)),
40
+ Coordinate(-180, 180, 'Longitude'),
41
+ Coordinate(-90, 90, 'Latitude'),
26
42
  Schema.optionalElement(Schema.Number).annotations({
27
43
  title: 'Height ASL (m)',
28
44
  }),
@@ -52,8 +68,9 @@ export namespace GeoLocation {
52
68
  */
53
69
  export const toGeoPoint = ({ longitude, latitude, height }: GeoLocation): GeoPoint => {
54
70
  // TODO(ZaymonFC): Use schema validation instead of doing this manually.
55
- const clampedLongitude = clamp(longitude, -180, 180);
56
- const clampedLatitude = clamp(latitude, -90, 90);
71
+ // Clamp + round to match the `Format.GeoPoint` decode/encode path so both produce identical tuples.
72
+ const clampedLongitude = roundCoordinate(clamp(longitude, -180, 180));
73
+ const clampedLatitude = roundCoordinate(clamp(latitude, -90, 90));
57
74
  return height !== undefined ? [clampedLongitude, clampedLatitude, height] : [clampedLongitude, clampedLatitude];
58
75
  };
59
76
 
@@ -7,7 +7,7 @@ import type * as JSONSchema from 'effect/JSONSchema';
7
7
  import * as Option from 'effect/Option';
8
8
  import * as SchemaAST from 'effect/SchemaAST';
9
9
 
10
- import { createAnnotationHelper } from '../Annotation';
10
+ import { createAnnotationHelper } from '../Annotation/util';
11
11
  import { type JsonSchemaType } from '../JsonSchema';
12
12
 
13
13
  // TODO(burdon): Rename PropertyType.
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as SchemaAST from 'effect/SchemaAST';
6
6
 
7
- import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation';
7
+ import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation/annotations';
8
8
  import { CurrencyAnnotationId, FormatAnnotationId } from '../Format';
9
9
  import { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../JsonSchema';
10
10
 
@@ -6,9 +6,9 @@ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { JsonPath, type JsonProp } from '@dxos/effect';
8
8
 
9
- import { FormatAnnotation, TypeFormat } from '../Format';
10
9
  import { type Mutable } from '../common/proxy';
11
10
  import { EntityKindSchema } from '../common/types';
11
+ import { FormatAnnotation, TypeFormat } from '../Format';
12
12
 
13
13
  //
14
14
  // JSON Schema
@@ -8,7 +8,7 @@ import * as SchemaAST from 'effect/SchemaAST';
8
8
  import { describe, expect, test } from 'vitest';
9
9
 
10
10
  import { type JsonProp, findAnnotation } from '@dxos/effect';
11
- import { ObjectId } from '@dxos/keys';
11
+ import { DXN, EntityId } from '@dxos/keys';
12
12
  import { log } from '@dxos/log';
13
13
 
14
14
  import { TestSchema, prepareAstForCompare } from '../../testing';
@@ -21,13 +21,12 @@ import {
21
21
  getTypeAnnotation,
22
22
  getTypeIdentifierAnnotation,
23
23
  } from '../Annotation';
24
+ import { EntityKind } from '../common/types';
24
25
  import { EchoObjectSchema } from '../Entity';
25
26
  import { Email, FormatAnnotation, TypeFormat } from '../Format';
26
27
  import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../JsonSchema';
27
28
  import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../Ref';
28
- import { PersistentSchema } from '../Type';
29
- import { EntityKind } from '../common/types';
30
-
29
+ import { TypeSchema } from '../Type';
31
30
  import { toEffectSchema, toJsonSchema } from './json-schema';
32
31
 
33
32
  const EXAMPLE_NAMESPACE = '@example';
@@ -35,26 +34,18 @@ const EXAMPLE_NAMESPACE = '@example';
35
34
  describe('effect-to-json', () => {
36
35
  test('type annotation', () => {
37
36
  const Test = Schema.Struct({ name: Schema.String }).pipe(
38
- Type.object({
39
- typename: 'com.example.type.test',
40
- version: '0.1.0',
41
- }),
37
+ Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
42
38
  );
43
39
  const jsonSchema = toJsonSchema(Test);
44
- expect((jsonSchema as any).$id).toEqual('dxn:type:com.example.type.test');
45
- expect((jsonSchema as any).version).toEqual('0.1.0');
40
+ expect(jsonSchema.$id).toEqual('dxn:com.example.type.test:0.1.0');
41
+ expect(jsonSchema.version).toEqual('0.1.0');
46
42
  });
47
43
 
48
44
  test('property meta annotation', () => {
49
45
  const meta = { maxLength: 0 };
50
46
  const Test = Schema.Struct({
51
47
  name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
52
- }).pipe(
53
- Type.object({
54
- typename: 'com.example.type.test',
55
- version: '0.1.0',
56
- }),
57
- );
48
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
58
49
  const jsonSchema = toJsonSchema(Test);
59
50
  expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
60
51
  });
@@ -62,20 +53,10 @@ describe('effect-to-json', () => {
62
53
  test('reference annotation', () => {
63
54
  const Nested = Schema.Struct({
64
55
  name: Schema.String,
65
- }).pipe(
66
- Type.object({
67
- typename: 'com.example.type.testNested',
68
- version: '0.1.0',
69
- }),
70
- );
56
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
71
57
  const Test = Schema.Struct({
72
58
  name: Ref(Nested),
73
- }).pipe(
74
- Type.object({
75
- typename: 'com.example.type.test',
76
- version: '0.1.0',
77
- }),
78
- );
59
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
79
60
  const jsonSchema = toJsonSchema(Test);
80
61
  // log.info('schema', { jsonSchema });
81
62
  const nested = jsonSchema.properties!.name;
@@ -87,20 +68,10 @@ describe('effect-to-json', () => {
87
68
  test.skip('reference annotation with lookup property', () => {
88
69
  const Nested = Schema.Struct({
89
70
  name: Schema.String,
90
- }).pipe(
91
- Type.object({
92
- typename: 'com.example.type.testNested',
93
- version: '0.1.0',
94
- }),
95
- );
71
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
96
72
  const Test = Schema.Struct({
97
73
  name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
98
- }).pipe(
99
- Type.object({
100
- typename: 'com.example.type.test',
101
- version: '0.1.0',
102
- }),
103
- );
74
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
104
75
  const jsonSchema = toJsonSchema(Test);
105
76
  const effectSchema = toEffectSchema(jsonSchema);
106
77
 
@@ -111,20 +82,10 @@ describe('effect-to-json', () => {
111
82
  test('array of references', () => {
112
83
  const Nested = Schema.Struct({
113
84
  name: Schema.String,
114
- }).pipe(
115
- Type.object({
116
- typename: 'com.example.type.testNested',
117
- version: '0.1.0',
118
- }),
119
- );
85
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
120
86
  const Test = Schema.Struct({
121
87
  name: Schema.Array(Ref(Nested)),
122
- }).pipe(
123
- Type.object({
124
- typename: 'com.example.type.test',
125
- version: '0.1.0',
126
- }),
127
- );
88
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
128
89
 
129
90
  const jsonSchema = toJsonSchema(Test);
130
91
  expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
@@ -133,20 +94,10 @@ describe('effect-to-json', () => {
133
94
  test('optional references', () => {
134
95
  const Nested = Schema.Struct({
135
96
  name: Schema.String,
136
- }).pipe(
137
- Type.object({
138
- typename: 'com.example.type.testNested',
139
- version: '0.1.0',
140
- }),
141
- );
97
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
142
98
  const Test = Schema.Struct({
143
99
  name: Schema.optional(Ref(Nested)),
144
- }).pipe(
145
- Type.object({
146
- typename: 'com.example.type.test',
147
- version: '0.1.0',
148
- }),
149
- );
100
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
150
101
  const jsonSchema = toJsonSchema(Test);
151
102
  expectReferenceAnnotation(jsonSchema.properties!.name);
152
103
  });
@@ -164,17 +115,12 @@ describe('effect-to-json', () => {
164
115
  email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
165
116
  description: 'Email address',
166
117
  }),
167
- }).pipe(
168
- Type.object({
169
- typename: 'com.example.type.person',
170
- version: '0.1.0',
171
- }),
172
- );
118
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
173
119
 
174
120
  const jsonSchema = toJsonSchema(TempSchema);
175
121
  expect(jsonSchema).to.deep.eq({
176
122
  $schema: 'http://json-schema.org/draft-07/schema#',
177
- $id: 'dxn:type:com.example.type.person',
123
+ $id: 'dxn:com.example.type.person:0.1.0',
178
124
 
179
125
  entityKind: EntityKind.Object,
180
126
  typename: 'com.example.type.person',
@@ -215,29 +161,19 @@ describe('effect-to-json', () => {
215
161
  test('reference property by ref', () => {
216
162
  const Organization = Schema.Struct({
217
163
  field: Schema.String,
218
- }).pipe(
219
- Type.object({
220
- typename: 'com.example.type.organization',
221
- version: '0.1.0',
222
- }),
223
- );
164
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
224
165
 
225
166
  const Contact = Schema.Struct({
226
167
  name: Schema.String,
227
168
  organization: Ref(Organization).annotations({ description: 'Contact organization' }),
228
- }).pipe(
229
- Type.object({
230
- typename: 'com.example.type.person',
231
- version: '0.1.0',
232
- }),
233
- );
169
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
234
170
 
235
171
  // log.info('Contact', { ast: Contact.ast });
236
172
 
237
173
  const jsonSchema = toJsonSchema(Contact);
238
174
  expect(jsonSchema).toEqual({
239
175
  $schema: 'http://json-schema.org/draft-07/schema#',
240
- $id: 'dxn:type:com.example.type.person',
176
+ $id: 'dxn:com.example.type.person:0.1.0',
241
177
 
242
178
  entityKind: EntityKind.Object,
243
179
  typename: 'com.example.type.person',
@@ -260,7 +196,7 @@ describe('effect-to-json', () => {
260
196
  $ref: '/schemas/echo/ref',
261
197
  reference: {
262
198
  schema: {
263
- $ref: 'dxn:type:com.example.type.organization',
199
+ $ref: 'dxn:com.example.type.organization',
264
200
  },
265
201
  schemaVersion: '0.1.0',
266
202
  },
@@ -277,31 +213,21 @@ describe('effect-to-json', () => {
277
213
  test('add reference property', () => {
278
214
  const Organization = Schema.Struct({
279
215
  field: Schema.String,
280
- }).pipe(
281
- Type.object({
282
- typename: 'com.example.type.organization',
283
- version: '0.1.0',
284
- }),
285
- );
216
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
286
217
 
287
218
  const Contact = Schema.Struct({
288
219
  name: Schema.String,
289
220
  organization: Ref(Organization).annotations({ description: 'Contact organization' }),
290
- }).pipe(
291
- Type.object({
292
- typename: 'com.example.type.person',
293
- version: '0.1.0',
294
- }),
295
- );
221
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
296
222
 
297
223
  const jsonSchema = toJsonSchema(Contact);
298
- setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization.typename));
224
+ setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Type.getTypename(Organization)));
299
225
  const { typename } = getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as JsonProp) ?? {}) ?? {};
300
- expect(typename).to.eq(Organization.typename);
226
+ expect(typename).to.eq(Type.getTypename(Organization));
301
227
  });
302
228
 
303
- test('serialize circular schema (PersistentSchema)', () => {
304
- const jsonSchema = toJsonSchema(PersistentSchema);
229
+ test('serialize circular schema (TypeSchema)', () => {
230
+ const jsonSchema = toJsonSchema(TypeSchema);
305
231
  expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
306
232
 
307
233
  // TODO(dmaretskyi): Currently unable to deserialize.
@@ -350,18 +276,18 @@ describe('effect-to-json', () => {
350
276
  const schema = TestSchema.EmployedBy;
351
277
  const jsonSchema = toJsonSchema(schema);
352
278
  expect(jsonSchema).toEqual({
353
- $id: 'dxn:type:com.example.type.employed-by',
279
+ $id: 'dxn:com.example.type.employedBy:0.1.0',
354
280
  $schema: 'http://json-schema.org/draft-07/schema#',
355
281
  entityKind: 'relation',
356
- typename: 'com.example.type.employed-by',
282
+ typename: 'com.example.type.employedBy',
357
283
  version: '0.1.0',
358
284
  relationSource: {
359
285
  // TODO(dmaretskyi): Should those point to specific schema version?
360
- $ref: 'dxn:type:com.example.type.person',
286
+ $ref: 'dxn:com.example.type.person',
361
287
  },
362
288
  relationTarget: {
363
289
  // TODO(dmaretskyi): Should those point to specific schema version?
364
- $ref: 'dxn:type:com.example.type.organization',
290
+ $ref: 'dxn:com.example.type.organization',
365
291
  },
366
292
  type: 'object',
367
293
  properties: {
@@ -383,19 +309,13 @@ describe('effect-to-json', () => {
383
309
 
384
310
  test('label prop', () => {
385
311
  const Organization = Schema.Struct({
386
- id: ObjectId,
312
+ id: EntityId,
387
313
  name: Schema.String,
388
- }).pipe(
389
- EchoObjectSchema({
390
- typename: 'com.example.type.organization',
391
- version: '0.1.0',
392
- }),
393
- LabelAnnotation.set(['name']),
394
- );
314
+ }).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
395
315
 
396
316
  const jsonSchema = toJsonSchema(Organization);
397
317
  expect(jsonSchema).toEqual({
398
- $id: 'dxn:type:com.example.type.organization',
318
+ $id: 'dxn:com.example.type.organization:0.1.0',
399
319
  $schema: 'http://json-schema.org/draft-07/schema#',
400
320
  typename: 'com.example.type.organization',
401
321
  version: '0.1.0',
@@ -422,9 +342,9 @@ describe('effect-to-json', () => {
422
342
 
423
343
  test('object id with description', () => {
424
344
  const schema = Schema.Struct({
425
- id: ObjectId.annotations({ description: 'The id' }),
345
+ id: EntityId.annotations({ description: 'The id' }),
426
346
  });
427
- // log.info('schema', { schema: ObjectId.ast });
347
+ // log.info('schema', { schema: EntityId.ast });
428
348
  const jsonSchema = toJsonSchema(schema);
429
349
  expect(jsonSchema).toMatchInlineSnapshot(`
430
350
  {
@@ -468,7 +388,7 @@ describe('effect-to-json', () => {
468
388
  const expectReferenceAnnotation = (object: JsonSchemaType) => {
469
389
  expect(object.reference).to.deep.eq({
470
390
  schema: {
471
- $ref: 'dxn:type:com.example.type.testNested',
391
+ $ref: 'dxn:com.example.type.testNested',
472
392
  },
473
393
  schemaVersion: '0.1.0',
474
394
  });
@@ -495,12 +415,7 @@ describe('json-to-effect', () => {
495
415
  test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
496
416
  const Organization = Schema.Struct({
497
417
  field: Schema.String,
498
- }).pipe(
499
- Type.object({
500
- typename: 'com.example.type.organization',
501
- version: '0.1.0',
502
- }),
503
- );
418
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
504
419
 
505
420
  const fields = {
506
421
  string: Schema.String,
@@ -517,10 +432,7 @@ describe('json-to-effect', () => {
517
432
  } as const;
518
433
 
519
434
  const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
520
- Type.object({
521
- typename: 'com.example.type.test',
522
- version: '0.1.0',
523
- }),
435
+ Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
524
436
  );
525
437
 
526
438
  const jsonSchema = toJsonSchema(Test);
@@ -528,11 +440,12 @@ describe('json-to-effect', () => {
528
440
 
529
441
  const schema = toEffectSchema(jsonSchema);
530
442
 
531
- expect(() => expect(schema.ast).to.deep.eq(Test.ast)).to.throw();
532
- expect(() => expect(prepareAstForCompare(Test.ast)).to.deep.eq(Test.ast)).to.throw();
533
- expect(() => expect(schema.ast).to.deep.eq(prepareAstForCompare(Test.ast))).to.throw();
443
+ const testAst = Type.getSchema(Test).ast;
444
+ expect(() => expect(schema.ast).to.deep.eq(testAst)).to.throw();
445
+ expect(() => expect(prepareAstForCompare(testAst)).to.deep.eq(testAst)).to.throw();
446
+ expect(() => expect(schema.ast).to.deep.eq(prepareAstForCompare(testAst))).to.throw();
534
447
  // log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
535
- expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(Test.ast));
448
+ expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
536
449
 
537
450
  // TODO(dmaretskyi): Fix.
538
451
  // expect(
@@ -580,7 +493,7 @@ describe('json-to-effect', () => {
580
493
  typename: 'com.example.type.project',
581
494
  version: '0.1.0',
582
495
  });
583
- expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('dxn:echo:@:01JERV1HQCQZDQ4NVCJ42QB38F');
496
+ expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
584
497
  });
585
498
 
586
499
  test('symbol annotations get compared', () => {
@@ -603,7 +516,7 @@ describe('json-to-effect', () => {
603
516
  const schema = TestSchema.HasManager;
604
517
  const jsonSchema = toJsonSchema(schema);
605
518
  const effectSchema = toEffectSchema(jsonSchema);
606
- expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
519
+ expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
607
520
  });
608
521
 
609
522
  test('generator annotation', () => {
@@ -715,7 +628,7 @@ describe('json-to-effect', () => {
715
628
  "$ref": "/schemas/echo/ref",
716
629
  "reference": {
717
630
  "schema": {
718
- "$ref": "dxn:type:com.example.type.person",
631
+ "$ref": "dxn:com.example.type.person",
719
632
  },
720
633
  "schemaVersion": "0.1.0",
721
634
  },
@@ -736,9 +649,9 @@ describe('json-to-effect', () => {
736
649
  test('object nested inside another struct', () => {
737
650
  const Contact = Schema.Struct({
738
651
  name: Schema.String,
739
- }).pipe(EchoObjectSchema({ typename: 'com.example.type.person', version: '0.1.0' }));
652
+ }).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
740
653
  const input = Schema.Struct({
741
- contact: Contact,
654
+ contact: Type.getSchema(Contact),
742
655
  });
743
656
  const jsonSchema = toJsonSchema(input);
744
657
  expect(jsonSchema).toMatchInlineSnapshot(`
@@ -747,7 +660,7 @@ describe('json-to-effect', () => {
747
660
  "additionalProperties": false,
748
661
  "properties": {
749
662
  "contact": {
750
- "$id": "dxn:type:com.example.type.person",
663
+ "$id": "dxn:com.example.type.person:0.1.0",
751
664
  "additionalProperties": false,
752
665
  "entityKind": "object",
753
666
  "properties": {
@@ -796,7 +709,7 @@ describe('reference', () => {
796
709
  $schema: 'http://json-schema.org/draft-07/schema#',
797
710
  reference: {
798
711
  schema: {
799
- $ref: 'dxn:type:com.example.type.person',
712
+ $ref: 'dxn:com.example.type.person',
800
713
  },
801
714
  schemaVersion: '0.1.0',
802
715
  },
@@ -814,7 +727,7 @@ describe('reference', () => {
814
727
  $ref: '/schemas/echo/ref',
815
728
  reference: {
816
729
  schema: {
817
- $ref: 'dxn:type:com.example.type.person',
730
+ $ref: 'dxn:com.example.type.person',
818
731
  },
819
732
  schemaVersion: '0.1.0',
820
733
  },
@@ -835,7 +748,7 @@ describe('reference', () => {
835
748
  $ref: '/schemas/echo/ref',
836
749
  reference: {
837
750
  schema: {
838
- $ref: 'dxn:type:com.example.type.person',
751
+ $ref: 'dxn:com.example.type.person',
839
752
  },
840
753
  schemaVersion: '0.1.0',
841
754
  },
@@ -854,8 +767,8 @@ describe('reference', () => {
854
767
  const deserializedSchema = toEffectSchema(jsonSchema);
855
768
  const refAst = getReferenceAst(deserializedSchema.ast);
856
769
  expect(refAst).toEqual({
857
- typename: TestSchema.Person.typename,
858
- version: TestSchema.Person.version,
770
+ typename: Type.getTypename(TestSchema.Person),
771
+ version: Type.getVersion(TestSchema.Person),
859
772
  });
860
773
  });
861
774
  });
@@ -13,19 +13,21 @@ import type * as Types from 'effect/Types';
13
13
  import { raise } from '@dxos/debug';
14
14
  import { mapAst } from '@dxos/effect';
15
15
  import { assertArgument, invariant } from '@dxos/invariant';
16
- import { DXN, ObjectId } from '@dxos/keys';
16
+ import { DXN, EID, EntityId } from '@dxos/keys';
17
17
  import { log } from '@dxos/log';
18
18
  import { clearUndefined, orderKeys, removeProperties } from '@dxos/util';
19
19
 
20
+ import type * as Type from '../../Type';
21
+ import { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation/annotations';
22
+ import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
20
23
  import {
21
- type TypeAnnotation,
22
- TypeAnnotationId,
23
- TypeIdentifierAnnotationId,
24
- makeTypeJsonSchemaAnnotation,
25
- } from '../Annotation';
24
+ ANY_OBJECT_TYPENAME,
25
+ ANY_OBJECT_VERSION,
26
+ EntityKind,
27
+ EntityKindSchema,
28
+ getStaticTypeSchema,
29
+ } from '../common/types';
26
30
  import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
27
- import { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, EntityKind, EntityKindSchema } from '../common/types';
28
-
29
31
  import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
30
32
  import {
31
33
  ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
@@ -82,11 +84,22 @@ export type JsonSchemaOptions = {
82
84
  // We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
83
85
  // TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
84
86
  export const toJsonSchema = (
85
- schema: Schema.Schema.All,
87
+ schema: Schema.Schema.All | Type.AnyEntity,
86
88
  options: JsonSchemaOptions = {},
87
89
  ): Types.DeepMutable<JsonSchemaType> => {
90
+ // Allow passing a `Type.Type` entity — use its hidden source schema (or its
91
+ // already-built jsonSchema as a fallback).
92
+ const slot = getStaticTypeSchema(schema);
93
+ if (slot != null) {
94
+ schema = slot;
95
+ } else if (!Schema.isSchema(schema)) {
96
+ const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;
97
+ if (entityJsonSchema != null) {
98
+ return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;
99
+ }
100
+ }
88
101
  assertArgument(Schema.isSchema(schema), 'schema');
89
- let jsonSchema = _toJsonSchemaAST(schema.ast);
102
+ let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
90
103
  if (options.strict) {
91
104
  // TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
92
105
  jsonSchema = removeProperties(jsonSchema, (key, value) => {
@@ -341,9 +354,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
341
354
  const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
342
355
  // TODO(dmaretskyi): Is this branch still taken?
343
356
  if ((echoRefinement as any)?.reference != null) {
344
- const echoId = root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
357
+ const echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
345
358
  return createEchoReferenceSchema(
346
- echoId,
359
+ echoUri,
347
360
  (echoRefinement as any).reference.typename,
348
361
  (echoRefinement as any).reference.version,
349
362
  );
@@ -364,14 +377,11 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
364
377
  throw new Error('Invalid reference field in ref schema');
365
378
  }
366
379
 
367
- const targetSchemaDXN = DXN.parse(reference.schema.$ref);
368
- invariant(targetSchemaDXN.kind === DXN.kind.TYPE);
380
+ const ref = reference.schema.$ref;
381
+ const targetSchemaDXN = DXN.tryMake(ref);
382
+ invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
369
383
 
370
- return createEchoReferenceSchema(
371
- targetSchemaDXN.toString(),
372
- targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
373
- reference.schemaVersion,
374
- );
384
+ return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
375
385
  };
376
386
 
377
387
  //
@@ -392,10 +402,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
392
402
  schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
393
403
  }
394
404
 
405
+ // For stored schemas the storage URI is the definitive identifier — it overrides
406
+ // the typename `$id` written above.
395
407
  const echoIdentifier = annotations[TypeIdentifierAnnotationId];
396
408
  if (echoIdentifier) {
397
- schemaFields[ECHO_ANNOTATIONS_NS_KEY] ??= {};
398
- schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
409
+ schemaFields.$id = echoIdentifier;
399
410
  }
400
411
 
401
412
  // Custom (at end).
@@ -410,14 +421,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
410
421
  };
411
422
 
412
423
  const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
413
- // Limit to dxn:echo: URIs.
414
- if (schema.$id && schema.$id.startsWith('dxn:echo:')) {
424
+ // For stored schemas `$id` IS the storage URI (echo:/… or legacy dxn:echo:…).
425
+ if (schema.$id && (schema.$id.startsWith('echo:') || schema.$id.startsWith('dxn:echo:'))) {
415
426
  return schema.$id;
416
- } else if (schema.$id && schema.$id.startsWith('dxn:type:') && schema?.echo?.type?.schemaId) {
417
- const id = schema?.echo?.type?.schemaId;
418
- if (ObjectId.isValid(id)) {
419
- return DXN.fromLocalObjectId(id).toString();
420
- }
427
+ }
428
+ // Legacy: older serializations stored the EID on echo.type.schemaId.
429
+ const legacySchemaId = schema.echo?.type?.schemaId;
430
+ if (legacySchemaId) {
431
+ return EntityId.isValid(legacySchemaId) ? EID.make({ entityId: legacySchemaId }) : legacySchemaId;
421
432
  }
422
433
  return undefined;
423
434
  };
@@ -434,8 +445,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
434
445
  if (annotation.kind === EntityKind.Relation) {
435
446
  const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
436
447
  const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
437
- annotation.sourceSchema = DXN.parse(source).toString();
438
- annotation.targetSchema = DXN.parse(target).toString();
448
+ annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
449
+ annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
439
450
  }
440
451
 
441
452
  return annotation;
@@ -471,7 +482,9 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
471
482
  if (typeAnnotation) {
472
483
  annotations[TypeAnnotationId] = typeAnnotation;
473
484
  annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
474
- identifier: typeIdentifier,
485
+ // $id is the typename DXN — the schema's type identity. The storage EID (if any)
486
+ // is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
487
+ identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
475
488
  kind: typeAnnotation.kind,
476
489
  typename: typeAnnotation.typename,
477
490
  version: typeAnnotation.version,