@dxos/echo 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b

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 (478) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/browser/Annotation.mjs +31 -0
  3. package/dist/lib/browser/Annotation.mjs.map +7 -0
  4. package/dist/lib/browser/Database.mjs +14 -0
  5. package/dist/lib/browser/Database.mjs.map +7 -0
  6. package/dist/lib/browser/Entity.mjs +20 -0
  7. package/dist/lib/browser/Entity.mjs.map +7 -0
  8. package/dist/lib/browser/Err.mjs +11 -0
  9. package/dist/lib/browser/Err.mjs.map +7 -0
  10. package/dist/lib/browser/Filter.mjs +60 -0
  11. package/dist/lib/browser/Filter.mjs.map +7 -0
  12. package/dist/lib/browser/Format.mjs +67 -0
  13. package/dist/lib/browser/Format.mjs.map +7 -0
  14. package/dist/lib/browser/JsonSchema.mjs +18 -0
  15. package/dist/lib/browser/JsonSchema.mjs.map +7 -0
  16. package/dist/lib/browser/Key.mjs +13 -0
  17. package/dist/lib/browser/Key.mjs.map +7 -0
  18. package/dist/lib/browser/Obj.mjs +83 -0
  19. package/dist/lib/browser/Obj.mjs.map +7 -0
  20. package/dist/lib/browser/Order.mjs +11 -0
  21. package/dist/lib/browser/Order.mjs.map +7 -0
  22. package/dist/lib/browser/Query.mjs +25 -0
  23. package/dist/lib/browser/Query.mjs.map +7 -0
  24. package/dist/lib/browser/QueryResult.mjs +3 -0
  25. package/dist/lib/browser/QueryResult.mjs.map +7 -0
  26. package/dist/lib/browser/Ref.mjs +21 -0
  27. package/dist/lib/browser/Ref.mjs.map +7 -0
  28. package/dist/lib/browser/Relation.mjs +33 -0
  29. package/dist/lib/browser/Relation.mjs.map +7 -0
  30. package/dist/lib/browser/SchemaRegistry.mjs +3 -0
  31. package/dist/lib/browser/SchemaRegistry.mjs.map +7 -0
  32. package/dist/lib/browser/Tag.mjs +25 -0
  33. package/dist/lib/browser/Tag.mjs.map +7 -0
  34. package/dist/lib/browser/Type.mjs +38 -0
  35. package/dist/lib/browser/Type.mjs.map +7 -0
  36. package/dist/lib/browser/chunk-3B2G6BW4.mjs +74 -0
  37. package/dist/lib/browser/chunk-3B2G6BW4.mjs.map +7 -0
  38. package/dist/lib/browser/chunk-5IN7XBIQ.mjs +24 -0
  39. package/dist/lib/browser/chunk-5IN7XBIQ.mjs.map +7 -0
  40. package/dist/lib/browser/chunk-6XVZF5VJ.mjs +2924 -0
  41. package/dist/lib/browser/chunk-6XVZF5VJ.mjs.map +7 -0
  42. package/dist/lib/browser/chunk-AGOWBKY6.mjs +94 -0
  43. package/dist/lib/browser/chunk-AGOWBKY6.mjs.map +7 -0
  44. package/dist/lib/browser/chunk-BD6MRI4M.mjs +113 -0
  45. package/dist/lib/browser/chunk-BD6MRI4M.mjs.map +7 -0
  46. package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
  47. package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
  48. package/dist/lib/browser/chunk-DOPKE2FQ.mjs +32 -0
  49. package/dist/lib/browser/chunk-DOPKE2FQ.mjs.map +7 -0
  50. package/dist/lib/browser/chunk-ESLW4N7S.mjs +41 -0
  51. package/dist/lib/browser/chunk-ESLW4N7S.mjs.map +7 -0
  52. package/dist/lib/browser/chunk-F4YF6C3O.mjs +363 -0
  53. package/dist/lib/browser/chunk-F4YF6C3O.mjs.map +7 -0
  54. package/dist/lib/browser/chunk-FGFQWIZE.mjs +9 -0
  55. package/dist/lib/browser/chunk-FGFQWIZE.mjs.map +7 -0
  56. package/dist/lib/browser/chunk-INHXFXY5.mjs +22 -0
  57. package/dist/lib/browser/chunk-INHXFXY5.mjs.map +7 -0
  58. package/dist/lib/browser/chunk-JG4GH6LN.mjs +9 -0
  59. package/dist/lib/browser/chunk-JG4GH6LN.mjs.map +7 -0
  60. package/dist/lib/browser/chunk-MYCCGG2T.mjs +15 -0
  61. package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +7 -0
  62. package/dist/lib/browser/chunk-NFH3POTD.mjs +37 -0
  63. package/dist/lib/browser/chunk-NFH3POTD.mjs.map +7 -0
  64. package/dist/lib/browser/chunk-O6FOICWT.mjs +57 -0
  65. package/dist/lib/browser/chunk-O6FOICWT.mjs.map +7 -0
  66. package/dist/lib/browser/chunk-P2B4BASR.mjs +288 -0
  67. package/dist/lib/browser/chunk-P2B4BASR.mjs.map +7 -0
  68. package/dist/lib/browser/chunk-QHC3ZYNC.mjs +152 -0
  69. package/dist/lib/browser/chunk-QHC3ZYNC.mjs.map +7 -0
  70. package/dist/lib/browser/chunk-QU7PWSZD.mjs +62 -0
  71. package/dist/lib/browser/chunk-QU7PWSZD.mjs.map +7 -0
  72. package/dist/lib/browser/chunk-RP4JV7FD.mjs +403 -0
  73. package/dist/lib/browser/chunk-RP4JV7FD.mjs.map +7 -0
  74. package/dist/lib/browser/chunk-V7TON6BX.mjs +151 -0
  75. package/dist/lib/browser/chunk-V7TON6BX.mjs.map +7 -0
  76. package/dist/lib/browser/chunk-WABSVOOX.mjs +303 -0
  77. package/dist/lib/browser/chunk-WABSVOOX.mjs.map +7 -0
  78. package/dist/lib/browser/chunk-XRHHSMHJ.mjs +39 -0
  79. package/dist/lib/browser/chunk-XRHHSMHJ.mjs.map +7 -0
  80. package/dist/lib/browser/chunk-ZIM3Y4ZK.mjs +38 -0
  81. package/dist/lib/browser/chunk-ZIM3Y4ZK.mjs.map +7 -0
  82. package/dist/lib/browser/index.mjs +72 -9
  83. package/dist/lib/browser/internal/index.mjs +347 -0
  84. package/dist/lib/browser/internal/index.mjs.map +7 -0
  85. package/dist/lib/browser/meta.json +1 -1
  86. package/dist/lib/browser/testing/index.mjs +322 -32
  87. package/dist/lib/browser/testing/index.mjs.map +4 -4
  88. package/dist/lib/node-esm/Annotation.mjs +31 -0
  89. package/dist/lib/node-esm/Annotation.mjs.map +7 -0
  90. package/dist/lib/node-esm/Database.mjs +14 -0
  91. package/dist/lib/node-esm/Database.mjs.map +7 -0
  92. package/dist/lib/node-esm/Entity.mjs +20 -0
  93. package/dist/lib/node-esm/Entity.mjs.map +7 -0
  94. package/dist/lib/node-esm/Err.mjs +11 -0
  95. package/dist/lib/node-esm/Err.mjs.map +7 -0
  96. package/dist/lib/node-esm/Filter.mjs +60 -0
  97. package/dist/lib/node-esm/Filter.mjs.map +7 -0
  98. package/dist/lib/node-esm/Format.mjs +67 -0
  99. package/dist/lib/node-esm/Format.mjs.map +7 -0
  100. package/dist/lib/node-esm/JsonSchema.mjs +18 -0
  101. package/dist/lib/node-esm/JsonSchema.mjs.map +7 -0
  102. package/dist/lib/node-esm/Key.mjs +13 -0
  103. package/dist/lib/node-esm/Key.mjs.map +7 -0
  104. package/dist/lib/node-esm/Obj.mjs +83 -0
  105. package/dist/lib/node-esm/Obj.mjs.map +7 -0
  106. package/dist/lib/node-esm/Order.mjs +11 -0
  107. package/dist/lib/node-esm/Order.mjs.map +7 -0
  108. package/dist/lib/node-esm/Query.mjs +25 -0
  109. package/dist/lib/node-esm/Query.mjs.map +7 -0
  110. package/dist/lib/node-esm/QueryResult.mjs +3 -0
  111. package/dist/lib/node-esm/QueryResult.mjs.map +7 -0
  112. package/dist/lib/node-esm/Ref.mjs +21 -0
  113. package/dist/lib/node-esm/Ref.mjs.map +7 -0
  114. package/dist/lib/node-esm/Relation.mjs +33 -0
  115. package/dist/lib/node-esm/Relation.mjs.map +7 -0
  116. package/dist/lib/node-esm/SchemaRegistry.mjs +3 -0
  117. package/dist/lib/node-esm/SchemaRegistry.mjs.map +7 -0
  118. package/dist/lib/node-esm/Tag.mjs +25 -0
  119. package/dist/lib/node-esm/Tag.mjs.map +7 -0
  120. package/dist/lib/node-esm/Type.mjs +38 -0
  121. package/dist/lib/node-esm/Type.mjs.map +7 -0
  122. package/dist/lib/node-esm/chunk-5M5P2DCR.mjs +32 -0
  123. package/dist/lib/node-esm/chunk-5M5P2DCR.mjs.map +7 -0
  124. package/dist/lib/node-esm/chunk-6OTQZKHX.mjs +303 -0
  125. package/dist/lib/node-esm/chunk-6OTQZKHX.mjs.map +7 -0
  126. package/dist/lib/node-esm/chunk-76LEDWHO.mjs +152 -0
  127. package/dist/lib/node-esm/chunk-76LEDWHO.mjs.map +7 -0
  128. package/dist/lib/node-esm/chunk-AGHZH33D.mjs +9 -0
  129. package/dist/lib/node-esm/chunk-AGHZH33D.mjs.map +7 -0
  130. package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +22 -0
  131. package/dist/lib/node-esm/chunk-AJEMYSIR.mjs.map +7 -0
  132. package/dist/lib/node-esm/chunk-BJACR7QG.mjs +363 -0
  133. package/dist/lib/node-esm/chunk-BJACR7QG.mjs.map +7 -0
  134. package/dist/lib/node-esm/chunk-BYL2NPEA.mjs +37 -0
  135. package/dist/lib/node-esm/chunk-BYL2NPEA.mjs.map +7 -0
  136. package/dist/lib/node-esm/chunk-CCMFPJUT.mjs +74 -0
  137. package/dist/lib/node-esm/chunk-CCMFPJUT.mjs.map +7 -0
  138. package/dist/lib/node-esm/chunk-D5BW7KHR.mjs +39 -0
  139. package/dist/lib/node-esm/chunk-D5BW7KHR.mjs.map +7 -0
  140. package/dist/lib/node-esm/chunk-DJX53IQ3.mjs +2924 -0
  141. package/dist/lib/node-esm/chunk-DJX53IQ3.mjs.map +7 -0
  142. package/dist/lib/node-esm/chunk-FWTPV5QD.mjs +94 -0
  143. package/dist/lib/node-esm/chunk-FWTPV5QD.mjs.map +7 -0
  144. package/dist/lib/node-esm/chunk-HLUDHPFO.mjs +403 -0
  145. package/dist/lib/node-esm/chunk-HLUDHPFO.mjs.map +7 -0
  146. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  147. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  148. package/dist/lib/node-esm/chunk-JYZSF62S.mjs +113 -0
  149. package/dist/lib/node-esm/chunk-JYZSF62S.mjs.map +7 -0
  150. package/dist/lib/node-esm/chunk-KUX5JEL2.mjs +57 -0
  151. package/dist/lib/node-esm/chunk-KUX5JEL2.mjs.map +7 -0
  152. package/dist/lib/node-esm/chunk-LDXRA5TC.mjs +288 -0
  153. package/dist/lib/node-esm/chunk-LDXRA5TC.mjs.map +7 -0
  154. package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +15 -0
  155. package/dist/lib/node-esm/chunk-MOWUEW5P.mjs.map +7 -0
  156. package/dist/lib/node-esm/chunk-NHYOREKX.mjs +62 -0
  157. package/dist/lib/node-esm/chunk-NHYOREKX.mjs.map +7 -0
  158. package/dist/lib/node-esm/chunk-QVZZHCDS.mjs +9 -0
  159. package/dist/lib/node-esm/chunk-QVZZHCDS.mjs.map +7 -0
  160. package/dist/lib/node-esm/chunk-W3OLV7MG.mjs +41 -0
  161. package/dist/lib/node-esm/chunk-W3OLV7MG.mjs.map +7 -0
  162. package/dist/lib/node-esm/chunk-W5AQXKVF.mjs +38 -0
  163. package/dist/lib/node-esm/chunk-W5AQXKVF.mjs.map +7 -0
  164. package/dist/lib/node-esm/chunk-YNBFXTDG.mjs +24 -0
  165. package/dist/lib/node-esm/chunk-YNBFXTDG.mjs.map +7 -0
  166. package/dist/lib/node-esm/chunk-Z53QIBP2.mjs +151 -0
  167. package/dist/lib/node-esm/chunk-Z53QIBP2.mjs.map +7 -0
  168. package/dist/lib/node-esm/index.mjs +72 -9
  169. package/dist/lib/node-esm/internal/index.mjs +347 -0
  170. package/dist/lib/node-esm/internal/index.mjs.map +7 -0
  171. package/dist/lib/node-esm/meta.json +1 -1
  172. package/dist/lib/node-esm/testing/index.mjs +322 -32
  173. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  174. package/dist/types/src/Annotation.d.ts +2 -0
  175. package/dist/types/src/Annotation.d.ts.map +1 -0
  176. package/dist/types/src/Database.d.ts +179 -0
  177. package/dist/types/src/Database.d.ts.map +1 -0
  178. package/dist/types/src/Entity.d.ts +36 -0
  179. package/dist/types/src/Entity.d.ts.map +1 -0
  180. package/dist/types/src/Err.d.ts +68 -0
  181. package/dist/types/src/Err.d.ts.map +1 -0
  182. package/dist/types/src/Filter.d.ts +120 -0
  183. package/dist/types/src/Filter.d.ts.map +1 -0
  184. package/dist/types/src/Format.d.ts +4 -0
  185. package/dist/types/src/Format.d.ts.map +1 -0
  186. package/dist/types/src/Hypergraph.d.ts +60 -0
  187. package/dist/types/src/Hypergraph.d.ts.map +1 -0
  188. package/dist/types/src/JsonSchema.d.ts +9 -0
  189. package/dist/types/src/JsonSchema.d.ts.map +1 -0
  190. package/dist/types/src/Key.d.ts +1 -0
  191. package/dist/types/src/Key.d.ts.map +1 -1
  192. package/dist/types/src/Obj.d.ts +152 -35
  193. package/dist/types/src/Obj.d.ts.map +1 -1
  194. package/dist/types/src/Order.d.ts +11 -0
  195. package/dist/types/src/Order.d.ts.map +1 -0
  196. package/dist/types/src/Query.d.ts +107 -0
  197. package/dist/types/src/Query.d.ts.map +1 -0
  198. package/dist/types/src/Query.test.d.ts +2 -0
  199. package/dist/types/src/Query.test.d.ts.map +1 -0
  200. package/dist/types/src/QueryResult.d.ts +84 -0
  201. package/dist/types/src/QueryResult.d.ts.map +1 -0
  202. package/dist/types/src/Ref.d.ts +12 -10
  203. package/dist/types/src/Ref.d.ts.map +1 -1
  204. package/dist/types/src/Relation.d.ts +20 -14
  205. package/dist/types/src/Relation.d.ts.map +1 -1
  206. package/dist/types/src/SchemaRegistry.d.ts +73 -0
  207. package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
  208. package/dist/types/src/Tag.d.ts +17 -0
  209. package/dist/types/src/Tag.d.ts.map +1 -0
  210. package/dist/types/src/Type.d.ts +39 -50
  211. package/dist/types/src/Type.d.ts.map +1 -1
  212. package/dist/types/src/index.d.ts +15 -3
  213. package/dist/types/src/index.d.ts.map +1 -1
  214. package/dist/types/src/internal/annotations/annotations.d.ts +179 -0
  215. package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
  216. package/dist/types/src/internal/annotations/annotations.test.d.ts +2 -0
  217. package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
  218. package/dist/types/src/internal/annotations/index.d.ts +3 -0
  219. package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
  220. package/dist/types/src/internal/annotations/util.d.ts +27 -0
  221. package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
  222. package/dist/types/src/internal/entities/entity.d.ts +10 -0
  223. package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
  224. package/dist/types/src/internal/entities/expando.d.ts +16 -0
  225. package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
  226. package/dist/types/src/internal/entities/index.d.ts +6 -0
  227. package/dist/types/src/internal/entities/index.d.ts.map +1 -0
  228. package/dist/types/src/internal/entities/model.d.ts +70 -0
  229. package/dist/types/src/internal/entities/model.d.ts.map +1 -0
  230. package/dist/types/src/internal/entities/object.d.ts +11 -0
  231. package/dist/types/src/internal/entities/object.d.ts.map +1 -0
  232. package/dist/types/src/internal/entities/relation.d.ts +55 -0
  233. package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
  234. package/dist/types/src/internal/entities/util.d.ts +2 -0
  235. package/dist/types/src/internal/entities/util.d.ts.map +1 -0
  236. package/dist/types/src/internal/formats/date.d.ts +63 -0
  237. package/dist/types/src/internal/formats/date.d.ts.map +1 -0
  238. package/dist/types/src/internal/formats/date.test.d.ts +2 -0
  239. package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
  240. package/dist/types/src/internal/formats/format.d.ts +32 -0
  241. package/dist/types/src/internal/formats/format.d.ts.map +1 -0
  242. package/dist/types/src/internal/formats/format.test.d.ts +2 -0
  243. package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
  244. package/dist/types/src/internal/formats/index.d.ts +8 -0
  245. package/dist/types/src/internal/formats/index.d.ts.map +1 -0
  246. package/dist/types/src/internal/formats/number.d.ts +31 -0
  247. package/dist/types/src/internal/formats/number.d.ts.map +1 -0
  248. package/dist/types/src/internal/formats/object.d.ts +35 -0
  249. package/dist/types/src/internal/formats/object.d.ts.map +1 -0
  250. package/dist/types/src/internal/formats/select.d.ts +13 -0
  251. package/dist/types/src/internal/formats/select.d.ts.map +1 -0
  252. package/dist/types/src/internal/formats/string.d.ts +42 -0
  253. package/dist/types/src/internal/formats/string.d.ts.map +1 -0
  254. package/dist/types/src/internal/formats/types.d.ts +72 -0
  255. package/dist/types/src/internal/formats/types.d.ts.map +1 -0
  256. package/dist/types/src/internal/index.d.ts +11 -0
  257. package/dist/types/src/internal/index.d.ts.map +1 -0
  258. package/dist/types/src/internal/json-schema/annotations.d.ts +19 -0
  259. package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
  260. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts +2 -0
  261. package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
  262. package/dist/types/src/internal/json-schema/index.d.ts +5 -0
  263. package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
  264. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
  265. package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
  266. package/dist/types/src/internal/json-schema/json-schema-type.d.ts +250 -0
  267. package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
  268. package/dist/types/src/internal/json-schema/json-schema.d.ts +29 -0
  269. package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
  270. package/dist/types/src/internal/json-schema/json-schema.test.d.ts +2 -0
  271. package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
  272. package/dist/types/src/internal/object/common.d.ts +18 -0
  273. package/dist/types/src/internal/object/common.d.ts.map +1 -0
  274. package/dist/types/src/internal/object/create-object.d.ts +39 -0
  275. package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
  276. package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
  277. package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
  278. package/dist/types/src/internal/object/deleted.d.ts +6 -0
  279. package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
  280. package/dist/types/src/internal/object/ids.d.ts +6 -0
  281. package/dist/types/src/internal/object/ids.d.ts.map +1 -0
  282. package/dist/types/src/internal/object/index.d.ts +8 -0
  283. package/dist/types/src/internal/object/index.d.ts.map +1 -0
  284. package/dist/types/src/internal/object/inspect.d.ts +2 -0
  285. package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
  286. package/dist/types/src/internal/object/json-serializer.d.ts +31 -0
  287. package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
  288. package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
  289. package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
  290. package/dist/types/src/internal/object/schema-validator.d.ts +15 -0
  291. package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
  292. package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
  293. package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
  294. package/dist/types/src/internal/object/typed-object.d.ts +31 -0
  295. package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
  296. package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
  297. package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
  298. package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
  299. package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
  300. package/dist/types/src/internal/proxy/index.d.ts +3 -0
  301. package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
  302. package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
  303. package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
  304. package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
  305. package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
  306. package/dist/types/src/internal/proxy/typed-handler.d.ts +44 -0
  307. package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
  308. package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
  309. package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
  310. package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
  311. package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
  312. package/dist/types/src/internal/ref/index.d.ts +3 -0
  313. package/dist/types/src/internal/ref/index.d.ts.map +1 -0
  314. package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
  315. package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
  316. package/dist/types/src/internal/ref/ref.d.ts +209 -0
  317. package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
  318. package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
  319. package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
  320. package/dist/types/src/internal/schema/compose.d.ts +6 -0
  321. package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
  322. package/dist/types/src/internal/schema/compose.test.d.ts +2 -0
  323. package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
  324. package/dist/types/src/internal/schema/echo-schema.d.ts +168 -0
  325. package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
  326. package/dist/types/src/internal/schema/index.d.ts +5 -0
  327. package/dist/types/src/internal/schema/index.d.ts.map +1 -0
  328. package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
  329. package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
  330. package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
  331. package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
  332. package/dist/types/src/internal/schema/snapshot.d.ts +6 -0
  333. package/dist/types/src/internal/schema/snapshot.d.ts.map +1 -0
  334. package/dist/types/src/internal/types/base.d.ts +37 -0
  335. package/dist/types/src/internal/types/base.d.ts.map +1 -0
  336. package/dist/types/src/internal/types/entity.d.ts +12 -0
  337. package/dist/types/src/internal/types/entity.d.ts.map +1 -0
  338. package/dist/types/src/internal/types/index.d.ts +6 -0
  339. package/dist/types/src/internal/types/index.d.ts.map +1 -0
  340. package/dist/types/src/internal/types/meta.d.ts +40 -0
  341. package/dist/types/src/internal/types/meta.d.ts.map +1 -0
  342. package/dist/types/src/internal/types/typename.d.ts +13 -0
  343. package/dist/types/src/internal/types/typename.d.ts.map +1 -0
  344. package/dist/types/src/internal/types/version.d.ts +15 -0
  345. package/dist/types/src/internal/types/version.d.ts.map +1 -0
  346. package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
  347. package/dist/types/src/testing/index.d.ts +3 -1
  348. package/dist/types/src/testing/index.d.ts.map +1 -1
  349. package/dist/types/src/testing/test-data.d.ts +18 -0
  350. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  351. package/dist/types/src/testing/test-schema.d.ts +407 -0
  352. package/dist/types/src/testing/test-schema.d.ts.map +1 -0
  353. package/dist/types/src/testing/util.d.ts +16 -0
  354. package/dist/types/src/testing/util.d.ts.map +1 -0
  355. package/dist/types/tsconfig.tsbuildinfo +1 -1
  356. package/package.json +164 -33
  357. package/src/Annotation.ts +17 -0
  358. package/src/Database.ts +308 -0
  359. package/src/Entity.ts +51 -0
  360. package/src/Err.ts +18 -0
  361. package/src/Filter.ts +376 -0
  362. package/src/Format.ts +9 -0
  363. package/src/Hypergraph.ts +74 -0
  364. package/src/JsonSchema.ts +16 -0
  365. package/src/Key.ts +3 -0
  366. package/src/Obj.ts +407 -71
  367. package/src/Order.ts +34 -0
  368. package/src/Query.test.ts +346 -0
  369. package/src/Query.ts +279 -0
  370. package/src/QueryResult.ts +109 -0
  371. package/src/Ref.ts +25 -9
  372. package/src/Relation.ts +72 -46
  373. package/src/SchemaRegistry.ts +92 -0
  374. package/src/Tag.ts +40 -0
  375. package/src/Type.ts +98 -84
  376. package/src/index.ts +17 -4
  377. package/src/internal/README.md +87 -0
  378. package/src/internal/annotations/annotations.test.ts +96 -0
  379. package/src/internal/annotations/annotations.ts +488 -0
  380. package/src/internal/annotations/index.ts +6 -0
  381. package/src/internal/annotations/util.ts +72 -0
  382. package/src/internal/entities/entity.ts +109 -0
  383. package/src/internal/entities/expando.ts +23 -0
  384. package/src/internal/entities/index.ts +9 -0
  385. package/src/internal/entities/model.ts +129 -0
  386. package/src/internal/entities/object.ts +45 -0
  387. package/src/internal/entities/relation.ts +155 -0
  388. package/src/internal/entities/util.ts +33 -0
  389. package/src/internal/formats/date.test.ts +56 -0
  390. package/src/internal/formats/date.ts +217 -0
  391. package/src/internal/formats/format.test.ts +77 -0
  392. package/src/internal/formats/format.ts +54 -0
  393. package/src/internal/formats/index.ts +12 -0
  394. package/src/internal/formats/number.ts +89 -0
  395. package/src/internal/formats/object.ts +80 -0
  396. package/src/internal/formats/select.ts +18 -0
  397. package/src/internal/formats/string.ts +81 -0
  398. package/src/internal/formats/types.ts +186 -0
  399. package/src/internal/index.ts +38 -0
  400. package/src/internal/json-schema/annotations.ts +50 -0
  401. package/src/internal/json-schema/effect-schema.test.ts +143 -0
  402. package/src/internal/json-schema/index.ts +8 -0
  403. package/src/internal/json-schema/json-schema-normalize.ts +109 -0
  404. package/src/internal/json-schema/json-schema-type.ts +404 -0
  405. package/src/internal/json-schema/json-schema.test.ts +861 -0
  406. package/src/internal/json-schema/json-schema.ts +528 -0
  407. package/src/internal/object/common.ts +75 -0
  408. package/src/internal/object/create-object.test.ts +116 -0
  409. package/src/internal/object/create-object.ts +95 -0
  410. package/src/internal/object/deleted.ts +19 -0
  411. package/src/internal/object/ids.ts +12 -0
  412. package/src/internal/object/index.ts +11 -0
  413. package/src/internal/object/inspect.ts +46 -0
  414. package/src/internal/object/json-serializer.test.ts +94 -0
  415. package/src/internal/object/json-serializer.ts +230 -0
  416. package/src/internal/object/schema-validator.test.ts +186 -0
  417. package/src/internal/object/schema-validator.ts +244 -0
  418. package/src/internal/object/typed-object.test.ts +34 -0
  419. package/src/internal/object/typed-object.ts +94 -0
  420. package/src/internal/proxy/handler.test.ts +173 -0
  421. package/src/internal/proxy/index.ts +6 -0
  422. package/src/internal/proxy/make-object.ts +113 -0
  423. package/src/internal/proxy/schema.test.ts +137 -0
  424. package/src/internal/proxy/typed-handler.test.ts +102 -0
  425. package/src/internal/proxy/typed-handler.ts +233 -0
  426. package/src/internal/proxy/typed-object.test.ts +105 -0
  427. package/src/internal/ref/index.ts +6 -0
  428. package/src/internal/ref/ref-array.ts +39 -0
  429. package/src/internal/ref/ref.test.ts +101 -0
  430. package/src/internal/ref/ref.ts +525 -0
  431. package/src/internal/schema/compose.test.ts +42 -0
  432. package/src/internal/schema/compose.ts +37 -0
  433. package/src/internal/schema/echo-schema.ts +385 -0
  434. package/src/internal/schema/index.ts +8 -0
  435. package/src/internal/schema/manipulation.ts +92 -0
  436. package/src/internal/schema/persistent-schema.ts +28 -0
  437. package/src/internal/schema/snapshot.ts +25 -0
  438. package/src/internal/types/base.ts +57 -0
  439. package/src/internal/types/entity.ts +23 -0
  440. package/src/internal/types/index.ts +9 -0
  441. package/src/internal/types/meta.ts +76 -0
  442. package/src/internal/types/typename.ts +45 -0
  443. package/src/internal/types/version.ts +20 -0
  444. package/src/testing/api.test.ts +100 -0
  445. package/src/testing/index.ts +3 -1
  446. package/src/testing/test-data.ts +130 -0
  447. package/src/testing/test-schema.ts +224 -0
  448. package/src/testing/util.ts +78 -0
  449. package/dist/lib/browser/chunk-EUA7CM23.mjs +0 -619
  450. package/dist/lib/browser/chunk-EUA7CM23.mjs.map +0 -7
  451. package/dist/lib/node-esm/chunk-IV6BWGHK.mjs +0 -619
  452. package/dist/lib/node-esm/chunk-IV6BWGHK.mjs.map +0 -7
  453. package/dist/types/src/experimental/database.d.ts +0 -8
  454. package/dist/types/src/experimental/database.d.ts.map +0 -1
  455. package/dist/types/src/experimental/index.d.ts +0 -1
  456. package/dist/types/src/experimental/index.d.ts.map +0 -1
  457. package/dist/types/src/experimental/queue.d.ts +0 -8
  458. package/dist/types/src/experimental/queue.d.ts.map +0 -1
  459. package/dist/types/src/experimental/space.d.ts +0 -8
  460. package/dist/types/src/experimental/space.d.ts.map +0 -1
  461. package/dist/types/src/query/dsl.d.ts +0 -218
  462. package/dist/types/src/query/dsl.d.ts.map +0 -1
  463. package/dist/types/src/query/dsl.test.d.ts +0 -2
  464. package/dist/types/src/query/dsl.test.d.ts.map +0 -1
  465. package/dist/types/src/query/index.d.ts +0 -2
  466. package/dist/types/src/query/index.d.ts.map +0 -1
  467. package/dist/types/src/testing/types.d.ts +0 -113
  468. package/dist/types/src/testing/types.d.ts.map +0 -1
  469. package/src/experimental/database.ts +0 -11
  470. package/src/experimental/index.ts +0 -7
  471. package/src/experimental/queue.ts +0 -11
  472. package/src/experimental/space.ts +0 -11
  473. package/src/query/dsl.test.ts +0 -323
  474. package/src/query/dsl.ts +0 -646
  475. package/src/query/index.ts +0 -5
  476. package/src/test/api.test.ts +0 -173
  477. package/src/testing/types.ts +0 -91
  478. /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
