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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/dist/lib/browser/{chunk-BIDAASFK.mjs → chunk-7GH6RXJ3.mjs} +2246 -2290
  2. package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
  4. package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +18 -8
  6. package/dist/lib/browser/internal/index.mjs +45 -45
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +252 -191
  9. package/dist/lib/browser/testing/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
  11. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
  12. package/dist/lib/node-esm/{chunk-3SVRRCUU.mjs → chunk-M4B6BMD2.mjs} +2246 -2290
  13. package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
  14. package/dist/lib/node-esm/index.mjs +18 -8
  15. package/dist/lib/node-esm/internal/index.mjs +45 -45
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +252 -191
  18. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  19. package/dist/types/src/Annotation.d.ts +2 -0
  20. package/dist/types/src/Annotation.d.ts.map +1 -0
  21. package/dist/types/src/Database.d.ts +137 -0
  22. package/dist/types/src/Database.d.ts.map +1 -0
  23. package/dist/types/src/Entity.d.ts +36 -0
  24. package/dist/types/src/Entity.d.ts.map +1 -0
  25. package/dist/types/src/Format.d.ts +4 -0
  26. package/dist/types/src/Format.d.ts.map +1 -0
  27. package/dist/types/src/JsonSchema.d.ts +9 -0
  28. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  29. package/dist/types/src/Key.d.ts +1 -0
  30. package/dist/types/src/Key.d.ts.map +1 -1
  31. package/dist/types/src/Obj.d.ts +79 -70
  32. package/dist/types/src/Obj.d.ts.map +1 -1
  33. package/dist/types/src/Ref.d.ts +10 -10
  34. package/dist/types/src/Ref.d.ts.map +1 -1
  35. package/dist/types/src/Relation.d.ts +14 -11
  36. package/dist/types/src/Relation.d.ts.map +1 -1
  37. package/dist/types/src/Tag.d.ts +1 -1
  38. package/dist/types/src/Tag.d.ts.map +1 -1
  39. package/dist/types/src/Type.d.ts +39 -49
  40. package/dist/types/src/Type.d.ts.map +1 -1
  41. package/dist/types/src/index.d.ts +6 -3
  42. package/dist/types/src/index.d.ts.map +1 -1
  43. package/dist/types/src/internal/annotations/annotations.d.ts +174 -0
  44. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  45. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  46. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  47. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  48. package/dist/types/src/internal/annotations/util.d.ts +26 -0
  49. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  50. package/dist/types/src/internal/entities/entity.d.ts +10 -0
  51. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  52. package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
  53. package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
  54. package/dist/types/src/internal/entities/index.d.ts +6 -0
  55. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  56. package/dist/types/src/internal/entities/model.d.ts +70 -0
  57. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  58. package/dist/types/src/internal/entities/object.d.ts +11 -0
  59. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  60. package/dist/types/src/internal/entities/relation.d.ts +55 -0
  61. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  62. package/dist/types/src/internal/entities/util.d.ts +2 -0
  63. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  64. package/dist/types/src/internal/formats/format.d.ts +2 -0
  65. package/dist/types/src/internal/formats/format.d.ts.map +1 -1
  66. package/dist/types/src/internal/formats/types.d.ts +7 -7
  67. package/dist/types/src/internal/formats/types.d.ts.map +1 -1
  68. package/dist/types/src/internal/index.d.ts +6 -10
  69. package/dist/types/src/internal/index.d.ts.map +1 -1
  70. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  71. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  72. package/dist/types/src/internal/json-schema/index.d.ts +2 -0
  73. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
  74. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
  75. package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -1
  76. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  77. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  78. package/dist/types/src/internal/object/common.d.ts.map +1 -1
  79. package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +8 -9
  80. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  81. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  82. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  83. package/dist/types/src/internal/object/deleted.d.ts +2 -2
  84. package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
  85. package/dist/types/src/internal/object/ids.d.ts.map +1 -1
  86. package/dist/types/src/internal/object/index.d.ts +3 -11
  87. package/dist/types/src/internal/object/index.d.ts.map +1 -1
  88. package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
  89. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
  90. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
  91. package/dist/types/src/internal/object/typed-object.d.ts +1 -1
  92. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
  93. package/dist/types/src/internal/proxy/index.d.ts +3 -0
  94. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  95. package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
  96. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  97. package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
  98. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
  99. package/dist/types/src/internal/ref/ref.d.ts +15 -12
  100. package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
  101. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  102. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  103. package/dist/types/src/internal/schema/echo-schema.d.ts +9 -9
  104. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
  105. package/dist/types/src/internal/schema/index.d.ts +3 -4
  106. package/dist/types/src/internal/schema/index.d.ts.map +1 -1
  107. package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
  108. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  109. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
  110. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
  111. package/dist/types/src/internal/types/base.d.ts +37 -0
  112. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  113. package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
  114. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  115. package/dist/types/src/internal/types/index.d.ts +5 -2
  116. package/dist/types/src/internal/types/index.d.ts.map +1 -1
  117. package/dist/types/src/internal/{object → types}/meta.d.ts +20 -11
  118. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  119. package/dist/types/src/internal/types/typename.d.ts +13 -0
  120. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  121. package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
  122. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  123. package/dist/types/src/query/filter.d.ts +167 -0
  124. package/dist/types/src/query/filter.d.ts.map +1 -0
  125. package/dist/types/src/query/index.d.ts +3 -0
  126. package/dist/types/src/query/index.d.ts.map +1 -1
  127. package/dist/types/src/query/order.d.ts +12 -0
  128. package/dist/types/src/query/order.d.ts.map +1 -0
  129. package/dist/types/src/query/query.d.ts +9 -145
  130. package/dist/types/src/query/query.d.ts.map +1 -1
  131. package/dist/types/src/query/testing.d.ts +51 -0
  132. package/dist/types/src/query/testing.d.ts.map +1 -0
  133. package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
  134. package/dist/types/src/query/types.d.ts.map +1 -0
  135. package/dist/types/src/query/util.d.ts +8 -0
  136. package/dist/types/src/query/util.d.ts.map +1 -0
  137. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  138. package/dist/types/src/testing/index.d.ts +3 -3
  139. package/dist/types/src/testing/index.d.ts.map +1 -1
  140. package/dist/types/src/testing/test-data.d.ts +18 -0
  141. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  142. package/dist/types/src/testing/{types.d.ts → test-schema.d.ts} +166 -57
  143. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  144. package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
  145. package/dist/types/src/testing/util.d.ts.map +1 -0
  146. package/dist/types/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +46 -38
  148. package/src/Annotation.ts +17 -0
  149. package/src/Database.ts +189 -0
  150. package/src/Entity.ts +51 -0
  151. package/src/Format.ts +11 -0
  152. package/src/JsonSchema.ts +16 -0
  153. package/src/Key.ts +3 -0
  154. package/src/Obj.ts +248 -181
  155. package/src/Ref.ts +9 -9
  156. package/src/Relation.ts +58 -44
  157. package/src/Tag.ts +2 -1
  158. package/src/Type.ts +96 -83
  159. package/src/index.ts +9 -4
  160. package/src/internal/README.md +83 -0
  161. package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
  162. package/src/internal/annotations/annotations.ts +463 -0
  163. package/src/internal/annotations/index.ts +6 -0
  164. package/src/internal/annotations/util.ts +70 -0
  165. package/src/internal/entities/entity.ts +109 -0
  166. package/src/internal/{object → entities}/expando.ts +7 -5
  167. package/src/internal/entities/index.ts +9 -0
  168. package/src/internal/{object → entities}/model.ts +49 -90
  169. package/src/internal/entities/object.ts +45 -0
  170. package/src/internal/entities/relation.ts +155 -0
  171. package/src/internal/entities/util.ts +33 -0
  172. package/src/internal/formats/date.test.ts +1 -1
  173. package/src/internal/formats/date.ts +5 -5
  174. package/src/internal/formats/format.test.ts +5 -5
  175. package/src/internal/formats/format.ts +3 -0
  176. package/src/internal/formats/number.ts +5 -5
  177. package/src/internal/formats/object.ts +2 -2
  178. package/src/internal/formats/string.ts +9 -9
  179. package/src/internal/formats/types.ts +44 -39
  180. package/src/internal/index.ts +29 -13
  181. package/src/internal/{json → json-schema}/annotations.ts +1 -1
  182. package/src/internal/json-schema/index.ts +2 -0
  183. package/src/internal/json-schema/json-schema-type.ts +4 -3
  184. package/src/internal/{json → json-schema}/json-schema.test.ts +48 -38
  185. package/src/internal/{json → json-schema}/json-schema.ts +16 -7
  186. package/src/internal/object/common.ts +3 -4
  187. package/src/internal/object/{create.test.ts → create-object.test.ts} +30 -32
  188. package/src/internal/object/{create.ts → create-object.ts} +33 -34
  189. package/src/internal/object/deleted.ts +6 -6
  190. package/src/internal/object/ids.ts +1 -1
  191. package/src/internal/object/index.ts +3 -11
  192. package/src/internal/object/inspect.ts +3 -5
  193. package/src/internal/object/json-serializer.test.ts +33 -38
  194. package/src/internal/object/json-serializer.ts +43 -38
  195. package/src/internal/object/schema-validator.ts +3 -2
  196. package/src/internal/object/typed-object.test.ts +1 -1
  197. package/src/internal/object/typed-object.ts +11 -5
  198. package/src/internal/proxy/handler.test.ts +30 -20
  199. package/src/internal/proxy/index.ts +6 -0
  200. package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
  201. package/src/internal/proxy/schema.test.ts +5 -4
  202. package/src/internal/proxy/typed-handler.test.ts +28 -28
  203. package/src/internal/proxy/typed-handler.ts +8 -3
  204. package/src/internal/proxy/typed-object.test.ts +16 -11
  205. package/src/internal/ref/ref.test.ts +8 -7
  206. package/src/internal/ref/ref.ts +24 -20
  207. package/src/internal/{projection → schema}/compose.test.ts +5 -6
  208. package/src/internal/{projection → schema}/compose.ts +2 -1
  209. package/src/internal/schema/echo-schema.ts +30 -28
  210. package/src/internal/schema/index.ts +3 -4
  211. package/src/internal/schema/manipulation.ts +1 -1
  212. package/src/internal/schema/persistent-schema.ts +28 -0
  213. package/src/internal/schema/runtime-schema-registry.ts +4 -4
  214. package/src/internal/types/base.ts +58 -0
  215. package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
  216. package/src/internal/types/index.ts +5 -2
  217. package/src/internal/{object → types}/meta.ts +32 -17
  218. package/src/internal/types/typename.ts +45 -0
  219. package/src/internal/types/version.ts +20 -0
  220. package/src/query/filter.ts +455 -0
  221. package/src/query/index.ts +4 -1
  222. package/src/query/order.ts +34 -0
  223. package/src/query/query.test.ts +48 -115
  224. package/src/query/query.ts +16 -502
  225. package/src/query/testing.ts +64 -0
  226. package/src/query/util.ts +25 -0
  227. package/src/testing/api.test.ts +100 -0
  228. package/src/testing/index.ts +3 -3
  229. package/src/testing/test-data.ts +130 -0
  230. package/src/testing/test-schema.ts +213 -0
  231. package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
  232. package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
  233. package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
  234. package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
  235. package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
  236. package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
  237. package/dist/lib/browser/query/index.mjs +0 -13
  238. package/dist/lib/browser/query/index.mjs.map +0 -7
  239. package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
  240. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
  241. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
  242. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
  243. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
  244. package/dist/lib/node-esm/query/index.mjs +0 -13
  245. package/dist/lib/node-esm/query/index.mjs.map +0 -7
  246. package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
  247. package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
  248. package/dist/types/src/internal/ast/annotations.d.ts +0 -131
  249. package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
  250. package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
  251. package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
  252. package/dist/types/src/internal/ast/index.d.ts +0 -5
  253. package/dist/types/src/internal/ast/index.d.ts.map +0 -1
  254. package/dist/types/src/internal/ast/types.d.ts +0 -6
  255. package/dist/types/src/internal/ast/types.d.ts.map +0 -1
  256. package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
  257. package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
  258. package/dist/types/src/internal/json/index.d.ts +0 -2
  259. package/dist/types/src/internal/json/index.d.ts.map +0 -1
  260. package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
  261. package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
  262. package/dist/types/src/internal/object/accessors.d.ts +0 -37
  263. package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
  264. package/dist/types/src/internal/object/create.d.ts.map +0 -1
  265. package/dist/types/src/internal/object/create.test.d.ts +0 -2
  266. package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
  267. package/dist/types/src/internal/object/entity.d.ts +0 -33
  268. package/dist/types/src/internal/object/entity.d.ts.map +0 -1
  269. package/dist/types/src/internal/object/expando.d.ts.map +0 -1
  270. package/dist/types/src/internal/object/meta.d.ts.map +0 -1
  271. package/dist/types/src/internal/object/model.d.ts +0 -117
  272. package/dist/types/src/internal/object/model.d.ts.map +0 -1
  273. package/dist/types/src/internal/object/relation.d.ts +0 -17
  274. package/dist/types/src/internal/object/relation.d.ts.map +0 -1
  275. package/dist/types/src/internal/object/typename.d.ts +0 -15
  276. package/dist/types/src/internal/object/typename.d.ts.map +0 -1
  277. package/dist/types/src/internal/object/version.d.ts.map +0 -1
  278. package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
  279. package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
  280. package/dist/types/src/internal/projection/index.d.ts +0 -2
  281. package/dist/types/src/internal/projection/index.d.ts.map +0 -1
  282. package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
  283. package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
  284. package/dist/types/src/internal/query/index.d.ts +0 -2
  285. package/dist/types/src/internal/query/index.d.ts.map +0 -1
  286. package/dist/types/src/internal/query/query.d.ts.map +0 -1
  287. package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
  288. package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
  289. package/dist/types/src/internal/testing/index.d.ts +0 -3
  290. package/dist/types/src/internal/testing/index.d.ts.map +0 -1
  291. package/dist/types/src/internal/testing/types.d.ts +0 -381
  292. package/dist/types/src/internal/testing/types.d.ts.map +0 -1
  293. package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
  294. package/dist/types/src/internal/types/types.d.ts +0 -79
  295. package/dist/types/src/internal/types/types.d.ts.map +0 -1
  296. package/dist/types/src/internal/types/types.test.d.ts +0 -2
  297. package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
  298. package/dist/types/src/internal/types/util.d.ts +0 -5
  299. package/dist/types/src/internal/types/util.d.ts.map +0 -1
  300. package/dist/types/src/testing/echo-schema.d.ts +0 -7
  301. package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
  302. package/dist/types/src/testing/types.d.ts.map +0 -1
  303. package/src/internal/ast/annotation-helper.ts +0 -22
  304. package/src/internal/ast/annotations.ts +0 -226
  305. package/src/internal/ast/index.ts +0 -8
  306. package/src/internal/ast/types.ts +0 -17
  307. package/src/internal/json/index.ts +0 -5
  308. package/src/internal/object/accessors.ts +0 -153
  309. package/src/internal/object/entity.ts +0 -248
  310. package/src/internal/object/relation.ts +0 -24
  311. package/src/internal/object/typename.ts +0 -61
  312. package/src/internal/object/version.ts +0 -22
  313. package/src/internal/projection/index.ts +0 -5
  314. package/src/internal/query/index.ts +0 -5
  315. package/src/internal/schema/stored-schema.ts +0 -26
  316. package/src/internal/testing/index.ts +0 -6
  317. package/src/internal/testing/types.ts +0 -144
  318. package/src/internal/types/types.test.ts +0 -48
  319. package/src/internal/types/types.ts +0 -176
  320. package/src/internal/types/util.ts +0 -9
  321. package/src/test/api.test.ts +0 -180
  322. package/src/testing/echo-schema.ts +0 -39
  323. package/src/testing/types.ts +0 -108
  324. /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
  325. /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
  326. /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
  327. /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
  328. /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
  329. /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
  330. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
  331. /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
  332. /package/src/{internal/query/query.ts → query/types.ts} +0 -0
