@dxos/echo 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8

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 (731) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +10 -11
  3. package/dist/lib/neutral/Annotation.mjs +68 -0
  4. package/dist/lib/neutral/Database.mjs +38 -0
  5. package/dist/lib/neutral/Entity.mjs +72 -0
  6. package/dist/lib/neutral/Err.mjs +12 -0
  7. package/dist/lib/neutral/Feed.mjs +54 -0
  8. package/dist/lib/neutral/Filter.mjs +70 -0
  9. package/dist/lib/neutral/Format.mjs +86 -0
  10. package/dist/lib/neutral/Format.mjs.map +7 -0
  11. package/dist/lib/neutral/JsonSchema.mjs +18 -0
  12. package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
  13. package/dist/lib/neutral/Key.mjs +16 -0
  14. package/dist/lib/neutral/Key.mjs.map +7 -0
  15. package/dist/lib/neutral/Migration.mjs +18 -0
  16. package/dist/lib/neutral/Migration.mjs.map +7 -0
  17. package/dist/lib/neutral/Obj.mjs +122 -0
  18. package/dist/lib/neutral/Obj.mjs.map +7 -0
  19. package/dist/lib/neutral/Order.mjs +16 -0
  20. package/dist/lib/neutral/Order.mjs.map +7 -0
  21. package/dist/lib/neutral/Query.mjs +38 -0
  22. package/dist/lib/neutral/Query.mjs.map +7 -0
  23. package/dist/lib/neutral/QueryResult.mjs +2 -0
  24. package/dist/lib/neutral/QueryResult.mjs.map +7 -0
  25. package/dist/lib/neutral/Ref.mjs +25 -0
  26. package/dist/lib/neutral/Ref.mjs.map +7 -0
  27. package/dist/lib/neutral/Registry.mjs +14 -0
  28. package/dist/lib/neutral/Registry.mjs.map +7 -0
  29. package/dist/lib/neutral/Relation.mjs +97 -0
  30. package/dist/lib/neutral/Relation.mjs.map +7 -0
  31. package/dist/lib/neutral/Scope.mjs +12 -0
  32. package/dist/lib/neutral/Scope.mjs.map +7 -0
  33. package/dist/lib/neutral/Tag.mjs +32 -0
  34. package/dist/lib/neutral/Tag.mjs.map +7 -0
  35. package/dist/lib/neutral/Type.mjs +65 -0
  36. package/dist/lib/neutral/Type.mjs.map +7 -0
  37. package/dist/lib/neutral/chunk-35INCYOE.mjs +7 -0
  38. package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
  39. package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
  40. package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
  42. package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
  43. package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
  44. package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
  45. package/dist/lib/neutral/chunk-5SUJPHAE.mjs +34 -0
  46. package/dist/lib/neutral/chunk-5SUJPHAE.mjs.map +7 -0
  47. package/dist/lib/neutral/chunk-6M2Z6WBH.mjs +93 -0
  48. package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
  49. package/dist/lib/neutral/chunk-6YDI3J37.mjs +346 -0
  50. package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
  51. package/dist/lib/neutral/chunk-7FPIAJIV.mjs +2279 -0
  52. package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +7 -0
  53. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +25 -0
  54. package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
  55. package/dist/lib/neutral/chunk-7PI7C4EF.mjs +747 -0
  56. package/dist/lib/neutral/chunk-7PI7C4EF.mjs.map +7 -0
  57. package/dist/lib/neutral/chunk-BBFJWWAV.mjs +51 -0
  58. package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
  59. package/dist/lib/neutral/chunk-EVK6XBXO.mjs +56 -0
  60. package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
  61. package/dist/lib/neutral/chunk-IGK6FN65.mjs +27 -0
  62. package/dist/lib/neutral/chunk-IGK6FN65.mjs.map +7 -0
  63. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  64. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  65. package/dist/lib/neutral/chunk-LWXVKPPW.mjs +281 -0
  66. package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
  67. package/dist/lib/neutral/chunk-MZ7K3MLL.mjs +48 -0
  68. package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
  69. package/dist/lib/neutral/chunk-O6BH7EPN.mjs +94 -0
  70. package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
  71. package/dist/lib/neutral/chunk-QQIYS74I.mjs +336 -0
  72. package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
  73. package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
  74. package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
  75. package/dist/lib/neutral/chunk-RIVWNMSF.mjs +41 -0
  76. package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
  77. package/dist/lib/neutral/chunk-SBVFRTST.mjs +160 -0
  78. package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
  79. package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
  80. package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
  81. package/dist/lib/neutral/chunk-TFEWTY5A.mjs +428 -0
  82. package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
  83. package/dist/lib/neutral/chunk-TYGKCRMK.mjs +437 -0
  84. package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
  85. package/dist/lib/neutral/chunk-UUP46KUQ.mjs +205 -0
  86. package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
  87. package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
  88. package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
  89. package/dist/lib/neutral/chunk-WTQJHC75.mjs +395 -0
  90. package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
  91. package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
  92. package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
  93. package/dist/lib/neutral/chunk-ZGNNFYHS.mjs +132 -0
  94. package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
  95. package/dist/lib/neutral/index.mjs +111 -0
  96. package/dist/lib/neutral/index.mjs.map +7 -0
  97. package/dist/lib/neutral/internal/index.mjs +539 -0
  98. package/dist/lib/neutral/internal/index.mjs.map +7 -0
  99. package/dist/lib/neutral/meta.json +1 -0
  100. package/dist/lib/neutral/testing/index.mjs +458 -0
  101. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  102. package/dist/types/src/Annotation.d.ts +128 -0
  103. package/dist/types/src/Annotation.d.ts.map +1 -0
  104. package/dist/types/src/Annotation.test.d.ts +2 -0
  105. package/dist/types/src/Annotation.test.d.ts.map +1 -0
  106. package/dist/types/src/Collection.d.ts +15 -0
  107. package/dist/types/src/Collection.d.ts.map +1 -0
  108. package/dist/types/src/Database.d.ts +208 -0
  109. package/dist/types/src/Database.d.ts.map +1 -0
  110. package/dist/types/src/Dataset.d.ts +29 -0
  111. package/dist/types/src/Dataset.d.ts.map +1 -0
  112. package/dist/types/src/Entity.d.ts +247 -0
  113. package/dist/types/src/Entity.d.ts.map +1 -0
  114. package/dist/types/src/Entity.test.d.ts +2 -0
  115. package/dist/types/src/Entity.test.d.ts.map +1 -0
  116. package/dist/types/src/Err.d.ts +107 -0
  117. package/dist/types/src/Err.d.ts.map +1 -0
  118. package/dist/types/src/Feed.d.ts +229 -0
  119. package/dist/types/src/Feed.d.ts.map +1 -0
  120. package/dist/types/src/Filter.d.ts +175 -0
  121. package/dist/types/src/Filter.d.ts.map +1 -0
  122. package/dist/types/src/Filter.test.d.ts +2 -0
  123. package/dist/types/src/Filter.test.d.ts.map +1 -0
  124. package/dist/types/src/Format.d.ts +2 -0
  125. package/dist/types/src/Format.d.ts.map +1 -0
  126. package/dist/types/src/Hypergraph.d.ts +70 -0
  127. package/dist/types/src/Hypergraph.d.ts.map +1 -0
  128. package/dist/types/src/Json.d.ts +33 -0
  129. package/dist/types/src/Json.d.ts.map +1 -0
  130. package/dist/types/src/Json.test.d.ts +2 -0
  131. package/dist/types/src/Json.test.d.ts.map +1 -0
  132. package/dist/types/src/JsonSchema.d.ts +16 -0
  133. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  134. package/dist/types/src/Key.d.ts +2 -1
  135. package/dist/types/src/Key.d.ts.map +1 -1
  136. package/dist/types/src/Migration.d.ts +72 -0
  137. package/dist/types/src/Migration.d.ts.map +1 -0
  138. package/dist/types/src/Obj.d.ts +483 -110
  139. package/dist/types/src/Obj.d.ts.map +1 -1
  140. package/dist/types/src/Obj.test.d.ts +2 -0
  141. package/dist/types/src/Obj.test.d.ts.map +1 -0
  142. package/dist/types/src/Order.d.ts +26 -0
  143. package/dist/types/src/Order.d.ts.map +1 -0
  144. package/dist/types/src/Query.d.ts +231 -0
  145. package/dist/types/src/Query.d.ts.map +1 -0
  146. package/dist/types/src/Query.test.d.ts +2 -0
  147. package/dist/types/src/Query.test.d.ts.map +1 -0
  148. package/dist/types/src/QueryResult.d.ts +101 -0
  149. package/dist/types/src/QueryResult.d.ts.map +1 -0
  150. package/dist/types/src/Ref.d.ts +69 -11
  151. package/dist/types/src/Ref.d.ts.map +1 -1
  152. package/dist/types/src/Registry.d.ts +131 -0
  153. package/dist/types/src/Registry.d.ts.map +1 -0
  154. package/dist/types/src/Relation.d.ts +321 -23
  155. package/dist/types/src/Relation.d.ts.map +1 -1
  156. package/dist/types/src/Relation.test.d.ts +2 -0
  157. package/dist/types/src/Relation.test.d.ts.map +1 -0
  158. package/dist/types/src/Scope.d.ts +35 -0
  159. package/dist/types/src/Scope.d.ts.map +1 -0
  160. package/dist/types/src/Tag.d.ts +26 -9
  161. package/dist/types/src/Tag.d.ts.map +1 -1
  162. package/dist/types/src/Type.d.ts +397 -106
  163. package/dist/types/src/Type.d.ts.map +1 -1
  164. package/dist/types/src/Type.test.d.ts +2 -0
  165. package/dist/types/src/Type.test.d.ts.map +1 -0
  166. package/dist/types/src/View.d.ts +65 -0
  167. package/dist/types/src/View.d.ts.map +1 -0
  168. package/dist/types/src/exemplars.test.d.ts +2 -0
  169. package/dist/types/src/exemplars.test.d.ts.map +1 -0
  170. package/dist/types/src/hierarchy.test.d.ts +2 -0
  171. package/dist/types/src/hierarchy.test.d.ts.map +1 -0
  172. package/dist/types/src/index.d.ts +21 -5
  173. package/dist/types/src/index.d.ts.map +1 -1
  174. package/dist/types/src/internal/Annotation/annotations.d.ts +272 -0
  175. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
  176. package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
  177. package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
  178. package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
  179. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
  180. package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
  181. package/dist/types/src/internal/Annotation/index.d.ts +6 -0
  182. package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
  183. package/dist/types/src/internal/Annotation/sorting.d.ts +24 -0
  184. package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
  185. package/dist/types/src/internal/Annotation/util.d.ts +48 -0
  186. package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
  187. package/dist/types/src/internal/Entity/api.d.ts +27 -0
  188. package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
  189. package/dist/types/src/internal/Entity/entity.d.ts +84 -0
  190. package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
  191. package/dist/types/src/internal/Entity/guard.d.ts +10 -0
  192. package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
  193. package/dist/types/src/internal/Entity/index.d.ts +10 -0
  194. package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
  195. package/dist/types/src/internal/Entity/model.d.ts +59 -0
  196. package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
  197. package/dist/types/src/internal/Entity/object.d.ts +18 -0
  198. package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
  199. package/dist/types/src/internal/Entity/relation.d.ts +58 -0
  200. package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
  201. package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
  202. package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
  203. package/dist/types/src/internal/Entity/type-uri.d.ts +24 -0
  204. package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
  205. package/dist/types/src/internal/Entity/util.d.ts +2 -0
  206. package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
  207. package/dist/types/src/internal/Entity/version.d.ts +42 -0
  208. package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
  209. package/dist/types/src/internal/Format/date.d.ts.map +1 -0
  210. package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
  211. package/dist/types/src/internal/{formats → Format}/format.d.ts +7 -4
  212. package/dist/types/src/internal/Format/format.d.ts.map +1 -0
  213. package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
  214. package/dist/types/src/internal/{formats → Format}/index.d.ts +2 -2
  215. package/dist/types/src/internal/Format/index.d.ts.map +1 -0
  216. package/dist/types/src/internal/Format/number.d.ts.map +1 -0
  217. package/dist/types/src/internal/{formats → Format}/object.d.ts +3 -1
  218. package/dist/types/src/internal/Format/object.d.ts.map +1 -0
  219. package/dist/types/src/internal/{formats → Format}/select.d.ts +6 -4
  220. package/dist/types/src/internal/Format/select.d.ts.map +1 -0
  221. package/dist/types/src/internal/{formats → Format}/string.d.ts +4 -0
  222. package/dist/types/src/internal/Format/string.d.ts.map +1 -0
  223. package/dist/types/src/internal/{formats → Format}/types.d.ts +14 -10
  224. package/dist/types/src/internal/Format/types.d.ts.map +1 -0
  225. package/dist/types/src/internal/{json → JsonSchema}/annotations.d.ts +1 -1
  226. package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
  227. package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
  228. package/dist/types/src/internal/JsonSchema/index.d.ts +5 -0
  229. package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
  230. package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
  231. package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +136 -35
  232. package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
  233. package/dist/types/src/internal/{json → JsonSchema}/json-schema.d.ts +6 -3
  234. package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
  235. package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
  236. package/dist/types/src/internal/Obj/atoms.d.ts +38 -0
  237. package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
  238. package/dist/types/src/internal/Obj/clone.d.ts +8 -0
  239. package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
  240. package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
  241. package/dist/types/src/internal/{object/create.d.ts → Obj/create-object.d.ts} +15 -16
  242. package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
  243. package/dist/types/src/internal/Obj/create-object.test.d.ts +2 -0
  244. package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
  245. package/dist/types/src/internal/Obj/deleted.d.ts +6 -0
  246. package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
  247. package/dist/types/src/internal/Obj/index.d.ts +11 -0
  248. package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
  249. package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
  250. package/dist/types/src/internal/Obj/json-serializer.d.ts +45 -0
  251. package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
  252. package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
  253. package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
  254. package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
  255. package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
  256. package/dist/types/src/internal/Obj/set-value.d.ts +7 -0
  257. package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
  258. package/dist/types/src/internal/Obj/set-value.test.d.ts +2 -0
  259. package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
  260. package/dist/types/src/internal/Obj/snapshot.d.ts +6 -0
  261. package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
  262. package/dist/types/src/internal/Obj/typed-object.d.ts +25 -0
  263. package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
  264. package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
  265. package/dist/types/src/internal/Query/index.d.ts +2 -0
  266. package/dist/types/src/internal/Query/index.d.ts.map +1 -0
  267. package/dist/types/src/internal/Query/pretty.d.ts +10 -0
  268. package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
  269. package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
  270. package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
  271. package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
  272. package/dist/types/src/internal/Ref/ref-array.d.ts +21 -0
  273. package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
  274. package/dist/types/src/internal/{ref → Ref}/ref.d.ts +88 -32
  275. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
  276. package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
  277. package/dist/types/src/internal/Ref/utils.d.ts +8 -0
  278. package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
  279. package/dist/types/src/internal/Type/compose.d.ts +7 -0
  280. package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
  281. package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
  282. package/dist/types/src/internal/Type/index.d.ts +3 -0
  283. package/dist/types/src/internal/Type/index.d.ts.map +1 -0
  284. package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -1
  285. package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
  286. package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
  287. package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
  288. package/dist/types/src/internal/common/api/index.d.ts +11 -0
  289. package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
  290. package/dist/types/src/internal/common/api/meta.d.ts +45 -0
  291. package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
  292. package/dist/types/src/internal/common/index.d.ts +4 -0
  293. package/dist/types/src/internal/common/index.d.ts.map +1 -0
  294. package/dist/types/src/internal/common/proxy/change-context.d.ts +55 -0
  295. package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
  296. package/dist/types/src/internal/common/proxy/change.test.d.ts +2 -0
  297. package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
  298. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts +5 -0
  299. package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
  300. package/dist/types/src/internal/common/proxy/errors.d.ts +19 -0
  301. package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
  302. package/dist/types/src/internal/common/proxy/event-batch.d.ts +10 -0
  303. package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
  304. package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
  305. package/dist/types/src/internal/common/proxy/index.d.ts +14 -0
  306. package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
  307. package/dist/types/src/internal/common/proxy/json-serializer.d.ts +6 -0
  308. package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
  309. package/dist/types/src/internal/common/proxy/make-object.d.ts +20 -0
  310. package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
  311. package/dist/types/src/internal/common/proxy/ownership.d.ts +57 -0
  312. package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
  313. package/dist/types/src/internal/common/proxy/proxy-types.d.ts +18 -0
  314. package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
  315. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +47 -0
  316. package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
  317. package/dist/types/src/internal/common/proxy/reactive-array.d.ts +8 -0
  318. package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
  319. package/dist/types/src/internal/common/proxy/reactive.d.ts +39 -0
  320. package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
  321. package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
  322. package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
  323. package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
  324. package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
  325. package/dist/types/src/internal/common/proxy/symbols.d.ts +3 -0
  326. package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
  327. package/dist/types/src/internal/common/proxy/typed-handler.d.ts +64 -0
  328. package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
  329. package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
  330. package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
  331. package/dist/types/src/internal/common/types/base.d.ts +27 -0
  332. package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
  333. package/dist/types/src/internal/common/types/entity.d.ts +94 -0
  334. package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
  335. package/dist/types/src/internal/common/types/index.d.ts +7 -0
  336. package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
  337. package/dist/types/src/internal/common/types/meta.d.ts +54 -0
  338. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
  339. package/dist/types/src/internal/common/types/model-symbols.d.ts +65 -0
  340. package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
  341. package/dist/types/src/internal/common/types/typename.d.ts +28 -0
  342. package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
  343. package/dist/types/src/internal/common/types/version.d.ts +15 -0
  344. package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
  345. package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
  346. package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
  347. package/dist/types/src/internal/index.d.ts +10 -14
  348. package/dist/types/src/internal/index.d.ts.map +1 -1
  349. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  350. package/dist/types/src/testing/index.d.ts +4 -3
  351. package/dist/types/src/testing/index.d.ts.map +1 -1
  352. package/dist/types/src/testing/registry.d.ts +9 -0
  353. package/dist/types/src/testing/registry.d.ts.map +1 -0
  354. package/dist/types/src/testing/test-data.d.ts +18 -0
  355. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  356. package/dist/types/src/testing/test-schema.d.ts +298 -0
  357. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  358. package/dist/types/src/testing/util.d.ts +23 -0
  359. package/dist/types/src/testing/util.d.ts.map +1 -0
  360. package/dist/types/tsconfig.tsbuildinfo +1 -1
  361. package/package.json +119 -66
  362. package/src/Annotation.test.ts +439 -0
  363. package/src/Annotation.ts +202 -0
  364. package/src/Collection.ts +33 -0
  365. package/src/Database.ts +345 -0
  366. package/src/Dataset.ts +34 -0
  367. package/src/Entity.test.ts +132 -0
  368. package/src/Entity.ts +345 -0
  369. package/src/Err.ts +40 -0
  370. package/src/Feed.ts +352 -0
  371. package/src/Filter.test.ts +90 -0
  372. package/src/Filter.ts +484 -0
  373. package/src/Format.ts +5 -0
  374. package/src/Hypergraph.ts +84 -0
  375. package/src/Json.test.ts +175 -0
  376. package/src/Json.ts +103 -0
  377. package/src/JsonSchema.ts +26 -0
  378. package/src/Key.ts +4 -1
  379. package/src/Migration.ts +114 -0
  380. package/src/Obj.test.ts +641 -0
  381. package/src/Obj.ts +778 -281
  382. package/src/Order.ts +68 -0
  383. package/src/Query.test.ts +835 -0
  384. package/src/Query.ts +634 -0
  385. package/src/QueryResult.ts +132 -0
  386. package/src/Ref.ts +98 -10
  387. package/src/Registry.ts +155 -0
  388. package/src/Relation.test.ts +88 -0
  389. package/src/Relation.ts +503 -67
  390. package/src/Scope.ts +50 -0
  391. package/src/Tag.md +88 -0
  392. package/src/Tag.ts +53 -8
  393. package/src/Type.test.ts +257 -0
  394. package/src/Type.ts +643 -151
  395. package/src/View.ts +98 -0
  396. package/src/exemplars.test.ts +21 -0
  397. package/src/hierarchy.test.ts +33 -0
  398. package/src/index.ts +22 -6
  399. package/src/internal/Annotation/annotations.test.ts +165 -0
  400. package/src/internal/Annotation/annotations.ts +609 -0
  401. package/src/internal/Annotation/dictionary.ts +47 -0
  402. package/src/internal/Annotation/entity-dictionary.ts +74 -0
  403. package/src/internal/Annotation/index.ts +9 -0
  404. package/src/internal/Annotation/sorting.ts +51 -0
  405. package/src/internal/Annotation/util.ts +94 -0
  406. package/src/internal/Entity/api.ts +77 -0
  407. package/src/internal/Entity/entity.ts +277 -0
  408. package/src/internal/Entity/guard.ts +26 -0
  409. package/src/internal/Entity/index.ts +13 -0
  410. package/src/internal/Entity/model.ts +119 -0
  411. package/src/internal/Entity/object.ts +73 -0
  412. package/src/internal/Entity/relation.ts +188 -0
  413. package/src/internal/Entity/type-kind.ts +75 -0
  414. package/src/internal/Entity/type-uri.ts +92 -0
  415. package/src/internal/Entity/util.ts +33 -0
  416. package/src/internal/Entity/version.ts +96 -0
  417. package/src/internal/{formats → Format}/date.test.ts +1 -2
  418. package/src/internal/{formats → Format}/date.ts +5 -9
  419. package/src/internal/{formats → Format}/format.test.ts +27 -7
  420. package/src/internal/{formats → Format}/format.ts +8 -6
  421. package/src/internal/{formats → Format}/index.ts +2 -3
  422. package/src/internal/{formats → Format}/number.ts +5 -5
  423. package/src/internal/{formats → Format}/object.ts +23 -6
  424. package/src/internal/{formats → Format}/select.ts +6 -4
  425. package/src/internal/{formats → Format}/string.ts +14 -9
  426. package/src/internal/{formats → Format}/types.ts +54 -43
  427. package/src/internal/{json → JsonSchema}/annotations.ts +3 -3
  428. package/src/internal/{json-schema → JsonSchema}/index.ts +2 -0
  429. package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +4 -2
  430. package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +39 -39
  431. package/src/internal/{json → JsonSchema}/json-schema.test.ts +119 -182
  432. package/src/internal/{json → JsonSchema}/json-schema.ts +70 -42
  433. package/src/internal/Obj/atoms.ts +244 -0
  434. package/src/internal/Obj/clone.ts +53 -0
  435. package/src/internal/{object → Obj}/common.ts +3 -4
  436. package/src/internal/Obj/create-object.test.ts +116 -0
  437. package/src/internal/Obj/create-object.ts +140 -0
  438. package/src/internal/Obj/deleted.ts +19 -0
  439. package/src/internal/Obj/index.ts +14 -0
  440. package/src/internal/{object → Obj}/inspect.ts +7 -7
  441. package/src/internal/Obj/json-serializer.test.ts +199 -0
  442. package/src/internal/Obj/json-serializer.ts +278 -0
  443. package/src/internal/{object → Obj}/schema-validator.test.ts +3 -7
  444. package/src/internal/Obj/schema-validator.ts +6 -0
  445. package/src/internal/Obj/set-value.test.ts +258 -0
  446. package/src/internal/Obj/set-value.ts +158 -0
  447. package/src/internal/Obj/snapshot.ts +114 -0
  448. package/src/internal/Obj/typed-object.test.ts +32 -0
  449. package/src/internal/Obj/typed-object.ts +30 -0
  450. package/src/internal/{json → Query}/index.ts +1 -1
  451. package/src/internal/Query/pretty.ts +162 -0
  452. package/src/internal/Ref/atoms.ts +20 -0
  453. package/src/internal/{ref → Ref}/ref-array.ts +6 -7
  454. package/src/internal/Ref/ref.test.ts +91 -0
  455. package/src/internal/{ref → Ref}/ref.ts +230 -101
  456. package/src/internal/Ref/utils.ts +45 -0
  457. package/src/internal/{projection → Type}/compose.test.ts +9 -9
  458. package/src/internal/{projection → Type}/compose.ts +14 -9
  459. package/src/internal/Type/index.ts +6 -0
  460. package/src/internal/{schema → Type}/manipulation.ts +0 -25
  461. package/src/internal/Type/type-schema.ts +60 -0
  462. package/src/internal/common/README.md +102 -0
  463. package/src/internal/common/api/index.ts +15 -0
  464. package/src/internal/common/api/meta.ts +90 -0
  465. package/src/internal/{testing → common}/index.ts +2 -1
  466. package/src/internal/common/proxy/change-context.ts +138 -0
  467. package/src/internal/common/proxy/change.test.ts +527 -0
  468. package/src/internal/common/proxy/define-hidden-property.ts +14 -0
  469. package/src/internal/common/proxy/errors.ts +42 -0
  470. package/src/internal/common/proxy/event-batch.ts +44 -0
  471. package/src/internal/common/proxy/handler.test.ts +121 -0
  472. package/src/internal/common/proxy/index.ts +17 -0
  473. package/src/internal/common/proxy/json-serializer.ts +101 -0
  474. package/src/internal/common/proxy/make-object.ts +129 -0
  475. package/src/internal/common/proxy/ownership.ts +252 -0
  476. package/src/internal/common/proxy/proxy-types.ts +23 -0
  477. package/src/internal/common/proxy/proxy-utils.ts +150 -0
  478. package/src/internal/common/proxy/reactive-array.ts +71 -0
  479. package/src/internal/common/proxy/reactive.test.ts +54 -0
  480. package/src/internal/common/proxy/reactive.ts +77 -0
  481. package/src/internal/{object → common/proxy}/schema-validator.ts +6 -3
  482. package/src/internal/common/proxy/schema.test.ts +107 -0
  483. package/src/internal/common/proxy/symbols.ts +7 -0
  484. package/src/internal/common/proxy/typed-handler.test.ts +314 -0
  485. package/src/internal/common/proxy/typed-handler.ts +509 -0
  486. package/src/internal/common/proxy/typed-object.test.ts +103 -0
  487. package/src/internal/common/types/base.ts +43 -0
  488. package/src/internal/common/types/entity.ts +133 -0
  489. package/src/internal/common/types/index.ts +15 -0
  490. package/src/internal/common/types/meta.ts +109 -0
  491. package/src/internal/common/types/model-symbols.ts +89 -0
  492. package/src/internal/common/types/typename.ts +91 -0
  493. package/src/internal/common/types/version.ts +19 -0
  494. package/src/internal/common/types/well-known-types.ts +15 -0
  495. package/src/internal/index.ts +14 -17
  496. package/src/testing/api.test.ts +131 -0
  497. package/src/testing/index.ts +4 -3
  498. package/src/testing/registry.ts +44 -0
  499. package/src/testing/test-data.ts +189 -0
  500. package/src/testing/test-schema.ts +204 -0
  501. package/src/testing/util.ts +88 -0
  502. package/dist/lib/browser/chunk-BIDAASFK.mjs +0 -3727
  503. package/dist/lib/browser/chunk-BIDAASFK.mjs.map +0 -7
  504. package/dist/lib/browser/chunk-ZDLCWGEW.mjs +0 -410
  505. package/dist/lib/browser/chunk-ZDLCWGEW.mjs.map +0 -7
  506. package/dist/lib/browser/chunk-ZFRJKT4A.mjs +0 -585
  507. package/dist/lib/browser/chunk-ZFRJKT4A.mjs.map +0 -7
  508. package/dist/lib/browser/index.mjs +0 -35
  509. package/dist/lib/browser/internal/index.mjs +0 -336
  510. package/dist/lib/browser/meta.json +0 -1
  511. package/dist/lib/browser/query/index.mjs +0 -13
  512. package/dist/lib/browser/testing/index.mjs +0 -267
  513. package/dist/lib/browser/testing/index.mjs.map +0 -7
  514. package/dist/lib/node-esm/chunk-3SVRRCUU.mjs +0 -3727
  515. package/dist/lib/node-esm/chunk-3SVRRCUU.mjs.map +0 -7
  516. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs +0 -585
  517. package/dist/lib/node-esm/chunk-CGDHRZWH.mjs.map +0 -7
  518. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs +0 -410
  519. package/dist/lib/node-esm/chunk-HWS6VBQC.mjs.map +0 -7
  520. package/dist/lib/node-esm/index.mjs +0 -35
  521. package/dist/lib/node-esm/internal/index.mjs +0 -336
  522. package/dist/lib/node-esm/meta.json +0 -1
  523. package/dist/lib/node-esm/query/index.mjs +0 -13
  524. package/dist/lib/node-esm/testing/index.mjs +0 -267
  525. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  526. package/dist/types/src/errors.d.ts +0 -68
  527. package/dist/types/src/errors.d.ts.map +0 -1
  528. package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
  529. package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
  530. package/dist/types/src/internal/ast/annotations.d.ts +0 -131
  531. package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
  532. package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
  533. package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
  534. package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
  535. package/dist/types/src/internal/ast/index.d.ts +0 -5
  536. package/dist/types/src/internal/ast/index.d.ts.map +0 -1
  537. package/dist/types/src/internal/ast/types.d.ts +0 -6
  538. package/dist/types/src/internal/ast/types.d.ts.map +0 -1
  539. package/dist/types/src/internal/formats/date.d.ts.map +0 -1
  540. package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
  541. package/dist/types/src/internal/formats/format.d.ts.map +0 -1
  542. package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
  543. package/dist/types/src/internal/formats/index.d.ts.map +0 -1
  544. package/dist/types/src/internal/formats/number.d.ts.map +0 -1
  545. package/dist/types/src/internal/formats/object.d.ts.map +0 -1
  546. package/dist/types/src/internal/formats/select.d.ts.map +0 -1
  547. package/dist/types/src/internal/formats/string.d.ts.map +0 -1
  548. package/dist/types/src/internal/formats/types.d.ts.map +0 -1
  549. package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
  550. package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
  551. package/dist/types/src/internal/json/index.d.ts +0 -2
  552. package/dist/types/src/internal/json/index.d.ts.map +0 -1
  553. package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
  554. package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
  555. package/dist/types/src/internal/json-schema/index.d.ts +0 -3
  556. package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
  557. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
  558. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
  559. package/dist/types/src/internal/object/accessors.d.ts +0 -37
  560. package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
  561. package/dist/types/src/internal/object/common.d.ts.map +0 -1
  562. package/dist/types/src/internal/object/create.d.ts.map +0 -1
  563. package/dist/types/src/internal/object/create.test.d.ts +0 -2
  564. package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
  565. package/dist/types/src/internal/object/deleted.d.ts +0 -6
  566. package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
  567. package/dist/types/src/internal/object/entity.d.ts +0 -33
  568. package/dist/types/src/internal/object/entity.d.ts.map +0 -1
  569. package/dist/types/src/internal/object/expando.d.ts +0 -14
  570. package/dist/types/src/internal/object/expando.d.ts.map +0 -1
  571. package/dist/types/src/internal/object/ids.d.ts +0 -6
  572. package/dist/types/src/internal/object/ids.d.ts.map +0 -1
  573. package/dist/types/src/internal/object/index.d.ts +0 -16
  574. package/dist/types/src/internal/object/index.d.ts.map +0 -1
  575. package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
  576. package/dist/types/src/internal/object/json-serializer.d.ts +0 -32
  577. package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
  578. package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
  579. package/dist/types/src/internal/object/meta.d.ts +0 -31
  580. package/dist/types/src/internal/object/meta.d.ts.map +0 -1
  581. package/dist/types/src/internal/object/model.d.ts +0 -117
  582. package/dist/types/src/internal/object/model.d.ts.map +0 -1
  583. package/dist/types/src/internal/object/relation.d.ts +0 -17
  584. package/dist/types/src/internal/object/relation.d.ts.map +0 -1
  585. package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
  586. package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
  587. package/dist/types/src/internal/object/typed-object.d.ts +0 -31
  588. package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
  589. package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
  590. package/dist/types/src/internal/object/typename.d.ts +0 -15
  591. package/dist/types/src/internal/object/typename.d.ts.map +0 -1
  592. package/dist/types/src/internal/object/version.d.ts +0 -14
  593. package/dist/types/src/internal/object/version.d.ts.map +0 -1
  594. package/dist/types/src/internal/projection/compose.d.ts +0 -6
  595. package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
  596. package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
  597. package/dist/types/src/internal/projection/index.d.ts +0 -2
  598. package/dist/types/src/internal/projection/index.d.ts.map +0 -1
  599. package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
  600. package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
  601. package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
  602. package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
  603. package/dist/types/src/internal/proxy/typed-handler.d.ts +0 -44
  604. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
  605. package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
  606. package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
  607. package/dist/types/src/internal/query/index.d.ts +0 -2
  608. package/dist/types/src/internal/query/index.d.ts.map +0 -1
  609. package/dist/types/src/internal/query/query.d.ts +0 -17
  610. package/dist/types/src/internal/query/query.d.ts.map +0 -1
  611. package/dist/types/src/internal/ref/index.d.ts.map +0 -1
  612. package/dist/types/src/internal/ref/ref-array.d.ts +0 -21
  613. package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
  614. package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
  615. package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
  616. package/dist/types/src/internal/schema/echo-schema.d.ts +0 -168
  617. package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
  618. package/dist/types/src/internal/schema/index.d.ts +0 -7
  619. package/dist/types/src/internal/schema/index.d.ts.map +0 -1
  620. package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
  621. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
  622. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
  623. package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
  624. package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
  625. package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
  626. package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
  627. package/dist/types/src/internal/testing/index.d.ts +0 -3
  628. package/dist/types/src/internal/testing/index.d.ts.map +0 -1
  629. package/dist/types/src/internal/testing/types.d.ts +0 -381
  630. package/dist/types/src/internal/testing/types.d.ts.map +0 -1
  631. package/dist/types/src/internal/testing/utils.d.ts +0 -10
  632. package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
  633. package/dist/types/src/internal/types/index.d.ts +0 -3
  634. package/dist/types/src/internal/types/index.d.ts.map +0 -1
  635. package/dist/types/src/internal/types/types.d.ts +0 -79
  636. package/dist/types/src/internal/types/types.d.ts.map +0 -1
  637. package/dist/types/src/internal/types/types.test.d.ts +0 -2
  638. package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
  639. package/dist/types/src/internal/types/util.d.ts +0 -5
  640. package/dist/types/src/internal/types/util.d.ts.map +0 -1
  641. package/dist/types/src/query/index.d.ts +0 -2
  642. package/dist/types/src/query/index.d.ts.map +0 -1
  643. package/dist/types/src/query/query.d.ts +0 -248
  644. package/dist/types/src/query/query.d.ts.map +0 -1
  645. package/dist/types/src/query/query.test.d.ts +0 -2
  646. package/dist/types/src/query/query.test.d.ts.map +0 -1
  647. package/dist/types/src/testing/echo-schema.d.ts +0 -7
  648. package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
  649. package/dist/types/src/testing/types.d.ts +0 -228
  650. package/dist/types/src/testing/types.d.ts.map +0 -1
  651. package/src/errors.ts +0 -18
  652. package/src/internal/ast/annotation-helper.ts +0 -22
  653. package/src/internal/ast/annotations.test.ts +0 -98
  654. package/src/internal/ast/annotations.ts +0 -226
  655. package/src/internal/ast/entity-kind.ts +0 -15
  656. package/src/internal/ast/index.ts +0 -8
  657. package/src/internal/ast/types.ts +0 -17
  658. package/src/internal/object/accessors.ts +0 -153
  659. package/src/internal/object/create.test.ts +0 -118
  660. package/src/internal/object/create.ts +0 -96
  661. package/src/internal/object/deleted.ts +0 -19
  662. package/src/internal/object/entity.ts +0 -248
  663. package/src/internal/object/expando.ts +0 -21
  664. package/src/internal/object/ids.ts +0 -12
  665. package/src/internal/object/index.ts +0 -19
  666. package/src/internal/object/json-serializer.test.ts +0 -99
  667. package/src/internal/object/json-serializer.ts +0 -225
  668. package/src/internal/object/meta.ts +0 -61
  669. package/src/internal/object/model.ts +0 -170
  670. package/src/internal/object/relation.ts +0 -24
  671. package/src/internal/object/typed-object.test.ts +0 -34
  672. package/src/internal/object/typed-object.ts +0 -88
  673. package/src/internal/object/typename.ts +0 -61
  674. package/src/internal/object/version.ts +0 -22
  675. package/src/internal/projection/index.ts +0 -5
  676. package/src/internal/proxy/handler.test.ts +0 -163
  677. package/src/internal/proxy/reactive-object.ts +0 -108
  678. package/src/internal/proxy/schema.test.ts +0 -136
  679. package/src/internal/proxy/typed-handler.test.ts +0 -102
  680. package/src/internal/proxy/typed-handler.ts +0 -228
  681. package/src/internal/proxy/typed-object.test.ts +0 -100
  682. package/src/internal/query/index.ts +0 -5
  683. package/src/internal/query/query.ts +0 -23
  684. package/src/internal/ref/ref.test.ts +0 -100
  685. package/src/internal/schema/echo-schema.ts +0 -383
  686. package/src/internal/schema/index.ts +0 -10
  687. package/src/internal/schema/runtime-schema-registry.ts +0 -78
  688. package/src/internal/schema/snapshot.ts +0 -25
  689. package/src/internal/schema/stored-schema.ts +0 -26
  690. package/src/internal/testing/types.ts +0 -144
  691. package/src/internal/testing/utils.ts +0 -54
  692. package/src/internal/types/index.ts +0 -6
  693. package/src/internal/types/types.test.ts +0 -48
  694. package/src/internal/types/types.ts +0 -176
  695. package/src/internal/types/util.ts +0 -9
  696. package/src/query/index.ts +0 -6
  697. package/src/query/query.test.ts +0 -401
  698. package/src/query/query.ts +0 -789
  699. package/src/test/api.test.ts +0 -180
  700. package/src/testing/echo-schema.ts +0 -39
  701. package/src/testing/types.ts +0 -108
  702. /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
  703. /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
  704. /package/dist/lib/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
  705. /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
  706. /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Feed.mjs.map} +0 -0
  707. /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Filter.mjs.map} +0 -0
  708. /package/dist/types/src/internal/{ast → Annotation}/annotations.test.d.ts +0 -0
  709. /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
  710. /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
  711. /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
  712. /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
  713. /package/dist/types/src/internal/{json → JsonSchema}/effect-schema.test.d.ts +0 -0
  714. /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
  715. /package/dist/types/src/internal/{json → JsonSchema}/json-schema.test.d.ts +0 -0
  716. /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
  717. /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
  718. /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
  719. /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
  720. /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
  721. /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
  722. /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
  723. /package/dist/types/src/internal/{projection → Type}/compose.test.d.ts +0 -0
  724. /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
  725. /package/dist/types/src/internal/{object → common/proxy}/schema-validator.d.ts +0 -0
  726. /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
  727. /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
  728. /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
  729. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
  730. /package/src/internal/{json → JsonSchema}/effect-schema.test.ts +0 -0
  731. /package/src/internal/{ref → Ref}/index.ts +0 -0
