@dxos/echo 0.8.4-main.548089c → 0.8.4-main.59c2e9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/lib/browser/Annotation.mjs +33 -0
- package/dist/lib/browser/Database.mjs +18 -0
- package/dist/lib/browser/Entity.mjs +52 -0
- package/dist/lib/browser/Entity.mjs.map +7 -0
- package/dist/lib/browser/Err.mjs +11 -0
- package/dist/lib/browser/Err.mjs.map +7 -0
- package/dist/lib/browser/Filter.mjs +62 -0
- package/dist/lib/browser/Filter.mjs.map +7 -0
- package/dist/lib/browser/Format.mjs +67 -0
- package/dist/lib/browser/Format.mjs.map +7 -0
- package/dist/lib/browser/JsonSchema.mjs +20 -0
- package/dist/lib/browser/JsonSchema.mjs.map +7 -0
- package/dist/lib/browser/Key.mjs +13 -0
- package/dist/lib/browser/Key.mjs.map +7 -0
- package/dist/lib/browser/Obj.mjs +91 -0
- package/dist/lib/browser/Obj.mjs.map +7 -0
- package/dist/lib/browser/Order.mjs +13 -0
- package/dist/lib/browser/Order.mjs.map +7 -0
- package/dist/lib/browser/Query.mjs +27 -0
- package/dist/lib/browser/Query.mjs.map +7 -0
- package/dist/lib/browser/QueryResult.mjs +3 -0
- package/dist/lib/browser/QueryResult.mjs.map +7 -0
- package/dist/lib/browser/Ref.mjs +23 -0
- package/dist/lib/browser/Ref.mjs.map +7 -0
- package/dist/lib/browser/Relation.mjs +85 -0
- package/dist/lib/browser/Relation.mjs.map +7 -0
- package/dist/lib/browser/SchemaRegistry.mjs +3 -0
- package/dist/lib/browser/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/browser/Tag.mjs +26 -0
- package/dist/lib/browser/Tag.mjs.map +7 -0
- package/dist/lib/browser/Type.mjs +48 -0
- package/dist/lib/browser/Type.mjs.map +7 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs +24 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs.map +7 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs +250 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs.map +7 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs +158 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs.map +7 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs +133 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-BJPE6CIC.mjs +3847 -0
- package/dist/lib/browser/chunk-BJPE6CIC.mjs.map +7 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-CJ5YELTO.mjs +39 -0
- package/dist/lib/browser/chunk-CJ5YELTO.mjs.map +7 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs +40 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs.map +7 -0
- package/dist/lib/browser/chunk-FRDT7RA4.mjs +403 -0
- package/dist/lib/browser/chunk-FRDT7RA4.mjs.map +7 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs +22 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs.map +7 -0
- package/dist/lib/browser/chunk-IXVWLTG7.mjs +9 -0
- package/dist/lib/browser/chunk-IXVWLTG7.mjs.map +7 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs +43 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-KQQGVHFN.mjs +143 -0
- package/dist/lib/browser/chunk-KQQGVHFN.mjs.map +7 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs +15 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-NOPVNWPT.mjs +204 -0
- package/dist/lib/browser/chunk-NOPVNWPT.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs +74 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs.map +7 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs +283 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs +57 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs.map +7 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs +98 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs.map +7 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs +41 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs +69 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs +288 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs +9 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +68 -18
- package/dist/lib/browser/internal/index.mjs +245 -124
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +298 -198
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/Annotation.mjs +33 -0
- package/dist/lib/node-esm/Annotation.mjs.map +7 -0
- package/dist/lib/node-esm/Database.mjs +18 -0
- package/dist/lib/node-esm/Database.mjs.map +7 -0
- package/dist/lib/node-esm/Entity.mjs +52 -0
- package/dist/lib/node-esm/Entity.mjs.map +7 -0
- package/dist/lib/node-esm/Err.mjs +11 -0
- package/dist/lib/node-esm/Err.mjs.map +7 -0
- package/dist/lib/node-esm/Filter.mjs +62 -0
- package/dist/lib/node-esm/Filter.mjs.map +7 -0
- package/dist/lib/node-esm/Format.mjs +67 -0
- package/dist/lib/node-esm/Format.mjs.map +7 -0
- package/dist/lib/node-esm/JsonSchema.mjs +20 -0
- package/dist/lib/node-esm/JsonSchema.mjs.map +7 -0
- package/dist/lib/node-esm/Key.mjs +13 -0
- package/dist/lib/node-esm/Key.mjs.map +7 -0
- package/dist/lib/node-esm/Obj.mjs +91 -0
- package/dist/lib/node-esm/Obj.mjs.map +7 -0
- package/dist/lib/node-esm/Order.mjs +13 -0
- package/dist/lib/node-esm/Order.mjs.map +7 -0
- package/dist/lib/node-esm/Query.mjs +27 -0
- package/dist/lib/node-esm/Query.mjs.map +7 -0
- package/dist/lib/node-esm/QueryResult.mjs +3 -0
- package/dist/lib/node-esm/QueryResult.mjs.map +7 -0
- package/dist/lib/node-esm/Ref.mjs +23 -0
- package/dist/lib/node-esm/Ref.mjs.map +7 -0
- package/dist/lib/node-esm/Relation.mjs +85 -0
- package/dist/lib/node-esm/Relation.mjs.map +7 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs +3 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/node-esm/Tag.mjs +26 -0
- package/dist/lib/node-esm/Tag.mjs.map +7 -0
- package/dist/lib/node-esm/Type.mjs +48 -0
- package/dist/lib/node-esm/Type.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs +250 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs +158 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +22 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs +98 -0
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs +57 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs +133 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs +204 -0
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs +43 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs +3847 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs +9 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +15 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs +40 -0
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs +143 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs +41 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs +288 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs +9 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs +403 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs +69 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs +74 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs +283 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs +39 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs +24 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +68 -18
- package/dist/lib/node-esm/internal/index.mjs +245 -124
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +298 -198
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +194 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +142 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/{errors.d.ts → Err.d.ts} +19 -19
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +9 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +300 -99
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +115 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +13 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +242 -22
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +7 -7
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +225 -72
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +14 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +170 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +27 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/api/annotations.d.ts +23 -0
- package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/api/entity.d.ts +13 -0
- package/dist/types/src/internal/api/entity.d.ts.map +1 -0
- package/dist/types/src/internal/api/index.d.ts +15 -0
- package/dist/types/src/internal/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/api/meta.d.ts +42 -0
- package/dist/types/src/internal/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/api/sorting.d.ts +24 -0
- package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/api/version.d.ts +42 -0
- package/dist/types/src/internal/api/version.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +20 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +77 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +18 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +62 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +4 -2
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +5 -3
- package/dist/types/src/internal/formats/select.d.ts.map +1 -1
- package/dist/types/src/internal/formats/string.d.ts +4 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +13 -9
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +7 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +2 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/clone.d.ts +8 -0
- package/dist/types/src/internal/object/clone.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +9 -10
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +2 -2
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/object/ids.d.ts.map +1 -1
- package/dist/types/src/internal/object/index.d.ts +6 -11
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +14 -9
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +1 -14
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/set-value.d.ts +7 -0
- package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/snapshot.d.ts +6 -0
- package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +8 -14
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +15 -12
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref-array.d.ts +4 -4
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +27 -16
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +24 -12
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +1 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +26 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +37 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +5 -2
- package/dist/types/src/internal/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/{object → types}/meta.d.ts +12 -11
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +303 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +160 -45
- package/src/Annotation.ts +18 -0
- package/src/Database.ts +336 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +217 -0
- package/src/{errors.ts → Err.ts} +2 -2
- package/src/Filter.ts +376 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +74 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.test.ts +386 -0
- package/src/Obj.ts +447 -292
- package/src/Order.ts +44 -0
- package/src/Query.test.ts +465 -0
- package/src/Query.ts +296 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +26 -9
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +411 -60
- package/src/SchemaRegistry.ts +105 -0
- package/src/Tag.ts +3 -2
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +361 -114
- package/src/index.ts +15 -6
- package/src/internal/README.md +100 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +18 -20
- package/src/internal/annotations/annotations.ts +460 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +72 -0
- package/src/internal/api/annotations.ts +60 -0
- package/src/internal/api/entity.ts +29 -0
- package/src/internal/api/index.ts +19 -0
- package/src/internal/api/meta.ts +88 -0
- package/src/internal/api/sorting.ts +53 -0
- package/src/internal/api/version.ts +96 -0
- package/src/internal/entities/entity.ts +126 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +134 -0
- package/src/internal/entities/object.ts +60 -0
- package/src/internal/entities/relation.ts +173 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +1 -1
- package/src/internal/formats/date.ts +5 -5
- package/src/internal/formats/format.test.ts +5 -5
- package/src/internal/formats/format.ts +8 -6
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +4 -4
- package/src/internal/formats/select.ts +5 -3
- package/src/internal/formats/string.ts +14 -9
- package/src/internal/formats/types.ts +53 -42
- package/src/internal/index.ts +30 -13
- package/src/internal/{json → json-schema}/annotations.ts +1 -1
- package/src/internal/json-schema/index.ts +2 -0
- package/src/internal/json-schema/json-schema-type.ts +5 -4
- package/src/internal/{json → json-schema}/json-schema.test.ts +67 -55
- package/src/internal/{json → json-schema}/json-schema.ts +17 -8
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/common.ts +3 -4
- package/src/internal/object/{create.test.ts → create-object.test.ts} +30 -32
- package/src/internal/object/{create.ts → create-object.ts} +35 -36
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +6 -11
- package/src/internal/object/inspect.ts +5 -7
- package/src/internal/object/json-serializer.test.ts +35 -37
- package/src/internal/object/json-serializer.ts +65 -102
- package/src/internal/object/schema-validator.ts +2 -237
- package/src/internal/object/set-value.test.ts +281 -0
- package/src/internal/object/set-value.ts +165 -0
- package/src/internal/object/snapshot.ts +70 -0
- package/src/internal/object/typed-object.test.ts +11 -11
- package/src/internal/object/typed-object.ts +8 -66
- package/src/internal/proxy/change-context.ts +138 -0
- package/src/internal/proxy/change.test.ts +519 -0
- package/src/internal/proxy/define-hidden-property.ts +14 -0
- package/src/internal/proxy/errors.ts +42 -0
- package/src/internal/proxy/event-batch.ts +44 -0
- package/src/internal/proxy/handler.test.ts +51 -91
- package/src/internal/proxy/index.ts +17 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +96 -0
- package/src/internal/proxy/ownership.ts +253 -0
- package/src/internal/proxy/proxy-types.ts +23 -0
- package/src/internal/proxy/proxy-utils.ts +150 -0
- package/src/internal/proxy/reactive-array.ts +71 -0
- package/src/internal/proxy/reactive.ts +69 -0
- package/src/internal/proxy/schema-validator.ts +244 -0
- package/src/internal/proxy/schema.test.ts +27 -18
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +264 -48
- package/src/internal/proxy/typed-handler.ts +275 -61
- package/src/internal/proxy/typed-object.test.ts +42 -26
- package/src/internal/ref/ref-array.ts +4 -4
- package/src/internal/ref/ref.test.ts +8 -7
- package/src/internal/ref/ref.ts +81 -54
- package/src/internal/{projection → schema}/compose.test.ts +8 -9
- package/src/internal/{projection → schema}/compose.ts +1 -1
- package/src/internal/schema/echo-schema.ts +73 -33
- package/src/internal/schema/index.ts +1 -4
- package/src/internal/schema/manipulation.ts +1 -1
- package/src/internal/schema/persistent-schema.ts +27 -0
- package/src/internal/types/base.ts +43 -0
- package/src/internal/types/entity.ts +54 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/{object → types}/meta.ts +22 -17
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +238 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-3FCPYTWA.mjs +0 -585
- package/dist/lib/browser/chunk-3FCPYTWA.mjs.map +0 -7
- package/dist/lib/browser/chunk-5BNXQE6S.mjs +0 -3727
- package/dist/lib/browser/chunk-5BNXQE6S.mjs.map +0 -7
- package/dist/lib/browser/chunk-U43CXUCL.mjs +0 -410
- package/dist/lib/browser/chunk-U43CXUCL.mjs.map +0 -7
- package/dist/lib/browser/query/index.mjs +0 -13
- package/dist/lib/node-esm/chunk-3FGSPSYN.mjs +0 -3727
- package/dist/lib/node-esm/chunk-3FGSPSYN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C7LTTWRL.mjs +0 -585
- package/dist/lib/node-esm/chunk-C7LTTWRL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OHJ5WBB6.mjs +0 -410
- package/dist/lib/node-esm/chunk-OHJ5WBB6.mjs.map +0 -7
- package/dist/lib/node-esm/query/index.mjs +0 -13
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -131
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -381
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -228
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -226
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/index.ts +0 -6
- package/src/internal/testing/types.ts +0 -144
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -108
- /package/dist/lib/browser/{query/index.mjs.map → Annotation.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → browser/Database.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
|
@@ -7,24 +7,35 @@ import { type InspectOptionsStylized } from 'node:util';
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
9
|
|
|
10
|
+
import { Event } from '@dxos/async';
|
|
10
11
|
import { inspectCustom } from '@dxos/debug';
|
|
11
|
-
import { type GenericSignal, compositeRuntime } from '@dxos/echo-signals/runtime';
|
|
12
12
|
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import {
|
|
14
|
-
ReactiveArray,
|
|
15
|
-
type ReactiveHandler,
|
|
16
|
-
createProxy,
|
|
17
|
-
defineHiddenProperty,
|
|
18
|
-
isValidProxyTarget,
|
|
19
|
-
objectData,
|
|
20
|
-
symbolIsProxy,
|
|
21
|
-
} from '@dxos/live-object';
|
|
22
13
|
|
|
23
|
-
import { getSchemaDXN } from '../
|
|
24
|
-
import {
|
|
14
|
+
import { getSchemaDXN } from '../annotations';
|
|
15
|
+
import { ObjectDeletedId } from '../entities';
|
|
16
|
+
import { SchemaId, TypeId } from '../types';
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
import { executeChange, isInChangeContext, queueNotification } from './change-context';
|
|
19
|
+
import { defineHiddenProperty } from './define-hidden-property';
|
|
20
|
+
import { createPropertyDeleteError } from './errors';
|
|
21
|
+
import { batchEvents } from './event-batch';
|
|
22
|
+
import {
|
|
23
|
+
getEchoRoot,
|
|
24
|
+
getOwner,
|
|
25
|
+
getRawTarget,
|
|
26
|
+
hasForeignOwner,
|
|
27
|
+
notifyOwnerChain,
|
|
28
|
+
setOwnerRecursive,
|
|
29
|
+
wouldCreateCycle,
|
|
30
|
+
} from './ownership';
|
|
31
|
+
import { type ReactiveHandler, objectData } from './proxy-types';
|
|
32
|
+
import { createProxy, isProxy, isValidProxyTarget, symbolIsProxy } from './proxy-utils';
|
|
33
|
+
import { ReactiveArray } from './reactive-array';
|
|
34
|
+
import { SchemaValidator } from './schema-validator';
|
|
35
|
+
import { ChangeId, EventId } from './symbols';
|
|
36
|
+
|
|
37
|
+
// Re-export for external consumers.
|
|
38
|
+
export { getEchoRoot, setMetaOwner } from './ownership';
|
|
28
39
|
|
|
29
40
|
type ProxyTarget = {
|
|
30
41
|
/**
|
|
@@ -38,24 +49,97 @@ type ProxyTarget = {
|
|
|
38
49
|
[SchemaId]: Schema.Schema.AnyNoContext;
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
|
-
* For
|
|
42
|
-
*/
|
|
43
|
-
// TODO(dmaretskyi): Turn into a map of signals per-field.
|
|
44
|
-
[symbolSignal]: GenericSignal;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* For modifying the structure of the object.
|
|
52
|
+
* For modifications.
|
|
48
53
|
*/
|
|
49
|
-
[
|
|
54
|
+
[EventId]: Event<void>;
|
|
50
55
|
} & ({ [key: keyof any]: any } | any[]);
|
|
51
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Deep copy a value, handling arrays and nested objects.
|
|
59
|
+
* Preserves ReactiveArray type and hidden properties (SchemaId, TypeId).
|
|
60
|
+
* Does not copy class instances or functions (except ReactiveArray).
|
|
61
|
+
*
|
|
62
|
+
* Note: Cannot use structuredClone because we need to:
|
|
63
|
+
* - Unwrap proxies
|
|
64
|
+
* - Preserve ReactiveArray instances
|
|
65
|
+
* - Copy Symbol-keyed hidden properties (SchemaId, TypeId)
|
|
66
|
+
* - Convert plain arrays to ReactiveArray
|
|
67
|
+
*
|
|
68
|
+
* Performance: O(n) where n is the total number of nested objects/arrays.
|
|
69
|
+
* For large structures, consider using Refs for frequently reassigned subtrees.
|
|
70
|
+
*/
|
|
71
|
+
const deepCopy = <T>(value: T, visited = new Map<object, object>()): T => {
|
|
72
|
+
if (value == null || typeof value !== 'object') {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Handle proxies - get the underlying target.
|
|
77
|
+
const actualValue = getRawTarget(value);
|
|
78
|
+
|
|
79
|
+
// Check for circular references in the copy.
|
|
80
|
+
if (visited.has(actualValue)) {
|
|
81
|
+
return visited.get(actualValue) as T;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Handle ReactiveArray specially to preserve reactivity.
|
|
85
|
+
if (actualValue instanceof ReactiveArray) {
|
|
86
|
+
const copy = new ReactiveArray<any>();
|
|
87
|
+
visited.set(actualValue, copy);
|
|
88
|
+
for (const item of actualValue) {
|
|
89
|
+
copy.push(deepCopy(item, visited));
|
|
90
|
+
}
|
|
91
|
+
// Copy hidden properties.
|
|
92
|
+
copyHiddenProperties(actualValue, copy);
|
|
93
|
+
return copy as T;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Don't copy other class instances (objects with non-Object prototype).
|
|
97
|
+
const proto = Object.getPrototypeOf(actualValue);
|
|
98
|
+
if (proto !== Object.prototype && proto !== Array.prototype && proto !== null) {
|
|
99
|
+
return value; // Return as-is, don't copy class instances.
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (Array.isArray(actualValue)) {
|
|
103
|
+
// Plain arrays become ReactiveArrays.
|
|
104
|
+
const copy = new ReactiveArray<any>();
|
|
105
|
+
visited.set(actualValue, copy);
|
|
106
|
+
for (const item of actualValue) {
|
|
107
|
+
copy.push(deepCopy(item, visited));
|
|
108
|
+
}
|
|
109
|
+
return copy as T;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const copy: Record<string, any> = {};
|
|
113
|
+
visited.set(actualValue, copy);
|
|
114
|
+
for (const key of Object.keys(actualValue)) {
|
|
115
|
+
copy[key] = deepCopy((actualValue as any)[key], visited);
|
|
116
|
+
}
|
|
117
|
+
// Copy hidden properties (SchemaId, TypeId).
|
|
118
|
+
copyHiddenProperties(actualValue, copy);
|
|
119
|
+
return copy as T;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Copy hidden properties (SchemaId, TypeId) from source to target.
|
|
124
|
+
*/
|
|
125
|
+
const copyHiddenProperties = (source: any, target: any): void => {
|
|
126
|
+
if (SchemaId in source) {
|
|
127
|
+
defineHiddenProperty(target, SchemaId, source[SchemaId]);
|
|
128
|
+
}
|
|
129
|
+
if (TypeId in source) {
|
|
130
|
+
defineHiddenProperty(target, TypeId, source[TypeId]);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
52
134
|
/**
|
|
53
135
|
* Typed in-memory reactive store (with Schema).
|
|
136
|
+
* Reactivity is based on Event subscriptions, not signals.
|
|
54
137
|
*/
|
|
55
138
|
export class TypedReactiveHandler implements ReactiveHandler<ProxyTarget> {
|
|
56
139
|
public static readonly instance: ReactiveHandler<any> = new TypedReactiveHandler();
|
|
57
140
|
|
|
58
141
|
readonly _proxyMap = new WeakMap<object, any>();
|
|
142
|
+
private _inSet = false;
|
|
59
143
|
|
|
60
144
|
private constructor() {}
|
|
61
145
|
|
|
@@ -63,21 +147,44 @@ export class TypedReactiveHandler implements ReactiveHandler<ProxyTarget> {
|
|
|
63
147
|
invariant(typeof target === 'object' && target !== null);
|
|
64
148
|
invariant(SchemaId in target, 'Schema is not defined for the target');
|
|
65
149
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
150
|
+
// Only set EventId on root objects (those without an owner).
|
|
151
|
+
// Nested objects share their root's EventId for centralized reactivity.
|
|
152
|
+
const hasOwner = !!getOwner(target);
|
|
153
|
+
if (!(EventId in target) && !hasOwner) {
|
|
154
|
+
defineHiddenProperty(target, EventId, new Event());
|
|
69
155
|
}
|
|
70
156
|
|
|
71
|
-
defineHiddenProperty(target,
|
|
157
|
+
defineHiddenProperty(target, ObjectDeletedId, false);
|
|
72
158
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
159
|
+
// Mark root objects as having a change handler.
|
|
160
|
+
// The actual handler is returned dynamically in get() to have access to the proxy.
|
|
161
|
+
if (!hasOwner && !(ChangeId in target)) {
|
|
162
|
+
defineHiddenProperty(target, ChangeId, true);
|
|
163
|
+
}
|
|
79
164
|
|
|
80
|
-
|
|
165
|
+
// Only set owners if this is a root object (no existing owner).
|
|
166
|
+
// Nested objects already have owners set by their root's initialization.
|
|
167
|
+
// If we re-set owners here for nested objects, we'd incorrectly point
|
|
168
|
+
// array elements to the array instead of the true root ECHO object.
|
|
169
|
+
if (!hasOwner) {
|
|
170
|
+
// Set owner on all nested objects to this root ECHO object.
|
|
171
|
+
// All nested records point directly to this root for centralized reactivity.
|
|
172
|
+
for (const key in target) {
|
|
173
|
+
if ((target as any)[symbolIsProxy]) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
let value = (target as any)[key];
|
|
177
|
+
if (isValidProxyTarget(value) || isProxy(value)) {
|
|
178
|
+
// Deep copy values that have foreign owners (owned by a different object,
|
|
179
|
+
// or are root ECHO objects whose nested structures would be owned by them).
|
|
180
|
+
// This recursively checks all nested objects.
|
|
181
|
+
if (hasForeignOwner(value, target)) {
|
|
182
|
+
value = deepCopy(value);
|
|
183
|
+
(target as any)[key] = value;
|
|
184
|
+
}
|
|
185
|
+
setOwnerRecursive(value, target);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
81
188
|
}
|
|
82
189
|
|
|
83
190
|
// Maybe have been set by `create`.
|
|
@@ -90,23 +197,26 @@ export class TypedReactiveHandler implements ReactiveHandler<ProxyTarget> {
|
|
|
90
197
|
|
|
91
198
|
get(target: ProxyTarget, prop: string | symbol, receiver: any): any {
|
|
92
199
|
switch (prop) {
|
|
200
|
+
// TODO(burdon): Remove?
|
|
93
201
|
case objectData: {
|
|
94
|
-
target[symbolSignal].notifyRead();
|
|
95
202
|
return toJSON(target);
|
|
96
203
|
}
|
|
204
|
+
case ChangeId: {
|
|
205
|
+
// Return change handler only for root objects that have been marked with ChangeId.
|
|
206
|
+
if ((target as any)[ChangeId] !== true) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
// Return a function that allows mutations within a controlled context.
|
|
210
|
+
// Uses target as both the context key and event target for non-database objects.
|
|
211
|
+
return (callback: (obj: any) => void) => executeChange(target, target, receiver, callback);
|
|
212
|
+
}
|
|
97
213
|
}
|
|
98
214
|
|
|
99
|
-
// Handle getter properties.
|
|
215
|
+
// Handle getter properties.
|
|
100
216
|
if (Object.getOwnPropertyDescriptor(target, prop)?.get) {
|
|
101
|
-
target[symbolPropertySignal].notifyRead();
|
|
102
|
-
|
|
103
|
-
// TODO(dmaretskyi): Turn getters into computed fields.
|
|
104
217
|
return Reflect.get(target, prop, receiver);
|
|
105
218
|
}
|
|
106
219
|
|
|
107
|
-
target[symbolSignal].notifyRead();
|
|
108
|
-
target[symbolPropertySignal].notifyRead();
|
|
109
|
-
|
|
110
220
|
const value = Reflect.get(target, prop, receiver);
|
|
111
221
|
if (isValidProxyTarget(value)) {
|
|
112
222
|
return createProxy(value, this);
|
|
@@ -116,43 +226,145 @@ export class TypedReactiveHandler implements ReactiveHandler<ProxyTarget> {
|
|
|
116
226
|
}
|
|
117
227
|
|
|
118
228
|
set(target: ProxyTarget, prop: string | symbol, value: any, receiver: any): boolean {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
229
|
+
const echoRoot = getEchoRoot(target);
|
|
230
|
+
|
|
231
|
+
// Check readonly enforcement - mutations only allowed within Obj.change().
|
|
232
|
+
// Skip check if the object is still being initialized (no ChangeId handler yet).
|
|
233
|
+
// Also skip for non-initialized root objects (those without EventId).
|
|
234
|
+
// Skip for symbol properties (internal infrastructure, not user data).
|
|
235
|
+
const isInitialized = ChangeId in echoRoot || EventId in echoRoot;
|
|
236
|
+
const isSymbolProp = typeof prop === 'symbol';
|
|
237
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`Cannot modify object property "${String(prop)}" outside of Obj.change(). ` +
|
|
240
|
+
'Use Obj.change(obj, (mutableObj) => { mutableObj.property = value; }) instead.',
|
|
241
|
+
);
|
|
122
242
|
}
|
|
123
243
|
|
|
124
244
|
let result: boolean = false;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
245
|
+
this._inSet = true;
|
|
246
|
+
try {
|
|
247
|
+
batchEvents(() => {
|
|
248
|
+
const { echoRoot: _, preparedValue } = this._prepareValueForAssignment(target, prop, value);
|
|
249
|
+
result = Reflect.set(target, prop, preparedValue, receiver);
|
|
250
|
+
// Queue notification instead of emitting immediately (batched).
|
|
251
|
+
if (isInitialized) {
|
|
252
|
+
queueNotification(echoRoot);
|
|
253
|
+
// Also notify the owner chain so parent objects are updated when nested objects change.
|
|
254
|
+
notifyOwnerChain(target);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
} finally {
|
|
258
|
+
this._inSet = false;
|
|
259
|
+
}
|
|
130
260
|
return result;
|
|
131
261
|
}
|
|
132
262
|
|
|
133
263
|
ownKeys(target: ProxyTarget): ArrayLike<string | symbol> {
|
|
134
|
-
// Touch both signals since `set` and `delete` operations may create or remove properties.
|
|
135
|
-
target[symbolSignal].notifyRead();
|
|
136
|
-
target[symbolPropertySignal].notifyRead();
|
|
137
264
|
return Reflect.ownKeys(target);
|
|
138
265
|
}
|
|
139
266
|
|
|
267
|
+
deleteProperty(target: ProxyTarget, property: string | symbol): boolean {
|
|
268
|
+
const echoRoot = getEchoRoot(target);
|
|
269
|
+
|
|
270
|
+
// Check readonly enforcement - mutations only allowed within Obj.change().
|
|
271
|
+
// Skip for symbol properties (internal infrastructure, not user data).
|
|
272
|
+
const isInitialized = (echoRoot as any)[ChangeId] === true || EventId in echoRoot;
|
|
273
|
+
const isSymbolProp = typeof property === 'symbol';
|
|
274
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
275
|
+
throw createPropertyDeleteError(property);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const result = Reflect.deleteProperty(target, property);
|
|
279
|
+
if (isInitialized) {
|
|
280
|
+
queueNotification(echoRoot);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
|
|
140
285
|
defineProperty(target: ProxyTarget, property: string | symbol, attributes: PropertyDescriptor): boolean {
|
|
141
|
-
const
|
|
286
|
+
const echoRoot = getEchoRoot(target);
|
|
287
|
+
|
|
288
|
+
// Check readonly enforcement - mutations only allowed within Obj.change().
|
|
289
|
+
// Skip check if the object is still being initialized (no ChangeId handler yet).
|
|
290
|
+
// Skip for symbol properties (internal infrastructure, not user data).
|
|
291
|
+
const isInitialized = ChangeId in echoRoot || EventId in echoRoot;
|
|
292
|
+
const isSymbolProp = typeof property === 'symbol';
|
|
293
|
+
if (isInitialized && !isSymbolProp && !isInChangeContext(echoRoot)) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
`Cannot modify object property "${String(property)}" outside of Obj.change(). ` +
|
|
296
|
+
'Use Obj.change(obj, (mutableObj) => { mutableObj.property = value; }) instead.',
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const { echoRoot: _, preparedValue } = this._prepareValueForAssignment(target, property, attributes.value);
|
|
142
301
|
const result = Reflect.defineProperty(target, property, {
|
|
143
302
|
...attributes,
|
|
144
|
-
value:
|
|
303
|
+
value: preparedValue,
|
|
145
304
|
});
|
|
146
|
-
|
|
305
|
+
if (!this._inSet && isInitialized) {
|
|
306
|
+
// Queue notification instead of emitting immediately (batched).
|
|
307
|
+
queueNotification(echoRoot);
|
|
308
|
+
}
|
|
147
309
|
return result;
|
|
148
310
|
}
|
|
149
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Prepare a value for assignment to a typed object property.
|
|
314
|
+
* Handles cycle detection, copy-on-assign, array conversion, validation, and ownership.
|
|
315
|
+
*/
|
|
316
|
+
private _prepareValueForAssignment(
|
|
317
|
+
target: ProxyTarget,
|
|
318
|
+
prop: string | symbol,
|
|
319
|
+
value: any,
|
|
320
|
+
): { echoRoot: object; preparedValue: any } {
|
|
321
|
+
const echoRoot = getEchoRoot(target);
|
|
322
|
+
|
|
323
|
+
// Check for cycles before assignment.
|
|
324
|
+
if (isValidProxyTarget(value) || isProxy(value)) {
|
|
325
|
+
if (wouldCreateCycle(echoRoot, value)) {
|
|
326
|
+
throw new Error('Cannot create cycles in typed object graph. Consider using Ref for circular references.');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Prevent direct assignment of root ECHO objects (those created with Obj.make/Relation.make).
|
|
331
|
+
// These must be wrapped with Ref.make for proper reference handling.
|
|
332
|
+
// This matches database object behavior for consistency.
|
|
333
|
+
if (isValidProxyTarget(value) || isProxy(value)) {
|
|
334
|
+
const actualValue = getRawTarget(value);
|
|
335
|
+
const isRootEchoObject = EventId in actualValue;
|
|
336
|
+
if (isRootEchoObject) {
|
|
337
|
+
throw new Error('Object references must be wrapped with `Ref.make`');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Copy-on-assign: If the value is a nested record owned by a different ECHO object, deep copy it.
|
|
342
|
+
if (isValidProxyTarget(value) || isProxy(value)) {
|
|
343
|
+
const actualValue = getRawTarget(value);
|
|
344
|
+
const existingOwner = getOwner(actualValue);
|
|
345
|
+
if (existingOwner != null && existingOwner !== echoRoot) {
|
|
346
|
+
value = deepCopy(value);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Convert arrays to reactive arrays.
|
|
351
|
+
if (Array.isArray(value) && !(value instanceof ReactiveArray)) {
|
|
352
|
+
value = ReactiveArray.from(value);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const validatedValue = this._validateValue(target, prop, value);
|
|
356
|
+
|
|
357
|
+
// Set owner on new value to the root ECHO object.
|
|
358
|
+
if (isValidProxyTarget(validatedValue) || isProxy(validatedValue)) {
|
|
359
|
+
setOwnerRecursive(validatedValue, echoRoot);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return { echoRoot, preparedValue: validatedValue };
|
|
363
|
+
}
|
|
364
|
+
|
|
150
365
|
private _validateValue(target: any, prop: string | symbol, value: any) {
|
|
151
366
|
const schema = SchemaValidator.getTargetPropertySchema(target, prop);
|
|
152
367
|
const _ = Schema.asserts(schema)(value);
|
|
153
|
-
if (Array.isArray(value)) {
|
|
154
|
-
value = new ReactiveArray(...value);
|
|
155
|
-
}
|
|
156
368
|
if (isValidProxyTarget(value)) {
|
|
157
369
|
setSchemaProperties(value, schema);
|
|
158
370
|
}
|
|
@@ -165,18 +377,20 @@ export class TypedReactiveHandler implements ReactiveHandler<ProxyTarget> {
|
|
|
165
377
|
options: InspectOptionsStylized,
|
|
166
378
|
inspectFn: (value: any, options?: InspectOptionsStylized) => string,
|
|
167
379
|
): string {
|
|
168
|
-
|
|
380
|
+
const inspected = inspectFn(this, {
|
|
169
381
|
...options,
|
|
170
|
-
compact: true,
|
|
171
382
|
showHidden: false,
|
|
172
383
|
customInspect: false,
|
|
173
|
-
})
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
return `Typed ${inspected}`;
|
|
174
387
|
}
|
|
175
388
|
}
|
|
176
389
|
|
|
177
390
|
/**
|
|
178
391
|
* @deprecated Use `Obj.toJSON` instead.
|
|
179
392
|
*/
|
|
393
|
+
// TODO(burdon): Remove?
|
|
180
394
|
const toJSON = (target: ProxyTarget): any => {
|
|
181
395
|
return { '@type': 'TypedReactiveObject', ...target };
|
|
182
396
|
};
|
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { EchoObjectSchema } from '../entities';
|
|
9
|
+
import { getSchema } from '../types';
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
+
import { makeObject } from './make-object';
|
|
12
|
+
import { change } from './reactive';
|
|
11
13
|
|
|
12
14
|
const Organization = Schema.Struct({
|
|
13
15
|
name: Schema.String,
|
|
14
16
|
}).pipe(
|
|
15
|
-
|
|
17
|
+
EchoObjectSchema({
|
|
16
18
|
typename: 'example.com/type/Organization',
|
|
17
19
|
version: '0.1.0',
|
|
18
20
|
}),
|
|
@@ -24,10 +26,13 @@ const Contact = Schema.Struct(
|
|
|
24
26
|
{
|
|
25
27
|
name: Schema.String,
|
|
26
28
|
},
|
|
27
|
-
{
|
|
29
|
+
{
|
|
30
|
+
key: Schema.String,
|
|
31
|
+
value: Schema.Any,
|
|
32
|
+
},
|
|
28
33
|
).pipe(
|
|
29
34
|
Schema.partial,
|
|
30
|
-
|
|
35
|
+
EchoObjectSchema({
|
|
31
36
|
typename: 'example.com/type/Person',
|
|
32
37
|
version: '0.1.0',
|
|
33
38
|
}),
|
|
@@ -37,17 +42,19 @@ interface Contact extends Schema.Schema.Type<typeof Contact> {}
|
|
|
37
42
|
|
|
38
43
|
const TEST_ORG: Omit<Organization, 'id'> = { name: 'Test' };
|
|
39
44
|
|
|
40
|
-
describe('
|
|
45
|
+
describe('EchoObjectSchema class DSL', () => {
|
|
41
46
|
test('can get object schema', async () => {
|
|
42
|
-
const obj =
|
|
47
|
+
const obj = makeObject(Organization, TEST_ORG);
|
|
43
48
|
expect(getSchema(obj)).to.deep.eq(Organization);
|
|
44
49
|
});
|
|
45
50
|
|
|
46
51
|
describe('class options', () => {
|
|
47
52
|
test('can assign undefined to partial fields', async () => {
|
|
48
|
-
const person =
|
|
49
|
-
person
|
|
50
|
-
|
|
53
|
+
const person = makeObject(Contact, { name: 'John' });
|
|
54
|
+
change(person, (p) => {
|
|
55
|
+
p.name = undefined;
|
|
56
|
+
p.recordField = 'hello';
|
|
57
|
+
});
|
|
51
58
|
expect(person.name).to.be.undefined;
|
|
52
59
|
expect(person.recordField).to.eq('hello');
|
|
53
60
|
});
|
|
@@ -65,36 +72,45 @@ describe('EchoObject class DSL', () => {
|
|
|
65
72
|
);
|
|
66
73
|
|
|
67
74
|
{
|
|
68
|
-
const object =
|
|
69
|
-
(object
|
|
70
|
-
|
|
75
|
+
const object = makeObject(schema, {});
|
|
76
|
+
change(object, (o) => {
|
|
77
|
+
(o.meta ??= {}).test = 100;
|
|
78
|
+
});
|
|
79
|
+
expect(object.meta!.test).to.eq(100);
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
{
|
|
74
|
-
const object =
|
|
75
|
-
object
|
|
76
|
-
|
|
83
|
+
const object = makeObject(schema, {});
|
|
84
|
+
change(object, (o) => {
|
|
85
|
+
o.meta = { test: { value: 300 } };
|
|
86
|
+
});
|
|
87
|
+
expect(object.meta!.test.value).to.eq(300);
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
{
|
|
91
|
+
// Plain object (not a reactive proxy) - doesn't need Obj.change.
|
|
80
92
|
type Test1 = Schema.Schema.Type<typeof schema>;
|
|
81
93
|
|
|
82
94
|
const object: Test1 = {};
|
|
83
95
|
(object.meta ??= {}).test = 100;
|
|
84
|
-
expect(object.meta
|
|
96
|
+
expect(object.meta!.test).to.eq(100);
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
{
|
|
88
|
-
|
|
89
|
-
typename: 'dxos.org/type/FunctionTrigger',
|
|
90
|
-
version: '0.1.0',
|
|
91
|
-
})({
|
|
100
|
+
const Test2 = Schema.Struct({
|
|
92
101
|
meta: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
}).pipe(
|
|
103
|
+
EchoObjectSchema({
|
|
104
|
+
typename: 'dxos.org/type/FunctionTrigger',
|
|
105
|
+
version: '0.1.0',
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const object = makeObject(Test2, {});
|
|
110
|
+
change(object, (o) => {
|
|
111
|
+
(o.meta ??= {}).test = 100;
|
|
112
|
+
});
|
|
113
|
+
expect(object.meta!.test).to.eq(100);
|
|
98
114
|
}
|
|
99
115
|
});
|
|
100
116
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type ObjectId } from '@dxos/keys';
|
|
6
6
|
import { isNonNullable } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type AnyEntity } from '../types';
|
|
9
9
|
|
|
10
10
|
import { Ref } from './ref';
|
|
11
11
|
|
|
@@ -16,21 +16,21 @@ export const RefArray = Object.freeze({
|
|
|
16
16
|
/**
|
|
17
17
|
* @returns all resolved targets.
|
|
18
18
|
*/
|
|
19
|
-
targets: <T extends
|
|
19
|
+
targets: <T extends AnyEntity>(refs: readonly Ref<T>[]): T[] => {
|
|
20
20
|
return refs.map((ref) => ref.target).filter(isNonNullable);
|
|
21
21
|
},
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Load all referenced objects.
|
|
25
25
|
*/
|
|
26
|
-
loadAll: <T extends
|
|
26
|
+
loadAll: <T extends AnyEntity>(refs: readonly Ref<T>[]): Promise<T[]> => {
|
|
27
27
|
return Promise.all(refs.map((ref) => ref.load()));
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Removes the ref with the given id.
|
|
32
32
|
*/
|
|
33
|
-
removeById: (refs: Ref<
|
|
33
|
+
removeById: (refs: Ref<AnyEntity>[], id: ObjectId) => {
|
|
34
34
|
const index = refs.findIndex(Ref.hasObjectId(id));
|
|
35
35
|
if (index >= 0) {
|
|
36
36
|
refs.splice(index, 1);
|
|
@@ -7,14 +7,15 @@ import { describe, expect, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { DXN, ObjectId } from '@dxos/keys';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { EchoObjectSchema, getObjectDXN } from '../entities';
|
|
11
|
+
import { createObject } from '../object';
|
|
11
12
|
|
|
12
13
|
import { Ref, getReferenceAst } from './ref';
|
|
13
14
|
|
|
14
15
|
const Task = Schema.Struct({
|
|
15
16
|
title: Schema.optional(Schema.String),
|
|
16
17
|
}).pipe(
|
|
17
|
-
|
|
18
|
+
EchoObjectSchema({
|
|
18
19
|
typename: 'example.com/type/Task',
|
|
19
20
|
version: '0.1.0',
|
|
20
21
|
}),
|
|
@@ -27,7 +28,7 @@ const Contact = Schema.Struct({
|
|
|
27
28
|
email: Schema.optional(Schema.String),
|
|
28
29
|
tasks: Schema.mutable(Schema.Array(Ref(Task))),
|
|
29
30
|
}).pipe(
|
|
30
|
-
|
|
31
|
+
EchoObjectSchema({
|
|
31
32
|
typename: 'example.com/type/Person',
|
|
32
33
|
version: '0.1.0',
|
|
33
34
|
}),
|
|
@@ -49,8 +50,8 @@ describe('Ref', () => {
|
|
|
49
50
|
|
|
50
51
|
// TODO(dmaretskyi): Figure out how to expose this in the API.
|
|
51
52
|
test.skip('encode with inlined target', () => {
|
|
52
|
-
const task =
|
|
53
|
-
const contact =
|
|
53
|
+
const task = createObject(Task, { title: 'Fix bugs' });
|
|
54
|
+
const contact = createObject(Contact, { name: 'John Doe', tasks: [Ref.make(task)] });
|
|
54
55
|
|
|
55
56
|
const json = JSON.parse(JSON.stringify(contact));
|
|
56
57
|
expect(json).toEqual({
|
|
@@ -70,8 +71,8 @@ describe('Ref', () => {
|
|
|
70
71
|
});
|
|
71
72
|
|
|
72
73
|
test('encode without inlining target', () => {
|
|
73
|
-
const task =
|
|
74
|
-
const contact =
|
|
74
|
+
const task = createObject(Task, { title: 'Fix bugs' });
|
|
75
|
+
const contact = createObject(Contact, { name: 'John Doe', tasks: [Ref.make(task).noInline()] });
|
|
75
76
|
|
|
76
77
|
const json = JSON.parse(JSON.stringify(contact));
|
|
77
78
|
expect(json).toEqual({
|