@dxos/echo 0.8.4-main.406dc2a → 0.8.4-main.59c2e9b
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 -2
- package/dist/lib/browser/Annotation.mjs +33 -0
- package/dist/lib/browser/Database.mjs +18 -0
- package/dist/lib/browser/Entity.mjs +52 -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 +62 -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 +20 -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 +91 -0
- package/dist/lib/browser/Obj.mjs.map +7 -0
- package/dist/lib/browser/Order.mjs +13 -0
- package/dist/lib/browser/Order.mjs.map +7 -0
- package/dist/lib/browser/Query.mjs +27 -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 +23 -0
- package/dist/lib/browser/Ref.mjs.map +7 -0
- package/dist/lib/browser/Relation.mjs +85 -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 +26 -0
- package/dist/lib/browser/Tag.mjs.map +7 -0
- package/dist/lib/browser/Type.mjs +48 -0
- package/dist/lib/browser/Type.mjs.map +7 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs +24 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs.map +7 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs +250 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs.map +7 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs +158 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs.map +7 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs +133 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-BJPE6CIC.mjs +3847 -0
- package/dist/lib/browser/chunk-BJPE6CIC.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-CJ5YELTO.mjs +39 -0
- package/dist/lib/browser/chunk-CJ5YELTO.mjs.map +7 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs +40 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs.map +7 -0
- package/dist/lib/browser/chunk-FRDT7RA4.mjs +403 -0
- package/dist/lib/browser/chunk-FRDT7RA4.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-IXVWLTG7.mjs +9 -0
- package/dist/lib/browser/chunk-IXVWLTG7.mjs.map +7 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs +43 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-KQQGVHFN.mjs +143 -0
- package/dist/lib/browser/chunk-KQQGVHFN.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-NOPVNWPT.mjs +204 -0
- package/dist/lib/browser/chunk-NOPVNWPT.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs +74 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs.map +7 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs +283 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs +57 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs.map +7 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs +98 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs.map +7 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs +41 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs +69 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs +288 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs +9 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -22
- package/dist/lib/browser/internal/index.mjs +245 -120
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +295 -226
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/Annotation.mjs +33 -0
- package/dist/lib/node-esm/Annotation.mjs.map +7 -0
- package/dist/lib/node-esm/Database.mjs +18 -0
- package/dist/lib/node-esm/Database.mjs.map +7 -0
- package/dist/lib/node-esm/Entity.mjs +52 -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 +62 -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 +20 -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 +91 -0
- package/dist/lib/node-esm/Obj.mjs.map +7 -0
- package/dist/lib/node-esm/Order.mjs +13 -0
- package/dist/lib/node-esm/Order.mjs.map +7 -0
- package/dist/lib/node-esm/Query.mjs +27 -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 +23 -0
- package/dist/lib/node-esm/Ref.mjs.map +7 -0
- package/dist/lib/node-esm/Relation.mjs +85 -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 +26 -0
- package/dist/lib/node-esm/Tag.mjs.map +7 -0
- package/dist/lib/node-esm/Type.mjs +48 -0
- package/dist/lib/node-esm/Type.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs +250 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs +158 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.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-ANLVLWME.mjs +98 -0
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs +57 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs +133 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.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-ILMLLM4R.mjs +204 -0
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs +43 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs +3847 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs +9 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.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-NBWL7UCZ.mjs +40 -0
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs +143 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs +41 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs +288 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs +9 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs +403 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs +69 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs +74 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs +283 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs +39 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs +24 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +72 -22
- package/dist/lib/node-esm/internal/index.mjs +245 -120
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +295 -226
- 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 +194 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +142 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/{errors.d.ts → Err.d.ts} +23 -31
- 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 +302 -99
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +115 -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 +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +13 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +242 -22
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -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 +225 -72
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +15 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +170 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -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/api/annotations.d.ts +23 -0
- package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/api/entity.d.ts +13 -0
- package/dist/types/src/internal/api/entity.d.ts.map +1 -0
- package/dist/types/src/internal/api/index.d.ts +15 -0
- package/dist/types/src/internal/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/api/meta.d.ts +42 -0
- package/dist/types/src/internal/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/api/sorting.d.ts +24 -0
- package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/api/version.d.ts +42 -0
- package/dist/types/src/internal/api/version.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +20 -0
- package/dist/types/src/internal/entities/entity.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 +77 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +18 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +62 -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/format.d.ts +4 -2
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +5 -3
- package/dist/types/src/internal/formats/select.d.ts.map +1 -1
- package/dist/types/src/internal/formats/string.d.ts +4 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +13 -9
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +7 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- 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.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +2 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -1
- 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.map +1 -0
- package/dist/types/src/internal/object/clone.d.ts +8 -0
- package/dist/types/src/internal/object/clone.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +10 -11
- 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 +2 -2
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/object/ids.d.ts.map +1 -1
- package/dist/types/src/internal/object/index.d.ts +6 -11
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +14 -9
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +1 -14
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/set-value.d.ts +7 -0
- package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/snapshot.d.ts +6 -0
- package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +8 -14
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +15 -12
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref-array.d.ts +4 -4
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +27 -16
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +24 -12
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +1 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +26 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +37 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +5 -2
- package/dist/types/src/internal/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/{object → types}/meta.d.ts +12 -11
- 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/{object → types}/version.d.ts +3 -2
- 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 -3
- 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 +303 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +160 -45
- package/src/Annotation.ts +18 -0
- package/src/Database.ts +336 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +217 -0
- package/src/{errors.ts → Err.ts} +2 -2
- 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.test.ts +386 -0
- package/src/Obj.ts +449 -275
- package/src/Order.ts +44 -0
- package/src/Query.test.ts +465 -0
- package/src/Query.ts +296 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +26 -9
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +411 -60
- package/src/SchemaRegistry.ts +105 -0
- package/src/{query/tag.ts → Tag.ts} +10 -7
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +361 -114
- package/src/index.ts +16 -6
- package/src/internal/README.md +100 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +18 -20
- package/src/internal/annotations/annotations.ts +460 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +72 -0
- package/src/internal/api/annotations.ts +60 -0
- package/src/internal/api/entity.ts +29 -0
- package/src/internal/api/index.ts +19 -0
- package/src/internal/api/meta.ts +88 -0
- package/src/internal/api/sorting.ts +53 -0
- package/src/internal/api/version.ts +96 -0
- package/src/internal/entities/entity.ts +126 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +134 -0
- package/src/internal/entities/object.ts +60 -0
- package/src/internal/entities/relation.ts +173 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +1 -1
- package/src/internal/formats/date.ts +5 -5
- package/src/internal/formats/format.test.ts +5 -5
- package/src/internal/formats/format.ts +8 -6
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +4 -4
- package/src/internal/formats/select.ts +5 -3
- package/src/internal/formats/string.ts +14 -9
- package/src/internal/formats/types.ts +53 -42
- package/src/internal/index.ts +30 -13
- package/src/internal/{json → json-schema}/annotations.ts +1 -1
- package/src/internal/json-schema/index.ts +2 -0
- package/src/internal/json-schema/json-schema-type.ts +5 -4
- package/src/internal/{json → json-schema}/json-schema.test.ts +73 -69
- package/src/internal/{json → json-schema}/json-schema.ts +17 -8
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/common.ts +3 -4
- package/src/internal/object/{create.test.ts → create-object.test.ts} +31 -33
- package/src/internal/object/{create.ts → create-object.ts} +36 -37
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +6 -11
- package/src/internal/object/inspect.ts +5 -7
- package/src/internal/object/json-serializer.test.ts +35 -37
- package/src/internal/object/json-serializer.ts +65 -102
- package/src/internal/object/schema-validator.ts +2 -237
- package/src/internal/object/set-value.test.ts +281 -0
- package/src/internal/object/set-value.ts +165 -0
- package/src/internal/object/snapshot.ts +70 -0
- package/src/internal/object/typed-object.test.ts +11 -11
- package/src/internal/object/typed-object.ts +8 -66
- package/src/internal/proxy/change-context.ts +138 -0
- package/src/internal/proxy/change.test.ts +519 -0
- package/src/internal/proxy/define-hidden-property.ts +14 -0
- package/src/internal/proxy/errors.ts +42 -0
- package/src/internal/proxy/event-batch.ts +44 -0
- package/src/internal/proxy/handler.test.ts +51 -91
- package/src/internal/proxy/index.ts +17 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +96 -0
- package/src/internal/proxy/ownership.ts +253 -0
- package/src/internal/proxy/proxy-types.ts +23 -0
- package/src/internal/proxy/proxy-utils.ts +150 -0
- package/src/internal/proxy/reactive-array.ts +71 -0
- package/src/internal/proxy/reactive.ts +69 -0
- package/src/internal/proxy/schema-validator.ts +244 -0
- package/src/internal/proxy/schema.test.ts +27 -18
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +264 -48
- package/src/internal/proxy/typed-handler.ts +275 -61
- package/src/internal/proxy/typed-object.test.ts +43 -27
- package/src/internal/ref/ref-array.ts +4 -4
- package/src/internal/ref/ref.test.ts +9 -8
- package/src/internal/ref/ref.ts +81 -54
- package/src/internal/{projection → schema}/compose.test.ts +8 -9
- package/src/internal/{projection → schema}/compose.ts +1 -1
- package/src/internal/schema/echo-schema.ts +73 -33
- package/src/internal/schema/index.ts +1 -4
- package/src/internal/schema/manipulation.ts +1 -1
- package/src/internal/schema/persistent-schema.ts +27 -0
- package/src/internal/types/base.ts +43 -0
- package/src/internal/types/entity.ts +54 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/{object → types}/meta.ts +22 -17
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +238 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-HKFCK2GL.mjs +0 -175
- package/dist/lib/browser/chunk-HKFCK2GL.mjs.map +0 -7
- package/dist/lib/browser/chunk-MAAYELT7.mjs +0 -830
- package/dist/lib/browser/chunk-MAAYELT7.mjs.map +0 -7
- package/dist/lib/browser/chunk-MB6MMNFP.mjs +0 -3857
- package/dist/lib/browser/chunk-MB6MMNFP.mjs.map +0 -7
- package/dist/lib/browser/query/index.mjs +0 -15
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs +0 -830
- package/dist/lib/node-esm/chunk-5NWDGIBT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs +0 -175
- package/dist/lib/node-esm/chunk-AUAH4E2J.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BQRA4VLX.mjs +0 -3857
- package/dist/lib/node-esm/chunk-BQRA4VLX.mjs.map +0 -7
- package/dist/lib/node-esm/query/index.mjs +0 -15
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -125
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -455
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -3
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/query/tag.d.ts +0 -17
- package/dist/types/src/query/tag.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.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/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -219
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/index.ts +0 -6
- package/src/internal/testing/types.ts +0 -211
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -91
- /package/dist/lib/browser/{query/index.mjs.map → Annotation.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → browser/Database.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
|
@@ -1,176 +0,0 @@
|
|
|
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 { Reference } from '@dxos/echo-protocol';
|
|
9
|
-
import { type JsonPath, splitJsonPath } from '@dxos/effect';
|
|
10
|
-
import { DXN, type ObjectId } from '@dxos/keys';
|
|
11
|
-
import { getDeep, setDeep } from '@dxos/util';
|
|
12
|
-
|
|
13
|
-
import { getSchemaDXN } from '../ast';
|
|
14
|
-
import { type EntityKindId, type ObjectMeta, getType, getTypename } from '../object';
|
|
15
|
-
import { ATTR_META } from '../object/model';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Base type for all data objects (reactive, ECHO, and other raw objects).
|
|
19
|
-
* NOTE: This describes the base type for all database objects.
|
|
20
|
-
* It is stricter than `T extends {}` or `T extends object`.
|
|
21
|
-
*/
|
|
22
|
-
// TODO(dmaretskyi): Rename AnyProperties.
|
|
23
|
-
// TODO(dmaretskyi): Prefer `Record<string, unknown>` over `any`.
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated use Obj.Any
|
|
26
|
-
*/
|
|
27
|
-
export type BaseObject = Record<string, any>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Marker interface for object with an `id`.
|
|
31
|
-
*/
|
|
32
|
-
export interface HasId {
|
|
33
|
-
readonly id: ObjectId;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// TODO(dmaretskyi): Remove; this type effectively disables type safety due to `any`.
|
|
37
|
-
export type WithId<T extends BaseObject = BaseObject> = T & HasId;
|
|
38
|
-
|
|
39
|
-
export type ExcludeId<T extends BaseObject> = Omit<T, 'id'>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Properties that are required for object creation.
|
|
43
|
-
*/
|
|
44
|
-
// TODO(dmaretskyi): Rename `MakeProps`?
|
|
45
|
-
export type CreationProps<T extends BaseObject> = Omit<T, 'id' | typeof EntityKindId>;
|
|
46
|
-
|
|
47
|
-
export type PropertyKey<T extends BaseObject> = Extract<keyof ExcludeId<T>, string>;
|
|
48
|
-
|
|
49
|
-
// TODO(dmaretskyi): Remove. This should be using the symbol type.
|
|
50
|
-
export type WithMeta = { [ATTR_META]?: ObjectMeta };
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The raw object should not include the ECHO id, but may include metadata.
|
|
54
|
-
*/
|
|
55
|
-
export const RawObject = <S extends Schema.Schema.AnyNoContext>(
|
|
56
|
-
schema: S,
|
|
57
|
-
): Schema.Schema<ExcludeId<Schema.Schema.Type<S>> & WithMeta, Schema.Schema.Encoded<S>> => {
|
|
58
|
-
return Schema.make(SchemaAST.omit(schema.ast, ['id']));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
// Utils
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Utility to split meta property from raw object.
|
|
67
|
-
* @deprecated Bad API.
|
|
68
|
-
*/
|
|
69
|
-
export const splitMeta = <T>(object: T & WithMeta): { object: T; meta?: ObjectMeta } => {
|
|
70
|
-
const meta = object[ATTR_META];
|
|
71
|
-
delete object[ATTR_META];
|
|
72
|
-
return { meta, object };
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// TODO(burdon): Move to `@dxos/util`.
|
|
76
|
-
export const getValue = <T extends object>(obj: T, path: JsonPath): any => {
|
|
77
|
-
return getDeep(
|
|
78
|
-
obj,
|
|
79
|
-
splitJsonPath(path).map((p) => p.replace(/[[\]]/g, '')),
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// TODO(burdon): Move to `@dxos/util`.
|
|
84
|
-
export const setValue = <T extends object>(obj: T, path: JsonPath, value: any): T => {
|
|
85
|
-
return setDeep(
|
|
86
|
-
obj,
|
|
87
|
-
splitJsonPath(path).map((p) => p.replace(/[[\]]/g, '')),
|
|
88
|
-
value,
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Returns a reference that will be used to point to a schema.
|
|
94
|
-
* @deprecated Use {@link getSchemaDXN} instead.
|
|
95
|
-
*/
|
|
96
|
-
export const getTypeReference = (schema: Schema.Schema.All | undefined): Reference | undefined => {
|
|
97
|
-
if (!schema) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const schemaDXN = getSchemaDXN(schema);
|
|
102
|
-
if (!schemaDXN) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
return Reference.fromDXN(schemaDXN);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Returns a reference that will be used to point to a schema.
|
|
110
|
-
* @throws If it is not possible to reference this schema.
|
|
111
|
-
*
|
|
112
|
-
* @deprecated Use {@link getSchemaDXN} instead.
|
|
113
|
-
*/
|
|
114
|
-
export const requireTypeReference = (schema: Schema.Schema.AnyNoContext): Reference => {
|
|
115
|
-
const typeReference = getTypeReference(schema);
|
|
116
|
-
if (typeReference == null) {
|
|
117
|
-
// TODO(burdon): Catalog user-facing errors (this is too verbose).
|
|
118
|
-
throw new Error('Schema must be defined via TypedObject.');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return typeReference;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// TODO(burdon): Can we use `Schema.is`?
|
|
125
|
-
/**
|
|
126
|
-
* Checks if the object is an instance of the schema.
|
|
127
|
-
* Only typename is compared, the schema version is ignored.
|
|
128
|
-
*
|
|
129
|
-
* The following cases are considered to mean that the object is an instance of the schema:
|
|
130
|
-
* - Object was created with this exact schema.
|
|
131
|
-
* - Object was created with a different version of this schema.
|
|
132
|
-
* - Object was created with a different schema (maybe dynamic) that has the same typename.
|
|
133
|
-
*/
|
|
134
|
-
export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
|
|
135
|
-
schema: Schema,
|
|
136
|
-
object: any,
|
|
137
|
-
): object is Schema.Schema.Type<Schema> => {
|
|
138
|
-
if (object == null) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const schemaDXN = getSchemaDXN(schema);
|
|
143
|
-
if (!schemaDXN) {
|
|
144
|
-
throw new Error('Schema must have an object annotation.');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const type = getType(object);
|
|
148
|
-
if (type && DXN.equals(type, schemaDXN)) {
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const typename = getTypename(object);
|
|
153
|
-
if (!typename) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const typeDXN = schemaDXN.asTypeDXN();
|
|
158
|
-
if (!typeDXN) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return typeDXN.type === typename;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Object that has an associated typename.
|
|
167
|
-
* The typename is retrievable using {@link getTypename}.
|
|
168
|
-
* The object can be used with {@link isInstanceOf} to check if it is an instance of a schema.
|
|
169
|
-
*/
|
|
170
|
-
export type HasTypename = {};
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Canonical type for all ECHO objects.
|
|
174
|
-
*/
|
|
175
|
-
// TODO(burdon): Reconcile with Obj.Any, Relation.Any.
|
|
176
|
-
export interface AnyEchoObject extends HasId, HasTypename {}
|
package/src/query/index.ts
DELETED
package/src/query/query.test.ts
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
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 Obj from '../Obj';
|
|
13
|
-
import * as Ref from '../Ref';
|
|
14
|
-
import * as Type from '../Type';
|
|
15
|
-
|
|
16
|
-
import { Filter, Order, Query } from './query';
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
// Example schema
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// TODO(dmaretskyi): Need common set of test types.
|
|
23
|
-
const Person = Schema.Struct({
|
|
24
|
-
name: Schema.String,
|
|
25
|
-
email: Schema.optional(Schema.String),
|
|
26
|
-
age: Schema.optional(Schema.Number),
|
|
27
|
-
fields: Schema.Struct({
|
|
28
|
-
label: Schema.String,
|
|
29
|
-
value: Schema.String,
|
|
30
|
-
}).pipe(Schema.Array, Schema.optional),
|
|
31
|
-
}).pipe(
|
|
32
|
-
Type.Obj({
|
|
33
|
-
typename: 'dxos.org/type/Person',
|
|
34
|
-
version: '0.1.0',
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
38
|
-
|
|
39
|
-
const Organization = Schema.Struct({
|
|
40
|
-
name: Schema.String,
|
|
41
|
-
properties: Schema.optional(
|
|
42
|
-
Schema.Record({
|
|
43
|
-
key: Schema.String,
|
|
44
|
-
value: Schema.String,
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
47
|
-
}).pipe(
|
|
48
|
-
Type.Obj({
|
|
49
|
-
typename: 'dxos.org/type/Organization',
|
|
50
|
-
version: '0.1.0',
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
interface Organization extends Schema.Schema.Type<typeof Organization> {}
|
|
54
|
-
|
|
55
|
-
const WorksFor = Schema.Struct({
|
|
56
|
-
since: Schema.String,
|
|
57
|
-
}).pipe(
|
|
58
|
-
Type.Relation({
|
|
59
|
-
typename: 'dxos.org/type/WorksFor',
|
|
60
|
-
version: '0.1.0',
|
|
61
|
-
source: Person,
|
|
62
|
-
target: Organization,
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {}
|
|
66
|
-
|
|
67
|
-
const Task = Schema.Struct({
|
|
68
|
-
title: Schema.String,
|
|
69
|
-
createdAt: Schema.String,
|
|
70
|
-
assignee: Schema.optional(Type.Ref(Person)),
|
|
71
|
-
}).pipe(Type.Obj({ typename: 'dxos.org/type/Task', version: '0.1.0' }));
|
|
72
|
-
interface Task extends Schema.Schema.Type<typeof Task> {}
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
// Example queries
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
describe('query api', () => {
|
|
79
|
-
describe('Query', () => {
|
|
80
|
-
test('get all people', () => {
|
|
81
|
-
const getAllPeople = Query.type(Person);
|
|
82
|
-
|
|
83
|
-
log('query', { ast: getAllPeople.ast });
|
|
84
|
-
Schema.validateSync(QueryAST.Query)(getAllPeople.ast);
|
|
85
|
-
console.log('getAllPeople', JSON.stringify(getAllPeople.ast, null, 2));
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('get all people ordered by name', () => {
|
|
89
|
-
const getAllPeopleOrderedByName = Query.type(Person).orderBy(Order.property('name', 'asc'));
|
|
90
|
-
|
|
91
|
-
log('query', { ast: getAllPeopleOrderedByName.ast });
|
|
92
|
-
Schema.validateSync(QueryAST.Query)(getAllPeopleOrderedByName.ast);
|
|
93
|
-
console.log('getAllPeopleOrderedByName', JSON.stringify(getAllPeopleOrderedByName.ast, null, 2));
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('get all people named Fred', () => {
|
|
97
|
-
const PeopleNamedFred = Query.select(Filter.type(Person, { name: 'Fred' }));
|
|
98
|
-
|
|
99
|
-
log('query', { ast: PeopleNamedFred.ast });
|
|
100
|
-
Schema.validateSync(QueryAST.Query)(PeopleNamedFred.ast);
|
|
101
|
-
console.log('PeopleNamedFred', JSON.stringify(PeopleNamedFred.ast, null, 2));
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test('get all people with field of "label" set to "Research"', () => {
|
|
105
|
-
const PeopleWithFieldLabelSetToResearch = Query.select(
|
|
106
|
-
Filter.type(Person, { fields: Filter.contains({ label: 'label', value: 'Research' }) }),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
log('query', { ast: PeopleWithFieldLabelSetToResearch.ast });
|
|
110
|
-
Schema.validateSync(QueryAST.Query)(PeopleWithFieldLabelSetToResearch.ast);
|
|
111
|
-
console.log('PeopleWithFieldLabelSetToResearch', JSON.stringify(PeopleWithFieldLabelSetToResearch.ast, null, 2));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('get all orgs with property "label" set to "Research"', () => {
|
|
115
|
-
const OrgsWithPropertyLabelSetToResearch = Query.select(
|
|
116
|
-
Filter.type(Organization, { properties: { label: 'Research' } }),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
log('query', { ast: OrgsWithPropertyLabelSetToResearch.ast });
|
|
120
|
-
Schema.validateSync(QueryAST.Query)(OrgsWithPropertyLabelSetToResearch.ast);
|
|
121
|
-
console.log(
|
|
122
|
-
'OrgsWithPropertyLabelSetToResearch',
|
|
123
|
-
JSON.stringify(OrgsWithPropertyLabelSetToResearch.ast, null, 2),
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('get all orgs Fred worked for since 2020', () => {
|
|
128
|
-
const fred = Obj.make(Person, { name: 'Fred' });
|
|
129
|
-
const OrganizationsFredWorkedForSince2020 = Query.select(Filter.type(Person, { id: fred.id }))
|
|
130
|
-
.sourceOf(WorksFor, { since: Filter.gt('2020') })
|
|
131
|
-
.target();
|
|
132
|
-
|
|
133
|
-
log('query', { ast: OrganizationsFredWorkedForSince2020.ast });
|
|
134
|
-
Schema.validateSync(QueryAST.Query)(OrganizationsFredWorkedForSince2020.ast);
|
|
135
|
-
console.log(
|
|
136
|
-
'OrganizationsFredWorkedForSince2020',
|
|
137
|
-
JSON.stringify(OrganizationsFredWorkedForSince2020.ast, null, 2),
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test('get all tasks for Fred', () => {
|
|
142
|
-
const fred = Obj.make(Person, { name: 'Fred' });
|
|
143
|
-
const TasksForFred = Query.select(Filter.type(Person, { id: fred.id })).referencedBy(Task, 'assignee');
|
|
144
|
-
|
|
145
|
-
log('query', { ast: TasksForFred.ast });
|
|
146
|
-
Schema.validateSync(QueryAST.Query)(TasksForFred.ast);
|
|
147
|
-
console.log('TasksForFred', JSON.stringify(TasksForFred.ast, null, 2));
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('get all tasks for employees of Cyberdyne', () => {
|
|
151
|
-
const TasksForEmployeesOfCyberdyne = Query.select(Filter.type(Organization, { name: 'Cyberdyne' }))
|
|
152
|
-
.targetOf(WorksFor)
|
|
153
|
-
.source()
|
|
154
|
-
.referencedBy(Task, 'assignee');
|
|
155
|
-
|
|
156
|
-
log('query', { ast: TasksForEmployeesOfCyberdyne.ast });
|
|
157
|
-
Schema.validateSync(QueryAST.Query)(TasksForEmployeesOfCyberdyne.ast);
|
|
158
|
-
console.log('TasksForEmployeesOfCyberdyne', JSON.stringify(TasksForEmployeesOfCyberdyne.ast, null, 2));
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('get all people or orgs', () => {
|
|
162
|
-
const PeopleOrOrganizations = Query.all(
|
|
163
|
-
Query.select(Filter.type(Person)),
|
|
164
|
-
Query.select(Filter.type(Organization)),
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
log('query', { ast: PeopleOrOrganizations.ast });
|
|
168
|
-
Schema.validateSync(QueryAST.Query)(PeopleOrOrganizations.ast);
|
|
169
|
-
console.log('PeopleOrOrganizations', JSON.stringify(PeopleOrOrganizations.ast, null, 2));
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test('get all people not in orgs', () => {
|
|
173
|
-
const PeopleNotInOrganizations = Query.without(
|
|
174
|
-
Query.select(Filter.type(Person)),
|
|
175
|
-
Query.select(Filter.type(Person)).sourceOf(WorksFor).source(),
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
log('query', { ast: PeopleNotInOrganizations.ast });
|
|
179
|
-
Schema.validateSync(QueryAST.Query)(PeopleNotInOrganizations.ast);
|
|
180
|
-
console.log('PeopleNotInOrganizations', JSON.stringify(PeopleNotInOrganizations.ast, null, 2));
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('get assignees of all tasks created after 2020', () => {
|
|
184
|
-
const AssigneesOfAllTasksCreatedAfter2020 = Query.select(
|
|
185
|
-
Filter.type(Task, { createdAt: Filter.gt('2020') }),
|
|
186
|
-
).reference('assignee');
|
|
187
|
-
|
|
188
|
-
log('query', { ast: AssigneesOfAllTasksCreatedAfter2020.ast });
|
|
189
|
-
Schema.validateSync(QueryAST.Query)(AssigneesOfAllTasksCreatedAfter2020.ast);
|
|
190
|
-
console.log(
|
|
191
|
-
'AssigneesOfAllTasksCreatedAfter2020',
|
|
192
|
-
JSON.stringify(AssigneesOfAllTasksCreatedAfter2020.ast, null, 2),
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('untyped full-text search', () => {
|
|
197
|
-
const contactFullTextSearch = Query.select(Filter.text('Bill'));
|
|
198
|
-
|
|
199
|
-
log('query', { ast: contactFullTextSearch.ast });
|
|
200
|
-
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
201
|
-
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
202
|
-
{
|
|
203
|
-
"filter": {
|
|
204
|
-
"searchKind": undefined,
|
|
205
|
-
"text": "Bill",
|
|
206
|
-
"type": "text-search",
|
|
207
|
-
},
|
|
208
|
-
"type": "select",
|
|
209
|
-
}
|
|
210
|
-
`);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test('typed full-text search', () => {
|
|
214
|
-
const contactFullTextSearch = Query.select(Filter.type(Person)).select(Filter.text('Bill'));
|
|
215
|
-
|
|
216
|
-
log('query', { ast: contactFullTextSearch.ast });
|
|
217
|
-
Schema.validateSync(QueryAST.Query)(contactFullTextSearch.ast);
|
|
218
|
-
expect(contactFullTextSearch.ast).toMatchInlineSnapshot(`
|
|
219
|
-
{
|
|
220
|
-
"filter": {
|
|
221
|
-
"searchKind": undefined,
|
|
222
|
-
"text": "Bill",
|
|
223
|
-
"type": "text-search",
|
|
224
|
-
},
|
|
225
|
-
"selection": {
|
|
226
|
-
"filter": {
|
|
227
|
-
"id": undefined,
|
|
228
|
-
"props": {},
|
|
229
|
-
"type": "object",
|
|
230
|
-
"typename": "dxn:type:dxos.org/type/Person:0.1.0",
|
|
231
|
-
},
|
|
232
|
-
"type": "select",
|
|
233
|
-
},
|
|
234
|
-
"type": "filter",
|
|
235
|
-
}
|
|
236
|
-
`);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
test('filter by ref', () => {
|
|
240
|
-
const fred = Obj.make(Person, { name: 'Fred' });
|
|
241
|
-
const tasksByFred = Filter.type(Task, { assignee: Ref.make(fred) });
|
|
242
|
-
expect(tasksByFred.ast).toEqual({
|
|
243
|
-
props: {
|
|
244
|
-
assignee: {
|
|
245
|
-
operator: 'eq',
|
|
246
|
-
type: 'compare',
|
|
247
|
-
value: {
|
|
248
|
-
'/': DXN.fromLocalObjectId(fred.id).toString(),
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
type: 'object',
|
|
253
|
-
typename: 'dxn:type:dxos.org/type/Task:0.1.0',
|
|
254
|
-
});
|
|
255
|
-
console.log('tasksByFred', JSON.stringify(tasksByFred.ast, null, 2));
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
test('select orgs and people', () => {
|
|
259
|
-
const orgsAndPeople = Query.select(Filter.or(Filter.type(Organization), Filter.type(Person)));
|
|
260
|
-
|
|
261
|
-
Schema.validateSync(QueryAST.Query)(orgsAndPeople.ast);
|
|
262
|
-
expect(orgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
263
|
-
{
|
|
264
|
-
"filter": {
|
|
265
|
-
"filters": [
|
|
266
|
-
{
|
|
267
|
-
"id": undefined,
|
|
268
|
-
"props": {},
|
|
269
|
-
"type": "object",
|
|
270
|
-
"typename": "dxn:type:dxos.org/type/Organization:0.1.0",
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
"id": undefined,
|
|
274
|
-
"props": {},
|
|
275
|
-
"type": "object",
|
|
276
|
-
"typename": "dxn:type:dxos.org/type/Person:0.1.0",
|
|
277
|
-
},
|
|
278
|
-
],
|
|
279
|
-
"type": "or",
|
|
280
|
-
},
|
|
281
|
-
"type": "select",
|
|
282
|
-
}
|
|
283
|
-
`);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test('select everything but orgs and people', () => {
|
|
287
|
-
const everythingButOrgsAndPeople = Query.select(
|
|
288
|
-
Filter.not(Filter.or(Filter.type(Organization), Filter.type(Person))),
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
Schema.validateSync(QueryAST.Query)(everythingButOrgsAndPeople.ast);
|
|
292
|
-
expect(everythingButOrgsAndPeople.ast).toMatchInlineSnapshot(`
|
|
293
|
-
{
|
|
294
|
-
"filter": {
|
|
295
|
-
"filter": {
|
|
296
|
-
"filters": [
|
|
297
|
-
{
|
|
298
|
-
"id": undefined,
|
|
299
|
-
"props": {},
|
|
300
|
-
"type": "object",
|
|
301
|
-
"typename": "dxn:type:dxos.org/type/Organization:0.1.0",
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
"id": undefined,
|
|
305
|
-
"props": {},
|
|
306
|
-
"type": "object",
|
|
307
|
-
"typename": "dxn:type:dxos.org/type/Person:0.1.0",
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
"type": "or",
|
|
311
|
-
},
|
|
312
|
-
"type": "not",
|
|
313
|
-
},
|
|
314
|
-
"type": "select",
|
|
315
|
-
}
|
|
316
|
-
`);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
test('select deleted tasks', () => {
|
|
320
|
-
const deletedTasks = Query.select(Filter.type(Task)).options({
|
|
321
|
-
deleted: 'only',
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
Schema.validateSync(QueryAST.Query)(deletedTasks.ast);
|
|
325
|
-
expect(deletedTasks.ast).toMatchInlineSnapshot(`
|
|
326
|
-
{
|
|
327
|
-
"options": {
|
|
328
|
-
"deleted": "only",
|
|
329
|
-
},
|
|
330
|
-
"query": {
|
|
331
|
-
"filter": {
|
|
332
|
-
"id": undefined,
|
|
333
|
-
"props": {},
|
|
334
|
-
"type": "object",
|
|
335
|
-
"typename": "dxn:type:dxos.org/type/Task:0.1.0",
|
|
336
|
-
},
|
|
337
|
-
"type": "select",
|
|
338
|
-
},
|
|
339
|
-
"type": "options",
|
|
340
|
-
}
|
|
341
|
-
`);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test('filter by tags', () => {
|
|
345
|
-
const query = Query.select(Filter.type(Task)).select(Filter.tag('important'));
|
|
346
|
-
Schema.validateSync(QueryAST.Query)(query.ast);
|
|
347
|
-
expect(query.ast).toMatchInlineSnapshot(`
|
|
348
|
-
{
|
|
349
|
-
"filter": {
|
|
350
|
-
"tag": "important",
|
|
351
|
-
"type": "tag",
|
|
352
|
-
},
|
|
353
|
-
"selection": {
|
|
354
|
-
"filter": {
|
|
355
|
-
"id": undefined,
|
|
356
|
-
"props": {},
|
|
357
|
-
"type": "object",
|
|
358
|
-
"typename": "dxn:type:dxos.org/type/Task:0.1.0",
|
|
359
|
-
},
|
|
360
|
-
"type": "select",
|
|
361
|
-
},
|
|
362
|
-
"type": "filter",
|
|
363
|
-
}
|
|
364
|
-
`);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
test.skip('chain', () => {
|
|
368
|
-
// NOTE: Can't support props without type since they can't be inferred.
|
|
369
|
-
// const f1: Filter<Person> = Filter.props({ name: 'Fred' });
|
|
370
|
-
|
|
371
|
-
// const x = Query.select(Filter.props({ id: '123' }));
|
|
372
|
-
const y = Query.select(Filter.type(Person));
|
|
373
|
-
|
|
374
|
-
const or = Filter.or(Filter.type(Person, { id: Filter.in('1', '2', '3') }), Filter.type(Organization));
|
|
375
|
-
|
|
376
|
-
const and = Filter.and(
|
|
377
|
-
Filter.type(Person, { id: Filter.in('1', '2', '3') }),
|
|
378
|
-
Filter.type(Person, { name: 'Fred' }),
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
const q = Query
|
|
382
|
-
//
|
|
383
|
-
// NOTE: Can't support functions since they can't be serialized (to server).
|
|
384
|
-
// .filter((object) => Math.random() > 0.5)
|
|
385
|
-
.select(Filter.type(Person))
|
|
386
|
-
.select(Filter.type(Person, { name: 'Fred' }))
|
|
387
|
-
.select({ age: Filter.between(20, 40) })
|
|
388
|
-
.select(Filter.and(Filter.type(Person), Filter.type(Person, { name: Filter.in('bob', 'bill') })));
|
|
389
|
-
|
|
390
|
-
log('stuff', { fOr: or, fAnd: and, q, y });
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
describe('Filter', () => {
|
|
395
|
-
test('Filter.or(Filter.typename(...))', () => {
|
|
396
|
-
const filter = Filter.or(Filter.typename('dxos.org/type/Person'));
|
|
397
|
-
// TODO(dmaretskyi): Give vitest type-tests a try.
|
|
398
|
-
const _isAssignable: Obj.Any = null as any as Filter.Type<typeof filter>;
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
});
|