@dxos/echo 0.8.4-main.84f28bd → 0.8.4-main.937b3ca
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 +2 -3
- package/dist/lib/browser/Annotation.mjs +33 -0
- package/dist/lib/browser/Annotation.mjs.map +7 -0
- package/dist/lib/browser/Database.mjs +18 -0
- package/dist/lib/browser/Database.mjs.map +7 -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 -9
- package/dist/lib/browser/internal/index.mjs +457 -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 +332 -35
- 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 -9
- package/dist/lib/node-esm/internal/index.mjs +457 -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 +332 -35
- 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/Err.d.ts +64 -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 +344 -34
- 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 -19
- 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 -73
- 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 -3
- 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 +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/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/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 +12 -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/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 +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 +11 -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 +37 -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 +2 -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/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 +25 -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/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/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 +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/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/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 +47 -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 +217 -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 +180 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/index.d.ts +4 -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 +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 +6 -0
- package/dist/types/src/internal/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/types/meta.d.ts +32 -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 +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 +166 -33
- 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/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.test.ts +386 -0
- package/src/Obj.ts +509 -85
- 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 +25 -9
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +414 -51
- package/src/SchemaRegistry.ts +105 -0
- package/src/Tag.ts +40 -0
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +360 -112
- package/src/index.ts +17 -4
- package/src/internal/README.md +102 -0
- package/src/internal/annotations/annotations.test.ts +96 -0
- 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 +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 +39 -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/clone.ts +48 -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 +14 -0
- package/src/internal/object/inspect.ts +46 -0
- package/src/internal/object/json-serializer.test.ts +97 -0
- package/src/internal/object/json-serializer.ts +188 -0
- package/src/internal/object/schema-validator.test.ts +186 -0
- package/src/internal/object/schema-validator.ts +6 -0
- 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 +34 -0
- package/src/internal/object/typed-object.ts +30 -0
- 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 +123 -0
- 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 +145 -0
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +318 -0
- package/src/internal/proxy/typed-handler.ts +442 -0
- package/src/internal/proxy/typed-object.test.ts +116 -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 +548 -0
- package/src/internal/schema/compose.test.ts +42 -0
- package/src/internal/schema/compose.ts +36 -0
- package/src/internal/schema/echo-schema.ts +423 -0
- package/src/internal/schema/index.ts +7 -0
- package/src/internal/schema/manipulation.ts +92 -0
- 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 +9 -0
- package/src/internal/types/meta.ts +66 -0
- 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 -1
- 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-SVSJEELN.mjs +0 -619
- package/dist/lib/browser/chunk-SVSJEELN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-53HXWYR6.mjs +0 -619
- package/dist/lib/node-esm/chunk-53HXWYR6.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,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { ForeignKey } from '@dxos/echo-protocol';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { type Comparator, intersection } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { type AnyProperties } from './base';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Property name for meta when object is serialized to JSON.
|
|
15
|
+
*/
|
|
16
|
+
export const ATTR_META = '@meta';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Metadata section.
|
|
20
|
+
*/
|
|
21
|
+
export const MetaId = Symbol.for('@dxos/echo/Meta');
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
// ObjectMeta
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
// TODO(dmaretskyi): Rename to ObjectMeta
|
|
28
|
+
export const ObjectMetaSchema = Schema.mutable(
|
|
29
|
+
Schema.Struct({
|
|
30
|
+
keys: Schema.mutable(Schema.Array(ForeignKey)),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A set of tags.
|
|
34
|
+
* Tags are arbitrary application-defined strings.
|
|
35
|
+
* ECHO makes no assumptions about the tag structure.
|
|
36
|
+
*/
|
|
37
|
+
// TODO(dmaretskyi): Has to be optional for compatibility with old data.
|
|
38
|
+
// Defaulting to an empty array is possible but requires a bit more work.
|
|
39
|
+
tags: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
export type ObjectMeta = Schema.Schema.Type<typeof ObjectMetaSchema>;
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Get metadata from object.
|
|
46
|
+
* Only callable on the object root.
|
|
47
|
+
*
|
|
48
|
+
* @internal (use Obj.getMeta or Relation.getMeta)
|
|
49
|
+
*/
|
|
50
|
+
// TODO(burdon): Refine type to BaseObj.
|
|
51
|
+
export const getMeta = (obj: AnyProperties): ObjectMeta => {
|
|
52
|
+
const metadata = (obj as any)[MetaId];
|
|
53
|
+
invariant(metadata, 'ObjectMeta not found.');
|
|
54
|
+
return metadata;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//
|
|
58
|
+
// Foreign keys
|
|
59
|
+
//
|
|
60
|
+
|
|
61
|
+
export const foreignKey = (source: string, id: string): ForeignKey => ({ source, id });
|
|
62
|
+
export const foreignKeyEquals = (a: ForeignKey, b: ForeignKey) => a.source === b.source && a.id === b.id;
|
|
63
|
+
|
|
64
|
+
// TODO(dmaretskyi): Move to echo-schema.
|
|
65
|
+
export const compareForeignKeys: Comparator<AnyProperties> = (a: AnyProperties, b: AnyProperties) =>
|
|
66
|
+
intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Property name for typename when object is serialized to JSON.
|
|
9
|
+
*/
|
|
10
|
+
export const ATTR_TYPE = '@type';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* DXN to the object type.
|
|
14
|
+
*/
|
|
15
|
+
export const TypeId = Symbol.for('@dxos/echo/Type');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reference to the object schema.
|
|
19
|
+
*/
|
|
20
|
+
export const SchemaId = Symbol.for('@dxos/echo/Schema');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns the schema for the given object if one is defined.
|
|
24
|
+
*
|
|
25
|
+
* @internal (Use Obj.getSchema)
|
|
26
|
+
*/
|
|
27
|
+
// TODO(burdon): Narrow type.
|
|
28
|
+
// TODO(dmaretskyi): For echo objects, this always returns the root schema.
|
|
29
|
+
export const getSchema = (obj: unknown | undefined): Schema.Schema.AnyNoContext | undefined => {
|
|
30
|
+
if (obj) {
|
|
31
|
+
return (obj as any)[SchemaId];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export const setSchema = (obj: any, schema: Schema.Schema.AnyNoContext): void => {
|
|
39
|
+
Object.defineProperty(obj, SchemaId, {
|
|
40
|
+
value: schema,
|
|
41
|
+
writable: false,
|
|
42
|
+
enumerable: false,
|
|
43
|
+
configurable: false,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Version type symbol.
|
|
7
|
+
*/
|
|
8
|
+
export const VersionTypeId: unique symbol = Symbol.for('@dxos/echo/VersionTypeId');
|
|
9
|
+
|
|
10
|
+
export type VersionTypeId = typeof VersionTypeId;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Represents the object version.
|
|
14
|
+
* May be backed by Automerge.
|
|
15
|
+
* Objects with no history are not versioned.
|
|
16
|
+
*/
|
|
17
|
+
export interface Version {
|
|
18
|
+
[VersionTypeId]: {};
|
|
19
|
+
automergeHeads?: string[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { raise } from '@dxos/debug';
|
|
9
|
+
|
|
10
|
+
import { Entity, Obj, Ref, Relation, Type } from '../index';
|
|
11
|
+
|
|
12
|
+
import { TestSchema } from './test-schema';
|
|
13
|
+
|
|
14
|
+
describe('Experimental API review', () => {
|
|
15
|
+
test('type checks', ({ expect }) => {
|
|
16
|
+
const contact = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
17
|
+
const schema = Obj.getSchema(contact) ?? raise(new Error('No schema found'));
|
|
18
|
+
|
|
19
|
+
expect(Type.getDXN(schema)?.typename).to.eq(TestSchema.Person.typename);
|
|
20
|
+
expect(Type.getTypename(schema)).to.eq('example.com/type/Person');
|
|
21
|
+
expect(Type.getVersion(schema)).to.eq('0.1.0');
|
|
22
|
+
expect(Type.getMeta(schema)).to.deep.eq({
|
|
23
|
+
kind: Entity.Kind.Object,
|
|
24
|
+
typename: 'example.com/type/Person',
|
|
25
|
+
version: '0.1.0',
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('instance checks', ({ expect }) => {
|
|
30
|
+
const organization = Obj.make(TestSchema.Organization, { name: 'DXOS' });
|
|
31
|
+
const contact = Obj.make(TestSchema.Person, {
|
|
32
|
+
name: 'Test',
|
|
33
|
+
employer: Ref.make(organization),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(Schema.is(TestSchema.Person)(contact)).to.be.true;
|
|
37
|
+
expect(Obj.instanceOf(TestSchema.Person, contact)).to.be.true;
|
|
38
|
+
expect(Obj.instanceOf(TestSchema.Organization, organization)).to.be.true;
|
|
39
|
+
|
|
40
|
+
const isPerson = Obj.instanceOf(TestSchema.Person);
|
|
41
|
+
const x: any = {};
|
|
42
|
+
if (isPerson(x)) {
|
|
43
|
+
x.name;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('default props', ({ expect }) => {
|
|
48
|
+
const message = Obj.make(TestSchema.Message, TestSchema.MessageStruct.make({}));
|
|
49
|
+
expect(message.timestamp).to.exist;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Obj.isObject', ({ expect }) => {
|
|
53
|
+
const guy = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
54
|
+
expect(Obj.isObject(guy)).to.be.true;
|
|
55
|
+
expect(Obj.isObject(null)).to.be.false;
|
|
56
|
+
expect(Obj.isObject(undefined)).to.be.false;
|
|
57
|
+
expect(Obj.isObject(1)).to.be.false;
|
|
58
|
+
expect(Obj.isObject('string')).to.be.false;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('create relation', ({ expect }) => {
|
|
62
|
+
const person = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
63
|
+
const organization = Obj.make(TestSchema.Organization, { name: 'DXOS' });
|
|
64
|
+
const worksFor = Relation.make(TestSchema.EmployedBy, {
|
|
65
|
+
[Relation.Source]: person,
|
|
66
|
+
[Relation.Target]: organization,
|
|
67
|
+
role: 'CEO',
|
|
68
|
+
});
|
|
69
|
+
expect(Relation.getSource(worksFor)).to.eq(person);
|
|
70
|
+
expect(Relation.getTarget(worksFor)).to.eq(organization);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('version', ({ expect }) => {
|
|
74
|
+
const person = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
75
|
+
const version = Obj.version(person);
|
|
76
|
+
expect(Obj.isVersion(version)).to.be.true;
|
|
77
|
+
expect(Obj.versionValid(version)).to.be.false;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// TODO(burdon): Implement test.
|
|
81
|
+
test.skip('type narrowing', () => {
|
|
82
|
+
const any: Entity.Unknown = null as any;
|
|
83
|
+
|
|
84
|
+
{
|
|
85
|
+
if (Obj.isObject(any)) {
|
|
86
|
+
any;
|
|
87
|
+
} else {
|
|
88
|
+
any;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
if (Relation.isRelation(any)) {
|
|
94
|
+
any;
|
|
95
|
+
} else {
|
|
96
|
+
any;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Test that Obj.make return types are clean and don't expose internal markers like OfKind.
|
|
103
|
+
* The return type of Obj.make(Schema, props) should be assignable to Obj.Obj<InstanceType>.
|
|
104
|
+
*/
|
|
105
|
+
describe('Obj.make return type', () => {
|
|
106
|
+
test('Obj.make with custom schema should be assignable to Obj.Obj<Person>', ({ expect }) => {
|
|
107
|
+
{
|
|
108
|
+
const expando = Obj.make(TestSchema.Expando, { content: 'Test' });
|
|
109
|
+
expect(Obj.isObject(expando)).to.be.true;
|
|
110
|
+
expect(expando.content).to.eq('Test');
|
|
111
|
+
|
|
112
|
+
// This should work: assign to Obj.Obj of the schema's instance type
|
|
113
|
+
const _typed: Obj.Obj<TestSchema.Expando> = expando;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
{
|
|
117
|
+
const person = Obj.make(TestSchema.Person, { name: 'Test' });
|
|
118
|
+
expect(Obj.isObject(person)).to.be.true;
|
|
119
|
+
expect(person.name).to.eq('Test');
|
|
120
|
+
|
|
121
|
+
// This should work: assign to Obj.Obj of the schema's instance type
|
|
122
|
+
const _typed: Obj.Obj<TestSchema.Person> = person;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
package/src/testing/index.ts
CHANGED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { DatabaseDirectory, ObjectStructure } from '@dxos/echo-protocol';
|
|
6
|
+
import { DXN, ObjectId, PublicKey } from '@dxos/keys';
|
|
7
|
+
|
|
8
|
+
import { Type } from '../index';
|
|
9
|
+
|
|
10
|
+
import { TestSchema } from './test-schema';
|
|
11
|
+
|
|
12
|
+
const spaceKey = PublicKey.random();
|
|
13
|
+
|
|
14
|
+
// TODO(burdon): Use Obj.make.
|
|
15
|
+
|
|
16
|
+
export const PEOPLE = {
|
|
17
|
+
alice: DatabaseDirectory.make({
|
|
18
|
+
spaceKey: spaceKey.toHex(),
|
|
19
|
+
objects: {
|
|
20
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
21
|
+
type: Type.getDXN(TestSchema.Person)!.toString(),
|
|
22
|
+
data: {
|
|
23
|
+
name: 'Alice',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
bob: DatabaseDirectory.make({
|
|
29
|
+
spaceKey: spaceKey.toHex(),
|
|
30
|
+
objects: {
|
|
31
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
32
|
+
type: Type.getDXN(TestSchema.Person)!.toString(),
|
|
33
|
+
data: {
|
|
34
|
+
name: 'Bob',
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const ORGS = {
|
|
42
|
+
dxos: DatabaseDirectory.make({
|
|
43
|
+
spaceKey: spaceKey.toHex(),
|
|
44
|
+
objects: {
|
|
45
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
46
|
+
type: Type.getDXN(TestSchema.Organization)!.toString(),
|
|
47
|
+
data: {
|
|
48
|
+
name: 'DXOS',
|
|
49
|
+
founded: '2023',
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
cyberdyne: DatabaseDirectory.make({
|
|
55
|
+
spaceKey: spaceKey.toHex(),
|
|
56
|
+
objects: {
|
|
57
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
58
|
+
type: Type.getDXN(TestSchema.Organization)!.toString(),
|
|
59
|
+
data: {
|
|
60
|
+
name: 'Cyberdyne Systems',
|
|
61
|
+
founded: '1984',
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const WORKS_FOR = {
|
|
69
|
+
fredWorksForCyberdyne: DatabaseDirectory.make({
|
|
70
|
+
spaceKey: spaceKey.toHex(),
|
|
71
|
+
objects: {
|
|
72
|
+
[ObjectId.random()]: ObjectStructure.makeRelation({
|
|
73
|
+
type: Type.getDXN(TestSchema.EmployedBy)!.toString(),
|
|
74
|
+
source: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.bob.objects!)[0]).toString() },
|
|
75
|
+
target: { '/': DXN.fromLocalObjectId(Object.keys(ORGS.cyberdyne.objects!)[0]).toString() },
|
|
76
|
+
data: {
|
|
77
|
+
since: '2020',
|
|
78
|
+
position: 'Engineer',
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
aliceWorksForAperture: DatabaseDirectory.make({
|
|
84
|
+
spaceKey: spaceKey.toHex(),
|
|
85
|
+
objects: {
|
|
86
|
+
[ObjectId.random()]: ObjectStructure.makeRelation({
|
|
87
|
+
type: Type.getDXN(TestSchema.EmployedBy)!.toString(),
|
|
88
|
+
source: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.alice.objects!)[0]).toString() },
|
|
89
|
+
target: { '/': DXN.fromLocalObjectId(Object.keys(ORGS.dxos.objects!)[0]).toString() },
|
|
90
|
+
data: {
|
|
91
|
+
since: '2018',
|
|
92
|
+
position: 'Research Scientist',
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const TASKS = {
|
|
100
|
+
task1: DatabaseDirectory.make({
|
|
101
|
+
spaceKey: spaceKey.toHex(),
|
|
102
|
+
objects: {
|
|
103
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
104
|
+
type: Type.getDXN(TestSchema.Task)!.toString(),
|
|
105
|
+
data: {
|
|
106
|
+
title: 'Complete project documentation',
|
|
107
|
+
description: 'Write comprehensive documentation for the new system',
|
|
108
|
+
status: 'in-progress',
|
|
109
|
+
dueDate: '2023-12-31',
|
|
110
|
+
assignee: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.bob.objects!)[0]).toString() },
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
115
|
+
task2: DatabaseDirectory.make({
|
|
116
|
+
spaceKey: spaceKey.toHex(),
|
|
117
|
+
objects: {
|
|
118
|
+
[ObjectId.random()]: ObjectStructure.makeObject({
|
|
119
|
+
type: Type.getDXN(TestSchema.Task)!.toString(),
|
|
120
|
+
data: {
|
|
121
|
+
title: 'Run experiments',
|
|
122
|
+
description: 'Conduct series of experiments on the portal device',
|
|
123
|
+
status: 'pending',
|
|
124
|
+
dueDate: '2023-11-15',
|
|
125
|
+
assignee: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.alice.objects!)[0]).toString() },
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
}),
|
|
130
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import * as Type from '../Type';
|
|
8
|
+
|
|
9
|
+
export namespace TestSchema {
|
|
10
|
+
//
|
|
11
|
+
// Expando
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Expando object is an object with an arbitrary set of properties.
|
|
16
|
+
* This is the test variant with example.com namespace.
|
|
17
|
+
*/
|
|
18
|
+
export const Expando = Schema.Struct({}, { key: Schema.String, value: Schema.Any }).pipe(
|
|
19
|
+
Type.object({
|
|
20
|
+
typename: 'example.com/type/Expando',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export interface Expando extends Schema.Schema.Type<typeof Expando> {}
|
|
26
|
+
|
|
27
|
+
//
|
|
28
|
+
// Example
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
const Nested = Schema.Struct({
|
|
32
|
+
field: Schema.String,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export class TestClass {
|
|
36
|
+
field = 'value';
|
|
37
|
+
toJSON() {
|
|
38
|
+
return { field: this.field };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @deprecated Use another test schema or create a specific local test schema. */
|
|
43
|
+
export const ExampleSchema = Schema.Struct({
|
|
44
|
+
string: Schema.String,
|
|
45
|
+
number: Schema.Number,
|
|
46
|
+
boolean: Schema.Boolean,
|
|
47
|
+
null: Schema.Null,
|
|
48
|
+
undefined: Schema.Undefined,
|
|
49
|
+
stringArray: Schema.Array(Schema.String),
|
|
50
|
+
twoDimNumberArray: Schema.Array(Schema.Array(Schema.Number)),
|
|
51
|
+
nested: Nested,
|
|
52
|
+
nestedArray: Schema.Array(Nested),
|
|
53
|
+
nestedNullableArray: Schema.Array(Schema.Union(Nested, Schema.Null)),
|
|
54
|
+
reference: Schema.suspend((): Type.Ref<Example> => Type.Ref(Example)),
|
|
55
|
+
referenceArray: Schema.Array(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))),
|
|
56
|
+
classInstance: Schema.instanceOf(TestClass),
|
|
57
|
+
other: Schema.Any,
|
|
58
|
+
}).pipe(Schema.partial);
|
|
59
|
+
|
|
60
|
+
/** @deprecated Use another test schema or create a specific local test schema. */
|
|
61
|
+
export interface ExampleSchema extends Schema.Schema.Type<typeof ExampleSchema> {}
|
|
62
|
+
|
|
63
|
+
/** @deprecated Use another test schema or create a specific local test schema. */
|
|
64
|
+
export const Example = ExampleSchema.pipe(
|
|
65
|
+
Type.object({
|
|
66
|
+
typename: 'example.com/type/Example',
|
|
67
|
+
version: '0.1.0',
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/** @deprecated Use another test schema or create a specific local test schema. */
|
|
72
|
+
export interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
73
|
+
|
|
74
|
+
//
|
|
75
|
+
// Message
|
|
76
|
+
//
|
|
77
|
+
|
|
78
|
+
// TODO(burdon): Support defaults directly on Type: `make` is erased by `pipe(Type.Obj)`.
|
|
79
|
+
export const MessageStruct = Schema.Struct({
|
|
80
|
+
// TODO(burdon): Support S.Date; Custom Timestamp (with defaults).
|
|
81
|
+
// TODO(burdon): Support defaults (update create and create).
|
|
82
|
+
timestamp: Schema.String.pipe(
|
|
83
|
+
Schema.propertySignature,
|
|
84
|
+
Schema.withConstructorDefault(() => new Date().toISOString()),
|
|
85
|
+
),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const Message = MessageStruct.pipe(
|
|
89
|
+
Type.object({
|
|
90
|
+
typename: 'example.com/type/Message',
|
|
91
|
+
version: '0.1.0',
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
export interface Message extends Schema.Schema.Type<typeof Message> {}
|
|
96
|
+
|
|
97
|
+
//
|
|
98
|
+
// Organization
|
|
99
|
+
//
|
|
100
|
+
|
|
101
|
+
export const Organization = Schema.Struct({
|
|
102
|
+
name: Schema.String,
|
|
103
|
+
properties: Schema.optional(
|
|
104
|
+
Schema.Record({
|
|
105
|
+
key: Schema.String,
|
|
106
|
+
value: Schema.String,
|
|
107
|
+
}),
|
|
108
|
+
),
|
|
109
|
+
}).pipe(
|
|
110
|
+
Type.object({
|
|
111
|
+
typename: 'example.com/type/Organization',
|
|
112
|
+
version: '0.1.0',
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export interface Organization extends Schema.Schema.Type<typeof Organization> {}
|
|
117
|
+
|
|
118
|
+
//
|
|
119
|
+
// Person
|
|
120
|
+
//
|
|
121
|
+
|
|
122
|
+
export const Person = Schema.Struct({
|
|
123
|
+
name: Schema.String,
|
|
124
|
+
username: Schema.String,
|
|
125
|
+
email: Schema.String,
|
|
126
|
+
age: Schema.Number.pipe(Schema.optional),
|
|
127
|
+
tasks: Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))),
|
|
128
|
+
employer: Schema.optional(Type.Ref(Organization)),
|
|
129
|
+
address: Schema.Struct({
|
|
130
|
+
city: Schema.optional(Schema.String),
|
|
131
|
+
state: Schema.optional(Schema.String),
|
|
132
|
+
zip: Schema.optional(Schema.String),
|
|
133
|
+
coordinates: Schema.Struct({
|
|
134
|
+
lat: Schema.optional(Schema.Number),
|
|
135
|
+
lng: Schema.optional(Schema.Number),
|
|
136
|
+
}),
|
|
137
|
+
}),
|
|
138
|
+
fields: Schema.Struct({
|
|
139
|
+
label: Schema.String,
|
|
140
|
+
value: Schema.String,
|
|
141
|
+
}).pipe(Schema.Array, Schema.optional),
|
|
142
|
+
}).pipe(
|
|
143
|
+
Schema.partial,
|
|
144
|
+
Type.object({
|
|
145
|
+
typename: 'example.com/type/Person',
|
|
146
|
+
version: '0.1.0',
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
export interface Person extends Schema.Schema.Type<typeof Person> {}
|
|
151
|
+
|
|
152
|
+
//
|
|
153
|
+
// Task
|
|
154
|
+
//
|
|
155
|
+
|
|
156
|
+
export const Task = Schema.Struct({
|
|
157
|
+
title: Schema.optional(Schema.String),
|
|
158
|
+
deadline: Schema.optional(Schema.String),
|
|
159
|
+
completed: Schema.optional(Schema.Boolean),
|
|
160
|
+
assignee: Schema.optional(Type.Ref(Person)),
|
|
161
|
+
previous: Schema.optional(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))),
|
|
162
|
+
subTasks: Schema.optional(Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task)))),
|
|
163
|
+
description: Schema.optional(Schema.String),
|
|
164
|
+
}).pipe(
|
|
165
|
+
Schema.partial,
|
|
166
|
+
Type.object({
|
|
167
|
+
typename: 'example.com/type/Task',
|
|
168
|
+
version: '0.1.0',
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
export interface Task extends Schema.Schema.Type<typeof Task> {}
|
|
173
|
+
|
|
174
|
+
//
|
|
175
|
+
// HasManager
|
|
176
|
+
//
|
|
177
|
+
|
|
178
|
+
export const HasManager = Schema.Struct({}).pipe(
|
|
179
|
+
Type.relation({
|
|
180
|
+
typename: 'example.com/type/HasManager',
|
|
181
|
+
version: '0.1.0',
|
|
182
|
+
source: Person,
|
|
183
|
+
target: Person,
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
export interface HasManager extends Schema.Schema.Type<typeof HasManager> {}
|
|
188
|
+
|
|
189
|
+
//
|
|
190
|
+
// EmployedBy
|
|
191
|
+
//
|
|
192
|
+
|
|
193
|
+
export const EmployedBy = Schema.Struct({
|
|
194
|
+
role: Schema.String,
|
|
195
|
+
since: Schema.optional(Schema.String),
|
|
196
|
+
}).pipe(
|
|
197
|
+
Type.relation({
|
|
198
|
+
typename: 'example.com/type/EmployedBy',
|
|
199
|
+
version: '0.1.0',
|
|
200
|
+
source: Person,
|
|
201
|
+
target: Organization,
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
export interface EmployedBy extends Schema.Schema.Type<typeof EmployedBy> {}
|
|
206
|
+
|
|
207
|
+
//
|
|
208
|
+
// RecordType
|
|
209
|
+
//
|
|
210
|
+
|
|
211
|
+
export enum RecordType {
|
|
212
|
+
UNDEFINED = 0,
|
|
213
|
+
PERSONAL = 1,
|
|
214
|
+
WORK = 2,
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const Container = Schema.Struct({
|
|
218
|
+
objects: Schema.Array(Type.Ref(Type.Obj)),
|
|
219
|
+
records: Schema.Array(
|
|
220
|
+
Schema.partial(
|
|
221
|
+
Schema.Struct({
|
|
222
|
+
title: Schema.String,
|
|
223
|
+
description: Schema.String,
|
|
224
|
+
contacts: Schema.Array(Type.Ref(Person)),
|
|
225
|
+
type: Schema.Enums(RecordType),
|
|
226
|
+
}),
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
}).pipe(
|
|
230
|
+
Schema.partial,
|
|
231
|
+
Type.object({
|
|
232
|
+
typename: 'example.com/type/Container',
|
|
233
|
+
version: '0.1.0',
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
export interface Container extends Schema.Schema.Type<typeof Container> {}
|
|
238
|
+
}
|