@dxos/echo 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d

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 (343) hide show
  1. package/dist/lib/browser/{chunk-MWLA34S5.mjs → chunk-7GH6RXJ3.mjs} +2513 -2673
  2. package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
  4. package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +21 -19
  6. package/dist/lib/browser/internal/index.mjs +55 -45
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +247 -217
  9. package/dist/lib/browser/testing/index.mjs.map +4 -4
  10. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
  11. package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
  12. package/dist/lib/node-esm/{chunk-YTNLFBIK.mjs → chunk-M4B6BMD2.mjs} +2513 -2673
  13. package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
  14. package/dist/lib/node-esm/index.mjs +21 -19
  15. package/dist/lib/node-esm/internal/index.mjs +55 -45
  16. package/dist/lib/node-esm/meta.json +1 -1
  17. package/dist/lib/node-esm/testing/index.mjs +247 -217
  18. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  19. package/dist/types/src/Annotation.d.ts +2 -0
  20. package/dist/types/src/Annotation.d.ts.map +1 -0
  21. package/dist/types/src/Database.d.ts +137 -0
  22. package/dist/types/src/Database.d.ts.map +1 -0
  23. package/dist/types/src/Entity.d.ts +36 -0
  24. package/dist/types/src/Entity.d.ts.map +1 -0
  25. package/dist/types/src/Format.d.ts +4 -0
  26. package/dist/types/src/Format.d.ts.map +1 -0
  27. package/dist/types/src/JsonSchema.d.ts +9 -0
  28. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  29. package/dist/types/src/Key.d.ts +1 -0
  30. package/dist/types/src/Key.d.ts.map +1 -1
  31. package/dist/types/src/Obj.d.ts +85 -62
  32. package/dist/types/src/Obj.d.ts.map +1 -1
  33. package/dist/types/src/Ref.d.ts +10 -10
  34. package/dist/types/src/Ref.d.ts.map +1 -1
  35. package/dist/types/src/Relation.d.ts +14 -11
  36. package/dist/types/src/Relation.d.ts.map +1 -1
  37. package/dist/types/src/Tag.d.ts +17 -0
  38. package/dist/types/src/Tag.d.ts.map +1 -0
  39. package/dist/types/src/Type.d.ts +39 -49
  40. package/dist/types/src/Type.d.ts.map +1 -1
  41. package/dist/types/src/errors.d.ts +14 -18
  42. package/dist/types/src/errors.d.ts.map +1 -1
  43. package/dist/types/src/index.d.ts +7 -3
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/internal/annotations/annotations.d.ts +174 -0
  46. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  47. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  48. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  49. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  50. package/dist/types/src/internal/annotations/util.d.ts +26 -0
  51. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  52. package/dist/types/src/internal/entities/entity.d.ts +10 -0
  53. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  54. package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
  55. package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
  56. package/dist/types/src/internal/entities/index.d.ts +6 -0
  57. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  58. package/dist/types/src/internal/entities/model.d.ts +70 -0
  59. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  60. package/dist/types/src/internal/entities/object.d.ts +11 -0
  61. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  62. package/dist/types/src/internal/entities/relation.d.ts +55 -0
  63. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  64. package/dist/types/src/internal/entities/util.d.ts +2 -0
  65. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  66. package/dist/types/src/internal/formats/format.d.ts +2 -0
  67. package/dist/types/src/internal/formats/format.d.ts.map +1 -1
  68. package/dist/types/src/internal/formats/types.d.ts +7 -7
  69. package/dist/types/src/internal/formats/types.d.ts.map +1 -1
  70. package/dist/types/src/internal/index.d.ts +6 -10
  71. package/dist/types/src/internal/index.d.ts.map +1 -1
  72. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  73. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  74. package/dist/types/src/internal/json-schema/index.d.ts +2 -0
  75. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
  76. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
  77. package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -5
  78. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  79. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  80. package/dist/types/src/internal/object/common.d.ts.map +1 -1
  81. package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +9 -10
  82. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  83. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  84. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  85. package/dist/types/src/internal/object/deleted.d.ts +2 -2
  86. package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
  87. package/dist/types/src/internal/object/ids.d.ts.map +1 -1
  88. package/dist/types/src/internal/object/index.d.ts +3 -12
  89. package/dist/types/src/internal/object/index.d.ts.map +1 -1
  90. package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
  91. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
  92. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
  93. package/dist/types/src/internal/object/typed-object.d.ts +1 -1
  94. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
  95. package/dist/types/src/internal/proxy/index.d.ts +3 -0
  96. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  97. package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
  98. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  99. package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
  100. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
  101. package/dist/types/src/internal/ref/ref.d.ts +15 -12
  102. package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
  103. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  104. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  105. package/dist/types/src/internal/schema/echo-schema.d.ts +9 -9
  106. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
  107. package/dist/types/src/internal/schema/index.d.ts +3 -4
  108. package/dist/types/src/internal/schema/index.d.ts.map +1 -1
  109. package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -1
  110. package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
  111. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  112. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
  113. package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
  114. package/dist/types/src/internal/types/base.d.ts +37 -0
  115. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  116. package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
  117. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  118. package/dist/types/src/internal/types/index.d.ts +5 -2
  119. package/dist/types/src/internal/types/index.d.ts.map +1 -1
  120. package/dist/types/src/internal/{object → types}/meta.d.ts +20 -11
  121. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  122. package/dist/types/src/internal/types/typename.d.ts +13 -0
  123. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  124. package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
  125. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  126. package/dist/types/src/query/filter.d.ts +167 -0
  127. package/dist/types/src/query/filter.d.ts.map +1 -0
  128. package/dist/types/src/query/index.d.ts +3 -1
  129. package/dist/types/src/query/index.d.ts.map +1 -1
  130. package/dist/types/src/query/order.d.ts +12 -0
  131. package/dist/types/src/query/order.d.ts.map +1 -0
  132. package/dist/types/src/query/query.d.ts +9 -144
  133. package/dist/types/src/query/query.d.ts.map +1 -1
  134. package/dist/types/src/query/testing.d.ts +51 -0
  135. package/dist/types/src/query/testing.d.ts.map +1 -0
  136. package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
  137. package/dist/types/src/query/types.d.ts.map +1 -0
  138. package/dist/types/src/query/util.d.ts +8 -0
  139. package/dist/types/src/query/util.d.ts.map +1 -0
  140. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  141. package/dist/types/src/testing/index.d.ts +3 -3
  142. package/dist/types/src/testing/index.d.ts.map +1 -1
  143. package/dist/types/src/testing/test-data.d.ts +18 -0
  144. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  145. package/dist/types/src/testing/test-schema.d.ts +337 -0
  146. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  147. package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
  148. package/dist/types/src/testing/util.d.ts.map +1 -0
  149. package/dist/types/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +46 -38
  151. package/src/Annotation.ts +17 -0
  152. package/src/Database.ts +189 -0
  153. package/src/Entity.ts +51 -0
  154. package/src/Format.ts +11 -0
  155. package/src/JsonSchema.ts +16 -0
  156. package/src/Key.ts +3 -0
  157. package/src/Obj.ts +260 -147
  158. package/src/Ref.ts +9 -9
  159. package/src/Relation.ts +58 -44
  160. package/src/Tag.ts +40 -0
  161. package/src/Type.ts +96 -83
  162. package/src/index.ts +10 -4
  163. package/src/internal/README.md +83 -0
  164. package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
  165. package/src/internal/annotations/annotations.ts +463 -0
  166. package/src/internal/annotations/index.ts +6 -0
  167. package/src/internal/annotations/util.ts +70 -0
  168. package/src/internal/entities/entity.ts +109 -0
  169. package/src/internal/{object → entities}/expando.ts +7 -5
  170. package/src/internal/entities/index.ts +9 -0
  171. package/src/internal/entities/model.ts +129 -0
  172. package/src/internal/entities/object.ts +45 -0
  173. package/src/internal/entities/relation.ts +155 -0
  174. package/src/internal/entities/util.ts +33 -0
  175. package/src/internal/formats/date.test.ts +1 -1
  176. package/src/internal/formats/date.ts +5 -5
  177. package/src/internal/formats/format.test.ts +5 -5
  178. package/src/internal/formats/format.ts +3 -0
  179. package/src/internal/formats/number.ts +5 -5
  180. package/src/internal/formats/object.ts +2 -2
  181. package/src/internal/formats/string.ts +9 -9
  182. package/src/internal/formats/types.ts +44 -39
  183. package/src/internal/index.ts +29 -13
  184. package/src/internal/{json → json-schema}/annotations.ts +1 -1
  185. package/src/internal/json-schema/index.ts +2 -0
  186. package/src/internal/json-schema/json-schema-type.ts +4 -3
  187. package/src/internal/{json → json-schema}/json-schema.test.ts +230 -97
  188. package/src/internal/{json → json-schema}/json-schema.ts +67 -87
  189. package/src/internal/object/common.ts +3 -4
  190. package/src/internal/object/{create.test.ts → create-object.test.ts} +31 -33
  191. package/src/internal/object/{create.ts → create-object.ts} +34 -35
  192. package/src/internal/object/deleted.ts +6 -6
  193. package/src/internal/object/ids.ts +1 -1
  194. package/src/internal/object/index.ts +3 -12
  195. package/src/internal/object/inspect.ts +3 -5
  196. package/src/internal/object/json-serializer.test.ts +33 -38
  197. package/src/internal/object/json-serializer.ts +43 -38
  198. package/src/internal/object/schema-validator.ts +3 -2
  199. package/src/internal/object/typed-object.test.ts +1 -1
  200. package/src/internal/object/typed-object.ts +17 -4
  201. package/src/internal/proxy/handler.test.ts +30 -20
  202. package/src/internal/proxy/index.ts +6 -0
  203. package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
  204. package/src/internal/proxy/schema.test.ts +5 -4
  205. package/src/internal/proxy/typed-handler.test.ts +28 -28
  206. package/src/internal/proxy/typed-handler.ts +11 -6
  207. package/src/internal/proxy/typed-object.test.ts +17 -12
  208. package/src/internal/ref/ref.test.ts +9 -8
  209. package/src/internal/ref/ref.ts +24 -20
  210. package/src/internal/{projection → schema}/compose.test.ts +5 -6
  211. package/src/internal/{projection → schema}/compose.ts +2 -1
  212. package/src/internal/schema/echo-schema.ts +30 -28
  213. package/src/internal/schema/index.ts +3 -4
  214. package/src/internal/schema/manipulation.ts +7 -1
  215. package/src/internal/schema/persistent-schema.ts +28 -0
  216. package/src/internal/schema/runtime-schema-registry.ts +4 -4
  217. package/src/internal/types/base.ts +58 -0
  218. package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
  219. package/src/internal/types/index.ts +5 -2
  220. package/src/internal/{object → types}/meta.ts +32 -18
  221. package/src/internal/types/typename.ts +45 -0
  222. package/src/internal/types/version.ts +20 -0
  223. package/src/query/filter.ts +455 -0
  224. package/src/query/index.ts +4 -1
  225. package/src/query/order.ts +34 -0
  226. package/src/query/query.test.ts +188 -216
  227. package/src/query/query.ts +24 -505
  228. package/src/query/testing.ts +64 -0
  229. package/src/query/util.ts +25 -0
  230. package/src/testing/api.test.ts +100 -0
  231. package/src/testing/index.ts +3 -3
  232. package/src/testing/test-data.ts +130 -0
  233. package/src/testing/test-schema.ts +213 -0
  234. package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
  235. package/dist/lib/browser/chunk-MWLA34S5.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-OAZJQHVO.mjs +0 -453
  237. package/dist/lib/browser/chunk-OAZJQHVO.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-ORIE2FMS.mjs +0 -514
  239. package/dist/lib/browser/chunk-ORIE2FMS.mjs.map +0 -7
  240. package/dist/lib/browser/query/index.mjs +0 -23
  241. package/dist/lib/browser/query/index.mjs.map +0 -7
  242. package/dist/lib/node-esm/chunk-AXWVDOP7.mjs +0 -453
  243. package/dist/lib/node-esm/chunk-AXWVDOP7.mjs.map +0 -7
  244. package/dist/lib/node-esm/chunk-L4PBAJDP.mjs +0 -514
  245. package/dist/lib/node-esm/chunk-L4PBAJDP.mjs.map +0 -7
  246. package/dist/lib/node-esm/chunk-YTNLFBIK.mjs.map +0 -7
  247. package/dist/lib/node-esm/query/index.mjs +0 -23
  248. package/dist/lib/node-esm/query/index.mjs.map +0 -7
  249. package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
  250. package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
  251. package/dist/types/src/internal/ast/annotations.d.ts +0 -119
  252. package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
  253. package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
  254. package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
  255. package/dist/types/src/internal/ast/index.d.ts +0 -5
  256. package/dist/types/src/internal/ast/index.d.ts.map +0 -1
  257. package/dist/types/src/internal/ast/types.d.ts +0 -6
  258. package/dist/types/src/internal/ast/types.d.ts.map +0 -1
  259. package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
  260. package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
  261. package/dist/types/src/internal/json/index.d.ts +0 -2
  262. package/dist/types/src/internal/json/index.d.ts.map +0 -1
  263. package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
  264. package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
  265. package/dist/types/src/internal/object/accessors.d.ts +0 -29
  266. package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
  267. package/dist/types/src/internal/object/create.d.ts.map +0 -1
  268. package/dist/types/src/internal/object/create.test.d.ts +0 -2
  269. package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
  270. package/dist/types/src/internal/object/entity.d.ts +0 -22
  271. package/dist/types/src/internal/object/entity.d.ts.map +0 -1
  272. package/dist/types/src/internal/object/expando.d.ts.map +0 -1
  273. package/dist/types/src/internal/object/meta.d.ts.map +0 -1
  274. package/dist/types/src/internal/object/model.d.ts +0 -117
  275. package/dist/types/src/internal/object/model.d.ts.map +0 -1
  276. package/dist/types/src/internal/object/relation.d.ts +0 -17
  277. package/dist/types/src/internal/object/relation.d.ts.map +0 -1
  278. package/dist/types/src/internal/object/typed-relation.d.ts +0 -32
  279. package/dist/types/src/internal/object/typed-relation.d.ts.map +0 -1
  280. package/dist/types/src/internal/object/typename.d.ts +0 -15
  281. package/dist/types/src/internal/object/typename.d.ts.map +0 -1
  282. package/dist/types/src/internal/object/version.d.ts.map +0 -1
  283. package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
  284. package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
  285. package/dist/types/src/internal/projection/index.d.ts +0 -2
  286. package/dist/types/src/internal/projection/index.d.ts.map +0 -1
  287. package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
  288. package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
  289. package/dist/types/src/internal/query/index.d.ts +0 -2
  290. package/dist/types/src/internal/query/index.d.ts.map +0 -1
  291. package/dist/types/src/internal/query/query.d.ts.map +0 -1
  292. package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
  293. package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
  294. package/dist/types/src/internal/testing/index.d.ts +0 -3
  295. package/dist/types/src/internal/testing/index.d.ts.map +0 -1
  296. package/dist/types/src/internal/testing/types.d.ts +0 -455
  297. package/dist/types/src/internal/testing/types.d.ts.map +0 -1
  298. package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
  299. package/dist/types/src/internal/types/types.d.ts +0 -79
  300. package/dist/types/src/internal/types/types.d.ts.map +0 -1
  301. package/dist/types/src/internal/types/types.test.d.ts +0 -2
  302. package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
  303. package/dist/types/src/internal/types/util.d.ts +0 -5
  304. package/dist/types/src/internal/types/util.d.ts.map +0 -1
  305. package/dist/types/src/query/tag.d.ts +0 -18
  306. package/dist/types/src/query/tag.d.ts.map +0 -1
  307. package/dist/types/src/testing/echo-schema.d.ts +0 -7
  308. package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
  309. package/dist/types/src/testing/types.d.ts +0 -113
  310. package/dist/types/src/testing/types.d.ts.map +0 -1
  311. package/src/internal/ast/annotation-helper.ts +0 -22
  312. package/src/internal/ast/annotations.ts +0 -212
  313. package/src/internal/ast/index.ts +0 -8
  314. package/src/internal/ast/types.ts +0 -17
  315. package/src/internal/json/index.ts +0 -5
  316. package/src/internal/object/accessors.ts +0 -115
  317. package/src/internal/object/entity.ts +0 -204
  318. package/src/internal/object/model.ts +0 -170
  319. package/src/internal/object/relation.ts +0 -24
  320. package/src/internal/object/typed-relation.ts +0 -85
  321. package/src/internal/object/typename.ts +0 -61
  322. package/src/internal/object/version.ts +0 -22
  323. package/src/internal/projection/index.ts +0 -5
  324. package/src/internal/query/index.ts +0 -5
  325. package/src/internal/schema/stored-schema.ts +0 -26
  326. package/src/internal/testing/index.ts +0 -6
  327. package/src/internal/testing/types.ts +0 -211
  328. package/src/internal/types/types.test.ts +0 -48
  329. package/src/internal/types/types.ts +0 -176
  330. package/src/internal/types/util.ts +0 -9
  331. package/src/query/tag.ts +0 -35
  332. package/src/test/api.test.ts +0 -180
  333. package/src/testing/echo-schema.ts +0 -39
  334. package/src/testing/types.ts +0 -91
  335. /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
  336. /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
  337. /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
  338. /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
  339. /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
  340. /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
  341. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
  342. /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
  343. /package/src/{internal/query/query.ts → query/types.ts} +0 -0
