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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +7 -7
  3. package/dist/lib/neutral/Annotation.mjs +29 -6
  4. package/dist/lib/neutral/Database.mjs +8 -9
  5. package/dist/lib/neutral/Entity.mjs +29 -18
  6. package/dist/lib/neutral/Err.mjs +3 -3
  7. package/dist/lib/neutral/Feed.mjs +27 -19
  8. package/dist/lib/neutral/Filter.mjs +25 -15
  9. package/dist/lib/neutral/Format.mjs +23 -3
  10. package/dist/lib/neutral/JsonSchema.mjs +7 -8
  11. package/dist/lib/neutral/Key.mjs +9 -5
  12. package/dist/lib/neutral/Migration.mjs +18 -0
  13. package/dist/lib/neutral/Obj.mjs +25 -19
  14. package/dist/lib/neutral/Order.mjs +1 -1
  15. package/dist/lib/neutral/Query.mjs +19 -16
  16. package/dist/lib/neutral/QueryResult.mjs +1 -1
  17. package/dist/lib/neutral/Ref.mjs +10 -9
  18. package/dist/lib/neutral/Registry.mjs +14 -0
  19. package/dist/lib/neutral/Registry.mjs.map +7 -0
  20. package/dist/lib/neutral/Relation.mjs +26 -24
  21. package/dist/lib/neutral/Scope.mjs +12 -0
  22. package/dist/lib/neutral/Scope.mjs.map +7 -0
  23. package/dist/lib/neutral/Tag.mjs +17 -13
  24. package/dist/lib/neutral/Type.mjs +52 -26
  25. package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
  26. package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
  27. package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
  28. package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
  29. package/dist/lib/neutral/{chunk-CIRHIEMW.mjs → chunk-4SFPZJVA.mjs} +92 -112
  30. package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
  31. package/dist/lib/neutral/{chunk-YWXWXIE5.mjs → chunk-4Z6GET2X.mjs} +3 -3
  32. package/dist/lib/neutral/chunk-4Z6GET2X.mjs.map +7 -0
  33. package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
  34. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  35. package/dist/lib/neutral/{chunk-43Y5DOS6.mjs → chunk-7OAFN3OX.mjs} +75 -112
  36. package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
  37. package/dist/lib/neutral/{chunk-BOZZPUXE.mjs → chunk-7PRCIDHH.mjs} +41 -81
  38. package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
  39. package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
  40. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-BDQGMDIX.mjs +132 -0
  42. package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
  44. package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
  45. package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-DKLUHO4T.mjs} +1 -1
  46. package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
  47. package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
  48. package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
  49. package/dist/lib/neutral/{chunk-UTBRYVQC.mjs → chunk-G6CFWUYH.mjs} +2 -2
  50. package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
  51. package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
  52. package/dist/lib/neutral/{chunk-FXEG7EOK.mjs → chunk-J3MNM65T.mjs} +9 -6
  53. package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
  54. package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
  55. package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
  56. package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
  57. package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
  58. package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
  59. package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
  60. package/dist/lib/neutral/{chunk-WYOKA6AE.mjs → chunk-O6BH7EPN.mjs} +31 -4
  61. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  62. package/dist/lib/neutral/{chunk-KTAWP7GI.mjs → chunk-OIYW7R2G.mjs} +99 -46
  63. package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
  64. package/dist/lib/neutral/{chunk-TQQZLKB7.mjs → chunk-OYUG4FHF.mjs} +648 -1228
  65. package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
  66. package/dist/lib/neutral/{chunk-NQRLRYJM.mjs → chunk-Q5FKCVBC.mjs} +173 -60
  67. package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
  68. package/dist/lib/neutral/chunk-Q62IHV2N.mjs +41 -0
  69. package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
  70. package/dist/lib/neutral/{chunk-UFDK26FO.mjs → chunk-QVJDDG44.mjs} +69 -34
  71. package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
  72. package/dist/lib/neutral/{chunk-B5OXLWZL.mjs → chunk-TFEWTY5A.mjs} +155 -129
  73. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  74. package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-TTCSATUD.mjs} +1 -1
  75. package/dist/lib/neutral/{chunk-FZO7LQO7.mjs → chunk-VKWOFXT2.mjs} +22 -2
  76. package/dist/lib/neutral/{chunk-FZO7LQO7.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
  77. package/dist/lib/neutral/{chunk-NXMFBIT5.mjs → chunk-ZACMEAYV.mjs} +89 -23
  78. package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
  79. package/dist/lib/neutral/index.mjs +58 -38
  80. package/dist/lib/neutral/internal/index.mjs +131 -64
  81. package/dist/lib/neutral/meta.json +1 -1
  82. package/dist/lib/neutral/testing/index.mjs +222 -177
  83. package/dist/lib/neutral/testing/index.mjs.map +3 -3
  84. package/dist/types/src/Annotation.d.ts +108 -4
  85. package/dist/types/src/Annotation.d.ts.map +1 -1
  86. package/dist/types/src/Annotation.test.d.ts +2 -0
  87. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  88. package/dist/types/src/Collection.d.ts +2 -3
  89. package/dist/types/src/Collection.d.ts.map +1 -1
  90. package/dist/types/src/Database.d.ts +56 -24
  91. package/dist/types/src/Database.d.ts.map +1 -1
  92. package/dist/types/src/Dataset.d.ts +17 -6
  93. package/dist/types/src/Dataset.d.ts.map +1 -1
  94. package/dist/types/src/Entity.d.ts +102 -26
  95. package/dist/types/src/Entity.d.ts.map +1 -1
  96. package/dist/types/src/Err.d.ts +27 -27
  97. package/dist/types/src/Err.d.ts.map +1 -1
  98. package/dist/types/src/Feed.d.ts +89 -25
  99. package/dist/types/src/Feed.d.ts.map +1 -1
  100. package/dist/types/src/Filter.d.ts +74 -11
  101. package/dist/types/src/Filter.d.ts.map +1 -1
  102. package/dist/types/src/Filter.test.d.ts +2 -0
  103. package/dist/types/src/Filter.test.d.ts.map +1 -0
  104. package/dist/types/src/Hypergraph.d.ts +14 -9
  105. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  106. package/dist/types/src/Json.d.ts +33 -0
  107. package/dist/types/src/Json.d.ts.map +1 -0
  108. package/dist/types/src/Json.test.d.ts +2 -0
  109. package/dist/types/src/Json.test.d.ts.map +1 -0
  110. package/dist/types/src/JsonSchema.d.ts +2 -2
  111. package/dist/types/src/JsonSchema.d.ts.map +1 -1
  112. package/dist/types/src/Key.d.ts +1 -1
  113. package/dist/types/src/Key.d.ts.map +1 -1
  114. package/dist/types/src/Migration.d.ts +72 -0
  115. package/dist/types/src/Migration.d.ts.map +1 -0
  116. package/dist/types/src/Obj.d.ts +108 -65
  117. package/dist/types/src/Obj.d.ts.map +1 -1
  118. package/dist/types/src/Order.d.ts.map +1 -1
  119. package/dist/types/src/Query.d.ts +35 -10
  120. package/dist/types/src/Query.d.ts.map +1 -1
  121. package/dist/types/src/QueryResult.d.ts +9 -0
  122. package/dist/types/src/QueryResult.d.ts.map +1 -1
  123. package/dist/types/src/Ref.d.ts +15 -7
  124. package/dist/types/src/Ref.d.ts.map +1 -1
  125. package/dist/types/src/Registry.d.ts +131 -0
  126. package/dist/types/src/Registry.d.ts.map +1 -0
  127. package/dist/types/src/Relation.d.ts +72 -44
  128. package/dist/types/src/Relation.d.ts.map +1 -1
  129. package/dist/types/src/Scope.d.ts +34 -0
  130. package/dist/types/src/Scope.d.ts.map +1 -0
  131. package/dist/types/src/StateMap.d.ts +32 -0
  132. package/dist/types/src/StateMap.d.ts.map +1 -0
  133. package/dist/types/src/StateMap.test.d.ts +2 -0
  134. package/dist/types/src/StateMap.test.d.ts.map +1 -0
  135. package/dist/types/src/Tag.d.ts +21 -5
  136. package/dist/types/src/Tag.d.ts.map +1 -1
  137. package/dist/types/src/TagIndex.d.ts +36 -0
  138. package/dist/types/src/TagIndex.d.ts.map +1 -0
  139. package/dist/types/src/TagIndex.test.d.ts +2 -0
  140. package/dist/types/src/TagIndex.test.d.ts.map +1 -0
  141. package/dist/types/src/Tagging.d.ts +31 -0
  142. package/dist/types/src/Tagging.d.ts.map +1 -0
  143. package/dist/types/src/Type.d.ts +357 -96
  144. package/dist/types/src/Type.d.ts.map +1 -1
  145. package/dist/types/src/View.d.ts +2 -5
  146. package/dist/types/src/View.d.ts.map +1 -1
  147. package/dist/types/src/exemplars.test.d.ts +2 -0
  148. package/dist/types/src/exemplars.test.d.ts.map +1 -0
  149. package/dist/types/src/index.d.ts +8 -2
  150. package/dist/types/src/index.d.ts.map +1 -1
  151. package/dist/types/src/internal/Annotation/annotations.d.ts +79 -37
  152. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  153. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  154. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  155. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  156. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  157. package/dist/types/src/internal/Annotation/index.d.ts +4 -2
  158. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
  159. package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
  160. package/dist/types/src/internal/Annotation/util.d.ts +14 -5
  161. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
  162. package/dist/types/src/internal/Entity/api.d.ts +3 -3
  163. package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
  164. package/dist/types/src/internal/Entity/entity.d.ts +72 -8
  165. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
  166. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  167. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  168. package/dist/types/src/internal/Entity/index.d.ts +2 -0
  169. package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
  170. package/dist/types/src/internal/Entity/model.d.ts +20 -17
  171. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  172. package/dist/types/src/internal/Entity/object.d.ts +3 -3
  173. package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
  174. package/dist/types/src/internal/Entity/relation.d.ts +30 -7
  175. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
  176. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  177. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  178. package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
  179. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  180. package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
  181. package/dist/types/src/internal/Format/date.d.ts.map +1 -1
  182. package/dist/types/src/internal/Format/format.d.ts +3 -2
  183. package/dist/types/src/internal/Format/format.d.ts.map +1 -1
  184. package/dist/types/src/internal/Format/index.d.ts +2 -2
  185. package/dist/types/src/internal/Format/index.d.ts.map +1 -1
  186. package/dist/types/src/internal/Format/number.d.ts.map +1 -1
  187. package/dist/types/src/internal/Format/object.d.ts +3 -1
  188. package/dist/types/src/internal/Format/object.d.ts.map +1 -1
  189. package/dist/types/src/internal/Format/types.d.ts.map +1 -1
  190. package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
  191. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +28 -28
  192. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
  193. package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
  194. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
  195. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
  196. package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
  197. package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
  198. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
  199. package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
  200. package/dist/types/src/internal/Obj/index.d.ts +0 -1
  201. package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
  202. package/dist/types/src/internal/Obj/json-serializer.d.ts +11 -10
  203. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
  204. package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
  205. package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
  206. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
  207. package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
  208. package/dist/types/src/internal/Query.d.ts +10 -0
  209. package/dist/types/src/internal/Query.d.ts.map +1 -0
  210. package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
  211. package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -1
  212. package/dist/types/src/internal/Ref/ref.d.ts +42 -19
  213. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  214. package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
  215. package/dist/types/src/internal/Type/index.d.ts +1 -2
  216. package/dist/types/src/internal/Type/index.d.ts.map +1 -1
  217. package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
  218. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
  219. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  220. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  221. package/dist/types/src/internal/common/api/meta.d.ts +14 -11
  222. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
  223. package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
  224. package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
  225. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
  226. package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
  227. package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
  228. package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
  229. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
  230. package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
  231. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
  232. package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
  233. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
  234. package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
  235. package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
  236. package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
  237. package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
  238. package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
  239. package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
  240. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
  241. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
  242. package/dist/types/src/internal/common/types/base.d.ts +4 -4
  243. package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
  244. package/dist/types/src/internal/common/types/entity.d.ts +63 -6
  245. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
  246. package/dist/types/src/internal/common/types/index.d.ts +1 -1
  247. package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
  248. package/dist/types/src/internal/common/types/meta.d.ts +23 -7
  249. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
  250. package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
  251. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
  252. package/dist/types/src/internal/common/types/typename.d.ts +7 -0
  253. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
  254. package/dist/types/src/internal/common/types/version.d.ts +1 -1
  255. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  256. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  257. package/dist/types/src/internal/index.d.ts +2 -0
  258. package/dist/types/src/internal/index.d.ts.map +1 -1
  259. package/dist/types/src/testing/test-data.d.ts +8 -8
  260. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  261. package/dist/types/src/testing/test-schema.d.ts +83 -89
  262. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  263. package/dist/types/src/testing/util.d.ts +5 -3
  264. package/dist/types/src/testing/util.d.ts.map +1 -1
  265. package/dist/types/tsconfig.tsbuildinfo +1 -1
  266. package/package.json +27 -19
  267. package/src/Annotation.test.ts +439 -0
  268. package/src/Annotation.ts +152 -4
  269. package/src/Collection.ts +6 -5
  270. package/src/Database.ts +117 -57
  271. package/src/Dataset.ts +10 -2
  272. package/src/Entity.test.ts +116 -6
  273. package/src/Entity.ts +130 -31
  274. package/src/Err.ts +4 -4
  275. package/src/Feed.ts +138 -43
  276. package/src/Filter.test.ts +90 -0
  277. package/src/Filter.ts +143 -27
  278. package/src/Hypergraph.ts +14 -9
  279. package/src/Json.test.ts +175 -0
  280. package/src/Json.ts +103 -0
  281. package/src/Key.ts +1 -1
  282. package/src/Migration.ts +114 -0
  283. package/src/Obj.test.ts +122 -19
  284. package/src/Obj.ts +279 -97
  285. package/src/Query.test.ts +317 -131
  286. package/src/Query.ts +181 -73
  287. package/src/QueryResult.ts +11 -0
  288. package/src/Ref.ts +22 -4
  289. package/src/Registry.ts +155 -0
  290. package/src/Relation.test.ts +10 -10
  291. package/src/Relation.ts +112 -71
  292. package/src/Scope.ts +50 -0
  293. package/src/StateMap.test.ts +56 -0
  294. package/src/StateMap.ts +99 -0
  295. package/src/Tag.md +88 -0
  296. package/src/Tag.ts +49 -6
  297. package/src/TagIndex.test.ts +57 -0
  298. package/src/TagIndex.ts +110 -0
  299. package/src/Tagging.ts +83 -0
  300. package/src/Type.test.ts +223 -18
  301. package/src/Type.ts +602 -132
  302. package/src/View.ts +11 -15
  303. package/src/exemplars.test.ts +21 -0
  304. package/src/index.ts +9 -3
  305. package/src/internal/Annotation/annotations.test.ts +82 -13
  306. package/src/internal/Annotation/annotations.ts +153 -115
  307. package/src/internal/Annotation/dictionary.ts +47 -0
  308. package/src/internal/Annotation/entity-dictionary.ts +40 -0
  309. package/src/internal/Annotation/index.ts +4 -2
  310. package/src/internal/Annotation/sorting.ts +0 -1
  311. package/src/internal/Annotation/util.ts +17 -8
  312. package/src/internal/Entity/api.ts +7 -8
  313. package/src/internal/Entity/entity.ts +196 -47
  314. package/src/internal/Entity/guard.ts +26 -0
  315. package/src/internal/Entity/index.ts +2 -0
  316. package/src/internal/Entity/model.ts +37 -28
  317. package/src/internal/Entity/object.ts +21 -6
  318. package/src/internal/Entity/relation.ts +68 -34
  319. package/src/internal/Entity/type-kind.ts +75 -0
  320. package/src/internal/Entity/type-uri.ts +87 -0
  321. package/src/internal/Entity/util.ts +10 -9
  322. package/src/internal/Entity/version.ts +0 -1
  323. package/src/internal/Format/date.test.ts +0 -1
  324. package/src/internal/Format/date.ts +0 -4
  325. package/src/internal/Format/format.test.ts +21 -1
  326. package/src/internal/Format/index.ts +2 -3
  327. package/src/internal/Format/object.ts +21 -4
  328. package/src/internal/Format/types.ts +1 -1
  329. package/src/internal/JsonSchema/annotations.ts +1 -1
  330. package/src/internal/JsonSchema/json-schema-type.ts +1 -1
  331. package/src/internal/JsonSchema/json-schema.test.ts +55 -142
  332. package/src/internal/JsonSchema/json-schema.ts +44 -31
  333. package/src/internal/Obj/clone.ts +9 -4
  334. package/src/internal/Obj/create-object.test.ts +13 -13
  335. package/src/internal/Obj/create-object.ts +68 -24
  336. package/src/internal/Obj/deleted.ts +1 -1
  337. package/src/internal/Obj/index.ts +0 -1
  338. package/src/internal/Obj/inspect.ts +4 -3
  339. package/src/internal/Obj/json-serializer.test.ts +102 -24
  340. package/src/internal/Obj/json-serializer.ts +105 -43
  341. package/src/internal/Obj/set-value.test.ts +31 -54
  342. package/src/internal/Obj/set-value.ts +1 -1
  343. package/src/internal/Obj/snapshot.ts +11 -4
  344. package/src/internal/Obj/typed-object.test.ts +9 -11
  345. package/src/internal/Obj/typed-object.ts +1 -1
  346. package/src/internal/Query.ts +159 -0
  347. package/src/internal/Ref/ref-array.ts +3 -4
  348. package/src/internal/Ref/ref.test.ts +17 -27
  349. package/src/internal/Ref/ref.ts +124 -59
  350. package/src/internal/Type/compose.test.ts +3 -2
  351. package/src/internal/Type/index.ts +1 -2
  352. package/src/internal/Type/manipulation.ts +0 -25
  353. package/src/internal/Type/type-schema.ts +60 -0
  354. package/src/internal/common/README.md +2 -2
  355. package/src/internal/common/api/meta.ts +19 -17
  356. package/src/internal/common/proxy/change-context.ts +1 -1
  357. package/src/internal/common/proxy/change.test.ts +118 -110
  358. package/src/internal/common/proxy/errors.ts +2 -2
  359. package/src/internal/common/proxy/handler.test.ts +1 -3
  360. package/src/internal/common/proxy/json-serializer.ts +26 -16
  361. package/src/internal/common/proxy/make-object.ts +43 -21
  362. package/src/internal/common/proxy/ownership.ts +2 -3
  363. package/src/internal/common/proxy/reactive-array.ts +1 -1
  364. package/src/internal/common/proxy/reactive.test.ts +54 -0
  365. package/src/internal/common/proxy/reactive.ts +11 -3
  366. package/src/internal/common/proxy/schema.test.ts +48 -86
  367. package/src/internal/common/proxy/typed-handler.test.ts +12 -12
  368. package/src/internal/common/proxy/typed-handler.ts +79 -19
  369. package/src/internal/common/proxy/typed-object.test.ts +16 -29
  370. package/src/internal/common/types/base.ts +4 -4
  371. package/src/internal/common/types/entity.ts +81 -2
  372. package/src/internal/common/types/index.ts +6 -1
  373. package/src/internal/common/types/meta.ts +49 -15
  374. package/src/internal/common/types/model-symbols.ts +16 -4
  375. package/src/internal/common/types/typename.ts +39 -3
  376. package/src/internal/common/types/well-known-types.ts +15 -0
  377. package/src/internal/index.ts +6 -0
  378. package/src/testing/api.test.ts +15 -10
  379. package/src/testing/test-data.ts +159 -100
  380. package/src/testing/test-schema.ts +22 -58
  381. package/src/testing/util.ts +14 -11
  382. package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
  383. package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +0 -7
  384. package/dist/lib/neutral/chunk-724GQYEN.mjs +0 -56
  385. package/dist/lib/neutral/chunk-724GQYEN.mjs.map +0 -7
  386. package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
  387. package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +0 -7
  388. package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
  389. package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
  390. package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +0 -7
  391. package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +0 -7
  392. package/dist/lib/neutral/chunk-DYDJBZEG.mjs +0 -102
  393. package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +0 -7
  394. package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +0 -7
  395. package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +0 -7
  396. package/dist/lib/neutral/chunk-NEGC54NE.mjs +0 -130
  397. package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +0 -7
  398. package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +0 -7
  399. package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +0 -7
  400. package/dist/lib/neutral/chunk-OENWMTE6.mjs +0 -45
  401. package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +0 -7
  402. package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
  403. package/dist/lib/neutral/chunk-RMLF7JOZ.mjs +0 -97
  404. package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +0 -7
  405. package/dist/lib/neutral/chunk-SEMVAGBM.mjs +0 -355
  406. package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +0 -7
  407. package/dist/lib/neutral/chunk-TQQZLKB7.mjs.map +0 -7
  408. package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
  409. package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +0 -7
  410. package/dist/lib/neutral/chunk-VA2F47ZC.mjs +0 -152
  411. package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +0 -7
  412. package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +0 -7
  413. package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +0 -7
  414. package/dist/types/src/SchemaRegistry.d.ts +0 -84
  415. package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
  416. package/dist/types/src/internal/Obj/ids.d.ts +0 -6
  417. package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
  418. package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
  419. package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
  420. package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
  421. package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
  422. package/src/SchemaRegistry.ts +0 -106
  423. package/src/internal/Obj/ids.ts +0 -12
  424. package/src/internal/Type/echo-schema.ts +0 -424
  425. package/src/internal/Type/persistent-schema.ts +0 -33
  426. /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Migration.mjs.map} +0 -0
  427. /package/dist/lib/neutral/{chunk-UTBRYVQC.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
  428. /package/dist/lib/neutral/{chunk-UI6MWK5W.mjs.map → chunk-TTCSATUD.mjs.map} +0 -0
package/src/View.ts CHANGED
@@ -8,8 +8,9 @@ import * as Schema from 'effect/Schema';
8
8
 
9
9
  import { QueryAST } from '@dxos/echo-protocol';
10
10
  import { JsonPath } from '@dxos/effect';
11
- import { PublicKey } from '@dxos/keys';
11
+ import { DXN, PublicKey } from '@dxos/keys';
12
12
 
13
+ import * as Annotation from './Annotation';
13
14
  import * as Filter from './Filter';
14
15
  import * as internal from './internal';
15
16
  import * as Obj from './Obj';
@@ -74,23 +75,18 @@ const ViewSchema = Schema.Struct({
74
75
  */
75
76
  projection: Projection,
76
77
  }).pipe(
77
- Type.object({
78
- typename: 'org.dxos.type.view',
79
- version: '0.1.0',
80
- }),
81
- internal.SystemTypeAnnotation.set(true),
78
+ internal.HiddenAnnotation.set(true),
79
+ Annotation.IconAnnotation.set({ icon: 'ph--funnel--regular', hue: 'green' }),
80
+ Type.makeObject(DXN.make('org.dxos.type.view', '0.1.0')),
82
81
  );
83
82
 
84
- export interface View extends Schema.Schema.Type<typeof ViewSchema> {}
85
-
86
- /**
87
- * View instance type.
88
- */
89
- // NOTE: This interface is explicitly defined rather than derived from the schema to avoid
90
- // TypeScript "cannot be named" portability errors. The schema contains QueryAST.Query which
91
- // references internal @dxos/echo-protocol module paths. Without this explicit interface,
92
- // any schema using Ref.Ref(View) would inherit the non-portable type and fail to compile.
83
+ // NOTE: Declared as a named interface and the `View` const is annotated `Type.Obj<View>` so
84
+ // downstream consumers see a named `View` type instead of the inlined `QueryAST.Query` union.
85
+ // Without the named interface, embedding `Type.getSchema(View.View)` in a downstream
86
+ // `Schema.Struct` triggers TS2742 portability errors (e.g. plugin-kanban, plugin-table).
93
87
  // TODO(wittjosiah): Find a better solution that doesn't require manually keeping the interface in sync.
88
+ export interface View extends Type.InstanceType<typeof ViewSchema> {}
89
+
94
90
  export const View: Type.Obj<View> = ViewSchema as any;
95
91
 
96
92
  export const make = (props: Partial<Obj.MakeProps<typeof View>>): View => {
@@ -0,0 +1,21 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import * as Obj from './Obj';
8
+ import { TestSchema } from './testing';
9
+ import type * as Type from './Type';
10
+
11
+ describe('Exemplars', () => {
12
+ test('factory', ({ expect }) => {
13
+ const factory = <S extends Type.AnyObj>(schema: S) => {
14
+ return (props: Obj.MakeProps<S>) => Obj.make(schema, props);
15
+ };
16
+
17
+ const makePerson = factory(TestSchema.Person);
18
+ const person = makePerson({ name: 'John Doe' });
19
+ expect(person.name).toBe('John Doe');
20
+ });
21
+ });
package/src/index.ts CHANGED
@@ -3,27 +3,33 @@
3
3
  //
4
4
 
5
5
  export { QueryAST } from '@dxos/echo-protocol';
6
- // TODO(wittjosiah): Refactor DXN to not use statics similar to Query.
7
- export { DXN } from '@dxos/keys';
6
+ export { DXN, EID, URI } from '@dxos/keys';
8
7
 
9
8
  export * as Annotation from './Annotation';
10
9
  export * as Database from './Database';
11
10
  export * as Entity from './Entity';
11
+ // TODO(burdon): Rename to Error (less problematic than Obj/Object).
12
12
  export * as Err from './Err';
13
13
  export * as Feed from './Feed';
14
14
  export * as Filter from './Filter';
15
15
  export * as Format from './Format';
16
16
  export * as Hypergraph from './Hypergraph';
17
+ export * as Json from './Json';
17
18
  export * as JsonSchema from './JsonSchema';
18
19
  export * as Key from './Key';
20
+ export * as Migration from './Migration';
19
21
  export * as Obj from './Obj';
20
22
  export * as Order from './Order';
21
23
  export * as Query from './Query';
22
24
  export * as QueryResult from './QueryResult';
23
25
  export * as Ref from './Ref';
26
+ export * as Registry from './Registry';
24
27
  export * as Relation from './Relation';
25
- export * as SchemaRegistry from './SchemaRegistry';
28
+ export * as Scope from './Scope';
29
+ export * as StateMap from './StateMap';
26
30
  export * as Tag from './Tag';
31
+ export * as TagIndex from './TagIndex';
32
+ export * as Tagging from './Tagging';
27
33
  export * as Type from './Type';
28
34
  export * as Collection from './Collection';
29
35
  export * as View from './View';
@@ -5,9 +5,13 @@
5
5
  import * as Schema from 'effect/Schema';
6
6
  import { describe, test } from 'vitest';
7
7
 
8
- import { EchoObjectSchema } from '../Entity';
8
+ import { DXN } from '@dxos/keys';
9
9
 
10
- import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema } from './annotations';
10
+ import { createEchoSchema } from '../../testing';
11
+ import * as Type from '../../Type';
12
+ import { EntityKind } from '../common/types';
13
+ import { EchoObjectSchema } from '../Entity';
14
+ import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema, getTypeAnnotation } from './annotations';
11
15
 
