@dxos/echo 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731
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 +4 -4
- package/dist/lib/neutral/Annotation.mjs +27 -6
- package/dist/lib/neutral/Database.mjs +6 -11
- package/dist/lib/neutral/Entity.mjs +25 -16
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +19 -17
- package/dist/lib/neutral/Filter.mjs +13 -13
- package/dist/lib/neutral/Format.mjs +23 -3
- package/dist/lib/neutral/JsonSchema.mjs +7 -8
- package/dist/lib/neutral/Key.mjs +9 -5
- package/dist/lib/neutral/Migration.mjs +11 -10
- package/dist/lib/neutral/Obj.mjs +21 -18
- package/dist/lib/neutral/Query.mjs +17 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +10 -11
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Relation.mjs +24 -23
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Tag.mjs +17 -14
- package/dist/lib/neutral/Type.mjs +52 -26
- package/dist/lib/neutral/chunk-3DKP2EIN.mjs +31 -0
- package/dist/lib/neutral/chunk-3DKP2EIN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4BB4MFCN.mjs +154 -0
- package/dist/lib/neutral/chunk-4BB4MFCN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-PT37DG2F.mjs → chunk-4SFPZJVA.mjs} +82 -74
- package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-APHSOTIX.mjs → chunk-4Z6GET2X.mjs} +3 -3
- package/dist/lib/neutral/{chunk-APHSOTIX.mjs.map → chunk-4Z6GET2X.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-7RVZT53K.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BMB7IHGB.mjs → chunk-7OAFN3OX.mjs} +70 -57
- package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MLS7U7AT.mjs → chunk-7PRCIDHH.mjs} +41 -28
- package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZISMEVKD.mjs → chunk-BBFJWWAV.mjs} +6 -6
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZFACXBY6.mjs → chunk-BDQGMDIX.mjs} +30 -34
- package/dist/lib/neutral/chunk-BDQGMDIX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CGTI5MXO.mjs +36 -0
- package/dist/lib/neutral/chunk-CGTI5MXO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-V72DY6LU.mjs → chunk-DKLUHO4T.mjs} +1 -1
- package/dist/lib/neutral/chunk-DKLUHO4T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DMN2CKPX.mjs +93 -0
- package/dist/lib/neutral/chunk-DMN2CKPX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs → chunk-G6CFWUYH.mjs} +2 -2
- package/dist/lib/neutral/chunk-H26LSXVJ.mjs +653 -0
- package/dist/lib/neutral/chunk-H26LSXVJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-N7VOEPSV.mjs → chunk-J3MNM65T.mjs} +9 -9
- package/dist/lib/neutral/chunk-J3MNM65T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JE7AOSWF.mjs +247 -0
- package/dist/lib/neutral/chunk-JE7AOSWF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LAF3LSWI.mjs +379 -0
- package/dist/lib/neutral/chunk-LAF3LSWI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LMNRFOVB.mjs +108 -0
- package/dist/lib/neutral/chunk-LMNRFOVB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-N4B7FHQT.mjs → chunk-O6BH7EPN.mjs} +30 -3
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-Q7ZL2P5H.mjs → chunk-OIYW7R2G.mjs} +62 -46
- package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-G54OX4IX.mjs → chunk-OYUG4FHF.mjs} +527 -847
- package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-J54QMAKF.mjs → chunk-Q5FKCVBC.mjs} +64 -59
- package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-FIWO2FZK.mjs → chunk-Q62IHV2N.mjs} +12 -7
- package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SCPFDS2E.mjs → chunk-QVJDDG44.mjs} +65 -34
- package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TRPZU2HV.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-44HT3MEC.mjs → chunk-VKWOFXT2.mjs} +22 -2
- package/dist/lib/neutral/{chunk-44HT3MEC.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-APJKDGFL.mjs → chunk-ZACMEAYV.mjs} +24 -24
- package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +50 -40
- package/dist/lib/neutral/internal/index.mjs +125 -64
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +88 -99
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +108 -4
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Annotation.test.d.ts +2 -0
- package/dist/types/src/Annotation.test.d.ts.map +1 -0
- package/dist/types/src/Collection.d.ts +2 -3
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +50 -30
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +16 -6
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +89 -19
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +9 -9
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +35 -12
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +21 -8
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +13 -8
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts.map +1 -1
- package/dist/types/src/JsonSchema.d.ts +1 -1
- package/dist/types/src/JsonSchema.d.ts.map +1 -1
- package/dist/types/src/Key.d.ts +1 -1
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +15 -12
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +69 -40
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +24 -10
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +9 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +15 -8
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +131 -0
- package/dist/types/src/Registry.d.ts.map +1 -0
- package/dist/types/src/Relation.d.ts +55 -26
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +34 -0
- package/dist/types/src/Scope.d.ts.map +1 -0
- package/dist/types/src/StateMap.d.ts +32 -0
- package/dist/types/src/StateMap.d.ts.map +1 -0
- package/dist/types/src/StateMap.test.d.ts +2 -0
- package/dist/types/src/StateMap.test.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +19 -3
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/TagIndex.d.ts +36 -0
- package/dist/types/src/TagIndex.d.ts.map +1 -0
- package/dist/types/src/TagIndex.test.d.ts +2 -0
- package/dist/types/src/TagIndex.test.d.ts.map +1 -0
- package/dist/types/src/Tagging.d.ts +31 -0
- package/dist/types/src/Tagging.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +356 -95
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +1 -4
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +6 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +68 -36
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/dictionary.d.ts +24 -0
- package/dist/types/src/internal/Annotation/dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +14 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/index.d.ts +4 -2
- package/dist/types/src/internal/Annotation/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +13 -4
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +3 -3
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/entity.d.ts +72 -8
- package/dist/types/src/internal/Entity/entity.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts +10 -0
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/index.d.ts +2 -0
- package/dist/types/src/internal/Entity/index.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +18 -17
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +3 -3
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +30 -7
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-kind.d.ts +24 -0
- package/dist/types/src/internal/Entity/type-kind.d.ts.map +1 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts +25 -0
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -0
- package/dist/types/src/internal/Format/date.d.ts.map +1 -1
- package/dist/types/src/internal/Format/format.d.ts +3 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/object.d.ts +3 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +2 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +11 -12
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/index.d.ts +0 -1
- package/dist/types/src/internal/Obj/index.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts +8 -8
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/typed-object.d.ts +1 -1
- package/dist/types/src/internal/Query.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref.d.ts +29 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Type/index.d.ts +1 -2
- package/dist/types/src/internal/Type/index.d.ts.map +1 -1
- package/dist/types/src/internal/Type/manipulation.d.ts +0 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/Type/type-schema.d.ts +52 -0
- package/dist/types/src/internal/Type/type-schema.d.ts.map +1 -0
- package/dist/types/src/internal/common/api/meta.d.ts +11 -8
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts +11 -5
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +18 -2
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/base.d.ts +4 -4
- package/dist/types/src/internal/common/types/entity.d.ts +59 -2
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/index.d.ts +1 -1
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +13 -7
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +8 -4
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/typename.d.ts +7 -0
- package/dist/types/src/internal/common/types/typename.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/well-known-types.d.ts +11 -0
- package/dist/types/src/internal/common/types/well-known-types.d.ts.map +1 -0
- package/dist/types/src/internal/index.d.ts +1 -0
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +32 -38
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts +5 -3
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -23
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +151 -4
- package/src/Collection.ts +5 -9
- package/src/Database.ts +86 -61
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +116 -23
- package/src/Err.ts +4 -4
- package/src/Feed.ts +57 -40
- package/src/Filter.ts +49 -27
- package/src/Hypergraph.ts +13 -8
- package/src/Json.test.ts +4 -4
- package/src/Json.ts +7 -6
- package/src/Key.ts +1 -1
- package/src/Migration.ts +27 -19
- package/src/Obj.test.ts +19 -8
- package/src/Obj.ts +131 -70
- package/src/Query.test.ts +147 -151
- package/src/Query.ts +133 -75
- package/src/QueryResult.ts +11 -0
- package/src/Ref.ts +21 -5
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +89 -52
- package/src/Scope.ts +50 -0
- package/src/StateMap.test.ts +56 -0
- package/src/StateMap.ts +99 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +49 -6
- package/src/TagIndex.test.ts +57 -0
- package/src/TagIndex.ts +110 -0
- package/src/Tagging.ts +83 -0
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +601 -131
- package/src/View.ts +10 -19
- package/src/index.ts +6 -4
- package/src/internal/Annotation/annotations.test.ts +31 -11
- package/src/internal/Annotation/annotations.ts +122 -103
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +40 -0
- package/src/internal/Annotation/index.ts +4 -2
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +7 -7
- package/src/internal/Entity/entity.ts +196 -47
- package/src/internal/Entity/guard.ts +26 -0
- package/src/internal/Entity/index.ts +2 -0
- package/src/internal/Entity/model.ts +35 -28
- package/src/internal/Entity/object.ts +21 -5
- package/src/internal/Entity/relation.ts +68 -34
- package/src/internal/Entity/type-kind.ts +75 -0
- package/src/internal/Entity/type-uri.ts +87 -0
- package/src/internal/Entity/util.ts +10 -9
- package/src/internal/Format/date.ts +0 -4
- package/src/internal/Format/format.test.ts +21 -0
- package/src/internal/Format/index.ts +2 -3
- package/src/internal/Format/object.ts +21 -4
- package/src/internal/Format/types.ts +1 -1
- package/src/internal/JsonSchema/annotations.ts +1 -1
- package/src/internal/JsonSchema/json-schema.test.ts +54 -140
- package/src/internal/JsonSchema/json-schema.ts +44 -30
- package/src/internal/Obj/clone.ts +9 -4
- package/src/internal/Obj/create-object.test.ts +12 -10
- package/src/internal/Obj/create-object.ts +67 -22
- package/src/internal/Obj/index.ts +0 -1
- package/src/internal/Obj/inspect.ts +4 -3
- package/src/internal/Obj/json-serializer.test.ts +100 -21
- package/src/internal/Obj/json-serializer.ts +93 -38
- package/src/internal/Obj/set-value.test.ts +7 -30
- package/src/internal/Obj/snapshot.ts +11 -4
- package/src/internal/Obj/typed-object.test.ts +9 -11
- package/src/internal/Obj/typed-object.ts +1 -1
- package/src/internal/Query.ts +14 -11
- package/src/internal/Ref/ref-array.ts +3 -3
- package/src/internal/Ref/ref.test.ts +17 -26
- package/src/internal/Ref/ref.ts +107 -59
- package/src/internal/Type/compose.test.ts +3 -1
- package/src/internal/Type/index.ts +1 -2
- package/src/internal/Type/manipulation.ts +0 -25
- package/src/internal/Type/type-schema.ts +60 -0
- package/src/internal/common/README.md +1 -1
- package/src/internal/common/api/meta.ts +16 -14
- package/src/internal/common/proxy/change.test.ts +35 -27
- package/src/internal/common/proxy/handler.test.ts +1 -1
- package/src/internal/common/proxy/json-serializer.ts +26 -16
- package/src/internal/common/proxy/make-object.ts +43 -20
- package/src/internal/common/proxy/ownership.ts +2 -2
- package/src/internal/common/proxy/schema.test.ts +48 -86
- package/src/internal/common/proxy/typed-handler.test.ts +12 -11
- package/src/internal/common/proxy/typed-handler.ts +71 -9
- package/src/internal/common/proxy/typed-object.test.ts +15 -27
- package/src/internal/common/types/base.ts +4 -4
- package/src/internal/common/types/entity.ts +80 -1
- package/src/internal/common/types/index.ts +6 -1
- package/src/internal/common/types/meta.ts +37 -14
- package/src/internal/common/types/model-symbols.ts +16 -4
- package/src/internal/common/types/typename.ts +39 -3
- package/src/internal/common/types/well-known-types.ts +15 -0
- package/src/internal/index.ts +5 -0
- package/src/testing/api.test.ts +15 -9
- package/src/testing/test-data.ts +24 -24
- package/src/testing/test-schema.ts +22 -58
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/Extension.mjs +0 -18
- package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
- package/dist/lib/neutral/chunk-5SL5LDLD.mjs +0 -47
- package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7RVZT53K.mjs.map +0 -7
- package/dist/lib/neutral/chunk-APJKDGFL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BICZKPQG.mjs +0 -7
- package/dist/lib/neutral/chunk-BICZKPQG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BMB7IHGB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-G54OX4IX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +0 -50
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +0 -7
- package/dist/lib/neutral/chunk-I2DARWPX.mjs +0 -128
- package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J54QMAKF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MGSQGHOD.mjs +0 -206
- package/dist/lib/neutral/chunk-MGSQGHOD.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MLS7U7AT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-N4B7FHQT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-N7VOEPSV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PSZBLH53.mjs +0 -81
- package/dist/lib/neutral/chunk-PSZBLH53.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PT37DG2F.mjs.map +0 -7
- package/dist/lib/neutral/chunk-Q2KKKJSV.mjs +0 -56
- package/dist/lib/neutral/chunk-Q2KKKJSV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-Q7ZL2P5H.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SCPFDS2E.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TNBK56IN.mjs +0 -350
- package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TRPZU2HV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-V72DY6LU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZFACXBY6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZISMEVKD.mjs.map +0 -7
- package/dist/types/src/Extension.d.ts +0 -80
- package/dist/types/src/Extension.d.ts.map +0 -1
- package/dist/types/src/Extension.test.d.ts +0 -2
- package/dist/types/src/Extension.test.d.ts.map +0 -1
- package/dist/types/src/SchemaRegistry.d.ts +0 -84
- package/dist/types/src/SchemaRegistry.d.ts.map +0 -1
- package/dist/types/src/internal/Obj/ids.d.ts +0 -6
- package/dist/types/src/internal/Obj/ids.d.ts.map +0 -1
- package/dist/types/src/internal/Type/echo-schema.d.ts +0 -181
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +0 -1
- package/dist/types/src/internal/Type/persistent-schema.d.ts +0 -20
- package/dist/types/src/internal/Type/persistent-schema.d.ts.map +0 -1
- package/src/Extension.test.ts +0 -235
- package/src/Extension.ts +0 -122
- package/src/SchemaRegistry.ts +0 -106
- package/src/internal/Obj/ids.ts +0 -12
- package/src/internal/Type/echo-schema.ts +0 -423
- package/src/internal/Type/persistent-schema.ts +0 -33
- /package/dist/lib/neutral/{Extension.mjs.map → Registry.mjs.map} +0 -0
- /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Scope.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-QRZ2I3ZM.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
package/src/Query.ts
CHANGED
|
@@ -19,6 +19,8 @@ import * as Obj from './Obj';
|
|
|
19
19
|
import type * as Order from './Order';
|
|
20
20
|
import type * as Ref from './Ref';
|
|
21
21
|
import type * as Relation from './Relation';
|
|
22
|
+
// eslint-disable-next-line @dxos/rules/import-as-namespace
|
|
23
|
+
import type * as Type$ from './Type';
|
|
22
24
|
import type * as View from './View';
|
|
23
25
|
|
|
24
26
|
// TODO(dmaretskyi): Split up into interfaces for objects and relations so they can have separate verbs.
|
|
@@ -69,11 +71,11 @@ export interface Query<T> {
|
|
|
69
71
|
*/
|
|
70
72
|
// TODO(dmaretskyi): any way to enforce `Ref.Target<Schema.Schema.Type<S>[key]> == T`?
|
|
71
73
|
// TODO(dmaretskyi): Ability to go through arrays of references.
|
|
72
|
-
'referencedBy'<S extends
|
|
74
|
+
'referencedBy'<S extends Type$.AnyEntity>(
|
|
73
75
|
target: S | string,
|
|
74
|
-
key: RefPropKey<
|
|
75
|
-
): Query<
|
|
76
|
-
'referencedBy'<S extends
|
|
76
|
+
key: RefPropKey<Type$.InstanceType<S>>,
|
|
77
|
+
): Query<Type$.InstanceType<S>>;
|
|
78
|
+
'referencedBy'<S extends Type$.AnyEntity>(target: S | string): Query<Type$.InstanceType<S>>;
|
|
77
79
|
'referencedBy'(): Query<any>;
|
|
78
80
|
|
|
79
81
|
/**
|
|
@@ -82,21 +84,21 @@ export interface Query<T> {
|
|
|
82
84
|
* @param relation - Schema of the relation.
|
|
83
85
|
* @param predicates - Predicates to filter the relation objects.
|
|
84
86
|
*/
|
|
85
|
-
'sourceOf'<
|
|
86
|
-
relation?:
|
|
87
|
-
predicates?: Filter.Props<
|
|
88
|
-
): Query<
|
|
87
|
+
'sourceOf'<R extends Type$.AnyRelation>(
|
|
88
|
+
relation?: R | string,
|
|
89
|
+
predicates?: Filter.Props<Type$.InstanceType<R>>,
|
|
90
|
+
): Query<Type$.InstanceType<R>>;
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* Find relations where this object is the target.
|
|
92
94
|
* @returns Query for the relation objects.
|
|
93
|
-
* @param relation -
|
|
95
|
+
* @param relation - Type entity of the relation.
|
|
94
96
|
* @param predicates - Predicates to filter the relation objects.
|
|
95
97
|
*/
|
|
96
|
-
'targetOf'<
|
|
97
|
-
relation?:
|
|
98
|
-
predicates?: Filter.Props<
|
|
99
|
-
): Query<
|
|
98
|
+
'targetOf'<R extends Type$.AnyRelation>(
|
|
99
|
+
relation?: R | string,
|
|
100
|
+
predicates?: Filter.Props<Type$.InstanceType<R>>,
|
|
101
|
+
): Query<Type$.InstanceType<R>>;
|
|
100
102
|
|
|
101
103
|
/**
|
|
102
104
|
* For a query for relations, get the source objects.
|
|
@@ -199,9 +201,20 @@ export interface Query<T> {
|
|
|
199
201
|
'from'(query: Any): Query<T>;
|
|
200
202
|
|
|
201
203
|
/**
|
|
202
|
-
* Query from
|
|
204
|
+
* Query from one or more raw scopes.
|
|
205
|
+
*
|
|
206
|
+
* Use the {@link Scope} constructors rather than raw tagged objects:
|
|
207
|
+
*
|
|
208
|
+
* ```ts
|
|
209
|
+
* Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry());
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
'from'(...scopes: QueryAST.Scope[]): Query<T>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Query from a raw scope or array of scopes.
|
|
203
216
|
*/
|
|
204
|
-
'from'(scope: QueryAST.Scope): Query<T>;
|
|
217
|
+
'from'(scope: QueryAST.Scope | QueryAST.Scope[]): Query<T>;
|
|
205
218
|
|
|
206
219
|
/**
|
|
207
220
|
* Add options to a query.
|
|
@@ -249,17 +262,17 @@ class QueryClass implements Any {
|
|
|
249
262
|
});
|
|
250
263
|
}
|
|
251
264
|
|
|
252
|
-
referencedBy(target?:
|
|
253
|
-
const
|
|
265
|
+
referencedBy(target?: Type$.AnyEntity | string, key?: string): Any {
|
|
266
|
+
const uri = target !== undefined ? internal.getTypeURIFromSpecifier(target) : null;
|
|
254
267
|
return new QueryClass({
|
|
255
268
|
type: 'incoming-references',
|
|
256
269
|
anchor: this.ast,
|
|
257
270
|
property: key ?? null,
|
|
258
|
-
typename:
|
|
271
|
+
typename: uri ?? null,
|
|
259
272
|
});
|
|
260
273
|
}
|
|
261
274
|
|
|
262
|
-
sourceOf(relation?:
|
|
275
|
+
sourceOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
263
276
|
return new QueryClass({
|
|
264
277
|
type: 'relation',
|
|
265
278
|
anchor: this.ast,
|
|
@@ -268,7 +281,7 @@ class QueryClass implements Any {
|
|
|
268
281
|
});
|
|
269
282
|
}
|
|
270
283
|
|
|
271
|
-
targetOf(relation?:
|
|
284
|
+
targetOf(relation?: Type$.AnyRelation | string, predicates?: Filter.Props<unknown> | undefined): Any {
|
|
272
285
|
return new QueryClass({
|
|
273
286
|
type: 'relation',
|
|
274
287
|
anchor: this.ast,
|
|
@@ -326,18 +339,48 @@ class QueryClass implements Any {
|
|
|
326
339
|
}
|
|
327
340
|
|
|
328
341
|
from(
|
|
329
|
-
|
|
330
|
-
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
...args:
|
|
343
|
+
| [
|
|
344
|
+
(
|
|
345
|
+
| Database.Database
|
|
346
|
+
| Database.Database[]
|
|
347
|
+
| Feed.Feed
|
|
348
|
+
| Feed.Feed[]
|
|
349
|
+
| Collection.Collection
|
|
350
|
+
| View.View
|
|
351
|
+
| Any
|
|
352
|
+
| QueryAST.Scope
|
|
353
|
+
| QueryAST.Scope[]
|
|
354
|
+
| 'all-accessible-spaces'
|
|
355
|
+
),
|
|
356
|
+
{ includeFeeds?: boolean }?,
|
|
357
|
+
]
|
|
358
|
+
| QueryAST.Scope[]
|
|
340
359
|
): Any {
|
|
360
|
+
// Variadic raw scopes: `.from(Scope.space(), Scope.registry())`.
|
|
361
|
+
if (args.length > 1 && args.every(_isRawScope)) {
|
|
362
|
+
return new QueryClass({
|
|
363
|
+
type: 'from',
|
|
364
|
+
query: this.ast,
|
|
365
|
+
from: { _tag: 'scope', scopes: args as QueryAST.Scope[] },
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const [arg, options] = args as [
|
|
370
|
+
(
|
|
371
|
+
| Database.Database
|
|
372
|
+
| Database.Database[]
|
|
373
|
+
| Feed.Feed
|
|
374
|
+
| Feed.Feed[]
|
|
375
|
+
| Collection.Collection
|
|
376
|
+
| View.View
|
|
377
|
+
| Any
|
|
378
|
+
| QueryAST.Scope
|
|
379
|
+
| QueryAST.Scope[]
|
|
380
|
+
| 'all-accessible-spaces'
|
|
381
|
+
),
|
|
382
|
+
{ includeFeeds?: boolean }?,
|
|
383
|
+
];
|
|
341
384
|
if (arg == null) {
|
|
342
385
|
throw new TypeError(
|
|
343
386
|
'Query.from() requires a valid data source argument (database, feed, query, scope, or "all-accessible-spaces").',
|
|
@@ -356,20 +399,23 @@ class QueryClass implements Any {
|
|
|
356
399
|
return new QueryClass({
|
|
357
400
|
type: 'from',
|
|
358
401
|
query: this.ast,
|
|
359
|
-
from: {
|
|
360
|
-
_tag: 'scope',
|
|
361
|
-
scope: {
|
|
362
|
-
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
363
|
-
},
|
|
364
|
-
},
|
|
402
|
+
from: { _tag: 'scope', scopes: [] },
|
|
365
403
|
});
|
|
366
404
|
}
|
|
367
405
|
|
|
368
|
-
|
|
406
|
+
// Raw scope(s): tagged union objects with _tag 'space' | 'feed' | 'registry'.
|
|
407
|
+
if (Array.isArray(arg) && arg.every(_isRawScope)) {
|
|
408
|
+
return new QueryClass({
|
|
409
|
+
type: 'from',
|
|
410
|
+
query: this.ast,
|
|
411
|
+
from: { _tag: 'scope', scopes: arg as QueryAST.Scope[] },
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
if (_isRawScope(arg)) {
|
|
369
415
|
return new QueryClass({
|
|
370
416
|
type: 'from',
|
|
371
417
|
query: this.ast,
|
|
372
|
-
from: { _tag: 'scope',
|
|
418
|
+
from: { _tag: 'scope', scopes: [arg] },
|
|
373
419
|
});
|
|
374
420
|
}
|
|
375
421
|
|
|
@@ -382,10 +428,11 @@ class QueryClass implements Any {
|
|
|
382
428
|
query: this.ast,
|
|
383
429
|
from: {
|
|
384
430
|
_tag: 'scope',
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
431
|
+
scopes: databases.map((db) => ({
|
|
432
|
+
_tag: 'space' as const,
|
|
433
|
+
spaceId: db.spaceId,
|
|
434
|
+
...(options?.includeFeeds ? { includeAllFeeds: true } : {}),
|
|
435
|
+
})),
|
|
389
436
|
},
|
|
390
437
|
});
|
|
391
438
|
}
|
|
@@ -411,24 +458,19 @@ class QueryClass implements Any {
|
|
|
411
458
|
}
|
|
412
459
|
|
|
413
460
|
const feedItems = items as Feed.Feed[];
|
|
414
|
-
const
|
|
415
|
-
const
|
|
416
|
-
if (!
|
|
461
|
+
const feedScopes = feedItems.map((feed) => {
|
|
462
|
+
const uri = Feed.getQueueUri(feed);
|
|
463
|
+
if (!uri) {
|
|
417
464
|
throw new TypeError(
|
|
418
|
-
`Query.from() expects persisted Feed objects with a queue
|
|
465
|
+
`Query.from() expects persisted Feed objects with a queue URI; got feed without a space (id=${Obj.getURI(feed)}).`,
|
|
419
466
|
);
|
|
420
467
|
}
|
|
421
|
-
return
|
|
468
|
+
return { _tag: 'feed' as const, feedUri: String(uri) };
|
|
422
469
|
});
|
|
423
470
|
return new QueryClass({
|
|
424
471
|
type: 'from',
|
|
425
472
|
query: this.ast,
|
|
426
|
-
from: {
|
|
427
|
-
_tag: 'scope',
|
|
428
|
-
scope: {
|
|
429
|
-
feeds: feedDXNs,
|
|
430
|
-
},
|
|
431
|
-
},
|
|
473
|
+
from: { _tag: 'scope', scopes: feedScopes },
|
|
432
474
|
});
|
|
433
475
|
}
|
|
434
476
|
|
|
@@ -486,15 +528,21 @@ export const select = <F extends Filter.Any>(filter: F): Query<Filter.Type<F>> =
|
|
|
486
528
|
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
487
529
|
*/
|
|
488
530
|
export const type: {
|
|
489
|
-
<
|
|
531
|
+
<T extends Type$.AnyEntity>(type: T, predicates?: Filter.Props<Type$.InstanceType<T>>): Query<Type$.InstanceType<T>>;
|
|
532
|
+
// Brand-narrowed schema overload — only well-known unknown schemas pass.
|
|
533
|
+
<S extends internal.UnknownTypeSchema<any, any>>(
|
|
490
534
|
schema: S,
|
|
491
535
|
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
492
536
|
): Query<Schema.Schema.Type<S>>;
|
|
537
|
+
<S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(
|
|
538
|
+
union: S,
|
|
539
|
+
predicates?: Filter.Props<Schema.Schema.Type<S>>,
|
|
540
|
+
): Query<Schema.Schema.Type<S>>;
|
|
493
541
|
(schema: string, predicates?: Filter.Props<unknown>): Query<any>;
|
|
494
|
-
} = (
|
|
542
|
+
} = (type: Type$.AnyEntity | string, predicates?: Filter.Props<unknown>): Any => {
|
|
495
543
|
return new QueryClass({
|
|
496
544
|
type: 'select',
|
|
497
|
-
filter: Filter.type(
|
|
545
|
+
filter: Filter.type(type, predicates).ast,
|
|
498
546
|
});
|
|
499
547
|
};
|
|
500
548
|
|
|
@@ -538,32 +586,42 @@ export const without = <T>(source: Query<T>, exclude: Query<T>): Query<T> => {
|
|
|
538
586
|
* @returns Query scoped to the given source.
|
|
539
587
|
*/
|
|
540
588
|
export const from = (
|
|
541
|
-
|
|
542
|
-
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
589
|
+
...args:
|
|
590
|
+
| [
|
|
591
|
+
(
|
|
592
|
+
| Database.Database
|
|
593
|
+
| Database.Database[]
|
|
594
|
+
| Feed.Feed
|
|
595
|
+
| Feed.Feed[]
|
|
596
|
+
| Any
|
|
597
|
+
| QueryAST.Scope
|
|
598
|
+
| QueryAST.Scope[]
|
|
599
|
+
| 'all-accessible-spaces'
|
|
600
|
+
),
|
|
601
|
+
{ includeFeeds?: boolean }?,
|
|
602
|
+
]
|
|
603
|
+
| QueryAST.Scope[]
|
|
550
604
|
): Any => {
|
|
551
605
|
const baseQuery: QueryAST.Query = {
|
|
552
606
|
type: 'select',
|
|
553
607
|
filter: Filter.everything().ast,
|
|
554
608
|
};
|
|
555
609
|
const wrapper = new QueryClass(baseQuery);
|
|
556
|
-
return wrapper.from
|
|
610
|
+
return (wrapper.from as (...args: unknown[]) => Any)(...args);
|
|
557
611
|
};
|
|
558
612
|
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
/** Detect a raw Scope
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
613
|
+
const SCOPE_TAGS = new Set<string>(['space', 'feed', 'registry']);
|
|
614
|
+
|
|
615
|
+
/** Detect a raw Scope tagged-union object. */
|
|
616
|
+
const _isRawScope = (value: unknown): value is QueryAST.Scope => {
|
|
617
|
+
return (
|
|
618
|
+
typeof value === 'object' &&
|
|
619
|
+
value !== null &&
|
|
620
|
+
!Array.isArray(value) &&
|
|
621
|
+
'_tag' in value &&
|
|
622
|
+
typeof value._tag === 'string' &&
|
|
623
|
+
SCOPE_TAGS.has(value._tag)
|
|
624
|
+
);
|
|
567
625
|
};
|
|
568
626
|
|
|
569
627
|
/**
|
package/src/QueryResult.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
|
|
5
8
|
import { type CleanupFn } from '@dxos/async';
|
|
6
9
|
|
|
7
10
|
import type * as Entity from './Entity';
|
|
@@ -104,3 +107,11 @@ export interface QueryResult<T> {
|
|
|
104
107
|
*/
|
|
105
108
|
subscribe(callback?: (query: QueryResult<T>) => void, opts?: SubscriptionOptions): CleanupFn;
|
|
106
109
|
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Effect that returns a QueryResult when evaluated, but also has shorthand methods for running the query or getting the first result.
|
|
113
|
+
*/
|
|
114
|
+
export interface QueryResultEffect<T, E, R> extends Effect.Effect<QueryResult<T>, E, R> {
|
|
115
|
+
run: Effect.Effect<T[], E, R>;
|
|
116
|
+
first: Effect.Effect<Option.Option<T>, E, R>;
|
|
117
|
+
}
|
package/src/Ref.ts
CHANGED
|
@@ -8,10 +8,15 @@ import * as Option from 'effect/Option';
|
|
|
8
8
|
import type * as Schema from 'effect/Schema';
|
|
9
9
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
10
10
|
|
|
11
|
+
import { type URI } from '@dxos/keys';
|
|
12
|
+
|
|
11
13
|
import type * as Entity from './Entity';
|
|
14
|
+
import type * as internal from './internal';
|
|
12
15
|
import * as refInternal from './internal/Ref';
|
|
13
16
|
import type * as JsonSchema from './JsonSchema';
|
|
14
17
|
import type * as Obj from './Obj';
|
|
18
|
+
// eslint-disable-next-line @dxos/rules/import-as-namespace
|
|
19
|
+
import type * as TypeNs from './Type';
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* Instance type for a reference.
|
|
@@ -42,10 +47,21 @@ export type Unknown = refInternal.Ref<Obj.Unknown>;
|
|
|
42
47
|
* ```ts
|
|
43
48
|
* const Task = Schema.Struct({
|
|
44
49
|
* assignee: Ref.Ref(Person), // Creates a Ref schema
|
|
45
|
-
* }).pipe(Type.
|
|
50
|
+
* }).pipe(Type.makeObject(DXN.make('com.example.type.task', '0.1.0')));
|
|
46
51
|
* ```
|
|
47
52
|
*/
|
|
48
|
-
export const Ref:
|
|
53
|
+
export const Ref: {
|
|
54
|
+
<S extends TypeNs.AnyObj | TypeNs.AnyRelation>(type: S): RefSchema<TypeNs.InstanceType<S> & Obj.Unknown>;
|
|
55
|
+
|
|
56
|
+
// `Type.Type` entities (the meta-schema kind) can be referenced too — e.g. a
|
|
57
|
+
// trigger that points to a stored function/workflow definition.
|
|
58
|
+
<T extends TypeNs.Type<any>>(type: T): RefSchema<TypeNs.InstanceType<T>>;
|
|
59
|
+
|
|
60
|
+
// Schema-side overload for the well-known "any object" / "any relation" schemas.
|
|
61
|
+
// Other raw `Schema.Schema` values are intentionally rejected — callers should
|
|
62
|
+
// pass a `Type.Type` entity instead.
|
|
63
|
+
<S extends internal.UnknownTypeSchema<any, any>>(schema: S): RefSchema<Schema.Schema.Type<S> & Obj.Unknown>;
|
|
64
|
+
} = refInternal.Ref as any;
|
|
49
65
|
|
|
50
66
|
export const Array = refInternal.RefArray;
|
|
51
67
|
|
|
@@ -82,10 +98,10 @@ export const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef
|
|
|
82
98
|
|
|
83
99
|
export const make = refInternal.Ref.make;
|
|
84
100
|
|
|
85
|
-
// TODO(dmaretskyi): Consider just allowing `make` to accept
|
|
86
|
-
export const
|
|
101
|
+
// TODO(dmaretskyi): Consider just allowing `make` to accept URI.
|
|
102
|
+
export const fromURI = (uri: URI.URI): refInternal.Ref<any> => refInternal.Ref.fromURI(uri);
|
|
87
103
|
|
|
88
|
-
export const
|
|
104
|
+
export const hasEntityId = refInternal.Ref.hasEntityId;
|
|
89
105
|
|
|
90
106
|
// TODO(wittjosiah): Factor out?
|
|
91
107
|
export const isRefType = (ast: SchemaAST.AST): boolean => {
|
package/src/Registry.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Copyright 2026 DXOS.org
|
|
2
|
+
|
|
3
|
+
// @import-as-namespace
|
|
4
|
+
|
|
5
|
+
import * as Context from 'effect/Context';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { type ReadOnlyEvent } from '@dxos/async';
|
|
9
|
+
|
|
10
|
+
import type * as Database from './Database';
|
|
11
|
+
import * as Entity from './Entity';
|
|
12
|
+
import type * as Filter from './Filter';
|
|
13
|
+
import type * as Query from './Query';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Identifier denoting an ECHO Registry.
|
|
17
|
+
*/
|
|
18
|
+
export const TypeId = Symbol.for('@dxos/echo/Registry');
|
|
19
|
+
export type TypeId = typeof TypeId;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Composable, in-memory registry of keyed ECHO entities.
|
|
23
|
+
*
|
|
24
|
+
* Entities are stored by id and queried via the standard ECHO Query API.
|
|
25
|
+
* A registry may delegate to an optional upstream registry: results from the local
|
|
26
|
+
* registry take precedence and upstream results fill in anything not found locally.
|
|
27
|
+
*
|
|
28
|
+
* Intended use cases include caches of schemas, operations, blueprints, routines, plugins,
|
|
29
|
+
* etc., sourced from 3rd-party plugins, local code, or local space objects.
|
|
30
|
+
*
|
|
31
|
+
* Types (schema-definition entities produced by `Type.makeObject` / `Type.makeRelation`) are
|
|
32
|
+
* stored the same way as any other entity — via `add()`. Use `list().filter(Type.isType)` to
|
|
33
|
+
* retrieve them.
|
|
34
|
+
*
|
|
35
|
+
* Scope: a Registry is independent of any ECHO space or Hypergraph — it is a process-local,
|
|
36
|
+
* in-memory cache. Wire one per space (e.g. as a Layer scoped to the space's Effect runtime)
|
|
37
|
+
* or share a single instance across spaces depending on the use case.
|
|
38
|
+
*
|
|
39
|
+
* The concrete implementation (and the `makeRegistry` / `registryLayer` factories) lives in
|
|
40
|
+
* `@dxos/echo-db`; this module declares only the interface so that the `@dxos/echo` API surface
|
|
41
|
+
* stays free of query-matching dependencies.
|
|
42
|
+
*/
|
|
43
|
+
export interface Registry {
|
|
44
|
+
readonly [TypeId]: TypeId;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Stable per-instance identifier. Used to key process-local resources (e.g. memoized
|
|
48
|
+
* reactive atoms) to a specific registry instance, analogous to {@link Database.spaceId}.
|
|
49
|
+
*/
|
|
50
|
+
readonly id: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Fires whenever local registry contents change (add, remove, or clear).
|
|
54
|
+
*/
|
|
55
|
+
readonly changed: ReadOnlyEvent<void>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* All locally-stored entities.
|
|
59
|
+
* Does not include upstream entities — use {@link list} for that.
|
|
60
|
+
*/
|
|
61
|
+
readonly local: readonly Entity.Unknown[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Add or replace one or more entities in the local registry.
|
|
65
|
+
* Existing entries with the same id are replaced.
|
|
66
|
+
* Also indexes type entities by DXN for fast lookup.
|
|
67
|
+
*/
|
|
68
|
+
add(entities: readonly Entity.Unknown[]): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Remove an entity by id from the local registry.
|
|
72
|
+
* @returns true if an entity was removed, false if it was not found.
|
|
73
|
+
*/
|
|
74
|
+
remove(id: string): boolean;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Remove all locally-stored entities.
|
|
78
|
+
* Does not affect the upstream registry.
|
|
79
|
+
*/
|
|
80
|
+
clear(): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get an entity by id.
|
|
84
|
+
* Searches the local registry first, then falls back to the upstream registry.
|
|
85
|
+
*/
|
|
86
|
+
get(id: string): Entity.Unknown | undefined;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get an entity by one of its addressing URIs — a type entity by its typename DXN (or, when
|
|
90
|
+
* persisted, its identifier EID), a keyed entity by its `dxn:<key>[:<version>]`. Accepts legacy
|
|
91
|
+
* DXN forms (normalized internally). Searches the local registry first, then falls back to the
|
|
92
|
+
* upstream registry. Narrow the result with `Type.isType` when a type entity is required.
|
|
93
|
+
*/
|
|
94
|
+
getByURI(uri: string): Entity.Unknown | undefined;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* List all entities.
|
|
98
|
+
* Local entities take precedence over upstream entities with the same id.
|
|
99
|
+
*/
|
|
100
|
+
list(): Entity.Unknown[];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Run an ECHO query against the registry's entities (implements {@link Database.Queryable}).
|
|
104
|
+
*
|
|
105
|
+
* Matching happens in-memory over {@link list}. Scope (`from`) clauses are unwrapped and
|
|
106
|
+
* ignored — a direct registry query always targets the registry's own entities. The primary
|
|
107
|
+
* way to query registry contents is still through the database (`db.query(...).from(Scope.registry())`),
|
|
108
|
+
* which fans the database and registry together; this method is for querying a registry directly.
|
|
109
|
+
*
|
|
110
|
+
* Only locally-evaluable AST nodes are supported: `select`, `filter`, `limit`, `from`, `options`,
|
|
111
|
+
* and boolean combinators. Server-side concerns (order, traversal, text/timestamp filters) throw.
|
|
112
|
+
*/
|
|
113
|
+
query: Database.QueryFn;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Type guard for {@link Registry}.
|
|
118
|
+
*/
|
|
119
|
+
export const isRegistry = (obj: unknown): obj is Registry =>
|
|
120
|
+
obj != null && typeof obj === 'object' && TypeId in obj && (obj as { [TypeId]?: unknown })[TypeId] === TypeId;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Options for the registry factory (`makeRegistry` in `@dxos/echo-db`).
|
|
124
|
+
*/
|
|
125
|
+
export type Options = {
|
|
126
|
+
/**
|
|
127
|
+
* Optional upstream registry. Queries fall back to upstream when an entity
|
|
128
|
+
* is not present in the local registry.
|
|
129
|
+
*/
|
|
130
|
+
upstream?: Registry;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Initial set of entities to seed the local registry with.
|
|
134
|
+
*/
|
|
135
|
+
initial?: readonly Entity.Unknown[];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Effect Context tag for {@link Registry}.
|
|
140
|
+
* Use this to inject a registry into Effect-based code.
|
|
141
|
+
*/
|
|
142
|
+
export class Service extends Context.Tag('@dxos/echo/Registry/Service')<Service, Registry>() {}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Executes a query against the registry and returns the results.
|
|
146
|
+
* Analogous to {@link Database.runQuery} for the in-process registry.
|
|
147
|
+
*/
|
|
148
|
+
export const runQuery: {
|
|
149
|
+
<Q extends Query.Any>(query: Q): Effect.Effect<Query.Type<Q>[], never, Service>;
|
|
150
|
+
<F extends Filter.Any>(filter: F): Effect.Effect<Filter.Type<F>[], never, Service>;
|
|
151
|
+
} = (queryOrFilter: Query.Any | Filter.Any) =>
|
|
152
|
+
Effect.gen(function* () {
|
|
153
|
+
const registry = yield* Service;
|
|
154
|
+
return (yield* Effect.promise(() => registry.query(queryOrFilter as any).run())) as any;
|
|
155
|
+
});
|
package/src/Relation.test.ts
CHANGED
|
@@ -44,13 +44,13 @@ describe('Relation', () => {
|
|
|
44
44
|
});
|
|
45
45
|
const snapshot = Relation.getSnapshot(rel);
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
expect(Relation.
|
|
49
|
-
expect(Relation.
|
|
47
|
+
// getSourceURI - works with both.
|
|
48
|
+
expect(Relation.getSourceURI(rel)).toBeDefined();
|
|
49
|
+
expect(Relation.getSourceURI(snapshot)).toBeDefined();
|
|
50
50
|
|
|
51
|
-
//
|
|
52
|
-
expect(Relation.
|
|
53
|
-
expect(Relation.
|
|
51
|
+
// getTargetURI - works with both.
|
|
52
|
+
expect(Relation.getTargetURI(rel)).toBeDefined();
|
|
53
|
+
expect(Relation.getTargetURI(snapshot)).toBeDefined();
|
|
54
54
|
|
|
55
55
|
// getSource - works with both.
|
|
56
56
|
expect(Relation.getSource(rel)).toBeDefined();
|
|
@@ -61,12 +61,12 @@ describe('Relation', () => {
|
|
|
61
61
|
expect(Relation.getTarget(snapshot)).toBeDefined();
|
|
62
62
|
|
|
63
63
|
// getDXN - works with both.
|
|
64
|
-
expect(Relation.
|
|
65
|
-
expect(Relation.
|
|
64
|
+
expect(Relation.getURI(rel)).toBeDefined();
|
|
65
|
+
expect(Relation.getURI(snapshot)).toBeDefined();
|
|
66
66
|
|
|
67
67
|
// getTypename - works with both.
|
|
68
|
-
expect(Relation.getTypename(rel)).toBe('com.example.type.
|
|
69
|
-
expect(Relation.getTypename(snapshot)).toBe('com.example.type.
|
|
68
|
+
expect(Relation.getTypename(rel)).toBe('com.example.type.hasManager');
|
|
69
|
+
expect(Relation.getTypename(snapshot)).toBe('com.example.type.hasManager');
|
|
70
70
|
|
|
71
71
|
// getMeta - works with both.
|
|
72
72
|
expect(Relation.getMeta(rel)).toBeDefined();
|