package/src/Obj.ts CHANGED
@@ -5,32 +5,63 @@
5
5
  import * as Function from 'effect/Function';
6
6
  import * as Schema from 'effect/Schema';
7
7
 
8
+ import { type ForeignKey } from '@dxos/echo-protocol';
8
9
  import { assertArgument, invariant } from '@dxos/invariant';
9
- import { type DXN } from '@dxos/keys';
10
- import * as LiveObject from '@dxos/live-object';
10
+ import { type DXN, ObjectId } from '@dxos/keys';
11
+ import { getSnapshot as getSnapshot$ } from '@dxos/live-object';
11
12
  import { assumeType, deepMapValues } from '@dxos/util';
12
13
 
13
- import { live } from './internal';
14
- import * as EchoSchema from './internal';
15
- import type * as Ref from './Ref';
16
- import type * as Relation from './Relation';
14
+ import * as Entity from './Entity';
15
+ import {
16
+ type AnyEchoObject,
17
+ type AnyProperties,
18
+ type InternalObjectProps,
19
+ MetaId,
20
+ type ObjectJSON,
21
+ type ObjectMeta,
22
+ ObjectVersionId,
23
+ VersionTypeId,
24
+ getDescription as getDescription$,
25
+ getLabel as getLabel$,
26
+ getMeta as getMeta$,
27
+ getObjectDXN,
28
+ getSchema as getSchema$,
29
+ getSchemaTypename,
30
+ getTypeAnnotation,
31
+ getTypeDXN as getTypeDXN$,
32
+ isDeleted as isDeleted$,
33
+ isInstanceOf,
34
+ makeObject,
35
+ objectFromJSON,
36
+ objectToJSON,
37
+ setDescription as setDescription$,
38
+ setLabel as setLabel$,
39
+ } from './internal';
40
+ import * as Ref from './Ref';
17
41
  import * as Type from './Type';
