@dxos/echo 0.8.4-main.3a94e84 → 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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Type.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema$ from 'effect/Schema';\n\nimport { type EncodedReference } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { type DXN } from '@dxos/keys';\nimport { type ToMutable } from '@dxos/util';\n\nimport type * as Entity$ from './Entity';\nimport {\n type ATTR_RELATION_SOURCE,\n type ATTR_RELATION_TARGET,\n EchoObjectSchema,\n EchoRelationSchema,\n type EchoRelationSchemaOptions,\n EchoSchema,\n Expando as Expando$,\n type ExpandoEncoded,\n PersistentSchema,\n type PersistentSchemaEncoded,\n Ref as Ref$,\n type RefFn,\n type RefSchema,\n type TypeAnnotation,\n type TypeMeta,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n getTypeAnnotation,\n isMutable as isMutable$,\n toEffectSchema,\n toJsonSchema,\n} from './internal';\nimport type * as Relation$ from './Relation';\n\n// TODO(burdon): Remove toEffectSchema, toJsonSchema (moved to JsonSchema export).\nexport { toEffectSchema, toJsonSchema };\n\n/**\n * Returns all properties of an object or relation except for the id and kind.\n */\nexport type Properties<T = any> = Omit<T, 'id' | Entity$.KindId | Relation$.Source | Relation$.Target>;\n\n//\n// Entity\n//\n\nexport namespace Entity {\n /**\n * Type.Obj.Any | Type.Relation.Any.\n */\n export type Any = Obj.Any | Relation.Any;\n}\n\n//\n// Obj\n//\n\ninterface ObjJsonProps {\n id: string;\n}\n\n/**\n * Return type of the `Obj` schema constructor.\n *\n * This typedef avoids `TS4023` error (name from external module cannot be used named).\n * See Effect's note on interface types.\n */\nexport interface obj<Self extends Schema$.Schema.Any>\n extends TypeMeta,\n Schema$.AnnotableClass<\n obj<Self>,\n Entity$.OfKind<typeof Entity$.Kind.Object> & ToMutable<Schema$.Schema.Type<Self>>,\n Schema$.Simplify<ObjJsonProps & ToMutable<Schema$.Schema.Encoded<Self>>>,\n Schema$.Schema.Context<Self>\n > {}\n\n/**\n * Object schema.\n */\nexport const Obj: {\n (opts: TypeMeta): <Self extends Schema$.Schema.Any>(self: Self) => obj<Self>;\n} = EchoObjectSchema as any;\n\n/**\n * Object schema type definitions.\n */\nexport declare namespace Obj {\n /**\n * Type that represents an arbitrary schema type of an object.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n // TODO(burdon): This erases the ECHO type info (e.g., id, typename).\n export type Any = obj<Schema$.Schema.AnyNoContext>;\n}\n\n//\n// Expando\n//\n\nexport const Expando: obj<Schema$.Schema<Expando$, ExpandoEncoded>> = Expando$ as any;\nexport type Expando = obj<Schema$.Schema<Expando$, ExpandoEncoded>>;\n\n//\n// Schema\n//\n\nexport const PersistentType: obj<Schema$.Schema<PersistentSchema, PersistentSchemaEncoded>> = PersistentSchema as any;\nexport type PersistentType = obj<Schema$.Schema<PersistentSchema, PersistentSchemaEncoded>>;\n\nexport { EchoSchema as RuntimeType };\n\n//\n// Relation\n//\n\ninterface RelationJsonProps {\n id: string;\n [ATTR_RELATION_SOURCE]: string;\n [ATTR_RELATION_TARGET]: string;\n}\n\n/**\n * Return type of the `Relation` schema constructor.\n *\n * This typedef avoids `TS4023` error (name from external module cannot be used named).\n * See Effect's note on interface types.\n */\nexport interface relation<\n Self extends Schema$.Schema.Any,\n SourceSchema extends Schema$.Schema.Any,\n TargetSchema extends Schema$.Schema.Any,\n> extends TypeMeta,\n Schema$.AnnotableClass<\n relation<Self, SourceSchema, TargetSchema>,\n Entity$.OfKind<typeof Entity$.Kind.Relation> &\n Relation.Endpoints<Schema$.Schema.Type<SourceSchema>, Schema$.Schema.Type<TargetSchema>> &\n ToMutable<Schema$.Schema.Type<Self>>,\n Schema$.Simplify<RelationJsonProps & ToMutable<Schema$.Schema.Encoded<Self>>>,\n Schema$.Schema.Context<Self>\n > {}\n\n/**\n * Relation schema.\n */\n// TODO(dmaretskyi): I have to redefine the type here so that the definition uses symbols from @dxos/echo/Relation.\n// TODO(burdon): Remove?\nexport const Relation: {\n <Source extends Schema$.Schema.AnyNoContext, Target extends Schema$.Schema.AnyNoContext>(\n opts: EchoRelationSchemaOptions<Source, Target>,\n ): <Self extends Schema$.Schema.Any>(self: Self) => relation<Self, Source, Target>;\n} = EchoRelationSchema as any;\n\n/**\n * Relation schema type definitions.\n */\nexport namespace Relation {\n /**\n * Type that represents an arbitrary schema type of a relation.\n * NOTE: This is not an instance type.\n */\n // TODO(dmaretskyi): If schema was covariant, we could specify props in here, like `id: ObjectId`.\n export type Any = Schema$.Schema.AnyNoContext;\n\n /**\n * Get relation source type.\n */\n export type Source<A> = A extends Relation.Endpoints<infer S, infer _T> ? S : never;\n\n /**\n * Get relation target type.\n */\n export type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;\n\n export type Endpoints<Source, Target> = {\n [Relation$.Source]: Source;\n [Relation$.Target]: Target;\n };\n}\n\n//\n// Ref\n// TODO(burdon): Reconcile Type.Ref with Ref.Ref.\n//\n\n/**\n * Return type of the `Ref` schema constructor.\n *\n * This typedef avoids `TS4023` error (name from external module cannot be used named).\n * See Effect's note on interface types.\n */\nexport interface ref<TargetSchema extends Schema$.Schema.Any> extends RefSchema<Schema$.Schema.Type<TargetSchema>> {}\n\n/**\n * Ref schema.\n */\nexport const Ref: RefFn = Ref$;\n\nexport interface Ref<T> extends Schema$.SchemaClass<Ref$<T>, EncodedReference> {}\n\nexport namespace Ref {\n /**\n * Type that represents an arbitrary schema type of a reference.\n * NOTE: This is not an instance type.\n */\n export type Any = Schema$.Schema<Ref$<any>, EncodedReference>;\n}\n\n/**\n * Gets the full DXN of the schema.\n * Will include the version if it's a `type` DXN.\n * @example \"dxn:example.com/type/Person:0.1.0\"\n * @example \"dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX\"\n */\nexport const getDXN = (schema: Entity.Any): DXN | undefined => {\n return getSchemaDXN(schema);\n};\n\n/**\n * @param schema - Schema to get the typename from.\n * @returns The typename of the schema. Example: `example.com/type/Person`.\n */\nexport const getTypename = (schema: Entity.Any): string => {\n const typename = getSchemaTypename(schema);\n invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version of the schema.\n * @example 0.1.0\n */\nexport const getVersion = (schema: Entity.Any): string => {\n const version = getSchemaVersion(schema);\n invariant(typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n return version;\n};\n\n/**\n * @returns True if the schema is mutable.\n */\nexport const isMutable = isMutable$;\n\n/**\n * ECHO type metadata.\n */\nexport type Meta = TypeAnnotation;\n\n/**\n * Gets the meta data of the schema.\n */\nexport const getMeta = (schema: Entity.Any): Meta | undefined => {\n return getTypeAnnotation(schema);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;iBAAAA;EAAA;;aAAAC;EAAA;;;;;;mBAAAC;EAAA;;;AAOA,SAASC,iBAAiB;A;AA4EnB,IAAMC,MAETC;AAmBG,IAAMC,WAAyDC;AAO/D,IAAMC,iBAAiFC;AAwCvF,IAAMC,WAITC;AA6CG,IAAMC,OAAaC;AAkBnB,IAAMC,SAAS,CAACC,WAAAA;AACrB,SAAOC,aAAaD,MAAAA;AACtB;AAMO,IAAME,cAAc,CAACF,WAAAA;AAC1B,QAAMG,WAAWC,kBAAkBJ,MAAAA;AACnCK,YAAU,OAAOF,aAAa,YAAY,CAACA,SAASG,WAAW,MAAA,GAAS,oBAAA;;;;;;;;;AACxE,SAAOH;AACT;AAMO,IAAMI,aAAa,CAACP,WAAAA;AACzB,QAAMQ,UAAUC,iBAAiBT,MAAAA;AACjCK,YAAU,OAAOG,YAAY,YAAYA,QAAQE,MAAM,iBAAA,GAAoB,mBAAA;;;;;;;;;AAC3E,SAAOF;AACT;AAKO,IAAMG,aAAYC;AAUlB,IAAMC,UAAU,CAACb,WAAAA;AACtB,SAAOc,kBAAkBd,MAAAA;AAC3B;",
6
+ "names": ["Expando", "Ref", "isMutable", "invariant", "Obj", "EchoObjectSchema", "Expando", "Expando$", "PersistentType", "PersistentSchema", "Relation", "EchoRelationSchema", "Ref", "Ref$", "getDXN", "schema", "getSchemaDXN", "getTypename", "typename", "getSchemaTypename", "invariant", "startsWith", "getVersion", "version", "getSchemaVersion", "match", "isMutable", "isMutable$", "getMeta", "getTypeAnnotation"]
7
+ }
@@ -0,0 +1,403 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ createAnnotationHelper
4
+ } from "./chunk-NHYOREKX.mjs";
5
+
6
+ // src/internal/formats/types.ts
7
+ import * as Function from "effect/Function";
8
+ import * as Option from "effect/Option";
9
+ import * as SchemaAST from "effect/SchemaAST";
10
+ var TypeEnum = /* @__PURE__ */ (function(TypeEnum2) {
11
+ TypeEnum2["Array"] = "array";
12
+ TypeEnum2["Object"] = "object";
13
+ TypeEnum2["String"] = "string";
14
+ TypeEnum2["Number"] = "number";
15
+ TypeEnum2["Boolean"] = "boolean";
16
+ TypeEnum2["Ref"] = "ref";
17
+ return TypeEnum2;
18
+ })({});
19
+ var getTypeEnum = (property) => {
20
+ switch (property.type) {
21
+ case "array":
22
+ return "array";
23
+ case "object":
24
+ return "object";
25
+ case "string":
26
+ return "string";
27
+ case "number":
28
+ return "number";
29
+ case "boolean":
30
+ return "boolean";
31
+ default:
32
+ return void 0;
33
+ }
34
+ };
35
+ var FormatAnnotationId = Symbol.for("@dxos/schema/annotation/Format");
36
+ var FormatAnnotation = createAnnotationHelper(FormatAnnotationId);
37
+ var getFormatAnnotation = (node) => Function.pipe(SchemaAST.getAnnotation(FormatAnnotationId)(node), Option.getOrUndefined);
38
+ var TypeFormat = /* @__PURE__ */ (function(TypeFormat2) {
39
+ TypeFormat2["None"] = "none";
40
+ TypeFormat2["String"] = "string";
41
+ TypeFormat2["Number"] = "number";
42
+ TypeFormat2["Boolean"] = "boolean";
43
+ TypeFormat2["Ref"] = "ref";
44
+ TypeFormat2["DID"] = "did";
45
+ TypeFormat2["DXN"] = "dxn";
46
+ TypeFormat2["Email"] = "email";
47
+ TypeFormat2["Formula"] = "formula";
48
+ TypeFormat2["Hostname"] = "hostname";
49
+ TypeFormat2["JSON"] = "json";
50
+ TypeFormat2["Markdown"] = "markdown";
51
+ TypeFormat2["Regex"] = "regex";
52
+ TypeFormat2["SingleSelect"] = "single-select";
53
+ TypeFormat2["Text"] = "text";
54
+ TypeFormat2["MultiSelect"] = "multi-select";
55
+ TypeFormat2["URL"] = "url";
56
+ TypeFormat2["UUID"] = "uuid";
57
+ TypeFormat2["Currency"] = "currency";
58
+ TypeFormat2["Integer"] = "integer";
59
+ TypeFormat2["Percent"] = "percent";
60
+ TypeFormat2["Timestamp"] = "timestamp";
61
+ TypeFormat2["DateTime"] = "date-time";
62
+ TypeFormat2["Date"] = "date";
63
+ TypeFormat2["Time"] = "time";
64
+ TypeFormat2["Duration"] = "duration";
65
+ TypeFormat2["GeoPoint"] = "lnglat";
66
+ return TypeFormat2;
67
+ })({});
68
+ var FormatEnums = Object.values(TypeFormat).sort();
69
+ var PropertyKind = {
70
+ type: TypeEnum,
71
+ format: TypeFormat
72
+ };
73
+ var typeToFormat = {
74
+ ["string"]: "string",
75
+ ["number"]: "number",
76
+ ["boolean"]: "boolean"
77
+ };
78
+ var formatToType = {
79
+ ["none"]: void 0,
80
+ ["string"]: "string",
81
+ ["number"]: "number",
82
+ ["boolean"]: "boolean",
83
+ ["ref"]: "ref",
84
+ ["did"]: "string",
85
+ ["dxn"]: "string",
86
+ ["email"]: "string",
87
+ ["formula"]: "string",
88
+ ["hostname"]: "string",
89
+ ["json"]: "string",
90
+ ["markdown"]: "string",
91
+ ["regex"]: "string",
92
+ ["url"]: "string",
93
+ ["uuid"]: "string",
94
+ ["single-select"]: "string",
95
+ ["text"]: "string",
96
+ ["multi-select"]: "object",
97
+ ["date"]: "string",
98
+ ["date-time"]: "string",
99
+ ["duration"]: "string",
100
+ ["time"]: "string",
101
+ ["currency"]: "number",
102
+ ["integer"]: "number",
103
+ ["percent"]: "number",
104
+ ["timestamp"]: "number",
105
+ ["lnglat"]: "array"
106
+ };
107
+ var OptionsAnnotationId = Symbol.for("@dxos/schema/annotation/Options");
108
+ var OptionsAnnotation = createAnnotationHelper(OptionsAnnotationId);
109
+ var getOptionsAnnotation = (node) => Function.pipe(SchemaAST.getAnnotation(OptionsAnnotationId)(node), Option.getOrUndefined);
110
+
111
+ // src/internal/formats/number.ts
112
+ import * as Schema from "effect/Schema";
113
+ var encodeMultipleOf = (divisor) => 1 / Math.pow(10, divisor);
114
+ var encodeMultiple = (divisor) => (self) => divisor === void 0 || divisor === 0 ? self : self.pipe(Schema.multipleOf(encodeMultipleOf(divisor)));
115
+ var DecimalPrecision = Schema.transform(Schema.Number, Schema.Number, {
116
+ strict: true,
117
+ encode: (value) => encodeMultipleOf(value),
118
+ decode: (value) => Math.log10(1 / value)
119
+ }).annotations({
120
+ title: "Number of digits"
121
+ });
122
+ var CurrencyAnnotationId = Symbol.for("@dxos/schema/annotation/Currency");
123
+ var Currency = ({ decimals, code } = {
124
+ decimals: 2
125
+ }) => Schema.Number.pipe(encodeMultiple(decimals), FormatAnnotation.set(TypeFormat.Currency), Schema.annotations({
126
+ title: "Currency",
127
+ description: "Currency value",
128
+ ...code ? {
129
+ [CurrencyAnnotationId]: code.toUpperCase()
130
+ } : {}
131
+ }));
132
+ var Integer = () => Schema.Number.pipe(Schema.int(), FormatAnnotation.set(TypeFormat.Integer), Schema.annotations({
133
+ title: "Integer",
134
+ description: "Integer value"
135
+ }));
136
+ var Percent = ({ decimals } = {
137
+ decimals: 2
138
+ }) => Schema.Number.pipe(encodeMultiple(decimals), FormatAnnotation.set(TypeFormat.Percent), Schema.annotations({
139
+ title: "Percent",
140
+ description: "Percentage value"
141
+ }));
142
+ var Timestamp = Schema.Number.pipe(FormatAnnotation.set(TypeFormat.Timestamp), Schema.annotations({
143
+ title: "Timestamp",
144
+ description: "Unix timestamp"
145
+ }));
146
+
147
+ // src/internal/formats/object.ts
148
+ import * as Schema2 from "effect/Schema";
149
+ import { clamp as clamp2 } from "@dxos/util";
150
+ var GeoPoint = Schema2.Tuple(Schema2.Number.pipe(Schema2.annotations({
151
+ title: "Longitude"
152
+ }), Schema2.clamp(-180, 180), Schema2.multipleOf(1e-6)), Schema2.Number.pipe(Schema2.annotations({
153
+ title: "Latitude"
154
+ }), Schema2.clamp(-90, 90), Schema2.multipleOf(1e-6)), Schema2.optionalElement(Schema2.Number).annotations({
155
+ title: "Height ASL (m)"
156
+ })).pipe(FormatAnnotation.set(TypeFormat.GeoPoint), Schema2.annotations({
157
+ title: "GeoPoint",
158
+ description: "GeoJSON Position"
159
+ }));
160
+ (function(GeoLocation2) {
161
+ GeoLocation2.toGeoPoint = ({ longitude, latitude, height }) => {
162
+ const clampedLongitude = clamp2(longitude, -180, 180);
163
+ const clampedLatitude = clamp2(latitude, -90, 90);
164
+ return height !== void 0 ? [
165
+ clampedLongitude,
166
+ clampedLatitude,
167
+ height
168
+ ] : [
169
+ clampedLongitude,
170
+ clampedLatitude
171
+ ];
172
+ };
173
+ GeoLocation2.fromGeoPoint = (geoPoint) => {
174
+ if (!geoPoint) {
175
+ return {
176
+ longitude: 0,
177
+ latitude: 0
178
+ };
179
+ }
180
+ const result = {
181
+ longitude: geoPoint[0],
182
+ latitude: geoPoint[1]
183
+ };
184
+ if (geoPoint[2] !== void 0) {
185
+ result.height = geoPoint[2];
186
+ }
187
+ return result;
188
+ };
189
+ })(GeoLocation || (GeoLocation = {}));
190
+ var GeoLocation;
191
+
192
+ // src/internal/formats/string.ts
193
+ import * as Schema3 from "effect/Schema";
194
+ import * as SchemaAST2 from "effect/SchemaAST";
195
+ var Email = Schema3.String.pipe(Schema3.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/), FormatAnnotation.set(TypeFormat.Email), Schema3.annotations({
196
+ title: "Email",
197
+ description: "Email address"
198
+ }));
199
+ var Formula = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.Formula));
200
+ var Hostname = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.Hostname));
201
+ var JSON = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.JSON));
202
+ var Markdown = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.Markdown));
203
+ var Regex = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.Regex));
204
+ var Text = Schema3.String.pipe(FormatAnnotation.set(TypeFormat.Text));
205
+ var URL = Schema3.String.pipe(Schema3.pattern(/^(\w+?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i), FormatAnnotation.set(TypeFormat.URL), Schema3.annotations({
206
+ title: "URL",
207
+ description: "URL"
208
+ }));
209
+ var UUID2 = Schema3.UUID.pipe(FormatAnnotation.set(TypeFormat.UUID), Schema3.annotations({
210
+ [SchemaAST2.ExamplesAnnotationId]: [
211
+ "3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a"
212
+ ]
213
+ }));
214
+
215
+ // src/internal/formats/format.ts
216
+ import * as Schema5 from "effect/Schema";
217
+ import * as Keys from "@dxos/keys";
218
+
219
+ // src/internal/formats/date.ts
220
+ import * as Schema4 from "effect/Schema";
221
+ import * as SchemaAST3 from "effect/SchemaAST";
222
+ var SimpleDate = Schema4.Struct({
223
+ year: Schema4.Number.pipe(Schema4.between(1900, 9999)),
224
+ month: Schema4.Number.pipe(Schema4.between(1, 12)),
225
+ day: Schema4.Number.pipe(Schema4.between(1, 31))
226
+ });
227
+ var SimpleTime = Schema4.Struct({
228
+ hours: Schema4.Number.pipe(Schema4.between(0, 23)),
229
+ minutes: Schema4.Number.pipe(Schema4.between(0, 59)),
230
+ seconds: Schema4.Number.pipe(Schema4.between(0, 59))
231
+ });
232
+ var SimpleDateTime = Schema4.extend(SimpleDate, SimpleTime);
233
+ var DateOnly = (
234
+ /* Schema.transformOrFail(Schema.String, SimpleDate, {
235
+ strict: true,
236
+ decode: (str, _, ast) => {
237
+ if (!isValidDateFormat(str)) {
238
+ return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected YYYY-MM-DD format'));
239
+ }
240
+ if (!isValidDate(str)) {
241
+ return ParseResult.fail(new ParseResult.Type(ast, str, 'Invalid date'));
242
+ }
243
+
244
+ const [year, month, day] = str.split('-').map(Number);
245
+ return ParseResult.succeed({ year, month, day });
246
+ },
247
+ encode: (date) => {
248
+ return ParseResult.succeed(
249
+ [
250
+ date.year.toString().padStart(4, '0'),
251
+ date.month.toString().padStart(2, '0'),
252
+ date.day.toString().padStart(2, '0'),
253
+ ].join('-'),
254
+ );
255
+ },
256
+ }) */
257
+ Schema4.String.pipe(FormatAnnotation.set(TypeFormat.Date), Schema4.annotations({
258
+ title: "Date",
259
+ description: "Valid date in ISO format"
260
+ }))
261
+ );
262
+ var TimeOnly = (
263
+ /* Schema.transformOrFail(Schema.String, SimpleTime, {
264
+ strict: true,
265
+ decode: (str, _, ast) => {
266
+ if (!isValidTimeFormat(str)) {
267
+ return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));
268
+ }
269
+
270
+ const [hours, minutes, seconds] = str.split(':').map(Number);
271
+ return ParseResult.succeed({ hours, minutes, seconds });
272
+ },
273
+ encode: (time) => {
274
+ return ParseResult.succeed(
275
+ [
276
+ time.hours.toString().padStart(2, '0'),
277
+ time.minutes.toString().padStart(2, '0'),
278
+ time.seconds.toString().padStart(2, '0'),
279
+ ].join(':'),
280
+ );
281
+ },
282
+ }) */
283
+ Schema4.String.pipe(FormatAnnotation.set(TypeFormat.Time), Schema4.annotations({
284
+ title: "Time",
285
+ description: "Valid time in ISO format"
286
+ }))
287
+ );
288
+ var DateTime = (
289
+ /* Schema.transformOrFail(Schema.String, SimpleDateTime, {
290
+ strict: false,
291
+ decode: (str, _, ast) => {
292
+ const [date, time] = str.split('T');
293
+ if (!isValidDateFormat(date)) {
294
+ return ParseResult.fail(new ParseResult.Type(ast, date, 'Expected YYYY-MM-DD format'));
295
+ }
296
+ if (!isValidDate(date)) {
297
+ return ParseResult.fail(new ParseResult.Type(ast, date, 'Invalid date'));
298
+ }
299
+ if (!isValidTimeFormat(time)) {
300
+ return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));
301
+ }
302
+
303
+ const [year, month, day] = date.split('-').map(Number);
304
+ const [hours, minutes, seconds] = time.split(':').map(Number);
305
+ return ParseResult.succeed({ year, month, day, hours, minutes, seconds });
306
+ },
307
+ encode: (datetime) => {
308
+ return ParseResult.succeed(
309
+ [
310
+ [
311
+ datetime.year.toString().padStart(4, '0'),
312
+ datetime.month.toString().padStart(2, '0'),
313
+ datetime.day.toString().padStart(2, '0'),
314
+ ].join('-'),
315
+ [
316
+ datetime.hours.toString().padStart(2, '0'),
317
+ datetime.minutes.toString().padStart(2, '0'),
318
+ datetime.seconds.toString().padStart(2, '0'),
319
+ ].join(':'),
320
+ ].join('T'),
321
+ );
322
+ },
323
+ }) */
324
+ Schema4.String.pipe(FormatAnnotation.set(TypeFormat.DateTime), Schema4.annotations({
325
+ title: "DateTime",
326
+ description: "Valid date and time in ISO format"
327
+ }))
328
+ );
329
+ var Duration = Schema4.String.pipe(FormatAnnotation.set(TypeFormat.Duration), Schema4.annotations({
330
+ title: "Duration",
331
+ description: "Duration in ISO 8601 format",
332
+ [SchemaAST3.ExamplesAnnotationId]: [
333
+ "1h",
334
+ "3D"
335
+ ]
336
+ }));
337
+
338
+ // src/internal/formats/format.ts
339
+ (function(Format2) {
340
+ Format2.TypeFormat = TypeFormat;
341
+ Format2.DXN = Keys.DXN.Schema;
342
+ Format2.Email = Email;
343
+ Format2.Formula = Formula;
344
+ Format2.Hostname = Hostname;
345
+ Format2.JSON = JSON;
346
+ Format2.Markdown = Markdown;
347
+ Format2.Regex = Regex;
348
+ Format2.URL = URL;
349
+ Format2.UUID = Schema5.UUID;
350
+ Format2.Currency = Currency;
351
+ Format2.Integer = Integer;
352
+ Format2.Percent = Percent;
353
+ Format2.Timestamp = Timestamp;
354
+ Format2.Date = DateOnly;
355
+ Format2.DateTime = DateTime;
356
+ Format2.Duration = Duration;
357
+ Format2.Time = TimeOnly;
358
+ Format2.GeoPoint = GeoPoint;
359
+ })(Format || (Format = {}));
360
+ var Format;
361
+
362
+ // src/internal/formats/select.ts
363
+ import * as Schema6 from "effect/Schema";
364
+ var SelectOption = Schema6.Struct({
365
+ /** Stable identifier for the option. */
366
+ id: Schema6.NonEmptyString,
367
+ title: Schema6.String,
368
+ /** Color palette used for visual styling. */
369
+ color: Schema6.String
370
+ }).pipe(Schema6.mutable);
371
+
372
+ export {
373
+ TypeEnum,
374
+ getTypeEnum,
375
+ FormatAnnotationId,
376
+ FormatAnnotation,
377
+ getFormatAnnotation,
378
+ TypeFormat,
379
+ FormatEnums,
380
+ PropertyKind,
381
+ typeToFormat,
382
+ formatToType,
383
+ OptionsAnnotationId,
384
+ OptionsAnnotation,
385
+ getOptionsAnnotation,
386
+ DecimalPrecision,
387
+ CurrencyAnnotationId,
388
+ Currency,
389
+ GeoPoint,
390
+ GeoLocation,
391
+ Email,
392
+ Formula,
393
+ Hostname,
394
+ JSON,
395
+ Markdown,
396
+ Regex,
397
+ Text,
398
+ URL,
399
+ UUID2 as UUID,
400
+ Format,
401
+ SelectOption
402
+ };
403
+ //# sourceMappingURL=chunk-HLUDHPFO.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/formats/types.ts", "../../../src/internal/formats/number.ts", "../../../src/internal/formats/object.ts", "../../../src/internal/formats/string.ts", "../../../src/internal/formats/format.ts", "../../../src/internal/formats/date.ts", "../../../src/internal/formats/select.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport type * as JSONSchema from 'effect/JSONSchema';\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { createAnnotationHelper } from '../annotations';\nimport { type JsonSchemaType } from '../json-schema';\n\n// TODO(burdon): Rename PropertyType.\nexport type ScalarType =\n | JSONSchema.JsonSchema7Object\n | JSONSchema.JsonSchema7String\n | JSONSchema.JsonSchema7Number\n | JSONSchema.JsonSchema7Boolean\n | JSONSchema.JsonSchema7Ref;\n\n// TODO(burdon): Rename ValueType and change to disciminated union.\n// export type ValueType = 'array' | 'object' | 'string' | 'number' | 'boolean' | 'ref';\nexport enum TypeEnum {\n Array = 'array', // TODO(burdon): Remove?\n Object = 'object',\n String = 'string',\n Number = 'number',\n Boolean = 'boolean',\n Ref = 'ref',\n}\n\n// TODO(burdon): Ref?\nexport const getTypeEnum = (property: JsonSchemaType): TypeEnum | undefined => {\n switch (property.type) {\n case 'array':\n return TypeEnum.Array;\n case 'object':\n return TypeEnum.Object;\n case 'string':\n return TypeEnum.String;\n case 'number':\n return TypeEnum.Number;\n case 'boolean':\n return TypeEnum.Boolean;\n default:\n return undefined;\n }\n};\n\n/**\n * https://json-schema.org/understanding-json-schema/reference/schema\n * https://json-schema.org/understanding-json-schema/reference/string#built-in-formats\n */\nexport const FormatAnnotationId = Symbol.for('@dxos/schema/annotation/Format');\n\nexport const FormatAnnotation = createAnnotationHelper<TypeFormat>(FormatAnnotationId);\n\n/** @deprecated */\nexport const getFormatAnnotation = (node: SchemaAST.AST): TypeFormat | undefined =>\n Function.pipe(SchemaAST.getAnnotation<TypeFormat>(FormatAnnotationId)(node), Option.getOrUndefined);\n\n// TODO(burdon): Rename Format; Change to discriminated union?\nexport enum TypeFormat {\n None = 'none',\n\n //\n // Scalar\n //\n\n String = 'string',\n Number = 'number',\n Boolean = 'boolean',\n Ref = 'ref',\n\n //\n // { type: 'string' }\n //\n\n DID = 'did', // Users, etc.\n DXN = 'dxn',\n Email = 'email',\n Formula = 'formula', // Spreadsheet formula.\n Hostname = 'hostname',\n JSON = 'json',\n Markdown = 'markdown',\n Regex = 'regex',\n SingleSelect = 'single-select',\n Text = 'text',\n MultiSelect = 'multi-select',\n URL = 'url',\n UUID = 'uuid',\n\n //\n // { type: 'number' }\n //\n\n Currency = 'currency',\n Integer = 'integer',\n Percent = 'percent',\n Timestamp = 'timestamp',\n\n //\n // { type: 'date' }\n //\n\n DateTime = 'date-time',\n Date = 'date',\n Time = 'time',\n Duration = 'duration',\n\n //\n // { type: 'object' }\n //\n\n GeoPoint = 'lnglat',\n}\n\nexport const FormatEnums = Object.values(TypeFormat).sort();\n\nexport const PropertyKind = {\n type: TypeEnum,\n format: TypeFormat,\n};\n\n/**\n * Default formats\n */\nexport const typeToFormat: Partial<Record<TypeEnum, TypeFormat>> = {\n [TypeEnum.String]: TypeFormat.String,\n [TypeEnum.Number]: TypeFormat.Number,\n [TypeEnum.Boolean]: TypeFormat.Boolean,\n};\n\n/**\n * Map of format to type.\n */\nexport const formatToType: Record<TypeFormat, TypeEnum> = {\n [TypeFormat.None]: undefined as any,\n [TypeFormat.String]: TypeEnum.String,\n [TypeFormat.Number]: TypeEnum.Number,\n [TypeFormat.Boolean]: TypeEnum.Boolean,\n [TypeFormat.Ref]: TypeEnum.Ref,\n\n // Strings\n [TypeFormat.DID]: TypeEnum.String,\n [TypeFormat.DXN]: TypeEnum.String,\n [TypeFormat.Email]: TypeEnum.String,\n [TypeFormat.Formula]: TypeEnum.String,\n [TypeFormat.Hostname]: TypeEnum.String,\n [TypeFormat.JSON]: TypeEnum.String,\n [TypeFormat.Markdown]: TypeEnum.String,\n [TypeFormat.Regex]: TypeEnum.String,\n [TypeFormat.URL]: TypeEnum.String,\n [TypeFormat.UUID]: TypeEnum.String,\n [TypeFormat.SingleSelect]: TypeEnum.String,\n [TypeFormat.Text]: TypeEnum.String,\n [TypeFormat.MultiSelect]: TypeEnum.Object,\n\n // Dates\n [TypeFormat.Date]: TypeEnum.String,\n [TypeFormat.DateTime]: TypeEnum.String,\n [TypeFormat.Duration]: TypeEnum.String,\n [TypeFormat.Time]: TypeEnum.String,\n\n // Numbers\n [TypeFormat.Currency]: TypeEnum.Number,\n [TypeFormat.Integer]: TypeEnum.Number,\n [TypeFormat.Percent]: TypeEnum.Number,\n [TypeFormat.Timestamp]: TypeEnum.Number,\n\n // Objects\n [TypeFormat.GeoPoint]: TypeEnum.Array,\n};\n\n/**\n * Allowed value options for select.\n */\nexport const OptionsAnnotationId = Symbol.for('@dxos/schema/annotation/Options');\n\n// TODO(wittjosiah): Reconcile with `SelectOption`.\nexport type Options = string | number;\nexport const OptionsAnnotation = createAnnotationHelper<Options[]>(OptionsAnnotationId);\n\n/** @deprecated */\nexport const getOptionsAnnotation = (node: SchemaAST.AST): Options[] | undefined =>\n Function.pipe(SchemaAST.getAnnotation<Options[]>(OptionsAnnotationId)(node), Option.getOrUndefined);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\nconst encodeMultipleOf = (divisor: number) => 1 / Math.pow(10, divisor);\n\nconst encodeMultiple =\n <A extends number>(divisor?: number) =>\n <I, R>(self: Schema.Schema<A, I, R>) =>\n divisor === undefined || divisor === 0 ? self : self.pipe(Schema.multipleOf(encodeMultipleOf(divisor)));\n\n/**\n * Convert number of digits to multipleOf annotation.\n */\nexport const DecimalPrecision = Schema.transform(Schema.Number, Schema.Number, {\n strict: true,\n encode: (value) => encodeMultipleOf(value),\n decode: (value) => Math.log10(1 / value),\n}).annotations({\n title: 'Number of digits',\n});\n\nexport const CurrencyAnnotationId = Symbol.for('@dxos/schema/annotation/Currency');\n\nexport type CurrencyAnnotation = {\n decimals?: number;\n code?: string;\n};\n\n/**\n * ISO 4217 currency code.\n */\nexport const Currency = ({ decimals, code }: CurrencyAnnotation = { decimals: 2 }) =>\n Schema.Number.pipe(\n encodeMultiple(decimals),\n FormatAnnotation.set(TypeFormat.Currency),\n Schema.annotations({\n title: 'Currency',\n description: 'Currency value',\n ...(code ? { [CurrencyAnnotationId]: code.toUpperCase() } : {}),\n }),\n );\n\nexport type PercentAnnotation = {\n decimals?: number;\n};\n\n/**\n * Integer.\n */\nexport const Integer = () =>\n Schema.Number.pipe(\n Schema.int(),\n FormatAnnotation.set(TypeFormat.Integer),\n Schema.annotations({\n title: 'Integer',\n description: 'Integer value',\n }),\n );\n\n/**\n * Percent.\n */\n// TODO(burdon): Define min/max (e.g., 0, 1).\nexport const Percent = ({ decimals }: PercentAnnotation = { decimals: 2 }) =>\n Schema.Number.pipe(\n encodeMultiple(decimals),\n FormatAnnotation.set(TypeFormat.Percent),\n Schema.annotations({\n title: 'Percent',\n description: 'Percentage value',\n }),\n );\n\n/**\n * Unix timestamp.\n * https://en.wikipedia.org/wiki/Unix_time\n */\nexport const Timestamp = Schema.Number.pipe(\n FormatAnnotation.set(TypeFormat.Timestamp),\n Schema.annotations({\n title: 'Timestamp',\n description: 'Unix timestamp',\n }),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { clamp } from '@dxos/util';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * GeoJSON Format\n * https://datatracker.ietf.org/doc/html/rfc7946\n * https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1\n * https://en.wikipedia.org/wiki/Geographic_coordinate_system\n * https://geojson.org\n * {\n * \"type\": \"Point\",\n * \"coordinates\": [0, 51.47] // [longitude, latitude]\n * }\n * Note: optional third element for altitude.\n */\nexport const GeoPoint = Schema.Tuple(\n Schema.Number.pipe(Schema.annotations({ title: 'Longitude' }), Schema.clamp(-180, 180), Schema.multipleOf(0.000001)),\n Schema.Number.pipe(Schema.annotations({ title: 'Latitude' }), Schema.clamp(-90, 90), Schema.multipleOf(0.000001)),\n Schema.optionalElement(Schema.Number).annotations({\n title: 'Height ASL (m)',\n }),\n).pipe(\n FormatAnnotation.set(TypeFormat.GeoPoint),\n Schema.annotations({\n title: 'GeoPoint',\n description: 'GeoJSON Position',\n }),\n);\n\nexport type GeoPoint = Schema.Schema.Type<typeof GeoPoint>;\n\nexport type GeoLocation = {\n longitude: number;\n latitude: number;\n height?: number;\n};\n\n/**\n * Geolocation utilities for working with GeoPoint format.\n */\nexport namespace GeoLocation {\n /**\n * Convert latitude and longitude to GeoPoint (GeoJSON format [longitude, latitude, height?]).\n * Clamps values to valid ranges: latitude [-90, 90], longitude [-180, 180].\n */\n export const toGeoPoint = ({ longitude, latitude, height }: GeoLocation): GeoPoint => {\n // TODO(ZaymonFC): Use schema validation instead of doing this manually.\n const clampedLongitude = clamp(longitude, -180, 180);\n const clampedLatitude = clamp(latitude, -90, 90);\n return height !== undefined ? [clampedLongitude, clampedLatitude, height] : [clampedLongitude, clampedLatitude];\n };\n\n /**\n * Extract latitude and longitude from GeoPoint (GeoJSON format [longitude, latitude, height?]).\n */\n export const fromGeoPoint = (geoPoint: GeoPoint | undefined): GeoLocation => {\n if (!geoPoint) {\n return { longitude: 0, latitude: 0 };\n }\n\n const result: GeoLocation = {\n longitude: geoPoint[0],\n latitude: geoPoint[1],\n };\n\n // Add height if defined.\n if (geoPoint[2] !== undefined) {\n result.height = geoPoint[2];\n }\n\n return result;\n };\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * Email address (RFC 5321)\n * https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2\n */\nexport const Email = Schema.String.pipe(\n Schema.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/),\n FormatAnnotation.set(TypeFormat.Email),\n Schema.annotations({\n title: 'Email',\n description: 'Email address',\n }),\n);\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const Formula = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Formula));\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const Hostname = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Hostname));\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const JSON = Schema.String.pipe(FormatAnnotation.set(TypeFormat.JSON));\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const Markdown = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Markdown));\n\n/**\n * Regex\n * https://json-schema.org/understanding-json-schema/reference/regular_expressions\n * https://ecma-international.org/publications-and-standards/standards/ecma-262\n */\n// TODO(burdon): Implement.\nexport const Regex = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex));\n\n/**\n * Multi-line text.\n */\nexport const Text = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Text));\n\n/**\n * https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.3\n */\nexport const URL = Schema.String.pipe(\n Schema.pattern(/^(\\w+?:\\/\\/)?([\\da-z.-]+)\\.([a-z.]{2,6})([/\\w .-]*)*\\/?$/i),\n FormatAnnotation.set(TypeFormat.URL),\n Schema.annotations({\n title: 'URL',\n description: 'URL',\n }),\n);\n\n/**\n * UUID (RFC 4122)\n * https://datatracker.ietf.org/doc/html/rfc4122\n */\nexport const UUID = Schema.UUID.pipe(\n FormatAnnotation.set(TypeFormat.UUID),\n Schema.annotations({\n [SchemaAST.ExamplesAnnotationId]: ['3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a'],\n }),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Keys from '@dxos/keys';\n\nimport * as DateUtil from './date';\nimport * as NumberUtil from './number';\nimport * as ObjectUtil from './object';\nimport * as StringUtil from './string';\nimport { TypeFormat as TypeFormat$ } from './types';\n\n// TODO(burdon): Media encoding.\n// - https://json-schema.org/understanding-json-schema/reference/non_json_data\n\n/**\n * Formats.\n * https://json-schema.org/understanding-json-schema/reference/string#built-in-formats\n * NOTE: A JSON Schema validator will ignore any format type that it does not understand.\n */\n// TODO(burdon): Add fields for `examples`, `message`, etc.\nexport namespace Format {\n export import TypeFormat = TypeFormat$;\n\n // String\n export const DXN = Keys.DXN.Schema;\n export const Email = StringUtil.Email;\n export const Formula = StringUtil.Formula;\n export const Hostname = StringUtil.Hostname;\n export const JSON = StringUtil.JSON;\n export const Markdown = StringUtil.Markdown;\n export const Regex = StringUtil.Regex;\n export const URL = StringUtil.URL;\n export const UUID = Schema.UUID;\n\n // Numbers\n // TODO(burdon): BigInt.\n export const Currency = NumberUtil.Currency;\n export const Integer = NumberUtil.Integer;\n export const Percent = NumberUtil.Percent;\n export const Timestamp = NumberUtil.Timestamp;\n\n // Dates and times\n export const Date = DateUtil.DateOnly;\n export const DateTime = DateUtil.DateTime;\n export const Duration = DateUtil.Duration;\n export const Time = DateUtil.TimeOnly;\n\n // Objects\n export const GeoPoint = ObjectUtil.GeoPoint;\n export type GeoPoint = ObjectUtil.GeoPoint; // TODO(burdon): Export types.\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * Datetime values should be stored as ISO strings or unix numbers (ms) in UTC.\n *\n * NOTE: HyperFormula uses Excel's time format (null date 1900/01/01)\n * It can be configured to use a different parser via `parseDateTime`.\n * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#date-and-time-handling\n * https://github.com/handsontable/hyperformula/blob/master/src/DateTimeHelper.ts\n */\n\n// TODO(burdon): Annotations not present in JSON.\n// TODO(burdon): Timezone.\n// TODO(burdon): Format for timestamp (Unix UTC or ISO 8601)?\n// TODO(burdon): Refs\n// - https://www.npmjs.com/package/numfmt\n// - https://date-fns.org/docs/Getting-Started\n// - https://github.com/date-fns/tz\n\n/**\n * Simple date compatible with HF.\n */\nexport const SimpleDate = Schema.Struct({\n year: Schema.Number.pipe(Schema.between(1900, 9999)),\n month: Schema.Number.pipe(Schema.between(1, 12)),\n day: Schema.Number.pipe(Schema.between(1, 31)),\n});\n\nexport type SimpleDate = Schema.Schema.Type<typeof SimpleDate>;\n\nexport const toSimpleDate = (date: Date): SimpleDate => ({\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n});\n\n/**\n * Simple time compatible with HF.\n */\nexport const SimpleTime = Schema.Struct({\n hours: Schema.Number.pipe(Schema.between(0, 23)),\n minutes: Schema.Number.pipe(Schema.between(0, 59)),\n seconds: Schema.Number.pipe(Schema.between(0, 59)),\n});\n\nexport type SimpleTime = Schema.Schema.Type<typeof SimpleTime>;\n\nexport const toSimpleTime = (date: Date): SimpleTime => ({\n hours: date.getUTCHours(),\n minutes: date.getUTCSeconds(),\n seconds: date.getUTCSeconds(),\n});\n\n/**\n * Simple date-time compatible with HF.\n */\nexport const SimpleDateTime = Schema.extend(SimpleDate, SimpleTime);\n\nexport type SimpleDateTime = Schema.Schema.Type<typeof SimpleDateTime>;\n\nexport const toSimpleDateTime = (date: Date): SimpleDateTime => ({\n ...toSimpleDate(date),\n ...toSimpleTime(date),\n});\n\n/**\n * https://effect.website/docs/guides/schema/transformations#date-transformations\n */\n\n// TODO(burdon): Consider if transformations should be supported with Automerge.\n\n/**\n * Format: 2018-11-13\n */\nexport const DateOnly = /* Schema.transformOrFail(Schema.String, SimpleDate, {\n strict: true,\n decode: (str, _, ast) => {\n if (!isValidDateFormat(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected YYYY-MM-DD format'));\n }\n if (!isValidDate(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Invalid date'));\n }\n\n const [year, month, day] = str.split('-').map(Number);\n return ParseResult.succeed({ year, month, day });\n },\n encode: (date) => {\n return ParseResult.succeed(\n [\n date.year.toString().padStart(4, '0'),\n date.month.toString().padStart(2, '0'),\n date.day.toString().padStart(2, '0'),\n ].join('-'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Date),\n Schema.annotations({\n title: 'Date',\n description: 'Valid date in ISO format',\n }),\n);\n\n/**\n * Format: 20:20:39+00:00\n */\nexport const TimeOnly = /* Schema.transformOrFail(Schema.String, SimpleTime, {\n strict: true,\n decode: (str, _, ast) => {\n if (!isValidTimeFormat(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));\n }\n\n const [hours, minutes, seconds] = str.split(':').map(Number);\n return ParseResult.succeed({ hours, minutes, seconds });\n },\n encode: (time) => {\n return ParseResult.succeed(\n [\n time.hours.toString().padStart(2, '0'),\n time.minutes.toString().padStart(2, '0'),\n time.seconds.toString().padStart(2, '0'),\n ].join(':'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Time),\n Schema.annotations({\n title: 'Time',\n description: 'Valid time in ISO format',\n }),\n);\n\n/**\n * Format: 2018-11-13T20:20:39+00:00\n */\nexport const DateTime = /* Schema.transformOrFail(Schema.String, SimpleDateTime, {\n strict: false,\n decode: (str, _, ast) => {\n const [date, time] = str.split('T');\n if (!isValidDateFormat(date)) {\n return ParseResult.fail(new ParseResult.Type(ast, date, 'Expected YYYY-MM-DD format'));\n }\n if (!isValidDate(date)) {\n return ParseResult.fail(new ParseResult.Type(ast, date, 'Invalid date'));\n }\n if (!isValidTimeFormat(time)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));\n }\n\n const [year, month, day] = date.split('-').map(Number);\n const [hours, minutes, seconds] = time.split(':').map(Number);\n return ParseResult.succeed({ year, month, day, hours, minutes, seconds });\n },\n encode: (datetime) => {\n return ParseResult.succeed(\n [\n [\n datetime.year.toString().padStart(4, '0'),\n datetime.month.toString().padStart(2, '0'),\n datetime.day.toString().padStart(2, '0'),\n ].join('-'),\n [\n datetime.hours.toString().padStart(2, '0'),\n datetime.minutes.toString().padStart(2, '0'),\n datetime.seconds.toString().padStart(2, '0'),\n ].join(':'),\n ].join('T'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.DateTime),\n Schema.annotations({\n title: 'DateTime',\n description: 'Valid date and time in ISO format',\n }),\n);\n\n/**\n * https://datatracker.ietf.org/doc/html/rfc3339#appendix-A\n */\n// TODO(burdon): Define duration type.\nexport const Duration = Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Duration),\n Schema.annotations({\n title: 'Duration',\n description: 'Duration in ISO 8601 format',\n [SchemaAST.ExamplesAnnotationId]: ['1h', '3D'],\n }),\n);\n\n//\n// Utils\n//\n\n// YYYY-MM-DD\nconst DATE_REGEX = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst _isValidDateFormat = (str: string) => DATE_REGEX.test(str);\n\nconst _isValidDate = (str: string) => {\n const date = new Date(str);\n return !isNaN(date.getTime()) && date.toISOString().startsWith(str);\n};\n\n// HH:mm:ss\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)$/;\n\nconst _isValidTimeFormat = (str: string) => TIME_REGEX.test(str);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\n/**\n * Schema for a single select option. Used to define choices in a {single|multi}-select field.\n */\nexport const SelectOption = Schema.Struct({\n /** Stable identifier for the option. */\n id: Schema.NonEmptyString,\n title: Schema.String,\n /** Color palette used for visual styling. */\n color: Schema.String,\n}).pipe(Schema.mutable);\n\nexport type SelectOption = Schema.Schema.Type<typeof SelectOption>;\n"],
5
+ "mappings": ";;;;;;AAIA,Y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tBC,QAAmBA;UACnBC,MAAiBA;UACjBC,OAAcA;UAIdC,WAAsBA;UACtBC,UAAqBA;UACrBC,UAAqBA;UACrBC,YAAuBA;UAGvBC,OAAgBC;UAChBC,WAAoBA;UACpBC,WAAoBA;UACpBC,OAAgBC;UAGhBC,WAAsBA;AAErC,GA9BiBtB,WAAAA,SAAAA,CAAAA,EAAAA;;;;AEnBjB,YAAYuB,aAAY;AAKjB,IAAMC,eAAsBC,eAAO;;EAExCC,IAAWC;EACXC,OAAcC;;EAEdC,OAAcD;AAChB,CAAA,EAAGE,KAAYC,eAAO;",
6
+ "names": ["Function", "Option", "SchemaAST", "TypeEnum", "getTypeEnum", "property", "type", "undefined", "FormatAnnotationId", "Symbol", "for", "FormatAnnotation", "createAnnotationHelper", "getFormatAnnotation", "node", "pipe", "getAnnotation", "getOrUndefined", "TypeFormat", "FormatEnums", "Object", "values", "sort", "PropertyKind", "format", "typeToFormat", "formatToType", "OptionsAnnotationId", "OptionsAnnotation", "getOptionsAnnotation", "Schema", "encodeMultipleOf", "divisor", "Math", "pow", "encodeMultiple", "self", "undefined", "pipe", "multipleOf", "DecimalPrecision", "transform", "Number", "strict", "encode", "value", "decode", "log10", "annotations", "title", "CurrencyAnnotationId", "Symbol", "for", "Currency", "decimals", "code", "FormatAnnotation", "set", "TypeFormat", "description", "toUpperCase", "Integer", "int", "Percent", "Timestamp", "Schema", "clamp", "GeoPoint", "Tuple", "Number", "pipe", "annotations", "title", "clamp", "multipleOf", "optionalElement", "FormatAnnotation", "set", "TypeFormat", "description", "GeoLocation", "toGeoPoint", "longitude", "latitude", "height", "clampedLongitude", "clampedLatitude", "undefined", "fromGeoPoint", "geoPoint", "result", "Schema", "SchemaAST", "Email", "String", "pipe", "pattern", "FormatAnnotation", "set", "TypeFormat", "annotations", "title", "description", "Formula", "Hostname", "JSON", "Markdown", "Regex", "Text", "URL", "UUID", "ExamplesAnnotationId", "Schema", "Keys", "Schema", "SchemaAST", "SimpleDate", "Struct", "year", "Number", "pipe", "between", "month", "day", "SimpleTime", "Struct", "hours", "Number", "pipe", "between", "minutes", "seconds", "SimpleDateTime", "extend", "SimpleDate", "SimpleTime", "DateOnly", "String", "pipe", "FormatAnnotation", "set", "TypeFormat", "Date", "annotations", "title", "description", "TimeOnly", "Time", "DateTime", "Duration", "ExamplesAnnotationId", "Format", "TypeFormat", "DXN", "Schema", "Email", "Formula", "Hostname", "JSON", "Markdown", "Regex", "URL", "UUID", "Currency", "Integer", "Percent", "Timestamp", "Date", "DateOnly", "DateTime", "Duration", "Time", "TimeOnly", "GeoPoint", "Schema", "SelectOption", "Struct", "id", "NonEmptyString", "title", "String", "color", "pipe", "mutable"]
7
+ }
@@ -0,0 +1,11 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ export {
9
+ __export
10
+ };
11
+ //# sourceMappingURL=chunk-HSLMI22Q.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,113 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ isInstanceOf
4
+ } from "./chunk-6OTQZKHX.mjs";
5
+ import {
6
+ ObjectNotFoundError
7
+ } from "./chunk-D5BW7KHR.mjs";
8
+ import {
9
+ __export
10
+ } from "./chunk-HSLMI22Q.mjs";
11
+
12
+ // src/Database.ts
13
+ var Database_exports = {};
14
+ __export(Database_exports, {
15
+ Service: () => Service
16
+ });
17
+ import * as Context from "effect/Context";
18
+ import * as Effect from "effect/Effect";
19
+ import * as Layer from "effect/Layer";
20
+ import * as Option from "effect/Option";
21
+ import { promiseWithCauseCapture } from "@dxos/effect";
22
+ import { invariant } from "@dxos/invariant";
23
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/Database.ts";
24
+ var Service = class _Service extends Context.Tag("@dxos/echo/Database/Service")() {
25
+ static notAvailable = Layer.succeed(_Service, {
26
+ get db() {
27
+ throw new Error("Database not available");
28
+ }
29
+ });
30
+ static make = (db) => {
31
+ return {
32
+ get db() {
33
+ return db;
34
+ }
35
+ };
36
+ };
37
+ static layer = (db) => {
38
+ return Layer.succeed(_Service, _Service.make(db));
39
+ };
40
+ /**
41
+ * Resolves an object by its DXN.
42
+ */
43
+ static resolve = (dxn, schema) => Effect.gen(function* () {
44
+ const { db } = yield* _Service;
45
+ const object = yield* promiseWithCauseCapture(() => db.graph.createRefResolver({
46
+ context: {
47
+ space: db.spaceId
48
+ }
49
+ }).resolve(dxn));
50
+ if (!object) {
51
+ return yield* Effect.fail(new ObjectNotFoundError(dxn));
52
+ }
53
+ invariant(!schema || isInstanceOf(schema, object), "Object type mismatch.", {
54
+ F: __dxlog_file,
55
+ L: 226,
56
+ S: this,
57
+ A: [
58
+ "!schema || isInstanceOf(schema, object)",
59
+ "'Object type mismatch.'"
60
+ ]
61
+ });
62
+ return object;
63
+ });
64
+ /**
65
+ * Loads an object reference.
66
+ */
67
+ static load = Effect.fn(function* (ref) {
68
+ const object = yield* promiseWithCauseCapture(() => ref.tryLoad());
69
+ if (!object) {
70
+ return yield* Effect.fail(new ObjectNotFoundError(ref.dxn));
71
+ }
72
+ return object;
73
+ });
74
+ /**
75
+ * Loads an object reference option.
76
+ */
77
+ // TODO(burdon): Option?
78
+ static loadOption = Effect.fn(function* (ref) {
79
+ const object = yield* _Service.load(ref).pipe(Effect.catchTag("OBJECT_NOT_FOUND", () => Effect.succeed(void 0)));
80
+ return Option.fromNullable(object);
81
+ });
82
+ // TODO(burdon): Can we create a proxy for the following methods on Database? Use @inheritDoc?
83
+ // TODO(burdon): Figure out how to chain query().run();
84
+ /**
85
+ * @link EchoDatabase.add
86
+ */
87
+ static add = (obj) => _Service.pipe(Effect.map(({ db }) => db.add(obj)));
88
+ /**
89
+ * @link EchoDatabase.remove
90
+ */
91
+ static remove = (obj) => _Service.pipe(Effect.map(({ db }) => db.remove(obj)));
92
+ /**
93
+ * @link EchoDatabase.flush
94
+ */
95
+ static flush = (opts) => _Service.pipe(Effect.flatMap(({ db }) => promiseWithCauseCapture(() => db.flush(opts))));
96
+ /**
97
+ * Creates a `QueryResult` object that can be subscribed to.
98
+ */
99
+ static query = (queryOrFilter) => _Service.pipe(Effect.map(({ db }) => db.query(queryOrFilter)), Effect.withSpan("Service.query"));
100
+ /**
101
+ * Executes the query once and returns the results.
102
+ */
103
+ static runQuery = (queryOrFilter) => _Service.query(queryOrFilter).pipe(Effect.flatMap((queryResult) => promiseWithCauseCapture(() => queryResult.run())));
104
+ // TODO(dmaretskyi): Change API to `yield* Service.querySchema(...).first` and `yield* Service.querySchema(...).schema`.
105
+ static schemaQuery = (query) => _Service.pipe(Effect.map(({ db }) => db.schemaRegistry.query(query)), Effect.withSpan("Service.schemaQuery"));
106
+ static runSchemaQuery = (query) => _Service.schemaQuery(query).pipe(Effect.flatMap((queryResult) => promiseWithCauseCapture(() => queryResult.run())));
107
+ };
108
+
109
+ export {
110
+ Service,
111
+ Database_exports
112
+ };
113
+ //# sourceMappingURL=chunk-JYZSF62S.mjs.map