@dxos/echo 0.8.4-main.84f28bd → 0.8.4-main.937b3ca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/lib/browser/Annotation.mjs +33 -0
- package/dist/lib/browser/Annotation.mjs.map +7 -0
- package/dist/lib/browser/Database.mjs +18 -0
- package/dist/lib/browser/Database.mjs.map +7 -0
- package/dist/lib/browser/Entity.mjs +52 -0
- package/dist/lib/browser/Entity.mjs.map +7 -0
- package/dist/lib/browser/Err.mjs +11 -0
- package/dist/lib/browser/Err.mjs.map +7 -0
- package/dist/lib/browser/Filter.mjs +62 -0
- package/dist/lib/browser/Filter.mjs.map +7 -0
- package/dist/lib/browser/Format.mjs +67 -0
- package/dist/lib/browser/Format.mjs.map +7 -0
- package/dist/lib/browser/JsonSchema.mjs +20 -0
- package/dist/lib/browser/JsonSchema.mjs.map +7 -0
- package/dist/lib/browser/Key.mjs +13 -0
- package/dist/lib/browser/Key.mjs.map +7 -0
- package/dist/lib/browser/Obj.mjs +91 -0
- package/dist/lib/browser/Obj.mjs.map +7 -0
- package/dist/lib/browser/Order.mjs +13 -0
- package/dist/lib/browser/Order.mjs.map +7 -0
- package/dist/lib/browser/Query.mjs +27 -0
- package/dist/lib/browser/Query.mjs.map +7 -0
- package/dist/lib/browser/QueryResult.mjs +3 -0
- package/dist/lib/browser/QueryResult.mjs.map +7 -0
- package/dist/lib/browser/Ref.mjs +23 -0
- package/dist/lib/browser/Ref.mjs.map +7 -0
- package/dist/lib/browser/Relation.mjs +85 -0
- package/dist/lib/browser/Relation.mjs.map +7 -0
- package/dist/lib/browser/SchemaRegistry.mjs +3 -0
- package/dist/lib/browser/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/browser/Tag.mjs +26 -0
- package/dist/lib/browser/Tag.mjs.map +7 -0
- package/dist/lib/browser/Type.mjs +48 -0
- package/dist/lib/browser/Type.mjs.map +7 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs +24 -0
- package/dist/lib/browser/chunk-22JMFST2.mjs.map +7 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs +250 -0
- package/dist/lib/browser/chunk-2SBB7OWV.mjs.map +7 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs +158 -0
- package/dist/lib/browser/chunk-6L5HHUVU.mjs.map +7 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs +133 -0
- package/dist/lib/browser/chunk-7STIBCP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-BJPE6CIC.mjs +3847 -0
- package/dist/lib/browser/chunk-BJPE6CIC.mjs.map +7 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/chunk-CJ5YELTO.mjs +39 -0
- package/dist/lib/browser/chunk-CJ5YELTO.mjs.map +7 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs +40 -0
- package/dist/lib/browser/chunk-FPOISFQK.mjs.map +7 -0
- package/dist/lib/browser/chunk-FRDT7RA4.mjs +403 -0
- package/dist/lib/browser/chunk-FRDT7RA4.mjs.map +7 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs +22 -0
- package/dist/lib/browser/chunk-INHXFXY5.mjs.map +7 -0
- package/dist/lib/browser/chunk-IXVWLTG7.mjs +9 -0
- package/dist/lib/browser/chunk-IXVWLTG7.mjs.map +7 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs +43 -0
- package/dist/lib/browser/chunk-JMKVF2YQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-KQQGVHFN.mjs +143 -0
- package/dist/lib/browser/chunk-KQQGVHFN.mjs.map +7 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs +15 -0
- package/dist/lib/browser/chunk-MYCCGG2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-NOPVNWPT.mjs +204 -0
- package/dist/lib/browser/chunk-NOPVNWPT.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs +74 -0
- package/dist/lib/browser/chunk-PQZW3S6L.mjs.map +7 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs +283 -0
- package/dist/lib/browser/chunk-RK4Z4JUZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs +57 -0
- package/dist/lib/browser/chunk-U2J7TA7K.mjs.map +7 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs +98 -0
- package/dist/lib/browser/chunk-W5D2GWAW.mjs.map +7 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs +41 -0
- package/dist/lib/browser/chunk-XDIUHAAX.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs +69 -0
- package/dist/lib/browser/chunk-YKTSSMDS.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs +288 -0
- package/dist/lib/browser/chunk-ZAGAOZVY.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs +9 -0
- package/dist/lib/browser/chunk-ZHXZGIXD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -9
- package/dist/lib/browser/internal/index.mjs +457 -0
- package/dist/lib/browser/internal/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +332 -35
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/Annotation.mjs +33 -0
- package/dist/lib/node-esm/Annotation.mjs.map +7 -0
- package/dist/lib/node-esm/Database.mjs +18 -0
- package/dist/lib/node-esm/Database.mjs.map +7 -0
- package/dist/lib/node-esm/Entity.mjs +52 -0
- package/dist/lib/node-esm/Entity.mjs.map +7 -0
- package/dist/lib/node-esm/Err.mjs +11 -0
- package/dist/lib/node-esm/Err.mjs.map +7 -0
- package/dist/lib/node-esm/Filter.mjs +62 -0
- package/dist/lib/node-esm/Filter.mjs.map +7 -0
- package/dist/lib/node-esm/Format.mjs +67 -0
- package/dist/lib/node-esm/Format.mjs.map +7 -0
- package/dist/lib/node-esm/JsonSchema.mjs +20 -0
- package/dist/lib/node-esm/JsonSchema.mjs.map +7 -0
- package/dist/lib/node-esm/Key.mjs +13 -0
- package/dist/lib/node-esm/Key.mjs.map +7 -0
- package/dist/lib/node-esm/Obj.mjs +91 -0
- package/dist/lib/node-esm/Obj.mjs.map +7 -0
- package/dist/lib/node-esm/Order.mjs +13 -0
- package/dist/lib/node-esm/Order.mjs.map +7 -0
- package/dist/lib/node-esm/Query.mjs +27 -0
- package/dist/lib/node-esm/Query.mjs.map +7 -0
- package/dist/lib/node-esm/QueryResult.mjs +3 -0
- package/dist/lib/node-esm/QueryResult.mjs.map +7 -0
- package/dist/lib/node-esm/Ref.mjs +23 -0
- package/dist/lib/node-esm/Ref.mjs.map +7 -0
- package/dist/lib/node-esm/Relation.mjs +85 -0
- package/dist/lib/node-esm/Relation.mjs.map +7 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs +3 -0
- package/dist/lib/node-esm/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/node-esm/Tag.mjs +26 -0
- package/dist/lib/node-esm/Tag.mjs.map +7 -0
- package/dist/lib/node-esm/Type.mjs +48 -0
- package/dist/lib/node-esm/Type.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs +250 -0
- package/dist/lib/node-esm/chunk-4PNXQA64.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs +158 -0
- package/dist/lib/node-esm/chunk-5OBN7GZW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs +22 -0
- package/dist/lib/node-esm/chunk-AJEMYSIR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs +98 -0
- package/dist/lib/node-esm/chunk-ANLVLWME.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs +57 -0
- package/dist/lib/node-esm/chunk-DMR7OAFK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs +133 -0
- package/dist/lib/node-esm/chunk-FWTSPIFF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs +204 -0
- package/dist/lib/node-esm/chunk-ILMLLM4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs +43 -0
- package/dist/lib/node-esm/chunk-K37NA7PO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs +3847 -0
- package/dist/lib/node-esm/chunk-LT3H4JOX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs +9 -0
- package/dist/lib/node-esm/chunk-MOLNWFNL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs +15 -0
- package/dist/lib/node-esm/chunk-MOWUEW5P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs +40 -0
- package/dist/lib/node-esm/chunk-NBWL7UCZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs +143 -0
- package/dist/lib/node-esm/chunk-NRN3ZW2T.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs +41 -0
- package/dist/lib/node-esm/chunk-QLI2EIJ2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs +288 -0
- package/dist/lib/node-esm/chunk-QYR67VBV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs +9 -0
- package/dist/lib/node-esm/chunk-UKGVOINP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs +403 -0
- package/dist/lib/node-esm/chunk-W6QIEBTQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs +69 -0
- package/dist/lib/node-esm/chunk-XHJRMQZD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs +74 -0
- package/dist/lib/node-esm/chunk-Y75VU7LB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs +283 -0
- package/dist/lib/node-esm/chunk-YOLH5KS4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs +39 -0
- package/dist/lib/node-esm/chunk-YQ2NWGL5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs +24 -0
- package/dist/lib/node-esm/chunk-ZBB67AKD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +72 -9
- package/dist/lib/node-esm/internal/index.mjs +457 -0
- package/dist/lib/node-esm/internal/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +332 -35
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +194 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +142 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/Err.d.ts +64 -0
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +9 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +344 -34
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +115 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +13 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +242 -19
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +225 -73
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +15 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +170 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts +2 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +27 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/api/annotations.d.ts +23 -0
- package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/api/entity.d.ts +13 -0
- package/dist/types/src/internal/api/entity.d.ts.map +1 -0
- package/dist/types/src/internal/api/index.d.ts +15 -0
- package/dist/types/src/internal/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/api/meta.d.ts +42 -0
- package/dist/types/src/internal/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/api/sorting.d.ts +24 -0
- package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/api/version.d.ts +42 -0
- package/dist/types/src/internal/api/version.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +20 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +77 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +18 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +62 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.d.ts +63 -0
- package/dist/types/src/internal/formats/date.d.ts.map +1 -0
- package/dist/types/src/internal/formats/date.test.d.ts +2 -0
- package/dist/types/src/internal/formats/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +32 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.test.d.ts +2 -0
- package/dist/types/src/internal/formats/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/formats/index.d.ts +8 -0
- package/dist/types/src/internal/formats/index.d.ts.map +1 -0
- package/dist/types/src/internal/formats/number.d.ts +31 -0
- package/dist/types/src/internal/formats/number.d.ts.map +1 -0
- package/dist/types/src/internal/formats/object.d.ts +35 -0
- package/dist/types/src/internal/formats/object.d.ts.map +1 -0
- package/dist/types/src/internal/formats/select.d.ts +13 -0
- package/dist/types/src/internal/formats/select.d.ts.map +1 -0
- package/dist/types/src/internal/formats/string.d.ts +42 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -0
- package/dist/types/src/internal/formats/types.d.ts +72 -0
- package/dist/types/src/internal/formats/types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +12 -0
- package/dist/types/src/internal/index.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/annotations.d.ts +19 -0
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +5 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts +7 -0
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +250 -0
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.d.ts +29 -0
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts +2 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/clone.d.ts +8 -0
- package/dist/types/src/internal/object/clone.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts +18 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.d.ts +39 -0
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +6 -0
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/object/ids.d.ts +6 -0
- package/dist/types/src/internal/object/ids.d.ts.map +1 -0
- package/dist/types/src/internal/object/index.d.ts +11 -0
- package/dist/types/src/internal/object/index.d.ts.map +1 -0
- package/dist/types/src/internal/object/inspect.d.ts +2 -0
- package/dist/types/src/internal/object/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.d.ts +37 -0
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts +2 -0
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts +2 -0
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.d.ts +7 -0
- package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/snapshot.d.ts +6 -0
- package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +25 -0
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +47 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/ref/index.d.ts +3 -0
- package/dist/types/src/internal/ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref-array.d.ts +21 -0
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.d.ts +217 -0
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/ref/ref.test.d.ts +2 -0
- package/dist/types/src/internal/ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.d.ts +6 -0
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts +2 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +180 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/index.d.ts +4 -0
- package/dist/types/src/internal/schema/index.d.ts.map +1 -0
- package/dist/types/src/internal/schema/manipulation.d.ts +10 -0
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +26 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +37 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +6 -0
- package/dist/types/src/internal/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/types/meta.d.ts +32 -0
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/types/version.d.ts +15 -0
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +303 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +166 -33
- package/src/Annotation.ts +18 -0
- package/src/Database.ts +336 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +217 -0
- package/src/Err.ts +18 -0
- package/src/Filter.ts +376 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +74 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.test.ts +386 -0
- package/src/Obj.ts +509 -85
- package/src/Order.ts +44 -0
- package/src/Query.test.ts +465 -0
- package/src/Query.ts +296 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +25 -9
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +414 -51
- package/src/SchemaRegistry.ts +105 -0
- package/src/Tag.ts +40 -0
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +360 -112
- package/src/index.ts +17 -4
- package/src/internal/README.md +102 -0
- package/src/internal/annotations/annotations.test.ts +96 -0
- package/src/internal/annotations/annotations.ts +460 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +72 -0
- package/src/internal/api/annotations.ts +60 -0
- package/src/internal/api/entity.ts +29 -0
- package/src/internal/api/index.ts +19 -0
- package/src/internal/api/meta.ts +88 -0
- package/src/internal/api/sorting.ts +53 -0
- package/src/internal/api/version.ts +96 -0
- package/src/internal/entities/entity.ts +126 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +134 -0
- package/src/internal/entities/object.ts +60 -0
- package/src/internal/entities/relation.ts +173 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +56 -0
- package/src/internal/formats/date.ts +217 -0
- package/src/internal/formats/format.test.ts +77 -0
- package/src/internal/formats/format.ts +54 -0
- package/src/internal/formats/index.ts +12 -0
- package/src/internal/formats/number.ts +89 -0
- package/src/internal/formats/object.ts +80 -0
- package/src/internal/formats/select.ts +18 -0
- package/src/internal/formats/string.ts +81 -0
- package/src/internal/formats/types.ts +186 -0
- package/src/internal/index.ts +39 -0
- package/src/internal/json-schema/annotations.ts +50 -0
- package/src/internal/json-schema/effect-schema.test.ts +143 -0
- package/src/internal/json-schema/index.ts +8 -0
- package/src/internal/json-schema/json-schema-normalize.ts +109 -0
- package/src/internal/json-schema/json-schema-type.ts +404 -0
- package/src/internal/json-schema/json-schema.test.ts +861 -0
- package/src/internal/json-schema/json-schema.ts +528 -0
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/common.ts +75 -0
- package/src/internal/object/create-object.test.ts +116 -0
- package/src/internal/object/create-object.ts +95 -0
- package/src/internal/object/deleted.ts +19 -0
- package/src/internal/object/ids.ts +12 -0
- package/src/internal/object/index.ts +14 -0
- package/src/internal/object/inspect.ts +46 -0
- package/src/internal/object/json-serializer.test.ts +97 -0
- package/src/internal/object/json-serializer.ts +188 -0
- package/src/internal/object/schema-validator.test.ts +186 -0
- package/src/internal/object/schema-validator.ts +6 -0
- package/src/internal/object/set-value.test.ts +281 -0
- package/src/internal/object/set-value.ts +165 -0
- package/src/internal/object/snapshot.ts +70 -0
- package/src/internal/object/typed-object.test.ts +34 -0
- package/src/internal/object/typed-object.ts +30 -0
- package/src/internal/proxy/change-context.ts +138 -0
- package/src/internal/proxy/change.test.ts +519 -0
- package/src/internal/proxy/define-hidden-property.ts +14 -0
- package/src/internal/proxy/errors.ts +42 -0
- package/src/internal/proxy/event-batch.ts +44 -0
- package/src/internal/proxy/handler.test.ts +123 -0
- package/src/internal/proxy/index.ts +17 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +96 -0
- package/src/internal/proxy/ownership.ts +253 -0
- package/src/internal/proxy/proxy-types.ts +23 -0
- package/src/internal/proxy/proxy-utils.ts +150 -0
- package/src/internal/proxy/reactive-array.ts +71 -0
- package/src/internal/proxy/reactive.ts +69 -0
- package/src/internal/proxy/schema-validator.ts +244 -0
- package/src/internal/proxy/schema.test.ts +145 -0
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +318 -0
- package/src/internal/proxy/typed-handler.ts +442 -0
- package/src/internal/proxy/typed-object.test.ts +116 -0
- package/src/internal/ref/index.ts +6 -0
- package/src/internal/ref/ref-array.ts +39 -0
- package/src/internal/ref/ref.test.ts +101 -0
- package/src/internal/ref/ref.ts +548 -0
- package/src/internal/schema/compose.test.ts +42 -0
- package/src/internal/schema/compose.ts +36 -0
- package/src/internal/schema/echo-schema.ts +423 -0
- package/src/internal/schema/index.ts +7 -0
- package/src/internal/schema/manipulation.ts +92 -0
- package/src/internal/schema/persistent-schema.ts +27 -0
- package/src/internal/types/base.ts +43 -0
- package/src/internal/types/entity.ts +54 -0
- package/src/internal/types/index.ts +9 -0
- package/src/internal/types/meta.ts +66 -0
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -1
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +238 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-SVSJEELN.mjs +0 -619
- package/dist/lib/browser/chunk-SVSJEELN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-53HXWYR6.mjs +0 -619
- package/dist/lib/node-esm/chunk-53HXWYR6.mjs.map +0 -7
- package/dist/types/src/experimental/database.d.ts +0 -8
- package/dist/types/src/experimental/database.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -1
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/queue.d.ts +0 -8
- package/dist/types/src/experimental/queue.d.ts.map +0 -1
- package/dist/types/src/experimental/space.d.ts +0 -8
- package/dist/types/src/experimental/space.d.ts.map +0 -1
- package/dist/types/src/query/dsl.d.ts +0 -218
- package/dist/types/src/query/dsl.d.ts.map +0 -1
- package/dist/types/src/query/dsl.test.d.ts +0 -2
- package/dist/types/src/query/dsl.test.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -2
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -113
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/experimental/database.ts +0 -11
- package/src/experimental/index.ts +0 -7
- package/src/experimental/queue.ts +0 -11
- package/src/experimental/space.ts +0 -11
- package/src/query/dsl.test.ts +0 -323
- package/src/query/dsl.ts +0 -646
- package/src/query/index.ts +0 -5
- package/src/test/api.test.ts +0 -173
- package/src/testing/types.ts +0 -91
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
## Refactor
|
|
2
|
+
|
|
3
|
+
1. Remove access from outisde of @dxos/echo-db
|
|
4
|
+
|
|
5
|
+
- [x] completely restructure @dxos/echo src/internal
|
|
6
|
+
- [x] Remove import "." and ".."! (create lint rule).
|
|
7
|
+
- [x] Unify FOUR different nests of test schema.
|
|
8
|
+
- [x] Remove @deprecated from internal methods and mark @internal (e.g., getSchemaDXN).
|
|
9
|
+
- NOTE: Internal methods should not use the import \* from Obj/Type APIs.
|
|
10
|
+
- [x] import ObjectId => @dxos/keys
|
|
11
|
+
- [x] Entity.Any = Obj.Any | Relation.Any
|
|
12
|
+
- NOTE: Relation does not extend (in not polymorphic with) Obj.
|
|
13
|
+
- [x] import LabelAnnotation => Annotation.LabelAnnotation
|
|
14
|
+
- [x] import Expando => @dxos/schema (Expando.Expando)
|
|
15
|
+
- [x] live => Obj.make
|
|
16
|
+
- [x] Rename live => makeObject
|
|
17
|
+
- [x] Rename {EchoObject, EchoRelation} => {EchoObjecSchema, EchoRelationSchema}
|
|
18
|
+
- [x] Rename AnyProperties => AnyProperties
|
|
19
|
+
- [x] Created Entity.Any (=> AnyEchoObject).
|
|
20
|
+
- [x] TypeFormat => TypeFormat
|
|
21
|
+
- [x] JsonSchemaType defs
|
|
22
|
+
- [x] Fix database.add() input/output types and search for "Obj.Any = db.add" (also QueryResult types).
|
|
23
|
+
- [x] TODO(burdon): FIX!!!
|
|
24
|
+
- [x] Fix failing tests.
|
|
25
|
+
- [x] Reconcile types/version with entities/model/version
|
|
26
|
+
- [x] Expando moved to @dxos/schema
|
|
27
|
+
- [x] Narrow QueryResult and match Schema and Object generics.
|
|
28
|
+
|
|
29
|
+
2. Clean-up
|
|
30
|
+
|
|
31
|
+
- [x] QueryResult namespace
|
|
32
|
+
- [x] SchemaRegistry interface
|
|
33
|
+
- [x] Schema registry should return Type.Entity.Any instead of Schema.Schema.AnyNoContext.
|
|
34
|
+
- [x] Hypergraph interface
|
|
35
|
+
- [x] Obj.getDatabase
|
|
36
|
+
- [x] SpaceAction.AddObject target should be a db not a space.
|
|
37
|
+
- [x] Add Relation.MakeProps
|
|
38
|
+
- [x] Add Obj.Unknown and Relation.Unknown to match Entity.Unknown.
|
|
39
|
+
- [x] TODO(wittjosiah): Should be Type.obj<...> or equivalent.
|
|
40
|
+
- [x] TODO(wittjosiah): Find a simpler way to define this type.
|
|
41
|
+
- [x] Ref.Array.targets doesn't satisfy Obj.Any because it uses AnyEchoObject.
|
|
42
|
+
- [x] Remove echo-db/AnyLiveObject<T> => Obj.Obj<T>
|
|
43
|
+
- [x] Rename AnyEchoObject => AnyEntity
|
|
44
|
+
- [x] Remove WithId => AnyEntity
|
|
45
|
+
- [x] Remove WithMeta => AnyEntity
|
|
46
|
+
- [x] Obj.Any => Obj.Unknown
|
|
47
|
+
- [x] Relation.Any => Relation.Unknown
|
|
48
|
+
- [x] Ref.Any => Ref.Unknown
|
|
49
|
+
- [x] Obj.AnyProps => Obj.Any
|
|
50
|
+
- [x] Factor Expando out of @dxos/echo (moved to @dxos/schema)
|
|
51
|
+
- [x] Obj.instanceOf works with Expando (tested in @dxos/schema)
|
|
52
|
+
- [x] Obj.Snapshot should be same shape as Obj.Obj but with a different brand
|
|
53
|
+
- [x] Mutators should only work on object after it is made mutable
|
|
54
|
+
|
|
55
|
+
- [ ] Review usage of Obj.Any, see if it could be stricter
|
|
56
|
+
- [ ] Type.Obj should validate using the echo object brand
|
|
57
|
+
- [ ] Mutable could be a branded type to fix "NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`"
|
|
58
|
+
- [ ] space properties, queues, messagins preventing getSpace from being removed
|
|
59
|
+
- [ ] Schema registry should use Query.Query.
|
|
60
|
+
- [ ] Move EchoSchemaRegistry into hypergraph
|
|
61
|
+
- [ ] Narrow QueryResult and match Schema and Object generics.
|
|
62
|
+
- [ ] BaseSchema
|
|
63
|
+
- [ ] Directly import JSONPath, etc. from @dxos/effect.
|
|
64
|
+
- [ ] Promote parts of src/internal/ref to Ref.ts
|
|
65
|
+
- [ ] JsonPath, JsonProp, getValue, setValue => Json.Path?
|
|
66
|
+
- [ ] DISCUSS: Standradize $ suffix to disambuguate imports (GPT recommended).
|
|
67
|
+
|
|
68
|
+
3. Audit usage from @dxos/echo-db
|
|
69
|
+
|
|
70
|
+
- [ ] Ability to extract Struct from Type.Obj
|
|
71
|
+
- [ ] created/updated system props (const { created } = Obj.getTimestamps)?
|
|
72
|
+
- [ ] QueryFn, QueryOptions => Database
|
|
73
|
+
- [ ] Datatbase.query() options?
|
|
74
|
+
- [ ] Expando type is used as a fallback in many plance.
|
|
75
|
+
- [ ] Standardize '@automerge/automerge' imports (A vs. next).
|
|
76
|
+
|
|
77
|
+
## NOTES
|
|
78
|
+
|
|
79
|
+
- Marking types as @internal (even for unexported types) erases type information.
|
|
80
|
+
|
|
81
|
+
## 0.9.0
|
|
82
|
+
|
|
83
|
+
- [ ] Database, Queue, Space, Type, namespaces.
|
|
84
|
+
- [ ] Support class variant for types.
|
|
85
|
+
- [ ] Support defaults.
|
|
86
|
+
- [ ] Support effect Date, Timestamp formats.
|
|
87
|
+
- [ ] Metadata for created, updated timestamps.
|
|
88
|
+
- [ ] Effect team design review.
|
|
89
|
+
- [ ] @category annotations to group types in the API.
|
|
90
|
+
- [ ] TSdoc and LLM training for function generation.
|
|
91
|
+
- [ ] Rename TypeFormat => Primitive?
|
|
92
|
+
- [ ] Don't re-export effect?
|
|
93
|
+
|
|
94
|
+
## Issues
|
|
95
|
+
|
|
96
|
+
- [ ] Build error when changing from TypedObject using Ref$: Type 'Task' does not satisfy the constraint 'WithId' (see echo-schema/testing/schema.ts)
|
|
97
|
+
- [ ] Reconcile all schema variants (Base, Immutable, TypedObject, EchoObject, etc.)
|
|
98
|
+
- [ ] Consolidate getters (getType, getSchema, getTypename, getSchemaTypename, etc.)
|
|
99
|
+
- [ ] ReactiveObject should specify id property? Reconcile AnyProperties, ReactiveObject, HasId, WithId, etc.
|
|
100
|
+
- [ ] Can we us S.is(MyType) to detect objects with our types system? (Branding?)
|
|
101
|
+
- [ ] Type.Expando doesn't work with AtomQuery result type (have to use Obj.Any instead).
|
|
102
|
+
- [ ] Obj.Any doesn't work with Obj.change callback types (have to use `any` for the mutable parameter).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { EchoObjectSchema } from '../entities';
|
|
9
|
+
|
|
10
|
+
import { LabelAnnotation, TypenameSchema, VersionSchema, getLabelWithSchema } from './annotations';
|
|
11
|
+
|
|
12
|
+
// TODO(dmaretskyi): Use one of the testing schemas.
|
|
13
|
+
const TestObject = Schema.Struct({
|
|
14
|
+
name: Schema.optional(Schema.String),
|
|
15
|
+
fallbackName: Schema.optional(Schema.String),
|
|
16
|
+
other: Schema.String,
|
|
17
|
+
}).pipe(LabelAnnotation.set(['name', 'fallbackName']));
|
|
18
|
+
|
|
19
|
+
type TestObject = Schema.Schema.Type<typeof TestObject>;
|
|
20
|
+
|
|
21
|
+
const TestEchoSchema = TestObject.pipe(
|
|
22
|
+
EchoObjectSchema({
|
|
23
|
+
typename: 'dxos.org/type/Test',
|
|
24
|
+
version: '0.1.0',
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
type TestEchoSchema = Schema.Schema.Type<typeof TestEchoSchema>;
|
|
29
|
+
|
|
30
|
+
describe('annotations', () => {
|
|
31
|
+
describe('Typename', () => {
|
|
32
|
+
test('should validate typename', ({ expect }) => {
|
|
33
|
+
// Valid.
|
|
34
|
+
expect(TypenameSchema.make('dxos.org/type/foo')).to.exist;
|
|
35
|
+
expect(TypenameSchema.make('dxos.org/type/foo-bar')).to.exist;
|
|
36
|
+
expect(TypenameSchema.make('dxos.org/type/foo_bar')).to.exist;
|
|
37
|
+
|
|
38
|
+
// Invalid.
|
|
39
|
+
expect(() => TypenameSchema.make('dxn:dxos.org')).to.throw();
|
|
40
|
+
expect(() => TypenameSchema.make('2dxos.org')).to.throw();
|
|
41
|
+
expect(() => TypenameSchema.make('dxos org')).to.throw();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('should validate version', ({ expect }) => {
|
|
45
|
+
// Valid.
|
|
46
|
+
expect(VersionSchema.make('0.1.0')).to.exist;
|
|
47
|
+
|
|
48
|
+
// Invalid.
|
|
49
|
+
expect(() => VersionSchema.make('0.1.x')).to.throw();
|
|
50
|
+
expect(() => VersionSchema.make('0.1.0-alpha')).to.throw();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('getLabelWithSchema', () => {
|
|
55
|
+
test('should return first available label value', ({ expect }) => {
|
|
56
|
+
const obj: TestObject = {
|
|
57
|
+
name: 'Primary Name',
|
|
58
|
+
fallbackName: 'Fallback Name',
|
|
59
|
+
other: 'Other',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
expect(getLabelWithSchema(TestObject, obj)).toEqual('Primary Name');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('should fallback to second path if first is undefined', ({ expect }) => {
|
|
66
|
+
const obj: TestObject = {
|
|
67
|
+
name: undefined,
|
|
68
|
+
fallbackName: 'Fallback Name',
|
|
69
|
+
other: 'Other',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
expect(getLabelWithSchema(TestObject, obj)).toEqual('Fallback Name');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('should return undefined if no label paths resolve', ({ expect }) => {
|
|
76
|
+
const obj: TestObject = {
|
|
77
|
+
name: undefined,
|
|
78
|
+
fallbackName: undefined,
|
|
79
|
+
other: 'Other',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
expect(getLabelWithSchema(TestObject, obj)).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should return label from echo object', ({ expect }) => {
|
|
86
|
+
const obj: TestEchoSchema = {
|
|
87
|
+
id: 'test',
|
|
88
|
+
name: 'Primary Name',
|
|
89
|
+
fallbackName: 'Fallback Name',
|
|
90
|
+
other: 'Other',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
expect(getLabelWithSchema(TestEchoSchema, obj)).toEqual('Primary Name');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
|
+
|
|
10
|
+
import { raise } from '@dxos/debug';
|
|
11
|
+
import { type JsonPath, getField } from '@dxos/effect';
|
|
12
|
+
import { assertArgument, invariant } from '@dxos/invariant';
|
|
13
|
+
import { DXN } from '@dxos/keys';
|
|
14
|
+
import { type Primitive } from '@dxos/util';
|
|
15
|
+
|
|
16
|
+
import { type AnyProperties, EntityKind, TypeId, getSchema } from '../types';
|
|
17
|
+
|
|
18
|
+
import { createAnnotationHelper } from './util';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export const FIELD_PATH_ANNOTATION = 'path';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the path for the field.
|
|
27
|
+
* @param path Data source path in the json path format. This is the field path in the source object.
|
|
28
|
+
*/
|
|
29
|
+
// TODO(burdon): Field, vs. path vs. property.
|
|
30
|
+
export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
|
|
31
|
+
|
|
32
|
+
//
|
|
33
|
+
// Type
|
|
34
|
+
//
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* ECHO identifier (for a stored schema).
|
|
38
|
+
* Must be a `dxn:echo:` URI.
|
|
39
|
+
*/
|
|
40
|
+
export const TypeIdentifierAnnotationId = Symbol.for('@dxos/schema/annotation/TypeIdentifier');
|
|
41
|
+
|
|
42
|
+
export const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>
|
|
43
|
+
Function.flow(
|
|
44
|
+
SchemaAST.getAnnotation<string>(TypeIdentifierAnnotationId),
|
|
45
|
+
Option.getOrElse(() => undefined),
|
|
46
|
+
)(schema.ast);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @returns DXN of the schema.
|
|
50
|
+
*
|
|
51
|
+
* For non-stored schema returns `dxn:type:`.
|
|
52
|
+
* For stored schema returns `dxn:echo:`.
|
|
53
|
+
*/
|
|
54
|
+
export const getSchemaDXN = (schema: Schema.Schema.All): DXN | undefined => {
|
|
55
|
+
assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');
|
|
56
|
+
const id = getTypeIdentifierAnnotation(schema);
|
|
57
|
+
if (id) {
|
|
58
|
+
return DXN.parse(id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// TODO(dmaretskyi): Add support for dynamic schema.
|
|
62
|
+
const objectAnnotation = getTypeAnnotation(schema);
|
|
63
|
+
if (!objectAnnotation) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return DXN.fromTypenameAndVersion(objectAnnotation.typename, objectAnnotation.version);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param input schema or a typename string.
|
|
72
|
+
* @return type DXN.
|
|
73
|
+
*/
|
|
74
|
+
export const getTypeDXNFromSpecifier = (input: Schema.Schema.All | string): DXN => {
|
|
75
|
+
if (Schema.isSchema(input)) {
|
|
76
|
+
return getSchemaDXN(input) ?? raise(new TypeError('Schema has no DXN'));
|
|
77
|
+
} else {
|
|
78
|
+
assertArgument(typeof input === 'string', 'input');
|
|
79
|
+
assertArgument(!input.startsWith('dxn:'), 'input');
|
|
80
|
+
return DXN.fromTypename(input);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// TypeAnnotation
|
|
86
|
+
//
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Fully qualified globally unique typename.
|
|
90
|
+
* Example: `dxos.org/type/Message`
|
|
91
|
+
*/
|
|
92
|
+
// TODO(burdon): Reconcile with short DXN format.
|
|
93
|
+
// TODO(burdon): Change "/type" => "/schema" throughout.
|
|
94
|
+
export const TypenameSchema = Schema.String.pipe(Schema.pattern(/^[a-zA-Z]\w+\.[a-zA-Z]\w{1,}\/[\w/_-]+$/)).annotations(
|
|
95
|
+
{
|
|
96
|
+
description: 'Fully qualified globally unique typename',
|
|
97
|
+
example: 'dxos.org/type/Message',
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Semantic version format: `major.minor.patch`
|
|
103
|
+
* Example: `1.0.0`
|
|
104
|
+
*/
|
|
105
|
+
export const VersionSchema = Schema.String.pipe(Schema.pattern(/^\d+.\d+.\d+$/)).annotations({
|
|
106
|
+
description: 'Semantic version format: `major.minor.patch`',
|
|
107
|
+
example: '1.0.0',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const TypeMeta = Schema.Struct({
|
|
111
|
+
typename: TypenameSchema,
|
|
112
|
+
version: VersionSchema,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export interface TypeMeta extends Schema.Schema.Type<typeof TypeMeta> {}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Entity type.
|
|
119
|
+
*/
|
|
120
|
+
export const TypeAnnotationId = Symbol.for('@dxos/schema/annotation/Type');
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Payload stored under {@link TypeAnnotationId}.
|
|
124
|
+
*/
|
|
125
|
+
export const TypeAnnotation = Schema.extend(
|
|
126
|
+
TypeMeta,
|
|
127
|
+
Schema.Struct({
|
|
128
|
+
kind: Schema.Enums(EntityKind),
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* If this is a relation, the schema of the source object.
|
|
132
|
+
* Must be present if entity kind is {@link EntityKind.Relation}.
|
|
133
|
+
*/
|
|
134
|
+
sourceSchema: Schema.optional(DXN.Schema),
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* If this is a relation, the schema of the target object.
|
|
138
|
+
* Must be present if entity kind is {@link EntityKind.Relation}.
|
|
139
|
+
*/
|
|
140
|
+
targetSchema: Schema.optional(DXN.Schema),
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
export interface TypeAnnotation extends Schema.Schema.Type<typeof TypeAnnotation> {}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @returns {@link TypeAnnotation} from a schema.
|
|
148
|
+
* Schema must have been created with {@link TypedObject} or {@link TypedLink} or manually assigned an appropriate annotation.
|
|
149
|
+
*/
|
|
150
|
+
export const getTypeAnnotation = (schema: Schema.Schema.All): TypeAnnotation | undefined => {
|
|
151
|
+
assertArgument(schema != null && schema.ast != null, 'schema', 'invalid schema');
|
|
152
|
+
return Function.flow(
|
|
153
|
+
SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId),
|
|
154
|
+
Option.getOrElse(() => undefined),
|
|
155
|
+
)(schema.ast);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @returns {@link EntityKind} from a schema.
|
|
160
|
+
*/
|
|
161
|
+
export const getEntityKind = (schema: Schema.Schema.All): EntityKind | undefined => getTypeAnnotation(schema)?.kind;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @internal
|
|
165
|
+
* @returns Schema typename (without dxn: prefix or version number).
|
|
166
|
+
*/
|
|
167
|
+
export const getSchemaTypename = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.typename;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
* @returns Schema version in semver format.
|
|
172
|
+
*/
|
|
173
|
+
export const getSchemaVersion = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.version;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Gets the typename of the object without the version.
|
|
177
|
+
* Returns only the name portion, not the DXN.
|
|
178
|
+
* @example "example.org/type/Contact"
|
|
179
|
+
*
|
|
180
|
+
* @internal (use Obj.getTypename)
|
|
181
|
+
*/
|
|
182
|
+
export const getTypename = (obj: AnyProperties): string | undefined => {
|
|
183
|
+
const schema = getSchema(obj);
|
|
184
|
+
if (schema != null) {
|
|
185
|
+
// Try to extract typename from DXN.
|
|
186
|
+
return getSchemaTypename(schema);
|
|
187
|
+
} else {
|
|
188
|
+
const type = getTypeDXN(obj);
|
|
189
|
+
return type?.asTypeDXN()?.type;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @internal (use Type.setTypename)
|
|
195
|
+
*/
|
|
196
|
+
// TODO(dmaretskyi): Rename setTypeDXN.
|
|
197
|
+
export const setTypename = (obj: any, typename: DXN): void => {
|
|
198
|
+
invariant(typename instanceof DXN, 'Invalid type.');
|
|
199
|
+
Object.defineProperty(obj, TypeId, {
|
|
200
|
+
value: typename,
|
|
201
|
+
writable: false,
|
|
202
|
+
enumerable: false,
|
|
203
|
+
configurable: false,
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @returns Object type as {@link DXN}.
|
|
209
|
+
* @returns undefined if the object doesn't have a type.
|
|
210
|
+
* @example `dxn:example.com/type/Person:1.0.0`
|
|
211
|
+
*
|
|
212
|
+
* @internal (use Obj.getTypeDXN)
|
|
213
|
+
*/
|
|
214
|
+
// TODO(burdon): Narrow type.
|
|
215
|
+
export const getTypeDXN = (obj: AnyProperties): DXN | undefined => {
|
|
216
|
+
if (!obj) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const type = (obj as any)[TypeId];
|
|
221
|
+
if (!type) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
invariant(type instanceof DXN, 'Invalid object.');
|
|
226
|
+
return type;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Checks if the object is an instance of the schema.
|
|
231
|
+
* Only typename is compared, the schema version is ignored.
|
|
232
|
+
*
|
|
233
|
+
* The following cases are considered to mean that the object is an instance of the schema:
|
|
234
|
+
* - Object was created with this exact schema.
|
|
235
|
+
* - Object was created with a different version of this schema.
|
|
236
|
+
* - Object was created with a different schema (maybe dynamic) that has the same typename.
|
|
237
|
+
*/
|
|
238
|
+
// TODO(burdon): Can we use `Schema.is`?
|
|
239
|
+
export const isInstanceOf = <Schema extends Schema.Schema.AnyNoContext>(
|
|
240
|
+
schema: Schema,
|
|
241
|
+
object: any,
|
|
242
|
+
): object is Schema.Schema.Type<Schema> => {
|
|
243
|
+
if (object == null) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const schemaDXN = getSchemaDXN(schema);
|
|
248
|
+
if (!schemaDXN) {
|
|
249
|
+
throw new Error('Schema must have an object annotation.');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const type = getTypeDXN(object);
|
|
253
|
+
if (type && DXN.equals(type, schemaDXN)) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const typename = getTypename(object);
|
|
258
|
+
if (!typename) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const typeDXN = schemaDXN.asTypeDXN();
|
|
263
|
+
if (!typeDXN) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return typeDXN.type === typename;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
//
|
|
271
|
+
// PropertyMeta
|
|
272
|
+
//
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* PropertyMeta (metadata for dynamic schema properties).
|
|
276
|
+
* For user-defined annotations.
|
|
277
|
+
*/
|
|
278
|
+
export const PropertyMetaAnnotationId = Symbol.for('@dxos/schema/annotation/PropertyMeta');
|
|
279
|
+
|
|
280
|
+
export type PropertyMetaValue = Primitive | Record<string, Primitive> | Primitive[];
|
|
281
|
+
|
|
282
|
+
export type PropertyMetaAnnotation = {
|
|
283
|
+
[name: string]: PropertyMetaValue;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// TODO(wittjosiah): Align with other annotations.
|
|
287
|
+
// TODO(wittjosiah): Why is this separate from FormatAnnotation?
|
|
288
|
+
export const PropertyMeta = (name: string, value: PropertyMetaValue) => {
|
|
289
|
+
return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {
|
|
290
|
+
const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;
|
|
291
|
+
return self.annotations({
|
|
292
|
+
[PropertyMetaAnnotationId]: {
|
|
293
|
+
...existingMeta,
|
|
294
|
+
[name]: value,
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const getPropertyMetaAnnotation = <T>(prop: SchemaAST.PropertySignature, name: string) =>
|
|
301
|
+
Function.pipe(
|
|
302
|
+
SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(prop.type),
|
|
303
|
+
Option.map((meta) => meta[name] as T),
|
|
304
|
+
Option.getOrElse(() => undefined),
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
//
|
|
308
|
+
// Reference
|
|
309
|
+
//
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Schema reference.
|
|
313
|
+
*/
|
|
314
|
+
export const ReferenceAnnotationId = Symbol.for('@dxos/schema/annotation/Reference');
|
|
315
|
+
export type ReferenceAnnotationValue = TypeAnnotation;
|
|
316
|
+
export const ReferenceAnnotation = createAnnotationHelper<ReferenceAnnotationValue>(ReferenceAnnotationId);
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* SchemaMeta.
|
|
320
|
+
*/
|
|
321
|
+
export const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');
|
|
322
|
+
export type SchemaMeta = TypeMeta & { id: string };
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Identifies a schema as a schema for a hidden system type.
|
|
326
|
+
*/
|
|
327
|
+
export const SystemTypeAnnotationId = Symbol.for('@dxos/schema/annotation/SystemType');
|
|
328
|
+
export const SystemTypeAnnotation = createAnnotationHelper<boolean>(SystemTypeAnnotationId);
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Identifies label property or JSON path expression.
|
|
332
|
+
* Either a string or an array of strings representing field accessors each matched in priority order.
|
|
333
|
+
*/
|
|
334
|
+
export const LabelAnnotationId = Symbol.for('@dxos/schema/annotation/Label');
|
|
335
|
+
export const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationId);
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Returns the label for a given object based on {@link LabelAnnotationId}.
|
|
339
|
+
* Lower-level version that requires explicit schema parameter.
|
|
340
|
+
*/
|
|
341
|
+
// TODO(burdon): Convert to JsonPath?
|
|
342
|
+
export const getLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
343
|
+
schema: S,
|
|
344
|
+
object: Schema.Schema.Type<S>,
|
|
345
|
+
): string | undefined => {
|
|
346
|
+
const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
|
|
347
|
+
for (const accessor of annotation) {
|
|
348
|
+
assertArgument(
|
|
349
|
+
typeof accessor === 'string',
|
|
350
|
+
'accessor',
|
|
351
|
+
'Label annotation must be a string or an array of strings',
|
|
352
|
+
);
|
|
353
|
+
const value = getField(object, accessor as JsonPath);
|
|
354
|
+
switch (typeof value) {
|
|
355
|
+
case 'string':
|
|
356
|
+
case 'number':
|
|
357
|
+
case 'boolean':
|
|
358
|
+
case 'bigint':
|
|
359
|
+
case 'symbol':
|
|
360
|
+
return value.toString();
|
|
361
|
+
case 'undefined':
|
|
362
|
+
case 'object':
|
|
363
|
+
case 'function':
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return undefined;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Sets the label for a given object based on {@link LabelAnnotationId}.
|
|
373
|
+
* Lower-level version that requires explicit schema parameter.
|
|
374
|
+
*/
|
|
375
|
+
export const setLabelWithSchema = <S extends Schema.Schema.Any>(
|
|
376
|
+
schema: S,
|
|
377
|
+
object: Schema.Schema.Type<S>,
|
|
378
|
+
label: string,
|
|
379
|
+
) => {
|
|
380
|
+
const annotation = LabelAnnotation.get(schema).pipe(
|
|
381
|
+
Option.map((field) => field[0]),
|
|
382
|
+
Option.getOrElse(() => 'name'),
|
|
383
|
+
);
|
|
384
|
+
object[annotation] = label;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Identifies description property or JSON path expression.
|
|
389
|
+
* A string representing field accessor.
|
|
390
|
+
*/
|
|
391
|
+
export const DescriptionAnnotationId = Symbol.for('@dxos/schema/annotation/Description');
|
|
392
|
+
export const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionAnnotationId);
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Returns the description for a given object based on {@link DescriptionAnnotationId}.
|
|
396
|
+
* Lower-level version that requires explicit schema parameter.
|
|
397
|
+
*/
|
|
398
|
+
// TODO(burdon): Convert to JsonPath?
|
|
399
|
+
export const getDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
400
|
+
schema: S,
|
|
401
|
+
object: Schema.Schema.Type<S>,
|
|
402
|
+
): string | undefined => {
|
|
403
|
+
const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
|
|
404
|
+
assertArgument(typeof accessor === 'string', 'accessor', 'Description annotation must be a string');
|
|
405
|
+
const value = getField(object, accessor as JsonPath);
|
|
406
|
+
switch (typeof value) {
|
|
407
|
+
case 'string':
|
|
408
|
+
case 'number':
|
|
409
|
+
case 'boolean':
|
|
410
|
+
case 'bigint':
|
|
411
|
+
case 'symbol':
|
|
412
|
+
return value.toString();
|
|
413
|
+
case 'undefined':
|
|
414
|
+
case 'object':
|
|
415
|
+
case 'function':
|
|
416
|
+
default:
|
|
417
|
+
return undefined;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Sets the description for a given object based on {@link DescriptionAnnotationId}.
|
|
423
|
+
* Lower-level version that requires explicit schema parameter.
|
|
424
|
+
*/
|
|
425
|
+
export const setDescriptionWithSchema = <S extends Schema.Schema.Any>(
|
|
426
|
+
schema: S,
|
|
427
|
+
object: Schema.Schema.Type<S>,
|
|
428
|
+
description: string,
|
|
429
|
+
) => {
|
|
430
|
+
const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
|
|
431
|
+
object[accessor] = description;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Identifies if a property should be included in a form or not.
|
|
436
|
+
* By default, all properties are included in forms, so this is opt-out.
|
|
437
|
+
*/
|
|
438
|
+
// TODO(burdon): UI concern.
|
|
439
|
+
export const FormInputAnnotationId = Symbol.for('@dxos/schema/annotation/FormInput');
|
|
440
|
+
export const FormInputAnnotation = createAnnotationHelper<boolean>(FormInputAnnotationId);
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Default field to be used on referenced schema to lookup the value.
|
|
444
|
+
*/
|
|
445
|
+
export const FieldLookupAnnotationId = Symbol.for('@dxos/schema/annotation/FieldLookup');
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Generate test data.
|
|
449
|
+
*/
|
|
450
|
+
export const GeneratorAnnotationId = Symbol.for('@dxos/schema/annotation/Generator');
|
|
451
|
+
|
|
452
|
+
export type GeneratorAnnotationValue =
|
|
453
|
+
| string
|
|
454
|
+
| {
|
|
455
|
+
generator: string;
|
|
456
|
+
args?: any[];
|
|
457
|
+
probability?: number;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);
|