@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
|
@@ -35,7 +35,7 @@ const EXAMPLE_NAMESPACE = '@example';
|
|
|
35
35
|
describe('effect-to-json', () => {
|
|
36
36
|
test('type annotation', () => {
|
|
37
37
|
const Test = Schema.Struct({ name: Schema.String }).pipe(
|
|
38
|
-
Type.
|
|
38
|
+
Type.object({
|
|
39
39
|
typename: 'example.com/type/Test',
|
|
40
40
|
version: '0.1.0',
|
|
41
41
|
}),
|
|
@@ -50,7 +50,7 @@ describe('effect-to-json', () => {
|
|
|
50
50
|
const Test = Schema.Struct({
|
|
51
51
|
name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
|
|
52
52
|
}).pipe(
|
|
53
|
-
Type.
|
|
53
|
+
Type.object({
|
|
54
54
|
typename: 'example.com/type/Test',
|
|
55
55
|
version: '0.1.0',
|
|
56
56
|
}),
|
|
@@ -63,7 +63,7 @@ describe('effect-to-json', () => {
|
|
|
63
63
|
const Nested = Schema.Struct({
|
|
64
64
|
name: Schema.String,
|
|
65
65
|
}).pipe(
|
|
66
|
-
Type.
|
|
66
|
+
Type.object({
|
|
67
67
|
typename: 'example.com/type/TestNested',
|
|
68
68
|
version: '0.1.0',
|
|
69
69
|
}),
|
|
@@ -71,7 +71,7 @@ describe('effect-to-json', () => {
|
|
|
71
71
|
const Test = Schema.Struct({
|
|
72
72
|
name: Ref(Nested),
|
|
73
73
|
}).pipe(
|
|
74
|
-
Type.
|
|
74
|
+
Type.object({
|
|
75
75
|
typename: 'example.com/type/Test',
|
|
76
76
|
version: '0.1.0',
|
|
77
77
|
}),
|
|
@@ -88,7 +88,7 @@ describe('effect-to-json', () => {
|
|
|
88
88
|
const Nested = Schema.Struct({
|
|
89
89
|
name: Schema.String,
|
|
90
90
|
}).pipe(
|
|
91
|
-
Type.
|
|
91
|
+
Type.object({
|
|
92
92
|
typename: 'example.com/type/TestNested',
|
|
93
93
|
version: '0.1.0',
|
|
94
94
|
}),
|
|
@@ -96,7 +96,7 @@ describe('effect-to-json', () => {
|
|
|
96
96
|
const Test = Schema.Struct({
|
|
97
97
|
name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
|
|
98
98
|
}).pipe(
|
|
99
|
-
Type.
|
|
99
|
+
Type.object({
|
|
100
100
|
typename: 'example.com/type/Test',
|
|
101
101
|
version: '0.1.0',
|
|
102
102
|
}),
|
|
@@ -112,7 +112,7 @@ describe('effect-to-json', () => {
|
|
|
112
112
|
const Nested = Schema.Struct({
|
|
113
113
|
name: Schema.String,
|
|
114
114
|
}).pipe(
|
|
115
|
-
Type.
|
|
115
|
+
Type.object({
|
|
116
116
|
typename: 'example.com/type/TestNested',
|
|
117
117
|
version: '0.1.0',
|
|
118
118
|
}),
|
|
@@ -120,7 +120,7 @@ describe('effect-to-json', () => {
|
|
|
120
120
|
const Test = Schema.Struct({
|
|
121
121
|
name: Schema.Array(Ref(Nested)),
|
|
122
122
|
}).pipe(
|
|
123
|
-
Type.
|
|
123
|
+
Type.object({
|
|
124
124
|
typename: 'example.com/type/Test',
|
|
125
125
|
version: '0.1.0',
|
|
126
126
|
}),
|
|
@@ -134,7 +134,7 @@ describe('effect-to-json', () => {
|
|
|
134
134
|
const Nested = Schema.Struct({
|
|
135
135
|
name: Schema.String,
|
|
136
136
|
}).pipe(
|
|
137
|
-
Type.
|
|
137
|
+
Type.object({
|
|
138
138
|
typename: 'example.com/type/TestNested',
|
|
139
139
|
version: '0.1.0',
|
|
140
140
|
}),
|
|
@@ -142,7 +142,7 @@ describe('effect-to-json', () => {
|
|
|
142
142
|
const Test = Schema.Struct({
|
|
143
143
|
name: Schema.optional(Ref(Nested)),
|
|
144
144
|
}).pipe(
|
|
145
|
-
Type.
|
|
145
|
+
Type.object({
|
|
146
146
|
typename: 'example.com/type/Test',
|
|
147
147
|
version: '0.1.0',
|
|
148
148
|
}),
|
|
@@ -165,7 +165,7 @@ describe('effect-to-json', () => {
|
|
|
165
165
|
description: 'Email address',
|
|
166
166
|
}),
|
|
167
167
|
}).pipe(
|
|
168
|
-
Type.
|
|
168
|
+
Type.object({
|
|
169
169
|
typename: 'example.com/type/Person',
|
|
170
170
|
version: '0.1.0',
|
|
171
171
|
}),
|
|
@@ -204,9 +204,11 @@ describe('effect-to-json', () => {
|
|
|
204
204
|
'name',
|
|
205
205
|
'username',
|
|
206
206
|
'email',
|
|
207
|
+
'age',
|
|
207
208
|
'tasks',
|
|
208
209
|
'employer',
|
|
209
210
|
'address',
|
|
211
|
+
'fields',
|
|
210
212
|
]);
|
|
211
213
|
});
|
|
212
214
|
|
|
@@ -214,7 +216,7 @@ describe('effect-to-json', () => {
|
|
|
214
216
|
const Organization = Schema.Struct({
|
|
215
217
|
field: Schema.String,
|
|
216
218
|
}).pipe(
|
|
217
|
-
Type.
|
|
219
|
+
Type.object({
|
|
218
220
|
typename: 'example.com/type/Organization',
|
|
219
221
|
version: '0.1.0',
|
|
220
222
|
}),
|
|
@@ -224,7 +226,7 @@ describe('effect-to-json', () => {
|
|
|
224
226
|
name: Schema.String,
|
|
225
227
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
226
228
|
}).pipe(
|
|
227
|
-
Type.
|
|
229
|
+
Type.object({
|
|
228
230
|
typename: 'example.com/type/Person',
|
|
229
231
|
version: '0.1.0',
|
|
230
232
|
}),
|
|
@@ -276,7 +278,7 @@ describe('effect-to-json', () => {
|
|
|
276
278
|
const Organization = Schema.Struct({
|
|
277
279
|
field: Schema.String,
|
|
278
280
|
}).pipe(
|
|
279
|
-
Type.
|
|
281
|
+
Type.object({
|
|
280
282
|
typename: 'example.com/type/Organization',
|
|
281
283
|
version: '0.1.0',
|
|
282
284
|
}),
|
|
@@ -286,7 +288,7 @@ describe('effect-to-json', () => {
|
|
|
286
288
|
name: Schema.String,
|
|
287
289
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
288
290
|
}).pipe(
|
|
289
|
-
Type.
|
|
291
|
+
Type.object({
|
|
290
292
|
typename: 'example.com/type/Person',
|
|
291
293
|
version: '0.1.0',
|
|
292
294
|
}),
|
|
@@ -494,7 +496,7 @@ describe('json-to-effect', () => {
|
|
|
494
496
|
const Organization = Schema.Struct({
|
|
495
497
|
field: Schema.String,
|
|
496
498
|
}).pipe(
|
|
497
|
-
Type.
|
|
499
|
+
Type.object({
|
|
498
500
|
typename: 'example.com/type/Organization',
|
|
499
501
|
version: '0.1.0',
|
|
500
502
|
}),
|
|
@@ -515,7 +517,7 @@ describe('json-to-effect', () => {
|
|
|
515
517
|
} as const;
|
|
516
518
|
|
|
517
519
|
const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
|
|
518
|
-
Type.
|
|
520
|
+
Type.object({
|
|
519
521
|
typename: 'example.com/type/Test',
|
|
520
522
|
version: '0.1.0',
|
|
521
523
|
}),
|
|
@@ -23,9 +23,8 @@ import {
|
|
|
23
23
|
TypeIdentifierAnnotationId,
|
|
24
24
|
makeTypeJsonSchemaAnnotation,
|
|
25
25
|
} from '../annotations';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { EntityKind, EntityKindSchema } from '../types';
|
|
26
|
+
import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../ref';
|
|
27
|
+
import { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, EntityKind, EntityKindSchema } from '../types';
|
|
29
28
|
|
|
30
29
|
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
31
30
|
import {
|
|
@@ -81,7 +80,11 @@ export type JsonSchemaOptions = {
|
|
|
81
80
|
*/
|
|
82
81
|
// TODO(burdon): Reconcile with possibly extending @effect/Schema/JSONSchema
|
|
83
82
|
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
84
|
-
|
|
83
|
+
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
84
|
+
export const toJsonSchema = (
|
|
85
|
+
schema: Schema.Schema.All,
|
|
86
|
+
options: JsonSchemaOptions = {},
|
|
87
|
+
): Types.DeepMutable<JsonSchemaType> => {
|
|
85
88
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
86
89
|
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
87
90
|
if (options.strict) {
|
|
@@ -104,11 +107,11 @@ export const toJsonSchema = (schema: Schema.Schema.All, options: JsonSchemaOptio
|
|
|
104
107
|
return jsonSchema;
|
|
105
108
|
};
|
|
106
109
|
|
|
107
|
-
const _toJsonSchemaAST = (ast: SchemaAST.AST): JsonSchemaType => {
|
|
110
|
+
const _toJsonSchemaAST = (ast: SchemaAST.AST): Types.DeepMutable<JsonSchemaType> => {
|
|
108
111
|
const withRefinements = withEchoRefinements(ast, '#');
|
|
109
112
|
const jsonSchema = JSONSchema.fromAST(withRefinements, {
|
|
110
113
|
definitions: {},
|
|
111
|
-
}) as JsonSchemaType
|
|
114
|
+
}) as Types.DeepMutable<JsonSchemaType>;
|
|
112
115
|
|
|
113
116
|
return normalizeJsonSchema(jsonSchema);
|
|
114
117
|
};
|
|
@@ -327,7 +330,7 @@ const objectToEffectSchema = (root: JsonSchemaType, defs: JsonSchemaType['$defs'
|
|
|
327
330
|
}
|
|
328
331
|
|
|
329
332
|
if (immutableIdField) {
|
|
330
|
-
schema = Schema.extend(
|
|
333
|
+
schema = Schema.extend(schema, Schema.Struct({ id: immutableIdField }));
|
|
331
334
|
}
|
|
332
335
|
|
|
333
336
|
const annotations = jsonSchemaFieldsToAnnotations(root);
|
|
@@ -352,7 +355,8 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
352
355
|
// TODO(dmaretskyi): Types.
|
|
353
356
|
const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
354
357
|
if (!('reference' in root)) {
|
|
355
|
-
|
|
358
|
+
// Fallback to generic object ref when no reference info is provided.
|
|
359
|
+
return createEchoReferenceSchema(undefined, ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION);
|
|
356
360
|
}
|
|
357
361
|
|
|
358
362
|
const reference: JsonSchemaReferenceInfo = root.reference;
|
|
@@ -377,7 +381,7 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
377
381
|
const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Record<symbol, any> => {
|
|
378
382
|
const schemaFields: Record<string, any> = {};
|
|
379
383
|
|
|
380
|
-
const echoAnnotations: JsonSchemaEchoAnnotations = {};
|
|
384
|
+
const echoAnnotations: Types.Mutable<JsonSchemaEchoAnnotations> = {};
|
|
381
385
|
for (const [key, annotationId] of Object.entries(EchoAnnotations)) {
|
|
382
386
|
if (annotations[annotationId] != null) {
|
|
383
387
|
echoAnnotations[key as keyof JsonSchemaEchoAnnotations] = annotations[annotationId] as any;
|
|
@@ -495,7 +499,7 @@ const addJsonSchemaFields = (ast: SchemaAST.AST, schema: JsonSchemaType): Schema
|
|
|
495
499
|
* Fixes field order.
|
|
496
500
|
* Sets `$schema` prop.
|
|
497
501
|
*/
|
|
498
|
-
const normalizeJsonSchema = (jsonSchema: JsonSchemaType): JsonSchemaType => {
|
|
502
|
+
const normalizeJsonSchema = (jsonSchema: Types.DeepMutable<JsonSchemaType>): Types.DeepMutable<JsonSchemaType> => {
|
|
499
503
|
if (jsonSchema.properties && 'id' in jsonSchema.properties) {
|
|
500
504
|
jsonSchema.properties = orderKeys(jsonSchema.properties, ['id']); // Put id first.
|
|
501
505
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import { deepMapValues } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import type * as Obj from '../../Obj';
|
|
9
|
+
import { makeObject } from '../proxy';
|
|
10
|
+
import { Ref } from '../ref';
|
|
11
|
+
import { getMeta, getSchema } from '../types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Clones an object or relation.
|
|
15
|
+
* This does not clone referenced objects, only the properties in the object.
|
|
16
|
+
* @returns A new object with the same schema and properties.
|
|
17
|
+
*/
|
|
18
|
+
export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
|
|
19
|
+
const { id, ...data } = obj;
|
|
20
|
+
const schema = getSchema(obj);
|
|
21
|
+
invariant(schema != null, 'Object should have a schema');
|
|
22
|
+
const props: any = deepMapValues(data, (value, recurse) => {
|
|
23
|
+
if (Ref.isRef(value)) {
|
|
24
|
+
if (opts?.deep) {
|
|
25
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
26
|
+
return Ref.make(clone(value.target!, opts));
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return recurse(value);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (opts?.retainId) {
|
|
34
|
+
props.id = id;
|
|
35
|
+
}
|
|
36
|
+
const meta = deepMapValues(getMeta(obj), (value, recurse) => {
|
|
37
|
+
if (Ref.isRef(value)) {
|
|
38
|
+
if (opts?.deep) {
|
|
39
|
+
// TODO(dmaretskyi): Will break on circular references.
|
|
40
|
+
return Ref.make(clone(value.target!, opts));
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return recurse(value);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return makeObject(schema, props, meta);
|
|
48
|
+
};
|
|
@@ -7,7 +7,6 @@ import type * as Schema from 'effect/Schema';
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
import { assertArgument, failedInvariant } from '@dxos/invariant';
|
|
9
9
|
import { ObjectId } from '@dxos/keys';
|
|
10
|
-
import { defineHiddenProperty } from '@dxos/live-object';
|
|
11
10
|
|
|
12
11
|
import { getSchemaDXN, getTypeAnnotation, setTypename } from '../annotations';
|
|
13
12
|
import {
|
|
@@ -18,6 +17,7 @@ import {
|
|
|
18
17
|
assertObjectModel,
|
|
19
18
|
getObjectDXN,
|
|
20
19
|
} from '../entities';
|
|
20
|
+
import { defineHiddenProperty } from '../proxy';
|
|
21
21
|
import { EntityKind, KindId, MetaId, setSchema } from '../types';
|
|
22
22
|
|
|
23
23
|
import { attachedTypedObjectInspector } from './inspect';
|
|
@@ -41,7 +41,7 @@ export type CreateObjectProps<T> = T extends { id: string } ? Omit<T, 'id' | Kin
|
|
|
41
41
|
* const Contact = Schema.Struct({
|
|
42
42
|
* name: Schema.String,
|
|
43
43
|
* email: Schema.String,
|
|
44
|
-
* }).pipe(Type.
|
|
44
|
+
* }).pipe(Type.object({
|
|
45
45
|
* typename: 'example.com/type/Person',
|
|
46
46
|
* version: '0.1.0',
|
|
47
47
|
* }))
|
|
@@ -7,7 +7,7 @@ import type { InspectOptionsStylized, inspect as inspectFn } from 'node:util';
|
|
|
7
7
|
import { type CustomInspectFunction, inspectCustom } from '@dxos/debug';
|
|
8
8
|
|
|
9
9
|
import { getTypeDXN } from '../annotations';
|
|
10
|
-
import { ATTR_META, ATTR_TYPE, type
|
|
10
|
+
import { ATTR_META, ATTR_TYPE, type AnyEntity, MetaId } from '../types';
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* @internal
|
|
@@ -27,8 +27,8 @@ export const attachedTypedObjectInspector = (obj: any) => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// NOTE: KEEP as function.
|
|
30
|
-
const typedObjectInspectFunction: CustomInspectFunction<
|
|
31
|
-
this:
|
|
30
|
+
const typedObjectInspectFunction: CustomInspectFunction<AnyEntity> = function (
|
|
31
|
+
this: AnyEntity,
|
|
32
32
|
depth: number,
|
|
33
33
|
options: InspectOptionsStylized,
|
|
34
34
|
inspect: typeof inspectFn,
|
|
@@ -6,12 +6,14 @@ import { describe, expect, test } from 'vitest';
|
|
|
6
6
|
|
|
7
7
|
import { DXN } from '@dxos/keys';
|
|
8
8
|
|
|
9
|
+
import * as Obj from '../../Obj';
|
|
9
10
|
import { TestSchema } from '../../testing';
|
|
10
11
|
import { getSchemaDXN, getSchemaTypename, getTypeDXN, getTypename } from '../annotations';
|
|
12
|
+
import { getMetaChecked } from '../api';
|
|
11
13
|
import { RelationSourceId, RelationTargetId, getObjectDXN } from '../entities';
|
|
12
14
|
import { makeObject } from '../proxy';
|
|
13
15
|
import { Ref, StaticRefResolver } from '../ref';
|
|
14
|
-
import { ATTR_TYPE, EntityKind, KindId, MetaId, TypeId,
|
|
16
|
+
import { ATTR_TYPE, EntityKind, KindId, MetaId, TypeId, getSchema } from '../types';
|
|
15
17
|
|
|
16
18
|
import { createObject } from './create-object';
|
|
17
19
|
import { objectFromJSON, objectToJSON } from './json-serializer';
|
|
@@ -19,7 +21,9 @@ import { objectFromJSON, objectToJSON } from './json-serializer';
|
|
|
19
21
|
describe('Object JSON serializer', () => {
|
|
20
22
|
test('should serialize and deserialize object', async () => {
|
|
21
23
|
const contact = makeObject(TestSchema.Person, { name: 'Alice' });
|
|
22
|
-
|
|
24
|
+
Obj.change(contact, (c) => {
|
|
25
|
+
getMetaChecked(c).keys.push({ id: '12345', source: 'example.com' });
|
|
26
|
+
});
|
|
23
27
|
|
|
24
28
|
const task = createObject(TestSchema.Task, {
|
|
25
29
|
title: 'Fix the tests',
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import { type EncodedReference,
|
|
8
|
+
import { type EncodedReference, ObjectStructure, isEncodedReference } from '@dxos/echo-protocol';
|
|
9
9
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
10
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
11
|
-
import { defineHiddenProperty } from '@dxos/live-object';
|
|
12
11
|
import { assumeType, deepMapValues, visitValues } from '@dxos/util';
|
|
13
12
|
|
|
13
|
+
import type * as Obj from '../../Obj';
|
|
14
14
|
import { getTypeDXN, setTypename } from '../annotations';
|
|
15
15
|
import {
|
|
16
16
|
ATTR_DELETED,
|
|
@@ -25,19 +25,22 @@ import {
|
|
|
25
25
|
SelfDXNId,
|
|
26
26
|
assertObjectModel,
|
|
27
27
|
} from '../entities';
|
|
28
|
+
import { attachTypedJsonSerializer, defineHiddenProperty, typedJsonSerializer } from '../proxy';
|
|
28
29
|
import { Ref, type RefResolver, refFromEncodedReference, setRefResolver } from '../ref';
|
|
29
30
|
import {
|
|
30
31
|
ATTR_META,
|
|
31
32
|
ATTR_TYPE,
|
|
32
|
-
type
|
|
33
|
+
type AnyEntity,
|
|
33
34
|
EntityKind,
|
|
34
35
|
KindId,
|
|
35
36
|
MetaId,
|
|
36
37
|
ObjectMetaSchema,
|
|
37
|
-
TypeId,
|
|
38
38
|
setSchema,
|
|
39
39
|
} from '../types';
|
|
40
40
|
|
|
41
|
+
// Re-export for backward compatibility.
|
|
42
|
+
export { attachTypedJsonSerializer };
|
|
43
|
+
|
|
41
44
|
type DeepReplaceRef<T> =
|
|
42
45
|
T extends Ref<any>
|
|
43
46
|
? EncodedReference
|
|
@@ -54,7 +57,7 @@ type SerializedObject<T extends { id: string }> = {
|
|
|
54
57
|
/**
|
|
55
58
|
* Converts object to it's JSON representation.
|
|
56
59
|
*/
|
|
57
|
-
export const objectToJSON = <T extends
|
|
60
|
+
export const objectToJSON = <T extends AnyEntity>(obj: T): SerializedObject<T> => {
|
|
58
61
|
const typename = getTypeDXN(obj)?.toString();
|
|
59
62
|
invariant(typename && typeof typename === 'string');
|
|
60
63
|
return typedJsonSerializer.call(obj);
|
|
@@ -69,7 +72,7 @@ export const objectToJSON = <T extends AnyEchoObject>(obj: T): SerializedObject<
|
|
|
69
72
|
export const objectFromJSON = async (
|
|
70
73
|
jsonData: unknown,
|
|
71
74
|
{ refResolver, dxn }: { refResolver?: RefResolver; dxn?: DXN } = {},
|
|
72
|
-
): Promise<
|
|
75
|
+
): Promise<AnyEntity> => {
|
|
73
76
|
assumeType<ObjectJSON>(jsonData);
|
|
74
77
|
assertArgument(typeof jsonData === 'object' && jsonData !== null, 'jsonData', 'expect object');
|
|
75
78
|
assertArgument(typeof jsonData[ATTR_TYPE] === 'string', 'jsonData[ATTR_TYPE]', 'expected object to have a type');
|
|
@@ -101,8 +104,8 @@ export const objectFromJSON = async (
|
|
|
101
104
|
const sourceDxn: DXN = DXN.parse(jsonData[ATTR_RELATION_SOURCE] ?? raise(new TypeError('Missing relation source')));
|
|
102
105
|
const targetDxn: DXN = DXN.parse(jsonData[ATTR_RELATION_TARGET] ?? raise(new TypeError('Missing relation target')));
|
|
103
106
|
|
|
104
|
-
const source = (await refResolver?.resolve(sourceDxn)) as
|
|
105
|
-
const target = (await refResolver?.resolve(targetDxn)) as
|
|
107
|
+
const source = (await refResolver?.resolve(sourceDxn)) as AnyEntity | undefined;
|
|
108
|
+
const target = (await refResolver?.resolve(targetDxn)) as AnyEntity | undefined;
|
|
106
109
|
|
|
107
110
|
defineHiddenProperty(obj, KindId, EntityKind.Relation);
|
|
108
111
|
defineHiddenProperty(obj, RelationSourceDXNId, sourceDxn);
|
|
@@ -117,6 +120,10 @@ export const objectFromJSON = async (
|
|
|
117
120
|
const meta = await ObjectMetaSchema.pipe(Schema.decodeUnknownPromise)(jsonData[ATTR_META]);
|
|
118
121
|
invariant(Array.isArray(meta.keys));
|
|
119
122
|
defineHiddenProperty(obj, MetaId, meta);
|
|
123
|
+
} else {
|
|
124
|
+
defineHiddenProperty(obj, MetaId, {
|
|
125
|
+
keys: [],
|
|
126
|
+
});
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
if (dxn) {
|
|
@@ -153,7 +160,7 @@ const decodeGeneric = (jsonData: unknown, options: { refResolver?: RefResolver }
|
|
|
153
160
|
});
|
|
154
161
|
};
|
|
155
162
|
|
|
156
|
-
export const setRefResolverOnData = (obj:
|
|
163
|
+
export const setRefResolverOnData = (obj: AnyEntity, refResolver: RefResolver) => {
|
|
157
164
|
const visitor = (value: unknown) => {
|
|
158
165
|
if (Ref.isRef(value)) {
|
|
159
166
|
setRefResolver(value, refResolver);
|
|
@@ -165,66 +172,17 @@ export const setRefResolverOnData = (obj: AnyEchoObject, refResolver: RefResolve
|
|
|
165
172
|
visitor(obj);
|
|
166
173
|
};
|
|
167
174
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// NOTE: KEEP as function.
|
|
184
|
-
const typedJsonSerializer = function (this: any) {
|
|
185
|
-
const { id, ...rest } = this;
|
|
186
|
-
const result: any = {
|
|
187
|
-
id,
|
|
175
|
+
/**
|
|
176
|
+
* Convert ObjectStructure to JSON data for indexing.
|
|
177
|
+
* Different from {@link objectToJSON} as it takes the internal {@link ObjectStructure} representation directly
|
|
178
|
+
*/
|
|
179
|
+
export const objectStructureToJson = (objectId: string, structure: ObjectStructure): Obj.JSON => {
|
|
180
|
+
return {
|
|
181
|
+
...structure.data,
|
|
182
|
+
id: objectId,
|
|
183
|
+
[ATTR_TYPE]: (ObjectStructure.getTypeReference(structure)?.['/'] ?? '') as DXN.String,
|
|
184
|
+
[ATTR_DELETED]: ObjectStructure.isDeleted(structure),
|
|
185
|
+
[ATTR_RELATION_SOURCE]: ObjectStructure.getRelationSource(structure)?.['/'] as DXN.String | undefined,
|
|
186
|
+
[ATTR_RELATION_TARGET]: ObjectStructure.getRelationTarget(structure)?.['/'] as DXN.String | undefined,
|
|
188
187
|
};
|
|
189
|
-
|
|
190
|
-
if (this[TypeId]) {
|
|
191
|
-
result[ATTR_TYPE] = this[TypeId].toString();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (this[MetaId]) {
|
|
195
|
-
result[ATTR_META] = serializeMeta(this[MetaId]);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (this[SelfDXNId]) {
|
|
199
|
-
result[ATTR_SELF_DXN] = this[SelfDXNId].toString();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (this[RelationSourceDXNId]) {
|
|
203
|
-
const sourceDXN = this[RelationSourceDXNId];
|
|
204
|
-
invariant(sourceDXN instanceof DXN);
|
|
205
|
-
result[ATTR_RELATION_SOURCE] = sourceDXN.toString();
|
|
206
|
-
}
|
|
207
|
-
if (this[RelationTargetDXNId]) {
|
|
208
|
-
const targetDXN = this[RelationTargetDXNId];
|
|
209
|
-
invariant(targetDXN instanceof DXN);
|
|
210
|
-
result[ATTR_RELATION_TARGET] = targetDXN.toString();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
Object.assign(result, serializeData(rest));
|
|
214
|
-
return result;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const serializeData = (data: unknown) => {
|
|
218
|
-
return deepMapValues(data, (value, recurse) => {
|
|
219
|
-
if (Ref.isRef(value)) {
|
|
220
|
-
// TODO(dmaretskyi): Should this be configurable?
|
|
221
|
-
return value.noInline().encode();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return recurse(value);
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const serializeMeta = (meta: ObjectMeta) => {
|
|
229
|
-
return deepMapValues(meta, (value, recurse) => recurse(value));
|
|
230
188
|
};
|
|
@@ -27,9 +27,7 @@ describe('schema-validator', () => {
|
|
|
27
27
|
const TestSchema: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
28
28
|
name: Schema.String.annotations({ [annotationId]: annotationValue }),
|
|
29
29
|
parent: Schema.optional(Schema.suspend(() => TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
30
|
-
friends: Schema.suspend(() =>
|
|
31
|
-
Schema.mutable(Schema.Array(TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
32
|
-
),
|
|
30
|
+
friends: Schema.suspend(() => Schema.Array(TestSchema.annotations({ [annotationId]: annotationValue }))),
|
|
33
31
|
});
|
|
34
32
|
expect(SchemaValidator.hasTypeAnnotation(TestSchema, 'name', annotationId)).to.be.true;
|
|
35
33
|
expect(SchemaValidator.hasTypeAnnotation(TestSchema, 'parent', annotationId)).to.be.true;
|
|
@@ -41,7 +39,7 @@ describe('schema-validator', () => {
|
|
|
41
39
|
const Person: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
42
40
|
name: Schema.String,
|
|
43
41
|
parent: Schema.optional(Schema.suspend(() => Person)),
|
|
44
|
-
friends: Schema.suspend(() => Schema.
|
|
42
|
+
friends: Schema.suspend(() => Schema.Array(Person)),
|
|
45
43
|
});
|
|
46
44
|
expect(SchemaValidator.hasTypeAnnotation(Person, 'name', annotationId)).to.be.false;
|
|
47
45
|
expect(SchemaValidator.hasTypeAnnotation(Person, 'parent', annotationId)).to.be.false;
|
|
@@ -87,9 +85,7 @@ describe('schema-validator', () => {
|
|
|
87
85
|
const annotationValue = 'bar';
|
|
88
86
|
const Person: Schema.Schema.AnyNoContext = Schema.Struct({
|
|
89
87
|
parent: Schema.optional(Schema.suspend(() => Person.annotations({ [annotationId]: annotationValue }))),
|
|
90
|
-
friends: Schema.suspend(() =>
|
|
91
|
-
Schema.mutable(Schema.Array(Person.annotations({ [annotationId]: annotationValue }))),
|
|
92
|
-
),
|
|
88
|
+
friends: Schema.suspend(() => Schema.Array(Person.annotations({ [annotationId]: annotationValue }))),
|
|
93
89
|
});
|
|
94
90
|
expect(SchemaValidator.getPropertySchema(Person, ['parent']).ast.annotations[annotationId]).to.eq(
|
|
95
91
|
annotationValue,
|