@@ -0,0 +1,74 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Option from 'effect/Option';
6
+
7
+ import { deepMapValues } from '@dxos/util';
8
+
9
+ import type * as Annotation from '../../Annotation';
10
+ import type * as Entity from '../../Entity';
11
+ import { getMetaChecked } from '../common/api/meta';
12
+ import { type Mutable } from '../common/proxy/reactive';
13
+ import { getDatabase } from '../Entity/api';
14
+ import { isEntity, isSnapshot } from '../Entity/guard';
15
+ import { Ref, getRefSavedTarget } from '../Ref';
16
+ import { getDictionary, setDictionary } from './dictionary';
17
+
18
+ /**
19
+ * Get the value of an annotation from an entity instance or snapshot.
20
+ */
21
+ export const get = <T>(
22
+ target: Entity.Unknown | Entity.Snapshot,
23
+ annotation: Annotation.Annotation<T>,
24
+ ): Option.Option<T> => {
25
+ if (isEntity(target) || isSnapshot(target)) {
26
+ const meta = getMetaChecked(target);
27
+ return getDictionary(meta.annotations, annotation);
28
+ } else {
29
+ throw new TypeError('Target is not an annotation target.');
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Set the value of an annotation on an entity instance.
35
+ * Must be called with a mutable entity — i.e. inside an `Obj.update` callback.
36
+ */
37
+ export const set = <T>(target: Mutable<Entity.Unknown>, annotation: Annotation.Annotation<T>, value: T): void => {
38
+ if (isEntity(target)) {
39
+ const meta = getMetaChecked(target);
40
+ // Persist any unsaved Ref targets in the value into the entity's database so
41
+ // the encoded DXN resolves on read. This mirrors normal property assignment,
42
+ // where the reactive proxy links unsaved ref targets via `createRef` →
43
+ // `database.add`. `setDictionary` pre-encodes the value (`Schema.encodeSync`),
44
+ // so the live Ref never reaches the proxy's link handling and would otherwise
45
+ // be stored as a dangling reference.
46
+ persistRefTargets(target, value);
47
+ setDictionary(meta.annotations, annotation, value);
48
+ } else {
49
+ throw new TypeError('Target is not an annotation target.');
50
+ }
51
+ };
52
+
53
+ /**
54
+ * Add any unsaved Ref targets found in `value` to the host entity's database, matching the
55
+ * auto-persistence applied to refs assigned to ordinary entity properties. Refs whose target
56
+ * already lives in a database (the host's or a foreign one) are left untouched.
57
+ */
58
+ const persistRefTargets = (host: Entity.Unknown, value: unknown): void => {
59
+ const database = getDatabase(host);
60
+ if (database == null) {
61
+ return;
62
+ }
63
+
64
+ deepMapValues(value, (current, recurse) => {
65
+ if (Ref.isRef(current)) {
66
+ const refTarget = getRefSavedTarget(current);
67
+ if (refTarget != null && isEntity(refTarget) && getDatabase(refTarget) == null) {
68
+ database.add(refTarget);
69
+ }
70
+ return current;
71
+ }
72
+ return recurse(current);
73
+ });
74
+ };
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './dictionary';
6
+ export * from './util';
7
+ export * from './sorting';
8
+ export * from './annotations';
9
+ export * from './entity-dictionary';
@@ -0,0 +1,51 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import type { AnyEntity } from '../common/types';
6
+ import { getLabel, getTypename } from './annotations';
7
+
8
+ /**
9
+ * String comparison helper for sorting.
10
+ */
11
+ export const compare = (a?: string, b?: string): number => {
12
+ if (a == null) {
13
+ return b == null ? 0 : 1;
14
+ }
15
+ if (b == null) {
16
+ return -1;
17
+ }
18
+ return a.localeCompare(b);
19
+ };
20
+
21
+ /**
22
+ * Comparator function type for sorting entities.
23
+ * Accepts both reactive entities and snapshots.
24
+ */
25
+ export type Comparator<T extends AnyEntity = AnyEntity> = (a: T, b: T) => number;
26
+
27
+ /**
28
+ * Sort entities by label.
29
+ */
30
+ export const sortByLabel: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getLabel(a), getLabel(b));
31
+
32
+ /**
33
+ * Sort entities by typename.
34
+ */
35
+ export const sortByTypename: Comparator = (a: AnyEntity, b: AnyEntity) => compare(getTypename(a), getTypename(b));
36
+
37
+ /**
38
+ * Compose multiple comparators into one.
39
+ * Applies comparators in order until one returns non-zero.
40
+ */
41
+ export const sort = <T extends AnyEntity>(...comparators: Comparator<T>[]): Comparator<T> => {
42
+ return (a: T, b: T) => {
43
+ for (const comparator of comparators) {
44
+ const result = comparator(a, b);
45
+ if (result !== 0) {
46
+ return result;
47
+ }
48
+ }
49
+ return 0;
50
+ };
51
+ };
@@ -0,0 +1,94 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Option from 'effect/Option';
6
+ import type * as Schema from 'effect/Schema';
7
+ import * as SchemaAST from 'effect/SchemaAST';
8
+
9
+ import { assertArgument } from '@dxos/invariant';
10
+ import { DXN } from '@dxos/keys';
11
+
12
+ import { EntityKind } from '../common/types';
13
+
14
+ export interface AnnotationHelper<T> {
15
+ /**
16
+ * Get the annotation value from an Effect schema.
17
+ *
18
+ * Only accepts `Schema.Schema.Any` — to read an annotation off a `Type.Type`
19
+ * entity, unwrap it first with `Type.getSchema(entity)`. This keeps the
20
+ * annotation pipeline single-shaped and forces annotations to live on the
21
+ * source schema, not on the post-construction Type entity.
22
+ */
23
+ get: (schema: Schema.Schema.Any) => Option.Option<T>;
24
+ /**
25
+ * Get the annotation value from the AST.
26
+ */
27
+ getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;
28
+ /**
29
+ * Set the annotation on an Effect schema.
30
+ *
31
+ * Only accepts `Schema.Schema.Any` — annotations must be applied to the
32
+ * source schema BEFORE wrapping it with `Type.makeObject` / `Type.makeRelation`.
33
+ * In a pipe, place every `Annotation.X.set(...)` before the `Type.make...` step.
34
+ */
35
+ set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;
36
+ }
37
+
38
+ /**
39
+ * Note: only for system annotations.
40
+ */
41
+ // TODO(dmaretskyi): Rename to createSystemAnnotationHelper.
42
+ // TODO(dmaretskyi): REconcile with Annotation.make.
43
+ export const createAnnotationHelper = <T>(id: symbol): AnnotationHelper<T> => {
44
+ return {
45
+ get: (schema) => SchemaAST.getAnnotation(schema.ast, id),
46
+ getFromAst: (ast) => SchemaAST.getAnnotation(ast, id),
47
+ set:
48
+ (value) =>
49
+ <S extends Schema.Schema.Any>(schema: S): S =>
50
+ schema.annotations({ [id]: value }) as S,
51
+ };
52
+ };
53
+
54
+ /**
55
+ * If property is optional returns the nested property, otherwise returns the property.
56
+ */
57
+ // TODO(wittjosiah): Is there a way to do this as a generic?
58
+ export const unwrapOptional = (property: SchemaAST.PropertySignature) => {
59
+ if (!property.isOptional || !SchemaAST.isUnion(property.type)) {
60
+ return property;
61
+ }
62
+
63
+ return property.type.types[0];
64
+ };
65
+
66
+ /**
67
+ * @see JSONSchemaAnnotationId
68
+ * @returns JSON-schema annotation so that the schema can be serialized with correct parameters.
69
+ */
70
+ // TODO(burdon): Required type.
71
+ export const makeTypeJsonSchemaAnnotation = (options: {
72
+ identifier?: string;
73
+ kind: EntityKind;
74
+ typename: string;
75
+ version: string;
76
+ relationSource?: string;
77
+ relationTarget?: string;
78
+ }) => {
79
+ assertArgument(!!options.relationSource === (options.kind === EntityKind.Relation), 'relationSource');
80
+ assertArgument(!!options.relationTarget === (options.kind === EntityKind.Relation), 'relationTarget');
81
+
82
+ const obj: Record<string, unknown> = {
83
+ $id: options.identifier ?? DXN.make(options.typename, options.version),
84
+ entityKind: options.kind,
85
+ version: options.version,
86
+ typename: options.typename,
87
+ };
88
+ if (options.kind === EntityKind.Relation) {
89
+ obj.relationSource = { $ref: options.relationSource };
90
+ obj.relationTarget = { $ref: options.relationTarget };
91
+ }
92
+
93
+ return obj;
94
+ };
@@ -0,0 +1,77 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { invariant } from '@dxos/invariant';
6
+ import { DXN, EID, URI, type SpaceId } from '@dxos/keys';
7
+ import { assumeType } from '@dxos/util';
8
+
9
+ import type { AnyEntity } from '../common/types';
10
+ import { MetaId } from '../common/types/model-symbols';
11
+ import { type InternalObjectProps, ObjectDatabaseId } from './model';
12
+ import { getObjectEchoUri } from './util';
13
+
14
+ /**
15
+ * Controls the URI form returned by `getUri` and the public `*.getURI` helpers.
16
+ *
17
+ * - `'named'` — Registry key URI (`dxn:<meta.key>`) when the entity has a key in its meta;
18
+ * falls back to the default EID.
19
+ * - `'absolute'` — Fully-qualified EID with space id (`echo://<spaceId>/<entityId>`);
20
+ * falls back when no space is available.
21
+ * - `'relative'` — Local EID without space id (`echo:/<entityId>`).
22
+ *
23
+ * Omitting `prefer` preserves the existing behaviour.
24
+ */
25
+ export type GetURIOptions = {
26
+ prefer?: 'named' | 'absolute' | 'relative';
27
+ };
28
+
29
+ /**
30
+ * Get the URI of an entity.
31
+ * Accepts both reactive entities and snapshots.
32
+ */
33
+ export const getUri = (entity: AnyEntity, options?: GetURIOptions): URI.URI => {
34
+ const prefer = options?.prefer;
35
+
36
+ if (prefer === 'named') {
37
+ const key = (entity as any)[MetaId]?.key;
38
+ if (key) {
39
+ return (DXN.tryMake(`dxn:${key}`) ?? URI.make(key)) as URI.URI;
40
+ }
41
+ const uri = getObjectEchoUri(entity);
42
+ invariant(uri != null, 'Invalid entity.');
43
+ return uri;
44
+ }
45
+
46
+ if (prefer === 'relative') {
47
+ const eid = getObjectEchoUri(entity);
48
+ invariant(eid != null, 'Invalid entity.');
49
+ const entityId = EID.getEntityId(eid);
50
+ return entityId ? EID.make({ entityId }) : eid;
51
+ }
52
+
53
+ if (prefer === 'absolute') {
54
+ const eid = getObjectEchoUri(entity);
55
+ invariant(eid != null, 'Invalid entity.');
56
+ const entityId = EID.getEntityId(eid);
57
+ if (!entityId) {
58
+ return eid;
59
+ }
60
+ assumeType<InternalObjectProps>(entity);
61
+ const spaceId: SpaceId | undefined = entity[ObjectDatabaseId]?.spaceId ?? EID.getSpaceId(eid);
62
+ return spaceId ? EID.make({ spaceId, entityId }) : eid;
63
+ }
64
+
65
+ const uri = getObjectEchoUri(entity);
66
+ invariant(uri != null, 'Invalid entity.');
67
+ return uri;
68
+ };
69
+
70
+ /**
71
+ * Get the database the entity belongs to.
72
+ * Accepts both reactive entities and snapshots.
73
+ */
74
+ export const getDatabase = (entity: AnyEntity): any | undefined => {
75
+ assumeType<InternalObjectProps>(entity);
76
+ return entity[ObjectDatabaseId];
77
+ };
@@ -0,0 +1,277 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import * as SchemaAST from 'effect/SchemaAST';
7
+ import type * as Types from 'effect/Types';
8
+
9
+ import { DXN, EntityId } from '@dxos/keys';
10
+ import { type ToMutable } from '@dxos/util';
11
+
12
+ import { type TypeAnnotation, TypeAnnotationId } from '../Annotation/annotations';
13
+ import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
14
+ import { defineHiddenProperty } from '../common/proxy/define-hidden-property';
15
+ import { makeObject } from '../common/proxy/make-object';
16
+ import { getProxyTarget } from '../common/proxy/proxy-utils';
17
+ import {
18
+ type AnyEntity,
19
+ EntityKind,
20
+ InstancePhantomId,
21
+ KindId,
22
+ SchemaKindId,
23
+ StaticTypeSchemaSlot,
24
+ } from '../common/types';
25
+ import { type EntityMeta } from '../common/types/meta';
26
+ import { JsonSchemaType } from '../JsonSchema/json-schema-type';
27
+
28
+ // TODO(burdon): Define Schema type for `typename` and use consistently for all DXN-like properties.
29
+
30
+ // type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
31
+ export type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<AnyEntity & ToMutable<T> & ExtraFields>;
32
+
33
+ /**
34
+ * Options accepted by every `Type.makeObject` / `Type.makeRelation` / type-kind
35
+ * factory. Defaults are derived from `(typename, version)` so callers normally
36
+ * pass nothing.
37
+ */
38
+ export type EchoTypeOptions = {
39
+ /**
40
+ * Override the entity id stamped on the in-memory `Type.Type` value.
41
+ *
42
+ * Defaults to `EntityId.deterministic(typename, version)` — stable across processes
43
+ * and workerd-safe (no `crypto.getRandomValues()` at module-evaluation time).
44
+ * Pass an explicit id (typically `EntityId.random()`) to opt out of the
45
+ * deterministic default.
46
+ */
47
+ id?: EntityId;
48
+ };
49
+
50
+ /**
51
+ * In-memory `Type.Type` entity shape produced by `Type.makeObject(dxn)` /
52
+ * `Type.makeRelation({...})`. A live reactive `TypeSchema` instance —
53
+ * identical to a persisted `Type.Type` except for database attachment.
54
+ *
55
+ * NOT a `Schema.Schema`. The underlying Effect Schema is cached on the hidden
56
+ * `StaticTypeSchemaSlot` slot — retrieve it via `Type.getSchema(...)`.
57
+ */
58
+ // TODO(burdon): Rename EchoEntitySchema.
59
+ export interface EchoTypeSchema<
60
+ Self extends Schema.Schema.Any,
61
+ ExtraFields = {},
62
+ K extends EntityKind = EntityKind,
63
+ Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
64
+ > {
65
+ /**
66
+ * Entity-kind brand. Type entities are their own kind (`Type`) regardless of
67
+ * the kind of instance they describe — `[SchemaKindId]` carries the latter.
68
+ * This lets predicates like `Obj.isObject` / `Relation.isRelation` cleanly
69
+ * reject type entities without also having to inspect `[SchemaKindId]`.
70
+ */
71
+ readonly [KindId]: EntityKind.Type;
72
+
73
+ /** Schema-kind brand indicating what kind of instance this type describes. */
74
+ readonly [SchemaKindId]: K;
75
+
76
+ /**
77
+ * Entity id. Always present — stamped at construction — but NOT the type's
78
+ * identity while in-memory: an unattached type resolves its URI to the typename
79
+ * DXN, switching to `echo:/<id>` only once attached to a database (see
80
+ * `getTypeURIFromSpecifier`, which discriminates by database attachment).
81
+ */
82
+ readonly id: EntityId;
83
+
84
+ /** Source Effect Schema (kept on a hidden slot for `Type.getSchema`). */
85
+ readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
86
+
87
+ // NOTE: `typename` / `version` are intentionally NOT fields. They live in
88
+ // `EntityMeta` (`key` / `version`); read via `Type.getTypename(self)` /
89
+ // `Type.getVersion(self)`.
90
+ readonly jsonSchema: JsonSchemaType;
91
+
92
+ /** Struct fields for introspection. */
93
+ readonly fields: Fields;
94
+
95
+ /** Phantom — instance type produced by `Obj.make(self, ...)`. */
96
+ readonly _instance?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>;
97
+
98
+ /**
99
+ * Phantom slot mirroring `Type<A>` so internal helpers (`makeObject`,
100
+ * `createObject`, `Ref.make`) infer the instance type uniformly whether
101
+ * the caller passes an `EchoTypeSchema` or a top-level `Type.Type` entity.
102
+ *
103
+ * Includes the instance-kind brand (`[KindId]`) so the phantom is assignable
104
+ * to the matching public-side interface in `Type.ts` (`Type.Obj` /
105
+ * `Type.Relation` / `Type.Type`). Each kind projects identity: instances of
106
+ * an object-kind schema are object-kind entities, type-kind schemas produce
107
+ * type-kind (persisted Type.Type) entities — the latter additionally carry
108
+ * the `[SchemaKindId]` / `[StaticTypeSchemaSlot]` brands the echo-handler
109
+ * proxy exposes on persisted Type entities.
110
+ */
111
+ readonly [InstancePhantomId]?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields> & {
112
+ readonly [KindId]: K;
113
+ } & (K extends EntityKind.Type
114
+ ? {
115
+ readonly [SchemaKindId]: EntityKind.Type;
116
+ readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
117
+ }
118
+ : {});
119
+ }
120
+
121
+ // type MakeProps =
122
+ // | boolean
123
+ // | {
124
+ // readonly disableValidation?: boolean;
125
+ // };
126
+
127
+ // NOTE: Utils copied from Effect `Schema.ts`.
128
+ // const _ownKeys = (o: object): Array<PropertyKey> =>
129
+ // (Object.keys(o) as Array<PropertyKey>).concat(Object.getOwnPropertySymbols(o));
130
+
131
+ // const _lazilyMergeDefaults = (
132
+ // fields: Schema.Struct.Fields,
133
+ // out: Record<PropertyKey, unknown>,
134
+ // ): { [x: string | symbol]: unknown } => {
135
+ // const ownKeys = _ownKeys(fields);
136
+ // for (const key of ownKeys) {
137
+ // const field = fields[key];
138
+ // if (out[key] === undefined && Schema.isPropertySignature(field)) {
139
+ // const ast = field.ast;
140
+ // const defaultValue = ast._tag === 'PropertySignatureDeclaration' ? ast.defaultValue : ast.to.defaultValue;
141
+ // if (defaultValue !== undefined) {
142
+ // out[key] = defaultValue();
143
+ // }
144
+ // }
145
+ // }
146
+ // return out;
147
+ // };
148
+
149
+ // const _getDisableValidationMakeOption = (options: MakeProps | undefined): boolean =>
150
+ // Predicate.isBoolean(options) ? options : options?.disableValidation ?? false;
151
+
152
+ /**
153
+ * Identity (typename + version) of the type meta-schema — the `Type.Type` that
154
+ * every ECHO type entity is itself an instance of. Shared by the materialisation
155
+ * vehicle ({@link persistentEntitySchema}) and `TypeSchema` so the two cannot
156
+ * drift on identity.
157
+ */
158
+ export const TypeMetaSchemaDXN = DXN.make('org.dxos.type.schema', '0.1.0');
159
+
160
+ /**
161
+ * Effect Schema that every `Type.Type` entity is an instance of: the meta-schema
162
+ * struct `{ name?, jsonSchema, id }` branded as a type-kind ECHO entity. This is
163
+ * the materialisation vehicle for `makeObject` below — the canonical user-facing
164
+ * entity is `Type/type-schema.ts`'s `TypeSchema`, which carries the same shape
165
+ * plus UI annotations.
166
+ *
167
+ * Kept self-contained (no import of `TypeSchema`) to avoid a bootstrap cycle:
168
+ * `TypeSchema` is itself produced via `makeEchoTypeSchema`, so this builder must
169
+ * not depend on it. `jsonSchema` is declared optional here (only on the
170
+ * materialisation vehicle — the canonical `TypeSchema` keeps it required) so the
171
+ * construction-time `Schema.asserts` does not force the field before it is
172
+ * attached; it is populated immediately after via a lazy accessor (see
173
+ * `makeEchoTypeSchema`).
174
+ */
175
+ // TODO(wittjosiah): Reconcile with `TypeSchema` (`Type/type-schema.ts`).
176
+ // Both describe the same `org.dxos.type.schema` shape.
177
+ const persistentEntitySchema: Schema.Schema.AnyNoContext = (() => {
178
+ const typename = DXN.getName(TypeMetaSchemaDXN);
179
+ const version = DXN.getVersion(TypeMetaSchemaDXN)!;
180
+ const struct = Schema.Struct({
181
+ name: Schema.optional(Schema.String),
182
+ jsonSchema: JsonSchemaType.pipe(Schema.optional),
183
+ id: EntityId,
184
+ });
185
+ const ast = SchemaAST.annotations(struct.ast, {
186
+ [TypeAnnotationId]: { kind: EntityKind.Type, typename, version } satisfies TypeAnnotation,
187
+ [SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({ kind: EntityKind.Type, typename, version }),
188
+ });
189
+ return Schema.make(ast);
190
+ })();
191
+
192
+ /**
193
+ * @internal
194
+ *
195
+ * Build an in-memory `Type.Type` entity (the value returned by `Type.makeObject`
196
+ * / `Type.makeRelation`). The result is a LIVE reactive `TypeSchema`
197
+ * instance — identical in every respect to a persisted `Type.Type` except that
198
+ * it is not yet attached to a database. It is mutable via `Type.update`, can be
199
+ * passed to `db.add(...)` (which keeps the same proxy and swaps the handler),
200
+ * and round-trips through `jsonSchema`.
201
+ *
202
+ * The source Effect Schema describing the user's type is cached on
203
+ * `[StaticTypeSchemaSlot]` so `Type.getSchema(...)` returns it without a
204
+ * jsonSchema round-trip; the cache is invalidated by the proxy set-trap when
205
+ * `jsonSchema` is mutated (see `typed-handler.ts`).
206
+ */
207
+ export const makeEchoTypeSchema = <
208
+ Self extends Schema.Schema.Any,
209
+ K extends EntityKind = EntityKind,
210
+ // TODO(wittjosiah): Can this be inferred from the schema?
211
+ Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
212
+ >(
213
+ fields: Fields,
214
+ ast: SchemaAST.AST,
215
+ typename: string,
216
+ version: string,
217
+ kind: K,
218
+ computeJsonSchema: () => JsonSchemaType,
219
+ explicitId?: EntityId,
220
+ ): EchoTypeSchema<Self, {}, K, Fields> => {
221
+ // Source Effect Schema describing the user's type — cached for `Type.getSchema`.
222
+ const sourceSchema = Schema.make<
223
+ EchoTypeSchemaProps<Schema.Schema.Type<Self>>,
224
+ EchoTypeSchemaProps<Schema.Schema.Encoded<Self>>,
225
+ Schema.Schema.Context<Self>
226
+ >(ast);
227
+
228
+ // `typename` / `version` route through `EntityMeta` (`key` / `version`) — the
229
+ // canonical registry-provenance pair — not data fields. `keys` is empty for
230
+ // in-memory declarations until persisted.
231
+ const meta: Partial<EntityMeta> = { keys: [], key: typename, version };
232
+
233
+ // Default to a deterministic id derived from `(typename, version)` so that
234
+ // constructing a `Type.Type` entity never reaches `crypto.getRandomValues()`.
235
+ // Cloudflare workerd forbids RNG calls in global scope, and the ~hundreds of
236
+ // `Type.makeObject(...)` call sites across the monorepo execute at module top.
237
+ // `setIdOnTarget` (see `proxy/make-object.ts`) short-circuits on a pre-supplied
238
+ // valid id, so this also bypasses the `EntityId.random()` path inside `makeObject`.
239
+ // Callers can override via `Type.makeObject(dxn, { id })` when they want a fresh
240
+ // random id (e.g. inside a request handler where workerd does allow RNG).
241
+ const id = explicitId ?? EntityId.deterministic(typename, version);
242
+
243
+ // Materialise as a live reactive meta-schema instance. `jsonSchema` is attached
244
+ // below as a getter (not passed here as data) for two reasons; see that accessor.
245
+ const entity = makeObject(persistentEntitySchema, { id } as any, meta);
246
+
247
+ const target = getProxyTarget(entity)!;
248
+ // `jsonSchema` is always available, but computed once on first read rather than at
249
+ // construction: serializing the AST walks `Schema.suspend(...)` thunks, and for a
250
+ // self-referential type (`Schema.suspend(() => Self)`) that thunk hits `Self`'s TDZ
251
+ // while we're still inside its `const` initializer. A getter also lets reads return
252
+ // the raw object instead of a child reactive proxy.
253
+ let memoizedJsonSchema: JsonSchemaType | undefined;
254
+ Object.defineProperty(target, 'jsonSchema', {
255
+ configurable: true,
256
+ enumerable: true,
257
+ get() {
258
+ return (memoizedJsonSchema ??= computeJsonSchema());
259
+ },
260
+ set(value: JsonSchemaType) {
261
+ memoizedJsonSchema = value;
262
+ },
263
+ });
264
+ // Cache the source Effect Schema (read by `Type.getSchema` via the proxy's
265
+ // `[StaticTypeSchemaSlot]` get-trap; invalidated on `jsonSchema` mutation).
266
+ defineHiddenProperty(target, StaticTypeSchemaSlot, sourceSchema);
267
+ // Schema-kind brand: what kind of instance this type describes. There is no
268
+ // database handler to derive it for in-memory entities, so stamp it directly.
269
+ defineHiddenProperty(target, SchemaKindId, kind);
270
+ // Struct fields for introspection. A getter (not a data property) so reads return
271
+ // the raw fields object rather than a child reactive proxy.
272
+ Object.defineProperty(target, 'fields', { configurable: true, enumerable: false, get: () => fields });
273
+
274
+ return entity as unknown as EchoTypeSchema<Self, {}, K, Fields>;
275
+ };
276
+
277
+ export { isEntity } from './guard';
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import type * as Entity from '../../Entity';
6
+ import { KindId, SnapshotKindId } from '../common/types';
7
+
8
+ /**
9
+ * Returns true if the value is an ECHO entity instance (object or relation).
10
+ */
11
+ export const isEntity = (value: unknown): value is Entity.Unknown => {
12
+ if (typeof value !== 'object' || value === null) {
13
+ return false;
14
+ }
15
+ return (value as any)[KindId] !== undefined;
16
+ };
17
+
18
+ /**
19
+ * Returns true if the value is an ECHO entity snapshot.
20
+ */
21
+ export const isSnapshot = (value: unknown): value is Entity.Snapshot => {
22
+ if (typeof value !== 'object' || value === null) {
23
+ return false;
24
+ }
25
+ return (value as any)[SnapshotKindId] !== undefined;
26
+ };
@@ -0,0 +1,13 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './api';
6
+ export * from './entity';
7
+ export * from './model'; // TODO(burdon): Rename.
8
+ export * from './object';
9
+ export * from './relation';
10
+ export * from './type-kind';
11
+ export * from './type-uri';
12
+ export * from './util';
13
+ export * from './version';