@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,346 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { QueryAST } from '@dxos/echo-protocol';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
import * as Filter from './Filter';
|
|
13
|
+
import * as Obj from './Obj';
|
|
14
|
+
import * as Order from './Order';
|
|
15
|
+
import * as Query from './Query';
|
|
16
|
+
import * as Ref from './Ref';
|
|
17
|
+
import { TestSchema } from './testing';
|
|
18
|
+
|
|
19
|
+
describe('query api', () => {
|
|
20
|
+
describe('Query', () => {
|
|
21
|
+
test('get all people', () => {
|
|
22
|
+
const getAllPeople = Query.type(TestSchema.Person);
|
|
23
|
+
|
|
24
|
+
log('query', { ast: getAllPeople.ast });
|
|
25
|
+
Schema.validateSync(QueryAST.Query)(getAllPeople.ast);
|
|
26
|
+
log('getAllPeople', { ast: getAllPeople.ast });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('get all people ordered by name', () => {
|
|
30
|
+
const getAllPeopleOrderedByName = Query.type(TestSchema.Person).orderBy(Order.property('name', 'asc'));
|
|
31
|
+
|
|
32
|
+
log('query', { ast: getAllPeopleOrderedByName.ast });
|
|
33
|
+
Schema.validateSync(QueryAST.Query)(getAllPeopleOrderedByName.ast);
|
|
34
|
+
log('getAllPeopleOrderedByName', { ast: getAllPeopleOrderedByName.ast });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('get all people named Fred', () => {
|
|
38
|
+
const PeopleNamedFred = Query.select(Filter.type(TestSchema.Person, { name: 'Fred' }));
|
|
39
|
+
|
|
40
|
+
log('query', { ast: PeopleNamedFred.ast });
|
|
41
|
+
Schema.validateSync(QueryAST.Query)(PeopleNamedFred.ast);
|
|
42
|
+
log('PeopleNamedFred', { ast: PeopleNamedFred.ast });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('get all people with field of "label" set to "Research"', () => {
|
|
46
|
+
const PeopleWithFieldLabelSetToResearch = Query.select(
|
|
47
|
+
Filter.type(TestSchema.Person, { fields: Filter.contains({ label: 'label', value: 'Research' }) }),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
log('query', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
51
|
+
Schema.validateSync(QueryAST.Query)(PeopleWithFieldLabelSetToResearch.ast);
|
|
52
|
+
log('PeopleWithFieldLabelSetToResearch', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('get all orgs with property "label" set to "Research"', () => {
|
|
56
|
+
const OrgsWithPropertyLabelSetToResearch = Query.select(
|
|
57
|
+
Filter.type(TestSchema.Organization, { properties: { label: 'Research' } }),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
log('query', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
61
|
+
Schema.validateSync(QueryAST.Query)(OrgsWithPropertyLabelSetToResearch.ast);
|
|
62
|
+
log('OrgsWithPropertyLabelSetToResearch', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('get all orgs Fred worked for since 2020', () => {
|
|
66
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
67
|
+
const OrganizationsFredWorkedForSince2020 = Query.select(Filter.type(TestSchema.Person, { id: fred.id }))
|
|
68
|
+
.sourceOf(TestSchema.EmployedBy, { since: Filter.gt('2020') })
|
|
69
|
+
.target();
|
|
70
|
+
|
|
71
|
+
log('query', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
72
|
+
Schema.validateSync(QueryAST.Query)(OrganizationsFredWorkedForSince2020.ast);
|
|
73
|
+
log('OrganizationsFredWorkedForSince2020', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('get all tasks for Fred', () => {
|
|
77
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
78
|
+
const TasksForFred = Query.select(Filter.type(TestSchema.Person, { id: fred.id })).referencedBy(
|
|
79
|
+
TestSchema.Task,
|
|
80
|
+
'assignee',
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
log('query', { ast: TasksForFred.ast });
|
|
84
|
+
Schema.validateSync(QueryAST.Query)(TasksForFred.ast);
|
|
85
|
+
log('TasksForFred', { ast: TasksForFred.ast });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('get all tasks for employees of Cyberdyne', () => {
|
|
89
|
+
const TasksForEmployeesOfCyberdyne = Query.select(Filter.type(TestSchema.Organization, { name: 'Cyberdyne' }))
|
|
90
|
+
.targetOf(TestSchema.EmployedBy)
|
|
91
|
+
.source()
|
|
92
|
+
.referencedBy(TestSchema.Task, 'assignee');
|
|
93
|
+
|
|
94
|
+
log('query', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
95
|
+
Schema.validateSync(QueryAST.Query)(TasksForEmployeesOfCyberdyne.ast);
|
|
96
|
+
log('TasksForEmployeesOfCyberdyne', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('get all people or orgs', () => {
|
|
100
|
+
const PeopleOrOrganizations = Query.all(
|
|
101
|
+
Query.select(Filter.type(TestSchema.Person)),
|
|
102
|
+
Query.select(Filter.type(TestSchema.Organization)),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
log('query', { ast: PeopleOrOrganizations.ast });
|
|
106
|
+
Schema.validateSync(QueryAST.Query)(PeopleOrOrganizations.ast);
|
|
107
|
+
log('PeopleOrOrganizations', { ast: PeopleOrOrganizations.ast });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('get all people not in orgs', () => {
|
|
111
|
+
const PeopleNotInOrganizations = Query.without(
|
|
112
|
+
Query.select(Filter.type(TestSchema.Person)),
|
|
113
|
+
Query.select(Filter.type(TestSchema.Person)).sourceOf(TestSchema.EmployedBy).source(),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
log('query', { ast: PeopleNotInOrganizations.ast });
|
|
117
|
+
Schema.validateSync(QueryAST.Query)(PeopleNotInOrganizations.ast);
|
|
118
|
+
log('PeopleNotInOrganizations', { ast: PeopleNotInOrganizations.ast });
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('get assignees of all tasks created after 2020', () => {
|
|
122
|
+
const AssigneesOfAllTasksCreatedAfter2020 = Query.select(
|
|
123
|
+
Filter.type(TestSchema.Task, { deadline: Filter.gt('2020') }),
|
|
124
|
+
).reference('assignee');
|
|
125
|
+
|
|
126
|
+
log('query', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
127
|
+
Schema.validateSync(QueryAST.Query)(AssigneesOfAllTasksCreatedAfter2020.ast);
|
|
128
|
+
log('AssigneesOfAllTasksCreatedAfter2020', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('untyped full-text search', () => {
|
|
132
|
+
const contactFullTextSearch = Query.select(Filter.text('Bill'));
|
|
133
|
+
|
|
134
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
135
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
136
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
137
|
+
{
|
|
138
|
+
"filter": {
|
|
139
|
+
"searchKind": undefined,
|
|
140
|
+
"text": "Bill",
|
|
141
|
+
"type": "text-search",
|
|
142
|
+
},
|
|
143
|
+
"type": "select",
|
|
144
|
+
}
|
|
145
|
+
`);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('typed full-text search', () => {
|
|
149
|
+
const contactFullTextSearch = Query.select(Filter.type(TestSchema.Person)).select(Filter.text('Bill'));
|
|
150
|
+
|
|
151
|
+
log('query', { ast: contactFullTextSearch.ast });
|
|
152
|
+
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
153
|
+
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
154
|
+
{
|
|
155
|
+
"filter": {
|
|
156
|
+
"searchKind": undefined,
|
|
157
|
+
"text": "Bill",
|
|
158
|
+
"type": "text-search",
|
|
159
|
+
},
|
|
160
|
+
"selection": {
|
|
161
|
+
"filter": {
|
|
162
|
+
"id": undefined,
|
|
163
|
+
"props": {},
|
|
164
|
+
"type": "object",
|
|
165
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
166
|
+
},
|
|
167
|
+
"type": "select",
|
|
168
|
+
},
|
|
169
|
+
"type": "filter",
|
|
170
|
+
}
|
|
171
|
+
`);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('filter by ref', () => {
|
|
175
|
+
const fred = Obj.make(TestSchema.Person, { name: 'Fred' });
|
|
176
|
+
const tasksByFred = Filter.type(TestSchema.Task, { assignee: Ref.make(fred) });
|
|
177
|
+
expect(tasksByFred.ast).toEqual({
|
|
178
|
+
props: {
|
|
179
|
+
assignee: {
|
|
180
|
+
operator: 'eq',
|
|
181
|
+
type: 'compare',
|
|
182
|
+
value: {
|
|
183
|
+
'/': DXN.fromLocalObjectId(fred.id).toString(),
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
type: 'object',
|
|
188
|
+
typename: 'dxn:type:example.com/type/Task:0.1.0',
|
|
189
|
+
});
|
|
190
|
+
log('tasksByFred', { ast: tasksByFred.ast });
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test('select orgs and people', () => {
|
|
194
|
+
const orgsAndPeople = Query.select(
|
|
195
|
+
Filter.or(Filter.type(TestSchema.Organization), Filter.type(TestSchema.Person)),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
Schema.validateSync(QueryAST.Query)(orgsAndPeople.ast);
|
|
199
|
+
expect(orgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
200
|
+
{
|
|
201
|
+
"filter": {
|
|
202
|
+
"filters": [
|
|
203
|
+
{
|
|
204
|
+
"id": undefined,
|
|
205
|
+
"props": {},
|
|
206
|
+
"type": "object",
|
|
207
|
+
"typename": "dxn:type:example.com/type/Organization:0.1.0",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": undefined,
|
|
211
|
+
"props": {},
|
|
212
|
+
"type": "object",
|
|
213
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
"type": "or",
|
|
217
|
+
},
|
|
218
|
+
"type": "select",
|
|
219
|
+
}
|
|
220
|
+
`);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test('select everything but orgs and people', () => {
|
|
224
|
+
const everythingButOrgsAndPeople = Query.select(
|
|
225
|
+
Filter.not(Filter.or(Filter.type(TestSchema.Organization), Filter.type(TestSchema.Person))),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
Schema.validateSync(QueryAST.Query)(everythingButOrgsAndPeople.ast);
|
|
229
|
+
expect(everythingButOrgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
230
|
+
{
|
|
231
|
+
"filter": {
|
|
232
|
+
"filter": {
|
|
233
|
+
"filters": [
|
|
234
|
+
{
|
|
235
|
+
"id": undefined,
|
|
236
|
+
"props": {},
|
|
237
|
+
"type": "object",
|
|
238
|
+
"typename": "dxn:type:example.com/type/Organization:0.1.0",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"id": undefined,
|
|
242
|
+
"props": {},
|
|
243
|
+
"type": "object",
|
|
244
|
+
"typename": "dxn:type:example.com/type/Person:0.1.0",
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
"type": "or",
|
|
248
|
+
},
|
|
249
|
+
"type": "not",
|
|
250
|
+
},
|
|
251
|
+
"type": "select",
|
|
252
|
+
}
|
|
253
|
+
`);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test('select deleted tasks', () => {
|
|
257
|
+
const deletedTasks = Query.select(Filter.type(TestSchema.Task)).options({
|
|
258
|
+
deleted: 'only',
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
Schema.validateSync(QueryAST.Query)(deletedTasks.ast);
|
|
262
|
+
expect(deletedTasks.ast).toMatchInlineSnapshot(`
|
|
263
|
+
{
|
|
264
|
+
"options": {
|
|
265
|
+
"deleted": "only",
|
|
266
|
+
},
|
|
267
|
+
"query": {
|
|
268
|
+
"filter": {
|
|
269
|
+
"id": undefined,
|
|
270
|
+
"props": {},
|
|
271
|
+
"type": "object",
|
|
272
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
273
|
+
},
|
|
274
|
+
"type": "select",
|
|
275
|
+
},
|
|
276
|
+
"type": "options",
|
|
277
|
+
}
|
|
278
|
+
`);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test('filter by tags', () => {
|
|
282
|
+
const query = Query.select(Filter.type(TestSchema.Task)).select(Filter.tag('important'));
|
|
283
|
+
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
284
|
+
expect(query.ast).toMatchInlineSnapshot(`
|
|
285
|
+
{
|
|
286
|
+
"filter": {
|
|
287
|
+
"tag": "important",
|
|
288
|
+
"type": "tag",
|
|
289
|
+
},
|
|
290
|
+
"selection": {
|
|
291
|
+
"filter": {
|
|
292
|
+
"id": undefined,
|
|
293
|
+
"props": {},
|
|
294
|
+
"type": "object",
|
|
295
|
+
"typename": "dxn:type:example.com/type/Task:0.1.0",
|
|
296
|
+
},
|
|
297
|
+
"type": "select",
|
|
298
|
+
},
|
|
299
|
+
"type": "filter",
|
|
300
|
+
}
|
|
301
|
+
`);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test.skip('chain', () => {
|
|
305
|
+
// NOTE: Can't support props without type since they can't be inferred.
|
|
306
|
+
// const f1: Filter<Person> = Filter.props({ name: 'Fred' });
|
|
307
|
+
|
|
308
|
+
// const x = Query.select(Filter.props({ id: '123' }));
|
|
309
|
+
const y = Query.select(Filter.type(TestSchema.Person));
|
|
310
|
+
|
|
311
|
+
const or = Filter.or(
|
|
312
|
+
Filter.type(TestSchema.Person, { id: Filter.in('1', '2', '3') }),
|
|
313
|
+
Filter.type(TestSchema.Organization),
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
const and = Filter.and(
|
|
317
|
+
Filter.type(TestSchema.Person, { id: Filter.in('1', '2', '3') }),
|
|
318
|
+
Filter.type(TestSchema.Person, { name: 'Fred' }),
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
const q = Query
|
|
322
|
+
//
|
|
323
|
+
// NOTE: Can't support functions since they can't be serialized (to server).
|
|
324
|
+
// .filter((object) => Math.random() > 0.5)
|
|
325
|
+
.select(Filter.type(TestSchema.Person))
|
|
326
|
+
.select(Filter.type(TestSchema.Person, { name: 'Fred' }))
|
|
327
|
+
.select({ age: Filter.between(20, 40) })
|
|
328
|
+
.select(
|
|
329
|
+
Filter.and(
|
|
330
|
+
Filter.type(TestSchema.Person),
|
|
331
|
+
Filter.type(TestSchema.Person, { name: Filter.in('bob', 'bill') }),
|
|
332
|
+
),
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
log('stuff', { fOr: or, fAnd: and, q, y });
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
describe('Filter', () => {
|
|
340
|
+
test('Filter.or(Filter.typename(...))', () => {
|
|
341
|
+
const filter = Filter.or(Filter.typename('example.com/type/Person'));
|
|
342
|
+
// TODO(dmaretskyi): Give vitest type-tests a try.
|
|
343
|
+
const _isAssignable: Obj.Any = null as any as Filter.Type<typeof filter>;
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
package/src/Query.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as EffectArray from 'effect/Array';
|
|
6
|
+
import type * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { type QueryAST } from '@dxos/echo-protocol';
|
|
9
|
+
|
|
10
|
+
import * as Filter from './Filter';
|
|
11
|
+
import { getTypeDXNFromSpecifier } from './internal';
|
|
12
|
+
import type * as Order from './Order';
|
|
13
|
+
import type * as Ref from './Ref';
|
|
14
|
+
import type * as Type$ from './Type';
|
|
15
|
+
|
|
16
|
+
// TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
|
|
17
|
+
// TODO(dmaretskyi): Undirected relation traversals.
|
|
18
|
+
// TODO(wittjosiah): Make Filter & Query pipeable.
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* All property paths inside T that are references.
|
|
22
|
+
*/
|
|
23
|
+
// TODO(dmaretskyi): Filter only properties that are references (or optional references, or unions that include references).
|
|
24
|
+
type RefPropKey<T> = keyof T & string;
|
|
25
|
+
|
|
26
|
+
// TODO(burdon): Narrow T to Entity.Unknown?
|
|
27
|
+
export interface Query<T> {
|
|
28
|
+
// TODO(dmaretskyi): See new effect-schema approach to variance.
|
|
29
|
+
'~Query': { value: T };
|
|
30
|
+
|
|
31
|
+
ast: QueryAST.Query;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Filter the current selection based on a filter.
|
|
35
|
+
* @param filter - Filter to select the objects.
|
|
36
|
+
* @returns Query for the selected objects.
|
|
37
|
+
*/
|
|
38
|
+
select(filter: Filter.Filter<T>): Query<T>;
|
|
39
|
+
select(props: Filter.Props<T>): Query<T>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Traverse an outgoing reference.
|
|
43
|
+
* @param key - Property path inside T that is a reference or optional reference.
|
|
44
|
+
* @returns Query for the target of the reference.
|
|
45
|
+
*/
|
|
46
|
+
reference<K extends RefPropKey<T>>(
|
|
47
|
+
key: K,
|
|
48
|
+
): Query<
|
|
49
|
+
T[K] extends Ref.Any
|
|
50
|
+
? Ref.Target<T[K]>
|
|
51
|
+
: T[K] extends Ref.Any | undefined
|
|
52
|
+
? Ref.Target<Exclude<T[K], undefined>>
|
|
53
|
+
: never
|
|
54
|
+
>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Find objects referencing this object.
|
|
58
|
+
* @param target - Schema of the referencing object.
|
|
59
|
+
* @param key - Property path inside the referencing object that is a reference.
|
|
60
|
+
* @returns Query for the referencing objects.
|
|
61
|
+
*/
|
|
62
|
+
// TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
|
|
63
|
+
// TODO(dmaretskyi): Ability to go through arrays of references.
|
|
64
|
+
referencedBy<S extends Schema.Schema.All>(
|
|
65
|
+
target: S | string,
|
|
66
|
+
key: RefPropKey<Schema.Schema.Type<S>>,
|
|
67
|
+
): Query<Schema.Schema.Type<S>>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Find relations where this object is the source.
|
|
71
|
+
* @returns Query for the relation objects.
|
|
72
|
+
* @param relation - Schema of the relation.
|
|
73
|
+
* @param predicates - Predicates to filter the relation objects.
|
|
74
|
+
*/
|
|
75
|
+
sourceOf<S extends Schema.Schema.All>(
|
|
76
|
+
relation: S | string,
|
|
77
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
78
|
+
): Query<Schema.Schema.Type<S>>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Find relations where this object is the target.
|
|
82
|
+
* @returns Query for the relation objects.
|
|
83
|
+
* @param relation - Schema of the relation.
|
|
84
|
+
* @param predicates - Predicates to filter the relation objects.
|
|
85
|
+
*/
|
|
86
|
+
targetOf<S extends Schema.Schema.All>(
|
|
87
|
+
relation: S | string,
|
|
88
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
89
|
+
): Query<Schema.Schema.Type<S>>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* For a query for relations, get the source objects.
|
|
93
|
+
* @returns Query for the source objects.
|
|
94
|
+
*/
|
|
95
|
+
source(): Query<Type$.Relation.Source<T>>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* For a query for relations, get the target objects.
|
|
99
|
+
* @returns Query for the target objects.
|
|
100
|
+
*/
|
|
101
|
+
target(): Query<Type$.Relation.Target<T>>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Order the query results.
|
|
105
|
+
* Orders are specified in priority order. The first order will be applied first, etc.
|
|
106
|
+
* @param order - Order to sort the results.
|
|
107
|
+
* @returns Query for the ordered results.
|
|
108
|
+
*/
|
|
109
|
+
orderBy(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Add options to a query.
|
|
113
|
+
*/
|
|
114
|
+
options(options: QueryAST.QueryOptions): Query<T>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type Any = Query<any>;
|
|
118
|
+
|
|
119
|
+
export type Type<Q extends Any> = Q extends Query<infer T> ? T : never;
|
|
120
|
+
|
|
121
|
+
class QueryClass implements Any {
|
|
122
|
+
private static variance: Any['~Query'] = {} as Any['~Query'];
|
|
123
|
+
|
|
124
|
+
constructor(public readonly ast: QueryAST.Query) {}
|
|
125
|
+
|
|
126
|
+
'~Query' = QueryClass.variance;
|
|
127
|
+
|
|
128
|
+
select(filter: Filter.Any | Filter.Props<any>): Any {
|
|
129
|
+
if (Filter.is(filter)) {
|
|
130
|
+
return new QueryClass({
|
|
131
|
+
type: 'filter',
|
|
132
|
+
selection: this.ast,
|
|
133
|
+
filter: filter.ast,
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
return new QueryClass({
|
|
137
|
+
type: 'filter',
|
|
138
|
+
selection: this.ast,
|
|
139
|
+
filter: Filter.props(filter).ast,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
reference(key: string): Any {
|
|
145
|
+
return new QueryClass({
|
|
146
|
+
type: 'reference-traversal',
|
|
147
|
+
anchor: this.ast,
|
|
148
|
+
property: key,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
referencedBy(target: Schema.Schema.All | string, key: string): Any {
|
|
153
|
+
const dxn = getTypeDXNFromSpecifier(target);
|
|
154
|
+
return new QueryClass({
|
|
155
|
+
type: 'incoming-references',
|
|
156
|
+
anchor: this.ast,
|
|
157
|
+
property: key,
|
|
158
|
+
typename: dxn.toString(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
sourceOf(relation: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
163
|
+
return new QueryClass({
|
|
164
|
+
type: 'relation',
|
|
165
|
+
anchor: this.ast,
|
|
166
|
+
direction: 'outgoing',
|
|
167
|
+
filter: Filter.type(relation, predicates).ast,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
targetOf(relation: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
172
|
+
return new QueryClass({
|
|
173
|
+
type: 'relation',
|
|
174
|
+
anchor: this.ast,
|
|
175
|
+
direction: 'incoming',
|
|
176
|
+
filter: Filter.type(relation, predicates).ast,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
source(): Any {
|
|
181
|
+
return new QueryClass({
|
|
182
|
+
type: 'relation-traversal',
|
|
183
|
+
anchor: this.ast,
|
|
184
|
+
direction: 'source',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
target(): Any {
|
|
189
|
+
return new QueryClass({
|
|
190
|
+
type: 'relation-traversal',
|
|
191
|
+
anchor: this.ast,
|
|
192
|
+
direction: 'target',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
orderBy(...order: Order.Order<any>[]): Any {
|
|
197
|
+
return new QueryClass({
|
|
198
|
+
type: 'order',
|
|
199
|
+
query: this.ast,
|
|
200
|
+
order: order.map((o) => o.ast),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
options(options: QueryAST.QueryOptions): Any {
|
|
205
|
+
return new QueryClass({
|
|
206
|
+
type: 'options',
|
|
207
|
+
query: this.ast,
|
|
208
|
+
options,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export const is = (value: unknown): value is Any => {
|
|
214
|
+
return typeof value === 'object' && value !== null && '~Query' in value;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** Construct a query from an ast. */
|
|
218
|
+
export const fromAst = (ast: QueryAST.Query): Any => {
|
|
219
|
+
return new QueryClass(ast);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Select objects based on a filter.
|
|
224
|
+
* @param filter - Filter to select the objects.
|
|
225
|
+
* @returns Query for the selected objects.
|
|
226
|
+
*/
|
|
227
|
+
export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> => {
|
|
228
|
+
return new QueryClass({
|
|
229
|
+
type: 'select',
|
|
230
|
+
filter: filter.ast,
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Query for objects of a given schema.
|
|
236
|
+
* @param schema - Schema of the objects.
|
|
237
|
+
* @param predicates - Predicates to filter the objects.
|
|
238
|
+
* @returns Query for the objects.
|
|
239
|
+
*
|
|
240
|
+
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
241
|
+
*/
|
|
242
|
+
export const type = (schema: Schema.Schema.All | string, predicates?: Filter.Props<unknown>): Any => {
|
|
243
|
+
return new QueryClass({
|
|
244
|
+
type: 'select',
|
|
245
|
+
filter: Filter.type(schema, predicates).ast,
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Combine results of multiple queries.
|
|
251
|
+
* @param queries - Queries to combine.
|
|
252
|
+
* @returns Query for the combined results.
|
|
253
|
+
*/
|
|
254
|
+
// TODO(dmaretskyi): Rename to `combine` or `union`.
|
|
255
|
+
export const all = (...queries: Any[]): Any => {
|
|
256
|
+
if (queries.length === 0) {
|
|
257
|
+
throw new TypeError(
|
|
258
|
+
'Query.all combines results of multiple queries, to query all objects use Query.select(Filter.everything())',
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
return new QueryClass({
|
|
262
|
+
type: 'union',
|
|
263
|
+
queries: queries.map((q) => q.ast),
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Subtract one query from another.
|
|
269
|
+
* @param source - Query to subtract from.
|
|
270
|
+
* @param exclude - Query to subtract.
|
|
271
|
+
* @returns Query for the results of the source query minus the results of the exclude query.
|
|
272
|
+
*/
|
|
273
|
+
export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
|
|
274
|
+
return new QueryClass({
|
|
275
|
+
type: 'set-difference',
|
|
276
|
+
source: source.ast,
|
|
277
|
+
exclude: exclude.ast,
|
|
278
|
+
});
|
|
279
|
+
};
|