@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
package/src/Relation.ts
CHANGED
|
@@ -2,47 +2,133 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import
|
|
8
|
+
import type { ForeignKey } from '@dxos/echo-protocol';
|
|
9
|
+
import { createJsonPath, getValue as getValue$ } from '@dxos/effect';
|
|
9
10
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
|
-
import { DXN } from '@dxos/keys';
|
|
11
|
-
import { type Live, live } from '@dxos/live-object';
|
|
11
|
+
import { DXN, type ObjectId } from '@dxos/keys';
|
|
12
12
|
import { assumeType } from '@dxos/util';
|
|
13
13
|
|
|
14
|
+
import type * as Database from './Database';
|
|
15
|
+
import * as Entity from './Entity';
|
|
16
|
+
import {
|
|
17
|
+
type ObjectJSON as APIJSON,
|
|
18
|
+
ATTR_RELATION_SOURCE,
|
|
19
|
+
ATTR_RELATION_TARGET,
|
|
20
|
+
type AnyEntity,
|
|
21
|
+
type Comparator as ApiComparator,
|
|
22
|
+
type Meta as ApiMeta,
|
|
23
|
+
type ReadonlyMeta as ApiReadonlyMeta,
|
|
24
|
+
type EntityVersion as ApiVersion,
|
|
25
|
+
type ChangeCallback,
|
|
26
|
+
EntityKind,
|
|
27
|
+
type InternalObjectProps,
|
|
28
|
+
type KindId,
|
|
29
|
+
MetaId,
|
|
30
|
+
type Mutable,
|
|
31
|
+
type ObjectMeta,
|
|
32
|
+
RelationSourceDXNId,
|
|
33
|
+
RelationSourceId,
|
|
34
|
+
RelationTargetDXNId,
|
|
35
|
+
RelationTargetId,
|
|
36
|
+
SnapshotKindId,
|
|
37
|
+
VersionTypeId,
|
|
38
|
+
addTag as addTag$,
|
|
39
|
+
change as change$,
|
|
40
|
+
deleteKeys as deleteKeys$,
|
|
41
|
+
getDXN as getDXN$,
|
|
42
|
+
getDatabase as getDatabase$,
|
|
43
|
+
getDescription as getDescription$,
|
|
44
|
+
getKeys as getKeys$,
|
|
45
|
+
getLabel as getLabel$,
|
|
46
|
+
getMetaChecked as getMeta$,
|
|
47
|
+
getObjectDXN,
|
|
48
|
+
getSchema as getSchema$,
|
|
49
|
+
getSnapshot as getSnapshot$,
|
|
50
|
+
getTypeAnnotation,
|
|
51
|
+
getTypeDXN as getTypeDXN$,
|
|
52
|
+
getTypename as getTypename$,
|
|
53
|
+
isDeleted as isDeleted$,
|
|
54
|
+
isVersion,
|
|
55
|
+
makeObject,
|
|
56
|
+
removeTag as removeTag$,
|
|
57
|
+
setDescription as setDescription$,
|
|
58
|
+
setLabel as setLabel$,
|
|
59
|
+
setValue as setValue$,
|
|
60
|
+
sort as sort$,
|
|
61
|
+
sortByLabel as sortByLabel$,
|
|
62
|
+
sortByTypename as sortByTypename$,
|
|
63
|
+
subscribe as subscribe$,
|
|
64
|
+
objectToJSON as toJSON$,
|
|
65
|
+
version as version$,
|
|
66
|
+
} from './internal';
|
|
14
67
|
import type * as Obj from './Obj';
|
|
15
68
|
import type * as Type from './Type';
|
|
16
69
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Base type for all ECHO relations.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
interface BaseRelation<Source, Target>
|
|
75
|
+
extends AnyEntity,
|
|
76
|
+
Type.Relation.Endpoints<Source, Target>,
|
|
77
|
+
Entity.OfKind<EntityKind.Relation> {}
|
|
23
78
|
|
|
24
79
|
/**
|
|
25
|
-
* Relation
|
|
80
|
+
* Relation with no known properties beyond id, kind, source, and target.
|
|
81
|
+
* Use this when the relation's schema/properties are not known.
|
|
82
|
+
*
|
|
83
|
+
* NOTE: This is a TypeScript type only, not a schema.
|
|
84
|
+
* To validate that a value is an ECHO relation, use `Relation.isRelation`.
|
|
26
85
|
*/
|
|
27
|
-
export
|
|
86
|
+
export interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}
|
|
28
87
|
|
|
29
88
|
/**
|
|
30
|
-
*
|
|
89
|
+
* Relation type with specific source and target types.
|
|
31
90
|
*/
|
|
32
|
-
export
|
|
91
|
+
export type Relation<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &
|
|
92
|
+
Props;
|
|
33
93
|
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Base type for snapshot relations (has SnapshotKindId instead of KindId).
|
|
96
|
+
*/
|
|
97
|
+
interface BaseRelationSnapshot<Source, Target> extends AnyEntity, Type.Relation.Endpoints<Source, Target> {
|
|
98
|
+
readonly [SnapshotKindId]: EntityKind.Relation;
|
|
99
|
+
readonly id: ObjectId;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Immutable snapshot of an ECHO relation.
|
|
104
|
+
* Branded with SnapshotKindId (not KindId).
|
|
105
|
+
* Property values are frozen at the time the snapshot was created.
|
|
106
|
+
* Returned by getSnapshot() and hooks.
|
|
107
|
+
*/
|
|
108
|
+
export type Snapshot<T extends Unknown = Unknown> = Omit<T, KindId> & BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;
|
|
109
|
+
|
|
110
|
+
export const Source: unique symbol = RelationSourceId as any;
|
|
36
111
|
export type Source = typeof Source;
|
|
37
|
-
|
|
112
|
+
|
|
113
|
+
export const Target: unique symbol = RelationTargetId as any;
|
|
38
114
|
export type Target = typeof Target;
|
|
39
115
|
|
|
40
|
-
|
|
41
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Internal props type for relation instance creation.
|
|
118
|
+
*/
|
|
119
|
+
type RelationMakeProps<T extends Unknown> = {
|
|
120
|
+
id?: ObjectId;
|
|
121
|
+
[MetaId]?: ObjectMeta;
|
|
42
122
|
[Source]: T[Source];
|
|
43
123
|
[Target]: T[Target];
|
|
44
124
|
} & Type.Properties<T>;
|
|
45
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Props type for relation creation with a given schema.
|
|
128
|
+
* Takes a schema type (created with Type.Relation) and extracts the props type.
|
|
129
|
+
*/
|
|
130
|
+
export type MakeProps<S extends Type.Relation.Any> = RelationMakeProps<Schema.Schema.Type<S>>;
|
|
131
|
+
|
|
46
132
|
/**
|
|
47
133
|
* Creates new relation.
|
|
48
134
|
* @param schema - Relation schema.
|
|
@@ -54,83 +140,360 @@ type MakeProps<T extends Any> = {
|
|
|
54
140
|
// TODO(dmaretskyi): Move meta into props.
|
|
55
141
|
export const make = <S extends Type.Relation.Any>(
|
|
56
142
|
schema: S,
|
|
57
|
-
props: NoInfer<
|
|
58
|
-
meta?:
|
|
59
|
-
):
|
|
60
|
-
assertArgument(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (props[EchoSchema.MetaId] != null) {
|
|
66
|
-
meta = props[EchoSchema.MetaId] as any;
|
|
67
|
-
delete props[EchoSchema.MetaId];
|
|
143
|
+
props: NoInfer<RelationMakeProps<Schema.Schema.Type<S>>>,
|
|
144
|
+
meta?: ObjectMeta,
|
|
145
|
+
): Schema.Schema.Type<S> & Entity.OfKind<typeof Entity.Kind.Relation> => {
|
|
146
|
+
assertArgument(getTypeAnnotation(schema)?.kind === EntityKind.Relation, 'schema', 'Expected a relation schema');
|
|
147
|
+
|
|
148
|
+
if (props[MetaId] != null) {
|
|
149
|
+
meta = props[MetaId] as any;
|
|
150
|
+
delete props[MetaId];
|
|
68
151
|
}
|
|
69
152
|
|
|
70
|
-
const sourceDXN =
|
|
71
|
-
const targetDXN =
|
|
72
|
-
(props as any)[EchoSchema.RelationSourceDXNId] = sourceDXN;
|
|
73
|
-
(props as any)[EchoSchema.RelationTargetDXNId] = targetDXN;
|
|
153
|
+
const sourceDXN = getObjectDXN(props[Source]) ?? raise(new Error('Unresolved relation source'));
|
|
154
|
+
const targetDXN = getObjectDXN(props[Target]) ?? raise(new Error('Unresolved relation target'));
|
|
74
155
|
|
|
75
|
-
|
|
156
|
+
(props as any)[RelationSourceDXNId] = sourceDXN;
|
|
157
|
+
(props as any)[RelationTargetDXNId] = targetDXN;
|
|
158
|
+
|
|
159
|
+
return makeObject<Schema.Schema.Type<S>>(schema, props as any, meta);
|
|
76
160
|
};
|
|
77
161
|
|
|
78
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Type guard for relations.
|
|
164
|
+
* Returns true for both reactive relations and relation snapshots.
|
|
165
|
+
*/
|
|
166
|
+
export const isRelation = (value: unknown): value is Unknown => {
|
|
79
167
|
if (typeof value !== 'object' || value === null) {
|
|
80
168
|
return false;
|
|
81
169
|
}
|
|
82
|
-
if (
|
|
170
|
+
if (ATTR_RELATION_SOURCE in value || ATTR_RELATION_TARGET in value) {
|
|
83
171
|
return true;
|
|
84
172
|
}
|
|
85
173
|
|
|
86
|
-
|
|
87
|
-
|
|
174
|
+
// Check for reactive relation (KindId) or snapshot (SnapshotKindId).
|
|
175
|
+
const kind = (value as any)[Entity.KindId] ?? (value as any)[SnapshotKindId];
|
|
176
|
+
return kind === EntityKind.Relation;
|
|
88
177
|
};
|
|
89
178
|
|
|
90
179
|
/**
|
|
91
180
|
* @returns Relation source DXN.
|
|
181
|
+
* Accepts both reactive relations and snapshots.
|
|
92
182
|
* @throws If the object is not a relation.
|
|
93
183
|
*/
|
|
94
|
-
export const getSourceDXN = (value:
|
|
184
|
+
export const getSourceDXN = (value: Unknown | Snapshot): DXN => {
|
|
95
185
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
96
|
-
assumeType<
|
|
97
|
-
const dxn = (value as
|
|
186
|
+
assumeType<InternalObjectProps>(value);
|
|
187
|
+
const dxn = (value as InternalObjectProps)[RelationSourceDXNId];
|
|
98
188
|
invariant(dxn instanceof DXN);
|
|
99
189
|
return dxn;
|
|
100
190
|
};
|
|
101
191
|
|
|
102
192
|
/**
|
|
103
193
|
* @returns Relation target DXN.
|
|
194
|
+
* Accepts both reactive relations and snapshots.
|
|
104
195
|
* @throws If the object is not a relation.
|
|
105
196
|
*/
|
|
106
|
-
export const getTargetDXN = (value:
|
|
197
|
+
export const getTargetDXN = (value: Unknown | Snapshot): DXN => {
|
|
107
198
|
assertArgument(isRelation(value), 'Expected a relation');
|
|
108
|
-
assumeType<
|
|
109
|
-
const dxn = (value as
|
|
199
|
+
assumeType<InternalObjectProps>(value);
|
|
200
|
+
const dxn = (value as InternalObjectProps)[RelationTargetDXNId];
|
|
110
201
|
invariant(dxn instanceof DXN);
|
|
111
202
|
return dxn;
|
|
112
203
|
};
|
|
113
204
|
|
|
114
205
|
/**
|
|
115
206
|
* @returns Relation source.
|
|
207
|
+
* Accepts both reactive relations and snapshots.
|
|
116
208
|
* @throws If the object is not a relation.
|
|
117
209
|
*/
|
|
118
|
-
export const getSource = <T extends
|
|
210
|
+
export const getSource = <T extends Unknown | Snapshot>(relation: T): Type.Relation.Source<T> => {
|
|
119
211
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
120
|
-
assumeType<
|
|
121
|
-
const obj = (relation as
|
|
212
|
+
assumeType<InternalObjectProps>(relation);
|
|
213
|
+
const obj = (relation as InternalObjectProps)[RelationSourceId];
|
|
122
214
|
invariant(obj !== undefined, `Invalid source: ${relation.id}`);
|
|
123
215
|
return obj as Type.Relation.Source<T>;
|
|
124
216
|
};
|
|
125
217
|
|
|
126
218
|
/**
|
|
127
219
|
* @returns Relation target.
|
|
220
|
+
* Accepts both reactive relations and snapshots.
|
|
128
221
|
* @throws If the object is not a relation.
|
|
129
222
|
*/
|
|
130
|
-
export const getTarget = <T extends
|
|
223
|
+
export const getTarget = <T extends Unknown | Snapshot>(relation: T): Type.Relation.Target<T> => {
|
|
131
224
|
assertArgument(isRelation(relation), 'Expected a relation');
|
|
132
|
-
assumeType<
|
|
133
|
-
const obj = (relation as
|
|
225
|
+
assumeType<InternalObjectProps>(relation);
|
|
226
|
+
const obj = (relation as InternalObjectProps)[RelationTargetId];
|
|
134
227
|
invariant(obj !== undefined, `Invalid target: ${relation.id}`);
|
|
135
228
|
return obj as Type.Relation.Target<T>;
|
|
136
229
|
};
|
|
230
|
+
|
|
231
|
+
//
|
|
232
|
+
// Change
|
|
233
|
+
//
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Makes all properties mutable recursively.
|
|
237
|
+
* Used to provide a mutable view of a relation within `Relation.change`.
|
|
238
|
+
*/
|
|
239
|
+
export type { Mutable };
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Perform mutations on an echo relation within a controlled context.
|
|
243
|
+
*
|
|
244
|
+
* All mutations within the callback are batched and trigger a single notification
|
|
245
|
+
* when the callback completes. Direct mutations outside of `Relation.change` will throw
|
|
246
|
+
* an error for echo relations.
|
|
247
|
+
*
|
|
248
|
+
* @param relation - The echo relation to mutate. Use `Obj.change` for objects.
|
|
249
|
+
* @param callback - The callback that performs mutations on the relation.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const worksFor = Relation.make(EmployedBy, {
|
|
254
|
+
* [Relation.Source]: person,
|
|
255
|
+
* [Relation.Target]: company,
|
|
256
|
+
* role: 'Engineer',
|
|
257
|
+
* });
|
|
258
|
+
*
|
|
259
|
+
* // Mutate within Relation.change
|
|
260
|
+
* Relation.change(worksFor, (r) => {
|
|
261
|
+
* r.role = 'Senior Engineer';
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* Note: Only accepts relations. Use `Obj.change` for objects.
|
|
266
|
+
*/
|
|
267
|
+
export const change = <T extends Unknown>(relation: T, callback: ChangeCallback<T>): void => {
|
|
268
|
+
change$(relation, callback);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
//
|
|
272
|
+
// Snapshot
|
|
273
|
+
//
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Returns an immutable snapshot of a relation.
|
|
277
|
+
* The snapshot is branded with SnapshotKindId instead of KindId,
|
|
278
|
+
* making it distinguishable from the reactive relation at the type level.
|
|
279
|
+
*/
|
|
280
|
+
export const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = getSnapshot$ as any;
|
|
281
|
+
|
|
282
|
+
//
|
|
283
|
+
// Subscribe
|
|
284
|
+
//
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Subscribe to relation updates.
|
|
288
|
+
* The callback is called synchronously when the relation is modified.
|
|
289
|
+
* Only accepts reactive relations (not snapshots).
|
|
290
|
+
* @returns Unsubscribe function.
|
|
291
|
+
*/
|
|
292
|
+
export const subscribe = (rel: Unknown, callback: () => void): (() => void) => {
|
|
293
|
+
return subscribe$(rel, callback);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
//
|
|
297
|
+
// Property Access
|
|
298
|
+
//
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get a deeply nested property from a relation.
|
|
302
|
+
* Accepts both reactive relations and snapshots.
|
|
303
|
+
*/
|
|
304
|
+
export const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {
|
|
305
|
+
return getValue$(rel, createJsonPath(path));
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Set a deeply nested property on a relation.
|
|
310
|
+
* Must be called within a `Relation.change` callback.
|
|
311
|
+
*
|
|
312
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
313
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
314
|
+
*/
|
|
315
|
+
export const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =
|
|
316
|
+
setValue$ as any;
|
|
317
|
+
|
|
318
|
+
//
|
|
319
|
+
// Type
|
|
320
|
+
//
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Get the DXN of the relation.
|
|
324
|
+
* Accepts both reactive relations and snapshots.
|
|
325
|
+
*/
|
|
326
|
+
export const getDXN = (entity: Unknown | Snapshot): DXN => getDXN$(entity);
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @returns The DXN of the relation's type.
|
|
330
|
+
*/
|
|
331
|
+
export const getTypeDXN = getTypeDXN$;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get the schema of the relation.
|
|
335
|
+
* Returns the branded ECHO schema used to create the relation.
|
|
336
|
+
*/
|
|
337
|
+
export const getSchema: (rel: unknown | undefined) => Type.Entity.Any | undefined = getSchema$ as any;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @returns The typename of the relation's type.
|
|
341
|
+
* Accepts both reactive relations and snapshots.
|
|
342
|
+
*/
|
|
343
|
+
export const getTypename = (entity: Unknown | Snapshot): string | undefined => getTypename$(entity);
|
|
344
|
+
|
|
345
|
+
//
|
|
346
|
+
// Database
|
|
347
|
+
//
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Get the database the relation belongs to.
|
|
351
|
+
* Accepts both reactive relations and snapshots.
|
|
352
|
+
*/
|
|
353
|
+
export const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => getDatabase$(entity);
|
|
354
|
+
|
|
355
|
+
//
|
|
356
|
+
// Meta
|
|
357
|
+
//
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Deeply read-only version of ObjectMeta.
|
|
361
|
+
*/
|
|
362
|
+
export type ReadonlyMeta = ApiReadonlyMeta;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Mutable meta type returned by `Relation.getMeta` inside a `Relation.change` callback.
|
|
366
|
+
*/
|
|
367
|
+
export type Meta = ApiMeta;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Get the metadata for a relation.
|
|
371
|
+
* Returns mutable meta when passed a mutable relation (inside `Relation.change` callback).
|
|
372
|
+
* Returns read-only meta when passed a regular relation or snapshot.
|
|
373
|
+
*/
|
|
374
|
+
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
375
|
+
export function getMeta(entity: Mutable<Unknown>): ObjectMeta;
|
|
376
|
+
export function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;
|
|
377
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): ObjectMeta | ReadonlyMeta {
|
|
378
|
+
return getMeta$(entity);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @returns Foreign keys for the relation from the specified source.
|
|
383
|
+
* Accepts both reactive relations and snapshots.
|
|
384
|
+
*/
|
|
385
|
+
export const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => getKeys$(entity, source);
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Delete all keys from the relation for the specified source.
|
|
389
|
+
* Must be called within a `Relation.change` callback.
|
|
390
|
+
*
|
|
391
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
392
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
393
|
+
*/
|
|
394
|
+
export const deleteKeys = (entity: Mutable<Unknown>, source: string): void => deleteKeys$(entity, source);
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Add a tag to the relation.
|
|
398
|
+
* Must be called within a `Relation.change` callback.
|
|
399
|
+
*
|
|
400
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
401
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
402
|
+
*/
|
|
403
|
+
export const addTag = (entity: Mutable<Unknown>, tag: string): void => addTag$(entity, tag);
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Remove a tag from the relation.
|
|
407
|
+
* Must be called within a `Relation.change` callback.
|
|
408
|
+
*
|
|
409
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
410
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
411
|
+
*/
|
|
412
|
+
export const removeTag = (entity: Mutable<Unknown>, tag: string): void => removeTag$(entity, tag);
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Check if the relation is deleted.
|
|
416
|
+
* Accepts both reactive relations and snapshots.
|
|
417
|
+
*/
|
|
418
|
+
export const isDeleted = (entity: Unknown | Snapshot): boolean => isDeleted$(entity);
|
|
419
|
+
|
|
420
|
+
//
|
|
421
|
+
// Annotations
|
|
422
|
+
//
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Get the label of the relation.
|
|
426
|
+
* Accepts both reactive relations and snapshots.
|
|
427
|
+
*/
|
|
428
|
+
export const getLabel = (entity: Unknown | Snapshot): string | undefined => getLabel$(entity);
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Set the label of the relation.
|
|
432
|
+
* Must be called within a `Relation.change` callback.
|
|
433
|
+
*
|
|
434
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
435
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
436
|
+
*/
|
|
437
|
+
export const setLabel = (entity: Mutable<Unknown>, label: string): void => setLabel$(entity, label);
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Get the description of the relation.
|
|
441
|
+
* Accepts both reactive relations and snapshots.
|
|
442
|
+
*/
|
|
443
|
+
export const getDescription = (entity: Unknown | Snapshot): string | undefined => getDescription$(entity);
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Set the description of the relation.
|
|
447
|
+
* Must be called within a `Relation.change` callback.
|
|
448
|
+
*
|
|
449
|
+
* NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`
|
|
450
|
+
* parameters, so there is no compile-time error. Enforcement is runtime-only.
|
|
451
|
+
*/
|
|
452
|
+
export const setDescription = (entity: Mutable<Unknown>, description: string): void =>
|
|
453
|
+
setDescription$(entity, description);
|
|
454
|
+
|
|
455
|
+
//
|
|
456
|
+
// JSON
|
|
457
|
+
//
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* JSON representation of a relation.
|
|
461
|
+
*/
|
|
462
|
+
export type JSON = APIJSON;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Converts relation to its JSON representation.
|
|
466
|
+
* Accepts both reactive relations and snapshots.
|
|
467
|
+
*/
|
|
468
|
+
export const toJSON = (entity: Unknown | Snapshot): JSON => toJSON$(entity);
|
|
469
|
+
|
|
470
|
+
//
|
|
471
|
+
// Sorting
|
|
472
|
+
//
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Comparator function type for sorting relations.
|
|
476
|
+
* Accepts both reactive relations and snapshots.
|
|
477
|
+
*/
|
|
478
|
+
export type Comparator = ApiComparator<Unknown | Snapshot>;
|
|
479
|
+
|
|
480
|
+
export const sortByLabel: Comparator = sortByLabel$ as Comparator;
|
|
481
|
+
export const sortByTypename: Comparator = sortByTypename$ as Comparator;
|
|
482
|
+
export const sort = (...comparators: Comparator[]): Comparator => sort$(...comparators) as Comparator;
|
|
483
|
+
|
|
484
|
+
//
|
|
485
|
+
// Version
|
|
486
|
+
//
|
|
487
|
+
|
|
488
|
+
export { VersionTypeId, isVersion };
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Represent relation version.
|
|
492
|
+
*/
|
|
493
|
+
export type Version = ApiVersion;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Returns the version of the relation.
|
|
497
|
+
* Accepts both reactive relations and snapshots.
|
|
498
|
+
*/
|
|
499
|
+
export const version = (entity: Unknown | Snapshot): Version => version$(entity);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Types from 'effect/Types';
|
|
6
|
+
|
|
7
|
+
import type * as JsonSchema from './JsonSchema';
|
|
8
|
+
import type * as Key from './Key';
|
|
9
|
+
import type * as QueryResult from './QueryResult';
|
|
10
|
+
import type * as Type from './Type';
|
|
11
|
+
|
|
12
|
+
// TODO(wittjosiah): Replace w/ Query.Query.
|
|
13
|
+
export type Query = {
|
|
14
|
+
/**
|
|
15
|
+
* Filter by schema ID.
|
|
16
|
+
* Schema id is a DXN with `echo` or `type` kind.
|
|
17
|
+
*/
|
|
18
|
+
id?: string | string[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Id of the backing ECHO object.
|
|
22
|
+
*/
|
|
23
|
+
backingObjectId?: Key.ObjectId | Key.ObjectId[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* One or more typenames to filter by.
|
|
27
|
+
*/
|
|
28
|
+
typename?: string | string[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* [Semver Range](https://docs.npmjs.com/cli/v6/using-npm/semver#ranges) for the schema version.
|
|
32
|
+
*/
|
|
33
|
+
version?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Where to look for the schema.
|
|
37
|
+
*
|
|
38
|
+
* Database schema are stored in the database of the current space.
|
|
39
|
+
* Runtime schema are registered in the runtime.
|
|
40
|
+
*
|
|
41
|
+
* @default ['database']
|
|
42
|
+
*/
|
|
43
|
+
location?: ('database' | 'runtime')[];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Include system schemas.
|
|
47
|
+
* @default false
|
|
48
|
+
*
|
|
49
|
+
* The system schema include but are not limited to:
|
|
50
|
+
* - dxos.org/type/Schema
|
|
51
|
+
*/
|
|
52
|
+
includeSystem?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Input for schema registration.
|
|
57
|
+
* The typename, version and schema mutability metadata is read from the schema annotations.
|
|
58
|
+
*
|
|
59
|
+
* Accepts:
|
|
60
|
+
* - Branded ECHO schemas created with Type.Obj() or Type.Relation()
|
|
61
|
+
* - JSON schema with typename and version
|
|
62
|
+
*/
|
|
63
|
+
export type RegisterSchemaInput =
|
|
64
|
+
| Type.Entity.Any
|
|
65
|
+
| {
|
|
66
|
+
typename: string;
|
|
67
|
+
version: string;
|
|
68
|
+
jsonSchema: JsonSchema.JsonSchema;
|
|
69
|
+
/**
|
|
70
|
+
* Display name of the schema.
|
|
71
|
+
*/
|
|
72
|
+
name?: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type ExtractQueryResult<Query> = Query extends { location: ('database' | 'runtime')[] }
|
|
76
|
+
? Type.Entity.Any
|
|
77
|
+
: Type.RuntimeType;
|
|
78
|
+
|
|
79
|
+
export interface SchemaRegistry {
|
|
80
|
+
/**
|
|
81
|
+
* Checks if the provided schema is registered.
|
|
82
|
+
*/
|
|
83
|
+
// TODO(burdon): Type?
|
|
84
|
+
hasSchema(schema: Type.Entity.Any): boolean;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Registers the provided schema.
|
|
88
|
+
*
|
|
89
|
+
* @returns Mutable runtime instances of schemas that were registered.
|
|
90
|
+
*
|
|
91
|
+
* The behavior of this method depends on the state of the database.
|
|
92
|
+
* The general principle is that the schema will be upserted into the space.
|
|
93
|
+
* If an equivalent schema with the same name and version already exists, the method does nothing.
|
|
94
|
+
* If a different schema with the same name and version exists, the method throws an error.
|
|
95
|
+
* If no schema with the same name and version exists, a new schema will be inserted based on semantic versioning rules.
|
|
96
|
+
*/
|
|
97
|
+
register(input: RegisterSchemaInput[]): Promise<Type.RuntimeType[]>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
query<Q extends Types.NoExcessProperties<Query, Q>>(
|
|
103
|
+
query?: Q & Query,
|
|
104
|
+
): QueryResult.QueryResult<ExtractQueryResult<Q>>;
|
|
105
|
+
}
|
package/src/Tag.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { LabelAnnotation, SystemTypeAnnotation } from './internal';
|
|
8
|
+
import * as Obj from './Obj';
|
|
9
|
+
import * as Type from './Type';
|
|
10
|
+
|
|
11
|
+
export const Tag = Schema.Struct({
|
|
12
|
+
label: Schema.String,
|
|
13
|
+
hue: Schema.optional(Schema.String), // TODO(burdon): Color name?
|
|
14
|
+
}).pipe(
|
|
15
|
+
Type.object({
|
|
16
|
+
typename: 'dxos.org/type/Tag',
|
|
17
|
+
version: '0.1.0',
|
|
18
|
+
}),
|
|
19
|
+
LabelAnnotation.set(['label']),
|
|
20
|
+
SystemTypeAnnotation.set(true),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type Tag = Schema.Schema.Type<typeof Tag>;
|
|
24
|
+
|
|
25
|
+
export const make = (props: Obj.MakeProps<typeof Tag>) => Obj.make(Tag, props);
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Rename Map.
|
|
28
|
+
export type Map = Record<string, Tag>;
|
|
29
|
+
|
|
30
|
+
export const sortTags = ({ label: a }: Tag, { label: b }: Tag) => a.localeCompare(b);
|
|
31
|
+
|
|
32
|
+
export const createTagList = (tags: Map): Tag[] =>
|
|
33
|
+
Object.entries(tags)
|
|
34
|
+
.map(([id, tag]) => ({ ...tag, id }))
|
|
35
|
+
.sort(sortTags);
|
|
36
|
+
|
|
37
|
+
export const findTagByLabel = (tags: Map | undefined, name: string): Tag | undefined => {
|
|
38
|
+
const entry = Object.entries(tags ?? {}).find(([_, tag]) => tag.label.toLowerCase() === name.toLowerCase());
|
|
39
|
+
return entry ? { ...entry[1], id: entry[0] } : undefined;
|
|
40
|
+
};
|