@@ -1,113 +0,0 @@
1
- import * as Schema from 'effect/Schema';
2
- import { Type } from '..';
3
- export declare namespace Testing {
4
- const _Contact: Type.obj<Schema.SchemaClass<{
5
- readonly email?: string | undefined;
6
- readonly name?: string | undefined;
7
- readonly username?: string | undefined;
8
- readonly tasks?: import("../internal").Ref<Task>[] | undefined;
9
- readonly address?: {
10
- readonly city?: string | undefined;
11
- readonly state?: string | undefined;
12
- readonly zip?: string | undefined;
13
- readonly coordinates: {
14
- readonly lat?: number | undefined;
15
- readonly lng?: number | undefined;
16
- };
17
- } | undefined;
18
- }, {
19
- readonly email?: string | undefined;
20
- readonly name?: string | undefined;
21
- readonly username?: string | undefined;
22
- readonly tasks?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
23
- readonly address?: {
24
- readonly coordinates: {
25
- readonly lat?: number | undefined;
26
- readonly lng?: number | undefined;
27
- };
28
- readonly city?: string | undefined;
29
- readonly state?: string | undefined;
30
- readonly zip?: string | undefined;
31
- } | undefined;
32
- }, never>>;
33
- export interface Contact extends Schema.Schema.Type<typeof _Contact> {
34
- }
35
- export const Contact: Schema.Schema<Contact, Schema.Schema.Encoded<typeof _Contact>, never>;
36
- const _Task: Type.obj<Schema.SchemaClass<{
37
- readonly title?: string | undefined;
38
- readonly description?: string | undefined;
39
- readonly completed?: boolean | undefined;
40
- readonly assignee?: import("../internal").Ref<Contact> | undefined;
41
- readonly previous?: import("../internal").Ref<Task> | undefined;
42
- readonly subTasks?: import("../internal").Ref<Task>[] | undefined;
43
- }, {
44
- readonly title?: string | undefined;
45
- readonly description?: string | undefined;
46
- readonly completed?: boolean | undefined;
47
- readonly assignee?: import("@dxos/echo-protocol").EncodedReference | undefined;
48
- readonly previous?: import("@dxos/echo-protocol").EncodedReference | undefined;
49
- readonly subTasks?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
50
- }, never>>;
51
- export interface Task extends Schema.Schema.Type<typeof _Task> {
52
- }
53
- export const Task: Schema.Schema<Task, Schema.Schema.Encoded<typeof _Task>, never>;
54
- export enum RecordType {
55
- UNDEFINED = 0,
56
- PERSONAL = 1,
57
- WORK = 2
58
- }
59
- export const Container: Type.obj<Schema.SchemaClass<{
60
- readonly records?: {
61
- readonly title?: string | undefined;
62
- readonly description?: string | undefined;
63
- readonly type?: RecordType | undefined;
64
- readonly contacts?: import("../internal").Ref<Contact>[] | undefined;
65
- }[] | undefined;
66
- readonly objects?: import("../internal").Ref<Type.Expando>[] | undefined;
67
- }, {
68
- readonly records?: {
69
- readonly title?: string | undefined;
70
- readonly description?: string | undefined;
71
- readonly type?: RecordType | undefined;
72
- readonly contacts?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
73
- }[] | undefined;
74
- readonly objects?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
75
- }, never>>;
76
- export const WorksFor: Type.relation<Schema.Struct<{
77
- since: Schema.optional<typeof Schema.String>;
78
- }>, Schema.Schema<Contact, {
79
- id: string;
80
- email?: string | undefined;
81
- name?: string | undefined;
82
- username?: string | undefined;
83
- tasks?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
84
- address?: {
85
- readonly coordinates: {
86
- readonly lat?: number | undefined;
87
- readonly lng?: number | undefined;
88
- };
89
- readonly city?: string | undefined;
90
- readonly state?: string | undefined;
91
- readonly zip?: string | undefined;
92
- } | undefined;
93
- }, never>, Schema.Schema<Contact, {
94
- id: string;
95
- email?: string | undefined;
96
- name?: string | undefined;
97
- username?: string | undefined;
98
- tasks?: import("@dxos/echo-protocol").EncodedReference[] | undefined;
99
- address?: {
100
- readonly coordinates: {
101
- readonly lat?: number | undefined;
102
- readonly lng?: number | undefined;
103
- };
104
- readonly city?: string | undefined;
105
- readonly state?: string | undefined;
106
- readonly zip?: string | undefined;
107
- } | undefined;
108
- }, never>>;
109
- export interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {
110
- }
111
- export {};
112
- }
113
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/testing/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAG1B,yBAAiB,OAAO,CAAC;IACvB,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoBb,CAAC;IACF,MAAM,WAAW,OAAQ,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC;KAAG;IACvE,MAAM,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,QAAQ,CAAC,EAAE,KAAK,CAAY,CAAC;IAEvG,MAAM,KAAK;;;;;;;;;;;;;;cAaV,CAAC;IACF,MAAM,WAAW,IAAK,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC;KAAG;IACjE,MAAM,CAAC,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,KAAK,CAAC,EAAE,KAAK,CAAS,CAAC;IAE3F,MAAM,MAAM,UAAU;QACpB,SAAS,IAAI;QACb,QAAQ,IAAI;QACZ,IAAI,IAAI;KACT;IAED,MAAM,CAAC,MAAM,SAAS;;;;;;;;;;;;;;;;cAoBrB,CAAC;IAEF,MAAM,CAAC,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cASpB,CAAC;IACF,MAAM,WAAW,QAAS,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC;KAAG;;CACzE"}
@@ -1,22 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import type * as Option from 'effect/Option';
6
- import type * as Schema from 'effect/Schema';
7
- import * as SchemaAST from 'effect/SchemaAST';
8
-
9
- export interface AnnotationHelper<T> {
10
- get: (schema: Schema.Schema.Any) => Option.Option<T>;
11
- set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;
12
- }
13
-
14
- export const createAnnotationHelper = <T>(id: symbol): AnnotationHelper<T> => {
15
- return {
16
- get: (schema) => SchemaAST.getAnnotation(schema.ast, id),
17
- set:
18
- (value) =>
19
- <S extends Schema.Schema.Any>(schema: S) =>
20
- schema.annotations({ [id]: value }) as S,
21
- };
22
- };
@@ -1,212 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import * as Function from 'effect/Function';
6
- import * as Option from 'effect/Option';
7
- import * as Schema from 'effect/Schema';
8
- import * as SchemaAST from 'effect/SchemaAST';
9
-
10
- import { assertArgument } from '@dxos/invariant';
11
- import { DXN } from '@dxos/keys';
12
- import { type Primitive } from '@dxos/util';
13
-
14
- import { createAnnotationHelper } from './annotation-helper';
15
- import { EntityKind } from './entity-kind';
16
-
17
- /**
18
- * If property is optional returns the nested property, otherwise returns the property.
19
- */
20
- // TODO(wittjosiah): Is there a way to do this as a generic?
21
- export const unwrapOptional = (property: SchemaAST.PropertySignature) => {
22
- if (!property.isOptional || !SchemaAST.isUnion(property.type)) {
23
- return property;
24
- }
25
-
26
- return property.type.types[0];
27
- };
28
-
29
- /**
30
- * ECHO identifier (for a stored schema).
31
- * Must be a `dxn:echo:` URI.
32
- */
33
- export const TypeIdentifierAnnotationId = Symbol.for('@dxos/schema/annotation/TypeIdentifier');
34
-
35
- export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
36
- Function.flow(
37
- SchemaAST.getAnnotation<string>(TypeIdentifierAnnotationId),
38
- Option.getOrElse(() => undefined),
39
- )(schema.ast);
40
-
41
- /**
42
- * ECHO type.
43
- */
44
- export const TypeAnnotationId = Symbol.for('@dxos/schema/annotation/Type');
45
-
46
- // TODO(burdon): Create echo-schema Format types.
47
- // TODO(burdon): Reconcile with "short" DXN.
48
- export const Typename = Schema.String.pipe(Schema.pattern(/^[a-zA-Z]\w+\.[a-zA-Z]\w{1,}\/[\w/_-]+$/));
49
- export const SchemaVersion = Schema.String.pipe(Schema.pattern(/^\d+.\d+.\d+$/));
50
-
51
- /**
52
- * Payload stored under {@link TypeAnnotationId}.
53
- */
54
- // TODO(dmaretskyi): Rename getTypeAnnotation to represent commonality between objects and relations (e.g. `entity`).
55
- export const TypeAnnotation = Schema.Struct({
56
- kind: Schema.Enums(EntityKind),
57
- typename: Typename,
58
- version: SchemaVersion,
59
-
60
- /**
61
- * If this is a relation, the schema of the source object.
62
- * Must be present if entity kind is {@link EntityKind.Relation}.
63
- */
64
- sourceSchema: Schema.optional(DXN.Schema),
65
-
66
- /**
67
- * If this is a relation, the schema of the target object.
68
- * Must be present if entity kind is {@link EntityKind.Relation}.
69
- */
70
- targetSchema: Schema.optional(DXN.Schema),
71
- });
72
-
73
- export interface TypeAnnotation extends Schema.Schema.Type<typeof TypeAnnotation> {}
74
-
75
- export type TypeMeta = Pick<TypeAnnotation, 'typename' | 'version'>;
76
-
77
- /**
78
- * @returns {@link TypeAnnotation} from a schema.
79
- * Schema must have been created with {@link TypedObject} or {@link TypedLink} or manually assigned an appropriate annotation.
80
- */
81
- export const getTypeAnnotation = (schema: Schema.Schema.All): TypeAnnotation | undefined => {
82
- assertArgument(schema != null && schema.ast != null, 'schema', 'invalid schema');
83
- return Function.flow(
84
- SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId),
85
- Option.getOrElse(() => undefined),
86
- )(schema.ast);
87
- };
88
-
89
- /**
90
- * @returns {@link EntityKind} from a schema.
91
- */
92
- export const getEntityKind = (schema: Schema.Schema.All): EntityKind | undefined => getTypeAnnotation(schema)?.kind;
93
-
94
- /**
95
- * @deprecated Use {@link Type.getTypename} instead.
96
- * @returns Schema typename (without dxn: prefix or version number).
97
- */
98
- export const getSchemaTypename = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.typename;
99
-
100
- /**
101
- * @deprecated Use {@link Type.getVersion} instead.
102
- * @returns Schema version in semver format.
103
- */
104
- export const getSchemaVersion = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.version;
105
-
106
- /**
107
- * PropertyMeta (metadata for dynamic schema properties).
108
- * For user-defined annotations.
109
- */
110
- export const PropertyMetaAnnotationId = Symbol.for('@dxos/schema/annotation/PropertyMeta');
111
-
112
- export type PropertyMetaValue = Primitive | Record<string, Primitive> | Primitive[];
113
-
114
- export type PropertyMetaAnnotation = {
115
- [name: string]: PropertyMetaValue;
116
- };
117
-
118
- export const PropertyMeta = (name: string, value: PropertyMetaValue) => {
119
- return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {
120
- const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;
121
- return self.annotations({
122
- [PropertyMetaAnnotationId]: {
123
- ...existingMeta,
124
- [name]: value,
125
- },
126
- });
127
- };
128
- };
129
-
130
- export const getPropertyMetaAnnotation = <T>(prop: SchemaAST.PropertySignature, name: string) =>
131
- Function.pipe(
132
- SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(prop.type),
133
- Option.map((meta) => meta[name] as T),
134
- Option.getOrElse(() => undefined),
135
- );
136
-
137
- /**
138
- * Schema reference.
139
- */
140
- export const ReferenceAnnotationId = Symbol.for('@dxos/schema/annotation/Reference');
141
-
142
- export type ReferenceAnnotationValue = TypeAnnotation;
143
-
144
- export const getReferenceAnnotation = (schema: Schema.Schema.AnyNoContext) =>
145
- Function.pipe(
146
- SchemaAST.getAnnotation<ReferenceAnnotationValue>(ReferenceAnnotationId)(schema.ast),
147
- Option.getOrElse(() => undefined),
148
- );
149
-
150
- /**
151
- * SchemaMeta.
152
- */
153
- export const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');
154
-
155
- export type SchemaMeta = TypeMeta & { id: string };
156
-
157
- /**
158
- * Identifies a schema as a view.
159
- */
160
- export const ViewAnnotationId = Symbol.for('@dxos/schema/annotation/View');
161
- export const ViewAnnotation = createAnnotationHelper<boolean>(ViewAnnotationId);
162
-
163
- /**
164
- * Identifies label property or JSON path expression.
165
- * Either a string or an array of strings representing field accessors each matched in priority order.
166
- */
167
- export const LabelAnnotationId = Symbol.for('@dxos/schema/annotation/Label');
168
- export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationId);
169
-
170
- /**
171
- * Default field to be used on referenced schema to lookup the value.
172
- */
173
- export const FieldLookupAnnotationId = Symbol.for('@dxos/schema/annotation/FieldLookup');
174
-
175
- /**
176
- * Generate test data.
177
- */
178
- export const GeneratorAnnotationId = Symbol.for('@dxos/schema/annotation/Generator');
179
-
180
- export type GeneratorAnnotationValue =
181
- | string
182
- | {
183
- generator: string;
184
- args?: any[];
185
- probability?: number;
186
- };
187
-
188
- export const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);
189
-
190
- /**
191
- * @returns DXN of the schema.
192
- *
193
- * For non-stored schema returns `dxn:type:`.
194
- * For stored schema returns `dxn:echo:`.
195
- * @deprecated Use `Type.getDXN`.
196
- */
197
- export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
198
- assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
199
-
200
- const id = getTypeIdentifierAnnotation(schema);
201
- if (id) {
202
- return DXN.parse(id);
203
- }
204
-
205
- // TODO(dmaretskyi): Add support for dynamic schema.
206
- const objectAnnotation = getTypeAnnotation(schema);
207
- if (!objectAnnotation) {
208
- return undefined;
209
- }
210
-
211
- return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
212
- };
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './annotations';
6
- export * from './annotation-helper';
7
- export * from './types';
8
- export * from './entity-kind';
@@ -1,17 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { PropertyMeta } from './annotations';
6
-
7
- /**
8
- * @internal
9
- */
10
- export const FIELD_PATH_ANNOTATION = 'path';
11
-
12
- /**
13
- * Sets the path for the field.
14
- * @param path Data source path in the json path format. This is the field path in the source object.
15
- */
16
- // TODO(burdon): Field, vs. path vs. property.
17
- export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './json-schema';
@@ -1,115 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Option from 'effect/Option';
6
- import * as Schema from 'effect/Schema';
7
-
8
- import { type JsonPath, getField } from '@dxos/effect';
9
- import { assertArgument, invariant } from '@dxos/invariant';
10
- import { DXN, ObjectId } from '@dxos/keys';
11
- import { assumeType } from '@dxos/util';
12
-
13
- import { LabelAnnotation } from '../ast';
14
-
15
- import { type InternalObjectProps, SchemaId, SelfDXNId } from './model';
16
-
17
- //
18
- // Accessors based on model.
19
- //
20
-
21
- /**
22
- * Returns a DXN for an object or schema.
23
- * @deprecated Use `Obj.getDXN`.
24
- */
25
- export const getObjectDXN = (object: any): DXN | undefined => {
26
- invariant(!Schema.isSchema(object), 'schema not allowed in this function');
27
- assertArgument(typeof object === 'object' && object != null, 'object', 'expected object');
28
- assumeType<InternalObjectProps>(object);
29
-
30
- if (object[SelfDXNId]) {
31
- invariant(object[SelfDXNId] instanceof DXN, 'Invalid object model: invalid self dxn');
32
- return object[SelfDXNId];
33
- }
34
-
35
- if (!ObjectId.isValid(object.id)) {
36
- throw new TypeError('Object id is not valid.');
37
- }
38
-
39
- return DXN.fromLocalObjectId(object.id);
40
- };
41
-
42
- /**
43
- * Returns the schema for the given object if one is defined.
44
- */
45
- // TODO(burdon): Reconcile with `getTypename`.
46
- // TODO(dmaretskyi): For echo objects, this always returns the root schema.
47
- export const getSchema = (obj: unknown | undefined): Schema.Schema.AnyNoContext | undefined => {
48
- if (obj) {
49
- return (obj as any)[SchemaId];
50
- }
51
- };
52
-
53
- /**
54
- * Internal use only.
55
- */
56
- export const setSchema = (obj: any, schema: Schema.Schema.AnyNoContext) => {
57
- Object.defineProperty(obj, SchemaId, {
58
- value: schema,
59
- writable: false,
60
- enumerable: false,
61
- configurable: false,
62
- });
63
- };
64
-
65
- /**
66
- * @deprecated Use {@link Obj.getLabel} instead.
67
- * Returns the label for a given object based on {@link LabelAnnotationId}.
68
- */
69
- export const getLabelForObject = (obj: unknown | undefined): string | undefined => {
70
- const schema = getSchema(obj);
71
- if (schema) {
72
- return getLabel(schema, obj);
73
- }
74
- };
75
-
76
- /**
77
- * Returns the label for a given object based on {@link LabelAnnotationId}.
78
- */
79
- // TODO(burdon): Convert to JsonPath?
80
- export const getLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.Schema.Type<S>): string | undefined => {
81
- const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
82
- for (const accessor of annotation) {
83
- assertArgument(
84
- typeof accessor === 'string',
85
- 'accessor',
86
- 'Label annotation must be a string or an array of strings',
87
- );
88
- const value = getField(object, accessor as JsonPath);
89
- switch (typeof value) {
90
- case 'string':
91
- case 'number':
92
- case 'boolean':
93
- case 'bigint':
94
- case 'symbol':
95
- return value.toString();
96
- case 'undefined':
97
- case 'object':
98
- case 'function':
99
- continue;
100
- }
101
- }
102
-
103
- return undefined;
104
- };
105
-
106
- /**
107
- * Sets the label for a given object based on {@link LabelAnnotationId}.
108
- */
109
- export const setLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.Schema.Type<S>, label: string) => {
110
- const annotation = LabelAnnotation.get(schema).pipe(
111
- Option.map((field) => field[0]),
112
- Option.getOrElse(() => 'name'),
113
- );
114
- object[annotation] = label;
115
- };