@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,43 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
5
|
+
|
|
6
|
+
// src/Order.ts
|
|
7
|
+
var Order_exports = {};
|
|
8
|
+
__export(Order_exports, {
|
|
9
|
+
natural: () => natural,
|
|
10
|
+
property: () => property,
|
|
11
|
+
rank: () => rank
|
|
12
|
+
});
|
|
13
|
+
var OrderClass = class _OrderClass {
|
|
14
|
+
ast;
|
|
15
|
+
static variance = {};
|
|
16
|
+
static is(value) {
|
|
17
|
+
return typeof value === "object" && value !== null && "~Order" in value;
|
|
18
|
+
}
|
|
19
|
+
constructor(ast) {
|
|
20
|
+
this.ast = ast;
|
|
21
|
+
}
|
|
22
|
+
"~Order" = _OrderClass.variance;
|
|
23
|
+
};
|
|
24
|
+
var natural = new OrderClass({
|
|
25
|
+
kind: "natural"
|
|
26
|
+
});
|
|
27
|
+
var property = (property2, direction) => new OrderClass({
|
|
28
|
+
kind: "property",
|
|
29
|
+
property: property2,
|
|
30
|
+
direction
|
|
31
|
+
});
|
|
32
|
+
var rank = (direction = "desc") => new OrderClass({
|
|
33
|
+
kind: "rank",
|
|
34
|
+
direction
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
natural,
|
|
39
|
+
property,
|
|
40
|
+
rank,
|
|
41
|
+
Order_exports
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=chunk-JMKVF2YQ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Order.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type QueryAST } from '@dxos/echo-protocol';\n\nexport interface Order<T> {\n // TODO(dmaretskyi): See new effect-schema approach to variance.\n '~Order': { value: T };\n\n ast: QueryAST.Order;\n}\n\nexport type Any = Order<any>;\n\nclass OrderClass implements Order<any> {\n private static variance: Order<any>['~Order'] = {} as Order<any>['~Order'];\n\n static is(value: unknown): value is Order<any> {\n return typeof value === 'object' && value !== null && '~Order' in value;\n }\n\n constructor(public readonly ast: QueryAST.Order) {}\n\n '~Order' = OrderClass.variance;\n}\n\nexport const natural: Order<any> = new OrderClass({ kind: 'natural' });\nexport const property = <T>(property: keyof T & string, direction: QueryAST.OrderDirection): Order<T> =>\n new OrderClass({\n kind: 'property',\n property,\n direction,\n });\n\n/**\n * Order by relevance rank (for FTS/vector search results).\n * Higher rank = better match. Default direction is 'desc' (best matches first).\n */\nexport const rank = <T>(direction: QueryAST.OrderDirection = 'desc'): Order<T> =>\n new OrderClass({\n kind: 'rank',\n direction,\n });\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA;;;;;;AAeA,IAAMA,aAAN,MAAMA,YAAAA;;EACJ,OAAeC,WAAiC,CAAC;EAEjD,OAAOC,GAAGC,OAAqC;AAC7C,WAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,YAAYA;EACpE;EAEA,YAA4BC,KAAqB;SAArBA,MAAAA;EAAsB;EAElD,WAAWJ,YAAWC;AACxB;AAEO,IAAMI,UAAsB,IAAIL,WAAW;EAAEM,MAAM;AAAU,CAAA;AAC7D,IAAMC,WAAW,CAAIA,WAA4BC,cACtD,IAAIR,WAAW;EACbM,MAAM;EACNC,UAAAA;EACAC;AACF,CAAA;AAMK,IAAMC,OAAO,CAAID,YAAqC,WAC3D,IAAIR,WAAW;EACbM,MAAM;EACNE;AACF,CAAA;",
|
|
6
|
+
"names": ["OrderClass", "variance", "is", "value", "ast", "natural", "kind", "property", "direction", "rank"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
EchoObjectSchema,
|
|
4
|
+
EchoRelationSchema,
|
|
5
|
+
EchoSchema,
|
|
6
|
+
PersistentSchema,
|
|
7
|
+
Ref,
|
|
8
|
+
isMutable,
|
|
9
|
+
toEffectSchema,
|
|
10
|
+
toJsonSchema
|
|
11
|
+
} from "./chunk-BJPE6CIC.mjs";
|
|
12
|
+
import {
|
|
13
|
+
getSchemaDXN,
|
|
14
|
+
getSchemaTypename,
|
|
15
|
+
getSchemaVersion,
|
|
16
|
+
getTypeAnnotation
|
|
17
|
+
} from "./chunk-RK4Z4JUZ.mjs";
|
|
18
|
+
import {
|
|
19
|
+
ANY_OBJECT_TYPENAME,
|
|
20
|
+
ANY_OBJECT_VERSION,
|
|
21
|
+
EntityKind,
|
|
22
|
+
SchemaKindId
|
|
23
|
+
} from "./chunk-YKTSSMDS.mjs";
|
|
24
|
+
import {
|
|
25
|
+
__export
|
|
26
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
27
|
+
|
|
28
|
+
// src/Type.ts
|
|
29
|
+
var Type_exports = {};
|
|
30
|
+
__export(Type_exports, {
|
|
31
|
+
Entity: () => Entity,
|
|
32
|
+
Obj: () => Obj,
|
|
33
|
+
PersistentType: () => PersistentType,
|
|
34
|
+
Ref: () => Ref2,
|
|
35
|
+
Relation: () => Relation,
|
|
36
|
+
RuntimeType: () => EchoSchema,
|
|
37
|
+
getDXN: () => getDXN,
|
|
38
|
+
getMeta: () => getMeta,
|
|
39
|
+
getTypename: () => getTypename,
|
|
40
|
+
getVersion: () => getVersion,
|
|
41
|
+
isMutable: () => isMutable2,
|
|
42
|
+
isObjectSchema: () => isObjectSchema,
|
|
43
|
+
isRelationSchema: () => isRelationSchema,
|
|
44
|
+
object: () => object,
|
|
45
|
+
relation: () => relation,
|
|
46
|
+
toEffectSchema: () => toEffectSchema,
|
|
47
|
+
toJsonSchema: () => toJsonSchema
|
|
48
|
+
});
|
|
49
|
+
import * as Schema from "effect/Schema";
|
|
50
|
+
import { invariant } from "@dxos/invariant";
|
|
51
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
52
|
+
var ObjSchema = Schema.Struct({
|
|
53
|
+
id: Schema.String
|
|
54
|
+
}).pipe(Schema.extend(Schema.Record({
|
|
55
|
+
key: Schema.String,
|
|
56
|
+
value: Schema.Unknown
|
|
57
|
+
})), EchoObjectSchema({
|
|
58
|
+
typename: ANY_OBJECT_TYPENAME,
|
|
59
|
+
version: ANY_OBJECT_VERSION
|
|
60
|
+
}));
|
|
61
|
+
var Obj = Object.assign(ObjSchema, {
|
|
62
|
+
[SchemaKindId]: ObjSchema[SchemaKindId]
|
|
63
|
+
});
|
|
64
|
+
var object = EchoObjectSchema;
|
|
65
|
+
var PersistentType = PersistentSchema;
|
|
66
|
+
var RelationSchema = Schema.Struct({
|
|
67
|
+
id: Schema.String
|
|
68
|
+
}).pipe(Schema.extend(Schema.Record({
|
|
69
|
+
key: Schema.String,
|
|
70
|
+
value: Schema.Unknown
|
|
71
|
+
})), EchoRelationSchema({
|
|
72
|
+
typename: "dxos.org/schema/AnyRelation",
|
|
73
|
+
version: "0.0.0",
|
|
74
|
+
source: ObjSchema,
|
|
75
|
+
target: ObjSchema
|
|
76
|
+
}));
|
|
77
|
+
var Relation = Object.assign(RelationSchema, {
|
|
78
|
+
[SchemaKindId]: RelationSchema[SchemaKindId]
|
|
79
|
+
});
|
|
80
|
+
var relation = EchoRelationSchema;
|
|
81
|
+
(function(Entity2) {
|
|
82
|
+
Entity2.Any = Schema.Union(Obj, Relation);
|
|
83
|
+
})(Entity || (Entity = {}));
|
|
84
|
+
var isObjectSchema = (schema) => {
|
|
85
|
+
return schema[SchemaKindId] === EntityKind.Object;
|
|
86
|
+
};
|
|
87
|
+
var isRelationSchema = (schema) => {
|
|
88
|
+
return schema[SchemaKindId] === EntityKind.Relation;
|
|
89
|
+
};
|
|
90
|
+
var Ref2 = Ref;
|
|
91
|
+
var getDXN = (schema) => {
|
|
92
|
+
return getSchemaDXN(schema);
|
|
93
|
+
};
|
|
94
|
+
var getTypename = (schema) => {
|
|
95
|
+
const typename = getSchemaTypename(schema);
|
|
96
|
+
invariant(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
97
|
+
F: __dxlog_file,
|
|
98
|
+
L: 463,
|
|
99
|
+
S: void 0,
|
|
100
|
+
A: [
|
|
101
|
+
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
102
|
+
"'Invalid typename'"
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
return typename;
|
|
106
|
+
};
|
|
107
|
+
var getVersion = (schema) => {
|
|
108
|
+
const version = getSchemaVersion(schema);
|
|
109
|
+
invariant(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
110
|
+
F: __dxlog_file,
|
|
111
|
+
L: 473,
|
|
112
|
+
S: void 0,
|
|
113
|
+
A: [
|
|
114
|
+
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
115
|
+
"'Invalid version'"
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
return version;
|
|
119
|
+
};
|
|
120
|
+
var isMutable2 = isMutable;
|
|
121
|
+
var getMeta = (schema) => {
|
|
122
|
+
return getTypeAnnotation(schema);
|
|
123
|
+
};
|
|
124
|
+
var Entity;
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
Obj,
|
|
128
|
+
object,
|
|
129
|
+
PersistentType,
|
|
130
|
+
Relation,
|
|
131
|
+
relation,
|
|
132
|
+
isObjectSchema,
|
|
133
|
+
isRelationSchema,
|
|
134
|
+
Ref2 as Ref,
|
|
135
|
+
getDXN,
|
|
136
|
+
getTypename,
|
|
137
|
+
getVersion,
|
|
138
|
+
isMutable2 as isMutable,
|
|
139
|
+
getMeta,
|
|
140
|
+
Entity,
|
|
141
|
+
Type_exports
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=chunk-KQQGVHFN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Type.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type EncodedReference } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { type DXN, type ObjectId } from '@dxos/keys';\nimport { type ToMutable } from '@dxos/util';\n\nimport type * as Entity$ from './Entity';\nimport {\n ANY_OBJECT_TYPENAME,\n ANY_OBJECT_VERSION,\n type ATTR_RELATION_SOURCE,\n type ATTR_RELATION_TARGET,\n type AnyEntity,\n type AnyProperties,\n EchoObjectSchema,\n EchoRelationSchema,\n type EchoRelationSchemaOptions,\n EchoSchema,\n EntityKind,\n PersistentSchema,\n Ref as Ref$,\n type RefFn,\n type RefSchema,\n SchemaKindId,\n type TypeAnnotation,\n type TypeMeta,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n getTypeAnnotation,\n isMutable as isMutable$,\n toEffectSchema,\n toJsonSchema,\n} from './internal';\nimport type * as Relation$ from './Relation';\n\n// TODO(burdon): Remove toEffectSchema, toJsonSchema (moved to JsonSchema export).\nexport { toEffectSchema, toJsonSchema };\n\n/**\n * Returns all properties of an object or relation except for the id and kind.\n */\nexport type Properties<T = any> = Omit<T, 'id' | Entity$.KindId | Relation$.Source | Relation$.Target>;\n\n//\n// Internal types (not exported)\n//\n\n/**\n * Type that marks a schema as an ECHO schema.\n * The value indicates the entity kind (Object or Relation).\n */\ntype EchoSchemaKind<K extends EntityKind = EntityKind> = {\n readonly [SchemaKindId]: K;\n};\n\n/**\n * JSON-encoded properties for objects.\n */\ninterface ObjJsonProps {\n id: string;\n}\n\n/**\n * JSON-encoded properties for relations.\n */\ninterface RelationJsonProps {\n id: string;\n [ATTR_RELATION_SOURCE]: string;\n [ATTR_RELATION_TARGET]: string;\n}\n\n//\n// Obj - Runtime schema for any ECHO object\n//\n\n// Internal type for the Obj schema constant.\n// NOTE: The `any` in the type intersection is intentional - it makes this type bidirectionally\n// assignable with specific object types (e.g., Type.Obj can be assigned to/from Meeting.Meeting).\n// This is needed because operation schemas erase type information.\n// TODO(wittjosiah): Consider alternatives to the `any` intersection hack:\n// - Generic operation schemas that preserve input type in output\n// - Branded types that specific schemas also carry\n// - Accept the limitation and require explicit type narrowing at call sites\ntype ObjSchemaType = Schema.Schema<\n any & AnyEntity & Entity$.OfKind<typeof Entity$.Kind.Object> & AnyProperties,\n { id: string } & AnyProperties\n> &\n EchoSchemaKind<EntityKind.Object> &\n TypeMeta;\n\n// Internal schema definition.\n// NOTE: The EchoObjectSchema annotation is required for Type.Ref(Type.Obj) to work.\n// The typename/version only satisfy ECHO schema machinery for reference targets.\nconst ObjSchema = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n EchoObjectSchema({ typename: ANY_OBJECT_TYPENAME, version: ANY_OBJECT_VERSION }),\n);\n\n/**\n * Runtime Effect schema for any ECHO object.\n * Use for validation, parsing, or as a reference target for collections.\n *\n * NOTE: `Schema.is(Type.Obj)` does STRUCTURAL validation only (checks for `id` field).\n * Use `Obj.isObject()` for proper ECHO instance type guards that check the KindId brand.\n *\n * @example\n * ```ts\n * // Structural type guard (accepts any object with id field)\n * if (Schema.is(Type.Obj)(unknownValue)) { ... }\n *\n * // ECHO instance type guard (checks KindId brand)\n * if (Obj.isObject(unknownValue)) { ... }\n *\n * // Reference to any object type\n * const Collection = Schema.Struct({\n * objects: Schema.Array(Type.Ref(Type.Obj)),\n * }).pipe(Type.object({ typename: 'Collection', version: '0.1.0' }));\n * ```\n */\n// TODO(wittjosiah): Investigate if Schema.filter can validate KindId on ECHO instances.\n// Effect Schema normalizes proxy objects to plain objects before calling filter predicates.\n// Possible approaches: custom Schema.declare, AST manipulation, or upstream contribution.\nexport const Obj: ObjSchemaType = Object.assign(ObjSchema, {\n [SchemaKindId]: (ObjSchema as any)[SchemaKindId],\n}) as unknown as ObjSchemaType;\n\n/**\n * TypeScript type for an ECHO object schema.\n * `T` is the instance type produced by the schema.\n * `Fields` is the optional struct fields type for introspection.\n *\n * @example\n * ```ts\n * const PersonSchema: Type.Obj<Person> = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.object({ typename: 'Person', version: '0.1.0' }));\n *\n * // Access fields for introspection:\n * Object.keys(PersonSchema.fields); // ['name']\n * ```\n */\nexport interface Obj<T = any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>\n extends TypeMeta,\n EchoSchemaKind<EntityKind.Object>,\n Schema.AnnotableClass<\n Obj<T, Fields>,\n Entity$.OfKind<typeof Entity$.Kind.Object> & T,\n Schema.Simplify<ObjJsonProps & ToMutable<T>>,\n never\n > {\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Structural base type for any ECHO object schema.\n * Accepts both static schemas (created with Type.object()) and EchoSchema.\n * NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.\n * Use Type.isObjectSchema() for runtime type guards.\n */\ntype ObjectSchemaBase = Schema.Schema.AnyNoContext & {\n readonly typename: string;\n readonly version: string;\n};\n\nexport namespace Obj {\n /**\n * Type that represents any ECHO object schema.\n * Accepts both static schemas (Type.object()) and mutable schemas (EchoSchema).\n */\n export type Any = ObjectSchemaBase;\n}\n\n/**\n * Factory function to create an ECHO object schema.\n * Adds object metadata annotations to an Effect schema.\n *\n * @example\n * ```ts\n * const Person = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.object({ typename: 'example.com/type/Person', version: '0.1.0' }));\n * ```\n */\nexport const object: {\n (opts: TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;\n} = EchoObjectSchema as any;\n\n//\n// PersistentType (Schema stored in database)\n//\n\nexport const PersistentType: Obj<PersistentSchema> = PersistentSchema as any;\n\nexport interface PersistentType extends Schema.Schema.Type<typeof PersistentType> {}\n\nexport { EchoSchema as RuntimeType };\n\n//\n// Relation - Runtime schema for any ECHO relation\n//\n\n// Internal type for the Relation schema constant.\ntype RelationSchemaType = Schema.Schema<\n { id: ObjectId } & Record<string, unknown>,\n { id: string } & Record<string, unknown>\n> &\n EchoSchemaKind<EntityKind.Relation> &\n TypeMeta;\n\n// Internal schema definition.\n// NOTE: The EchoRelationSchema annotation is required for Type.Ref(Type.Relation) to work.\n// The typename/version/source/target only satisfy ECHO schema machinery for reference targets.\nconst RelationSchema = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n EchoRelationSchema({\n typename: 'dxos.org/schema/AnyRelation',\n version: '0.0.0',\n source: ObjSchema,\n target: ObjSchema,\n }),\n);\n\n/**\n * Runtime Effect schema for any ECHO relation.\n * Use for validation, parsing, or as a reference target for collections.\n * A relation has `id`, source, and target fields plus any additional properties.\n *\n * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).\n * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.\n *\n * @example\n * ```ts\n * // Structural type guard (accepts any object with id field)\n * if (Schema.is(Type.Relation)(unknownValue)) { ... }\n *\n * // ECHO instance type guard (checks KindId brand)\n * if (Relation.isRelation(unknownValue)) { ... }\n * ```\n */\nexport const Relation: RelationSchemaType = Object.assign(RelationSchema, {\n [SchemaKindId]: (RelationSchema as any)[SchemaKindId],\n}) as unknown as RelationSchemaType;\n\n/**\n * TypeScript type for an ECHO relation schema.\n * `T` is the instance type produced by the schema (excluding source/target).\n * `Source` and `Target` are the endpoint types.\n * `Fields` is the optional struct fields type for introspection.\n */\nexport interface Relation<\n T = any,\n Source = any,\n Target = any,\n Fields extends Schema.Struct.Fields = Schema.Struct.Fields,\n> extends TypeMeta,\n EchoSchemaKind<EntityKind.Relation>,\n Schema.AnnotableClass<\n Relation<T, Source, Target, Fields>,\n Entity$.OfKind<typeof Entity$.Kind.Relation> & Relation.Endpoints<Source, Target> & T,\n Schema.Simplify<RelationJsonProps & ToMutable<T>>,\n never\n > {\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Structural base type for any ECHO relation schema.\n * Accepts static schemas (created with Type.relation()).\n * NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.\n * Use Type.isRelationSchema() for runtime type guards.\n */\ntype RelationSchemaBase = Schema.Schema.AnyNoContext & {\n readonly typename: string;\n readonly version: string;\n};\n\nexport namespace Relation {\n /**\n * Type that represents any ECHO relation schema.\n * Accepts static schemas (Type.relation()).\n */\n export type Any = RelationSchemaBase;\n\n /**\n * Get relation source type.\n */\n export type Source<A> = A extends Relation.Endpoints<infer S, infer _T> ? S : never;\n\n /**\n * Get relation target type.\n */\n export type Target<A> = A extends Relation.Endpoints<infer _S, infer T> ? T : never;\n\n export type Endpoints<Source, Target> = {\n [Relation$.Source]: Source;\n [Relation$.Target]: Target;\n };\n}\n\n/**\n * Factory function to create an ECHO relation schema.\n * Adds relation metadata annotations to an Effect schema.\n *\n * @example\n * ```ts\n * const WorksFor = Schema.Struct({\n * role: Schema.String,\n * }).pipe(Type.relation({\n * typename: 'example.com/type/WorksFor',\n * version: '0.1.0',\n * source: Person,\n * target: Company,\n * }));\n * ```\n */\nexport const relation: {\n <SourceSchema extends Schema.Schema.AnyNoContext, TargetSchema extends Schema.Schema.AnyNoContext>(\n opts: EchoRelationSchemaOptions<SourceSchema, TargetSchema>,\n ): <Self extends Schema.Schema.Any>(\n self: Self,\n ) => Relation<Schema.Schema.Type<Self>, Schema.Schema.Type<SourceSchema>, Schema.Schema.Type<TargetSchema>>;\n} = EchoRelationSchema as any;\n\n//\n// Entity - Entity schema types (union of Object | Relation)\n//\n\nexport namespace Entity {\n /**\n * Runtime Effect schema for any ECHO entity (object or relation).\n * Use for validation, parsing, or type guards on unknown values.\n *\n * @example\n * ```ts\n * if (Schema.is(Type.Entity.Any)(unknownValue)) {\n * // unknownValue is an ECHO entity\n * }\n * ```\n */\n export const Any: Schema.Schema<\n { id: ObjectId } & Record<string, unknown>,\n { id: string } & Record<string, unknown>\n > = Schema.Union(Obj, Relation);\n\n /**\n * Type alias for any ECHO entity schema (object or relation).\n * Use this in type annotations for schema parameters.\n */\n export type Any = Obj.Any | Relation.Any;\n}\n\n/**\n * Type guard to check if a schema is an object schema.\n * NOTE: This checks SCHEMAS, not instances. Use Obj.isObject for instances.\n */\nexport const isObjectSchema = (schema: Entity.Any): schema is Obj.Any => {\n return (schema as any)[SchemaKindId] === EntityKind.Object;\n};\n\n/**\n * Type guard to check if a schema is a relation schema.\n * NOTE: This checks SCHEMAS, not instances. Use Relation.isRelation for instances.\n */\nexport const isRelationSchema = (schema: Entity.Any): schema is Relation.Any => {\n return (schema as any)[SchemaKindId] === EntityKind.Relation;\n};\n\n//\n// Ref\n//\n// NOTE: `Type.Ref` vs `Ref.Ref`:\n// - `Type.Ref<T>` is the SCHEMA type - a schema that produces `Ref.Ref<T>` instances.\n// - `Ref.Ref<T>` is the INSTANCE type - the actual runtime ref object.\n//\n// Example:\n// const taskRef: Ref.Ref<Task> = Ref.make(task); // Instance\n// const schema: Type.Ref<Task> = Type.Ref(Task); // Schema\n//\n\n/**\n * Return type of the `Ref` schema constructor.\n *\n * This typedef avoids `TS4023` error (name from external module cannot be used named).\n * See Effect's note on interface types.\n */\nexport interface ref<TargetSchema extends Schema.Schema.Any> extends RefSchema<Schema.Schema.Type<TargetSchema>> {}\n\n/**\n * Factory function to create a Ref schema for the given target schema.\n * Use this in schema definitions to declare reference fields.\n *\n * @example\n * ```ts\n * const Task = Schema.Struct({\n * assignee: Type.Ref(Person), // Creates a Ref schema\n * }).pipe(Type.object({ typename: 'Task', version: '0.1.0' }));\n * ```\n */\nexport const Ref: RefFn = Ref$;\n\n/**\n * TypeScript type for a Ref schema.\n * This is the type of the SCHEMA itself, not the runtime ref instance.\n * For the instance type, use `Ref.Ref<T>` from the Ref module.\n *\n * @example\n * ```ts\n * // Schema type annotation (rarely needed, usually inferred):\n * const refSchema: Type.Ref<Task> = Type.Ref(Task);\n *\n * // Instance type annotation (use Ref.Ref instead):\n * const refInstance: Ref.Ref<Task> = Ref.make(task);\n * ```\n */\nexport interface Ref<T> extends Schema.SchemaClass<Ref$<T>, EncodedReference> {}\n\nexport namespace Ref {\n /**\n * Type that represents any Ref schema (with unknown target type).\n * This is a schema type, not an instance type.\n */\n export type Any = Schema.Schema<Ref$<any>, EncodedReference>;\n}\n\n//\n// Schema utility functions\n//\n\n/**\n * Gets the full DXN of the schema.\n * Will include the version if it's a `type` DXN.\n * @example \"dxn:example.com/type/Person:0.1.0\"\n * @example \"dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX\"\n */\nexport const getDXN = (schema: Entity.Any): DXN | undefined => {\n return getSchemaDXN(schema);\n};\n\n/**\n * @param schema - Schema to get the typename from.\n * @returns The typename of the schema. Example: `example.com/type/Person`.\n */\nexport const getTypename = (schema: Entity.Any): string => {\n const typename = getSchemaTypename(schema);\n invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version of the schema.\n * @example 0.1.0\n */\nexport const getVersion = (schema: Entity.Any): string => {\n const version = getSchemaVersion(schema);\n invariant(typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n return version;\n};\n\n/**\n * @returns True if the schema is mutable.\n */\nexport const isMutable = isMutable$;\n\n/**\n * ECHO type metadata.\n */\nexport type Meta = TypeAnnotation;\n\n/**\n * Gets the meta data of the schema.\n */\nexport const getMeta = (schema: Entity.Any): Meta | undefined => {\n return getTypeAnnotation(schema);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;aAAAA;EAAA;;;;;;mBAAAC;EAAA;;;;;;;AAIA,YAAYC,YAAY;AAGxB,SAASC,iBAAiB;A;AA4F1B,IAAMC,YAAmBC,cAAO;EAC9BC,IAAWC;AACb,CAAA,EAAGC,KACMC,cAAcC,cAAO;EAAEC,KAAYJ;EAAQK,OAAcC;AAAQ,CAAA,CAAA,GACxEC,iBAAiB;EAAEC,UAAUC;EAAqBC,SAASC;AAAmB,CAAA,CAAA;AA2BzE,IAAMC,MAAqBC,OAAOC,OAAOjB,WAAW;EACzD,CAACkB,YAAAA,GAAgBlB,UAAkBkB,YAAAA;AACrC,CAAA;AA+DO,IAAMC,SAETT;AAMG,IAAMU,iBAAwCC;AAqBrD,IAAMC,iBAAwBC,cAAO;EACnCC,IAAWC;AACb,CAAA,EAAGC,KACMC,cAAcC,cAAO;EAAEC,KAAYJ;EAAQK,OAAcC;AAAQ,CAAA,CAAA,GACxEC,mBAAmB;EACjBC,UAAU;EACVC,SAAS;EACTC,QAAQC;EACRC,QAAQD;AACV,CAAA,CAAA;AAoBK,IAAME,WAA+BC,OAAOC,OAAOlB,gBAAgB;EACxE,CAACmB,YAAAA,GAAgBnB,eAAuBmB,YAAAA;AAC1C,CAAA;AA8EO,IAAMC,WAMTV;UAMaW,SAAAA;UAYFC,MAGFC,aAAMC,KAAKR,QAAAA;AAOxB,GAtBiBK,WAAAA,SAAAA,CAAAA,EAAAA;AA4BV,IAAMI,iBAAiB,CAACC,WAAAA;AAC7B,SAAQA,OAAeP,YAAAA,MAAkBQ,WAAWV;AACtD;AAMO,IAAMW,mBAAmB,CAACF,WAAAA;AAC/B,SAAQA,OAAeP,YAAAA,MAAkBQ,WAAWX;AACtD;AAiCO,IAAMa,OAAaC;AAoCnB,IAAMC,SAAS,CAACL,WAAAA;AACrB,SAAOM,aAAaN,MAAAA;AACtB;AAMO,IAAMO,cAAc,CAACP,WAAAA;AAC1B,QAAMf,WAAWuB,kBAAkBR,MAAAA;AACnCS,YAAU,OAAOxB,aAAa,YAAY,CAACA,SAASyB,WAAW,MAAA,GAAS,oBAAA;;;;;;;;;AACxE,SAAOzB;AACT;AAMO,IAAM0B,aAAa,CAACX,WAAAA;AACzB,QAAMd,UAAU0B,iBAAiBZ,MAAAA;AACjCS,YAAU,OAAOvB,YAAY,YAAYA,QAAQ2B,MAAM,iBAAA,GAAoB,mBAAA;;;;;;;;;AAC3E,SAAO3B;AACT;AAKO,IAAM4B,aAAYC;AAUlB,IAAMC,UAAU,CAAChB,WAAAA;AACtB,SAAOiB,kBAAkBjB,MAAAA;AAC3B;;",
|
|
6
|
+
"names": ["Ref", "isMutable", "Schema", "invariant", "ObjSchema", "Struct", "id", "String", "pipe", "extend", "Record", "key", "value", "Unknown", "EchoObjectSchema", "typename", "ANY_OBJECT_TYPENAME", "version", "ANY_OBJECT_VERSION", "Obj", "Object", "assign", "SchemaKindId", "object", "PersistentType", "PersistentSchema", "RelationSchema", "Struct", "id", "String", "pipe", "extend", "Record", "key", "value", "Unknown", "EchoRelationSchema", "typename", "version", "source", "ObjSchema", "target", "Relation", "Object", "assign", "SchemaKindId", "relation", "Entity", "Any", "Union", "Obj", "isObjectSchema", "schema", "EntityKind", "isRelationSchema", "Ref", "Ref$", "getDXN", "getSchemaDXN", "getTypename", "getSchemaTypename", "invariant", "startsWith", "getVersion", "getSchemaVersion", "match", "isMutable", "isMutable$", "getMeta", "getTypeAnnotation"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { QueryAST } from "@dxos/echo-protocol";
|
|
5
|
+
import { DXN } from "@dxos/keys";
|
|
6
|
+
|
|
7
|
+
// src/Hypergraph.ts
|
|
8
|
+
var Hypergraph_exports = {};
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
Hypergraph_exports,
|
|
12
|
+
QueryAST,
|
|
13
|
+
DXN
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-MYCCGG2T.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/Hypergraph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { QueryAST } from '@dxos/echo-protocol';\n// TODO(wittjosiah): Refactor DXN to not use statics similar to Query.\nexport { DXN } from '@dxos/keys';\n\nexport * as Annotation from './Annotation';\nexport * as Database from './Database';\nexport * as Entity from './Entity';\nexport * as Err from './Err';\nexport * as Filter from './Filter';\nexport * as Format from './Format';\nexport * as Hypergraph from './Hypergraph';\nexport * as JsonSchema from './JsonSchema';\nexport * as Key from './Key';\nexport * as Obj from './Obj';\nexport * as Order from './Order';\nexport * as Query from './Query';\nexport * as QueryResult from './QueryResult';\nexport * as Ref from './Ref';\nexport * as Relation from './Relation';\nexport * as SchemaRegistry from './SchemaRegistry';\nexport * as Tag from './Tag';\nexport * as Type from './Type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type DXN } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport { type AnyProperties } from './internal';\nimport type * as Key from './Key';\nimport type * as Ref from './Ref';\nimport type * as SchemaRegistry from './SchemaRegistry';\n\n/**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\nexport interface RefResolutionContext {\n /**\n * Space that the resolution is happening from.\n */\n space?: Key.SpaceId;\n\n /**\n * Queue that the resolution is happening from.\n * This queue will be searched first, and then the space it belongs to.\n */\n queue?: DXN;\n}\n\nexport interface RefResolverOptions {\n /**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\n context?: RefResolutionContext;\n\n /**\n * Middleware to change the resolved object before returning it.\n * @deprecated On track to be removed.\n */\n middleware?: (obj: AnyProperties) => AnyProperties;\n}\n\n/**\n *\n */\n// TODO(burdon): Comment required.\nexport interface Hypergraph extends Database.Queryable {\n get schemaRegistry(): SchemaRegistry.SchemaRegistry;\n\n /**\n * Query objects.\n */\n query: Database.QueryFn;\n\n /**\n * Creates a reference to an existing object in the database.\n *\n * NOTE: The reference may be dangling if the object is not present in the database.\n * NOTE: Difference from `Ref.fromDXN`\n * `Ref.fromDXN(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.\n * `db.makeRef(dxn)` is preferable in cases with access to the database.\n */\n makeRef<T extends Entity.Unknown = Entity.Unknown>(dxn: DXN): Ref.Ref<T>;\n\n /**\n * @param hostDb Host database for reference resolution.\n * @param middleware Called with the loaded object. The caller may change the object.\n * @returns Result of `onLoad`.\n */\n // TODO(dmaretskyi): Restructure API: Remove middleware.\n createRefResolver(options: RefResolverOptions): Ref.Resolver;\n}\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,gBAAgB;AAEzB,SAASC,WAAW;;;ACNpB;",
|
|
6
|
+
"names": ["QueryAST", "DXN"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
Kind
|
|
4
|
+
} from "./chunk-W5D2GWAW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
MetaId,
|
|
7
|
+
VersionTypeId,
|
|
8
|
+
addTag,
|
|
9
|
+
change,
|
|
10
|
+
clone,
|
|
11
|
+
compareVersions,
|
|
12
|
+
decodeVersion,
|
|
13
|
+
deleteKeys,
|
|
14
|
+
encodeVersion,
|
|
15
|
+
getDXN,
|
|
16
|
+
getDatabase,
|
|
17
|
+
getDescription,
|
|
18
|
+
getKeys,
|
|
19
|
+
getLabel,
|
|
20
|
+
getMetaChecked,
|
|
21
|
+
getSnapshot,
|
|
22
|
+
isDeleted,
|
|
23
|
+
isVersion,
|
|
24
|
+
makeObject,
|
|
25
|
+
objectFromJSON,
|
|
26
|
+
objectToJSON,
|
|
27
|
+
removeTag,
|
|
28
|
+
setDescription,
|
|
29
|
+
setLabel,
|
|
30
|
+
setValue,
|
|
31
|
+
sort,
|
|
32
|
+
sortByLabel,
|
|
33
|
+
sortByTypename,
|
|
34
|
+
subscribe,
|
|
35
|
+
version,
|
|
36
|
+
versionValid
|
|
37
|
+
} from "./chunk-BJPE6CIC.mjs";
|
|
38
|
+
import {
|
|
39
|
+
getSchema,
|
|
40
|
+
getTypeAnnotation,
|
|
41
|
+
getTypeDXN,
|
|
42
|
+
getTypename,
|
|
43
|
+
isInstanceOf
|
|
44
|
+
} from "./chunk-RK4Z4JUZ.mjs";
|
|
45
|
+
import {
|
|
46
|
+
KindId
|
|
47
|
+
} from "./chunk-YKTSSMDS.mjs";
|
|
48
|
+
import {
|
|
49
|
+
__export
|
|
50
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
51
|
+
|
|
52
|
+
// src/Obj.ts
|
|
53
|
+
var Obj_exports = {};
|
|
54
|
+
__export(Obj_exports, {
|
|
55
|
+
ID: () => ID,
|
|
56
|
+
Meta: () => Meta,
|
|
57
|
+
VersionTypeId: () => VersionTypeId,
|
|
58
|
+
addTag: () => addTag2,
|
|
59
|
+
change: () => change2,
|
|
60
|
+
clone: () => clone2,
|
|
61
|
+
compareVersions: () => compareVersions,
|
|
62
|
+
decodeVersion: () => decodeVersion,
|
|
63
|
+
deleteKeys: () => deleteKeys2,
|
|
64
|
+
encodeVersion: () => encodeVersion,
|
|
65
|
+
fromJSON: () => fromJSON,
|
|
66
|
+
getDXN: () => getDXN2,
|
|
67
|
+
getDatabase: () => getDatabase2,
|
|
68
|
+
getDescription: () => getDescription2,
|
|
69
|
+
getKeys: () => getKeys2,
|
|
70
|
+
getLabel: () => getLabel2,
|
|
71
|
+
getMeta: () => getMeta,
|
|
72
|
+
getSchema: () => getSchema2,
|
|
73
|
+
getSnapshot: () => getSnapshot2,
|
|
74
|
+
getTypeDXN: () => getTypeDXN2,
|
|
75
|
+
getTypename: () => getTypename2,
|
|
76
|
+
getValue: () => getValue,
|
|
77
|
+
instanceOf: () => instanceOf,
|
|
78
|
+
isDeleted: () => isDeleted2,
|
|
79
|
+
isObject: () => isObject,
|
|
80
|
+
isVersion: () => isVersion,
|
|
81
|
+
make: () => make,
|
|
82
|
+
removeTag: () => removeTag2,
|
|
83
|
+
setDescription: () => setDescription2,
|
|
84
|
+
setLabel: () => setLabel2,
|
|
85
|
+
setValue: () => setValue2,
|
|
86
|
+
sort: () => sort2,
|
|
87
|
+
sortByLabel: () => sortByLabel2,
|
|
88
|
+
sortByTypename: () => sortByTypename2,
|
|
89
|
+
subscribe: () => subscribe2,
|
|
90
|
+
toJSON: () => toJSON,
|
|
91
|
+
version: () => version2,
|
|
92
|
+
versionValid: () => versionValid
|
|
93
|
+
});
|
|
94
|
+
import * as Function from "effect/Function";
|
|
95
|
+
import * as Schema from "effect/Schema";
|
|
96
|
+
import { createJsonPath, getValue as getValue$ } from "@dxos/effect";
|
|
97
|
+
import { assertArgument } from "@dxos/invariant";
|
|
98
|
+
import { ObjectId } from "@dxos/keys";
|
|
99
|
+
import { assumeType } from "@dxos/util";
|
|
100
|
+
var defaultMeta = {
|
|
101
|
+
keys: []
|
|
102
|
+
};
|
|
103
|
+
var make = (schema, props, meta) => {
|
|
104
|
+
assertArgument(getTypeAnnotation(schema)?.kind === Kind.Object, "schema", "Expected an object schema");
|
|
105
|
+
if (props[MetaId] != null) {
|
|
106
|
+
meta = {
|
|
107
|
+
...structuredClone(defaultMeta),
|
|
108
|
+
...props[MetaId]
|
|
109
|
+
};
|
|
110
|
+
delete props[MetaId];
|
|
111
|
+
}
|
|
112
|
+
const filterUndefined = Object.fromEntries(Object.entries(props).filter(([_, v]) => v !== void 0));
|
|
113
|
+
return makeObject(schema, filterUndefined, {
|
|
114
|
+
...defaultMeta,
|
|
115
|
+
...meta
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
var isObject = (obj) => {
|
|
119
|
+
assumeType(obj);
|
|
120
|
+
return typeof obj === "object" && obj !== null && obj[KindId] === Kind.Object;
|
|
121
|
+
};
|
|
122
|
+
var subscribe2 = (obj, callback) => {
|
|
123
|
+
return subscribe(obj, callback);
|
|
124
|
+
};
|
|
125
|
+
var getSnapshot2 = getSnapshot;
|
|
126
|
+
var clone2 = clone;
|
|
127
|
+
var change2 = (obj, callback) => {
|
|
128
|
+
change(obj, callback);
|
|
129
|
+
};
|
|
130
|
+
var getValue = (obj, path) => {
|
|
131
|
+
return getValue$(obj, createJsonPath(path));
|
|
132
|
+
};
|
|
133
|
+
var setValue2 = setValue;
|
|
134
|
+
var ID = ObjectId;
|
|
135
|
+
var instanceOf = (...args) => {
|
|
136
|
+
if (args.length === 1) {
|
|
137
|
+
return (entity) => isInstanceOf(args[0], entity);
|
|
138
|
+
}
|
|
139
|
+
return isInstanceOf(args[0], args[1]);
|
|
140
|
+
};
|
|
141
|
+
var getDXN2 = (entity) => {
|
|
142
|
+
assertArgument(!Schema.isSchema(entity), "obj", "Object should not be a schema.");
|
|
143
|
+
return getDXN(entity);
|
|
144
|
+
};
|
|
145
|
+
var getTypeDXN2 = getTypeDXN;
|
|
146
|
+
var getSchema2 = getSchema;
|
|
147
|
+
var getTypename2 = (entity) => getTypename(entity);
|
|
148
|
+
var getDatabase2 = (entity) => getDatabase(entity);
|
|
149
|
+
var Meta = MetaId;
|
|
150
|
+
function getMeta(entity) {
|
|
151
|
+
return getMetaChecked(entity);
|
|
152
|
+
}
|
|
153
|
+
var getKeys2 = Function.dual(2, (entity, source) => getKeys(entity, source));
|
|
154
|
+
var deleteKeys2 = (entity, source) => deleteKeys(entity, source);
|
|
155
|
+
var addTag2 = (entity, tag) => addTag(entity, tag);
|
|
156
|
+
var removeTag2 = (entity, tag) => removeTag(entity, tag);
|
|
157
|
+
var isDeleted2 = (entity) => isDeleted(entity);
|
|
158
|
+
var getLabel2 = (entity) => getLabel(entity);
|
|
159
|
+
var setLabel2 = (entity, label) => setLabel(entity, label);
|
|
160
|
+
var getDescription2 = (entity) => getDescription(entity);
|
|
161
|
+
var setDescription2 = (entity, description) => setDescription(entity, description);
|
|
162
|
+
var toJSON = (entity) => objectToJSON(entity);
|
|
163
|
+
var fromJSON = objectFromJSON;
|
|
164
|
+
var sortByLabel2 = sortByLabel;
|
|
165
|
+
var sortByTypename2 = sortByTypename;
|
|
166
|
+
var sort2 = (...comparators) => sort(...comparators);
|
|
167
|
+
var version2 = (entity) => version(entity);
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
make,
|
|
171
|
+
isObject,
|
|
172
|
+
subscribe2 as subscribe,
|
|
173
|
+
getSnapshot2 as getSnapshot,
|
|
174
|
+
clone2 as clone,
|
|
175
|
+
change2 as change,
|
|
176
|
+
getValue,
|
|
177
|
+
setValue2 as setValue,
|
|
178
|
+
ID,
|
|
179
|
+
instanceOf,
|
|
180
|
+
getDXN2 as getDXN,
|
|
181
|
+
getTypeDXN2 as getTypeDXN,
|
|
182
|
+
getSchema2 as getSchema,
|
|
183
|
+
getTypename2 as getTypename,
|
|
184
|
+
getDatabase2 as getDatabase,
|
|
185
|
+
Meta,
|
|
186
|
+
getMeta,
|
|
187
|
+
getKeys2 as getKeys,
|
|
188
|
+
deleteKeys2 as deleteKeys,
|
|
189
|
+
addTag2 as addTag,
|
|
190
|
+
removeTag2 as removeTag,
|
|
191
|
+
isDeleted2 as isDeleted,
|
|
192
|
+
getLabel2 as getLabel,
|
|
193
|
+
setLabel2 as setLabel,
|
|
194
|
+
getDescription2 as getDescription,
|
|
195
|
+
setDescription2 as setDescription,
|
|
196
|
+
toJSON,
|
|
197
|
+
fromJSON,
|
|
198
|
+
sortByLabel2 as sortByLabel,
|
|
199
|
+
sortByTypename2 as sortByTypename,
|
|
200
|
+
sort2 as sort,
|
|
201
|
+
version2 as version,
|
|
202
|
+
Obj_exports
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=chunk-NOPVNWPT.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Obj.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Schema from 'effect/Schema';\n\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport { createJsonPath, getValue as getValue$ } from '@dxos/effect';\nimport { assertArgument } from '@dxos/invariant';\nimport { type DXN, ObjectId } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Database from './Database';\nimport * as Entity from './Entity';\nimport {\n type ObjectJSON as APIJSON,\n type AnyEntity,\n type AnyProperties,\n type Comparator as ApiComparator,\n type Meta as ApiMeta,\n type ReadonlyMeta as ApiReadonlyMeta,\n type EntityVersion as ApiVersion,\n type ChangeCallback,\n type InternalObjectProps,\n type KindId,\n MetaId,\n type Mutable,\n type ObjectMeta,\n type SnapshotKindId,\n type VersionCompareResult,\n VersionTypeId,\n addTag as addTag$,\n change as change$,\n clone as clone$,\n compareVersions,\n decodeVersion,\n deleteKeys as deleteKeys$,\n encodeVersion,\n getDXN as getDXN$,\n getDatabase as getDatabase$,\n getDescription as getDescription$,\n getKeys as getKeys$,\n getLabel as getLabel$,\n getMetaChecked as getMeta$,\n getSchema as getSchema$,\n getSnapshot as getSnapshot$,\n getTypeAnnotation,\n getTypeDXN as getTypeDXN$,\n getTypename as getTypename$,\n isDeleted as isDeleted$,\n isInstanceOf,\n isVersion,\n makeObject,\n objectFromJSON,\n removeTag as removeTag$,\n setDescription as setDescription$,\n setLabel as setLabel$,\n setValue as setValue$,\n sort as sort$,\n sortByLabel as sortByLabel$,\n sortByTypename as sortByTypename$,\n subscribe as subscribe$,\n objectToJSON as toJSON$,\n version as version$,\n versionValid,\n} from './internal';\nimport type * as Ref from './Ref';\nimport type * as Type from './Type';\n\n/**\n * Base type for all ECHO objects.\n */\ninterface BaseObj extends AnyEntity, Entity.OfKind<typeof Entity.Kind.Object> {}\n\n/**\n * Object type with specific properties.\n */\nexport type Obj<Props> = BaseObj & Props;\n\n/**\n * Object with no known properties beyond id and kind.\n * Use this when the object's schema/properties are not known.\n * For objects with arbitrary properties, use `Obj.AnyProps`.\n *\n * NOTE: This is a TypeScript type only, not a schema.\n * To validate that a value is an ECHO object, use `Schema.is(Type.Obj)`.\n */\nexport interface Unknown extends BaseObj {}\n\n/**\n * Object with arbitrary properties.\n *\n * NOTE: Due to how TypeScript works, this type is not assignable to a specific schema type.\n * In that case, use `Obj.instanceOf` to check if an object is of a specific type.\n *\n * Prefer using `Obj.Unknown` when you don't need to access arbitrary properties.\n */\nexport interface Any extends BaseObj, AnyProperties {}\n\n/**\n * Base type for snapshot objects (has SnapshotKindId instead of KindId).\n */\ninterface BaseSnapshot extends AnyEntity {\n readonly [SnapshotKindId]: typeof Entity.Kind.Object;\n readonly id: ObjectId;\n}\n\n/**\n * Immutable snapshot of an ECHO object.\n * Branded with SnapshotKindId (not KindId).\n * Property values are frozen at the time the snapshot was created.\n * Returned by getSnapshot() and hooks like useObject().\n *\n * Snapshots are structurally identical to reactive objects but have a different brand,\n * making them distinguishable at the TypeScript level. Neither is assignable to the other.\n */\nexport type Snapshot<T extends Unknown = Unknown> = Omit<T, KindId> & BaseSnapshot;\n\nconst defaultMeta: ObjectMeta = {\n keys: [],\n};\n\ntype Props<T = any> = {\n id?: ObjectId;\n [Meta]?: Partial<ObjectMeta>;\n} & Type.Properties<T>;\n\n// TODO(burdon): Should we allow the caller to set the id?\n/**\n * Props type for object creation with a given schema.\n */\nexport type MakeProps<S extends Schema.Schema.AnyNoContext> = {\n id?: ObjectId;\n [Meta]?: Partial<ObjectMeta>;\n} & NoInfer<Props<Schema.Schema.Type<S>>>;\n\n/**\n * Creates a new echo object of the given schema.\n * @param schema - Object schema.\n * @param props - Object properties.\n * @param meta - Object metadata (deprecated) -- pass with Obj.Meta.\n *\n * Meta can be passed as a symbol in `props`.\n *\n * Example:\n * ```ts\n * const obj = Obj.make(Person, { [Obj.Meta]: { keys: [...] }, name: 'John' });\n * ```\n *\n * Note: Only accepts object schemas, not relation schemas. Use `Relation.make` for relations.\n */\nexport const make: {\n <S extends Type.Obj.Any>(schema: S, props: MakeProps<S>): Obj<Schema.Schema.Type<S>>;\n /**\n * @deprecated Pass meta as in the example: `Obj.make(Person, { [Obj.Meta]: { keys: [...] }, name: 'John' })`.\n */\n <S extends Type.Obj.Any>(schema: S, props: MakeProps<S>, meta: Partial<ObjectMeta>): Obj<Schema.Schema.Type<S>>;\n} = <S extends Type.Obj.Any>(\n schema: S,\n props: MakeProps<S>,\n meta?: Partial<ObjectMeta>,\n): Obj<Schema.Schema.Type<S>> => {\n assertArgument(getTypeAnnotation(schema)?.kind === Entity.Kind.Object, 'schema', 'Expected an object schema');\n\n // Set default fields on meta on creation.\n if (props[MetaId] != null) {\n meta = { ...structuredClone(defaultMeta), ...props[MetaId] };\n delete props[MetaId];\n }\n\n // Filter undefined values.\n const filterUndefined = Object.fromEntries(Object.entries(props).filter(([_, v]) => v !== undefined));\n\n return makeObject<Schema.Schema.Type<S>>(schema, filterUndefined as any, {\n ...defaultMeta,\n ...meta,\n });\n};\n\n/**\n * Determine if object is an ECHO object.\n */\nexport const isObject = (obj: unknown): obj is Unknown => {\n assumeType<InternalObjectProps>(obj);\n return typeof obj === 'object' && obj !== null && obj[Entity.KindId] === Entity.Kind.Object;\n};\n\n/**\n * Subscribe to object updates.\n * The callback is called synchronously when the object is modified.\n * Only accepts reactive objects (not snapshots).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (obj: Unknown, callback: () => void): (() => void) => {\n return subscribe$(obj, callback);\n};\n\n//\n// Snapshot\n//\n\n/**\n * Returns an immutable snapshot of an object.\n * The snapshot is branded with SnapshotKindId instead of KindId,\n * making it distinguishable from the reactive object at the type level.\n */\nexport const getSnapshot: <T extends Unknown>(obj: T) => Snapshot<T> = getSnapshot$ as any;\n\nexport type CloneOptions = {\n /**\n * Retain the original object's ID.\n * @default false\n */\n retainId?: boolean;\n\n /**\n * Recursively clone referenced objects.\n * @default false\n */\n deep?: boolean;\n};\n\n/**\n * Clones an object or relation.\n * This does not clone referenced objects, only the properties in the object.\n * @returns A new object with the same schema and properties.\n */\nexport const clone: <T extends Unknown>(obj: T, opts?: CloneOptions) => T = clone$;\n\n//\n// Change\n//\n\n/**\n * Makes all properties mutable recursively.\n * Used to provide a mutable view of an object within `Obj.change`.\n */\nexport type { Mutable };\n\n/**\n * Perform mutations on an echo object within a controlled context.\n *\n * All mutations within the callback are batched and trigger a single notification\n * when the callback completes. Direct mutations outside of `Obj.change` will throw\n * an error for echo objects.\n *\n * This function also works with nested objects within echo objects (e.g., Template structs)\n * that are reactive at runtime.\n *\n * @param obj - The echo object to mutate. Use `Relation.change` for relations.\n * @param callback - The callback that performs mutations on the object.\n *\n * @example\n * ```ts\n * const person = Obj.make(Person, { name: 'John', age: 25 });\n *\n * // Mutate within Obj.change\n * Obj.change(person, (p) => {\n * p.name = 'Jane';\n * p.age = 30;\n * });\n * // ONE notification fires here\n *\n * // Direct mutation throws\n * person.name = 'Bob'; // Error: Cannot modify outside Obj.change()\n * ```\n *\n * Note: Only accepts objects. Use `Relation.change` for relations.\n */\nexport const change = <T extends Unknown>(obj: T, callback: ChangeCallback<T>): void => {\n change$(obj, callback);\n};\n\n/**\n * Get a deeply nested property from an object.\n *\n * Similar to lodash.get and getDeep from @dxos/util.\n * This is the complementary function to setValue.\n * Accepts both reactive objects and snapshots.\n *\n * @param obj - The ECHO object to get the property from.\n * @param path - Path to the property (array of keys).\n * @returns The value at the path, or undefined if not found.\n *\n * @example\n * ```ts\n * const person = Obj.make(Person, {\n * name: 'John',\n * addresses: [{ street: '123 Main St' }]\n * });\n *\n * Obj.getValue(person, ['addresses', 0, 'street']); // '123 Main St'\n * Obj.getValue(person, ['addresses', 1, 'street']); // undefined\n * ```\n */\nexport const getValue = (obj: Unknown | Snapshot, path: readonly (string | number)[]): any => {\n return getValue$(obj, createJsonPath(path));\n};\n\n/**\n * Set a deeply nested property on an object, using the object's schema to determine\n * whether to initialize nested data as an empty object or array.\n *\n * Similar to lodash.set and setDeep from @dxos/util, but schema-aware.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n *\n * @param obj - The mutable ECHO object to set the property on.\n * @param path - Path to the property (array of keys).\n * @param value - Value to set.\n * @returns The value that was set.\n *\n * @example\n * ```ts\n * const person = Obj.make(Person, { name: 'John' });\n * // Person schema has: addresses: Schema.mutable(Schema.Array(Address))\n * Obj.change(person, (p) => {\n * Obj.setValue(p, ['addresses', 0, 'street'], '123 Main St');\n * });\n * // Creates: person.addresses = [{ street: '123 Main St' }]\n * ```\n */\n// TODO(wittjosiah): Compute possible path values + type value based on generic object type.\nexport const setValue: (obj: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =\n setValue$ as any;\n\n//\n// Type\n//\n\n// TODO(burdon): To discuss: prefer over ObjectId or Key.ObjectId or Type.ID?\nexport const ID = ObjectId;\nexport type ID = ObjectId;\n\n/**\n * Test if object or relation is an instance of a schema.\n * @example\n * ```ts\n * const john = Obj.make(Person, { name: 'John' });\n * const isPerson = Obj.instanceOf(Person);\n * if (isPerson(john)) {\n * // john is Person\n * }\n * ```\n */\nexport const instanceOf: {\n <S extends Type.Entity.Any>(schema: S): (value: unknown) => value is Schema.Schema.Type<S>;\n <S extends Type.Entity.Any>(schema: S, value: unknown): value is Schema.Schema.Type<S>;\n} = ((...args: [schema: Type.Entity.Any, value: unknown] | [schema: Type.Entity.Any]) => {\n if (args.length === 1) {\n return (entity: unknown) => isInstanceOf(args[0], entity);\n }\n\n return isInstanceOf(args[0], args[1]);\n}) as any;\n\n// TODO(dmaretskyi): Allow returning undefined.\n/**\n * Get the DXN of the object.\n * Accepts both reactive objects and snapshots.\n */\nexport const getDXN = (entity: Unknown | Snapshot): DXN => {\n assertArgument(!Schema.isSchema(entity), 'obj', 'Object should not be a schema.');\n return getDXN$(entity);\n};\n\n/**\n * @returns The DXN of the object's type.\n * @example dxn:example.com/type/Person:1.0.0\n */\n// TODO(wittjosiah): Narrow types.\nexport const getTypeDXN: (obj: unknown | undefined) => DXN | undefined = getTypeDXN$ as any;\n\n/**\n * Get the schema of the object.\n * Returns the branded ECHO schema used to create the object.\n */\n// TODO(wittjosiah): Narrow types.\nexport const getSchema: (obj: unknown | undefined) => Type.Entity.Any | undefined = getSchema$ as any;\n\n/**\n * @returns The typename of the object's type.\n * Accepts both reactive objects and snapshots.\n * @example `example.com/type/Person`\n */\nexport const getTypename = (entity: Unknown | Snapshot): string | undefined => getTypename$(entity);\n\n//\n// Database\n//\n\n/**\n * Get the database the object belongs to.\n * Accepts both reactive objects and snapshots.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => getDatabase$(entity);\n\n//\n// Meta\n//\n\nexport const Meta: unique symbol = MetaId as any;\n\n/**\n * Deeply read-only version of ObjectMeta.\n * Prevents mutation at all nesting levels (e.g., `meta.keys.push()` is a TypeScript error).\n */\nexport type ReadonlyMeta = ApiReadonlyMeta;\n\n/**\n * Mutable meta type returned by `Obj.getMeta` inside an `Obj.change` callback.\n */\nexport type Meta = ApiMeta;\n\n// TODO(burdon): Narrow type.\n// TODO(dmaretskyi): Allow returning undefined.\n/**\n * Get the metadata for an object.\n * Returns mutable meta when passed a mutable object (inside `Obj.change` callback).\n * Returns read-only meta when passed a regular object or snapshot.\n *\n * @example\n * ```ts\n * // Read-only access outside change callback\n * const meta = Obj.getMeta(person); // ReadonlyMeta\n *\n * // Mutable access inside change callback\n * Obj.change(person, (p) => {\n * const meta = Obj.getMeta(p); // ObjectMeta (mutable)\n * meta.tags ??= [];\n * meta.tags.push('important');\n * });\n * ```\n */\n// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\nexport function getMeta(entity: Mutable<Unknown>): ObjectMeta;\nexport function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): ObjectMeta | ReadonlyMeta {\n return getMeta$(entity);\n}\n\n/**\n * @returns Foreign keys for the object from the specified source.\n * Accepts both reactive objects and snapshots.\n */\nexport const getKeys: {\n (entity: Unknown | Snapshot, source: string): ForeignKey[];\n (source: string): (entity: Unknown | Snapshot) => ForeignKey[];\n} = Function.dual(2, (entity: Unknown | Snapshot, source?: string): ForeignKey[] => getKeys$(entity, source!));\n\n/**\n * Delete all keys from the object for the specified source.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const deleteKeys = (entity: Mutable<Unknown>, source: string): void => deleteKeys$(entity, source);\n\n/**\n * Add a tag to the object.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: string): void => addTag$(entity, tag);\n\n/**\n * Remove a tag from the object.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: string): void => removeTag$(entity, tag);\n\n/**\n * Check if the object is deleted.\n * Accepts both reactive objects and snapshots.\n */\n// TODO(dmaretskyi): Default to `false`.\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => isDeleted$(entity);\n\n//\n// Annotations\n//\n\n/**\n * Get the label of the object.\n * Accepts both reactive objects and snapshots.\n */\nexport const getLabel = (entity: Unknown | Snapshot): string | undefined => getLabel$(entity);\n\n/**\n * Set the label of the object.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => setLabel$(entity, label);\n\n/**\n * Get the description of the object.\n * Accepts both reactive objects and snapshots.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => getDescription$(entity);\n\n/**\n * Set the description of the object.\n * Must be called within an `Obj.change` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setDescription = (entity: Mutable<Unknown>, description: string): void =>\n setDescription$(entity, description);\n\n//\n// JSON\n//\n\n/**\n * JSON representation of an object.\n */\nexport type JSON = APIJSON;\n\n/**\n * Converts object to its JSON representation.\n * Accepts both reactive objects and snapshots.\n *\n * The same algorithm is used when calling the standard `JSON.stringify(obj)` function.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => toJSON$(entity);\n\n/**\n * Creates an object from its json representation, performing schema validation.\n * References and schemas will be resolvable if the `refResolver` is provided.\n *\n * The function must be async to support resolving the schema as well as the relation endpoints.\n *\n * @param options.refResolver - Resolver for references. Produces hydrated references that can be resolved.\n * @param options.dxn - Override object DXN. Changes the result of `Obj.getDXN`.\n */\nexport const fromJSON: (json: unknown, options?: { refResolver?: Ref.Resolver; dxn?: DXN }) => Promise<Unknown> =\n objectFromJSON as any;\n\n//\n// Sorting\n//\n\n/**\n * Comparator function type for sorting objects.\n * Accepts both reactive objects and snapshots.\n */\nexport type Comparator = ApiComparator<Unknown | Snapshot>;\n\nexport const sortByLabel: Comparator = sortByLabel$ as Comparator;\nexport const sortByTypename: Comparator = sortByTypename$ as Comparator;\nexport const sort = (...comparators: Comparator[]): Comparator => sort$(...comparators) as Comparator;\n\n//\n// Version\n//\n\nexport { VersionTypeId };\nexport type { VersionCompareResult };\n\n/**\n * Represent object version.\n * May be backed by Automerge.\n * Objects with no history are not versioned.\n */\nexport type Version = ApiVersion;\n\nexport { isVersion, versionValid, compareVersions, encodeVersion, decodeVersion };\n\n/**\n * Returns the version of the object.\n * Accepts both reactive objects and snapshots.\n */\nexport const version = (entity: Unknown | Snapshot): Version => version$(entity);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;gBAAAA;EAAA,cAAAC;EAAA,aAAAC;EAAA;;oBAAAC;EAAA;;gBAAAC;EAAA,mBAAAC;EAAA,sBAAAC;EAAA,eAAAC;EAAA,gBAAAC;EAAA;mBAAAC;EAAA,mBAAAC;EAAA,kBAAAC;EAAA,mBAAAC;EAAA;;mBAAAC;EAAA;;;mBAAAC;EAAA,sBAAAC;EAAA,gBAAAC;EAAA,gBAAAC;EAAA,YAAAC;EAAA,mBAAAC;EAAA,sBAAAC;EAAA,iBAAAC;EAAA;iBAAAC;EAAA;;AAIA,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAGxB,SAASC,gBAAgBC,YAAYC,iBAAiB;AACtD,SAASC,sBAAsB;AAC/B,SAAmBC,gBAAgB;AACnC,SAASC,kBAAkB;AA4G3B,IAAMC,cAA0B;EAC9BC,MAAM,CAAA;AACR;AA+BO,IAAMC,OAMT,CACFC,QACAC,OACAC,SAAAA;AAEAC,iBAAeC,kBAAkBJ,MAAAA,GAASK,SAAgBC,KAAKC,QAAQ,UAAU,2BAAA;AAGjF,MAAIN,MAAMO,MAAAA,KAAW,MAAM;AACzBN,WAAO;MAAE,GAAGO,gBAAgBZ,WAAAA;MAAc,GAAGI,MAAMO,MAAAA;IAAQ;AAC3D,WAAOP,MAAMO,MAAAA;EACf;AAGA,QAAME,kBAAkBH,OAAOI,YAAYJ,OAAOK,QAAQX,KAAAA,EAAOY,OAAO,CAAC,CAACC,GAAGC,CAAAA,MAAOA,MAAMC,MAAAA,CAAAA;AAE1F,SAAOC,WAAkCjB,QAAQU,iBAAwB;IACvE,GAAGb;IACH,GAAGK;EACL,CAAA;AACF;AAKO,IAAMgB,WAAW,CAACC,QAAAA;AACvBC,aAAgCD,GAAAA;AAChC,SAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQA,IAAWE,MAAM,MAAaf,KAAKC;AACvF;AAQO,IAAMe,aAAY,CAACH,KAAcI,aAAAA;AACtC,SAAOC,UAAWL,KAAKI,QAAAA;AACzB;AAWO,IAAME,eAA0DC;AAqBhE,IAAMC,SAA+DC;AA0CrE,IAAMC,UAAS,CAAoBV,KAAQI,aAAAA;AAChDO,SAAQX,KAAKI,QAAAA;AACf;AAwBO,IAAMQ,WAAW,CAACZ,KAAyBa,SAAAA;AAChD,SAAOC,UAAUd,KAAKe,eAAeF,IAAAA,CAAAA;AACvC;AA4BO,IAAMG,YACXC;AAOK,IAAMC,KAAKC;AAcX,IAAMC,aAGR,IAAIC,SAAAA;AACP,MAAIA,KAAKC,WAAW,GAAG;AACrB,WAAO,CAACC,WAAoBC,aAAaH,KAAK,CAAA,GAAIE,MAAAA;EACpD;AAEA,SAAOC,aAAaH,KAAK,CAAA,GAAIA,KAAK,CAAA,CAAE;AACtC;AAOO,IAAMI,UAAS,CAACF,WAAAA;AACrBvC,iBAAe,CAAQ0C,gBAASH,MAAAA,GAAS,OAAO,gCAAA;AAChD,SAAOI,OAAQJ,MAAAA;AACjB;AAOO,IAAMK,cAA4DC;AAOlE,IAAMC,aAAuEC;AAO7E,IAAMC,eAAc,CAACT,WAAmDU,YAAaV,MAAAA;AAUrF,IAAMW,eAAc,CAACX,WAA8DY,YAAaZ,MAAAA;AAMhG,IAAMa,OAAsB/C;AAoC5B,SAASgD,QAAQd,QAA6C;AACnE,SAAOe,eAASf,MAAAA;AAClB;AAMO,IAAMgB,WAGAC,cAAK,GAAG,CAACjB,QAA4BkB,WAAkCC,QAASnB,QAAQkB,MAAAA,CAAAA;AAS9F,IAAME,cAAa,CAACpB,QAA0BkB,WAAyBG,WAAYrB,QAAQkB,MAAAA;AAS3F,IAAMI,UAAS,CAACtB,QAA0BuB,QAAsBC,OAAQxB,QAAQuB,GAAAA;AAShF,IAAME,aAAY,CAACzB,QAA0BuB,QAAsBG,UAAW1B,QAAQuB,GAAAA;AAOtF,IAAMI,aAAY,CAAC3B,WAAwC4B,UAAW5B,MAAAA;AAUtE,IAAM6B,YAAW,CAAC7B,WAAmD8B,SAAU9B,MAAAA;AAS/E,IAAM+B,YAAW,CAAC/B,QAA0BgC,UAAwBC,SAAUjC,QAAQgC,KAAAA;AAMtF,IAAME,kBAAiB,CAAClC,WAAmDmC,eAAgBnC,MAAAA;AAS3F,IAAMoC,kBAAiB,CAACpC,QAA0BqC,gBACvDC,eAAgBtC,QAAQqC,WAAAA;AAiBnB,IAAME,SAAS,CAACvC,WAAqCwC,aAAQxC,MAAAA;AAW7D,IAAMyC,WACXC;AAYK,IAAMC,eAA0BC;AAChC,IAAMC,kBAA6BC;AACnC,IAAMC,QAAO,IAAIC,gBAA0CC,KAAAA,GAASD,WAAAA;AAsBpE,IAAME,WAAU,CAACC,WAAwCC,QAASD,MAAAA;",
|
|
6
|
+
"names": ["addTag", "change", "clone", "deleteKeys", "getDXN", "getDatabase", "getDescription", "getKeys", "getLabel", "getSchema", "getSnapshot", "getTypeDXN", "getTypename", "isDeleted", "removeTag", "setDescription", "setLabel", "setValue", "sort", "sortByLabel", "sortByTypename", "subscribe", "version", "Function", "Schema", "createJsonPath", "getValue", "getValue$", "assertArgument", "ObjectId", "assumeType", "defaultMeta", "keys", "make", "schema", "props", "meta", "assertArgument", "getTypeAnnotation", "kind", "Kind", "Object", "MetaId", "structuredClone", "filterUndefined", "fromEntries", "entries", "filter", "_", "v", "undefined", "makeObject", "isObject", "obj", "assumeType", "KindId", "subscribe", "callback", "subscribe$", "getSnapshot", "getSnapshot$", "clone", "clone$", "change", "change$", "getValue", "path", "getValue$", "createJsonPath", "setValue", "setValue$", "ID", "ObjectId", "instanceOf", "args", "length", "entity", "isInstanceOf", "getDXN", "isSchema", "getDXN$", "getTypeDXN", "getTypeDXN$", "getSchema", "getSchema$", "getTypename", "getTypename$", "getDatabase", "getDatabase$", "Meta", "getMeta", "getMeta$", "getKeys", "dual", "source", "getKeys$", "deleteKeys", "deleteKeys$", "addTag", "tag", "addTag$", "removeTag", "removeTag$", "isDeleted", "isDeleted$", "getLabel", "getLabel$", "setLabel", "label", "setLabel$", "getDescription", "getDescription$", "setDescription", "description", "setDescription$", "toJSON", "toJSON$", "fromJSON", "objectFromJSON", "sortByLabel", "sortByLabel$", "sortByTypename", "sortByTypename$", "sort", "comparators", "sort$", "version", "entity", "version$"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
Currency,
|
|
4
|
+
CurrencyAnnotationId,
|
|
5
|
+
DecimalPrecision,
|
|
6
|
+
Email,
|
|
7
|
+
Format,
|
|
8
|
+
FormatAnnotation,
|
|
9
|
+
FormatAnnotationId,
|
|
10
|
+
FormatEnums,
|
|
11
|
+
Formula,
|
|
12
|
+
GeoLocation,
|
|
13
|
+
GeoPoint,
|
|
14
|
+
Hostname,
|
|
15
|
+
JSON,
|
|
16
|
+
Markdown,
|
|
17
|
+
OptionsAnnotation,
|
|
18
|
+
OptionsAnnotationId,
|
|
19
|
+
PropertyKind,
|
|
20
|
+
Regex,
|
|
21
|
+
SelectOption,
|
|
22
|
+
Text,
|
|
23
|
+
TypeEnum,
|
|
24
|
+
TypeFormat,
|
|
25
|
+
URL,
|
|
26
|
+
UUID,
|
|
27
|
+
formatToType,
|
|
28
|
+
getFormatAnnotation,
|
|
29
|
+
getOptionsAnnotation,
|
|
30
|
+
getTypeEnum,
|
|
31
|
+
typeToFormat
|
|
32
|
+
} from "./chunk-FRDT7RA4.mjs";
|
|
33
|
+
import {
|
|
34
|
+
__export
|
|
35
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
36
|
+
|
|
37
|
+
// src/Format.ts
|
|
38
|
+
var Format_exports = {};
|
|
39
|
+
__export(Format_exports, {
|
|
40
|
+
Currency: () => Currency,
|
|
41
|
+
CurrencyAnnotationId: () => CurrencyAnnotationId,
|
|
42
|
+
DecimalPrecision: () => DecimalPrecision,
|
|
43
|
+
Email: () => Email,
|
|
44
|
+
Format: () => Format,
|
|
45
|
+
FormatAnnotation: () => FormatAnnotation,
|
|
46
|
+
FormatAnnotationId: () => FormatAnnotationId,
|
|
47
|
+
FormatEnums: () => FormatEnums,
|
|
48
|
+
Formula: () => Formula,
|
|
49
|
+
GeoLocation: () => GeoLocation,
|
|
50
|
+
GeoPoint: () => GeoPoint,
|
|
51
|
+
Hostname: () => Hostname,
|
|
52
|
+
JSON: () => JSON,
|
|
53
|
+
Markdown: () => Markdown,
|
|
54
|
+
OptionsAnnotation: () => OptionsAnnotation,
|
|
55
|
+
OptionsAnnotationId: () => OptionsAnnotationId,
|
|
56
|
+
PropertyKind: () => PropertyKind,
|
|
57
|
+
Regex: () => Regex,
|
|
58
|
+
SelectOption: () => SelectOption,
|
|
59
|
+
Text: () => Text,
|
|
60
|
+
TypeEnum: () => TypeEnum,
|
|
61
|
+
TypeFormat: () => TypeFormat,
|
|
62
|
+
URL: () => URL,
|
|
63
|
+
UUID: () => UUID,
|
|
64
|
+
formatToType: () => formatToType,
|
|
65
|
+
getFormatAnnotation: () => getFormatAnnotation,
|
|
66
|
+
getOptionsAnnotation: () => getOptionsAnnotation,
|
|
67
|
+
getTypeEnum: () => getTypeEnum,
|
|
68
|
+
typeToFormat: () => typeToFormat
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
Format_exports
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=chunk-PQZW3S6L.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Format.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type TypeFormat as Format } from './internal';\n\nexport * from './internal/formats';\n\nexport type { Format };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|