18
42
 
19
43
  /**
20
- * NOTE: Don't export: Obj.Any and Obj.Obj form the public API.
44
+ * Base type for all ECHO objects.
45
+ * @private
21
46
  */
22
- interface BaseObj extends EchoSchema.HasId, Type.OfKind<EchoSchema.EntityKind.Object> {}
47
+ interface BaseObj extends AnyEchoObject, Entity.OfKind<typeof Entity.Kind.Object> {}
23
48
 
24
49
  /**
25
- * Object type with specific properties.
50
+ * Base type for all Obj objects.
26
51
  */
27
- export type Obj<Props> = BaseObj & Props;
52
+ export interface Any extends BaseObj {}
53
+
54
+ export const Any = Schema.Struct({}).pipe(
55
+ Type.Obj({
56
+ typename: 'dxos.org/type/Any',
57
+ version: '0.1.0',
58
+ }),
59
+ );
28
60
 
29
61
  /**
30
- * Base type for all ECHO objects.
31
- * This type does not define any properties.
62
+ * Object type with specific properties.
32
63
  */
33
- export interface Any extends BaseObj {}
64
+ export type Obj<Props> = BaseObj & Props;
34
65
 
35
66
  /**
36
67
  * Object with arbitrary properties.
@@ -38,31 +69,25 @@ export interface Any extends BaseObj {}
38
69
  * NOTE: Due to how typescript works, this type is not assignable to a specific schema type.
39
70
  * In that case, use `Obj.instanceOf` to check if an object is of a specific type.
40
71
  */
