@dxos/echo 0.8.4-main.66e292d → 0.8.4-main.69d29f4
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/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-2RMVRVOB.mjs +250 -0
- package/dist/lib/browser/chunk-2RMVRVOB.mjs.map +7 -0
- package/dist/lib/browser/chunk-5RDNDPMX.mjs +74 -0
- package/dist/lib/browser/chunk-5RDNDPMX.mjs.map +7 -0
- package/dist/lib/browser/chunk-73M2G455.mjs +98 -0
- package/dist/lib/browser/chunk-73M2G455.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-AFGYYVVQ.mjs +57 -0
- package/dist/lib/browser/chunk-AFGYYVVQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-BC6R4CAF.mjs +24 -0
- package/dist/lib/browser/chunk-BC6R4CAF.mjs.map +7 -0
- package/dist/lib/browser/chunk-BPYFLHWO.mjs +158 -0
- package/dist/lib/browser/chunk-BPYFLHWO.mjs.map +7 -0
- package/dist/lib/browser/chunk-CBPFF3ZO.mjs +204 -0
- package/dist/lib/browser/chunk-CBPFF3ZO.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-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-L4RXUJHJ.mjs +143 -0
- package/dist/lib/browser/chunk-L4RXUJHJ.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-7GH6RXJ3.mjs → chunk-PAM4KEXE.mjs} +2005 -1841
- package/dist/lib/browser/chunk-PAM4KEXE.mjs.map +7 -0
- package/dist/lib/browser/chunk-QIWDIPLR.mjs +41 -0
- package/dist/lib/browser/chunk-QIWDIPLR.mjs.map +7 -0
- package/dist/lib/browser/chunk-R3S54KRI.mjs +403 -0
- package/dist/lib/browser/chunk-R3S54KRI.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-TPIL3G6Y.mjs +288 -0
- package/dist/lib/browser/chunk-TPIL3G6Y.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-ZHXZGIXD.mjs +9 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +65 -25
- package/dist/lib/browser/internal/index.mjs +213 -92
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +80 -41
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- 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-2RIFBW3A.mjs +250 -0
- package/dist/lib/node-esm/chunk-2RIFBW3A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5CB2ZW74.mjs +57 -0
- package/dist/lib/node-esm/chunk-5CB2ZW74.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-M4B6BMD2.mjs → chunk-5U5F4AWK.mjs} +2005 -1841
- package/dist/lib/node-esm/chunk-5U5F4AWK.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-BKYE5IW6.mjs +158 -0
- package/dist/lib/node-esm/chunk-BKYE5IW6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BYOD7EVP.mjs +98 -0
- package/dist/lib/node-esm/chunk-BYOD7EVP.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-K37NA7PO.mjs +43 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LIXUCQJM.mjs +41 -0
- package/dist/lib/node-esm/chunk-LIXUCQJM.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-OZEDKT4R.mjs +204 -0
- package/dist/lib/node-esm/chunk-OZEDKT4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PW3VCWL5.mjs +24 -0
- package/dist/lib/node-esm/chunk-PW3VCWL5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TSTKBFST.mjs +403 -0
- package/dist/lib/node-esm/chunk-TSTKBFST.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-UV63HEHQ.mjs +143 -0
- package/dist/lib/node-esm/chunk-UV63HEHQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WXLVPCRJ.mjs +288 -0
- package/dist/lib/node-esm/chunk-WXLVPCRJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WZ6YBELW.mjs +74 -0
- package/dist/lib/node-esm/chunk-WZ6YBELW.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-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/index.mjs +65 -25
- package/dist/lib/node-esm/internal/index.mjs +213 -92
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +80 -41
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +1 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +117 -60
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +111 -5
- package/dist/types/src/Entity.d.ts.map +1 -1
- 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} +13 -17
- 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.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +268 -76
- 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/query.d.ts → Query.d.ts} +53 -50
- 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 +9 -7
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +235 -18
- 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 +6 -6
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +213 -50
- 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 +8 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +23 -27
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/util.d.ts +1 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -1
- 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 +13 -3
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -1
- package/dist/types/src/internal/entities/index.d.ts +1 -1
- package/dist/types/src/internal/entities/index.d.ts.map +1 -1
- package/dist/types/src/internal/entities/model.d.ts +14 -7
- package/dist/types/src/internal/entities/model.d.ts.map +1 -1
- package/dist/types/src/internal/entities/object.d.ts +8 -1
- package/dist/types/src/internal/entities/object.d.ts.map +1 -1
- package/dist/types/src/internal/entities/relation.d.ts +8 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -1
- package/dist/types/src/internal/formats/format.d.ts +4 -4
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +6 -4
- 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 +6 -2
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +2 -1
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +130 -29
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts +2 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -1
- 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/create-object.d.ts +1 -1
- package/dist/types/src/internal/object/index.d.ts +3 -0
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +13 -7
- 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 +7 -13
- 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 +11 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -1
- 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 +2 -4
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -1
- 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 +14 -11
- 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 +16 -7
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts +2 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts +15 -3
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +0 -2
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +9 -7
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -1
- package/dist/types/src/internal/types/base.d.ts +5 -16
- package/dist/types/src/internal/types/base.d.ts.map +1 -1
- package/dist/types/src/internal/types/entity.d.ts +27 -2
- package/dist/types/src/internal/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/types/meta.d.ts +6 -14
- package/dist/types/src/internal/types/meta.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +141 -175
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +6 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +130 -23
- package/src/Annotation.ts +5 -4
- package/src/Database.ts +229 -82
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +173 -7
- package/src/{errors.ts → Err.ts} +2 -2
- package/src/Filter.ts +376 -0
- package/src/Format.ts +0 -2
- package/src/Hypergraph.ts +74 -0
- package/src/Obj.test.ts +386 -0
- package/src/Obj.ts +338 -250
- package/src/{query/order.ts → Order.ts} +19 -9
- package/src/{query/query.test.ts → Query.test.ts} +180 -49
- package/src/{query/query.ts → Query.ts} +115 -122
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +20 -3
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +364 -27
- package/src/SchemaRegistry.ts +105 -0
- package/src/Tag.ts +1 -1
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +322 -88
- package/src/index.ts +9 -5
- package/src/internal/README.md +36 -17
- package/src/internal/annotations/annotations.test.ts +6 -6
- package/src/internal/annotations/annotations.ts +73 -76
- package/src/internal/annotations/util.ts +2 -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 +36 -19
- package/src/internal/entities/index.ts +1 -1
- package/src/internal/entities/model.ts +17 -12
- package/src/internal/entities/object.ts +21 -8
- package/src/internal/entities/relation.ts +23 -7
- package/src/internal/formats/format.test.ts +1 -1
- package/src/internal/formats/format.ts +7 -8
- package/src/internal/formats/object.ts +2 -2
- package/src/internal/formats/select.ts +6 -4
- package/src/internal/formats/string.ts +5 -0
- package/src/internal/formats/types.ts +9 -3
- package/src/internal/index.ts +2 -1
- package/src/internal/json-schema/json-schema-normalize.ts +4 -2
- package/src/internal/json-schema/json-schema-type.ts +31 -32
- package/src/internal/json-schema/json-schema.test.ts +19 -17
- package/src/internal/json-schema/json-schema.ts +14 -10
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/create-object.ts +2 -2
- package/src/internal/object/index.ts +3 -0
- package/src/internal/object/inspect.ts +3 -3
- package/src/internal/object/json-serializer.test.ts +6 -2
- package/src/internal/object/json-serializer.ts +28 -70
- package/src/internal/object/schema-validator.test.ts +3 -7
- package/src/internal/object/schema-validator.ts +2 -238
- 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 -72
- 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 +30 -80
- package/src/internal/proxy/index.ts +11 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +33 -50
- 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 +23 -15
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +247 -35
- package/src/internal/proxy/typed-handler.ts +265 -56
- package/src/internal/proxy/typed-object.test.ts +37 -26
- package/src/internal/ref/ref-array.ts +4 -4
- package/src/internal/ref/ref.test.ts +1 -1
- package/src/internal/ref/ref.ts +64 -40
- package/src/internal/schema/compose.test.ts +3 -3
- package/src/internal/schema/compose.ts +13 -9
- package/src/internal/schema/echo-schema.ts +49 -11
- package/src/internal/schema/index.ts +0 -2
- package/src/internal/schema/persistent-schema.ts +3 -4
- package/src/internal/types/base.ts +6 -21
- package/src/internal/types/entity.ts +35 -4
- package/src/internal/types/meta.ts +13 -24
- package/src/testing/api.test.ts +31 -5
- package/src/testing/test-schema.ts +55 -30
- package/src/testing/util.ts +22 -15
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +0 -7
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +0 -1111
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +0 -1111
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +0 -7
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/entities/expando.d.ts +0 -16
- package/dist/types/src/internal/entities/expando.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/query/filter.d.ts +0 -167
- package/dist/types/src/query/filter.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -5
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/order.d.ts +0 -12
- package/dist/types/src/query/order.d.ts.map +0 -1
- 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/testing.d.ts +0 -51
- package/dist/types/src/query/testing.d.ts.map +0 -1
- package/dist/types/src/query/types.d.ts +0 -17
- package/dist/types/src/query/types.d.ts.map +0 -1
- package/dist/types/src/query/util.d.ts +0 -8
- package/dist/types/src/query/util.d.ts.map +0 -1
- package/src/internal/entities/expando.ts +0 -23
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/query/filter.ts +0 -455
- package/src/query/index.ts +0 -9
- package/src/query/testing.ts +0 -64
- package/src/query/types.ts +0 -23
- package/src/query/util.ts +0 -25
package/src/internal/ref/ref.ts
CHANGED
|
@@ -7,15 +7,18 @@ import * as Option from 'effect/Option';
|
|
|
7
7
|
import * as ParseResult from 'effect/ParseResult';
|
|
8
8
|
import * as Schema from 'effect/Schema';
|
|
9
9
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
10
|
+
import type * as Types from 'effect/Types';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { Event } from '@dxos/async';
|
|
13
|
+
import { type CustomInspectFunction, inspectCustom } from '@dxos/debug';
|
|
14
|
+
import { EncodedReference } from '@dxos/echo-protocol';
|
|
13
15
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
14
16
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
15
17
|
|
|
18
|
+
import * as Database from '../../Database';
|
|
16
19
|
import { ReferenceAnnotationId, getSchemaDXN, getTypeAnnotation, getTypeIdentifierAnnotation } from '../annotations';
|
|
17
20
|
import { type JsonSchemaType } from '../json-schema';
|
|
18
|
-
import type {
|
|
21
|
+
import type { AnyEntity, AnyProperties } from '../types';
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* The `$id` and `$ref` fields for an ECHO reference schema.
|
|
@@ -29,7 +32,7 @@ export const getSchemaReference = (property: JsonSchemaType): { typename: string
|
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
export const createSchemaReference = (typename: string): JsonSchemaType => {
|
|
35
|
+
export const createSchemaReference = (typename: string): Types.DeepMutable<JsonSchemaType> => {
|
|
33
36
|
return {
|
|
34
37
|
$id: JSON_SCHEMA_ECHO_REF_ID,
|
|
35
38
|
reference: {
|
|
@@ -70,7 +73,7 @@ export const RefTypeId: unique symbol = Symbol('@dxos/echo/internal/Ref');
|
|
|
70
73
|
/**
|
|
71
74
|
* Reference Schema.
|
|
72
75
|
*/
|
|
73
|
-
export interface RefSchema<T extends
|
|
76
|
+
export interface RefSchema<T extends AnyEntity> extends Schema.SchemaClass<Ref<T>, EncodedReference> {}
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* Type of the `Ref` function and extra methods attached to it.
|
|
@@ -101,8 +104,8 @@ export interface RefFn {
|
|
|
101
104
|
/**
|
|
102
105
|
* Constructs a reference that points to the given object.
|
|
103
106
|
*/
|
|
104
|
-
// TODO(burdon): Narrow to Obj.
|
|
105
|
-
make: <T extends
|
|
107
|
+
// TODO(burdon): Narrow to Obj.Unknown?
|
|
108
|
+
make: <T extends AnyEntity>(object: T) => Ref<T>;
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* Constructs a reference that points to the object specified by the provided DXN.
|
|
@@ -115,18 +118,12 @@ export interface RefFn {
|
|
|
115
118
|
*/
|
|
116
119
|
export const Ref: RefFn = <S extends Schema.Schema.Any>(schema: S): RefSchema<Schema.Schema.Type<S>> => {
|
|
117
120
|
assertArgument(Schema.isSchema(schema), 'schema', 'Must call with an instance of effect-schema');
|
|
118
|
-
|
|
119
121
|
const annotation = getTypeAnnotation(schema);
|
|
120
122
|
if (annotation == null) {
|
|
121
123
|
throw new Error('Reference target must be an ECHO schema.');
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
return createEchoReferenceSchema(
|
|
125
|
-
getTypeIdentifierAnnotation(schema),
|
|
126
|
-
annotation.typename,
|
|
127
|
-
annotation.version,
|
|
128
|
-
getSchemaExpectedName(schema.ast),
|
|
129
|
-
);
|
|
126
|
+
return createEchoReferenceSchema(getTypeIdentifierAnnotation(schema), annotation.typename, annotation.version);
|
|
130
127
|
};
|
|
131
128
|
|
|
132
129
|
/**
|
|
@@ -139,12 +136,15 @@ export interface Ref<T> {
|
|
|
139
136
|
*/
|
|
140
137
|
get dxn(): DXN;
|
|
141
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Returns true if the reference has a target available (inlined or resolver set).
|
|
141
|
+
*/
|
|
142
|
+
get isAvailable(): boolean;
|
|
143
|
+
|
|
142
144
|
/**
|
|
143
145
|
* @returns The reference target.
|
|
144
146
|
* May return `undefined` if the object is not loaded in the working set.
|
|
145
147
|
* Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.
|
|
146
|
-
*
|
|
147
|
-
* @reactive Supports signal subscriptions.
|
|
148
148
|
*/
|
|
149
149
|
get target(): T | undefined;
|
|
150
150
|
|
|
@@ -158,6 +158,7 @@ export interface Ref<T> {
|
|
|
158
158
|
/**
|
|
159
159
|
* @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.
|
|
160
160
|
*/
|
|
161
|
+
|
|
161
162
|
tryLoad(): Promise<T | undefined>;
|
|
162
163
|
|
|
163
164
|
/**
|
|
@@ -219,7 +220,7 @@ Ref.make = <T extends AnyProperties>(obj: T): Ref<T> => {
|
|
|
219
220
|
// TODO(dmaretskyi): Extract to `getObjectDXN` function.
|
|
220
221
|
const id = obj.id;
|
|
221
222
|
invariant(ObjectId.isValid(id), 'Invalid object ID');
|
|
222
|
-
const dxn =
|
|
223
|
+
const dxn = DXN.fromLocalObjectId(id);
|
|
223
224
|
return new RefImpl(dxn, obj);
|
|
224
225
|
};
|
|
225
226
|
|
|
@@ -244,7 +245,6 @@ export const createEchoReferenceSchema = (
|
|
|
244
245
|
echoId: string | undefined,
|
|
245
246
|
typename: string | undefined,
|
|
246
247
|
version: string | undefined,
|
|
247
|
-
schemaName?: string, // TODO(burdon): Not used.
|
|
248
248
|
): Schema.SchemaClass<Ref<any>, EncodedReference> => {
|
|
249
249
|
if (!echoId && !typename) {
|
|
250
250
|
throw new TypeError('Either echoId or typename must be provided.');
|
|
@@ -263,25 +263,39 @@ export const createEchoReferenceSchema = (
|
|
|
263
263
|
[],
|
|
264
264
|
{
|
|
265
265
|
encode: () => {
|
|
266
|
-
return (value) =>
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
return (value) =>
|
|
267
|
+
Effect.gen(function* () {
|
|
268
|
+
if (Ref.isRef(value)) {
|
|
269
|
+
return EncodedReference.fromDXN((value as Ref<any>).dxn);
|
|
270
|
+
} else if (EncodedReference.isEncodedReference(value)) {
|
|
271
|
+
return value;
|
|
272
|
+
}
|
|
273
|
+
throw new Error('Invalid reference');
|
|
269
274
|
});
|
|
270
|
-
};
|
|
271
275
|
},
|
|
272
276
|
decode: () => {
|
|
273
|
-
return (value) =>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
277
|
+
return (value) =>
|
|
278
|
+
Effect.gen(function* () {
|
|
279
|
+
const dbService = yield* Effect.serviceOption(Database.Service);
|
|
280
|
+
|
|
281
|
+
// TODO(dmaretskyi): This branch seems to be taken by Schema.is
|
|
282
|
+
if (Ref.isRef(value)) {
|
|
283
|
+
if (Option.isSome(dbService)) {
|
|
284
|
+
return dbService.value.db.makeRef(value.dxn);
|
|
285
|
+
} else {
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (!EncodedReference.isEncodedReference(value)) {
|
|
291
|
+
return yield* Effect.fail(new ParseResult.Unexpected(value, 'reference'));
|
|
292
|
+
}
|
|
293
|
+
if (Option.isSome(dbService)) {
|
|
294
|
+
return dbService.value.db.makeRef(EncodedReference.toDXN(value));
|
|
295
|
+
} else {
|
|
296
|
+
return Ref.fromDXN(EncodedReference.toDXN(value));
|
|
297
|
+
}
|
|
298
|
+
});
|
|
285
299
|
},
|
|
286
300
|
},
|
|
287
301
|
{
|
|
@@ -331,7 +345,7 @@ export interface RefResolver {
|
|
|
331
345
|
export class RefImpl<T> implements Ref<T> {
|
|
332
346
|
#dxn: DXN;
|
|
333
347
|
#resolver?: RefResolver = undefined;
|
|
334
|
-
#
|
|
348
|
+
#resolved = new Event<void>();
|
|
335
349
|
|
|
336
350
|
/**
|
|
337
351
|
* Target is set when the reference is created from a specific object.
|
|
@@ -343,7 +357,7 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
343
357
|
* Callback to issue a reactive notification when object is resolved.
|
|
344
358
|
*/
|
|
345
359
|
#resolverCallback = () => {
|
|
346
|
-
this.#
|
|
360
|
+
this.#resolved.emit();
|
|
347
361
|
};
|
|
348
362
|
|
|
349
363
|
constructor(dxn: DXN, target?: T) {
|
|
@@ -358,11 +372,17 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
358
372
|
return this.#dxn;
|
|
359
373
|
}
|
|
360
374
|
|
|
375
|
+
/**
|
|
376
|
+
* @inheritdoc
|
|
377
|
+
*/
|
|
378
|
+
get isAvailable(): boolean {
|
|
379
|
+
return this.#target !== undefined || this.#resolver !== undefined;
|
|
380
|
+
}
|
|
381
|
+
|
|
361
382
|
/**
|
|
362
383
|
* @inheritdoc
|
|
363
384
|
*/
|
|
364
385
|
get target(): T | undefined {
|
|
365
|
-
this.#signal.notifyRead();
|
|
366
386
|
if (this.#target) {
|
|
367
387
|
return this.#target;
|
|
368
388
|
}
|
|
@@ -390,6 +410,9 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
390
410
|
* @inheritdoc
|
|
391
411
|
*/
|
|
392
412
|
async tryLoad(): Promise<T | undefined> {
|
|
413
|
+
if (this.#target) {
|
|
414
|
+
return this.#target;
|
|
415
|
+
}
|
|
393
416
|
invariant(this.#resolver, 'Resolver is not set');
|
|
394
417
|
return (await this.#resolver.resolve(this.#dxn)) as T | undefined;
|
|
395
418
|
}
|
|
@@ -430,6 +453,10 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
430
453
|
return `Ref(${this.#dxn.toString()})`;
|
|
431
454
|
}
|
|
432
455
|
|
|
456
|
+
[inspectCustom]: CustomInspectFunction = (depth, options, inspect) => {
|
|
457
|
+
return this.toString();
|
|
458
|
+
};
|
|
459
|
+
|
|
433
460
|
[RefTypeId] = refVariance;
|
|
434
461
|
|
|
435
462
|
/**
|
|
@@ -442,9 +469,6 @@ export class RefImpl<T> implements Ref<T> {
|
|
|
442
469
|
}
|
|
443
470
|
|
|
444
471
|
/**
|
|
445
|
-
* Internal method to get the saved target.
|
|
446
|
-
* Not the same as `target` which is resolved from the resolver.
|
|
447
|
-
*
|
|
448
472
|
* @internal
|
|
449
473
|
*/
|
|
450
474
|
_getSavedTarget(): T | undefined {
|
|
@@ -6,18 +6,18 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { FieldPath } from '../annotations';
|
|
9
|
+
import { EchoObjectSchema } from '../entities';
|
|
9
10
|
import { FormatAnnotation, TypeFormat } from '../formats';
|
|
10
11
|
import { ECHO_ANNOTATIONS_NS_KEY, toJsonSchema } from '../json-schema';
|
|
11
|
-
import { TypedObject } from '../object';
|
|
12
12
|
|
|
13
13
|
import { composeSchema } from './compose';
|
|
14
14
|
|
|
15
15
|
describe('schema composition', () => {
|
|
16
16
|
test('schema composition', ({ expect }) => {
|
|
17
|
-
|
|
17
|
+
const BaseType = Schema.Struct({
|
|
18
18
|
name: Schema.String,
|
|
19
19
|
email: Schema.String,
|
|
20
|
-
})
|
|
20
|
+
}).pipe(EchoObjectSchema({ typename: 'example.com/Person', version: '0.1.0' }));
|
|
21
21
|
|
|
22
22
|
const OverlaySchema = Schema.Struct({
|
|
23
23
|
email: Schema.String.pipe(FieldPath('$.email'), FormatAnnotation.set(TypeFormat.Email)),
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as Types from 'effect/Types';
|
|
6
|
+
|
|
5
7
|
import { invariant } from '@dxos/invariant';
|
|
6
8
|
|
|
7
9
|
import { type JsonSchemaType } from '../json-schema';
|
|
8
10
|
|
|
9
|
-
import { getSnapshot } from './snapshot';
|
|
10
|
-
|
|
11
11
|
/**
|
|
12
12
|
* Creates a composite schema from the source and projection schemas.
|
|
13
13
|
*/
|
|
14
14
|
// TODO(burdon): Use effect schema projections.
|
|
15
15
|
// TODO(burdon): Can avoid having to call this every time we modify any property on the view?
|
|
16
|
-
export const composeSchema = (
|
|
17
|
-
|
|
16
|
+
export const composeSchema = (
|
|
17
|
+
source: Types.Mutable<JsonSchemaType>,
|
|
18
|
+
target: Types.Mutable<JsonSchemaType>,
|
|
19
|
+
): Types.Mutable<JsonSchemaType> => {
|
|
20
|
+
const result = structuredClone(target);
|
|
18
21
|
invariant('type' in result && result.type === 'object', 'source schema must be an object');
|
|
19
22
|
invariant('type' in source && source.type === 'object', 'target schema must be an object');
|
|
20
23
|
|
|
@@ -22,12 +25,13 @@ export const composeSchema = (source: JsonSchemaType, target: JsonSchemaType): J
|
|
|
22
25
|
const propSchema = source.properties![prop]; // TODO(dmaretskyi): Find by json-path instead.
|
|
23
26
|
const annotations = (propSchema as JsonSchemaType)?.annotations?.meta;
|
|
24
27
|
if (annotations) {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const resultProp = result.properties[prop] as Record<string, any>;
|
|
29
|
+
resultProp.annotations ??= {};
|
|
30
|
+
resultProp.annotations.meta ??= {};
|
|
27
31
|
for (const key in annotations) {
|
|
28
|
-
|
|
29
|
-
Object.assign(
|
|
30
|
-
...
|
|
32
|
+
resultProp.annotations.meta[key] ??= {};
|
|
33
|
+
Object.assign(resultProp.annotations.meta[key], annotations[key], {
|
|
34
|
+
...resultProp.annotations.meta[key],
|
|
31
35
|
});
|
|
32
36
|
}
|
|
33
37
|
}
|
|
@@ -10,7 +10,9 @@ import { type ObjectId } from '@dxos/keys';
|
|
|
10
10
|
|
|
11
11
|
import { type SchemaMeta, SchemaMetaSymbol, type TypeAnnotation, getTypeAnnotation } from '../annotations';
|
|
12
12
|
import { type JsonSchemaType, toEffectSchema, toJsonSchema } from '../json-schema';
|
|
13
|
-
import { type TypedObject, type TypedObjectPrototype } from '../object';
|
|
13
|
+
import { type TypedObject, type TypedObjectPrototype, getSnapshot } from '../object';
|
|
14
|
+
import { ChangeId } from '../proxy';
|
|
15
|
+
import { EntityKind, SchemaKindId } from '../types';
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
18
|
addFieldsToSchema,
|
|
@@ -20,7 +22,6 @@ import {
|
|
|
20
22
|
updateFieldsInSchema,
|
|
21
23
|
} from './manipulation';
|
|
22
24
|
import { PersistentSchema } from './persistent-schema';
|
|
23
|
-
import { getSnapshot } from './snapshot';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Base schema type.
|
|
@@ -83,6 +84,10 @@ export class ImmutableSchema<A = any, I = any> implements BaseSchema<A, I> {
|
|
|
83
84
|
// TypedObject
|
|
84
85
|
//
|
|
85
86
|
|
|
87
|
+
get kind(): EntityKind {
|
|
88
|
+
return this._objectAnnotation.kind;
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
get typename(): string {
|
|
87
92
|
return this._objectAnnotation.typename;
|
|
88
93
|
}
|
|
@@ -172,7 +177,7 @@ const schemaVariance = {
|
|
|
172
177
|
*
|
|
173
178
|
* @example
|
|
174
179
|
* ```ts
|
|
175
|
-
* export class TableType extends Schema.Struct({...}).pipe(Type.
|
|
180
|
+
* export class TableType extends Schema.Struct({...}).pipe(Type.object({ typename: 'example.org/type/Table', version: '0.1.0' })){
|
|
176
181
|
* title: Schema.String,
|
|
177
182
|
* schema: Schema.optional(ref(EchoSchema)),
|
|
178
183
|
* props: Schema.mutable(S.Array(TablePropSchema)),
|
|
@@ -185,6 +190,12 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
185
190
|
private _schema: Schema.Schema.AnyNoContext | undefined;
|
|
186
191
|
private _isDirty = true;
|
|
187
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Schema kind key that marks this as an ECHO schema.
|
|
195
|
+
* Makes EchoSchema satisfy the Type.Obj.Any type.
|
|
196
|
+
*/
|
|
197
|
+
readonly [SchemaKindId]: EntityKind.Object = EntityKind.Object;
|
|
198
|
+
|
|
188
199
|
constructor(private readonly _persistentSchema: PersistentSchema) {
|
|
189
200
|
super();
|
|
190
201
|
}
|
|
@@ -229,6 +240,11 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
229
240
|
// BaseSchema
|
|
230
241
|
//
|
|
231
242
|
|
|
243
|
+
public get kind(): EntityKind.Object {
|
|
244
|
+
// Dynamic schemas are always object schemas.
|
|
245
|
+
return EntityKind.Object;
|
|
246
|
+
}
|
|
247
|
+
|
|
232
248
|
public get typename(): string {
|
|
233
249
|
return this._persistentSchema.typename;
|
|
234
250
|
}
|
|
@@ -249,7 +265,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
249
265
|
}
|
|
250
266
|
|
|
251
267
|
/**
|
|
252
|
-
*
|
|
268
|
+
* Returns the JSON schema for the schema.
|
|
253
269
|
*/
|
|
254
270
|
public get jsonSchema(): JsonSchemaType {
|
|
255
271
|
return this._persistentSchema.jsonSchema;
|
|
@@ -309,8 +325,10 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
309
325
|
*/
|
|
310
326
|
public updateTypename(typename: string): void {
|
|
311
327
|
const updated = setTypenameInSchema(this._getSchema(), typename);
|
|
312
|
-
this.
|
|
313
|
-
|
|
328
|
+
this._change((schema) => {
|
|
329
|
+
schema.typename = typename;
|
|
330
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
331
|
+
});
|
|
314
332
|
}
|
|
315
333
|
|
|
316
334
|
/**
|
|
@@ -318,7 +336,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
318
336
|
*/
|
|
319
337
|
public addFields(fields: Schema.Struct.Fields): void {
|
|
320
338
|
const extended = addFieldsToSchema(this._getSchema(), fields);
|
|
321
|
-
this.
|
|
339
|
+
this._change((schema) => {
|
|
340
|
+
schema.jsonSchema = toJsonSchema(extended);
|
|
341
|
+
});
|
|
322
342
|
}
|
|
323
343
|
|
|
324
344
|
/**
|
|
@@ -326,7 +346,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
326
346
|
*/
|
|
327
347
|
public updateFields(fields: Schema.Struct.Fields): void {
|
|
328
348
|
const updated = updateFieldsInSchema(this._getSchema(), fields);
|
|
329
|
-
this.
|
|
349
|
+
this._change((schema) => {
|
|
350
|
+
schema.jsonSchema = toJsonSchema(updated);
|
|
351
|
+
});
|
|
330
352
|
}
|
|
331
353
|
|
|
332
354
|
/**
|
|
@@ -334,7 +356,9 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
334
356
|
*/
|
|
335
357
|
public updateFieldPropertyName({ before, after }: { before: PropertyKey; after: PropertyKey }): void {
|
|
336
358
|
const renamed = updateFieldNameInSchema(this._getSchema(), { before, after });
|
|
337
|
-
this.
|
|
359
|
+
this._change((schema) => {
|
|
360
|
+
schema.jsonSchema = toJsonSchema(renamed);
|
|
361
|
+
});
|
|
338
362
|
}
|
|
339
363
|
|
|
340
364
|
/**
|
|
@@ -342,7 +366,21 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
342
366
|
*/
|
|
343
367
|
public removeFields(fieldNames: string[]): void {
|
|
344
368
|
const removed = removeFieldsFromSchema(this._getSchema(), fieldNames);
|
|
345
|
-
this.
|
|
369
|
+
this._change((schema) => {
|
|
370
|
+
schema.jsonSchema = toJsonSchema(removed);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Wrapper for Obj.change that handles the change context for the persistent schema.
|
|
376
|
+
*/
|
|
377
|
+
private _change(callback: (schema: PersistentSchema) => void): void {
|
|
378
|
+
const changeFn = (this._persistentSchema as any)[ChangeId];
|
|
379
|
+
if (changeFn) {
|
|
380
|
+
changeFn(callback);
|
|
381
|
+
} else {
|
|
382
|
+
callback(this._persistentSchema);
|
|
383
|
+
}
|
|
346
384
|
}
|
|
347
385
|
|
|
348
386
|
//
|
|
@@ -350,7 +388,7 @@ export class EchoSchema<A = any, I = any> extends EchoSchemaConstructor() implem
|
|
|
350
388
|
//
|
|
351
389
|
|
|
352
390
|
/**
|
|
353
|
-
* Called by
|
|
391
|
+
* Called by DatabaseSchemaRegistry on update.
|
|
354
392
|
*/
|
|
355
393
|
_invalidate(): void {
|
|
356
394
|
this._isDirty = true;
|
|
@@ -12,7 +12,7 @@ import { JsonSchemaType } from '../json-schema';
|
|
|
12
12
|
* Persistent representation of a schema.
|
|
13
13
|
*/
|
|
14
14
|
// TODO(burdon): Move.
|
|
15
|
-
const
|
|
15
|
+
export const PersistentSchema = Schema.Struct({
|
|
16
16
|
name: Schema.optional(Schema.String),
|
|
17
17
|
typename: TypenameSchema,
|
|
18
18
|
version: VersionSchema,
|
|
@@ -23,6 +23,5 @@ const PersistentEchoSchema = Schema.Struct({
|
|
|
23
23
|
version: '0.1.0',
|
|
24
24
|
}),
|
|
25
25
|
);
|
|
26
|
-
|
|
27
|
-
export interface
|
|
28
|
-
export const PersistentSchema: Schema.Schema<PersistentSchema, PersistentSchemaEncoded> = PersistentEchoSchema;
|
|
26
|
+
|
|
27
|
+
export interface PersistentSchema extends Schema.Schema.Type<typeof PersistentSchema> {}
|
|
@@ -9,20 +9,6 @@ import { type ObjectId } from '@dxos/keys';
|
|
|
9
9
|
|
|
10
10
|
import { type ATTR_META, type ObjectMeta } from './meta';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Marker interface for object with an `id`.
|
|
14
|
-
*/
|
|
15
|
-
export interface HasId {
|
|
16
|
-
readonly id: ObjectId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Object that has an associated typename.
|
|
21
|
-
* The typename is retrievable using {@link getTypename}.
|
|
22
|
-
* The object can be used with {@link isInstanceOf} to check if it is an instance of a schema.
|
|
23
|
-
*/
|
|
24
|
-
export type HasTypename = {};
|
|
25
|
-
|
|
26
12
|
/**
|
|
27
13
|
* Base type for all data objects (reactive, ECHO, and other raw objects).
|
|
28
14
|
* NOTE: This describes the base type for all database objects.
|
|
@@ -30,23 +16,22 @@ export type HasTypename = {};
|
|
|
30
16
|
*/
|
|
31
17
|
// TODO(burdon): Make internal.
|
|
32
18
|
// TODO(burdon): Prefer Record<string, unknown>.
|
|
33
|
-
// TODO(burdon): Exclude "id", etc. from keys.
|
|
34
19
|
export type AnyProperties = Record<string, any>;
|
|
35
20
|
|
|
36
21
|
/**
|
|
37
|
-
* Canonical type for all ECHO objects.
|
|
22
|
+
* Canonical type for all ECHO entities (objects and relations).
|
|
38
23
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
// TODO(wittjosiah): Remove. Prefer higher level types (e.g. Entity.Unknown).
|
|
25
|
+
export interface AnyEntity {
|
|
26
|
+
readonly id: ObjectId;
|
|
27
|
+
}
|
|
43
28
|
|
|
44
29
|
export type ExcludeId<T extends AnyProperties> = Omit<T, 'id'>;
|
|
45
30
|
|
|
46
31
|
export type PropertyKey<T extends AnyProperties> = Extract<keyof ExcludeId<T>, string>;
|
|
47
32
|
|
|
48
33
|
// TODO(dmaretskyi): Remove. This should be using the symbol type.
|
|
49
|
-
|
|
34
|
+
type WithMeta = { [ATTR_META]?: ObjectMeta };
|
|
50
35
|
|
|
51
36
|
/**
|
|
52
37
|
* The raw object should not include the ECHO id, but may include metadata.
|
|
@@ -4,10 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
+
// NOTE: String literals are used instead of unique symbols for both KindId and SchemaKindId.
|
|
8
|
+
// Unique symbols cause TS4023 "cannot be named" errors when external packages
|
|
9
|
+
// try to export types that reference this key (e.g., `export const Graph = ...`).
|
|
10
|
+
// TypeScript cannot emit declaration files that reference unique symbols from
|
|
11
|
+
// external modules. Using a string literal allows the type to be inlined in
|
|
12
|
+
// declaration files, making the API portable across package boundaries.
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* String key used to identify the kind of an entity instance (object or relation).
|
|
16
|
+
*/
|
|
17
|
+
export const KindId = '~@dxos/echo/Kind' as const;
|
|
18
|
+
export type KindId = typeof KindId;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* String key used to identify the kind of a schema (object schema or relation schema).
|
|
22
|
+
* Parallels KindId which identifies instance kinds.
|
|
23
|
+
*/
|
|
24
|
+
export const SchemaKindId = '~@dxos/echo/SchemaKind' as const;
|
|
25
|
+
export type SchemaKindId = typeof SchemaKindId;
|
|
26
|
+
|
|
7
27
|
/**
|
|
8
|
-
*
|
|
28
|
+
* String key used to brand snapshot types.
|
|
29
|
+
* Snapshots have SnapshotKindId instead of KindId, making them
|
|
30
|
+
* distinguishable from reactive objects at the type level.
|
|
9
31
|
*/
|
|
10
|
-
const
|
|
32
|
+
export const SnapshotKindId = '~@dxos/echo/SnapshotKind' as const;
|
|
33
|
+
export type SnapshotKindId = typeof SnapshotKindId;
|
|
11
34
|
|
|
12
35
|
/**
|
|
13
36
|
* Kinds of entities stored in ECHO: objects and relations.
|
|
@@ -19,5 +42,13 @@ export enum EntityKind {
|
|
|
19
42
|
|
|
20
43
|
export const EntityKindSchema = Schema.Enums(EntityKind);
|
|
21
44
|
|
|
22
|
-
|
|
23
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Typename for generic object references (Type.Obj / Type.Ref(Type.Obj)).
|
|
47
|
+
* Used when referencing any object without a specific schema.
|
|
48
|
+
*/
|
|
49
|
+
export const ANY_OBJECT_TYPENAME = 'dxos.org/schema/AnyObject';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Version for generic object references.
|
|
53
|
+
*/
|
|
54
|
+
export const ANY_OBJECT_VERSION = '0.0.0';
|
|
@@ -8,7 +8,7 @@ import { ForeignKey } from '@dxos/echo-protocol';
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { type Comparator, intersection } from '@dxos/util';
|
|
10
10
|
|
|
11
|
-
import { type AnyProperties
|
|
11
|
+
import { type AnyProperties } from './base';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Property name for meta when object is serialized to JSON.
|
|
@@ -25,20 +25,19 @@ export const MetaId = Symbol.for('@dxos/echo/Meta');
|
|
|
25
25
|
//
|
|
26
26
|
|
|
27
27
|
// TODO(dmaretskyi): Rename to ObjectMeta
|
|
28
|
-
export const ObjectMetaSchema = Schema.
|
|
29
|
-
Schema.
|
|
30
|
-
|
|
28
|
+
export const ObjectMetaSchema = Schema.Struct({
|
|
29
|
+
keys: Schema.Array(ForeignKey),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A set of tags.
|
|
33
|
+
* Tags are arbitrary application-defined strings.
|
|
34
|
+
* ECHO makes no assumptions about the tag structure.
|
|
35
|
+
*/
|
|
36
|
+
// TODO(dmaretskyi): Has to be optional for compatibility with old data.
|
|
37
|
+
// Defaulting to an empty array is possible but requires a bit more work.
|
|
38
|
+
tags: Schema.optional(Schema.Array(Schema.String)),
|
|
39
|
+
});
|
|
31
40
|
|
|
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
41
|
export type ObjectMeta = Schema.Schema.Type<typeof ObjectMetaSchema>;
|
|
43
42
|
|
|
44
43
|
/*
|
|
@@ -54,16 +53,6 @@ export const getMeta = (obj: AnyProperties): ObjectMeta => {
|
|
|
54
53
|
return metadata;
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
/**
|
|
58
|
-
* Utility to split meta property from raw object.
|
|
59
|
-
* @deprecated Bad API.
|
|
60
|
-
*/
|
|
61
|
-
export const splitMeta = <T>(object: T & WithMeta): { object: T; meta?: ObjectMeta } => {
|
|
62
|
-
const meta = object[ATTR_META];
|
|
63
|
-
delete object[ATTR_META];
|
|
64
|
-
return { meta, object };
|
|
65
|
-
};
|
|
66
|
-
|
|
67
56
|
//
|
|
68
57
|
// Foreign keys
|
|
69
58
|
//
|