@dxos/echo 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +4 -4
  2. package/dist/lib/neutral/Annotation.mjs +27 -6
  3. package/dist/lib/neutral/Database.mjs +6 -11
  4. package/dist/lib/neutral/Entity.mjs +25 -16
  5. package/dist/lib/neutral/Err.mjs +3 -3
  6. package/dist/lib/neutral/Feed.mjs +19 -17
  7. package/dist/lib/neutral/Filter.mjs +13 -13
  8. package/dist/lib/neutral/Format.mjs +23 -3
  9. package/dist/lib/neutral/JsonSchema.mjs +7 -8
  10. package/dist/lib/neutral/Key.mjs +9 -5
  11. package/dist/lib/neutral/Migration.mjs +11 -10
  12. package/dist/lib/neutral/Obj.mjs +21 -18
  13. package/dist/lib/neutral/Query.mjs +17 -17
  14. package/dist/lib/neutral/QueryResult.mjs +1 -1
  15. package/dist/lib/neutral/Ref.mjs +10 -11
  16. package/dist/lib/neutral/Registry.mjs +14 -0
  17. package/dist/lib/neutral/Relation.mjs +24 -23
  18. package/dist/lib/neutral/Scope.mjs +12 -0
  19. package/dist/lib/neutral/Tag.mjs +17 -14
  20. package/dist/lib/neutral/Type.mjs +52 -26
  21. package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
  22. package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
  23. package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
  24. package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
  25. package/dist/lib/neutral/{chunk-PT37DG2F.mjs → chunk-4SFPZJVA.mjs} +82 -74
  26. package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
  27. package/dist/lib/neutral/{chunk-APHSOTIX.mjs → chunk-4Z6GET2X.mjs} +3 -3
  28. package/dist/lib/neutral/{chunk-APHSOTIX.mjs.map → chunk-4Z6GET2X.mjs.map} +2 -2
  29. package/dist/lib/neutral/{chunk-7RVZT53K.mjs → chunk-7LOUAPYZ.mjs} +9 -5
  30. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  31. package/dist/lib/neutral/{chunk-BMB7IHGB.mjs → chunk-7OAFN3OX.mjs} +70 -57
  32. package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
  33. package/dist/lib/neutral/{chunk-MLS7U7AT.mjs → chunk-7PRCIDHH.mjs} +41 -28
  34. package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
  35. package/dist/lib/neutral/{chunk-ZISMEVKD.mjs → chunk-BBFJWWAV.mjs} +6 -6
  36. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  37. package/dist/lib/neutral/{chunk-ZFACXBY6.mjs → chunk-BDQGMDIX.mjs} +30 -34
  38. package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
  39. package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
  40. package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
  41. package/dist/lib/neutral/{chunk-V72DY6LU.mjs → chunk-DKLUHO4T.mjs} +1 -1
  42. package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
  44. package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
  45. package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs → chunk-G6CFWUYH.mjs} +2 -2
  46. package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
  47. package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
  48. package/dist/lib/neutral/{chunk-N7VOEPSV.mjs → chunk-J3MNM65T.mjs} +9 -9
  49. package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
  50. package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
  51. package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
  52. package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
  53. package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
  54. package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
  55. package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
  56. package/dist/lib/neutral/{chunk-N4B7FHQT.mjs → chunk-O6BH7EPN.mjs} +30 -3
  57. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  58. package/dist/lib/neutral/{chunk-Q7ZL2P5H.mjs → chunk-OIYW7R2G.mjs} +62 -46
  59. package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
  60. package/dist/lib/neutral/{chunk-G54OX4IX.mjs → chunk-OYUG4FHF.mjs} +527 -847
  61. package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
  62. package/dist/lib/neutral/{chunk-J54QMAKF.mjs → chunk-Q5FKCVBC.mjs} +64 -59
  63. package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
  64. package/dist/lib/neutral/{chunk-FIWO2FZK.mjs → chunk-Q62IHV2N.mjs} +12 -7
  65. package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
  66. package/dist/lib/neutral/{chunk-SCPFDS2E.mjs → chunk-QVJDDG44.mjs} +65 -34
  67. package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
  68. package/dist/lib/neutral/{chunk-TRPZU2HV.mjs → chunk-TFEWTY5A.mjs} +155 -129
  69. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  70. package/dist/lib/neutral/{chunk-44HT3MEC.mjs → chunk-VKWOFXT2.mjs} +22 -2
  71. package/dist/lib/neutral/{chunk-44HT3MEC.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
  72. package/dist/lib/neutral/{chunk-APJKDGFL.mjs → chunk-ZACMEAYV.mjs} +24 -24
  73. package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
  74. package/dist/lib/neutral/index.mjs +50 -40
  75. package/dist/lib/neutral/internal/index.mjs +125 -64
  76. package/dist/lib/neutral/meta.json +1 -1
  77. package/dist/lib/neutral/testing/index.mjs +88 -99
  78. package/dist/lib/neutral/testing/index.mjs.map +3 -3
  79. package/dist/types/src/Annotation.d.ts +108 -4
  80. package/dist/types/src/Annotation.d.ts.map +1 -1
  81. package/dist/types/src/Annotation.test.d.ts +2 -0
  82. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  83. package/dist/types/src/Collection.d.ts +2 -3
  84. package/dist/types/src/Collection.d.ts.map +1 -1
  85. package/dist/types/src/Database.d.ts +50 -30
  86. package/dist/types/src/Database.d.ts.map +1 -1
  87. package/dist/types/src/Dataset.d.ts +16 -6
  88. package/dist/types/src/Dataset.d.ts.map +1 -1
  89. package/dist/types/src/Entity.d.ts +89 -19
  90. package/dist/types/src/Entity.d.ts.map +1 -1
  91. package/dist/types/src/Err.d.ts +9 -9
  92. package/dist/types/src/Err.d.ts.map +1 -1
  93. package/dist/types/src/Feed.d.ts +35 -12
  94. package/dist/types/src/Feed.d.ts.map +1 -1
  95. package/dist/types/src/Filter.d.ts +21 -8
  96. package/dist/types/src/Filter.d.ts.map +1 -1
  97. package/dist/types/src/Hypergraph.d.ts +13 -8
  98. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  99. package/dist/types/src/Json.d.ts.map +1 -1
  100. package/dist/types/src/JsonSchema.d.ts +1 -1
  101. package/dist/types/src/JsonSchema.d.ts.map +1 -1
  102. package/dist/types/src/Key.d.ts +1 -1
  103. package/dist/types/src/Key.d.ts.map +1 -1
  104. package/dist/types/src/Migration.d.ts +15 -12
  105. package/dist/types/src/Migration.d.ts.map +1 -1
  106. package/dist/types/src/Obj.d.ts +69 -40
  107. package/dist/types/src/Obj.d.ts.map +1 -1
  108. package/dist/types/src/Query.d.ts +24 -10
  109. package/dist/types/src/Query.d.ts.map +1 -1
  110. package/dist/types/src/QueryResult.d.ts +9 -0
  111. package/dist/types/src/QueryResult.d.ts.map +1 -1
  112. package/dist/types/src/Ref.d.ts +15 -8
  113. package/dist/types/src/Ref.d.ts.map +1 -1
  114. package/dist/types/src/Registry.d.ts +131 -0
  115. package/dist/types/src/Registry.d.ts.map +1 -0
  116. package/dist/types/src/Relation.d.ts +55 -26
  117. package/dist/types/src/Relation.d.ts.map +1 -1
  118. package/dist/types/src/Scope.d.ts +34 -0
  119. package/dist/types/src/Scope.d.ts.map +1 -0
  120. package/dist/types/src/StateMap.d.ts +32 -0
  121. package/dist/types/src/StateMap.d.ts.map +1 -0
  122. package/dist/types/src/StateMap.test.d.ts +2 -0
  123. package/dist/types/src/StateMap.test.d.ts.map +1 -0
  124. package/dist/types/src/Tag.d.ts +19 -3
  125. package/dist/types/src/Tag.d.ts.map +1 -1
  126. package/dist/types/src/TagIndex.d.ts +36 -0
  127. package/dist/types/src/TagIndex.d.ts.map +1 -0
  128. package/dist/types/src/TagIndex.test.d.ts +2 -0
  129. package/dist/types/src/TagIndex.test.d.ts.map +1 -0
  130. package/dist/types/src/Tagging.d.ts +31 -0
  131. package/dist/types/src/Tagging.d.ts.map +1 -0
  132. package/dist/types/src/Type.d.ts +356 -95
  133. package/dist/types/src/Type.d.ts.map +1 -1
  134. package/dist/types/src/View.d.ts +1 -4
  135. package/dist/types/src/View.d.ts.map +1 -1
  136. package/dist/types/src/index.d.ts +6 -3
  137. package/dist/types/src/index.d.ts.map +1 -1
  138. package/dist/types/src/internal/Annotation/annotations.d.ts +68 -36
  139. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  140. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  141. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  142. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  143. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  144. package/dist/types/src/internal/Annotation/index.d.ts +4 -2
  145. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
  146. package/dist/types/src/internal/Annotation/util.d.ts +13 -4
  147. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
  148. package/dist/types/src/internal/Entity/api.d.ts +3 -3
  149. package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
  150. package/dist/types/src/internal/Entity/entity.d.ts +72 -8
  151. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
  152. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  153. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  154. package/dist/types/src/internal/Entity/index.d.ts +2 -0
  155. package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
  156. package/dist/types/src/internal/Entity/model.d.ts +18 -17
  157. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  158. package/dist/types/src/internal/Entity/object.d.ts +3 -3
  159. package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
  160. package/dist/types/src/internal/Entity/relation.d.ts +30 -7
  161. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
  162. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  163. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  164. package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
  165. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  166. package/dist/types/src/internal/Format/date.d.ts.map +1 -1
  167. package/dist/types/src/internal/Format/format.d.ts +3 -2
  168. package/dist/types/src/internal/Format/format.d.ts.map +1 -1
  169. package/dist/types/src/internal/Format/index.d.ts +2 -2
  170. package/dist/types/src/internal/Format/index.d.ts.map +1 -1
  171. package/dist/types/src/internal/Format/object.d.ts +3 -1
  172. package/dist/types/src/internal/Format/object.d.ts.map +1 -1
  173. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +2 -1
  174. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  175. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
  176. package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
  177. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
  178. package/dist/types/src/internal/Obj/index.d.ts +0 -1
  179. package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
  180. package/dist/types/src/internal/Obj/json-serializer.d.ts +8 -8
  181. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  182. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
  183. package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
  184. package/dist/types/src/internal/Query.d.ts.map +1 -1
  185. package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
  186. package/dist/types/src/internal/Ref/ref.d.ts +29 -19
  187. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  188. package/dist/types/src/internal/Type/index.d.ts +1 -2
  189. package/dist/types/src/internal/Type/index.d.ts.map +1 -1
  190. package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
  191. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
  192. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  193. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  194. package/dist/types/src/internal/common/api/meta.d.ts +11 -8
  195. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
  196. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
  197. package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
  198. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  199. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
  200. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  201. package/dist/types/src/internal/common/types/base.d.ts +4 -4
  202. package/dist/types/src/internal/common/types/entity.d.ts +59 -2
  203. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
  204. package/dist/types/src/internal/common/types/index.d.ts +1 -1
  205. package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
  206. package/dist/types/src/internal/common/types/meta.d.ts +13 -7
  207. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
  208. package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
  209. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
  210. package/dist/types/src/internal/common/types/typename.d.ts +7 -0
  211. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
  212. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  213. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  214. package/dist/types/src/internal/index.d.ts +1 -0
  215. package/dist/types/src/internal/index.d.ts.map +1 -1
  216. package/dist/types/src/testing/test-schema.d.ts +32 -38
  217. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  218. package/dist/types/src/testing/util.d.ts +5 -3
  219. package/dist/types/src/testing/util.d.ts.map +1 -1
  220. package/dist/types/tsconfig.tsbuildinfo +1 -1
  221. package/package.json +21 -23
  222. package/src/Annotation.test.ts +439 -0
  223. package/src/Annotation.ts +151 -4
  224. package/src/Collection.ts +5 -9
  225. package/src/Database.ts +86 -61
  226. package/src/Dataset.ts +10 -2
  227. package/src/Entity.test.ts +116 -6
  228. package/src/Entity.ts +116 -23
  229. package/src/Err.ts +4 -4
  230. package/src/Feed.ts +57 -40
  231. package/src/Filter.ts +49 -27
  232. package/src/Hypergraph.ts +13 -8
  233. package/src/Json.test.ts +4 -4
  234. package/src/Json.ts +7 -6
  235. package/src/Key.ts +1 -1
  236. package/src/Migration.ts +27 -19
  237. package/src/Obj.test.ts +19 -8
  238. package/src/Obj.ts +131 -70
  239. package/src/Query.test.ts +147 -151
  240. package/src/Query.ts +133 -75
  241. package/src/QueryResult.ts +11 -0
  242. package/src/Ref.ts +21 -5
  243. package/src/Registry.ts +155 -0
  244. package/src/Relation.test.ts +10 -10
  245. package/src/Relation.ts +89 -52
  246. package/src/Scope.ts +50 -0
  247. package/src/StateMap.test.ts +56 -0
  248. package/src/StateMap.ts +99 -0
  249. package/src/Tag.md +88 -0
  250. package/src/Tag.ts +49 -6
  251. package/src/TagIndex.test.ts +57 -0
  252. package/src/TagIndex.ts +110 -0
  253. package/src/Tagging.ts +83 -0
  254. package/src/Type.test.ts +223 -18
  255. package/src/Type.ts +601 -131
  256. package/src/View.ts +10 -19
  257. package/src/index.ts +6 -4
  258. package/src/internal/Annotation/annotations.test.ts +31 -11
  259. package/src/internal/Annotation/annotations.ts +122 -103
  260. package/src/internal/Annotation/dictionary.ts +47 -0
  261. package/src/internal/Annotation/entity-dictionary.ts +40 -0
  262. package/src/internal/Annotation/index.ts +4 -2
  263. package/src/internal/Annotation/util.ts +17 -8
  264. package/src/internal/Entity/api.ts +7 -7
  265. package/src/internal/Entity/entity.ts +196 -47
  266. package/src/internal/Entity/guard.ts +26 -0
  267. package/src/internal/Entity/index.ts +2 -0
  268. package/src/internal/Entity/model.ts +35 -28
  269. package/src/internal/Entity/object.ts +21 -5
  270. package/src/internal/Entity/relation.ts +68 -34
  271. package/src/internal/Entity/type-kind.ts +75 -0
  272. package/src/internal/Entity/type-uri.ts +87 -0
  273. package/src/internal/Entity/util.ts +10 -9
  274. package/src/internal/Format/date.ts +0 -4
  275. package/src/internal/Format/format.test.ts +21 -0
  276. package/src/internal/Format/index.ts +2 -3
  277. package/src/internal/Format/object.ts +21 -4
  278. package/src/internal/Format/types.ts +1 -1
  279. package/src/internal/JsonSchema/annotations.ts +1 -1
  280. package/src/internal/JsonSchema/json-schema.test.ts +54 -140
  281. package/src/internal/JsonSchema/json-schema.ts +44 -30
  282. package/src/internal/Obj/clone.ts +9 -4
  283. package/src/internal/Obj/create-object.test.ts +12 -10
  284. package/src/internal/Obj/create-object.ts +67 -22
  285. package/src/internal/Obj/index.ts +0 -1
  286. package/src/internal/Obj/inspect.ts +4 -3
  287. package/src/internal/Obj/json-serializer.test.ts +100 -21
  288. package/src/internal/Obj/json-serializer.ts +93 -38
  289. package/src/internal/Obj/set-value.test.ts +7 -30
  290. package/src/internal/Obj/snapshot.ts +11 -4
  291. package/src/internal/Obj/typed-object.test.ts +9 -11
  292. package/src/internal/Obj/typed-object.ts +1 -1
  293. package/src/internal/Query.ts +14 -11
  294. package/src/internal/Ref/ref-array.ts +3 -3
  295. package/src/internal/Ref/ref.test.ts +17 -26
  296. package/src/internal/Ref/ref.ts +107 -59
  297. package/src/internal/Type/compose.test.ts +3 -1
  298. package/src/internal/Type/index.ts +1 -2
  299. package/src/internal/Type/manipulation.ts +0 -25
  300. package/src/internal/Type/type-schema.ts +60 -0
  301. package/src/internal/common/README.md +1 -1
  302. package/src/internal/common/api/meta.ts +16 -14
  303. package/src/internal/common/proxy/change.test.ts +35 -27
  304. package/src/internal/common/proxy/handler.test.ts +1 -1
  305. package/src/internal/common/proxy/json-serializer.ts +26 -16
  306. package/src/internal/common/proxy/make-object.ts +43 -20
  307. package/src/internal/common/proxy/ownership.ts +2 -2
  308. package/src/internal/common/proxy/schema.test.ts +48 -86
  309. package/src/internal/common/proxy/typed-handler.test.ts +12 -11
  310. package/src/internal/common/proxy/typed-handler.ts +71 -9
  311. package/src/internal/common/proxy/typed-object.test.ts +15 -27
  312. package/src/internal/common/types/base.ts +4 -4
  313. package/src/internal/common/types/entity.ts +80 -1
  314. package/src/internal/common/types/index.ts +6 -1
  315. package/src/internal/common/types/meta.ts +37 -14
  316. package/src/internal/common/types/model-symbols.ts +16 -4
  317. package/src/internal/common/types/typename.ts +39 -3
  318. package/src/internal/common/types/well-known-types.ts +15 -0
  319. package/src/internal/index.ts +5 -0
  320. package/src/testing/api.test.ts +15 -9
  321. package/src/testing/test-data.ts +24 -24
  322. package/src/testing/test-schema.ts +22 -58
  323. package/src/testing/util.ts +14 -11
  324. package/dist/lib/neutral/Extension.mjs +0 -18
  325. package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
  326. package/dist/lib/neutral/chunk-5SL5LDLD.mjs +0 -47
  327. package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +0 -7
  328. package/dist/lib/neutral/chunk-7RVZT53K.mjs.map +0 -7
  329. package/dist/lib/neutral/chunk-APJKDGFL.mjs.map +0 -7
  330. package/dist/lib/neutral/chunk-BICZKPQG.mjs +0 -7
  331. package/dist/lib/neutral/chunk-BICZKPQG.mjs.map +0 -7
  332. package/dist/lib/neutral/chunk-BMB7IHGB.mjs.map +0 -7
  333. package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +0 -7
  334. package/dist/lib/neutral/chunk-G54OX4IX.mjs.map +0 -7
  335. package/dist/lib/neutral/chunk-GWFFC34K.mjs +0 -50
  336. package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +0 -7
  337. package/dist/lib/neutral/chunk-I2DARWPX.mjs +0 -128
  338. package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +0 -7
  339. package/dist/lib/neutral/chunk-J54QMAKF.mjs.map +0 -7
  340. package/dist/lib/neutral/chunk-MGSQGHOD.mjs +0 -206
  341. package/dist/lib/neutral/chunk-MGSQGHOD.mjs.map +0 -7
  342. package/dist/lib/neutral/chunk-MLS7U7AT.mjs.map +0 -7
  343. package/dist/lib/neutral/chunk-N4B7FHQT.mjs.map +0 -7
  344. package/dist/lib/neutral/chunk-N7VOEPSV.mjs.map +0 -7
  345. package/dist/lib/neutral/chunk-PSZBLH53.mjs +0 -81
  346. package/dist/lib/neutral/chunk-PSZBLH53.mjs.map +0 -7
  347. package/dist/lib/neutral/chunk-PT37DG2F.mjs.map +0 -7
  348. package/dist/lib/neutral/chunk-Q2KKKJSV.mjs +0 -56
  349. package/dist/lib/neutral/chunk-Q2KKKJSV.mjs.map +0 -7
  350. package/dist/lib/neutral/chunk-Q7ZL2P5H.mjs.map +0 -7
  351. package/dist/lib/neutral/chunk-SCPFDS2E.mjs.map +0 -7
  352. package/dist/lib/neutral/chunk-TNBK56IN.mjs +0 -350
  353. package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +0 -7
  354. package/dist/lib/neutral/chunk-TRPZU2HV.mjs.map +0 -7
  355. package/dist/lib/neutral/chunk-V72DY6LU.mjs.map +0 -7
  356. package/dist/lib/neutral/chunk-ZFACXBY6.mjs.map +0 -7
  357. package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +0 -7
  358. package/dist/types/src/Extension.d.ts +0 -80
  359. package/dist/types/src/Extension.d.ts.map +0 -1
  360. package/dist/types/src/Extension.test.d.ts +0 -2
  361. package/dist/types/src/Extension.test.d.ts.map +0 -1
  362. package/dist/types/src/SchemaRegistry.d.ts +0 -84
  363. package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
  364. package/dist/types/src/internal/Obj/ids.d.ts +0 -6
  365. package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
  366. package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
  367. package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
  368. package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
  369. package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
  370. package/src/Extension.test.ts +0 -235
  371. package/src/Extension.ts +0 -122
  372. package/src/SchemaRegistry.ts +0 -106
  373. package/src/internal/Obj/ids.ts +0 -12
  374. package/src/internal/Type/echo-schema.ts +0 -423
  375. package/src/internal/Type/persistent-schema.ts +0 -33
  376. /package/dist/lib/neutral/{Extension.mjs.map → Registry.mjs.map} +0 -0
  377. /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Scope.mjs.map} +0 -0
  378. /package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