12
16
  // TODO(dmaretskyi): Use one of the testing schemas.
13
17
  const TestObject = Schema.Struct({
@@ -18,21 +22,16 @@ const TestObject = Schema.Struct({
18
22
 
19
23
  type TestObject = Schema.Schema.Type<typeof TestObject>;
20
24
 
21
- const TestEchoSchema = TestObject.pipe(
22
- EchoObjectSchema({
23
- typename: 'org.dxos.type.test',
24
- version: '0.1.0',
25
- }),
26
- );
25
+ const TestEchoSchema = TestObject.pipe(EchoObjectSchema(DXN.make('org.dxos.type.test', '0.1.0')));
27
26
 
28
- type TestEchoSchema = Schema.Schema.Type<typeof TestEchoSchema>;
27
+ type TestEchoSchema = Type.InstanceType<typeof TestEchoSchema>;
29
28
 
30
29
  describe('annotations', () => {
31
30
  describe('Typename', () => {
32
31
  test('should validate typename', ({ expect }) => {
33
32
  // Valid (reverse-DNS format).
34
33
  expect(TypenameSchema.make('org.dxos.type.foo')).to.exist;
35
- expect(TypenameSchema.make('org.dxos.type.foo-bar')).to.exist;
34
+ expect(TypenameSchema.make('org.dxos.type.fooBar')).to.exist;
36
35
  expect(TypenameSchema.make('org.dxos.type.foobar')).to.exist;
37
36
 
38
37
  // Invalid.
@@ -82,15 +81,85 @@ describe('annotations', () => {
82
81
  expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
83
82
  });
84
83
 
84
+ test('should skip empty string and fallback to next path', ({ expect }) => {
85
+ const obj: TestObject = {
86
+ name: '',
87
+ fallbackName: 'Fallback Name',
88
+ other: 'Other',
89
+ };
90
+
91
+ expect(getLabelWithSchema(TestObject, obj)).toEqual('Fallback Name');
92
+ });
93
+
94
+ test('should skip whitespace-only string and fallback to next path', ({ expect }) => {
95
+ const obj: TestObject = {
96
+ name: ' ',
97
+ fallbackName: 'Fallback Name',
98
+ other: 'Other',
99
+ };
100
+
101
+ expect(getLabelWithSchema(TestObject, obj)).toEqual('Fallback Name');
102
+ });
103
+
104
+ test('should return undefined if all paths are empty strings', ({ expect }) => {
105
+ const obj: TestObject = {
106
+ name: '',
107
+ fallbackName: '',
108
+ other: 'Other',
109
+ };
110
+
111
+ expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
112
+ });
113
+
114
+ test('should return undefined if all paths are whitespace-only', ({ expect }) => {
115
+ const obj: TestObject = {
116
+ name: ' ',
117
+ fallbackName: '\t\n',
118
+ other: 'Other',
119
+ };
120
+
121
+ expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
122
+ });
123
+
124
+ test('should preserve original string with leading/trailing whitespace when valid', ({ expect }) => {
125
+ const obj: TestObject = {
126
+ name: ' Valid Name ',
127
+ fallbackName: 'Fallback Name',
128
+ other: 'Other',
129
+ };
130
+
131
+ expect(getLabelWithSchema(TestObject, obj)).toEqual(' Valid Name ');
132
+ });
133
+
85
134
  test('should return label from echo object', ({ expect }) => {
86
- const obj: TestEchoSchema = {
135
+ const obj = {
87
136
  id: 'test',
88
137
  name: 'Primary Name',
89
138
  fallbackName: 'Fallback Name',
90
139
  other: 'Other',
91
- };
140
+ } as unknown as TestEchoSchema;
141
+
142
+ expect(getLabelWithSchema(Type.getSchema(TestEchoSchema), obj)).toEqual('Primary Name');
143
+ });
144
+ });
145
+
146
+ // `getTypeAnnotation` reads annotations from an Effect Schema. To read off a
147
+ // `Type.Type` entity (static or persisted), unwrap with `Type.getSchema(entity)`
148
+ // first — that handles both the static `StaticTypeSchemaSlot` case and the
149
+ // persisted `jsonSchema` rebuild case.
150
+ describe('getTypeAnnotation via Type.getSchema(entity)', () => {
151
+ test('returns TypeAnnotation for a static Type.Obj entity', ({ expect }) => {
152
+ const annotation = getTypeAnnotation(Type.getSchema(TestEchoSchema));
153
+ expect(annotation).toBeDefined();
154
+ expect(annotation?.kind).toBe(EntityKind.Object);
155
+ expect(annotation?.typename).toBe('org.dxos.type.test');
156
+ });
92
157
 
93
- expect(getLabelWithSchema(TestEchoSchema, obj)).toEqual('Primary Name');
158
+ test('returns TypeAnnotation for a persisted Type.Type entity', ({ expect }) => {
159
+ const persisted = createEchoSchema(Type.getSchema(TestEchoSchema));
160
+ const annotation = getTypeAnnotation(Type.getSchema(persisted));
161
+ expect(annotation).toBeDefined();
162
+ expect(annotation?.typename).toBe('org.dxos.type.test');
94
163
  });
95
164
  });
96
165
  });
@@ -7,16 +7,17 @@ import * as Option from 'effect/Option';
7
7
  import * as Schema from 'effect/Schema';
8
8
  import * as SchemaAST from 'effect/SchemaAST';
9
9
 
10
- import { raise } from '@dxos/debug';
11
10
  import { type JsonPath, getField } from '@dxos/effect';
12
11
  import { assertArgument, invariant } from '@dxos/invariant';
13
- import { DXN } from '@dxos/keys';
12
+ import { DXN, URI } from '@dxos/keys';
14
13
  import { type Primitive } from '@dxos/util';
15
14
 
15
+ import type * as Annotation from '../../Annotation';
16
16
  import { type Mutable } from '../common/proxy';
17
17
  import { type AnyProperties, EntityKind, TypeId, getSchema } from '../common/types';
18
+ import { createAnnotationHelper } from './util';
18
19
 
19
- import { type AnnotationHelper, createAnnotationHelper } from './util';
20
+ const ANNOTATION_TYPE_ID: Annotation.TypeId = '~@dxos/echo/Annotation' as const;
20
21
 
21
22
  /**
22
23
  * @internal
@@ -47,39 +48,27 @@ export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
47
48
  )(schema.ast);
48
49
 
49
50
  /**
50
- * @returns DXN of the schema.
51
+ * @returns The schema's type identifier URI — whichever URI fits.
51
52
  *
52
- * For non-stored schema returns `dxn:type:`.
53
- * For stored schema returns `dxn:echo:`.
53
+ * - Stored (dynamic) schemas: the schema-as-object's EID, so loaded objects ride
54
+ * along with their schema as a strong dependency.
55
+ * - Non-stored (static) schemas: the typename DXN built from `TypeAnnotation`.
56
+ *
57
+ * This URI is what gets written to an object's `system.type`; queries that filter by
58
+ * type also use it (see `Filter.type` / `getTypeURIFromSpecifier`), so both sides
59
+ * stay symmetric without per-schema branching.
54
60
  */
55
- export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
61
+ export const getSchemaURI = (schema: Schema.Schema.All): URI.URI | undefined => {
56
62
  assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
57
63
  const id = getTypeIdentifierAnnotation(schema);
58
64
  if (id) {
59
- return DXN.parse(id);
65
+ return URI.make(id);
60
66
  }
61
-
62
- // TODO(dmaretskyi): Add support for dynamic schema.
63
67
  const objectAnnotation = getTypeAnnotation(schema);
64
- if (!objectAnnotation) {
65
- return undefined;
66
- }
67
-
68
- return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
69
- };
70
-
71
- /**
72
- * @param input schema or a typename string.
73
- * @return type DXN.
74
- */
75
- export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN => {
76
- if (Schema.isSchema(input)) {
77
- return getSchemaDXN(input) ?? raise(new TypeError('Schema has no DXN'));
78
- } else {
79
- assertArgument(typeof input === 'string', 'input');
80
- assertArgument(!input.startsWith('dxn:'), 'input');
81
- return DXN.fromTypename(input);
68
+ if (objectAnnotation) {
69
+ return DXN.make(objectAnnotation.typename, objectAnnotation.version);
82
70
  }
71
+ return undefined;
83
72
  };
84
73
 
85
74
  //
@@ -90,14 +79,15 @@ export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN
90
79
  * Fully qualified globally unique typename.
91
80
  * Example: `org.dxos.type.message`
92
81
  */
93
- // TODO(burdon): Reconcile with short DXN format.
94
- // TODO(burdon): Change "type" => "schema" throughout.
95
- export const TypenameSchema = Schema.String.pipe(Schema.pattern(/^[a-z][a-z0-9]*(\.[a-z][a-z0-9-]*){2,}$/)).annotations(
96
- {
97
- description: 'Fully qualified globally unique typename in lowercase reverse-DNS form.',
98
- example: 'org.dxos.type.message',
99
- },
100
- );
82
+ // TODO(wittjosiah): Factor out to DXN spec.
83
+ export const TypenameSchema = Schema.String.pipe(
84
+ Schema.pattern(
85
+ /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/,
86
+ ),
87
+ ).annotations({
88
+ description: 'Fully qualified globally unique typename in reverse-DNS form.',
89
+ example: 'org.dxos.type.message',
90
+ });
101
91
 
102
92
  /**
103
93
  * Semantic version format: `major.minor.patch`
@@ -186,8 +176,15 @@ export const getTypename = (obj: AnyProperties): string | undefined => {
186
176
  // Try to extract typename from DXN.
187
177
  return getSchemaTypename(schema);
188
178
  } else {
189
- const type = getTypeDXN(obj);
190
- return type?.asTypeDXN()?.type;
179
+ // `obj` may be an arbitrary value (e.g. from `isInstanceOf`); read TypeId
180
+ // directly so we return undefined for non-entities instead of throwing.
181
+ const type = (obj as any)?.[TypeId];
182
+ // Parse the URI string to extract typename.
183
+ if (DXN.isDXN(type)) {
184
+ const parsed = DXN.tryMake(type);
185
+ return parsed && DXN.getName(parsed);
186
+ }
187
+ return undefined;
191
188
  }
192
189
  };
193
190
 
@@ -195,8 +192,8 @@ export const getTypename = (obj: AnyProperties): string | undefined => {
195
192
  * @internal (use Type.setTypename)
196
193
  */
197
194
  // TODO(dmaretskyi): Rename setTypeDXN.
198
- export const setTypename = (obj: any, typename: DXN): void => {
199
- invariant(typename instanceof DXN, 'Invalid type.');
195
+ export const setTypename = (obj: any, typename: URI.URI): void => {
196
+ assertArgument(typeof typename === 'string', 'typename', 'Invalid type.');
200
197
  Object.defineProperty(obj, TypeId, {
201
198
  value: typename,
202
199
  writable: false,
@@ -206,68 +203,25 @@ export const setTypename = (obj: any, typename: DXN): void => {
206
203
  };
207
204
 
208
205
  /**
209
- * @returns Object type as {@link DXN}.
210
- * @returns undefined if the object doesn't have a type.
206
+ * @returns Object type URI — either a typename {@link DXN} or an `echo:` reference to a stored Schema object.
207
+ * @returns undefined if the object has no registered type URI (e.g. unresolved query result).
211
208
  * @example `dxn:com.example.type.person:1.0.0`
209
+ * @example `echo:/01KKKG2FHWCMTR0BY00GJSVT1X` (stored schema)
212
210
  *
213
- * @internal (use Obj.getTypeDXN)
211
+ * @internal (use Obj.getTypeURI)
214
212
  */
215
- // TODO(burdon): Narrow type.
216
- export const getTypeDXN = (obj: AnyProperties): DXN | undefined => {
217
- if (!obj) {
213
+ export const getTypeURI = (obj: AnyProperties): URI.URI | undefined => {
214
+ if (obj == null) {
218
215
  return undefined;
219
216
  }
220
-
221
217
  const type = (obj as any)[TypeId];
222
- if (!type) {
218
+ if (type == null) {
223
219
  return undefined;
224
220
  }
225
-
226
- invariant(type instanceof DXN, 'Invalid object.');
221
+ invariant(URI.isURI(type), 'Invalid object.');
227
222
  return type;
228
223
  };
229
224
 
230
- /**
231
- * Checks if the object is an instance of the schema.
232
- * Only typename is compared, the schema version is ignored.
233
- *
234
- * The following cases are considered to mean that the object is an instance of the schema:
235
- * - Object was created with this exact schema.
236
- * - Object was created with a different version of this schema.
237
- * - Object was created with a different schema (maybe dynamic) that has the same typename.
238
- */
239
- // TODO(burdon): Can we use `Schema.is`?
240
- export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
241
- schema: Schema,
242
- object: any,
243
- ): object is Schema.Schema.Type<Schema> => {
244
- if (object == null) {
245
- return false;
246
- }
247
-
248
- const schemaDXN = getSchemaDXN(schema);
249
- if (!schemaDXN) {
250
- throw new Error('Schema must have an object annotation.');
251
- }
252
-
253
- const type = getTypeDXN(object);
254
- if (type && DXN.equals(type, schemaDXN)) {
255
- return true;
256
- }
257
-
258
- const typename = getTypename(object);
259
- if (!typename) {
260
- return false;
261
- }
262
-
263
- const typeDXN = schemaDXN.asTypeDXN();
264
- if (!typeDXN) {
265
- return false;
266
- }
267
-
268
- return typeDXN.type === typename;
269
- };
270
-
271
225
  //
272
226
  // PropertyMeta
273
227
  //
@@ -286,6 +240,12 @@ export type PropertyMetaAnnotation = {
286
240
 
287
241
  // TODO(wittjosiah): Align with other annotations.
288
242
  // TODO(wittjosiah): Why is this separate from FormatAnnotation?
243
+ /**
244
+ * Apply property-level metadata to an Effect schema. Only accepts
245
+ * `Schema.Schema.Any` — apply BEFORE wrapping the schema with
246
+ * `Type.makeObject` / `Type.makeRelation`. To read property meta off a
247
+ * `Type.Type` entity, unwrap it first with `Type.getSchema(entity)`.
248
+ */
289
249
  export const PropertyMeta = (name: string, value: PropertyMetaValue) => {
290
250
  return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {
291
251
  const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;
@@ -323,10 +283,10 @@ export const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');
323
283
  export type SchemaMeta = TypeMeta & { id: string };
324
284
 
325
285
  /**
326
- * Identifies a schema as a schema for a hidden system type.
286
+ * Identifies a schema as hidden from user-facing surfaces (like dotfiles — visible only via an advanced setting).
327
287
  */
328
- export const SystemTypeAnnotationId = Symbol.for('@dxos/schema/annotation/SystemType');
329
- export const SystemTypeAnnotation = createAnnotationHelper<boolean>(SystemTypeAnnotationId);
288
+ export const HiddenAnnotationId = Symbol.for('@dxos/schema/annotation/Hidden');
289
+ export const HiddenAnnotation = createAnnotationHelper<boolean>(HiddenAnnotationId);
330
290
 
331
291
  /**
332
292
  * Identifies label property or JSON path expression.
@@ -338,6 +298,7 @@ export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationI
338
298
  /**
339
299
  * Returns the label for a given object based on {@link LabelAnnotationId}.
340
300
  * Lower-level version that requires explicit schema parameter.
301
+ * Skips empty strings and whitespace-only strings, continuing to the next field.
341
302
  */
342
303
  // TODO(burdon): Convert to JsonPath?
343
304
  export const getLabelWithSchema = <S extends Schema.Schema.Any>(
@@ -353,7 +314,13 @@ export const getLabelWithSchema = <S extends Schema.Schema.Any>(
353
314
  );
354
315
  const value = getField(object, accessor as JsonPath);
355
316
  switch (typeof value) {
356
- case 'string':
317
+ case 'string': {
318
+ const trimmed = value.trim();
319
+ if (trimmed.length > 0) {
320
+ return value;
321
+ }
322
+ continue;
323
+ }
357
324
  case 'number':
358
325
  case 'boolean':
359
326
  case 'bigint':
@@ -436,10 +403,16 @@ export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
436
403
  * Identifies if a property should be included in a form or not.
437
404
  * By default, all properties are included in forms, so this is opt-out.
438
405
  */
439
- // TODO(burdon): UI concern.
440
406
  export const FormInputAnnotationId = Symbol.for('@dxos/schema/annotation/FormInput');
441
407
  export const FormInputAnnotation = createAnnotationHelper<boolean>(FormInputAnnotationId);
442
408
 
409
+ /**
410
+ * When set on a `Ref` property, the form renders the referenced object's own
411
+ * fields inline (a nested form bound to the target) instead of a picker.
412
+ */
413
+ export const FormInlineAnnotationId = Symbol.for('@dxos/schema/annotation/FormInline');
414
+ export const FormInlineAnnotation = createAnnotationHelper<boolean>(FormInlineAnnotationId);
415
+
443
416
  /**
444
417
  * Default field to be used on referenced schema to lookup the value.
445
418
  */
@@ -465,26 +438,29 @@ interface MakeAnnoationsProps<T> {
465
438
  schema: Schema.Schema<T, any, never>;
466
439
  }
467
440
 
468
- // TODO(wittjosiah): Comment.
469
- export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): AnnotationHelper<T> => {
441
+ // Annotation ids use the same NSID / reverse-DNS format as TypenameSchema —
442
+ // dot-separated segments, middle segments may be hyphenated, final segment may be camelCase.
443
+ // At least 3 segments are required (e.g. org.dxos.annotation.example).
444
+ export const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): Annotation.Annotation<T> => {
470
445
  assertArgument(
471
- /^[a-z][a-z0-9]*(\.[a-z][a-z0-9-]*){2,}$/.test(props.id),
446
+ /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?){2,}(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)?$/.test(
447
+ props.id,
448
+ ),
472
449
  'id',
473
- 'Annotation id must be in the FQN format (org.dxos.annotation.example).',
450
+ 'Annotation id must be in the FQN format (org.dxos.annotation.example or org.dxos.space.rootCollection).',
474
451
  );
475
452
 
476
- const getFromAst = (ast: SchemaAST.AST) =>
477
- SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
478
- Option.map((meta) => meta[props.id] as unknown),
479
- Option.map(Schema.decodeUnknownSync(props.schema)),
480
- );
481
-
482
- return {
483
- get: (schema) => getFromAst(schema.ast),
484
- getFromAst: (ast) => getFromAst(ast),
453
+ const annotation: Annotation.Annotation<T> = {
454
+ [ANNOTATION_TYPE_ID]: { _Type: {} as T },
455
+ key: props.id as Annotation.Key,
456
+ schema: props.schema,
457
+ get: (schema) => getFromAst(schema.ast, annotation),
458
+ getFromAst: (ast) => getFromAst(ast, annotation),
485
459
  set: (value) =>
486
460
  PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,
487
461
  };
462
+
463
+ return annotation;
488
464
  };
489
465
 
490
466
  const IconAnnotationSchema = Schema.Struct({
@@ -512,7 +488,6 @@ const IconAnnotationSchema = Schema.Struct({
512
488
  * - 'pink'
513
489
  * - 'rose'
514
490
  */
515
-
516
491
  hue: Schema.optional(Schema.String),
517
492
  });
518
493
 
@@ -526,20 +501,54 @@ export const IconAnnotation = makeUserAnnotation<IconAnnotation>({
526
501
  schema: IconAnnotationSchema,
527
502
  });
528
503
 
504
+ /**
505
+ * Indicates that this entity's icon should be resolved from a property whose value is a `Ref`
506
+ * to another entity. Consumers (e.g. graph node builders) resolve the ref target and use that
507
+ * target's schema `IconAnnotation` in place of the static one declared on this schema.
508
+ *
509
+ * Useful for wrapper schemas that delegate their visual identity to a referenced sub-entity
510
+ * (e.g. a generic `Game` whose icon should come from its `variant` ref's typed state).
511
+ */
512
+ export const IconFromRefAnnotation = makeUserAnnotation<string>({
513
+ id: 'org.dxos.annotation.icon.from-ref',
514
+ schema: Schema.String,
515
+ });
516
+
517
+ /**
518
+ * Options for {@link getLabel}.
519
+ */
520
+ export type GetLabelOptions = {
521
+ /**
522
+ * Strategy for deriving a label when the entity has no `LabelAnnotation` value.
523
+ * - `'typename'`: use the entity's typename (e.g. `org.dxos.type.table`).
524
+ * Useful for Card.Title chrome that must always display something, even
525
+ * for unlabeled objects.
526
+ */
527
+ fallback?: 'typename';
528
+ };
529
+
529
530
  /**
530
531
  * Get the label of an entity.
531
532
  * Accepts both reactive entities and snapshots.
533
+ *
534
+ * If `options.fallback === 'typename'` and no label is set, returns the
535
+ * entity's typename instead.
532
536
  */
533
- export const getLabel = (entity: AnyProperties): string | undefined => {
537
+ export const getLabel = (entity: AnyProperties, options?: GetLabelOptions): string | undefined => {
534
538
  const schema = getSchema(entity);
535
- if (schema != null) {
536
- return getLabelWithSchema(schema, entity);
539
+ const label = schema != null ? getLabelWithSchema(schema, entity) : undefined;
540
+ if (label != null) {
541
+ return label;
542
+ }
543
+ if (options?.fallback === 'typename') {
544
+ return getTypename(entity);
537
545
  }
546
+ return undefined;
538
547
  };
539
548
 
540
549
  /**
541
550
  * Set the label of an entity.
542
- * Must be called within an Obj.change or Relation.change callback.
551
+ * Must be called within an Obj.update or Relation.update callback.
543
552
  */
544
553
  export const setLabel = (entity: Mutable<AnyProperties>, label: string) => {
545
554
  const schema = getSchema(entity);
@@ -559,9 +568,29 @@ export const getDescription = (entity: AnyProperties): string | undefined => {
559
568
  }
560
569
  };
561
570
 
571
+ /**
572
+ * Get the icon annotation for an entity, resolved via its type-level `IconAnnotation`.
573
+ * Accepts both reactive entities and snapshots.
574
+ *
575
+ * Returns the full `{ icon, hue }` annotation so callers can use both the phosphor icon
576
+ * name and the suggested colour. Callers wanting just the icon name typically write
577
+ * `Obj.getIcon(obj)?.icon ?? 'ph--cube--regular'`.
578
+ *
579
+ * Note: this is the "static" icon from the object's own schema. It does not follow
580
+ * `IconFromRefAnnotation` delegation — call sites needing that (e.g. app-graph node
581
+ * builders) should resolve the ref themselves.
582
+ */
583
+ export const getIcon = (entity: AnyProperties): IconAnnotation | undefined => {
584
+ const schema = getSchema(entity);
585
+ if (schema == null) {
586
+ return undefined;
587
+ }
588
+ return Option.getOrUndefined(IconAnnotation.get(schema));
589
+ };
590
+
562
591
  /**
563
592
  * Set the description of an entity.
564
- * Must be called within an Obj.change or Relation.change callback.
593
+ * Must be called within an Obj.update or Relation.update callback.
565
594
  */
566
595
  export const setDescription = (entity: Mutable<AnyProperties>, description: string) => {
567
596
  const schema = getSchema(entity);
@@ -569,3 +598,12 @@ export const setDescription = (entity: Mutable<AnyProperties>, description: stri
569
598
  setDescriptionWithSchema(schema, entity, description);
570
599
  }
571
600
  };
601
+
602
+ export { Dictionary, Key, getDictionary, setDictionary } from './dictionary';
603
+
604
+ export const getFromAst = <T>(ast: SchemaAST.AST, annotation: Annotation.Annotation<T>): Option.Option<T> => {
605
+ return SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(
606
+ Option.flatMap((meta) => Option.fromNullable(meta[annotation.key])),
607
+ Option.map(Schema.decodeUnknownSync(annotation.schema)),
608
+ );
609
+ };