@dxos/echo 0.8.4-main.67995b8 → 0.8.4-main.69d29f4

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 (553) hide show
  1. package/README.md +2 -3
  2. package/dist/lib/browser/Annotation.mjs +33 -0
  3. package/dist/lib/browser/Annotation.mjs.map +7 -0
  4. package/dist/lib/browser/Database.mjs +18 -0
  5. package/dist/lib/browser/Database.mjs.map +7 -0
  6. package/dist/lib/browser/Entity.mjs +52 -0
  7. package/dist/lib/browser/Entity.mjs.map +7 -0
  8. package/dist/lib/browser/Err.mjs +11 -0
  9. package/dist/lib/browser/Err.mjs.map +7 -0
  10. package/dist/lib/browser/Filter.mjs +62 -0
  11. package/dist/lib/browser/Filter.mjs.map +7 -0
  12. package/dist/lib/browser/Format.mjs +67 -0
  13. package/dist/lib/browser/Format.mjs.map +7 -0
  14. package/dist/lib/browser/JsonSchema.mjs +20 -0
  15. package/dist/lib/browser/JsonSchema.mjs.map +7 -0
  16. package/dist/lib/browser/Key.mjs +13 -0
  17. package/dist/lib/browser/Key.mjs.map +7 -0
  18. package/dist/lib/browser/Obj.mjs +91 -0
  19. package/dist/lib/browser/Obj.mjs.map +7 -0
  20. package/dist/lib/browser/Order.mjs +13 -0
  21. package/dist/lib/browser/Order.mjs.map +7 -0
  22. package/dist/lib/browser/Query.mjs +27 -0
  23. package/dist/lib/browser/Query.mjs.map +7 -0
  24. package/dist/lib/browser/QueryResult.mjs +3 -0
  25. package/dist/lib/browser/QueryResult.mjs.map +7 -0
  26. package/dist/lib/browser/Ref.mjs +23 -0
  27. package/dist/lib/browser/Ref.mjs.map +7 -0
  28. package/dist/lib/browser/Relation.mjs +85 -0
  29. package/dist/lib/browser/Relation.mjs.map +7 -0
  30. package/dist/lib/browser/SchemaRegistry.mjs +3 -0
  31. package/dist/lib/browser/SchemaRegistry.mjs.map +7 -0
  32. package/dist/lib/browser/Tag.mjs +26 -0
  33. package/dist/lib/browser/Tag.mjs.map +7 -0
  34. package/dist/lib/browser/Type.mjs +48 -0
  35. package/dist/lib/browser/Type.mjs.map +7 -0
  36. package/dist/lib/browser/chunk-2RMVRVOB.mjs +250 -0
  37. package/dist/lib/browser/chunk-2RMVRVOB.mjs.map +7 -0
  38. package/dist/lib/browser/chunk-5RDNDPMX.mjs +74 -0
  39. package/dist/lib/browser/chunk-5RDNDPMX.mjs.map +7 -0
  40. package/dist/lib/browser/chunk-73M2G455.mjs +98 -0
  41. package/dist/lib/browser/chunk-73M2G455.mjs.map +7 -0
  42. package/dist/lib/browser/chunk-7STIBCP7.mjs +133 -0
  43. package/dist/lib/browser/chunk-7STIBCP7.mjs.map +7 -0
  44. package/dist/lib/browser/chunk-AFGYYVVQ.mjs +57 -0
  45. package/dist/lib/browser/chunk-AFGYYVVQ.mjs.map +7 -0
  46. package/dist/lib/browser/chunk-BC6R4CAF.mjs +24 -0
  47. package/dist/lib/browser/chunk-BC6R4CAF.mjs.map +7 -0
  48. package/dist/lib/browser/chunk-BPYFLHWO.mjs +158 -0
  49. package/dist/lib/browser/chunk-BPYFLHWO.mjs.map +7 -0
  50. package/dist/lib/browser/chunk-CBPFF3ZO.mjs +204 -0
  51. package/dist/lib/browser/chunk-CBPFF3ZO.mjs.map +7 -0
  52. package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
  53. package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
  54. package/dist/lib/browser/chunk-CJ5YELTO.mjs +39 -0
  55. package/dist/lib/browser/chunk-CJ5YELTO.mjs.map +7 -0
  56. package/dist/lib/browser/chunk-FPOISFQK.mjs +40 -0
  57. package/dist/lib/browser/chunk-FPOISFQK.mjs.map +7 -0
  58. package/dist/lib/browser/chunk-INHXFXY5.mjs +22 -0
  59. package/dist/lib/browser/chunk-INHXFXY5.mjs.map +7 -0
  60. package/dist/lib/browser/chunk-IXVWLTG7.mjs +9 -0
  61. package/dist/lib/browser/chunk-IXVWLTG7.mjs.map +7 -0
  62. package/dist/lib/browser/chunk-JMKVF2YQ.mjs +43 -0
  63. package/dist/lib/browser/chunk-JMKVF2YQ.mjs.map +7 -0
  64. package/dist/lib/browser/chunk-L4RXUJHJ.mjs +143 -0
  65. package/dist/lib/browser/chunk-L4RXUJHJ.mjs.map +7 -0
  66. package/dist/lib/browser/chunk-MYCCGG2T.mjs +15 -0
  67. package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +7 -0
  68. package/dist/lib/browser/chunk-PAM4KEXE.mjs +3847 -0
  69. package/dist/lib/browser/chunk-PAM4KEXE.mjs.map +7 -0
  70. package/dist/lib/browser/chunk-QIWDIPLR.mjs +41 -0
  71. package/dist/lib/browser/chunk-QIWDIPLR.mjs.map +7 -0
  72. package/dist/lib/browser/chunk-R3S54KRI.mjs +403 -0
  73. package/dist/lib/browser/chunk-R3S54KRI.mjs.map +7 -0
  74. package/dist/lib/browser/chunk-RK4Z4JUZ.mjs +283 -0
  75. package/dist/lib/browser/chunk-RK4Z4JUZ.mjs.map +7 -0
  76. package/dist/lib/browser/chunk-TPIL3G6Y.mjs +288 -0
  77. package/dist/lib/browser/chunk-TPIL3G6Y.mjs.map +7 -0
  78. package/dist/lib/browser/chunk-YKTSSMDS.mjs +69 -0
  79. package/dist/lib/browser/chunk-YKTSSMDS.mjs.map +7 -0
  80. package/dist/lib/browser/chunk-ZHXZGIXD.mjs +9 -0
  81. package/dist/lib/browser/chunk-ZHXZGIXD.mjs.map +7 -0
  82. package/dist/lib/browser/index.mjs +72 -9
  83. package/dist/lib/browser/internal/index.mjs +457 -0
  84. package/dist/lib/browser/internal/index.mjs.map +7 -0
  85. package/dist/lib/browser/meta.json +1 -1
  86. package/dist/lib/browser/testing/index.mjs +332 -35
  87. package/dist/lib/browser/testing/index.mjs.map +4 -4
  88. package/dist/lib/node-esm/Annotation.mjs +33 -0
  89. package/dist/lib/node-esm/Annotation.mjs.map +7 -0
  90. package/dist/lib/node-esm/Database.mjs +18 -0
  91. package/dist/lib/node-esm/Database.mjs.map +7 -0
  92. package/dist/lib/node-esm/Entity.mjs +52 -0
  93. package/dist/lib/node-esm/Entity.mjs.map +7 -0
  94. package/dist/lib/node-esm/Err.mjs +11 -0
  95. package/dist/lib/node-esm/Err.mjs.map +7 -0
  96. package/dist/lib/node-esm/Filter.mjs +62 -0
  97. package/dist/lib/node-esm/Filter.mjs.map +7 -0
  98. package/dist/lib/node-esm/Format.mjs +67 -0
  99. package/dist/lib/node-esm/Format.mjs.map +7 -0
  100. package/dist/lib/node-esm/JsonSchema.mjs +20 -0
  101. package/dist/lib/node-esm/JsonSchema.mjs.map +7 -0
  102. package/dist/lib/node-esm/Key.mjs +13 -0
  103. package/dist/lib/node-esm/Key.mjs.map +7 -0
  104. package/dist/lib/node-esm/Obj.mjs +91 -0
  105. package/dist/lib/node-esm/Obj.mjs.map +7 -0
  106. package/dist/lib/node-esm/Order.mjs +13 -0
  107. package/dist/lib/node-esm/Order.mjs.map +7 -0
  108. package/dist/lib/node-esm/Query.mjs +27 -0
  109. package/dist/lib/node-esm/Query.mjs.map +7 -0
  110. package/dist/lib/node-esm/QueryResult.mjs +3 -0
  111. package/dist/lib/node-esm/QueryResult.mjs.map +7 -0
  112. package/dist/lib/node-esm/Ref.mjs +23 -0
  113. package/dist/lib/node-esm/Ref.mjs.map +7 -0
  114. package/dist/lib/node-esm/Relation.mjs +85 -0
  115. package/dist/lib/node-esm/Relation.mjs.map +7 -0
  116. package/dist/lib/node-esm/SchemaRegistry.mjs +3 -0
  117. package/dist/lib/node-esm/SchemaRegistry.mjs.map +7 -0
  118. package/dist/lib/node-esm/Tag.mjs +26 -0
  119. package/dist/lib/node-esm/Tag.mjs.map +7 -0
  120. package/dist/lib/node-esm/Type.mjs +48 -0
  121. package/dist/lib/node-esm/Type.mjs.map +7 -0
  122. package/dist/lib/node-esm/chunk-2RIFBW3A.mjs +250 -0
  123. package/dist/lib/node-esm/chunk-2RIFBW3A.mjs.map +7 -0
  124. package/dist/lib/node-esm/chunk-5CB2ZW74.mjs +57 -0
  125. package/dist/lib/node-esm/chunk-5CB2ZW74.mjs.map +7 -0
  126. package/dist/lib/node-esm/chunk-5U5F4AWK.mjs +3847 -0
  127. package/dist/lib/node-esm/chunk-5U5F4AWK.mjs.map +7 -0
  128. package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +22 -0
  129. package/dist/lib/node-esm/chunk-AJEMYSIR.mjs.map +7 -0
  130. package/dist/lib/node-esm/chunk-BKYE5IW6.mjs +158 -0
  131. package/dist/lib/node-esm/chunk-BKYE5IW6.mjs.map +7 -0
  132. package/dist/lib/node-esm/chunk-BYOD7EVP.mjs +98 -0
  133. package/dist/lib/node-esm/chunk-BYOD7EVP.mjs.map +7 -0
  134. package/dist/lib/node-esm/chunk-FWTSPIFF.mjs +133 -0
  135. package/dist/lib/node-esm/chunk-FWTSPIFF.mjs.map +7 -0
  136. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  137. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  138. package/dist/lib/node-esm/chunk-K37NA7PO.mjs +43 -0
  139. package/dist/lib/node-esm/chunk-K37NA7PO.mjs.map +7 -0
  140. package/dist/lib/node-esm/chunk-LIXUCQJM.mjs +41 -0
  141. package/dist/lib/node-esm/chunk-LIXUCQJM.mjs.map +7 -0
  142. package/dist/lib/node-esm/chunk-MOLNWFNL.mjs +9 -0
  143. package/dist/lib/node-esm/chunk-MOLNWFNL.mjs.map +7 -0
  144. package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +15 -0
  145. package/dist/lib/node-esm/chunk-MOWUEW5P.mjs.map +7 -0
  146. package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs +40 -0
  147. package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs.map +7 -0
  148. package/dist/lib/node-esm/chunk-OZEDKT4R.mjs +204 -0
  149. package/dist/lib/node-esm/chunk-OZEDKT4R.mjs.map +7 -0
  150. package/dist/lib/node-esm/chunk-PW3VCWL5.mjs +24 -0
  151. package/dist/lib/node-esm/chunk-PW3VCWL5.mjs.map +7 -0
  152. package/dist/lib/node-esm/chunk-TSTKBFST.mjs +403 -0
  153. package/dist/lib/node-esm/chunk-TSTKBFST.mjs.map +7 -0
  154. package/dist/lib/node-esm/chunk-UKGVOINP.mjs +9 -0
  155. package/dist/lib/node-esm/chunk-UKGVOINP.mjs.map +7 -0
  156. package/dist/lib/node-esm/chunk-UV63HEHQ.mjs +143 -0
  157. package/dist/lib/node-esm/chunk-UV63HEHQ.mjs.map +7 -0
  158. package/dist/lib/node-esm/chunk-WXLVPCRJ.mjs +288 -0
  159. package/dist/lib/node-esm/chunk-WXLVPCRJ.mjs.map +7 -0
  160. package/dist/lib/node-esm/chunk-WZ6YBELW.mjs +74 -0
  161. package/dist/lib/node-esm/chunk-WZ6YBELW.mjs.map +7 -0
  162. package/dist/lib/node-esm/chunk-XHJRMQZD.mjs +69 -0
  163. package/dist/lib/node-esm/chunk-XHJRMQZD.mjs.map +7 -0
  164. package/dist/lib/node-esm/chunk-YOLH5KS4.mjs +283 -0
  165. package/dist/lib/node-esm/chunk-YOLH5KS4.mjs.map +7 -0
  166. package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs +39 -0
  167. package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs.map +7 -0
  168. package/dist/lib/node-esm/index.mjs +72 -9
  169. package/dist/lib/node-esm/internal/index.mjs +457 -0
  170. package/dist/lib/node-esm/internal/index.mjs.map +7 -0
  171. package/dist/lib/node-esm/meta.json +1 -1
  172. package/dist/lib/node-esm/testing/index.mjs +332 -35
  173. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  174. package/dist/types/src/Annotation.d.ts +2 -0
  175. package/dist/types/src/Annotation.d.ts.map +1 -0
  176. package/dist/types/src/Database.d.ts +194 -0
  177. package/dist/types/src/Database.d.ts.map +1 -0
  178. package/dist/types/src/Entity.d.ts +142 -0
  179. package/dist/types/src/Entity.d.ts.map +1 -0
  180. package/dist/types/src/Entity.test.d.ts +2 -0
  181. package/dist/types/src/Entity.test.d.ts.map +1 -0
  182. package/dist/types/src/Err.d.ts +64 -0
  183. package/dist/types/src/Err.d.ts.map +1 -0
  184. package/dist/types/src/Filter.d.ts +120 -0
  185. package/dist/types/src/Filter.d.ts.map +1 -0
  186. package/dist/types/src/Format.d.ts +4 -0
  187. package/dist/types/src/Format.d.ts.map +1 -0
  188. package/dist/types/src/Hypergraph.d.ts +60 -0
  189. package/dist/types/src/Hypergraph.d.ts.map +1 -0
  190. package/dist/types/src/JsonSchema.d.ts +9 -0
  191. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  192. package/dist/types/src/Key.d.ts +1 -0
  193. package/dist/types/src/Key.d.ts.map +1 -1
  194. package/dist/types/src/Obj.d.ts +344 -35
  195. package/dist/types/src/Obj.d.ts.map +1 -1
  196. package/dist/types/src/Obj.test.d.ts +2 -0
  197. package/dist/types/src/Obj.test.d.ts.map +1 -0
  198. package/dist/types/src/Order.d.ts +16 -0
  199. package/dist/types/src/Order.d.ts.map +1 -0
  200. package/dist/types/src/Query.d.ts +115 -0
  201. package/dist/types/src/Query.d.ts.map +1 -0
  202. package/dist/types/src/Query.test.d.ts +2 -0
  203. package/dist/types/src/Query.test.d.ts.map +1 -0
  204. package/dist/types/src/QueryResult.d.ts +80 -0
  205. package/dist/types/src/QueryResult.d.ts.map +1 -0
  206. package/dist/types/src/Ref.d.ts +13 -11
  207. package/dist/types/src/Ref.d.ts.map +1 -1
  208. package/dist/types/src/Relation.d.ts +242 -19
  209. package/dist/types/src/Relation.d.ts.map +1 -1
  210. package/dist/types/src/Relation.test.d.ts +2 -0
  211. package/dist/types/src/Relation.test.d.ts.map +1 -0
  212. package/dist/types/src/SchemaRegistry.d.ts +84 -0
  213. package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
  214. package/dist/types/src/Tag.d.ts +17 -0
  215. package/dist/types/src/Tag.d.ts.map +1 -0
  216. package/dist/types/src/Type.d.ts +225 -73
  217. package/dist/types/src/Type.d.ts.map +1 -1
  218. package/dist/types/src/Type.test.d.ts +2 -0
  219. package/dist/types/src/Type.test.d.ts.map +1 -0
  220. package/dist/types/src/index.d.ts +15 -3
  221. package/dist/types/src/index.d.ts.map +1 -1
  222. package/dist/types/src/internal/annotations/annotations.d.ts +170 -0
  223. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  224. package/dist/types/src/internal/annotations/annotations.test.d.ts +2 -0
  225. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  226. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  227. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  228. package/dist/types/src/internal/annotations/util.d.ts +27 -0
  229. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  230. package/dist/types/src/internal/api/annotations.d.ts +23 -0
  231. package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
  232. package/dist/types/src/internal/api/entity.d.ts +13 -0
  233. package/dist/types/src/internal/api/entity.d.ts.map +1 -0
  234. package/dist/types/src/internal/api/index.d.ts +15 -0
  235. package/dist/types/src/internal/api/index.d.ts.map +1 -0
  236. package/dist/types/src/internal/api/meta.d.ts +42 -0
  237. package/dist/types/src/internal/api/meta.d.ts.map +1 -0
  238. package/dist/types/src/internal/api/sorting.d.ts +24 -0
  239. package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
  240. package/dist/types/src/internal/api/version.d.ts +42 -0
  241. package/dist/types/src/internal/api/version.d.ts.map +1 -0
  242. package/dist/types/src/internal/entities/entity.d.ts +20 -0
  243. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  244. package/dist/types/src/internal/entities/index.d.ts +6 -0
  245. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  246. package/dist/types/src/internal/entities/model.d.ts +77 -0
  247. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  248. package/dist/types/src/internal/entities/object.d.ts +18 -0
  249. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  250. package/dist/types/src/internal/entities/relation.d.ts +62 -0
  251. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  252. package/dist/types/src/internal/entities/util.d.ts +2 -0
  253. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  254. package/dist/types/src/internal/formats/date.d.ts +63 -0
  255. package/dist/types/src/internal/formats/date.d.ts.map +1 -0
  256. package/dist/types/src/internal/formats/date.test.d.ts +2 -0
  257. package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
  258. package/dist/types/src/internal/formats/format.d.ts +32 -0
  259. package/dist/types/src/internal/formats/format.d.ts.map +1 -0
  260. package/dist/types/src/internal/formats/format.test.d.ts +2 -0
  261. package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
  262. package/dist/types/src/internal/formats/index.d.ts +8 -0
  263. package/dist/types/src/internal/formats/index.d.ts.map +1 -0
  264. package/dist/types/src/internal/formats/number.d.ts +31 -0
  265. package/dist/types/src/internal/formats/number.d.ts.map +1 -0
  266. package/dist/types/src/internal/formats/object.d.ts +35 -0
  267. package/dist/types/src/internal/formats/object.d.ts.map +1 -0
  268. package/dist/types/src/internal/formats/select.d.ts +13 -0
  269. package/dist/types/src/internal/formats/select.d.ts.map +1 -0
  270. package/dist/types/src/internal/formats/string.d.ts +42 -0
  271. package/dist/types/src/internal/formats/string.d.ts.map +1 -0
  272. package/dist/types/src/internal/formats/types.d.ts +72 -0
  273. package/dist/types/src/internal/formats/types.d.ts.map +1 -0
  274. package/dist/types/src/internal/index.d.ts +12 -0
  275. package/dist/types/src/internal/index.d.ts.map +1 -0
  276. package/dist/types/src/internal/json-schema/annotations.d.ts +19 -0
  277. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  278. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts +2 -0
  279. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  280. package/dist/types/src/internal/json-schema/index.d.ts +5 -0
  281. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
  282. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
  283. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
  284. package/dist/types/src/internal/json-schema/json-schema-type.d.ts +351 -0
  285. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
  286. package/dist/types/src/internal/json-schema/json-schema.d.ts +30 -0
  287. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  288. package/dist/types/src/internal/json-schema/json-schema.test.d.ts +2 -0
  289. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  290. package/dist/types/src/internal/object/clone.d.ts +8 -0
  291. package/dist/types/src/internal/object/clone.d.ts.map +1 -0
  292. package/dist/types/src/internal/object/common.d.ts +18 -0
  293. package/dist/types/src/internal/object/common.d.ts.map +1 -0
  294. package/dist/types/src/internal/object/create-object.d.ts +39 -0
  295. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  296. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  297. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  298. package/dist/types/src/internal/object/deleted.d.ts +6 -0
  299. package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
  300. package/dist/types/src/internal/object/ids.d.ts +6 -0
  301. package/dist/types/src/internal/object/ids.d.ts.map +1 -0
  302. package/dist/types/src/internal/object/index.d.ts +11 -0
  303. package/dist/types/src/internal/object/index.d.ts.map +1 -0
  304. package/dist/types/src/internal/object/inspect.d.ts +2 -0
  305. package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
  306. package/dist/types/src/internal/object/json-serializer.d.ts +37 -0
  307. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
  308. package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
  309. package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
  310. package/dist/types/src/internal/object/schema-validator.d.ts +2 -0
  311. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
  312. package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
  313. package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
  314. package/dist/types/src/internal/object/set-value.d.ts +7 -0
  315. package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
  316. package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
  317. package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
  318. package/dist/types/src/internal/object/snapshot.d.ts +6 -0
  319. package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
  320. package/dist/types/src/internal/object/typed-object.d.ts +25 -0
  321. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
  322. package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
  323. package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
  324. package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
  325. package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
  326. package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
  327. package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
  328. package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
  329. package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
  330. package/dist/types/src/internal/proxy/errors.d.ts +19 -0
  331. package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
  332. package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
  333. package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
  334. package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
  335. package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
  336. package/dist/types/src/internal/proxy/index.d.ts +14 -0
  337. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  338. package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
  339. package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
  340. package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
  341. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  342. package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
  343. package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
  344. package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
  345. package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
  346. package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
  347. package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
  348. package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
  349. package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
  350. package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
  351. package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
  352. package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
  353. package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
  354. package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
  355. package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
  356. package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
  357. package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
  358. package/dist/types/src/internal/proxy/typed-handler.d.ts +47 -0
  359. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
  360. package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
  361. package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
  362. package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
  363. package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
  364. package/dist/types/src/internal/ref/index.d.ts +3 -0
  365. package/dist/types/src/internal/ref/index.d.ts.map +1 -0
  366. package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
  367. package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
  368. package/dist/types/src/internal/ref/ref.d.ts +218 -0
  369. package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
  370. package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
  371. package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
  372. package/dist/types/src/internal/schema/compose.d.ts +7 -0
  373. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  374. package/dist/types/src/internal/schema/compose.test.d.ts +2 -0
  375. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  376. package/dist/types/src/internal/schema/echo-schema.d.ts +180 -0
  377. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
  378. package/dist/types/src/internal/schema/index.d.ts +4 -0
  379. package/dist/types/src/internal/schema/index.d.ts.map +1 -0
  380. package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
  381. package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
  382. package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
  383. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  384. package/dist/types/src/internal/types/base.d.ts +26 -0
  385. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  386. package/dist/types/src/internal/types/entity.d.ts +37 -0
  387. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  388. package/dist/types/src/internal/types/index.d.ts +6 -0
  389. package/dist/types/src/internal/types/index.d.ts.map +1 -0
  390. package/dist/types/src/internal/types/meta.d.ts +32 -0
  391. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  392. package/dist/types/src/internal/types/typename.d.ts +13 -0
  393. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  394. package/dist/types/src/internal/types/version.d.ts +15 -0
  395. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  396. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  397. package/dist/types/src/testing/index.d.ts +3 -1
  398. package/dist/types/src/testing/index.d.ts.map +1 -1
  399. package/dist/types/src/testing/test-data.d.ts +18 -0
  400. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  401. package/dist/types/src/testing/test-schema.d.ts +303 -0
  402. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  403. package/dist/types/src/testing/util.d.ts +21 -0
  404. package/dist/types/src/testing/util.d.ts.map +1 -0
  405. package/dist/types/tsconfig.tsbuildinfo +1 -1
  406. package/package.json +169 -42
  407. package/src/Annotation.ts +18 -0
  408. package/src/Database.ts +336 -0
  409. package/src/Entity.test.ts +22 -0
  410. package/src/Entity.ts +217 -0
  411. package/src/Err.ts +18 -0
  412. package/src/Filter.ts +376 -0
  413. package/src/Format.ts +9 -0
  414. package/src/Hypergraph.ts +74 -0
  415. package/src/JsonSchema.ts +16 -0
  416. package/src/Key.ts +3 -0
  417. package/src/Obj.test.ts +386 -0
  418. package/src/Obj.ts +508 -84
  419. package/src/Order.ts +44 -0
  420. package/src/Query.test.ts +465 -0
  421. package/src/Query.ts +296 -0
  422. package/src/QueryResult.ts +106 -0
  423. package/src/Ref.ts +25 -9
  424. package/src/Relation.test.ts +82 -0
  425. package/src/Relation.ts +414 -51
  426. package/src/SchemaRegistry.ts +105 -0
  427. package/src/Tag.ts +40 -0
  428. package/src/Type.test.ts +52 -0
  429. package/src/Type.ts +360 -112
  430. package/src/index.ts +17 -4
  431. package/src/internal/README.md +102 -0
  432. package/src/internal/annotations/annotations.test.ts +96 -0
  433. package/src/internal/annotations/annotations.ts +460 -0
  434. package/src/internal/annotations/index.ts +6 -0
  435. package/src/internal/annotations/util.ts +72 -0
  436. package/src/internal/api/annotations.ts +60 -0
  437. package/src/internal/api/entity.ts +29 -0
  438. package/src/internal/api/index.ts +19 -0
  439. package/src/internal/api/meta.ts +88 -0
  440. package/src/internal/api/sorting.ts +53 -0
  441. package/src/internal/api/version.ts +96 -0
  442. package/src/internal/entities/entity.ts +126 -0
  443. package/src/internal/entities/index.ts +9 -0
  444. package/src/internal/entities/model.ts +134 -0
  445. package/src/internal/entities/object.ts +58 -0
  446. package/src/internal/entities/relation.ts +171 -0
  447. package/src/internal/entities/util.ts +33 -0
  448. package/src/internal/formats/date.test.ts +56 -0
  449. package/src/internal/formats/date.ts +217 -0
  450. package/src/internal/formats/format.test.ts +77 -0
  451. package/src/internal/formats/format.ts +54 -0
  452. package/src/internal/formats/index.ts +12 -0
  453. package/src/internal/formats/number.ts +89 -0
  454. package/src/internal/formats/object.ts +80 -0
  455. package/src/internal/formats/select.ts +18 -0
  456. package/src/internal/formats/string.ts +81 -0
  457. package/src/internal/formats/types.ts +186 -0
  458. package/src/internal/index.ts +39 -0
  459. package/src/internal/json-schema/annotations.ts +50 -0
  460. package/src/internal/json-schema/effect-schema.test.ts +143 -0
  461. package/src/internal/json-schema/index.ts +8 -0
  462. package/src/internal/json-schema/json-schema-normalize.ts +111 -0
  463. package/src/internal/json-schema/json-schema-type.ts +403 -0
  464. package/src/internal/json-schema/json-schema.test.ts +861 -0
  465. package/src/internal/json-schema/json-schema.ts +532 -0
  466. package/src/internal/object/clone.ts +48 -0
  467. package/src/internal/object/common.ts +75 -0
  468. package/src/internal/object/create-object.test.ts +116 -0
  469. package/src/internal/object/create-object.ts +95 -0
  470. package/src/internal/object/deleted.ts +19 -0
  471. package/src/internal/object/ids.ts +12 -0
  472. package/src/internal/object/index.ts +14 -0
  473. package/src/internal/object/inspect.ts +46 -0
  474. package/src/internal/object/json-serializer.test.ts +98 -0
  475. package/src/internal/object/json-serializer.ts +188 -0
  476. package/src/internal/object/schema-validator.test.ts +182 -0
  477. package/src/internal/object/schema-validator.ts +6 -0
  478. package/src/internal/object/set-value.test.ts +281 -0
  479. package/src/internal/object/set-value.ts +165 -0
  480. package/src/internal/object/snapshot.ts +70 -0
  481. package/src/internal/object/typed-object.test.ts +34 -0
  482. package/src/internal/object/typed-object.ts +30 -0
  483. package/src/internal/proxy/change-context.ts +138 -0
  484. package/src/internal/proxy/change.test.ts +519 -0
  485. package/src/internal/proxy/define-hidden-property.ts +14 -0
  486. package/src/internal/proxy/errors.ts +42 -0
  487. package/src/internal/proxy/event-batch.ts +44 -0
  488. package/src/internal/proxy/handler.test.ts +123 -0
  489. package/src/internal/proxy/index.ts +17 -0
  490. package/src/internal/proxy/json-serializer.ts +87 -0
  491. package/src/internal/proxy/make-object.ts +96 -0
  492. package/src/internal/proxy/ownership.ts +253 -0
  493. package/src/internal/proxy/proxy-types.ts +23 -0
  494. package/src/internal/proxy/proxy-utils.ts +150 -0
  495. package/src/internal/proxy/reactive-array.ts +71 -0
  496. package/src/internal/proxy/reactive.ts +69 -0
  497. package/src/internal/proxy/schema-validator.ts +244 -0
  498. package/src/internal/proxy/schema.test.ts +145 -0
  499. package/src/internal/proxy/symbols.ts +7 -0
  500. package/src/internal/proxy/typed-handler.test.ts +314 -0
  501. package/src/internal/proxy/typed-handler.ts +442 -0
  502. package/src/internal/proxy/typed-object.test.ts +116 -0
  503. package/src/internal/ref/index.ts +6 -0
  504. package/src/internal/ref/ref-array.ts +39 -0
  505. package/src/internal/ref/ref.test.ts +101 -0
  506. package/src/internal/ref/ref.ts +549 -0
  507. package/src/internal/schema/compose.test.ts +42 -0
  508. package/src/internal/schema/compose.ts +41 -0
  509. package/src/internal/schema/echo-schema.ts +423 -0
  510. package/src/internal/schema/index.ts +7 -0
  511. package/src/internal/schema/manipulation.ts +92 -0
  512. package/src/internal/schema/persistent-schema.ts +27 -0
  513. package/src/internal/types/base.ts +43 -0
  514. package/src/internal/types/entity.ts +54 -0
  515. package/src/internal/types/index.ts +9 -0
  516. package/src/internal/types/meta.ts +65 -0
  517. package/src/internal/types/typename.ts +45 -0
  518. package/src/internal/types/version.ts +20 -0
  519. package/src/testing/api.test.ts +126 -0
  520. package/src/testing/index.ts +3 -1
  521. package/src/testing/test-data.ts +130 -0
  522. package/src/testing/test-schema.ts +238 -0
  523. package/src/testing/util.ts +85 -0
  524. package/dist/lib/browser/chunk-EUA7CM23.mjs +0 -619
  525. package/dist/lib/browser/chunk-EUA7CM23.mjs.map +0 -7
  526. package/dist/lib/node-esm/chunk-IV6BWGHK.mjs +0 -619
  527. package/dist/lib/node-esm/chunk-IV6BWGHK.mjs.map +0 -7
  528. package/dist/types/src/experimental/database.d.ts +0 -8
  529. package/dist/types/src/experimental/database.d.ts.map +0 -1
  530. package/dist/types/src/experimental/index.d.ts +0 -1
  531. package/dist/types/src/experimental/index.d.ts.map +0 -1
  532. package/dist/types/src/experimental/queue.d.ts +0 -8
  533. package/dist/types/src/experimental/queue.d.ts.map +0 -1
  534. package/dist/types/src/experimental/space.d.ts +0 -8
  535. package/dist/types/src/experimental/space.d.ts.map +0 -1
  536. package/dist/types/src/query/dsl.d.ts +0 -218
  537. package/dist/types/src/query/dsl.d.ts.map +0 -1
  538. package/dist/types/src/query/dsl.test.d.ts +0 -2
  539. package/dist/types/src/query/dsl.test.d.ts.map +0 -1
  540. package/dist/types/src/query/index.d.ts +0 -2
  541. package/dist/types/src/query/index.d.ts.map +0 -1
  542. package/dist/types/src/testing/types.d.ts +0 -113
  543. package/dist/types/src/testing/types.d.ts.map +0 -1
  544. package/src/experimental/database.ts +0 -11
  545. package/src/experimental/index.ts +0 -7
  546. package/src/experimental/queue.ts +0 -11
  547. package/src/experimental/space.ts +0 -11
  548. package/src/query/dsl.test.ts +0 -323
  549. package/src/query/dsl.ts +0 -646
  550. package/src/query/index.ts +0 -5
  551. package/src/test/api.test.ts +0 -173
  552. package/src/testing/types.ts +0 -91
  553. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