@@ -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';
@@ -26,7 +26,7 @@ import { EchoObjectSchema } from '../Entity';
26
26
  import { Email, FormatAnnotation, TypeFormat } from '../Format';
27
27
  import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../JsonSchema';
28
28
  import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../Ref';
29
- import { PersistentSchema } from '../Type';
29
+ import { TypeSchema } from '../Type';
30
30
  import { toEffectSchema, toJsonSchema } from './json-schema';
31
31
 
32
32
  const EXAMPLE_NAMESPACE = '@example';
@@ -34,26 +34,18 @@ const EXAMPLE_NAMESPACE = '@example';
34
34
  describe('effect-to-json', () => {
35
35
  test('type annotation', () => {
36
36
  const Test = Schema.Struct({ name: Schema.String }).pipe(
37
- Type.object({
38
- typename: 'com.example.type.test',
39
- version: '0.1.0',
40
- }),
37
+ Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
41
38
  );
42
39
  const jsonSchema = toJsonSchema(Test);
43
- expect((jsonSchema as any).$id).toEqual('dxn:type:com.example.type.test');
44
- 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');
45
42
  });
46
43
 
47
44
  test('property meta annotation', () => {
48
45
  const meta = { maxLength: 0 };
49
46
  const Test = Schema.Struct({
50
47
  name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
51
- }).pipe(
52
- Type.object({
53
- typename: 'com.example.type.test',
54
- version: '0.1.0',
55
- }),
56
- );
48
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
57
49
  const jsonSchema = toJsonSchema(Test);
58
50
  expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
59
51
  });
@@ -61,20 +53,10 @@ describe('effect-to-json', () => {
61
53
  test('reference annotation', () => {
62
54
  const Nested = Schema.Struct({
63
55
  name: Schema.String,
64
- }).pipe(
65
- Type.object({
66
- typename: 'com.example.type.testNested',
67
- version: '0.1.0',
68
- }),
69
- );
56
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
70
57
  const Test = Schema.Struct({
71
58
  name: Ref(Nested),
72
- }).pipe(
73
- Type.object({
74
- typename: 'com.example.type.test',
75
- version: '0.1.0',
76
- }),
77
- );
59
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
78
60
  const jsonSchema = toJsonSchema(Test);
79
61
  // log.info('schema', { jsonSchema });
80
62
  const nested = jsonSchema.properties!.name;
@@ -86,20 +68,10 @@ describe('effect-to-json', () => {
86
68
  test.skip('reference annotation with lookup property', () => {
87
69
  const Nested = Schema.Struct({
88
70
  name: Schema.String,
89
- }).pipe(
90
- Type.object({
91
- typename: 'com.example.type.testNested',
92
- version: '0.1.0',
93
- }),
94
- );
71
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
95
72
  const Test = Schema.Struct({
96
73
  name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
97
- }).pipe(
98
- Type.object({
99
- typename: 'com.example.type.test',
100
- version: '0.1.0',
101
- }),
102
- );
74
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
103
75
  const jsonSchema = toJsonSchema(Test);
104
76
  const effectSchema = toEffectSchema(jsonSchema);
105
77
 
@@ -110,20 +82,10 @@ describe('effect-to-json', () => {
110
82
  test('array of references', () => {
111
83
  const Nested = Schema.Struct({
112
84
  name: Schema.String,
113
- }).pipe(
114
- Type.object({
115
- typename: 'com.example.type.testNested',
116
- version: '0.1.0',
117
- }),
118
- );
85
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
119
86
  const Test = Schema.Struct({
120
87
  name: Schema.Array(Ref(Nested)),
121
- }).pipe(
122
- Type.object({
123
- typename: 'com.example.type.test',
124
- version: '0.1.0',
125
- }),
126
- );
88
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
127
89
 
128
90
  const jsonSchema = toJsonSchema(Test);
129
91
  expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
@@ -132,20 +94,10 @@ describe('effect-to-json', () => {
132
94
  test('optional references', () => {
133
95
  const Nested = Schema.Struct({
134
96
  name: Schema.String,
135
- }).pipe(
136
- Type.object({
137
- typename: 'com.example.type.testNested',
138
- version: '0.1.0',
139
- }),
140
- );
97
+ }).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
141
98
  const Test = Schema.Struct({
142
99
  name: Schema.optional(Ref(Nested)),
143
- }).pipe(
144
- Type.object({
145
- typename: 'com.example.type.test',
146
- version: '0.1.0',
147
- }),
148
- );
100
+ }).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
149
101
  const jsonSchema = toJsonSchema(Test);
150
102
  expectReferenceAnnotation(jsonSchema.properties!.name);
151
103
  });
@@ -163,17 +115,12 @@ describe('effect-to-json', () => {
163
115
  email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
164
116
  description: 'Email address',
165
117
  }),
166
- }).pipe(
167
- Type.object({
168
- typename: 'com.example.type.person',
169
- version: '0.1.0',
170
- }),
171
- );
118
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
172
119
 
173
120
  const jsonSchema = toJsonSchema(TempSchema);
174
121
  expect(jsonSchema).to.deep.eq({
175
122
  $schema: 'http://json-schema.org/draft-07/schema#',
176
- $id: 'dxn:type:com.example.type.person',
123
+ $id: 'dxn:com.example.type.person:0.1.0',
177
124
 
178
125
  entityKind: EntityKind.Object,
179
126
  typename: 'com.example.type.person',
@@ -214,29 +161,19 @@ describe('effect-to-json', () => {
214
161
  test('reference property by ref', () => {
215
162
  const Organization = Schema.Struct({
216
163
  field: Schema.String,
217
- }).pipe(
218
- Type.object({
219
- typename: 'com.example.type.organization',
220
- version: '0.1.0',
221
- }),
222
- );
164
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
223
165
 
224
166
  const Contact = Schema.Struct({
225
167
  name: Schema.String,
226
168
  organization: Ref(Organization).annotations({ description: 'Contact organization' }),
227
- }).pipe(
228
- Type.object({
229
- typename: 'com.example.type.person',
230
- version: '0.1.0',
231
- }),
232
- );
169
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
233
170
 
234
171
  // log.info('Contact', { ast: Contact.ast });
235
172
 
236
173
  const jsonSchema = toJsonSchema(Contact);
237
174
  expect(jsonSchema).toEqual({
238
175
  $schema: 'http://json-schema.org/draft-07/schema#',
239
- $id: 'dxn:type:com.example.type.person',
176
+ $id: 'dxn:com.example.type.person:0.1.0',
240
177
 
241
178
  entityKind: EntityKind.Object,
242
179
  typename: 'com.example.type.person',
@@ -259,7 +196,7 @@ describe('effect-to-json', () => {
259
196
  $ref: '/schemas/echo/ref',
260
197
  reference: {
261
198
  schema: {
262
- $ref: 'dxn:type:com.example.type.organization',
199
+ $ref: 'dxn:com.example.type.organization',
263
200
  },
264
201
  schemaVersion: '0.1.0',
265
202
  },
@@ -276,31 +213,21 @@ describe('effect-to-json', () => {
276
213
  test('add reference property', () => {
277
214
  const Organization = Schema.Struct({
278
215
  field: Schema.String,
279
- }).pipe(
280
- Type.object({
281
- typename: 'com.example.type.organization',
282
- version: '0.1.0',
283
- }),
284
- );
216
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
285
217
 
286
218
  const Contact = Schema.Struct({
287
219
  name: Schema.String,
288
220
  organization: Ref(Organization).annotations({ description: 'Contact organization' }),
289
- }).pipe(
290
- Type.object({
291
- typename: 'com.example.type.person',
292
- version: '0.1.0',
293
- }),
294
- );
221
+ }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
295
222
 
296
223
  const jsonSchema = toJsonSchema(Contact);
297
- setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization.typename));
224
+ setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Type.getTypename(Organization)));
298
225
  const { typename } = getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as JsonProp) ?? {}) ?? {};
299
- expect(typename).to.eq(Organization.typename);
226
+ expect(typename).to.eq(Type.getTypename(Organization));
300
227
  });
301
228
 
302
- test('serialize circular schema (PersistentSchema)', () => {
303
- const jsonSchema = toJsonSchema(PersistentSchema);
229
+ test('serialize circular schema (TypeSchema)', () => {
230
+ const jsonSchema = toJsonSchema(TypeSchema);
304
231
  expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
305
232
 
306
233
  // TODO(dmaretskyi): Currently unable to deserialize.
@@ -349,18 +276,18 @@ describe('effect-to-json', () => {
349
276
  const schema = TestSchema.EmployedBy;
350
277
  const jsonSchema = toJsonSchema(schema);
351
278
  expect(jsonSchema).toEqual({
352
- $id: 'dxn:type:com.example.type.employed-by',
279
+ $id: 'dxn:com.example.type.employedBy:0.1.0',
353
280
  $schema: 'http://json-schema.org/draft-07/schema#',
354
281
  entityKind: 'relation',
355
- typename: 'com.example.type.employed-by',
282
+ typename: 'com.example.type.employedBy',
356
283
  version: '0.1.0',
357
284
  relationSource: {
358
285
  // TODO(dmaretskyi): Should those point to specific schema version?
359
- $ref: 'dxn:type:com.example.type.person',
286
+ $ref: 'dxn:com.example.type.person',
360
287
  },
361
288
  relationTarget: {
362
289
  // TODO(dmaretskyi): Should those point to specific schema version?
363
- $ref: 'dxn:type:com.example.type.organization',
290
+ $ref: 'dxn:com.example.type.organization',
364
291
  },
365
292
  type: 'object',
366
293
  properties: {
@@ -382,19 +309,13 @@ describe('effect-to-json', () => {
382
309
 
383
310
  test('label prop', () => {
384
311
  const Organization = Schema.Struct({
385
- id: ObjectId,
312
+ id: EntityId,
386
313
  name: Schema.String,
387
- }).pipe(
388
- EchoObjectSchema({
389
- typename: 'com.example.type.organization',
390
- version: '0.1.0',
391
- }),
392
- LabelAnnotation.set(['name']),
393
- );
314
+ }).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
394
315
 
395
316
  const jsonSchema = toJsonSchema(Organization);
396
317
  expect(jsonSchema).toEqual({
397
- $id: 'dxn:type:com.example.type.organization',
318
+ $id: 'dxn:com.example.type.organization:0.1.0',
398
319
  $schema: 'http://json-schema.org/draft-07/schema#',
399
320
  typename: 'com.example.type.organization',
400
321
  version: '0.1.0',
@@ -421,9 +342,9 @@ describe('effect-to-json', () => {
421
342
 
422
343
  test('object id with description', () => {
423
344
  const schema = Schema.Struct({
424
- id: ObjectId.annotations({ description: 'The id' }),
345
+ id: EntityId.annotations({ description: 'The id' }),
425
346
  });
426
- // log.info('schema', { schema: ObjectId.ast });
347
+ // log.info('schema', { schema: EntityId.ast });
427
348
  const jsonSchema = toJsonSchema(schema);
428
349
  expect(jsonSchema).toMatchInlineSnapshot(`
429
350
  {
@@ -467,7 +388,7 @@ describe('effect-to-json', () => {
467
388
  const expectReferenceAnnotation = (object: JsonSchemaType) => {
468
389
  expect(object.reference).to.deep.eq({
469
390
  schema: {
470
- $ref: 'dxn:type:com.example.type.testNested',
391
+ $ref: 'dxn:com.example.type.testNested',
471
392
  },
472
393
  schemaVersion: '0.1.0',
473
394
  });
@@ -494,12 +415,7 @@ describe('json-to-effect', () => {
494
415
  test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
495
416
  const Organization = Schema.Struct({
496
417
  field: Schema.String,
497
- }).pipe(
498
- Type.object({
499
- typename: 'com.example.type.organization',
500
- version: '0.1.0',
501
- }),
502
- );
418
+ }).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
503
419
 
504
420
  const fields = {
505
421
  string: Schema.String,
@@ -516,10 +432,7 @@ describe('json-to-effect', () => {
516
432
  } as const;
517
433
 
518
434
  const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
519
- Type.object({
520
- typename: 'com.example.type.test',
521
- version: '0.1.0',
522
- }),
435
+ Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
523
436
  );
524
437
 
525
438
  const jsonSchema = toJsonSchema(Test);
@@ -527,11 +440,12 @@ describe('json-to-effect', () => {
527
440
 
528
441
  const schema = toEffectSchema(jsonSchema);
529
442
 
530
- expect(() => expect(schema.ast).to.deep.eq(Test.ast)).to.throw();
531
- expect(() => expect(prepareAstForCompare(Test.ast)).to.deep.eq(Test.ast)).to.throw();
532
- 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();
533
447
  // log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
534
- expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(Test.ast));
448
+ expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
535
449
 
536
450
  // TODO(dmaretskyi): Fix.
537
451
  // expect(
@@ -579,7 +493,7 @@ describe('json-to-effect', () => {
579
493
  typename: 'com.example.type.project',
580
494
  version: '0.1.0',
581
495
  });
582
- expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('dxn:echo:@:01JERV1HQCQZDQ4NVCJ42QB38F');
496
+ expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
583
497
  });
584
498
 
585
499
  test('symbol annotations get compared', () => {
@@ -602,7 +516,7 @@ describe('json-to-effect', () => {
602
516
  const schema = TestSchema.HasManager;
603
517
  const jsonSchema = toJsonSchema(schema);
604
518
  const effectSchema = toEffectSchema(jsonSchema);
605
- expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
519
+ expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
606
520
  });
607
521
 
608
522
  test('generator annotation', () => {
@@ -714,7 +628,7 @@ describe('json-to-effect', () => {
714
628
  "$ref": "/schemas/echo/ref",
715
629
  "reference": {
716
630
  "schema": {
717
- "$ref": "dxn:type:com.example.type.person",
631
+ "$ref": "dxn:com.example.type.person",
718
632
  },
719
633
  "schemaVersion": "0.1.0",
720
634
  },
@@ -735,9 +649,9 @@ describe('json-to-effect', () => {
735
649
  test('object nested inside another struct', () => {
736
650
  const Contact = Schema.Struct({
737
651
  name: Schema.String,
738
- }).pipe(EchoObjectSchema({ typename: 'com.example.type.person', version: '0.1.0' }));
652
+ }).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
739
653
  const input = Schema.Struct({
740
- contact: Contact,
654
+ contact: Type.getSchema(Contact),
741
655
  });
742
656
  const jsonSchema = toJsonSchema(input);
743
657
  expect(jsonSchema).toMatchInlineSnapshot(`
@@ -746,7 +660,7 @@ describe('json-to-effect', () => {
746
660
  "additionalProperties": false,
747
661
  "properties": {
748
662
  "contact": {
749
- "$id": "dxn:type:com.example.type.person",
663
+ "$id": "dxn:com.example.type.person:0.1.0",
750
664
  "additionalProperties": false,
751
665
  "entityKind": "object",
752
666
  "properties": {
@@ -795,7 +709,7 @@ describe('reference', () => {
795
709
  $schema: 'http://json-schema.org/draft-07/schema#',
796
710
  reference: {
797
711
  schema: {
798
- $ref: 'dxn:type:com.example.type.person',
712
+ $ref: 'dxn:com.example.type.person',
799
713
  },
800
714
  schemaVersion: '0.1.0',
801
715
  },
@@ -813,7 +727,7 @@ describe('reference', () => {
813
727
  $ref: '/schemas/echo/ref',
814
728
  reference: {
815
729
  schema: {
816
- $ref: 'dxn:type:com.example.type.person',
730
+ $ref: 'dxn:com.example.type.person',
817
731
  },
818
732
  schemaVersion: '0.1.0',
819
733
  },
@@ -834,7 +748,7 @@ describe('reference', () => {
834
748
  $ref: '/schemas/echo/ref',
835
749
  reference: {
836
750
  schema: {
837
- $ref: 'dxn:type:com.example.type.person',
751
+ $ref: 'dxn:com.example.type.person',
838
752
  },
839
753
  schemaVersion: '0.1.0',
840
754
  },
@@ -853,8 +767,8 @@ describe('reference', () => {
853
767
  const deserializedSchema = toEffectSchema(jsonSchema);
854
768
  const refAst = getReferenceAst(deserializedSchema.ast);
855
769
  expect(refAst).toEqual({
856
- typename: TestSchema.Person.typename,
857
- version: TestSchema.Person.version,
770
+ typename: Type.getTypename(TestSchema.Person),
771
+ version: Type.getVersion(TestSchema.Person),
858
772
  });
859
773
  });
860
774
  });
@@ -13,17 +13,20 @@ 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';
26
- import { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, EntityKind, EntityKindSchema } from '../common/types';
24
+ ANY_OBJECT_TYPENAME,
25
+ ANY_OBJECT_VERSION,
26
+ EntityKind,
27
+ EntityKindSchema,
28
+ getStaticTypeSchema,
29
+ } from '../common/types';
27
30
  import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
28
31
  import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
29
32
  import {
@@ -81,11 +84,22 @@ export type JsonSchemaOptions = {
81
84
  // We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
82
85
  // TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
83
86
  export const toJsonSchema = (
84
- schema: Schema.Schema.All,
87
+ schema: Schema.Schema.All | Type.AnyEntity,
85
88
  options: JsonSchemaOptions = {},
86
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
+ }
87
101
  assertArgument(Schema.isSchema(schema), 'schema');
88
- let jsonSchema = _toJsonSchemaAST(schema.ast);
102
+ let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
89
103
  if (options.strict) {
90
104
  // TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
91
105
  jsonSchema = removeProperties(jsonSchema, (key, value) => {
@@ -340,9 +354,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
340
354
  const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
341
355
  // TODO(dmaretskyi): Is this branch still taken?
342
356
  if ((echoRefinement as any)?.reference != null) {
343
- 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;
344
358
  return createEchoReferenceSchema(
345
- echoId,
359
+ echoUri,
346
360
  (echoRefinement as any).reference.typename,
347
361
  (echoRefinement as any).reference.version,
348
362
  );
@@ -363,14 +377,11 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
363
377
  throw new Error('Invalid reference field in ref schema');
364
378
  }
365
379
 
366
- const targetSchemaDXN = DXN.parse(reference.schema.$ref);
367
- 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}`);
368
383
 
369
- return createEchoReferenceSchema(
370
- targetSchemaDXN.toString(),
371
- targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
372
- reference.schemaVersion,
373
- );
384
+ return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
374
385
  };
375
386
 
376
387
  //
@@ -391,10 +402,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
391
402
  schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
392
403
  }
393
404
 
405
+ // For stored schemas the storage URI is the definitive identifier — it overrides
406
+ // the typename `$id` written above.
394
407
  const echoIdentifier = annotations[TypeIdentifierAnnotationId];
395
408
  if (echoIdentifier) {
396
- schemaFields[ECHO_ANNOTATIONS_NS_KEY] ??= {};
397
- schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
409
+ schemaFields.$id = echoIdentifier;
398
410
  }
399
411
 
400
412
  // Custom (at end).
@@ -409,14 +421,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
409
421
  };
410
422
 
411
423
  const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
412
- // Limit to dxn:echo: URIs.
413
- 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:'))) {
414
426
  return schema.$id;
415
- } else if (schema.$id && schema.$id.startsWith('dxn:type:') && schema?.echo?.type?.schemaId) {
416
- const id = schema?.echo?.type?.schemaId;
417
- if (ObjectId.isValid(id)) {
418
- return DXN.fromLocalObjectId(id).toString();
419
- }
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;
420
432
  }
421
433
  return undefined;
422
434
  };
@@ -433,8 +445,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
433
445
  if (annotation.kind === EntityKind.Relation) {
434
446
  const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
435
447
  const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
436
- annotation.sourceSchema = DXN.parse(source).toString();
437
- 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}`));
438
450
  }
439
451
 
440
452
  return annotation;
@@ -470,7 +482,9 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
470
482
  if (typeAnnotation) {
471
483
  annotations[TypeAnnotationId] = typeAnnotation;
472
484
  annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
473
- 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),
474
488
  kind: typeAnnotation.kind,
475
489
  typename: typeAnnotation.typename,
476
490
  version: typeAnnotation.version,
@@ -7,7 +7,8 @@ import { deepMapValues } from '@dxos/util';
7
7
 
8
8
  import type * as Obj from '../../Obj';
9
9
  import { makeObject } from '../common/proxy';
10
- import { getMeta, getSchema } from '../common/types';
10
+ import { getSchema, getStaticTypeSchema, getType } from '../common/types';
11
+ import { getMeta } from '../common/types/meta';
11
12
  import { Ref } from '../Ref';
12
13
 
13
14
  /**
@@ -17,8 +18,12 @@ import { Ref } from '../Ref';
17
18
  */
18
19
  export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
19
20
  const { id, ...data } = obj;
20
- const schema = getSchema(obj);
21
- invariant(schema != null, 'Object should have a schema');
21
+ // Prefer cloning through the type entity so the cloned instance preserves
22
+ // `Obj.getType` identity. Falls back to the raw schema for older instances
23
+ // that don't have a type-entity back-reference set (e.g. deserialized).
24
+ const typeEntity = getType(obj);
25
+ const schema = typeEntity != null ? getStaticTypeSchema(typeEntity) : getSchema(obj);
26
+ invariant(schema != null, 'Object should have a type or schema');
22
27
  const props: any = deepMapValues(data, (value, recurse) => {
23
28
  if (Ref.isRef(value)) {
24
29
  if (opts?.deep) {
@@ -44,5 +49,5 @@ export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T =>
44
49
  return recurse(value);
45
50
  });
46
51
 
47
- return makeObject(schema, props, meta);
52
+ return makeObject(schema, props, meta, typeEntity as object | undefined);
48
53
  };
@@ -6,13 +6,15 @@ import * as Schema from 'effect/Schema';
6
6
  import { inspect } from 'util';
7
7
  import { describe, expect, test } from 'vitest';
8
8
 
9
- import { DXN } from '@dxos/keys';
9
+ import { DXN, EID } from '@dxos/keys';
10
10
 
11
11
  import { Relation } from '../../index';
12
12
  import { TestSchema } from '../../testing';
13
- import { getSchemaDXN, getTypeDXN, isInstanceOf } from '../Annotation';
14
- import { ATTR_META, ATTR_TYPE, getSchema } from '../common/types';
15
- import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET } from '../Entity';
13
+ import * as Type from '../../Type';
14
+ import { getTypeURI } from '../Annotation';
15
+ import { ATTR_TYPE, getSchema } from '../common/types';
16
+ import { ATTR_META } from '../common/types/meta';
17
+ import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, isInstanceOf } from '../Entity';
16
18
  import { createObject } from './create-object';
17
19
  import { objectToJSON } from './json-serializer';
18
20
 
@@ -40,7 +42,7 @@ describe('create (static version)', () => {
40
42
  expect(contact.name).toBe('Bot');
41
43
  expect(contact.email).toBe('bot@example.com');
42
44
  expect((contact as any)['@type']).toBeUndefined();
43
- expect(getTypeDXN(contact)?.toString()).toBe(getSchemaDXN(TestSchema.Person)!.toString());
45
+ expect(getTypeURI(contact)?.toString()).toBe(Type.getURI(TestSchema.Person).toString());
44
46
  expect(isInstanceOf(TestSchema.Person, contact)).toBe(true);
45
47
  });
46
48
 
@@ -53,7 +55,7 @@ describe('create (static version)', () => {
53
55
  const json = JSON.parse(JSON.stringify(contact));
54
56
  expect(json).toEqual({
55
57
  id: contact.id,
56
- '@type': DXN.fromTypenameAndVersion(TestSchema.Person.typename, TestSchema.Person.version).toString(),
58
+ '@type': DXN.make(Type.getTypename(TestSchema.Person), Type.getVersion(TestSchema.Person)),
57
59
  '@meta': {
58
60
  keys: [],
59
61
  },
@@ -81,9 +83,9 @@ describe('create (static version)', () => {
81
83
  const json = JSON.parse(JSON.stringify(manager));
82
84
  expect(json).toEqual({
83
85
  id: manager.id,
84
- [ATTR_TYPE]: DXN.fromTypenameAndVersion(TestSchema.HasManager.typename, TestSchema.HasManager.version).toString(),
85
- [ATTR_RELATION_SOURCE]: DXN.fromLocalObjectId(person1.id).toString(),
86
- [ATTR_RELATION_TARGET]: DXN.fromLocalObjectId(person2.id).toString(),
86
+ [ATTR_TYPE]: DXN.make(Type.getTypename(TestSchema.HasManager), Type.getVersion(TestSchema.HasManager)),
87
+ [ATTR_RELATION_SOURCE]: EID.make({ entityId: person1.id }),
88
+ [ATTR_RELATION_TARGET]: EID.make({ entityId: person2.id }),
87
89
  [ATTR_META]: {
88
90
  keys: [],
89
91
  },
@@ -96,7 +98,7 @@ describe('create (static version)', () => {
96
98
  email: 'bot@example.com',
97
99
  });
98
100
 
99
- expect(getSchema(contact)).toBe(TestSchema.Person);
101
+ expect(getSchema(contact)).toBe(Type.getSchema(TestSchema.Person));
100
102
  });
101
103
 
102
104
  test('inspect', () => {