@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.
- package/README.md +1 -1
- package/dist/lib/browser/Annotation.mjs +31 -0
- package/dist/lib/browser/Annotation.mjs.map +7 -0
- package/dist/lib/browser/Database.mjs +14 -0
- package/dist/lib/browser/Database.mjs.map +7 -0
- package/dist/lib/browser/Entity.mjs +20 -0
- package/dist/lib/browser/Entity.mjs.map +7 -0
- package/dist/lib/browser/Err.mjs +11 -0
- package/dist/lib/browser/Err.mjs.map +7 -0
- package/dist/lib/browser/Filter.mjs +60 -0
- package/dist/lib/browser/Filter.mjs.map +7 -0
- package/dist/lib/browser/Format.mjs +67 -0
- package/dist/lib/browser/Format.mjs.map +7 -0
- package/dist/lib/browser/JsonSchema.mjs +18 -0
- package/dist/lib/browser/JsonSchema.mjs.map +7 -0
- package/dist/lib/browser/Key.mjs +13 -0
- package/dist/lib/browser/Key.mjs.map +7 -0
- package/dist/lib/browser/Obj.mjs +83 -0
- package/dist/lib/browser/Obj.mjs.map +7 -0
- package/dist/lib/browser/Order.mjs +11 -0
- package/dist/lib/browser/Order.mjs.map +7 -0
- package/dist/lib/browser/Query.mjs +25 -0
- package/dist/lib/browser/Query.mjs.map +7 -0
- package/dist/lib/browser/QueryResult.mjs +3 -0
- package/dist/lib/browser/QueryResult.mjs.map +7 -0
- package/dist/lib/browser/Ref.mjs +21 -0
- package/dist/lib/browser/Ref.mjs.map +7 -0
- package/dist/lib/browser/Relation.mjs +33 -0
- package/dist/lib/browser/Relation.mjs.map +7 -0
- package/dist/lib/browser/SchemaRegistry.mjs +3 -0
- package/dist/lib/browser/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/browser/Tag.mjs +25 -0
- package/dist/lib/browser/Tag.mjs.map +7 -0
- package/dist/lib/browser/Type.mjs +38 -0
- package/dist/lib/browser/Type.mjs.map +7 -0
- package/dist/lib/browser/chunk-3B2G6BW4.mjs +74 -0
- package/dist/lib/browser/chunk-3B2G6BW4.mjs.map +7 -0
- package/dist/lib/browser/chunk-5IN7XBIQ.mjs +24 -0
- package/dist/lib/browser/chunk-5IN7XBIQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-6XVZF5VJ.mjs +2924 -0
- package/dist/lib/browser/chunk-6XVZF5VJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-AGOWBKY6.mjs +94 -0
- package/dist/lib/browser/chunk-AGOWBKY6.mjs.map +7 -0
- package/dist/lib/browser/chunk-BD6MRI4M.mjs +113 -0
- package/dist/lib/browser/chunk-BD6MRI4M.mjs.map +7 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-DOPKE2FQ.mjs +32 -0
- package/dist/lib/browser/chunk-DOPKE2FQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-ESLW4N7S.mjs +41 -0
- package/dist/lib/browser/chunk-ESLW4N7S.mjs.map +7 -0
- package/dist/lib/browser/chunk-F4YF6C3O.mjs +363 -0
- package/dist/lib/browser/chunk-F4YF6C3O.mjs.map +7 -0
- package/dist/lib/browser/chunk-FGFQWIZE.mjs +9 -0
- package/dist/lib/browser/chunk-FGFQWIZE.mjs.map +7 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs +22 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs.map +7 -0
- package/dist/lib/browser/chunk-JG4GH6LN.mjs +9 -0
- package/dist/lib/browser/chunk-JG4GH6LN.mjs.map +7 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs +15 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-NFH3POTD.mjs +37 -0
- package/dist/lib/browser/chunk-NFH3POTD.mjs.map +7 -0
- package/dist/lib/browser/chunk-O6FOICWT.mjs +57 -0
- package/dist/lib/browser/chunk-O6FOICWT.mjs.map +7 -0
- package/dist/lib/browser/chunk-P2B4BASR.mjs +288 -0
- package/dist/lib/browser/chunk-P2B4BASR.mjs.map +7 -0
- package/dist/lib/browser/chunk-QHC3ZYNC.mjs +152 -0
- package/dist/lib/browser/chunk-QHC3ZYNC.mjs.map +7 -0
- package/dist/lib/browser/chunk-QU7PWSZD.mjs +62 -0
- package/dist/lib/browser/chunk-QU7PWSZD.mjs.map +7 -0
- package/dist/lib/browser/chunk-RP4JV7FD.mjs +403 -0
- package/dist/lib/browser/chunk-RP4JV7FD.mjs.map +7 -0
- package/dist/lib/browser/chunk-V7TON6BX.mjs +151 -0
- package/dist/lib/browser/chunk-V7TON6BX.mjs.map +7 -0
- package/dist/lib/browser/chunk-WABSVOOX.mjs +303 -0
- package/dist/lib/browser/chunk-WABSVOOX.mjs.map +7 -0
- package/dist/lib/browser/chunk-XRHHSMHJ.mjs +39 -0
- package/dist/lib/browser/chunk-XRHHSMHJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZIM3Y4ZK.mjs +38 -0
- package/dist/lib/browser/chunk-ZIM3Y4ZK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -9
- package/dist/lib/browser/internal/index.mjs +347 -0
- package/dist/lib/browser/internal/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +322 -32
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/Annotation.mjs +31 -0
- package/dist/lib/node-esm/Annotation.mjs.map +7 -0
- package/dist/lib/node-esm/Database.mjs +14 -0
- package/dist/lib/node-esm/Database.mjs.map +7 -0
- package/dist/lib/node-esm/Entity.mjs +20 -0
- package/dist/lib/node-esm/Entity.mjs.map +7 -0
- package/dist/lib/node-esm/Err.mjs +11 -0
- package/dist/lib/node-esm/Err.mjs.map +7 -0
- package/dist/lib/node-esm/Filter.mjs +60 -0
- package/dist/lib/node-esm/Filter.mjs.map +7 -0
- package/dist/lib/node-esm/Format.mjs +67 -0
- package/dist/lib/node-esm/Format.mjs.map +7 -0
- package/dist/lib/node-esm/JsonSchema.mjs +18 -0
- package/dist/lib/node-esm/JsonSchema.mjs.map +7 -0
- package/dist/lib/node-esm/Key.mjs +13 -0
- package/dist/lib/node-esm/Key.mjs.map +7 -0
- package/dist/lib/node-esm/Obj.mjs +83 -0
- package/dist/lib/node-esm/Obj.mjs.map +7 -0
- package/dist/lib/node-esm/Order.mjs +11 -0
- package/dist/lib/node-esm/Order.mjs.map +7 -0
- package/dist/lib/node-esm/Query.mjs +25 -0
- package/dist/lib/node-esm/Query.mjs.map +7 -0
- package/dist/lib/node-esm/QueryResult.mjs +3 -0
- package/dist/lib/node-esm/QueryResult.mjs.map +7 -0
- package/dist/lib/node-esm/Ref.mjs +21 -0
- package/dist/lib/node-esm/Ref.mjs.map +7 -0
- package/dist/lib/node-esm/Relation.mjs +33 -0
- package/dist/lib/node-esm/Relation.mjs.map +7 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs +3 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/node-esm/Tag.mjs +25 -0
- package/dist/lib/node-esm/Tag.mjs.map +7 -0
- package/dist/lib/node-esm/Type.mjs +38 -0
- package/dist/lib/node-esm/Type.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5M5P2DCR.mjs +32 -0
- package/dist/lib/node-esm/chunk-5M5P2DCR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6OTQZKHX.mjs +303 -0
- package/dist/lib/node-esm/chunk-6OTQZKHX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-76LEDWHO.mjs +152 -0
- package/dist/lib/node-esm/chunk-76LEDWHO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AGHZH33D.mjs +9 -0
- package/dist/lib/node-esm/chunk-AGHZH33D.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +22 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BJACR7QG.mjs +363 -0
- package/dist/lib/node-esm/chunk-BJACR7QG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BYL2NPEA.mjs +37 -0
- package/dist/lib/node-esm/chunk-BYL2NPEA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CCMFPJUT.mjs +74 -0
- package/dist/lib/node-esm/chunk-CCMFPJUT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D5BW7KHR.mjs +39 -0
- package/dist/lib/node-esm/chunk-D5BW7KHR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DJX53IQ3.mjs +2924 -0
- package/dist/lib/node-esm/chunk-DJX53IQ3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FWTPV5QD.mjs +94 -0
- package/dist/lib/node-esm/chunk-FWTPV5QD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HLUDHPFO.mjs +403 -0
- package/dist/lib/node-esm/chunk-HLUDHPFO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JYZSF62S.mjs +113 -0
- package/dist/lib/node-esm/chunk-JYZSF62S.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KUX5JEL2.mjs +57 -0
- package/dist/lib/node-esm/chunk-KUX5JEL2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LDXRA5TC.mjs +288 -0
- package/dist/lib/node-esm/chunk-LDXRA5TC.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +15 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NHYOREKX.mjs +62 -0
- package/dist/lib/node-esm/chunk-NHYOREKX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QVZZHCDS.mjs +9 -0
- package/dist/lib/node-esm/chunk-QVZZHCDS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W3OLV7MG.mjs +41 -0
- package/dist/lib/node-esm/chunk-W3OLV7MG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W5AQXKVF.mjs +38 -0
- package/dist/lib/node-esm/chunk-W5AQXKVF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YNBFXTDG.mjs +24 -0
- package/dist/lib/node-esm/chunk-YNBFXTDG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z53QIBP2.mjs +151 -0
- package/dist/lib/node-esm/chunk-Z53QIBP2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +72 -9
- package/dist/lib/node-esm/internal/index.mjs +347 -0
- package/dist/lib/node-esm/internal/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +322 -32
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +179 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +36 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +68 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +9 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +152 -35
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +11 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +107 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +84 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +12 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +20 -14
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +73 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +39 -50
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +15 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +179 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts +2 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +27 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +10 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/entities/expando.d.ts +16 -0
- package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +70 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +11 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +55 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.d.ts +63 -0
- package/dist/types/src/internal/formats/date.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.test.d.ts +2 -0
- package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +32 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.test.d.ts +2 -0
- package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/index.d.ts +8 -0
- package/dist/types/src/internal/formats/index.d.ts.map +1 -0
- package/dist/types/src/internal/formats/number.d.ts +31 -0
- package/dist/types/src/internal/formats/number.d.ts.map +1 -0
- package/dist/types/src/internal/formats/object.d.ts +35 -0
- package/dist/types/src/internal/formats/object.d.ts.map +1 -0
- package/dist/types/src/internal/formats/select.d.ts +13 -0
- package/dist/types/src/internal/formats/select.d.ts.map +1 -0
- package/dist/types/src/internal/formats/string.d.ts +42 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -0
- package/dist/types/src/internal/formats/types.d.ts +72 -0
- package/dist/types/src/internal/formats/types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +11 -0
- package/dist/types/src/internal/index.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/annotations.d.ts +19 -0
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +5 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +250 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.d.ts +29 -0
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts +18 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.d.ts +39 -0
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +6 -0
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/object/ids.d.ts +6 -0
- package/dist/types/src/internal/object/ids.d.ts.map +1 -0
- package/dist/types/src/internal/object/index.d.ts +8 -0
- package/dist/types/src/internal/object/index.d.ts.map +1 -0
- package/dist/types/src/internal/object/inspect.d.ts +2 -0
- package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.d.ts +31 -0
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +31 -0
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +3 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +44 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/ref/index.d.ts +3 -0
- package/dist/types/src/internal/ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.d.ts +209 -0
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
- package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.d.ts +6 -0
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts +2 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +168 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/index.d.ts +5 -0
- package/dist/types/src/internal/schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/snapshot.d.ts +6 -0
- package/dist/types/src/internal/schema/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +37 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +12 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +6 -0
- package/dist/types/src/internal/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/types/meta.d.ts +40 -0
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/types/version.d.ts +15 -0
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +407 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +16 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +164 -33
- package/src/Annotation.ts +17 -0
- package/src/Database.ts +308 -0
- package/src/Entity.ts +51 -0
- package/src/Err.ts +18 -0
- package/src/Filter.ts +376 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +74 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.ts +407 -71
- package/src/Order.ts +34 -0
- package/src/Query.test.ts +346 -0
- package/src/Query.ts +279 -0
- package/src/QueryResult.ts +109 -0
- package/src/Ref.ts +25 -9
- package/src/Relation.ts +72 -46
- package/src/SchemaRegistry.ts +92 -0
- package/src/Tag.ts +40 -0
- package/src/Type.ts +98 -84
- package/src/index.ts +17 -4
- package/src/internal/README.md +87 -0
- package/src/internal/annotations/annotations.test.ts +96 -0
- package/src/internal/annotations/annotations.ts +488 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +72 -0
- package/src/internal/entities/entity.ts +109 -0
- package/src/internal/entities/expando.ts +23 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +129 -0
- package/src/internal/entities/object.ts +45 -0
- package/src/internal/entities/relation.ts +155 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +56 -0
- package/src/internal/formats/date.ts +217 -0
- package/src/internal/formats/format.test.ts +77 -0
- package/src/internal/formats/format.ts +54 -0
- package/src/internal/formats/index.ts +12 -0
- package/src/internal/formats/number.ts +89 -0
- package/src/internal/formats/object.ts +80 -0
- package/src/internal/formats/select.ts +18 -0
- package/src/internal/formats/string.ts +81 -0
- package/src/internal/formats/types.ts +186 -0
- package/src/internal/index.ts +38 -0
- package/src/internal/json-schema/annotations.ts +50 -0
- package/src/internal/json-schema/effect-schema.test.ts +143 -0
- package/src/internal/json-schema/index.ts +8 -0
- package/src/internal/json-schema/json-schema-normalize.ts +109 -0
- package/src/internal/json-schema/json-schema-type.ts +404 -0
- package/src/internal/json-schema/json-schema.test.ts +861 -0
- package/src/internal/json-schema/json-schema.ts +528 -0
- package/src/internal/object/common.ts +75 -0
- package/src/internal/object/create-object.test.ts +116 -0
- package/src/internal/object/create-object.ts +95 -0
- package/src/internal/object/deleted.ts +19 -0
- package/src/internal/object/ids.ts +12 -0
- package/src/internal/object/index.ts +11 -0
- package/src/internal/object/inspect.ts +46 -0
- package/src/internal/object/json-serializer.test.ts +94 -0
- package/src/internal/object/json-serializer.ts +230 -0
- package/src/internal/object/schema-validator.test.ts +186 -0
- package/src/internal/object/schema-validator.ts +244 -0
- package/src/internal/object/typed-object.test.ts +34 -0
- package/src/internal/object/typed-object.ts +94 -0
- package/src/internal/proxy/handler.test.ts +173 -0
- package/src/internal/proxy/index.ts +6 -0
- package/src/internal/proxy/make-object.ts +113 -0
- package/src/internal/proxy/schema.test.ts +137 -0
- package/src/internal/proxy/typed-handler.test.ts +102 -0
- package/src/internal/proxy/typed-handler.ts +233 -0
- package/src/internal/proxy/typed-object.test.ts +105 -0
- package/src/internal/ref/index.ts +6 -0
- package/src/internal/ref/ref-array.ts +39 -0
- package/src/internal/ref/ref.test.ts +101 -0
- package/src/internal/ref/ref.ts +525 -0
- package/src/internal/schema/compose.test.ts +42 -0
- package/src/internal/schema/compose.ts +37 -0
- package/src/internal/schema/echo-schema.ts +385 -0
- package/src/internal/schema/index.ts +8 -0
- package/src/internal/schema/manipulation.ts +92 -0
- package/src/internal/schema/persistent-schema.ts +28 -0
- package/src/internal/schema/snapshot.ts +25 -0
- package/src/internal/types/base.ts +57 -0
- package/src/internal/types/entity.ts +23 -0
- package/src/internal/types/index.ts +9 -0
- package/src/internal/types/meta.ts +76 -0
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/testing/api.test.ts +100 -0
- package/src/testing/index.ts +3 -1
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +224 -0
- package/src/testing/util.ts +78 -0
- package/dist/lib/browser/chunk-EUA7CM23.mjs +0 -619
- package/dist/lib/browser/chunk-EUA7CM23.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IV6BWGHK.mjs +0 -619
- package/dist/lib/node-esm/chunk-IV6BWGHK.mjs.map +0 -7
- package/dist/types/src/experimental/database.d.ts +0 -8
- package/dist/types/src/experimental/database.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -1
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/queue.d.ts +0 -8
- package/dist/types/src/experimental/queue.d.ts.map +0 -1
- package/dist/types/src/experimental/space.d.ts +0 -8
- package/dist/types/src/experimental/space.d.ts.map +0 -1
- package/dist/types/src/query/dsl.d.ts +0 -218
- package/dist/types/src/query/dsl.d.ts.map +0 -1
- package/dist/types/src/query/dsl.test.d.ts +0 -2
- package/dist/types/src/query/dsl.test.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -113
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/experimental/database.ts +0 -11
- package/src/experimental/index.ts +0 -7
- package/src/experimental/queue.ts +0 -11
- package/src/experimental/space.ts +0 -11
- package/src/query/dsl.test.ts +0 -323
- package/src/query/dsl.ts +0 -646
- package/src/query/index.ts +0 -5
- package/src/test/api.test.ts +0 -173
- package/src/testing/types.ts +0 -91
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { type ForeignKey } from '@dxos/echo-protocol';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { DXN, ObjectId } from '@dxos/keys';
|
|
10
|
+
import { assumeType } from '@dxos/util';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type ATTR_META,
|
|
14
|
+
type ATTR_TYPE,
|
|
15
|
+
EntityKind,
|
|
16
|
+
KindId,
|
|
17
|
+
type MetaId,
|
|
18
|
+
type ObjectMeta,
|
|
19
|
+
type SchemaId,
|
|
20
|
+
TypeId,
|
|
21
|
+
type Version,
|
|
22
|
+
} from '../types';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
type ATTR_RELATION_SOURCE,
|
|
26
|
+
type ATTR_RELATION_TARGET,
|
|
27
|
+
RelationSourceDXNId,
|
|
28
|
+
RelationSourceId,
|
|
29
|
+
RelationTargetDXNId,
|
|
30
|
+
RelationTargetId,
|
|
31
|
+
} from './relation';
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// Defines the internal model of the echo object.
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Property name for self DXN when object is serialized to JSON.
|
|
39
|
+
*/
|
|
40
|
+
export const ATTR_SELF_DXN = '@dxn';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* DXN to the object itself.
|
|
44
|
+
*/
|
|
45
|
+
export const SelfDXNId = Symbol.for('@dxos/echo/DXN');
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Property name for deleted when object is serialized to JSON.
|
|
49
|
+
*/
|
|
50
|
+
export const ATTR_DELETED = '@deleted';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Deletion marker.
|
|
54
|
+
*/
|
|
55
|
+
export const ObjectDeletedId = Symbol.for('@dxos/echo/Deleted');
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Object version accessor symbol.
|
|
59
|
+
*/
|
|
60
|
+
export const ObjectVersionId: unique symbol = Symbol.for('@dxos/echo/Version');
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Internal runtime representation of an object.
|
|
64
|
+
* The fields are accessed through getter functions.
|
|
65
|
+
*/
|
|
66
|
+
export interface InternalObjectProps {
|
|
67
|
+
id: ObjectId;
|
|
68
|
+
|
|
69
|
+
// Echo supports untyped objects O_O.
|
|
70
|
+
readonly [TypeId]?: DXN;
|
|
71
|
+
|
|
72
|
+
// TODO(burdon): ???
|
|
73
|
+
readonly [SelfDXNId]?: DXN;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns the schema for the object.
|
|
77
|
+
*/
|
|
78
|
+
readonly [SchemaId]?: Schema.Schema.AnyNoContext;
|
|
79
|
+
readonly [KindId]: EntityKind;
|
|
80
|
+
readonly [MetaId]?: ObjectMeta;
|
|
81
|
+
readonly [ObjectDeletedId]?: boolean;
|
|
82
|
+
readonly [ObjectVersionId]?: Version;
|
|
83
|
+
readonly [RelationSourceDXNId]?: DXN;
|
|
84
|
+
readonly [RelationTargetDXNId]?: DXN;
|
|
85
|
+
readonly [RelationSourceId]?: InternalObjectProps;
|
|
86
|
+
readonly [RelationTargetId]?: InternalObjectProps;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Entity metadata.
|
|
91
|
+
*/
|
|
92
|
+
export interface ObjectMetaJSON {
|
|
93
|
+
keys: ForeignKey[];
|
|
94
|
+
tags?: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* JSON representation of an object or relation metadata.
|
|
99
|
+
*/
|
|
100
|
+
export interface ObjectJSON {
|
|
101
|
+
id: string;
|
|
102
|
+
[ATTR_TYPE]: DXN.String;
|
|
103
|
+
[ATTR_SELF_DXN]?: DXN.String;
|
|
104
|
+
[ATTR_DELETED]?: boolean;
|
|
105
|
+
[ATTR_META]?: ObjectMetaJSON;
|
|
106
|
+
[ATTR_RELATION_SOURCE]?: DXN.String;
|
|
107
|
+
[ATTR_RELATION_TARGET]?: DXN.String;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* NOTE: Keep as `function` to avoid type inference issues.
|
|
112
|
+
*/
|
|
113
|
+
export function assertObjectModel(obj: unknown): asserts obj is InternalObjectProps {
|
|
114
|
+
invariant(typeof obj === 'object' && obj !== null, 'Invalid object model: not an object');
|
|
115
|
+
assumeType<InternalObjectProps>(obj);
|
|
116
|
+
invariant(ObjectId.isValid(obj.id), 'Invalid object model: invalid id');
|
|
117
|
+
invariant(obj[TypeId] === undefined || obj[TypeId] instanceof DXN, 'Invalid object model: invalid type');
|
|
118
|
+
invariant(
|
|
119
|
+
obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation,
|
|
120
|
+
'Invalid object model: invalid entity kind',
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (obj[KindId] === EntityKind.Relation) {
|
|
124
|
+
invariant(obj[RelationSourceDXNId] instanceof DXN, 'Invalid object model: invalid relation source');
|
|
125
|
+
invariant(obj[RelationTargetDXNId] instanceof DXN, 'Invalid object model: invalid relation target');
|
|
126
|
+
invariant(!(obj[RelationSourceId] instanceof DXN), 'Invalid object model: source pointer is a DXN');
|
|
127
|
+
invariant(!(obj[RelationTargetId] instanceof DXN), 'Invalid object model: target pointer is a DXN');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
|
|
10
|
+
import { type TypeAnnotation, TypeAnnotationId, type TypeMeta, makeTypeJsonSchemaAnnotation } from '../annotations';
|
|
11
|
+
import { EntityKind } from '../types';
|
|
12
|
+
|
|
13
|
+
import { type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Schema for Obj entity types.
|
|
17
|
+
* Pipeable function to add ECHO object annotations to a schema.
|
|
18
|
+
*/
|
|
19
|
+
export const EchoObjectSchema: {
|
|
20
|
+
// TODO(burdon): Tighten Self type to Schema.TypeLiteral or Schema.Struct to facilitate definition of `make` method.
|
|
21
|
+
// (meta: TypeMeta): <Self extends Schema.Struct<Fields>, Fields extends Schema.Struct.Fields>(self: Self) => EchoObjectSchema<Self, Fields>;
|
|
22
|
+
(meta: TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => EchoTypeSchema<Self>;
|
|
23
|
+
} = ({ typename, version }) => {
|
|
24
|
+
return <Self extends Schema.Schema.Any>(self: Self): EchoTypeSchema<Self> => {
|
|
25
|
+
invariant(typeof TypeAnnotationId === 'symbol', 'Sanity.');
|
|
26
|
+
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
27
|
+
|
|
28
|
+
// TODO(dmaretskyi): Does `Schema.mutable` work for deep mutability here?
|
|
29
|
+
// TODO(dmaretskyi): Do not do mutable here.
|
|
30
|
+
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
31
|
+
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
32
|
+
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
33
|
+
...self.ast.annotations,
|
|
34
|
+
[TypeAnnotationId]: { kind: EntityKind.Object, typename, version } satisfies TypeAnnotation,
|
|
35
|
+
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
36
|
+
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
37
|
+
kind: EntityKind.Object,
|
|
38
|
+
typename,
|
|
39
|
+
version,
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return makeEchoTypeSchema<Self>(/* self.fields, */ ast, typename, version);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
9
|
+
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
|
+
import { DXN } from '@dxos/keys';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type TypeAnnotation,
|
|
14
|
+
TypeAnnotationId,
|
|
15
|
+
type TypeMeta,
|
|
16
|
+
getEntityKind,
|
|
17
|
+
getSchemaTypename,
|
|
18
|
+
getTypeIdentifierAnnotation,
|
|
19
|
+
makeTypeJsonSchemaAnnotation,
|
|
20
|
+
} from '../annotations';
|
|
21
|
+
import { EntityKind } from '../types';
|
|
22
|
+
|
|
23
|
+
import { type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Property name for relation source when object is serialized to JSON.
|
|
27
|
+
*/
|
|
28
|
+
export const ATTR_RELATION_SOURCE = '@relationSource';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Used to access relation source ref on live ECHO objects.
|
|
32
|
+
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
33
|
+
*/
|
|
34
|
+
export const RelationSourceId: unique symbol = Symbol.for('@dxos/echo/RelationSource');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Used to access relation source ref on live ECHO objects.
|
|
38
|
+
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
39
|
+
*/
|
|
40
|
+
export const RelationSourceDXNId: unique symbol = Symbol.for('@dxos/echo/RelationSourceDXN');
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Property name for relation target when object is serialized to JSON.
|
|
44
|
+
*/
|
|
45
|
+
export const ATTR_RELATION_TARGET = '@relationTarget';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Used to access relation target ref on live ECHO objects.
|
|
49
|
+
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
50
|
+
*/
|
|
51
|
+
export const RelationTargetId: unique symbol = Symbol.for('@dxos/echo/RelationTarget');
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Used to access relation target ref on live ECHO objects.
|
|
55
|
+
* Reading this symbol must return `Live<EchoObjectSchema<any>>` or a DXN.
|
|
56
|
+
*/
|
|
57
|
+
export const RelationTargetDXNId: unique symbol = Symbol.for('@dxos/echo/RelationTargetDXN');
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Source and target props on relations.
|
|
61
|
+
*/
|
|
62
|
+
// TODO(burdon): any?
|
|
63
|
+
export type RelationSourceTargetRefs<Source = any, Target = any> = {
|
|
64
|
+
/**
|
|
65
|
+
* Source ECHO live object.
|
|
66
|
+
*/
|
|
67
|
+
[RelationSourceId]: Source;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Target ECHO live object.
|
|
71
|
+
*/
|
|
72
|
+
[RelationTargetId]: Target;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type RelationSource<R> = R extends RelationSourceTargetRefs<infer Source, infer _Target> ? Source : never;
|
|
76
|
+
export type RelationTarget<R> = R extends RelationSourceTargetRefs<infer _Source, infer Target> ? Target : never;
|
|
77
|
+
|
|
78
|
+
export type EchoRelationSchemaOptions<
|
|
79
|
+
TSource extends Schema.Schema.AnyNoContext,
|
|
80
|
+
TTarget extends Schema.Schema.AnyNoContext,
|
|
81
|
+
> = TypeMeta & {
|
|
82
|
+
source: TSource;
|
|
83
|
+
target: TTarget;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Schema for Relation entity types.
|
|
88
|
+
*/
|
|
89
|
+
export const EchoRelationSchema = <
|
|
90
|
+
Source extends Schema.Schema.AnyNoContext,
|
|
91
|
+
Target extends Schema.Schema.AnyNoContext,
|
|
92
|
+
>({
|
|
93
|
+
source,
|
|
94
|
+
target,
|
|
95
|
+
typename,
|
|
96
|
+
version,
|
|
97
|
+
}: EchoRelationSchemaOptions<Source, Target>) => {
|
|
98
|
+
assertArgument(Schema.isSchema(source), 'source');
|
|
99
|
+
assertArgument(Schema.isSchema(target), 'target');
|
|
100
|
+
const sourceDXN = getDXNForRelationSchemaRef(source);
|
|
101
|
+
const targetDXN = getDXNForRelationSchemaRef(target);
|
|
102
|
+
if (getEntityKind(source) !== EntityKind.Object) {
|
|
103
|
+
raise(new Error('Source schema must be an echo object schema.'));
|
|
104
|
+
}
|
|
105
|
+
if (getEntityKind(target) !== EntityKind.Object) {
|
|
106
|
+
raise(new Error('Target schema must be an echo object schema.'));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return <Self extends Schema.Schema.Any>(
|
|
110
|
+
self: Self,
|
|
111
|
+
): EchoTypeSchema<Self, RelationSourceTargetRefs<Schema.Schema.Type<Source>, Schema.Schema.Type<Target>>> => {
|
|
112
|
+
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
113
|
+
|
|
114
|
+
// TODO(dmaretskyi): Does `Schema.mutable` work for deep mutability here?
|
|
115
|
+
// TODO(dmaretskyi): Do not do mutable here.
|
|
116
|
+
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
117
|
+
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
118
|
+
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
119
|
+
...self.ast.annotations,
|
|
120
|
+
[TypeAnnotationId]: {
|
|
121
|
+
kind: EntityKind.Relation,
|
|
122
|
+
typename,
|
|
123
|
+
version,
|
|
124
|
+
sourceSchema: sourceDXN,
|
|
125
|
+
targetSchema: targetDXN,
|
|
126
|
+
} satisfies TypeAnnotation,
|
|
127
|
+
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
128
|
+
|
|
129
|
+
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
130
|
+
kind: EntityKind.Relation,
|
|
131
|
+
typename,
|
|
132
|
+
version,
|
|
133
|
+
relationSource: sourceDXN,
|
|
134
|
+
relationTarget: targetDXN,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return makeEchoTypeSchema<Self>(/* self.fields, */ ast, typename, version);
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const getDXNForRelationSchemaRef = (schema: Schema.Schema.Any): string => {
|
|
143
|
+
assertArgument(Schema.isSchema(schema), 'schema');
|
|
144
|
+
const identifier = getTypeIdentifierAnnotation(schema);
|
|
145
|
+
if (identifier) {
|
|
146
|
+
return identifier;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const typename = getSchemaTypename(schema);
|
|
150
|
+
if (!typename) {
|
|
151
|
+
throw new Error('Schema must have a typename');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return DXN.fromTypename(typename).toString();
|
|
155
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { assertArgument, invariant } from '@dxos/invariant';
|
|
8
|
+
import { DXN, ObjectId } from '@dxos/keys';
|
|
9
|
+
import { assumeType } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { type InternalObjectProps, SelfDXNId } from './model';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns a DXN for an object or schema.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const getObjectDXN = (object: any): DXN | undefined => {
|
|
19
|
+
invariant(!Schema.isSchema(object), 'schema not allowed in this function');
|
|
20
|
+
assertArgument(typeof object === 'object' && object != null, 'object', 'expected object');
|
|
21
|
+
assumeType<InternalObjectProps>(object);
|
|
22
|
+
|
|
23
|
+
if (object[SelfDXNId]) {
|
|
24
|
+
invariant(object[SelfDXNId] instanceof DXN, 'Invalid object model: invalid self dxn');
|
|
25
|
+
return object[SelfDXNId];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!ObjectId.isValid(object.id)) {
|
|
29
|
+
throw new TypeError('Object id is not valid.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return DXN.fromLocalObjectId(object.id);
|
|
33
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { log } from '@dxos/log';
|
|
9
|
+
|
|
10
|
+
import { toJsonSchema } from '../json-schema';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
DateOnly,
|
|
14
|
+
DateTime,
|
|
15
|
+
type SimpleDate,
|
|
16
|
+
type SimpleDateTime,
|
|
17
|
+
type SimpleTime,
|
|
18
|
+
TimeOnly,
|
|
19
|
+
toSimpleDate,
|
|
20
|
+
toSimpleTime,
|
|
21
|
+
} from './date';
|
|
22
|
+
|
|
23
|
+
describe.skip('date', () => {
|
|
24
|
+
test('basic', () => {
|
|
25
|
+
const date = new Date('2024-12-31T23:59:59Z');
|
|
26
|
+
expect(toSimpleDate(date)).to.deep.eq({ year: 2024, month: 12, day: 31 });
|
|
27
|
+
expect(toSimpleTime(date)).to.deep.eq({ hours: 23, minutes: 59, seconds: 59 });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Date', ({ expect }) => {
|
|
31
|
+
const jsonSchema = toJsonSchema(DateOnly);
|
|
32
|
+
log('schema', { jsonSchema });
|
|
33
|
+
const v1: SimpleDate = { year: 1999, month: 12, day: 31 };
|
|
34
|
+
const str = Schema.encodeUnknownSync(DateOnly)(v1);
|
|
35
|
+
const v2 = Schema.decodeUnknownSync(DateOnly)(str);
|
|
36
|
+
expect(v1).to.deep.eq(v2);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Time', ({ expect }) => {
|
|
40
|
+
const jsonSchema = toJsonSchema(TimeOnly);
|
|
41
|
+
log('schema', { jsonSchema });
|
|
42
|
+
const v1: SimpleTime = { hours: 23, minutes: 59, seconds: 59 };
|
|
43
|
+
const str = Schema.encodeUnknownSync(TimeOnly)(v1);
|
|
44
|
+
const v2 = Schema.decodeUnknownSync(TimeOnly)(str);
|
|
45
|
+
expect(v1).to.deep.eq(v2);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('DateTime', ({ expect }) => {
|
|
49
|
+
const jsonSchema = toJsonSchema(DateTime);
|
|
50
|
+
log('schema', { jsonSchema });
|
|
51
|
+
const v1: SimpleDateTime = { year: 1999, month: 12, day: 31, hours: 23, minutes: 59, seconds: 59 };
|
|
52
|
+
const str = Schema.encodeUnknownSync(DateTime)(v1);
|
|
53
|
+
const v2 = Schema.decodeUnknownSync(DateTime)(str);
|
|
54
|
+
expect(v1).to.deep.eq(v2);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
+
|
|
8
|
+
import { FormatAnnotation, TypeFormat } from './types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Datetime values should be stored as ISO strings or unix numbers (ms) in UTC.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: HyperFormula uses Excel's time format (null date 1900/01/01)
|
|
14
|
+
* It can be configured to use a different parser via `parseDateTime`.
|
|
15
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#date-and-time-handling
|
|
16
|
+
* https://github.com/handsontable/hyperformula/blob/master/src/DateTimeHelper.ts
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TODO(burdon): Annotations not present in JSON.
|
|
20
|
+
// TODO(burdon): Timezone.
|
|
21
|
+
// TODO(burdon): Format for timestamp (Unix UTC or ISO 8601)?
|
|
22
|
+
// TODO(burdon): Refs
|
|
23
|
+
// - https://www.npmjs.com/package/numfmt
|
|
24
|
+
// - https://date-fns.org/docs/Getting-Started
|
|
25
|
+
// - https://github.com/date-fns/tz
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Simple date compatible with HF.
|
|
29
|
+
*/
|
|
30
|
+
export const SimpleDate = Schema.Struct({
|
|
31
|
+
year: Schema.Number.pipe(Schema.between(1900, 9999)),
|
|
32
|
+
month: Schema.Number.pipe(Schema.between(1, 12)),
|
|
33
|
+
day: Schema.Number.pipe(Schema.between(1, 31)),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type SimpleDate = Schema.Schema.Type<typeof SimpleDate>;
|
|
37
|
+
|
|
38
|
+
export const toSimpleDate = (date: Date): SimpleDate => ({
|
|
39
|
+
year: date.getUTCFullYear(),
|
|
40
|
+
month: date.getUTCMonth() + 1,
|
|
41
|
+
day: date.getUTCDate(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Simple time compatible with HF.
|
|
46
|
+
*/
|
|
47
|
+
export const SimpleTime = Schema.Struct({
|
|
48
|
+
hours: Schema.Number.pipe(Schema.between(0, 23)),
|
|
49
|
+
minutes: Schema.Number.pipe(Schema.between(0, 59)),
|
|
50
|
+
seconds: Schema.Number.pipe(Schema.between(0, 59)),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type SimpleTime = Schema.Schema.Type<typeof SimpleTime>;
|
|
54
|
+
|
|
55
|
+
export const toSimpleTime = (date: Date): SimpleTime => ({
|
|
56
|
+
hours: date.getUTCHours(),
|
|
57
|
+
minutes: date.getUTCSeconds(),
|
|
58
|
+
seconds: date.getUTCSeconds(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Simple date-time compatible with HF.
|
|
63
|
+
*/
|
|
64
|
+
export const SimpleDateTime = Schema.extend(SimpleDate, SimpleTime);
|
|
65
|
+
|
|
66
|
+
export type SimpleDateTime = Schema.Schema.Type<typeof SimpleDateTime>;
|
|
67
|
+
|
|
68
|
+
export const toSimpleDateTime = (date: Date): SimpleDateTime => ({
|
|
69
|
+
...toSimpleDate(date),
|
|
70
|
+
...toSimpleTime(date),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* https://effect.website/docs/guides/schema/transformations#date-transformations
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
// TODO(burdon): Consider if transformations should be supported with Automerge.
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Format: 2018-11-13
|
|
81
|
+
*/
|
|
82
|
+
export const DateOnly = /* Schema.transformOrFail(Schema.String, SimpleDate, {
|
|
83
|
+
strict: true,
|
|
84
|
+
decode: (str, _, ast) => {
|
|
85
|
+
if (!isValidDateFormat(str)) {
|
|
86
|
+
return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected YYYY-MM-DD format'));
|
|
87
|
+
}
|
|
88
|
+
if (!isValidDate(str)) {
|
|
89
|
+
return ParseResult.fail(new ParseResult.Type(ast, str, 'Invalid date'));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const [year, month, day] = str.split('-').map(Number);
|
|
93
|
+
return ParseResult.succeed({ year, month, day });
|
|
94
|
+
},
|
|
95
|
+
encode: (date) => {
|
|
96
|
+
return ParseResult.succeed(
|
|
97
|
+
[
|
|
98
|
+
date.year.toString().padStart(4, '0'),
|
|
99
|
+
date.month.toString().padStart(2, '0'),
|
|
100
|
+
date.day.toString().padStart(2, '0'),
|
|
101
|
+
].join('-'),
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
}) */ Schema.String.pipe(
|
|
105
|
+
FormatAnnotation.set(TypeFormat.Date),
|
|
106
|
+
Schema.annotations({
|
|
107
|
+
title: 'Date',
|
|
108
|
+
description: 'Valid date in ISO format',
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Format: 20:20:39+00:00
|
|
114
|
+
*/
|
|
115
|
+
export const TimeOnly = /* Schema.transformOrFail(Schema.String, SimpleTime, {
|
|
116
|
+
strict: true,
|
|
117
|
+
decode: (str, _, ast) => {
|
|
118
|
+
if (!isValidTimeFormat(str)) {
|
|
119
|
+
return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const [hours, minutes, seconds] = str.split(':').map(Number);
|
|
123
|
+
return ParseResult.succeed({ hours, minutes, seconds });
|
|
124
|
+
},
|
|
125
|
+
encode: (time) => {
|
|
126
|
+
return ParseResult.succeed(
|
|
127
|
+
[
|
|
128
|
+
time.hours.toString().padStart(2, '0'),
|
|
129
|
+
time.minutes.toString().padStart(2, '0'),
|
|
130
|
+
time.seconds.toString().padStart(2, '0'),
|
|
131
|
+
].join(':'),
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
}) */ Schema.String.pipe(
|
|
135
|
+
FormatAnnotation.set(TypeFormat.Time),
|
|
136
|
+
Schema.annotations({
|
|
137
|
+
title: 'Time',
|
|
138
|
+
description: 'Valid time in ISO format',
|
|
139
|
+
}),
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Format: 2018-11-13T20:20:39+00:00
|
|
144
|
+
*/
|
|
145
|
+
export const DateTime = /* Schema.transformOrFail(Schema.String, SimpleDateTime, {
|
|
146
|
+
strict: false,
|
|
147
|
+
decode: (str, _, ast) => {
|
|
148
|
+
const [date, time] = str.split('T');
|
|
149
|
+
if (!isValidDateFormat(date)) {
|
|
150
|
+
return ParseResult.fail(new ParseResult.Type(ast, date, 'Expected YYYY-MM-DD format'));
|
|
151
|
+
}
|
|
152
|
+
if (!isValidDate(date)) {
|
|
153
|
+
return ParseResult.fail(new ParseResult.Type(ast, date, 'Invalid date'));
|
|
154
|
+
}
|
|
155
|
+
if (!isValidTimeFormat(time)) {
|
|
156
|
+
return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const [year, month, day] = date.split('-').map(Number);
|
|
160
|
+
const [hours, minutes, seconds] = time.split(':').map(Number);
|
|
161
|
+
return ParseResult.succeed({ year, month, day, hours, minutes, seconds });
|
|
162
|
+
},
|
|
163
|
+
encode: (datetime) => {
|
|
164
|
+
return ParseResult.succeed(
|
|
165
|
+
[
|
|
166
|
+
[
|
|
167
|
+
datetime.year.toString().padStart(4, '0'),
|
|
168
|
+
datetime.month.toString().padStart(2, '0'),
|
|
169
|
+
datetime.day.toString().padStart(2, '0'),
|
|
170
|
+
].join('-'),
|
|
171
|
+
[
|
|
172
|
+
datetime.hours.toString().padStart(2, '0'),
|
|
173
|
+
datetime.minutes.toString().padStart(2, '0'),
|
|
174
|
+
datetime.seconds.toString().padStart(2, '0'),
|
|
175
|
+
].join(':'),
|
|
176
|
+
].join('T'),
|
|
177
|
+
);
|
|
178
|
+
},
|
|
179
|
+
}) */ Schema.String.pipe(
|
|
180
|
+
FormatAnnotation.set(TypeFormat.DateTime),
|
|
181
|
+
Schema.annotations({
|
|
182
|
+
title: 'DateTime',
|
|
183
|
+
description: 'Valid date and time in ISO format',
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* https://datatracker.ietf.org/doc/html/rfc3339#appendix-A
|
|
189
|
+
*/
|
|
190
|
+
// TODO(burdon): Define duration type.
|
|
191
|
+
export const Duration = Schema.String.pipe(
|
|
192
|
+
FormatAnnotation.set(TypeFormat.Duration),
|
|
193
|
+
Schema.annotations({
|
|
194
|
+
title: 'Duration',
|
|
195
|
+
description: 'Duration in ISO 8601 format',
|
|
196
|
+
[SchemaAST.ExamplesAnnotationId]: ['1h', '3D'],
|
|
197
|
+
}),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
//
|
|
201
|
+
// Utils
|
|
202
|
+
//
|
|
203
|
+
|
|
204
|
+
// YYYY-MM-DD
|
|
205
|
+
const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
206
|
+
|
|
207
|
+
const _isValidDateFormat = (str: string) => DATE_REGEX.test(str);
|
|
208
|
+
|
|
209
|
+
const _isValidDate = (str: string) => {
|
|
210
|
+
const date = new Date(str);
|
|
211
|
+
return !isNaN(date.getTime()) && date.toISOString().startsWith(str);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// HH:mm:ss
|
|
215
|
+
const TIME_REGEX = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
|
|
216
|
+
|
|
217
|
+
const _isValidTimeFormat = (str: string) => TIME_REGEX.test(str);
|