@dxos/echo 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 -2
- package/dist/lib/neutral/Annotation.mjs +8 -3
- package/dist/lib/neutral/Database.mjs +36 -6
- package/dist/lib/neutral/Entity.mjs +18 -10
- package/dist/lib/neutral/Err.mjs +3 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +45 -0
- package/dist/lib/neutral/Feed.mjs.map +7 -0
- package/dist/lib/neutral/Filter.mjs +19 -10
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +9 -9
- package/dist/lib/neutral/Obj.mjs +35 -15
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +21 -9
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +20 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +13 -10
- package/dist/lib/neutral/Type.mjs +13 -23
- package/dist/lib/neutral/chunk-24XI6DOL.mjs +34 -0
- package/dist/lib/neutral/chunk-24XI6DOL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VB5HVDCA.mjs → chunk-4YAAHG3E.mjs} +53 -5
- package/dist/lib/neutral/chunk-4YAAHG3E.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-CUDIBUM4.mjs → chunk-4ZRIO2QF.mjs} +104 -25
- package/dist/lib/neutral/chunk-4ZRIO2QF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SU2LVM7J.mjs → chunk-7C2A2RP6.mjs} +1731 -2747
- package/dist/lib/neutral/chunk-7C2A2RP6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs → chunk-BNCCGLJN.mjs} +1 -1
- package/dist/lib/neutral/{chunk-4L6DOFXP.mjs.map → chunk-BNCCGLJN.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-2MTHJ5UW.mjs → chunk-CAB5PWUF.mjs} +134 -24
- package/dist/lib/neutral/chunk-CAB5PWUF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-62DWJ6CE.mjs → chunk-DQYLD2RB.mjs} +14 -14
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XMIDBDE6.mjs → chunk-DUTD5HFU.mjs} +11 -56
- package/dist/lib/neutral/chunk-DUTD5HFU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-EKQJGGA3.mjs +396 -0
- package/dist/lib/neutral/chunk-EKQJGGA3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-VR4A4WGG.mjs → chunk-EOIR5O5I.mjs} +72 -23
- package/dist/lib/neutral/chunk-EOIR5O5I.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-HMOXCO27.mjs → chunk-GVY6O76A.mjs} +8 -3
- package/dist/lib/neutral/chunk-GVY6O76A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4TT624YA.mjs → chunk-GZQTCRJB.mjs} +2 -2
- package/dist/lib/neutral/{chunk-4TT624YA.mjs.map → chunk-GZQTCRJB.mjs.map} +1 -1
- package/dist/lib/neutral/chunk-HGHJ36DH.mjs +117 -0
- package/dist/lib/neutral/chunk-HGHJ36DH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-3ZEAZF7T.mjs → chunk-IICPQK3M.mjs} +8 -4
- package/dist/lib/neutral/chunk-IICPQK3M.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-IP2GHXWA.mjs → chunk-NKPWM67P.mjs} +5 -5
- package/dist/lib/neutral/chunk-NKPWM67P.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6QPSGMEF.mjs → chunk-OPMZTWI3.mjs} +32 -8
- package/dist/lib/neutral/chunk-OPMZTWI3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NWUO5FKZ.mjs → chunk-OPQEHU36.mjs} +8 -2
- package/dist/lib/neutral/chunk-OPQEHU36.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QDV7C7VM.mjs +299 -0
- package/dist/lib/neutral/chunk-QDV7C7VM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YQYMWZAD.mjs → chunk-TBKX6JQO.mjs} +4 -4
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RPB6V4BE.mjs → chunk-UBEZSGXY.mjs} +14 -1
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ROKO4RKJ.mjs → chunk-UI6MWK5W.mjs} +2 -2
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XV5R2XZH.mjs +133 -0
- package/dist/lib/neutral/chunk-XV5R2XZH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YPGDBRPH.mjs +159 -0
- package/dist/lib/neutral/chunk-YPGDBRPH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +50 -0
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZCBOJ6I7.mjs +787 -0
- package/dist/lib/neutral/chunk-ZCBOJ6I7.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +42 -25
- package/dist/lib/neutral/internal/index.mjs +56 -38
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +42 -34
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +23 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +16 -0
- package/dist/types/src/Collection.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +86 -84
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +19 -0
- package/dist/types/src/Dataset.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +41 -15
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +43 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +163 -0
- package/dist/types/src/Feed.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +21 -5
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +3 -3
- package/dist/types/src/Format.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +8 -3
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/JsonSchema.d.ts +11 -4
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +158 -43
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +109 -15
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +58 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +75 -28
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/SchemaRegistry.d.ts +4 -4
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +4 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +51 -180
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +68 -0
- package/dist/types/src/View.d.ts.map +1 -0
- package/dist/types/src/hierarchy.test.d.ts +2 -0
- package/dist/types/src/hierarchy.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/{annotations → Annotation}/annotations.d.ts +69 -8
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -0
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Annotation}/sorting.d.ts +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/{annotations → Annotation}/util.d.ts +13 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api/entity.d.ts → Entity/api.d.ts} +2 -2
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/entity.d.ts +3 -3
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/model.d.ts +4 -26
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/object.d.ts +2 -2
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -0
- package/dist/types/src/internal/{entities → Entity}/relation.d.ts +3 -30
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/util.d.ts.map +1 -0
- package/dist/types/src/internal/{api → Entity}/version.d.ts +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.test.d.ts.map +1 -0
- package/dist/types/src/internal/Format/index.d.ts.map +1 -0
- package/dist/types/src/internal/Format/number.d.ts.map +1 -0
- package/dist/types/src/internal/Format/object.d.ts.map +1 -0
- package/dist/types/src/internal/Format/select.d.ts.map +1 -0
- package/dist/types/src/internal/Format/string.d.ts.map +1 -0
- package/dist/types/src/internal/{formats → Format}/types.d.ts +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/annotations.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/index.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -0
- package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-type.d.ts +19 -19
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/JsonSchema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/create-object.d.ts +2 -2
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/deleted.d.ts +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/inspect.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/json-serializer.d.ts +12 -5
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/json-serializer.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts +2 -0
- package/dist/types/src/internal/Obj/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/schema-validator.test.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/{object → Obj}/typed-object.d.ts +4 -4
- package/dist/types/src/internal/Obj/typed-object.d.ts.map +1 -0
- package/dist/types/src/internal/Obj/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref-array.d.ts +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -0
- package/dist/types/src/internal/{ref → Ref}/ref.d.ts +16 -3
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/compose.d.ts +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -0
- package/dist/types/src/internal/Type/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/echo-schema.d.ts +8 -7
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -0
- package/dist/types/src/internal/Type/index.d.ts.map +1 -0
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -0
- package/dist/types/src/internal/{schema → Type}/persistent-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/{api → common/api}/index.d.ts +0 -4
- package/dist/types/src/internal/common/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/index.d.ts +4 -0
- package/dist/types/src/internal/common/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.d.ts +2 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-handler.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/typed-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/base.d.ts +1 -0
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/entity.d.ts +2 -2
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/meta.d.ts +2 -1
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts +54 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/typename.d.ts +8 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{types → common/types}/version.d.ts +2 -2
- package/dist/types/src/internal/common/types/version.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +9 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +19 -18
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/src/Annotation.ts +31 -1
- package/src/Collection.ts +37 -0
- package/src/Database.ts +167 -173
- package/src/Dataset.ts +26 -0
- package/src/Entity.ts +73 -54
- package/src/Err.ts +22 -0
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +268 -0
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +55 -7
- package/src/Format.ts +3 -3
- package/src/Hypergraph.ts +9 -4
- package/src/JsonSchema.ts +14 -4
- package/src/Obj.test.ts +69 -8
- package/src/Obj.ts +285 -140
- package/src/Order.ts +3 -1
- package/src/Query.test.ts +248 -15
- package/src/Query.ts +275 -24
- package/src/Ref.ts +64 -11
- package/src/Relation.test.ts +8 -2
- package/src/Relation.ts +165 -131
- package/src/SchemaRegistry.ts +5 -4
- package/src/Tag.ts +6 -5
- package/src/Type.test.ts +10 -10
- package/src/Type.ts +70 -303
- package/src/View.ts +107 -0
- package/src/hierarchy.test.ts +33 -0
- package/src/index.ts +5 -0
- package/src/internal/{annotations → Annotation}/annotations.test.ts +56 -6
- package/src/internal/{annotations → Annotation}/annotations.ts +134 -15
- package/src/internal/{annotations → Annotation}/index.ts +1 -0
- package/src/internal/{api → Annotation}/sorting.ts +2 -3
- package/src/internal/{annotations → Annotation}/util.ts +14 -1
- package/src/internal/{api/entity.ts → Entity/api.ts} +4 -2
- package/src/internal/{entities → Entity}/entity.ts +6 -4
- package/src/internal/{entities → Entity}/index.ts +2 -0
- package/src/internal/{entities → Entity}/model.ts +17 -42
- package/src/internal/{entities → Entity}/object.ts +2 -2
- package/src/internal/{entities → Entity}/relation.ts +19 -36
- package/src/internal/{api → Entity}/version.ts +3 -2
- package/src/internal/{formats → Format}/date.test.ts +1 -1
- package/src/internal/{formats → Format}/format.test.ts +1 -1
- package/src/internal/{formats → Format}/types.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/annotations.ts +3 -3
- package/src/internal/{json-schema → JsonSchema}/json-schema-type.ts +4 -4
- package/src/internal/{json-schema → JsonSchema}/json-schema.test.ts +48 -48
- package/src/internal/{json-schema → JsonSchema}/json-schema.ts +6 -4
- package/src/internal/{object → Obj}/clone.ts +3 -3
- package/src/internal/{object → Obj}/common.ts +2 -2
- package/src/internal/{object → Obj}/create-object.test.ts +4 -4
- package/src/internal/{object → Obj}/create-object.ts +5 -5
- package/src/internal/{object → Obj}/deleted.ts +2 -2
- package/src/internal/{object → Obj}/inspect.ts +2 -2
- package/src/internal/{object → Obj}/json-serializer.test.ts +31 -8
- package/src/internal/{object → Obj}/json-serializer.ts +42 -15
- package/src/internal/{object → Obj}/schema-validator.ts +1 -1
- package/src/internal/{object → Obj}/set-value.test.ts +24 -24
- package/src/internal/{object → Obj}/set-value.ts +2 -2
- package/src/internal/Obj/snapshot.ts +105 -0
- package/src/internal/{object → Obj}/typed-object.test.ts +3 -3
- package/src/internal/{object → Obj}/typed-object.ts +4 -4
- package/src/internal/Query.ts +132 -0
- package/src/internal/{ref → Ref}/ref-array.ts +1 -1
- package/src/internal/{ref → Ref}/ref.test.ts +4 -4
- package/src/internal/{ref → Ref}/ref.ts +27 -4
- package/src/internal/{schema → Type}/compose.test.ts +5 -5
- package/src/internal/{schema → Type}/compose.ts +1 -1
- package/src/internal/{schema → Type}/echo-schema.ts +11 -10
- package/src/internal/{schema → Type}/manipulation.ts +1 -1
- package/src/internal/{schema → Type}/persistent-schema.ts +10 -4
- package/src/internal/{README.md → common/README.md} +1 -1
- package/src/internal/{api → common/api}/index.ts +0 -4
- package/src/internal/common/index.ts +7 -0
- package/src/internal/{proxy → common/proxy}/change.test.ts +58 -58
- package/src/internal/{proxy → common/proxy}/handler.test.ts +2 -2
- package/src/internal/{proxy → common/proxy}/json-serializer.ts +6 -3
- package/src/internal/{proxy → common/proxy}/make-object.ts +13 -3
- package/src/internal/{proxy → common/proxy}/reactive.ts +1 -1
- package/src/internal/{proxy → common/proxy}/schema.test.ts +10 -10
- package/src/internal/{proxy → common/proxy}/typed-handler.test.ts +6 -6
- package/src/internal/{proxy → common/proxy}/typed-handler.ts +10 -3
- package/src/internal/{proxy → common/proxy}/typed-object.test.ts +4 -4
- package/src/internal/{types → common/types}/base.ts +1 -1
- package/src/internal/{types → common/types}/entity.ts +2 -2
- package/src/internal/{types → common/types}/index.ts +1 -0
- package/src/internal/{types → common/types}/meta.ts +4 -1
- package/src/internal/common/types/model-symbols.ts +69 -0
- package/src/internal/{types → common/types}/typename.ts +10 -0
- package/src/internal/{types → common/types}/version.ts +2 -3
- package/src/internal/index.ts +9 -31
- package/src/testing/api.test.ts +4 -4
- package/src/testing/test-schema.ts +20 -18
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs.map +0 -7
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HMOXCO27.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs +0 -132
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +0 -13
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs +0 -157
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs.map +0 -7
- package/dist/types/src/internal/annotations/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/index.d.ts +0 -3
- package/dist/types/src/internal/annotations/index.d.ts.map +0 -1
- package/dist/types/src/internal/annotations/util.d.ts.map +0 -1
- package/dist/types/src/internal/api/annotations.d.ts +0 -23
- package/dist/types/src/internal/api/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/api/entity.d.ts.map +0 -1
- package/dist/types/src/internal/api/index.d.ts.map +0 -1
- package/dist/types/src/internal/api/meta.d.ts.map +0 -1
- package/dist/types/src/internal/api/sorting.d.ts.map +0 -1
- package/dist/types/src/internal/api/version.d.ts.map +0 -1
- package/dist/types/src/internal/entities/entity.d.ts.map +0 -1
- package/dist/types/src/internal/entities/index.d.ts.map +0 -1
- package/dist/types/src/internal/entities/model.d.ts.map +0 -1
- package/dist/types/src/internal/entities/object.d.ts.map +0 -1
- package/dist/types/src/internal/entities/relation.d.ts.map +0 -1
- package/dist/types/src/internal/entities/util.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.d.ts.map +0 -1
- package/dist/types/src/internal/formats/date.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.d.ts.map +0 -1
- package/dist/types/src/internal/formats/format.test.d.ts.map +0 -1
- package/dist/types/src/internal/formats/index.d.ts.map +0 -1
- package/dist/types/src/internal/formats/number.d.ts.map +0 -1
- package/dist/types/src/internal/formats/object.d.ts.map +0 -1
- package/dist/types/src/internal/formats/select.d.ts.map +0 -1
- package/dist/types/src/internal/formats/string.d.ts.map +0 -1
- package/dist/types/src/internal/formats/types.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/clone.d.ts.map +0 -1
- package/dist/types/src/internal/object/common.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/create-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/deleted.d.ts.map +0 -1
- package/dist/types/src/internal/object/ids.d.ts.map +0 -1
- package/dist/types/src/internal/object/index.d.ts.map +0 -1
- package/dist/types/src/internal/object/inspect.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/object/json-serializer.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +0 -2
- package/dist/types/src/internal/object/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/object/schema-validator.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.d.ts.map +0 -1
- package/dist/types/src/internal/object/set-value.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change-context.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/change.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/errors.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/make-object.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/ownership.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/symbols.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-handler.test.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/typed-object.test.d.ts.map +0 -1
- package/dist/types/src/internal/ref/index.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref-array.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.d.ts.map +0 -1
- package/dist/types/src/internal/ref/ref.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +0 -1
- package/dist/types/src/internal/schema/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/schema/index.d.ts.map +0 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +0 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +0 -1
- package/dist/types/src/internal/types/base.d.ts.map +0 -1
- package/dist/types/src/internal/types/entity.d.ts.map +0 -1
- package/dist/types/src/internal/types/index.d.ts.map +0 -1
- package/dist/types/src/internal/types/meta.d.ts.map +0 -1
- package/dist/types/src/internal/types/typename.d.ts.map +0 -1
- package/dist/types/src/internal/types/version.d.ts.map +0 -1
- package/src/internal/api/annotations.ts +0 -60
- package/src/internal/object/snapshot.ts +0 -70
- /package/dist/types/src/internal/{annotations → Annotation}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{entities → Entity}/util.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/date.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/format.test.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/index.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/number.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/object.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/select.d.ts +0 -0
- /package/dist/types/src/internal/{formats → Format}/string.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/index.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema-normalize.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.d.ts +0 -0
- /package/dist/types/src/internal/{json-schema → JsonSchema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/clone.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/common.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/create-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/ids.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/index.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/inspect.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/json-serializer.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/schema-validator.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/set-value.test.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/snapshot.d.ts +0 -0
- /package/dist/types/src/internal/{object → Obj}/typed-object.test.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/index.d.ts +0 -0
- /package/dist/types/src/internal/{ref → Ref}/ref.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/compose.test.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/index.d.ts +0 -0
- /package/dist/types/src/internal/{schema → Type}/manipulation.d.ts +0 -0
- /package/dist/types/src/internal/{api → common/api}/meta.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change-context.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/change.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/define-hidden-property.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/errors.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/event-batch.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/index.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/json-serializer.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/make-object.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/ownership.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-types.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/proxy-utils.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/reactive-array.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema-validator.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/symbols.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-handler.test.d.ts +0 -0
- /package/dist/types/src/internal/{proxy → common/proxy}/typed-object.test.d.ts +0 -0
- /package/src/internal/{entities → Entity}/util.ts +0 -0
- /package/src/internal/{formats → Format}/date.ts +0 -0
- /package/src/internal/{formats → Format}/format.ts +0 -0
- /package/src/internal/{formats → Format}/index.ts +0 -0
- /package/src/internal/{formats → Format}/number.ts +0 -0
- /package/src/internal/{formats → Format}/object.ts +0 -0
- /package/src/internal/{formats → Format}/select.ts +0 -0
- /package/src/internal/{formats → Format}/string.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/effect-schema.test.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/index.ts +0 -0
- /package/src/internal/{json-schema → JsonSchema}/json-schema-normalize.ts +0 -0
- /package/src/internal/{object → Obj}/ids.ts +0 -0
- /package/src/internal/{object → Obj}/index.ts +0 -0
- /package/src/internal/{object → Obj}/schema-validator.test.ts +0 -0
- /package/src/internal/{ref → Ref}/index.ts +0 -0
- /package/src/internal/{schema → Type}/index.ts +0 -0
- /package/src/internal/{api → common/api}/meta.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/change-context.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/define-hidden-property.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/errors.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/event-batch.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/index.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/ownership.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-types.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/proxy-utils.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/reactive-array.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/schema-validator.ts +0 -0
- /package/src/internal/{proxy → common/proxy}/symbols.ts +0 -0
package/src/Query.ts
CHANGED
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import type * as EffectArray from 'effect/Array';
|
|
6
8
|
import type * as Schema from 'effect/Schema';
|
|
7
9
|
|
|
8
10
|
import { type QueryAST } from '@dxos/echo-protocol';
|
|
9
11
|
|
|
12
|
+
import type * as Collection from './Collection';
|
|
13
|
+
import * as Database from './Database';
|
|
14
|
+
import type * as Dataset from './Dataset';
|
|
15
|
+
import * as Feed from './Feed';
|
|
10
16
|
import * as Filter from './Filter';
|
|
11
|
-
import
|
|
17
|
+
import * as internal from './internal';
|
|
18
|
+
import * as Obj from './Obj';
|
|
12
19
|
import type * as Order from './Order';
|
|
13
20
|
import type * as Ref from './Ref';
|
|
14
|
-
import type * as
|
|
21
|
+
import type * as Relation from './Relation';
|
|
22
|
+
import type * as View from './View';
|
|
15
23
|
|
|
16
24
|
// TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
|
|
17
25
|
// TODO(dmaretskyi): Undirected relation traversals.
|
|
@@ -35,15 +43,15 @@ export interface Query<T> {
|
|
|
35
43
|
* @param filter - Filter to select the objects.
|
|
36
44
|
* @returns Query for the selected objects.
|
|
37
45
|
*/
|
|
38
|
-
select(filter: Filter.Filter<T>): Query<T>;
|
|
39
|
-
select(props: Filter.Props<T>): Query<T>;
|
|
46
|
+
'select'(filter: Filter.Filter<T>): Query<T>;
|
|
47
|
+
'select'(props: Filter.Props<T>): Query<T>;
|
|
40
48
|
|
|
41
49
|
/**
|
|
42
50
|
* Traverse an outgoing reference.
|
|
43
51
|
* @param key - Property path inside T that is a reference or optional reference.
|
|
44
52
|
* @returns Query for the target of the reference.
|
|
45
53
|
*/
|
|
46
|
-
reference<K extends RefPropKey<T>>(
|
|
54
|
+
'reference'<K extends RefPropKey<T>>(
|
|
47
55
|
key: K,
|
|
48
56
|
): Query<
|
|
49
57
|
T[K] extends Ref.Unknown
|
|
@@ -61,12 +69,12 @@ export interface Query<T> {
|
|
|
61
69
|
*/
|
|
62
70
|
// TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
|
|
63
71
|
// TODO(dmaretskyi): Ability to go through arrays of references.
|
|
64
|
-
referencedBy<S extends Schema.Schema.All>(
|
|
72
|
+
'referencedBy'<S extends Schema.Schema.All>(
|
|
65
73
|
target: S | string,
|
|
66
74
|
key: RefPropKey<Schema.Schema.Type<S>>,
|
|
67
75
|
): Query<Schema.Schema.Type<S>>;
|
|
68
|
-
referencedBy<S extends Schema.Schema.All>(target: S | string): Query<Schema.Schema.Type<S>>;
|
|
69
|
-
referencedBy(): Query<any>;
|
|
76
|
+
'referencedBy'<S extends Schema.Schema.All>(target: S | string): Query<Schema.Schema.Type<S>>;
|
|
77
|
+
'referencedBy'(): Query<any>;
|
|
70
78
|
|
|
71
79
|
/**
|
|
72
80
|
* Find relations where this object is the source.
|
|
@@ -74,8 +82,8 @@ export interface Query<T> {
|
|
|
74
82
|
* @param relation - Schema of the relation.
|
|
75
83
|
* @param predicates - Predicates to filter the relation objects.
|
|
76
84
|
*/
|
|
77
|
-
sourceOf<S extends Schema.Schema.All>(
|
|
78
|
-
relation
|
|
85
|
+
'sourceOf'<S extends Schema.Schema.All>(
|
|
86
|
+
relation?: S | string,
|
|
79
87
|
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
80
88
|
): Query<Schema.Schema.Type<S>>;
|
|
81
89
|
|
|
@@ -85,8 +93,8 @@ export interface Query<T> {
|
|
|
85
93
|
* @param relation - Schema of the relation.
|
|
86
94
|
* @param predicates - Predicates to filter the relation objects.
|
|
87
95
|
*/
|
|
88
|
-
targetOf<S extends Schema.Schema.All>(
|
|
89
|
-
relation
|
|
96
|
+
'targetOf'<S extends Schema.Schema.All>(
|
|
97
|
+
relation?: S | string,
|
|
90
98
|
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
91
99
|
): Query<Schema.Schema.Type<S>>;
|
|
92
100
|
|
|
@@ -94,13 +102,25 @@ export interface Query<T> {
|
|
|
94
102
|
* For a query for relations, get the source objects.
|
|
95
103
|
* @returns Query for the source objects.
|
|
96
104
|
*/
|
|
97
|
-
source(): Query<
|
|
105
|
+
'source'(): Query<Relation.SourceOf<T>>;
|
|
98
106
|
|
|
99
107
|
/**
|
|
100
108
|
* For a query for relations, get the target objects.
|
|
101
109
|
* @returns Query for the target objects.
|
|
102
110
|
*/
|
|
103
|
-
target(): Query<
|
|
111
|
+
'target'(): Query<Relation.TargetOf<T>>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the parent object of the current selection.
|
|
115
|
+
* @returns Query for the parent objects.
|
|
116
|
+
*/
|
|
117
|
+
'parent'(): Query<any>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get all child objects of the current selection.
|
|
121
|
+
* @returns Query for the child objects.
|
|
122
|
+
*/
|
|
123
|
+
'children'(): Query<any>;
|
|
104
124
|
|
|
105
125
|
/**
|
|
106
126
|
* Order the query results.
|
|
@@ -108,19 +128,85 @@ export interface Query<T> {
|
|
|
108
128
|
* @param order - Order to sort the results.
|
|
109
129
|
* @returns Query for the ordered results.
|
|
110
130
|
*/
|
|
111
|
-
orderBy(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
131
|
+
'orderBy'(...order: EffectArray.NonEmptyArray<Order.Order<T>>): Query<T>;
|
|
112
132
|
|
|
113
133
|
/**
|
|
114
134
|
* Limit the number of results.
|
|
115
135
|
* @param limit - Maximum number of results to return.
|
|
116
136
|
* @returns Query for the limited results.
|
|
117
137
|
*/
|
|
118
|
-
limit(limit: number): Query<T>;
|
|
138
|
+
'limit'(limit: number): Query<T>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Query from selected databases only.
|
|
142
|
+
*
|
|
143
|
+
* Example:
|
|
144
|
+
*
|
|
145
|
+
* ```ts
|
|
146
|
+
* Query.select(Filter.type(Person)).from(db);
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
150
|
+
*/
|
|
151
|
+
'from'(database: Database.Database | Database.Database[], options?: { includeFeeds?: boolean }): Query<T>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Query from selected feeds only.
|
|
155
|
+
*
|
|
156
|
+
* Example:
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* Query.select(Filter.type(Person)).from(feed);
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
'from'(feeds: Feed.Feed | Feed.Feed[]): Query<T>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Query from all accessible spaces.
|
|
167
|
+
*
|
|
168
|
+
* Example:
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* Query.select(Filter.type(Person)).from('all-accessible-spaces');
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @param options.includeFeeds [false] - Whether to include feeds in the query. Default is to query from automerge documents only.
|
|
175
|
+
*/
|
|
176
|
+
'from'(allSpaces: 'all-accessible-spaces', options?: { includeFeeds?: boolean }): Query<T>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Query from a dataset.
|
|
180
|
+
* Currently only feeds are supported.
|
|
181
|
+
*
|
|
182
|
+
* Example:
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* Query.type(Person).from(feed);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
'from'(dataset: Dataset.Dataset): Query<T>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Query from the results of another query.
|
|
192
|
+
*
|
|
193
|
+
* Example:
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* Query.select(Filter.props({ foo: 'foo' })).from(Query.select(Filter.type(Contact)).reference('org'));
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
'from'(query: Any): Query<T>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Query from a raw scope specification.
|
|
203
|
+
*/
|
|
204
|
+
'from'(scope: QueryAST.Scope): Query<T>;
|
|
119
205
|
|
|
120
206
|
/**
|
|
121
207
|
* Add options to a query.
|
|
122
208
|
*/
|
|
123
|
-
options(options: QueryAST.QueryOptions): Query<T>;
|
|
209
|
+
'options'(options: QueryAST.QueryOptions): Query<T>;
|
|
124
210
|
}
|
|
125
211
|
|
|
126
212
|
export type Any = Query<any>;
|
|
@@ -128,7 +214,7 @@ export type Any = Query<any>;
|
|
|
128
214
|
export type Type<Q extends Any> = Q extends Query<infer T> ? T : never;
|
|
129
215
|
|
|
130
216
|
class QueryClass implements Any {
|
|
131
|
-
private static variance: Any['~Query'] = {} as Any['~Query'];
|
|
217
|
+
private static 'variance': Any['~Query'] = {} as Any['~Query'];
|
|
132
218
|
|
|
133
219
|
constructor(public readonly ast: QueryAST.Query) {}
|
|
134
220
|
|
|
@@ -159,7 +245,7 @@ class QueryClass implements Any {
|
|
|
159
245
|
}
|
|
160
246
|
|
|
161
247
|
referencedBy(target?: Schema.Schema.All | string, key?: string): Any {
|
|
162
|
-
const dxn = target !== undefined ? getTypeDXNFromSpecifier(target) : null;
|
|
248
|
+
const dxn = target !== undefined ? internal.getTypeDXNFromSpecifier(target) : null;
|
|
163
249
|
return new QueryClass({
|
|
164
250
|
type: 'incoming-references',
|
|
165
251
|
anchor: this.ast,
|
|
@@ -168,21 +254,21 @@ class QueryClass implements Any {
|
|
|
168
254
|
});
|
|
169
255
|
}
|
|
170
256
|
|
|
171
|
-
sourceOf(relation
|
|
257
|
+
sourceOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
172
258
|
return new QueryClass({
|
|
173
259
|
type: 'relation',
|
|
174
260
|
anchor: this.ast,
|
|
175
261
|
direction: 'outgoing',
|
|
176
|
-
filter: Filter.type(relation, predicates).ast,
|
|
262
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
177
263
|
});
|
|
178
264
|
}
|
|
179
265
|
|
|
180
|
-
targetOf(relation
|
|
266
|
+
targetOf(relation?: Schema.Schema.All | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
181
267
|
return new QueryClass({
|
|
182
268
|
type: 'relation',
|
|
183
269
|
anchor: this.ast,
|
|
184
270
|
direction: 'incoming',
|
|
185
|
-
filter: Filter.type(relation, predicates).ast,
|
|
271
|
+
filter: relation !== undefined ? Filter.type(relation, predicates).ast : undefined,
|
|
186
272
|
});
|
|
187
273
|
}
|
|
188
274
|
|
|
@@ -202,6 +288,22 @@ class QueryClass implements Any {
|
|
|
202
288
|
});
|
|
203
289
|
}
|
|
204
290
|
|
|
291
|
+
parent(): Any {
|
|
292
|
+
return new QueryClass({
|
|
293
|
+
type: 'hierarchy-traversal',
|
|
294
|
+
anchor: this.ast,
|
|
295
|
+
direction: 'to-parent',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
children(): Any {
|
|
300
|
+
return new QueryClass({
|
|
301
|
+
type: 'hierarchy-traversal',
|
|
302
|
+
anchor: this.ast,
|
|
303
|
+
direction: 'to-children',
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
205
307
|
orderBy(...order: Order.Order<any>[]): Any {
|
|
206
308
|
return new QueryClass({
|
|
207
309
|
type: 'order',
|
|
@@ -218,6 +320,108 @@ class QueryClass implements Any {
|
|
|
218
320
|
});
|
|
219
321
|
}
|
|
220
322
|
|
|
323
|
+
from(
|
|
324
|
+
arg:
|
|
325
|
+
| Database.Database
|
|
326
|
+
| Database.Database[]
|
|
327
|
+
| Feed.Feed
|
|
328
|
+
| Feed.Feed[]
|
|
329
|
+
| Collection.Collection
|
|
330
|
+
| View.View
|
|
331
|
+
| Any
|
|
332
|
+
| QueryAST.Scope
|
|
333
|
+
| 'all-accessible-spaces',
|
|
334
|
+
options?: { includeFeeds?: boolean },
|
|
335
|
+
): Any {
|
|
336
|
+
if (arg == null) {
|
|
337
|
+
throw new TypeError(
|
|
338
|
+
'Query.from() requires a valid data source argument (database, feed, query, scope, or "all-accessible-spaces").',
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (is(arg)) {
|
|
343
|
+
return new QueryClass({
|
|
344
|
+
type: 'from',
|
|
345
|
+
query: this.ast,
|
|
346
|
+
from: { _tag: 'query', query: arg.ast },
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (arg === 'all-accessible-spaces') {
|
|
351
|
+
return new QueryClass({
|
|
352
|
+
type: 'from',
|
|
353
|
+
query: this.ast,
|
|
354
|
+
from: {
|
|
355
|
+
_tag: 'scope',
|
|
356
|
+
scope: {
|
|
357
|
+
...(options?.includeFeeds ? { allQueuesFromSpaces: true } : {}),
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (_isScope(arg)) {
|
|
364
|
+
return new QueryClass({
|
|
365
|
+
type: 'from',
|
|
366
|
+
query: this.ast,
|
|
367
|
+
from: { _tag: 'scope', scope: arg },
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const items = Array.isArray(arg) ? arg : [arg];
|
|
372
|
+
|
|
373
|
+
if (items.length > 0 && Database.isDatabase(items[0])) {
|
|
374
|
+
const databases = items as Database.Database[];
|
|
375
|
+
return new QueryClass({
|
|
376
|
+
type: 'from',
|
|
377
|
+
query: this.ast,
|
|
378
|
+
from: {
|
|
379
|
+
_tag: 'scope',
|
|
380
|
+
scope: {
|
|
381
|
+
spaceIds: databases.map((db) => db.spaceId),
|
|
382
|
+
...(options?.includeFeeds ? { allQueuesFromSpaces: true } : {}),
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (items.length > 0) {
|
|
389
|
+
const typename = Obj.getTypename(items[0] as Obj.Unknown);
|
|
390
|
+
// TODO(dmaretskyi): Support querying from views.
|
|
391
|
+
if (typename === 'org.dxos.type.view') {
|
|
392
|
+
throw new Error('Query.from(view) is not yet supported.');
|
|
393
|
+
}
|
|
394
|
+
// TODO(dmaretskyi): Support querying from collections.
|
|
395
|
+
if (typename === 'org.dxos.type.collection') {
|
|
396
|
+
throw new Error('Query.from(collection) is not yet supported.');
|
|
397
|
+
}
|
|
398
|
+
// Validate that the items are Feed.Feed instances.
|
|
399
|
+
for (const item of items) {
|
|
400
|
+
if (!Obj.instanceOf(Feed.Feed, item)) {
|
|
401
|
+
throw new TypeError(
|
|
402
|
+
`Query.from() expects Feed objects (org.dxos.type.feed), but received an object with typename '${typename ?? 'unknown'}'.`,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const feeds = items as Feed.Feed[];
|
|
409
|
+
const queueDxns = feeds.flatMap((feed) => {
|
|
410
|
+
const dxn = Feed.getQueueDxn(feed);
|
|
411
|
+
return dxn ? [dxn.toString()] : [];
|
|
412
|
+
});
|
|
413
|
+
return new QueryClass({
|
|
414
|
+
type: 'from',
|
|
415
|
+
query: this.ast,
|
|
416
|
+
from: {
|
|
417
|
+
_tag: 'scope',
|
|
418
|
+
scope: {
|
|
419
|
+
queues: queueDxns,
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
221
425
|
options(options: QueryAST.QueryOptions): Any {
|
|
222
426
|
return new QueryClass({
|
|
223
427
|
type: 'options',
|
|
@@ -256,7 +460,13 @@ export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> =
|
|
|
256
460
|
*
|
|
257
461
|
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
258
462
|
*/
|
|
259
|
-
export const type
|
|
463
|
+
export const type: {
|
|
464
|
+
<S extends Schema.Schema.All>(
|
|
465
|
+
schema: S,
|
|
466
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
467
|
+
): Query<Schema.Schema.Type<S>>;
|
|
468
|
+
(schema: string, predicates?: Filter.Props<unknown>): Query<any>;
|
|
469
|
+
} = (schema: Schema.Schema.All | string, predicates?: Filter.Props<unknown>): Any => {
|
|
260
470
|
return new QueryClass({
|
|
261
471
|
type: 'select',
|
|
262
472
|
filter: Filter.type(schema, predicates).ast,
|
|
@@ -294,3 +504,44 @@ export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
|
|
|
294
504
|
exclude: exclude.ast,
|
|
295
505
|
});
|
|
296
506
|
};
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Create a query scoped to a data source.
|
|
510
|
+
* The returned query selects everything from the source; chain `.select()` to narrow results.
|
|
511
|
+
*
|
|
512
|
+
* @param source - Data source: database, feed, 'all-accessible-spaces', or another query.
|
|
513
|
+
* @returns Query scoped to the given source.
|
|
514
|
+
*/
|
|
515
|
+
export const from = (
|
|
516
|
+
source:
|
|
517
|
+
| Database.Database
|
|
518
|
+
| Database.Database[]
|
|
519
|
+
| Feed.Feed
|
|
520
|
+
| Feed.Feed[]
|
|
521
|
+
| Any
|
|
522
|
+
| QueryAST.Scope
|
|
523
|
+
| 'all-accessible-spaces',
|
|
524
|
+
options?: { includeFeeds?: boolean },
|
|
525
|
+
): Any => {
|
|
526
|
+
const baseQuery: QueryAST.Query = {
|
|
527
|
+
type: 'select',
|
|
528
|
+
filter: Filter.everything().ast,
|
|
529
|
+
};
|
|
530
|
+
const wrapper = new QueryClass(baseQuery);
|
|
531
|
+
return wrapper.from(source as any, options);
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
const SCOPE_KEYS = new Set(['spaceIds', 'queues', 'allQueuesFromSpaces']);
|
|
535
|
+
|
|
536
|
+
/** Detect a raw Scope object (plain object with only Scope-valid keys). */
|
|
537
|
+
const _isScope = (value: unknown): value is QueryAST.Scope => {
|
|
538
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
return Object.keys(value).every((key) => SCOPE_KEYS.has(key));
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Returns a human-readable string representation of a Query AST.
|
|
546
|
+
*/
|
|
547
|
+
export const pretty = (query: Any): string => internal.prettyQuery(query.ast);
|
package/src/Ref.ts
CHANGED
|
@@ -2,42 +2,95 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
// @import-as-namespace
|
|
6
|
+
|
|
5
7
|
import * as Option from 'effect/Option';
|
|
8
|
+
import type * as Schema from 'effect/Schema';
|
|
6
9
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
10
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
11
|
+
import type * as Entity from './Entity';
|
|
12
|
+
import * as refInternal from './internal/Ref';
|
|
10
13
|
import type * as JsonSchema from './JsonSchema';
|
|
11
14
|
import type * as Obj from './Obj';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Instance type for a reference.
|
|
18
|
+
*
|
|
19
|
+
* Reference can point to any object or relation.
|
|
20
|
+
* References are lazy loaded.
|
|
21
|
+
*
|
|
22
|
+
* `ref.dxn` is the DXN of the referenced object.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const taskRef: Ref<Task> = Ref.make(task);
|
|
27
|
+
*
|
|
28
|
+
* await taskRef.load(); // Returns Promise<Task>
|
|
29
|
+
* yield* Database.load(taskRef); // Effectful version.
|
|
30
|
+
*
|
|
31
|
+
* database.makeRef(dxn); // Create a ref from a DXN.
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type Ref<T> = refInternal.Ref<T>;
|
|
35
|
+
export type Unknown = refInternal.Ref<Obj.Unknown>;
|
|
15
36
|
|
|
16
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Factory function to create a Ref schema for the given target schema.
|
|
39
|
+
* Use this in schema definitions to declare reference fields.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const Task = Schema.Struct({
|
|
44
|
+
* assignee: Ref.Ref(Person), // Creates a Ref schema
|
|
45
|
+
* }).pipe(Type.object({ typename: 'Task', version: '0.1.0' }));
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export const Ref: <S extends Schema.Schema.Any>(schema: S) => RefSchema<Schema.Schema.Type<S>> = refInternal.Ref;
|
|
49
|
+
|
|
50
|
+
export const Array = refInternal.RefArray;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* TypeScript type for a Ref schema.
|
|
54
|
+
* This is the type of the SCHEMA itself, not the runtime ref instance.
|
|
55
|
+
* For the instance type, use `Ref.Ref<T>` from the Ref module.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // Schema type annotation (rarely needed, usually inferred):
|
|
60
|
+
* const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);
|
|
61
|
+
*
|
|
62
|
+
* // Instance type annotation (use Ref.Ref instead):
|
|
63
|
+
* const refInstance: Ref.Ref<Task> = Ref.make(task);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
// TODO(dmaretskyi): Investigate if we can remove this type.
|
|
67
|
+
// Post DX-836 it will become just `Schema.Schema<Ref.Ref<T>>`.
|
|
68
|
+
// NOTE: This could be Type.Ref<T> instead, but since it going to be removed, it's better to keep it here, self-contained.
|
|
69
|
+
export interface RefSchema<T extends Entity.Unknown> extends refInternal.RefSchema<T> {}
|
|
17
70
|
|
|
18
71
|
/**
|
|
19
72
|
* Extract reference target.
|
|
20
73
|
*/
|
|
21
|
-
export type Target<R extends Unknown> = R extends Ref
|
|
74
|
+
export type Target<R extends Unknown> = R extends refInternal.Ref<infer T> ? T : never;
|
|
22
75
|
|
|
23
76
|
/**
|
|
24
77
|
* Reference resolver.
|
|
25
78
|
*/
|
|
26
|
-
export type Resolver = RefResolver;
|
|
79
|
+
export type Resolver = refInternal.RefResolver;
|
|
27
80
|
|
|
28
|
-
export const isRef: (value: unknown) => value is Unknown = Ref
|
|
81
|
+
export const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef;
|
|
29
82
|
|
|
30
|
-
export const make = Ref
|
|
83
|
+
export const make = refInternal.Ref.make;
|
|
31
84
|
|
|
32
85
|
// TODO(dmaretskyi): Consider just allowing `make` to accept DXN.
|
|
33
|
-
export const fromDXN = Ref
|
|
86
|
+
export const fromDXN = refInternal.Ref.fromDXN;
|
|
34
87
|
|
|
35
88
|
// TODO(wittjosiah): Factor out?
|
|
36
89
|
export const isRefType = (ast: SchemaAST.AST): boolean => {
|
|
37
90
|
return SchemaAST.getAnnotation<JsonSchema.JsonSchema>(ast, SchemaAST.JSONSchemaAnnotationId).pipe(
|
|
38
91
|
Option.flatMap((jsonSchema) => ('$id' in jsonSchema ? Option.some(jsonSchema) : Option.none())),
|
|
39
92
|
Option.flatMap((jsonSchema) => {
|
|
40
|
-
const { typename } = getSchemaReference(jsonSchema) ?? {};
|
|
93
|
+
const { typename } = refInternal.getSchemaReference(jsonSchema) ?? {};
|
|
41
94
|
return typename ? Option.some(true) : Option.some(false);
|
|
42
95
|
}),
|
|
43
96
|
Option.getOrElse(() => false),
|
package/src/Relation.test.ts
CHANGED
|
@@ -25,6 +25,12 @@ describe('Relation', () => {
|
|
|
25
25
|
expect(snapshot[SnapshotKindId]).toBe(Entity.Kind.Relation);
|
|
26
26
|
expect((snapshot as any)[Entity.KindId]).toBeUndefined();
|
|
27
27
|
|
|
28
|
+
expect(Relation.isSnapshot(snapshot)).toBe(true);
|
|
29
|
+
expect(Obj.isSnapshot(snapshot)).toBe(false);
|
|
30
|
+
|
|
31
|
+
expect(Relation.getSource(snapshot)).toEqual(obj1);
|
|
32
|
+
expect(Relation.getTarget(snapshot)).toEqual(obj2);
|
|
33
|
+
|
|
28
34
|
// Snapshot has same id.
|
|
29
35
|
expect(snapshot.id).toBe(rel.id);
|
|
30
36
|
});
|
|
@@ -59,8 +65,8 @@ describe('Relation', () => {
|
|
|
59
65
|
expect(Relation.getDXN(snapshot)).toBeDefined();
|
|
60
66
|
|
|
61
67
|
// getTypename - works with both.
|
|
62
|
-
expect(Relation.getTypename(rel)).toBe('example.
|
|
63
|
-
expect(Relation.getTypename(snapshot)).toBe('example.
|
|
68
|
+
expect(Relation.getTypename(rel)).toBe('com.example.type.has-manager');
|
|
69
|
+
expect(Relation.getTypename(snapshot)).toBe('com.example.type.has-manager');
|
|
64
70
|
|
|
65
71
|
// getMeta - works with both.
|
|
66
72
|
expect(Relation.getMeta(rel)).toBeDefined();
|