@@ -0,0 +1,143 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as JSONSchema from 'effect/JSONSchema';
6
+ import * as Option from 'effect/Option';
7
+ import * as Schema from 'effect/Schema';
8
+ import * as SchemaAST from 'effect/SchemaAST';
9
+ import { expect, test } from 'vitest';
10
+
11
+ import { log } from '@dxos/log';
12
+
13
+ test('json-schema annotations for filter refinement get combined', () => {
14
+ const type = Schema.Number.annotations({
15
+ jsonSchema: { foo: 'foo' },
16
+ }).pipe(Schema.filter(() => true, { jsonSchema: { bar: 'bar' } }));
17
+
18
+ const jsonSchema = JSONSchema.make(type);
19
+ expect(jsonSchema).toEqual({
20
+ $schema: 'http://json-schema.org/draft-07/schema#',
21
+ foo: 'foo',
22
+ bar: 'bar',
23
+ type: 'number',
24
+ });
25
+ });
26
+
27
+ test('json-schema annotations on types do not override the default serialization', () => {
28
+ const type = Schema.Number.annotations({
29
+ jsonSchema: { foo: 'foo' },
30
+ });
31
+
32
+ const jsonSchema = JSONSchema.make(type);
33
+ expect(jsonSchema).toEqual({
34
+ $schema: 'http://json-schema.org/draft-07/schema#',
35
+ foo: 'foo',
36
+ type: 'number',
37
+ });
38
+ });
39
+
40
+ // pass
41
+ test('number with title and description annotations', () => {
42
+ const number = Schema.Number.annotations({
43
+ title: 'My Title',
44
+ description: 'My Description',
45
+ });
46
+
47
+ expect(JSONSchema.make(number)).toEqual({
48
+ $schema: 'http://json-schema.org/draft-07/schema#',
49
+ type: 'number',
50
+ title: 'My Title',
51
+ description: 'My Description',
52
+ });
53
+ });
54
+
55
+ // pass
56
+ test('date with title and description annotations', () => {
57
+ const date = Schema.Date.annotations({
58
+ title: 'My Title',
59
+ description: 'My Description',
60
+ });
61
+
62
+ expect(JSONSchema.make(date)).toEqual({
63
+ $schema: 'http://json-schema.org/draft-07/schema#',
64
+ $defs: {
65
+ DateFromString: {
66
+ description: 'a string to be decoded into a Date',
67
+ type: 'string',
68
+ },
69
+ },
70
+ $ref: '#/$defs/DateFromString',
71
+ });
72
+ });
73
+
74
+ // fail
75
+ test('declare', () => {
76
+ class MyType {}
77
+ const type = Schema.declare<MyType>((x) => x instanceof MyType, {
78
+ jsonSchema: {
79
+ type: 'my-type',
80
+ },
81
+ });
82
+
83
+ expect(JSONSchema.make(type)).toEqual({
84
+ $schema: 'http://json-schema.org/draft-07/schema#',
85
+ type: 'my-type',
86
+ });
87
+
88
+ expect(type.pipe(Schema.is)(new MyType())).toBe(true);
89
+ expect(type.pipe(Schema.is)({})).toBe(false);
90
+
91
+ const withAnnotations = type.annotations({
92
+ title: 'My Title',
93
+ description: 'My Description',
94
+ });
95
+
96
+ expect(JSONSchema.make(withAnnotations)).toEqual({
97
+ $schema: 'http://json-schema.org/draft-07/schema#',
98
+ type: 'my-type',
99
+ title: 'My Title',
100
+ description: 'My Description',
101
+ });
102
+ });
103
+
104
+ // pass
105
+ test('declare with refinement', () => {
106
+ class MyType {}
107
+ const type = Schema.declare<MyType>((x) => x instanceof MyType, {
108
+ jsonSchema: {
109
+ type: 'my-type',
110
+ },
111
+ }).pipe(Schema.filter(() => true, { jsonSchema: {} }));
112
+
113
+ const named = type.annotations({
114
+ title: 'My Title',
115
+ description: 'My Description',
116
+ });
117
+
118
+ expect(JSONSchema.make(named)).toEqual({
119
+ $schema: 'http://json-schema.org/draft-07/schema#',
120
+ type: 'my-type',
121
+ title: 'My Title',
122
+ description: 'My Description',
123
+ });
124
+ });
125
+
126
+ test("default title annotations don't get serialized", () => {
127
+ const schema = Schema.String;
128
+
129
+ expect(SchemaAST.getTitleAnnotation(schema.ast).pipe(Option.getOrUndefined)).toEqual('string');
130
+ expect(SchemaAST.getDescriptionAnnotation(schema.ast).pipe(Option.getOrUndefined)).toEqual('a string');
131
+
132
+ expect(JSONSchema.make(schema)).toEqual({
133
+ $schema: 'http://json-schema.org/draft-07/schema#',
134
+ type: 'string',
135
+ });
136
+ });
137
+
138
+ test.skip('ast comparison', () => {
139
+ log.info('ast', {
140
+ default: Schema.String.ast,
141
+ annotated: Schema.String.annotations({ title: 'Custom title', description: 'Custom description' }).ast,
142
+ });
143
+ });
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './annotations';
6
+ export * from './json-schema-normalize';
7
+ export * from './json-schema-type';
8
+ export * from './json-schema';
@@ -0,0 +1,109 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { JsonSchemaFields, type JsonSchemaType } from './json-schema-type';
6
+
7
+ /**
8
+ * Normalize schema to to draft-07 format.
9
+ * Note: the input type does not necessarily match the {@link JsonSchemaType} type.
10
+ */
11
+ export const normalizeSchema = (schema: JsonSchemaType): JsonSchemaType => {
12
+ const copy = structuredClone(schema);
13
+ go(copy);
14
+ return copy;
15
+ };
16
+
17
+ const go = (schema: JsonSchemaType) => {
18
+ if (typeof schema !== 'object' || schema === null) {
19
+ return;
20
+ }
21
+
22
+ if ((schema as any).exclusiveMaximum === true) {
23
+ schema.exclusiveMaximum = schema.maximum;
24
+ delete (schema as any).exclusiveMaximum;
25
+ } else if ((schema as any).exclusiveMaximum === false) {
26
+ delete (schema as any).exclusiveMaximum;
27
+ }
28
+
29
+ if ((schema as any).exclusiveMinimum === true) {
30
+ schema.exclusiveMinimum = schema.minimum;
31
+ delete (schema as any).exclusiveMinimum;
32
+ } else if ((schema as any).exclusiveMinimum === false) {
33
+ delete (schema as any).exclusiveMinimum;
34
+ }
35
+
36
+ // Delete all properties that are not in the JsonSchemaFields.
37
+ for (const key of Object.keys(schema)) {
38
+ if (!JsonSchemaFields.includes(key)) {
39
+ delete (schema as any)[key];
40
+ }
41
+ }
42
+
43
+ // Recursively normalize the schema.
44
+ // Recursively normalize the schema.
45
+ if (schema.properties) {
46
+ goOnRecord(schema.properties);
47
+ }
48
+ if (schema.patternProperties) {
49
+ goOnRecord(schema.patternProperties);
50
+ }
51
+ if (schema.propertyNames) {
52
+ go(schema.propertyNames);
53
+ }
54
+ if (schema.definitions) {
55
+ goOnRecord(schema.definitions);
56
+ }
57
+ if (schema.items) {
58
+ maybeGoOnArray(schema.items);
59
+ }
60
+ if (schema.additionalItems) {
61
+ maybeGoOnArray(schema.additionalItems);
62
+ }
63
+ if (schema.contains) {
64
+ go(schema.contains);
65
+ }
66
+ if (schema.if) {
67
+ go(schema.if);
68
+ }
69
+ if (schema.then) {
70
+ go(schema.then);
71
+ }
72
+ if (schema.else) {
73
+ go(schema.else);
74
+ }
75
+ if (schema.allOf) {
76
+ maybeGoOnArray(schema.allOf);
77
+ }
78
+ if (schema.anyOf) {
79
+ maybeGoOnArray(schema.anyOf);
80
+ }
81
+ if (schema.oneOf) {
82
+ maybeGoOnArray(schema.oneOf);
83
+ }
84
+ if (schema.not) {
85
+ go(schema.not);
86
+ }
87
+ if (schema.$defs) {
88
+ goOnRecord(schema.$defs);
89
+ }
90
+ if (schema.reference) {
91
+ go(schema.reference.schema);
92
+ }
93
+ };
94
+
95
+ const maybeGoOnArray = (value: any) => {
96
+ if (Array.isArray(value)) {
97
+ for (const item of value) {
98
+ go(item);
99
+ }
100
+ } else if (typeof value === 'object' && value !== null) {
101
+ go(value);
102
+ }
103
+ };
104
+
105
+ const goOnRecord = (record: Record<string, any>) => {
106
+ for (const key of Object.keys(record)) {
107
+ go(record[key]);
108
+ }
109
+ };
@@ -0,0 +1,404 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { JsonPath, type JsonProp } from '@dxos/effect';
8
+
9
+ import { FormatAnnotation, TypeFormat } from '../formats';
10
+ import { EntityKindSchema } from '../types';
11
+
12
+ //
13
+ // JSON Schema
14
+ //
15
+
16
+ // TODO(burdon): Reuse/reconcile with ScalarTypeEnum (handle arrays).
17
+ const SimpleTypes = Schema.Literal('array', 'boolean', 'integer', 'null', 'number', 'object', 'string');
18
+
19
+ const NonNegativeInteger = Schema.Number.pipe(Schema.greaterThanOrEqualTo(0));
20
+
21
+ const StringArray = Schema.Array(Schema.String).pipe(Schema.mutable);
22
+
23
+ const JsonSchemaOrBoolean = Schema.Union(
24
+ Schema.suspend(() => JsonSchemaType),
25
+ Schema.Boolean,
26
+ );
27
+
28
+ /**
29
+ * Go under the `annotations` property.
30
+ */
31
+ export const JsonSchemaEchoAnnotations = Schema.Struct({
32
+ /**
33
+ * Label for this schema.
34
+ * Mapped from {@link LabelAnnotationId}.
35
+ */
36
+ labelProp: Schema.optional(Schema.Union(JsonPath, Schema.Array(JsonPath))),
37
+
38
+ /**
39
+ * Generator function for this schema.
40
+ * Mapped from {@link GeneratorAnnotationId}.
41
+ */
42
+ generator: Schema.optional(Schema.Union(Schema.String, Schema.Tuple(Schema.String, Schema.Number))),
43
+
44
+ /**
45
+ * {@link PropertyMeta} annotations get serialized here.
46
+ */
47
+ meta: Schema.optional(
48
+ Schema.Record({
49
+ key: Schema.String,
50
+ value: Schema.Any,
51
+ }).pipe(Schema.mutable),
52
+ ),
53
+
54
+ /**
55
+ * @deprecated
56
+ */
57
+ // TODO(dmaretskyi): We risk old schema not passing validation due to the extra fields. Remove when we are sure this is safe.
58
+ type: Schema.optional(
59
+ Schema.Struct({
60
+ typename: Schema.String,
61
+ version: Schema.String,
62
+
63
+ // Not used.
64
+ schemaId: Schema.optional(Schema.String),
65
+ }).pipe(Schema.mutable),
66
+ ),
67
+
68
+ /**
69
+ * @deprecated Superseded by `meta`.
70
+ */
71
+ annotations: Schema.optional(
72
+ Schema.Record({
73
+ key: Schema.String,
74
+ value: Schema.Any,
75
+ }).pipe(Schema.mutable),
76
+ ),
77
+ }).pipe(Schema.mutable);
78
+ export type JsonSchemaEchoAnnotations = Schema.Schema.Type<typeof JsonSchemaEchoAnnotations>;
79
+
80
+ /**
81
+ * Describes a schema for the JSON-schema objects stored in ECHO.
82
+ * Contains extensions for ECHO (e.g., references).
83
+ * Ref: https://json-schema.org/draft-07/schema
84
+ */
85
+ // TODO(burdon): Integrate with Effect Serializable?
86
+ // TODO(dmaretskyi): Update to latest draft: https://json-schema.org/draft/2020-12
87
+ const _JsonSchemaType = Schema.Struct({
88
+ /**
89
+ * Identifier for this schema.
90
+ * This schema might be referenced by $ref clause in other schemas.
91
+ */
92
+ // TODO(dmaretskyi): Specify how the ids are generated.
93
+ // TODO(dmaretskyi): For type dxns, should this include the version?
94
+ $id: Schema.optional(Schema.String),
95
+
96
+ /**
97
+ * Schema of this schema.
98
+ * Set to "https://json-schema.org/draft-07/schema".
99
+ */
100
+ $schema: Schema.optional(Schema.String),
101
+
102
+ /**
103
+ * Reference to another schema.
104
+ */
105
+ $ref: Schema.optional(Schema.String),
106
+
107
+ /**
108
+ * Comments are ignored when interpreting the schema.
109
+ */
110
+ $comment: Schema.optional(Schema.String),
111
+
112
+ /**
113
+ * Defines whether this schema is an object schema or a relation schema.
114
+ */
115
+ entityKind: Schema.optional(EntityKindSchema),
116
+
117
+ /**
118
+ * Typename of this schema.
119
+ * Only on schema representing an ECHO object.
120
+ *
121
+ * @example 'example.com/type/MyType'
122
+ */
123
+ typename: Schema.optional(Schema.String),
124
+
125
+ /**
126
+ * Version of this schema.
127
+ * Custom dialect for ECHO.
128
+ */
129
+ version: Schema.optional(Schema.String),
130
+
131
+ /**
132
+ * Target of this relation.
133
+ * Only for relation schemas.
134
+ * The referenced schema must be an object schema.
135
+ */
136
+ relationTarget: Schema.optional(Schema.suspend(() => JsonSchemaType)),
137
+
138
+ /**
139
+ * Source of this relation.
140
+ * Only for relation schemas.
141
+ * The referenced schema must be an object schema.
142
+ */
143
+ relationSource: Schema.optional(Schema.suspend(() => JsonSchemaType)),
144
+
145
+ /**
146
+ * Title of this schema.
147
+ */
148
+ title: Schema.optional(Schema.String),
149
+
150
+ /**
151
+ * Description of this schema.
152
+ */
153
+ description: Schema.optional(Schema.String),
154
+
155
+ /**
156
+ * Whether this schema is read-only.
157
+ */
158
+ readOnly: Schema.optional(Schema.Boolean),
159
+
160
+ /**
161
+ * Whether this schema is write-only.
162
+ */
163
+ writeOnly: Schema.optional(Schema.Boolean),
164
+
165
+ /**
166
+ * Examples of instances of this schema.
167
+ */
168
+ examples: Schema.optional(Schema.Array(Schema.Any)),
169
+
170
+ /**
171
+ * Default value for this schema.
172
+ */
173
+ default: Schema.optional(Schema.Any),
174
+
175
+ /**
176
+ * This schema only matches values that are equal to this value.
177
+ */
178
+ const: Schema.optional(Schema.Any),
179
+
180
+ /**
181
+ * This schema only matches one of the values in this array.
182
+ */
183
+ enum: Schema.optional(Schema.Array(Schema.Any)),
184
+
185
+ /**
186
+ * Base type of the schema.
187
+ */
188
+ type: Schema.optional(Schema.Union(SimpleTypes, Schema.Array(SimpleTypes))),
189
+
190
+ //
191
+ // Numbers.
192
+ //
193
+
194
+ multipleOf: Schema.optional(Schema.Number.pipe(Schema.greaterThan(0))),
195
+ maximum: Schema.optional(Schema.Number),
196
+ exclusiveMaximum: Schema.optional(Schema.Number),
197
+ minimum: Schema.optional(Schema.Number),
198
+ exclusiveMinimum: Schema.optional(Schema.Number),
199
+
200
+ //
201
+ // Strings.
202
+ //
203
+
204
+ maxLength: Schema.optional(NonNegativeInteger),
205
+
206
+ /**
207
+ * Regex pattern for strings.
208
+ */
209
+ pattern: Schema.optional(Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex))),
210
+
211
+ /**
212
+ * Serialized from {@link FormatAnnotationId}.
213
+ */
214
+ format: Schema.optional(Schema.String),
215
+
216
+ //
217
+ // Arrays
218
+ //
219
+
220
+ minLength: Schema.optional(NonNegativeInteger),
221
+ items: Schema.optional(
222
+ Schema.Union(
223
+ Schema.suspend(() => JsonSchemaType),
224
+ Schema.Array(Schema.suspend(() => JsonSchemaType)),
225
+ ),
226
+ ),
227
+ additionalItems: Schema.optional(
228
+ Schema.Union(
229
+ Schema.suspend(() => JsonSchemaType),
230
+ Schema.Boolean,
231
+ ),
232
+ ),
233
+ maxItems: Schema.optional(NonNegativeInteger),
234
+ minItems: Schema.optional(NonNegativeInteger),
235
+ uniqueItems: Schema.optional(Schema.Boolean),
236
+ contains: Schema.optional(Schema.suspend(() => JsonSchemaType)),
237
+
238
+ //
239
+ // Objects
240
+ //
241
+
242
+ maxProperties: Schema.optional(NonNegativeInteger),
243
+ minProperties: Schema.optional(NonNegativeInteger),
244
+ required: Schema.optional(StringArray),
245
+
246
+ /**
247
+ * Non-standard JSON Schema extension.
248
+ * Defines the order of properties in the object.
249
+ * The unmentioned properties are placed at the end.
250
+ *
251
+ * Related: https://github.com/json-schema/json-schema/issues/119
252
+ */
253
+ propertyOrder: Schema.optional(StringArray),
254
+
255
+ additionalProperties: Schema.optional(JsonSchemaOrBoolean),
256
+ properties: Schema.optional(
257
+ Schema.Record({
258
+ key: Schema.String,
259
+ value: Schema.suspend(() => JsonSchemaType),
260
+ }).pipe(Schema.mutable),
261
+ ),
262
+ patternProperties: Schema.optional(
263
+ Schema.Record({
264
+ key: Schema.String,
265
+ value: Schema.suspend(() => JsonSchemaType),
266
+ }).pipe(Schema.mutable),
267
+ ),
268
+ propertyNames: Schema.optional(Schema.suspend(() => JsonSchemaType)),
269
+
270
+ definitions: Schema.optional(
271
+ Schema.mutable(
272
+ Schema.Record({
273
+ key: Schema.String,
274
+ value: Schema.suspend(() => JsonSchemaType),
275
+ }),
276
+ ),
277
+ ),
278
+ dependencies: Schema.optional(
279
+ Schema.Record({
280
+ key: Schema.String,
281
+ value: Schema.suspend(() => Schema.Union(Schema.String, StringArray, JsonSchemaType)).annotations({
282
+ identifier: 'dependency',
283
+ description: 'Dependency',
284
+ }),
285
+ }),
286
+ ),
287
+
288
+ contentMediaType: Schema.optional(Schema.String),
289
+ contentEncoding: Schema.optional(Schema.String),
290
+
291
+ if: Schema.optional(Schema.suspend(() => JsonSchemaType)),
292
+ then: Schema.optional(Schema.suspend(() => JsonSchemaType)),
293
+ else: Schema.optional(Schema.suspend(() => JsonSchemaType)),
294
+ allOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
295
+ anyOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
296
+ oneOf: Schema.optional(Schema.Array(Schema.suspend(() => JsonSchemaType))),
297
+ not: Schema.optional(Schema.suspend(() => JsonSchemaType)),
298
+ $defs: Schema.optional(
299
+ Schema.mutable(
300
+ Schema.Record({
301
+ key: Schema.String,
302
+ value: Schema.suspend(() => JsonSchemaType),
303
+ }),
304
+ ),
305
+ ),
306
+
307
+ //
308
+ // ECHO extensions.
309
+ //
310
+
311
+ currency: Schema.optional(Schema.String),
312
+
313
+ reference: Schema.optional(
314
+ Schema.mutable(
315
+ Schema.Struct({
316
+ schema: Schema.suspend(() => JsonSchemaType),
317
+ schemaVersion: Schema.optional(Schema.String),
318
+ schemaObject: Schema.optional(Schema.String),
319
+ }),
320
+ ),
321
+ ),
322
+
323
+ /**
324
+ * ECHO-specific annotations.
325
+ */
326
+ // TODO(dmaretskyi): Since we are adding a lot of new extensions to the JSON Schema, it is safer to namespace them here.
327
+ annotations: Schema.optional(Schema.mutable(JsonSchemaEchoAnnotations)),
328
+
329
+ /**
330
+ * @deprecated Use `annotations` instead.
331
+ */
332
+ echo: Schema.optional(Schema.mutable(JsonSchemaEchoAnnotations)),
333
+ }).annotations({ identifier: 'jsonSchema', description: 'JSON Schema' });
334
+
335
+ export const JsonSchemaFields = Object.keys(_JsonSchemaType.fields);
336
+
337
+ /**
338
+ * https://json-schema.org/draft-07/schema
339
+ */
340
+ // TODO(burdon): Reconcile with @effect/Schema/JSONSchema
341
+ export interface JsonSchemaType extends Schema.Schema.Type<Schema.mutable<typeof _JsonSchemaType>> {}
342
+
343
+ export const JsonSchemaType: Schema.Schema<JsonSchemaType> = _JsonSchemaType.pipe(Schema.mutable);
344
+
345
+ // TODO(burdon): Factor out JSON schema utils.
346
+
347
+ export const getSchemaProperty = (schema: JsonSchemaType, property: JsonProp): JsonSchemaType | undefined => {
348
+ return schema.properties?.[property];
349
+ };
350
+
351
+ // TODO(burdon): Properties should be ordered.
352
+ export const setSchemaProperty = (schema: JsonSchemaType, property: JsonProp, value: JsonSchemaType) => {
353
+ schema.properties ??= {};
354
+ schema.properties[property] = value;
355
+ return schema;
356
+ };
357
+
358
+ /**
359
+ * @internal
360
+ */
361
+ export const ECHO_ANNOTATIONS_NS_DEPRECATED_KEY: keyof JsonSchemaType = 'echo';
362
+
363
+ /**
364
+ * @internal
365
+ */
366
+ export const ECHO_ANNOTATIONS_NS_KEY = 'annotations';
367
+
368
+ /**
369
+ * @internal
370
+ * @returns ECHO annotations namespace object in its normalized form.
371
+ *
372
+ * `meta` holds PropertyMeta annotations.
373
+ * `annotations` holds other annotations.
374
+ */
375
+ export const getNormalizedEchoAnnotations = (obj: JsonSchemaType): JsonSchemaEchoAnnotations | undefined => {
376
+ if (obj[ECHO_ANNOTATIONS_NS_KEY] != null && obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
377
+ return normalizeEchoAnnotations({
378
+ ...obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY],
379
+ ...obj[ECHO_ANNOTATIONS_NS_KEY],
380
+ });
381
+ } else if (obj[ECHO_ANNOTATIONS_NS_KEY] != null) {
382
+ return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_KEY]!);
383
+ } else if (obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY] != null) {
384
+ return normalizeEchoAnnotations(obj[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY]!);
385
+ } else {
386
+ return undefined;
387
+ }
388
+ };
389
+
390
+ const normalizeEchoAnnotations = (obj: JsonSchemaEchoAnnotations): JsonSchemaEchoAnnotations => {
391
+ if (!obj.annotations) {
392
+ return obj;
393
+ } else {
394
+ const res = {
395
+ ...obj,
396
+ meta: {
397
+ ...obj.annotations,
398
+ ...(obj.meta ?? {}),
399
+ },
400
+ };
401
+ delete res.annotations;
402
+ return res;
403
+ }
404
+ };