41
- export interface AnyProps extends BaseObj {
42
- [key: string]: any;
43
- }
44
-
45
- export const Any = Schema.Struct({}).pipe(
46
- Type.Obj({
47
- typename: 'dxos.org/types/Any',
48
- version: '0.1.0',
49
- }),
50
- );
72
+ export interface AnyProps extends BaseObj, AnyProperties {}
51
73
 
52
- type Props<T = any> = { id?: EchoSchema.ObjectId } & Type.Properties<T>;
53
-
54
- export type MakeProps<T extends Type.Obj.Any> = NoInfer<Props<Schema.Schema.Type<T>>> & {
55
- [Meta]?: Partial<EchoSchema.ObjectMeta>;
74
+ const defaultMeta: ObjectMeta = {
75
+ keys: [],
56
76
  };
57
77
 
58
- export const Meta: unique symbol = EchoSchema.MetaId as any;
78
+ type Props<T = any> = {
79
+ id?: ObjectId;
80
+ [Meta]?: Partial<ObjectMeta>;
81
+ } & Type.Properties<T>;
59
82
 
60
- const DEFAULT_META: EchoSchema.ObjectMeta = {
61
- keys: [],
62
- };
83
+ // TODO(burdon): Should we allow the caller to set the id?
84
+ export type MakeProps<T extends Schema.Schema.AnyNoContext> = {
85
+ id?: ObjectId;
86
+ [Meta]?: Partial<ObjectMeta>;
87
+ } & NoInfer<Props<Schema.Schema.Type<T>>>;
63
88
 
64
89
  /**
65
- * Creates new object.
90
+ * Creates a new object of the given types.
66
91
  * @param schema - Object schema.
67
92
  * @param props - Object properties.
68
93
  * @param meta - Object metadata (deprecated) -- pass with Obj.Meta.
@@ -74,40 +99,96 @@ const DEFAULT_META: EchoSchema.ObjectMeta = {
74
99
  * const obj = Obj.make(Person, { [Obj.Meta]: { keys: [...] }, name: 'John' });
75
100
  * ```
76
101
  */
77
- export const make = <S extends Type.Obj.Any>(
102
+ export const make = <S extends Schema.Schema.AnyNoContext>(
78
103
  schema: S,
79
104
  props: MakeProps<S>,
80
- meta?: Partial<EchoSchema.ObjectMeta>,
81
- ): LiveObject.Live<Schema.Schema.Type<S>> => {
82
- assertArgument(
83
- EchoSchema.getTypeAnnotation(schema)?.kind === EchoSchema.EntityKind.Object,
84
- 'schema',
85
- 'Expected an object schema',
86
- );
87
-
88
- if (props[EchoSchema.MetaId] != null) {
89
- // Set default fields on meta on creation.
90
- meta = { ...structuredClone(DEFAULT_META), ...props[EchoSchema.MetaId] };
91
- delete props[EchoSchema.MetaId];
105
+ meta?: Partial<ObjectMeta>,
106
+ ): Obj<Schema.Schema.Type<S>> => {
107
+ assertArgument(getTypeAnnotation(schema)?.kind === Entity.Kind.Object, 'schema', 'Expected an object schema');
108
+
109
+ // Set default fields on meta on creation.
110
+ if (props[MetaId] != null) {
111
+ meta = { ...structuredClone(defaultMeta), ...props[MetaId] };
112
+ delete props[MetaId];
92
113
  }
93
114
 
115
+ // Filter undefined values.
94
116
  const filterUndefined = Object.fromEntries(Object.entries(props).filter(([_, v]) => v !== undefined));
95
117
 
96
- return live<Schema.Schema.Type<S>>(schema, filterUndefined as any, { keys: [], ...meta });
118
+ return makeObject<Schema.Schema.Type<S>>(schema, filterUndefined as any, {
119
+ ...defaultMeta,
120
+ ...meta,
121
+ });
97
122
  };
98
123
 
124
+ /**
125
+ * Determine if object is an ECHO object.
126
+ */
99
127
  export const isObject = (obj: unknown): obj is Any => {
100
- assumeType<EchoSchema.InternalObjectProps>(obj);
101
- return typeof obj === 'object' && obj !== null && obj[EchoSchema.EntityKindId] === EchoSchema.EntityKind.Object;
128
+ assumeType<InternalObjectProps>(obj);
129
+ return typeof obj === 'object' && obj !== null && obj[Entity.KindId] === Entity.Kind.Object;
130
+ };
131
+
132
+ //
133
+ // Snapshot
134
+ //
135
+
136
+ /**
137
+ * Returns an immutable snapshot of an object.
138
+ */
139
+ export const getSnapshot: <T extends Any>(obj: Obj<T>) => T = getSnapshot$;
140
+
141
+ export type CloneOptions = {
142
+ /**
143
+ * Retain the original object's ID.
144
+ * @default false
145
+ */
146
+ retainId?: boolean;
147
+ };
148
+
149
+ /**
150
+ * Clones an object or relation.
151
+ * This does not clone referenced objects, only the properties in the object.
152
+ * @returns A new object with the same schema and properties.
153
+ */
154
+ export const clone = <T extends Any>(obj: T, opts?: CloneOptions): T => {
155
+ const { id, ...data } = obj;
156
+ const schema = getSchema$(obj);
157
+ invariant(schema != null, 'Object should have a schema');
158
+ const props: any = deepMapValues(data, (value, recurse) => {
159
+ if (Ref.isRef(value)) {
160
+ return value;
161
+ }
162
+ return recurse(value);
163
+ });
164
+
165
+ if (opts?.retainId) {
166
+ props.id = id;
167
+ }
168
+ const meta = getMeta(obj);
169
+ props[MetaId] = deepMapValues(meta, (value, recurse) => {
170
+ if (Ref.isRef(value)) {
171
+ return value;
172
+ }
173
+ return recurse(value);
174
+ });
175
+
176
+ return make(schema as Type.Obj.Any, props);
102
177
  };
103
178
 
179
+ //
180
+ // Type
181
+ //
182
+
183
+ // TODO(burdon): To discuss: prefer over ObjectId or Key.ObjectId or Type.ID?
184
+ export const ID = ObjectId;
185
+ export type ID = ObjectId;
186
+
104
187
  /**
105
188
  * Test if object or relation is an instance of a schema.
106
189
  * @example
107
190
  * ```ts
108
191
  * const john = Obj.make(Person, { name: 'John' });
109
- * const johnIsPerson = Obj.instanceOf(Person)(john);
110
- *
111
192
  * const isPerson = Obj.instanceOf(Person);
112
193
  * if (isPerson(john)) {
113
194
  * // john is Person
@@ -115,24 +196,20 @@ export const isObject = (obj: unknown): obj is Any => {
115
196
  * ```
116
197
  */
117
198
  export const instanceOf: {
118
- <S extends Type.Relation.Any | Type.Obj.Any>(schema: S): (value: unknown) => value is Schema.Schema.Type<S>;
119
- <S extends Type.Relation.Any | Type.Obj.Any>(schema: S, value: unknown): value is Schema.Schema.Type<S>;
120
- } = ((
121
- ...args: [schema: Type.Relation.Any | Type.Obj.Any, value: unknown] | [schema: Type.Relation.Any | Type.Obj.Any]
122
- ) => {
199
+ <S extends Type.Entity.Any>(schema: S): (value: unknown) => value is Schema.Schema.Type<S>;
200
+ <S extends Type.Entity.Any>(schema: S, value: unknown): value is Schema.Schema.Type<S>;
201
+ } = ((...args: [schema: Type.Entity.Any, value: unknown] | [schema: Type.Entity.Any]) => {
123
202
  if (args.length === 1) {
124
- return (obj: unknown) => EchoSchema.isInstanceOf(args[0], obj);
203
+ return (entity: unknown) => isInstanceOf(args[0], entity);
125
204
  }
126
205
 
127
- return EchoSchema.isInstanceOf(args[0], args[1]);
206
+ return isInstanceOf(args[0], args[1]);
128
207
  }) as any;
129
208
 
130
- export const getSchema = EchoSchema.getSchema;
131
-
132
209
  // TODO(dmaretskyi): Allow returning undefined.
133
- export const getDXN = (obj: Any | Relation.Any): DXN => {
134
- assertArgument(!Schema.isSchema(obj), 'obj', 'Object should not be a schema.');
135
- const dxn = EchoSchema.getObjectDXN(obj);
210
+ export const getDXN = (entity: Entity.Unknown): DXN => {
211
+ assertArgument(!Schema.isSchema(entity), 'obj', 'Object should not be a schema.');
212
+ const dxn = getObjectDXN(entity);
136
213
  invariant(dxn != null, 'Invalid object.');
137
214
  return dxn;
138
215
  };
@@ -141,26 +218,38 @@ export const getDXN = (obj: Any | Relation.Any): DXN => {
141
218
  * @returns The DXN of the object's type.
142
219
  * @example dxn:example.com/type/Person:1.0.0
143
220
  */
144
- // TODO(burdon): Expando does not have a type.
145
- export const getTypeDXN = EchoSchema.getType;
221
+ // TODO(burdon): Must define and return type for expando.
222
+ export const getTypeDXN = getTypeDXN$;
223
+
224
+ /**
225
+ * Get the schema of the object.
226
+ */
227
+ export const getSchema = getSchema$;
146
228
 
147
229
  /**
148
230
  * @returns The typename of the object's type.
149
231
  * @example `example.com/type/Person`
150
232
  */
151
- export const getTypename = (obj: Any | Relation.Any): string | undefined => {
152
- const schema = getSchema(obj);
233
+ export const getTypename = (entity: Entity.Unknown): string | undefined => {
234
+ const schema = getSchema$(entity);
153
235
  if (schema == null) {
154
236
  // Try to extract typename from DXN.
155
- return EchoSchema.getType(obj)?.asTypeDXN()?.type;
237
+ return getTypeDXN$(entity)?.asTypeDXN()?.type;
156
238
  }
157
239
 
158
- return EchoSchema.getSchemaTypename(schema);
240
+ return getSchemaTypename(schema);
159
241
  };
160
242
 
243
+ //
244
+ // Meta
245
+ //
246
+
247
+ export const Meta: unique symbol = MetaId as any;
248
+
249
+ // TODO(burdon): Narrow type.
161
250
  // TODO(dmaretskyi): Allow returning undefined.
162
- export const getMeta = (obj: Any | Relation.Any): EchoSchema.ObjectMeta => {
163
- const meta = EchoSchema.getMeta(obj);
251
+ export const getMeta = (entity: AnyProperties): ObjectMeta => {
252
+ const meta = getMeta$(entity);
164
253
  invariant(meta != null, 'Invalid object.');
165
254
  return meta;
166
255
  };
@@ -169,21 +258,21 @@ export const getMeta = (obj: Any | Relation.Any): EchoSchema.ObjectMeta => {
169
258
  * @returns Foreign keys for the object from the specified source.
170
259
  */
171
260
  export const getKeys: {
172
- (obj: Any | Relation.Any, source: string): EchoSchema.ForeignKey[];
173
- (source: string): (obj: Any | Relation.Any) => EchoSchema.ForeignKey[];
174
- } = Function.dual(2, (obj: Any | Relation.Any, source?: string): EchoSchema.ForeignKey[] => {
175
- const meta = EchoSchema.getMeta(obj);
261
+ (entity: Entity.Unknown, source: string): ForeignKey[];
262
+ (source: string): (entity: Entity.Unknown) => ForeignKey[];
263
+ } = Function.dual(2, (entity: Entity.Unknown, source?: string): ForeignKey[] => {
264
+ const meta = getMeta(entity);
176
265
  invariant(meta != null, 'Invalid object.');
177
266
  return meta.keys.filter((key) => key.source === source);
178
267
  });
179
268
 
180
269
  /**
181
270
  * Delete all keys from the object for the specified source.
182
- * @param obj
271
+ * @param entity
183
272
  * @param source
184
273
  */
185
- export const deleteKeys = (obj: Any | Relation.Any, source: string) => {
186
- const meta = EchoSchema.getMeta(obj);
274
+ export const deleteKeys = (entity: Entity.Unknown, source: string) => {
275
+ const meta = getMeta(entity);
187
276
  for (let i = 0; i < meta.keys.length; i++) {
188
277
  if (meta.keys[i].source === source) {
189
278
  meta.keys.splice(i, 1);
@@ -192,59 +281,95 @@ export const deleteKeys = (obj: Any | Relation.Any, source: string) => {
192
281
  }
193
282
  };
194
283
 
284
+ export const addTag = (entity: Entity.Unknown, tag: string) => {
285
+ const meta = getMeta(entity);
286
+ meta.tags ??= [];
287
+ meta.tags.push(tag);
288
+ };
289
+
290
+ export const removeTag = (entity: Entity.Unknown, tag: string) => {
291
+ const meta = getMeta(entity);
292
+ if (!meta.tags) {
293
+ return;
294
+ }
295
+ for (let i = 0; i < meta.tags.length; i++) {
296
+ if (meta.tags[i] === tag) {
297
+ meta.tags.splice(i, 1);
298
+ i--;
299
+ }
300
+ }
301
+ };
302
+
195
303
  // TODO(dmaretskyi): Default to `false`.
196
- export const isDeleted = (obj: Any | Relation.Any): boolean => {
197
- const deleted = EchoSchema.isDeleted(obj);
304
+ export const isDeleted = (entity: Entity.Unknown): boolean => {
305
+ const deleted = isDeleted$(entity);
198
306
  invariant(typeof deleted === 'boolean', 'Invalid object.');
199
307
  return deleted;
200
308
  };
201
309
 
202
- export const getLabel = (obj: Any | Relation.Any): string | undefined => {
203
- const schema = getSchema(obj);
310
+ //
311
+ // Annotations
312
+ //
313
+
314
+ export const getLabel = (entity: Entity.Unknown): string | undefined => {
315
+ const schema = getSchema$(entity);
204
316
  if (schema != null) {
205
- return EchoSchema.getLabel(schema, obj);
317
+ return getLabel$(schema, entity);
206
318
  }
207
319
  };
208
320
 
209
- export const setLabel = (obj: Any | Relation.Any, label: string) => {
210
- const schema = getSchema(obj);
321
+ export const setLabel = (entity: Entity.Unknown, label: string) => {
322
+ const schema = getSchema$(entity);
211
323
  if (schema != null) {
212
- EchoSchema.setLabel(schema, obj, label);
324
+ setLabel$(schema, entity, label);
213
325
  }
214
326
  };
215
327
 
216
- export const getDescription = (obj: Any | Relation.Any): string | undefined => {
217
- const schema = getSchema(obj);
328
+ export const getDescription = (entity: Entity.Unknown): string | undefined => {
329
+ const schema = getSchema$(entity);
218
330
  if (schema != null) {
219
- return EchoSchema.getDescription(schema, obj);
331
+ return getDescription$(schema, entity);
220
332
  }
221
333
  };
222
334
 
223
- export const setDescription = (obj: Any | Relation.Any, description: string) => {
224
- const schema = getSchema(obj);
335
+ export const setDescription = (entity: Entity.Unknown, description: string) => {
336
+ const schema = getSchema$(entity);
225
337
  if (schema != null) {
226
- EchoSchema.setDescription(schema, obj, description);
338
+ setDescription$(schema, entity, description);
227
339
  }
228
340
  };
229
341
 
230
- export const addTag = (obj: Any | Relation.Any, tag: string) => {
231
- const meta = getMeta(obj);
232
- meta.tags ??= [];
233
- meta.tags.push(tag);
234
- };
342
+ //
343
+ // JSON
344
+ //
235
345
 
236
- export const removeTag = (obj: Any | Relation.Any, tag: string) => {
237
- const meta = getMeta(obj);
238
- if (!meta.tags) {
239
- return;
240
- }
241
- for (let i = 0; i < meta.tags.length; i++) {
242
- if (meta.tags[i] === tag) {
243
- meta.tags.splice(i, 1);
244
- i--;
245
- }
246
- }
247
- };
346
+ /**
347
+ * JSON representation of an object.
348
+ */
349
+ export type JSON = ObjectJSON;
350
+
351
+ /**
352
+ * Converts object to its JSON representation.
353
+ *
354
+ * The same algorithm is used when calling the standard `JSON.stringify(obj)` function.
355
+ */
356
+ export const toJSON = (entity: Entity.Unknown): JSON => objectToJSON(entity);
357
+
358
+ /**
359
+ * Creates an object from its json representation, performing schema validation.
360
+ * References and schemas will be resolvable if the `refResolver` is provided.
361
+ *
362
+ * The function must be async to support resolving the schema as well as the relation endpoints.
363
+ *
364
+ * @param options.refResolver - Resolver for references. Produces hydrated references that can be resolved.
365
+ * @param options.dxn - Override object DXN. Changes the result of `Obj.getDXN`.
366
+ */
367
+ export const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver; dxn?: DXN }) => Promise<Any> =
368
+ objectFromJSON as any;
369
+
370
+ //
371
+ // Sorting
372
+ //
248
373
 
249
374
  const compare = (a?: string, b?: string) => {
250
375
  if (a == null) {
@@ -258,12 +383,13 @@ const compare = (a?: string, b?: string) => {
258
383
  return a.localeCompare(b);
259
384
  };
260
385
 
261
- export type Comparator = (a: Any, b: Any) => number;
386
+ export type Comparator = (a: Entity.Unknown, b: Entity.Unknown) => number;
262
387
 
263
- export const sortByLabel: Comparator = (a: Any, b: Any) => compare(getLabel(a), getLabel(b));
264
- export const sortByTypename: Comparator = (a: Any, b: Any) => compare(getTypename(a), getTypename(b));
388
+ export const sortByLabel: Comparator = (a: Entity.Unknown, b: Entity.Unknown) => compare(getLabel(a), getLabel(b));
389
+ export const sortByTypename: Comparator = (a: Entity.Unknown, b: Entity.Unknown) =>
390
+ compare(getTypename(a), getTypename(b));
265
391
  export const sort = (...comparators: Comparator[]): Comparator => {
266
- return (a: Any, b: Any) => {
392
+ return (a: Entity.Unknown, b: Entity.Unknown) => {
267
393
  for (const comparator of comparators) {
268
394
  const result = comparator(a, b);
269
395
  if (result !== 0) {
@@ -275,74 +401,14 @@ export const sort = (...comparators: Comparator[]): Comparator => {
275
401
  };
276
402
  };
277
403
 
278
- /**
279
- * JSON representation of an object.
280
- */
281
- export type JSON = EchoSchema.ObjectJSON;
282
-
283
- /**
284
- * Converts object to its JSON representation.
285
- *
286
- * The same algorithm is used when calling the standard `JSON.stringify(obj)` function.
287
- */
288
- // TODO(burdon): Base util type for Obj/Relation?
289
- export const toJSON = (obj: Any | Relation.Any): JSON => EchoSchema.objectToJSON(obj);
290
-
291
- /**
292
- * Creates an object from its json representation, performing schema validation.
293
- * References and schemas will be resolvable if the `refResolver` is provided.
294
- *
295
- * The function need to be async to support resolving the schema as well as the relation endpoints.
296
- *
297
- * @param options.refResolver - Resolver for references. Produces hydrated references that can be resolved.
298
- * @param options.dxn - Override object DXN. Changes the result of `Obj.getDXN`.
299
- */
300
- export const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver; dxn?: DXN }) => Promise<Any> =
301
- EchoSchema.objectFromJSON as any;
302
-
303
- /**
304
- * Returns an immutable snapshot of an object.
305
- */
306
- export const getSnapshot: <T extends Any>(obj: Obj<T>) => T = LiveObject.getSnapshot;
307
-
308
- export type CloneOptions = {
309
- /**
310
- * Retain the original object's ID.
311
- * @default false
312
- */
313
- retainId?: boolean;
314
- };
404
+ //
405
+ // Version
406
+ //
315
407
 
316
408
  /**
317
- * Clones an object or relation.
318
- * This does not clone referenced objects, only the properties in the object.
319
- * @returns A new object with the same schema and properties.
409
+ * Unique symbol for version type identification.
320
410
  */
321
- export const clone = <T extends Any | Relation.Any>(obj: T, opts?: CloneOptions): T => {
322
- const { id, ...data } = obj;
323
- const schema = getSchema(obj);
324
- invariant(schema != null, 'Object should have a schema');
325
- const props: any = deepMapValues(data, (value, recurse) => {
326
- if (EchoSchema.Ref.isRef(value)) {
327
- return value;
328
- }
329
- return recurse(value);
330
- });
331
- if (opts?.retainId) {
332
- props.id = id;
333
- }
334
- const meta = getMeta(obj);
335
- props[EchoSchema.MetaId] = deepMapValues(meta, (value, recurse) => {
336
- if (EchoSchema.Ref.isRef(value)) {
337
- return value;
338
- }
339
- return recurse(value);
340
- });
341
- return make(schema, props);
342
- };
343
-
344
- export const VersionTypeId = EchoSchema.VersionTypeId;
345
- export type VersionType = typeof VersionTypeId;
411
+ export { VersionTypeId };
346
412
 
347
413
  /**
348
414
  * Represent object version.
@@ -371,18 +437,19 @@ const unversioned: Version = {
371
437
  /**
372
438
  * Checks that `obj` is a version object.
373
439
  */
374
- export const isVersion = (obj: unknown): obj is Version => {
375
- return obj != null && typeof obj === 'object' && VersionTypeId in obj;
440
+ export const isVersion = (entity: unknown): entity is Version => {
441
+ return entity != null && typeof entity === 'object' && VersionTypeId in entity;
376
442
  };
377
443
 
378
444
  /**
379
445
  * Returns the version of the object.
380
446
  */
381
- export const version = (obj: Any | Relation.Any): Version => {
382
- const version = (obj as any)[EchoSchema.ObjectVersionId];
447
+ export const version = (entity: Entity.Unknown): Version => {
448
+ const version = (entity as any)[ObjectVersionId];
383
449
  if (version === undefined) {
384
450
  return unversioned;
385
451
  }
452
+
386
453
  return version;
387
454
  };
388
455
 
package/src/Ref.ts CHANGED
@@ -2,27 +2,27 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import * as EchoSchema from './internal';
5
+ import { Ref as Ref$, RefArray, type RefResolver } from './internal';
6
6
  import type * as Obj from './Obj';
7
7
 
8
- export type Ref<T> = EchoSchema.Ref<T>;
9
- export type Any = EchoSchema.Ref<Obj.Any>;
8
+ export type Ref<T> = Ref$<T>;
9
+ export type Any = Ref$<Obj.Any>;
10
10
 
11
- export const Array = EchoSchema.RefArray;
11
+ export const Array = RefArray;
12
12
 
13
13
  /**
14
14
  * Extract reference target.
15
15
  */
16
- export type Target<R extends Any> = R extends EchoSchema.Ref<infer T> ? T : never;
16
+ export type Target<R extends Any> = R extends Ref$<infer T> ? T : never;
17
17
 
18
18
  /**
19
19
  * Reference resolver.
20
20
  */
21
- export type Resolver = EchoSchema.RefResolver;
21
+ export type Resolver = RefResolver;
22
22
 
23
- export const isRef: (value: unknown) => value is Any = EchoSchema.Ref.isRef;
23
+ export const isRef: (value: unknown) => value is Any = Ref$.isRef;
24
24
 
25
- export const make = EchoSchema.Ref.make;
25
+ export const make = Ref$.make;
26
26
 
27
27
  // TODO(dmaretskyi): Consider just allowing `make` to accept DXN.
28
- export const fromDXN = EchoSchema.Ref.fromDXN;
28
+ export const fromDXN = Ref$.fromDXN;