@@ -0,0 +1,102 @@
1
+ ## Refactor
2
+
3
+ 1. Remove access from outisde of @dxos/echo-db
4
+
5
+ - [x] completely restructure @dxos/echo src/internal
6
+ - [x] Remove import "." and ".."! (create lint rule).
7
+ - [x] Unify FOUR different nests of test schema.
8
+ - [x] Remove @deprecated from internal methods and mark @internal (e.g., getSchemaDXN).
9
+ - NOTE: Internal methods should not use the import \* from Obj/Type APIs.
10
+ - [x] import ObjectId => @dxos/keys
11
+ - [x] Entity.Any = Obj.Any | Relation.Any
12
+ - NOTE: Relation does not extend (in not polymorphic with) Obj.
13
+ - [x] import LabelAnnotation => Annotation.LabelAnnotation
14
+ - [x] import Expando => @dxos/schema (Expando.Expando)
15
+ - [x] live => Obj.make
16
+ - [x] Rename live => makeObject
17
+ - [x] Rename {EchoObject, EchoRelation} => {EchoObjecSchema, EchoRelationSchema}
18
+ - [x] Rename AnyProperties => AnyProperties
19
+ - [x] Created Entity.Any (=> AnyEchoObject).
20
+ - [x] TypeFormat => TypeFormat
21
+ - [x] JsonSchemaType defs
22
+ - [x] Fix database.add() input/output types and search for "Obj.Any = db.add" (also QueryResult types).
23
+ - [x] TODO(burdon): FIX!!!
24
+ - [x] Fix failing tests.
25
+ - [x] Reconcile types/version with entities/model/version
26
+ - [x] Expando moved to @dxos/schema
27
+ - [x] Narrow QueryResult and match Schema and Object generics.
28
+
29
+ 2. Clean-up
30
+
31
+ - [x] QueryResult namespace
32
+ - [x] SchemaRegistry interface
33
+ - [x] Schema registry should return Type.Entity.Any instead of Schema.Schema.AnyNoContext.
34
+ - [x] Hypergraph interface
35
+ - [x] Obj.getDatabase
36
+ - [x] SpaceAction.AddObject target should be a db not a space.
37
+ - [x] Add Relation.MakeProps
38
+ - [x] Add Obj.Unknown and Relation.Unknown to match Entity.Unknown.
39
+ - [x] TODO(wittjosiah): Should be Type.obj<...> or equivalent.
40
+ - [x] TODO(wittjosiah): Find a simpler way to define this type.
41
+ - [x] Ref.Array.targets doesn't satisfy Obj.Any because it uses AnyEchoObject.
42
+ - [x] Remove echo-db/AnyLiveObject<T> => Obj.Obj<T>
43
+ - [x] Rename AnyEchoObject => AnyEntity
44
+ - [x] Remove WithId => AnyEntity
45
+ - [x] Remove WithMeta => AnyEntity
46
+ - [x] Obj.Any => Obj.Unknown
47
+ - [x] Relation.Any => Relation.Unknown
48
+ - [x] Ref.Any => Ref.Unknown
49
+ - [x] Obj.AnyProps => Obj.Any
50
+ - [x] Factor Expando out of @dxos/echo (moved to @dxos/schema)
51
+ - [x] Obj.instanceOf works with Expando (tested in @dxos/schema)
52
+ - [x] Obj.Snapshot should be same shape as Obj.Obj but with a different brand
53
+ - [x] Mutators should only work on object after it is made mutable
54
+
55
+ - [ ] Review usage of Obj.Any, see if it could be stricter
56
+ - [ ] Type.Obj should validate using the echo object brand
57
+ - [ ] Mutable could be a branded type to fix "NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`"
58
+ - [ ] space properties, queues, messagins preventing getSpace from being removed
59
+ - [ ] Schema registry should use Query.Query.
60
+ - [ ] Move EchoSchemaRegistry into hypergraph
61
+ - [ ] Narrow QueryResult and match Schema and Object generics.
62
+ - [ ] BaseSchema
63
+ - [ ] Directly import JSONPath, etc. from @dxos/effect.
64
+ - [ ] Promote parts of src/internal/ref to Ref.ts
65
+ - [ ] JsonPath, JsonProp, getValue, setValue => Json.Path?
66
+ - [ ] DISCUSS: Standradize $ suffix to disambuguate imports (GPT recommended).
67
+
68
+ 3. Audit usage from @dxos/echo-db
69
+
70
+ - [ ] Ability to extract Struct from Type.Obj
71
+ - [ ] created/updated system props (const { created } = Obj.getTimestamps)?
72
+ - [ ] QueryFn, QueryOptions => Database
73
+ - [ ] Datatbase.query() options?
74
+ - [ ] Expando type is used as a fallback in many plance.
75
+ - [ ] Standardize '@automerge/automerge' imports (A vs. next).
76
+
77
+ ## NOTES
78
+
79
+ - Marking types as @internal (even for unexported types) erases type information.
80
+
81
+ ## 0.9.0
82
+
83
+ - [ ] Database, Queue, Space, Type, namespaces.
84
+ - [ ] Support class variant for types.
85
+ - [ ] Support defaults.
86
+ - [ ] Support effect Date, Timestamp formats.
87
+ - [ ] Metadata for created, updated timestamps.
88
+ - [ ] Effect team design review.
89
+ - [ ] @category annotations to group types in the API.
90
+ - [ ] TSdoc and LLM training for function generation.
91
+ - [ ] Rename TypeFormat => Primitive?
92
+ - [ ] Don't re-export effect?
93
+
94
+ ## Issues
95
+
96
+ - [ ] Build error when changing from TypedObject using Ref$: Type 'Task' does not satisfy the constraint 'WithId' (see echo-schema/testing/schema.ts)
97
+ - [ ] Reconcile all schema variants (Base, Immutable, TypedObject, EchoObject, etc.)
98
+ - [ ] Consolidate getters (getType, getSchema, getTypename, getSchemaTypename, etc.)
99
+ - [ ] ReactiveObject should specify id property? Reconcile AnyProperties, ReactiveObject, HasId, WithId, etc.
100
+ - [ ] Can we us S.is(MyType) to detect objects with our types system? (Branding?)
101
+ - [ ] Type.Expando doesn't work with AtomQuery result type (have to use Obj.Any instead).
102
+ - [ ] Obj.Any doesn't work with Obj.change callback types (have to use `any` for the mutable parameter).
@@ -0,0 +1,96 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import { describe, test } from 'vitest';
7
+
8
+ import { EchoObjectSchema } from '../entities';
9
+
10
+ import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema } from './annotations';
11
+
12
+ // TODO(dmaretskyi): Use one of the testing schemas.
13
+ const TestObject = Schema.Struct({
14
+ name: Schema.optional(Schema.String),
15
+ fallbackName: Schema.optional(Schema.String),
16
+ other: Schema.String,
17
+ }).pipe(LabelAnnotation.set(['name', 'fallbackName']));
18
+
19
+ type TestObject = Schema.Schema.Type<typeof TestObject>;
20
+
21
+ const TestEchoSchema = TestObject.pipe(
22
+ EchoObjectSchema({
23
+ typename: 'dxos.org/type/Test',
24
+ version: '0.1.0',
25
+ }),
26
+ );
27
+
28
+ type TestEchoSchema = Schema.Schema.Type<typeof TestEchoSchema>;
29
+
30
+ describe('annotations', () => {
31
+ describe('Typename', () => {
32
+ test('should validate typename', ({ expect }) => {
33
+ // Valid.
34
+ expect(TypenameSchema.make('dxos.org/type/foo')).to.exist;
35
+ expect(TypenameSchema.make('dxos.org/type/foo-bar')).to.exist;
36
+ expect(TypenameSchema.make('dxos.org/type/foo_bar')).to.exist;
37
+
38
+ // Invalid.
39
+ expect(() => TypenameSchema.make('dxn:dxos.org')).to.throw();
40
+ expect(() => TypenameSchema.make('2dxos.org')).to.throw();
41
+ expect(() => TypenameSchema.make('dxos org')).to.throw();
42
+ });
43
+
44
+ test('should validate version', ({ expect }) => {
45
+ // Valid.
46
+ expect(VersionSchema.make('0.1.0')).to.exist;
47
+
48
+ // Invalid.
49
+ expect(() => VersionSchema.make('0.1.x')).to.throw();
50
+ expect(() => VersionSchema.make('0.1.0-alpha')).to.throw();
51
+ });
52
+ });
53
+
54
+ describe('getLabelWithSchema', () => {
55
+ test('should return first available label value', ({ expect }) => {
56
+ const obj: TestObject = {
57
+ name: 'Primary Name',
58
+ fallbackName: 'Fallback Name',
59
+ other: 'Other',
60
+ };
61
+
62
+ expect(getLabelWithSchema(TestObject, obj)).toEqual('Primary Name');
63
+ });
64
+
65
+ test('should fallback to second path if first is undefined', ({ expect }) => {
66
+ const obj: TestObject = {
67
+ name: undefined,
68
+ fallbackName: 'Fallback Name',
69
+ other: 'Other',
70
+ };
71
+
72
+ expect(getLabelWithSchema(TestObject, obj)).toEqual('Fallback Name');
73
+ });
74
+
75
+ test('should return undefined if no label paths resolve', ({ expect }) => {
76
+ const obj: TestObject = {
77
+ name: undefined,
78
+ fallbackName: undefined,
79
+ other: 'Other',
80
+ };
81
+
82
+ expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
83
+ });
84
+
85
+ test('should return label from echo object', ({ expect }) => {
86
+ const obj: TestEchoSchema = {
87
+ id: 'test',
88
+ name: 'Primary Name',
89
+ fallbackName: 'Fallback Name',
90
+ other: 'Other',
91
+ };
92
+
93
+ expect(getLabelWithSchema(TestEchoSchema, obj)).toEqual('Primary Name');
94
+ });
95
+ });
96
+ });
@@ -0,0 +1,460 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Function from 'effect/Function';
6
+ import * as Option from 'effect/Option';
7
+ import * as Schema from 'effect/Schema';
8
+ import * as SchemaAST from 'effect/SchemaAST';
9
+
10
+ import { raise } from '@dxos/debug';
11
+ import { type JsonPath, getField } from '@dxos/effect';
12
+ import { assertArgument, invariant } from '@dxos/invariant';
13
+ import { DXN } from '@dxos/keys';
14
+ import { type Primitive } from '@dxos/util';
15
+
16
+ import { type AnyProperties, EntityKind, TypeId, getSchema } from '../types';
17
+
18
+ import { createAnnotationHelper } from './util';
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ export const FIELD_PATH_ANNOTATION = 'path';
24
+
25
+ /**
26
+ * Sets the path for the field.
27
+ * @param path Data source path in the json path format. This is the field path in the source object.
28
+ */
29
+ // TODO(burdon): Field, vs. path vs. property.
30
+ export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
31
+
32
+ //
33
+ // Type
34
+ //
35
+
36
+ /**
37
+ * ECHO identifier (for a stored schema).
38
+ * Must be a `dxn:echo:` URI.
39
+ */
40
+ export const TypeIdentifierAnnotationId = Symbol.for('@dxos/schema/annotation/TypeIdentifier');
41
+
42
+ export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
43
+ Function.flow(
44
+ SchemaAST.getAnnotation<string>(TypeIdentifierAnnotationId),
45
+ Option.getOrElse(() => undefined),
46
+ )(schema.ast);
47
+
48
+ /**
49
+ * @returns DXN of the schema.
50
+ *
51
+ * For non-stored schema returns `dxn:type:`.
52
+ * For stored schema returns `dxn:echo:`.
53
+ */
54
+ export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
55
+ assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
56
+ const id = getTypeIdentifierAnnotation(schema);
57
+ if (id) {
58
+ return DXN.parse(id);
59
+ }
60
+
61
+ // TODO(dmaretskyi): Add support for dynamic schema.
62
+ const objectAnnotation = getTypeAnnotation(schema);
63
+ if (!objectAnnotation) {
64
+ return undefined;
65
+ }
66
+
67
+ return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
68
+ };
69
+
70
+ /**
71
+ * @param input schema or a typename string.
72
+ * @return type DXN.
73
+ */
74
+ export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN => {
75
+ if (Schema.isSchema(input)) {
76
+ return getSchemaDXN(input) ?? raise(new TypeError('Schema has no DXN'));
77
+ } else {
78
+ assertArgument(typeof input === 'string', 'input');
79
+ assertArgument(!input.startsWith('dxn:'), 'input');
80
+ return DXN.fromTypename(input);
81
+ }
82
+ };
83
+
84
+ //
85
+ // TypeAnnotation
86
+ //
87
+
88
+ /**
89
+ * Fully qualified globally unique typename.
90
+ * Example: `dxos.org/type/Message`
91
+ */
92
+ // TODO(burdon): Reconcile with short DXN format.
93
+ // TODO(burdon): Change "/type" => "/schema" throughout.
94
+ export const TypenameSchema = Schema.String.pipe(Schema.pattern(/^[a-zA-Z]\w+\.[a-zA-Z]\w{1,}\/[\w/_-]+$/)).annotations(
95
+ {
96
+ description: 'Fully qualified globally unique typename',
97
+ example: 'dxos.org/type/Message',
98
+ },
99
+ );
100
+
101
+ /**
102
+ * Semantic version format: `major.minor.patch`
103
+ * Example: `1.0.0`
104
+ */
105
+ export const VersionSchema = Schema.String.pipe(Schema.pattern(/^\d+.\d+.\d+$/)).annotations({
106
+ description: 'Semantic version format: `major.minor.patch`',
107
+ example: '1.0.0',
108
+ });
109
+
110
+ export const TypeMeta = Schema.Struct({
111
+ typename: TypenameSchema,
112
+ version: VersionSchema,
113
+ });
114
+
115
+ export interface TypeMeta extends Schema.Schema.Type<typeof TypeMeta> {}
116
+
117
+ /**
118
+ * Entity type.
119
+ */
120
+ export const TypeAnnotationId = Symbol.for('@dxos/schema/annotation/Type');
121
+
122
+ /**
123
+ * Payload stored under {@link TypeAnnotationId}.
124
+ */
125
+ export const TypeAnnotation = Schema.extend(
126
+ TypeMeta,
127
+ Schema.Struct({
128
+ kind: Schema.Enums(EntityKind),
129
+
130
+ /**
131
+ * If this is a relation, the schema of the source object.
132
+ * Must be present if entity kind is {@link EntityKind.Relation}.
133
+ */
134
+ sourceSchema: Schema.optional(DXN.Schema),
135
+
136
+ /**
137
+ * If this is a relation, the schema of the target object.
138
+ * Must be present if entity kind is {@link EntityKind.Relation}.
139
+ */
140
+ targetSchema: Schema.optional(DXN.Schema),
141
+ }),
142
+ );
143
+
144
+ export interface TypeAnnotation extends Schema.Schema.Type<typeof TypeAnnotation> {}
145
+
146
+ /**
147
+ * @returns {@link TypeAnnotation} from a schema.
148
+ * Schema must have been created with {@link TypedObject} or {@link TypedLink} or manually assigned an appropriate annotation.
149
+ */
150
+ export const getTypeAnnotation = (schema: Schema.Schema.All): TypeAnnotation | undefined => {
151
+ assertArgument(schema != null && schema.ast != null, 'schema', 'invalid schema');
152
+ return Function.flow(
153
+ SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId),
154
+ Option.getOrElse(() => undefined),
155
+ )(schema.ast);
156
+ };
157
+
158
+ /**
159
+ * @returns {@link EntityKind} from a schema.
160
+ */
161
+ export const getEntityKind = (schema: Schema.Schema.All): EntityKind | undefined => getTypeAnnotation(schema)?.kind;
162
+
163
+ /**
164
+ * @internal
165
+ * @returns Schema typename (without dxn: prefix or version number).
166
+ */
167
+ export const getSchemaTypename = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.typename;
168
+
169
+ /**
170
+ * @internal
171
+ * @returns Schema version in semver format.
172
+ */
173
+ export const getSchemaVersion = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.version;
174
+
175
+ /**
176
+ * Gets the typename of the object without the version.
177
+ * Returns only the name portion, not the DXN.
178
+ * @example "example.org/type/Contact"
179
+ *
180
+ * @internal (use Obj.getTypename)
181
+ */
182
+ export const getTypename = (obj: AnyProperties): string | undefined => {
183
+ const schema = getSchema(obj);
184
+ if (schema != null) {
185
+ // Try to extract typename from DXN.
186
+ return getSchemaTypename(schema);
187
+ } else {
188
+ const type = getTypeDXN(obj);
189
+ return type?.asTypeDXN()?.type;
190
+ }
191
+ };
192
+
193
+ /**
194
+ * @internal (use Type.setTypename)
195
+ */
196
+ // TODO(dmaretskyi): Rename setTypeDXN.
197
+ export const setTypename = (obj: any, typename: DXN): void => {
198
+ invariant(typename instanceof DXN, 'Invalid type.');
199
+ Object.defineProperty(obj, TypeId, {
200
+ value: typename,
201
+ writable: false,
202
+ enumerable: false,
203
+ configurable: false,
204
+ });
205
+ };
206
+
207
+ /**
208
+ * @returns Object type as {@link DXN}.
209
+ * @returns undefined if the object doesn't have a type.
210
+ * @example `dxn:example.com/type/Person:1.0.0`
211
+ *
212
+ * @internal (use Obj.getTypeDXN)
213
+ */
214
+ // TODO(burdon): Narrow type.
215
+ export const getTypeDXN = (obj: AnyProperties): DXN | undefined => {
216
+ if (!obj) {
217
+ return undefined;
218
+ }
219
+
220
+ const type = (obj as any)[TypeId];
221
+ if (!type) {
222
+ return undefined;
223
+ }
224
+
225
+ invariant(type instanceof DXN, 'Invalid object.');
226
+ return type;
227
+ };
228
+
229
+ /**
230
+ * Checks if the object is an instance of the schema.
231
+ * Only typename is compared, the schema version is ignored.
232
+ *
233
+ * The following cases are considered to mean that the object is an instance of the schema:
234
+ * - Object was created with this exact schema.
235
+ * - Object was created with a different version of this schema.
236
+ * - Object was created with a different schema (maybe dynamic) that has the same typename.
237
+ */
238
+ // TODO(burdon): Can we use `Schema.is`?
239
+ export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
240
+ schema: Schema,
241
+ object: any,
242
+ ): object is Schema.Schema.Type<Schema> => {
243
+ if (object == null) {
244
+ return false;
245
+ }
246
+
247
+ const schemaDXN = getSchemaDXN(schema);
248
+ if (!schemaDXN) {
249
+ throw new Error('Schema must have an object annotation.');
250
+ }
251
+
252
+ const type = getTypeDXN(object);
253
+ if (type && DXN.equals(type, schemaDXN)) {
254
+ return true;
255
+ }
256
+
257
+ const typename = getTypename(object);
258
+ if (!typename) {
259
+ return false;
260
+ }
261
+
262
+ const typeDXN = schemaDXN.asTypeDXN();
263
+ if (!typeDXN) {
264
+ return false;
265
+ }
266
+
267
+ return typeDXN.type === typename;
268
+ };
269
+
270
+ //
271
+ // PropertyMeta
272
+ //
273
+
274
+ /**
275
+ * PropertyMeta (metadata for dynamic schema properties).
276
+ * For user-defined annotations.
277
+ */
278
+ export const PropertyMetaAnnotationId = Symbol.for('@dxos/schema/annotation/PropertyMeta');
279
+
280
+ export type PropertyMetaValue = Primitive | Record<string, Primitive> | Primitive[];
281
+
282
+ export type PropertyMetaAnnotation = {
283
+ [name: string]: PropertyMetaValue;
284
+ };
285
+
286
+ // TODO(wittjosiah): Align with other annotations.
287
+ // TODO(wittjosiah): Why is this separate from FormatAnnotation?
288
+ export const PropertyMeta = (name: string, value: PropertyMetaValue) => {
289
+ return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {
290
+ const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;
291
+ return self.annotations({
292
+ [PropertyMetaAnnotationId]: {
293
+ ...existingMeta,
294
+ [name]: value,
295
+ },
296
+ });
297
+ };
298
+ };
299
+
300
+ export const getPropertyMetaAnnotation = <T>(prop: SchemaAST.PropertySignature, name: string) =>
301
+ Function.pipe(
302
+ SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(prop.type),
303
+ Option.map((meta) => meta[name] as T),
304
+ Option.getOrElse(() => undefined),
305
+ );
306
+
307
+ //
308
+ // Reference
309
+ //
310
+
311
+ /**
312
+ * Schema reference.
313
+ */
314
+ export const ReferenceAnnotationId = Symbol.for('@dxos/schema/annotation/Reference');
315
+ export type ReferenceAnnotationValue = TypeAnnotation;
316
+ export const ReferenceAnnotation = createAnnotationHelper<ReferenceAnnotationValue>(ReferenceAnnotationId);
317
+
318
+ /**
319
+ * SchemaMeta.
320
+ */
321
+ export const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');
322
+ export type SchemaMeta = TypeMeta & { id: string };
323
+
324
+ /**
325
+ * Identifies a schema as a schema for a hidden system type.
326
+ */
327
+ export const SystemTypeAnnotationId = Symbol.for('@dxos/schema/annotation/SystemType');
328
+ export const SystemTypeAnnotation = createAnnotationHelper<boolean>(SystemTypeAnnotationId);
329
+
330
+ /**
331
+ * Identifies label property or JSON path expression.
332
+ * Either a string or an array of strings representing field accessors each matched in priority order.
333
+ */
334
+ export const LabelAnnotationId = Symbol.for('@dxos/schema/annotation/Label');
335
+ export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationId);
336
+
337
+ /**
338
+ * Returns the label for a given object based on {@link LabelAnnotationId}.
339
+ * Lower-level version that requires explicit schema parameter.
340
+ */
341
+ // TODO(burdon): Convert to JsonPath?
342
+ export const getLabelWithSchema = <S extends Schema.Schema.Any>(
343
+ schema: S,
344
+ object: Schema.Schema.Type<S>,
345
+ ): string | undefined => {
346
+ const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
347
+ for (const accessor of annotation) {
348
+ assertArgument(
349
+ typeof accessor === 'string',
350
+ 'accessor',
351
+ 'Label annotation must be a string or an array of strings',
352
+ );
353
+ const value = getField(object, accessor as JsonPath);
354
+ switch (typeof value) {
355
+ case 'string':
356
+ case 'number':
357
+ case 'boolean':
358
+ case 'bigint':
359
+ case 'symbol':
360
+ return value.toString();
361
+ case 'undefined':
362
+ case 'object':
363
+ case 'function':
364
+ continue;
365
+ }
366
+ }
367
+
368
+ return undefined;
369
+ };
370
+
371
+ /**
372
+ * Sets the label for a given object based on {@link LabelAnnotationId}.
373
+ * Lower-level version that requires explicit schema parameter.
374
+ */
375
+ export const setLabelWithSchema = <S extends Schema.Schema.Any>(
376
+ schema: S,
377
+ object: Schema.Schema.Type<S>,
378
+ label: string,
379
+ ) => {
380
+ const annotation = LabelAnnotation.get(schema).pipe(
381
+ Option.map((field) => field[0]),
382
+ Option.getOrElse(() => 'name'),
383
+ );
384
+ object[annotation] = label;
385
+ };
386
+
387
+ /**
388
+ * Identifies description property or JSON path expression.
389
+ * A string representing field accessor.
390
+ */
391
+ export const DescriptionAnnotationId = Symbol.for('@dxos/schema/annotation/Description');
392
+ export const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionAnnotationId);
393
+
394
+ /**
395
+ * Returns the description for a given object based on {@link DescriptionAnnotationId}.
396
+ * Lower-level version that requires explicit schema parameter.
397
+ */
398
+ // TODO(burdon): Convert to JsonPath?
399
+ export const getDescriptionWithSchema = <S extends Schema.Schema.Any>(
400
+ schema: S,
401
+ object: Schema.Schema.Type<S>,
402
+ ): string | undefined => {
403
+ const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
404
+ assertArgument(typeof accessor === 'string', 'accessor', 'Description annotation must be a string');
405
+ const value = getField(object, accessor as JsonPath);
406
+ switch (typeof value) {
407
+ case 'string':
408
+ case 'number':
409
+ case 'boolean':
410
+ case 'bigint':
411
+ case 'symbol':
412
+ return value.toString();
413
+ case 'undefined':
414
+ case 'object':
415
+ case 'function':
416
+ default:
417
+ return undefined;
418
+ }
419
+ };
420
+
421
+ /**
422
+ * Sets the description for a given object based on {@link DescriptionAnnotationId}.
423
+ * Lower-level version that requires explicit schema parameter.
424
+ */
425
+ export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
426
+ schema: S,
427
+ object: Schema.Schema.Type<S>,
428
+ description: string,
429
+ ) => {
430
+ const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
431
+ object[accessor] = description;
432
+ };
433
+
434
+ /**
435
+ * Identifies if a property should be included in a form or not.
436
+ * By default, all properties are included in forms, so this is opt-out.
437
+ */
438
+ // TODO(burdon): UI concern.
439
+ export const FormInputAnnotationId = Symbol.for('@dxos/schema/annotation/FormInput');
440
+ export const FormInputAnnotation = createAnnotationHelper<boolean>(FormInputAnnotationId);
441
+
442
+ /**
443
+ * Default field to be used on referenced schema to lookup the value.
444
+ */
445
+ export const FieldLookupAnnotationId = Symbol.for('@dxos/schema/annotation/FieldLookup');
446
+
447
+ /**
448
+ * Generate test data.
449
+ */
450
+ export const GeneratorAnnotationId = Symbol.for('@dxos/schema/annotation/Generator');
451
+
452
+ export type GeneratorAnnotationValue =
453
+ | string
454
+ | {
455
+ generator: string;
456
+ args?: any[];
457
+ probability?: number;
458
+ };
459
+
460
+ export const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './annotations';
6
+ export * from './util';