@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/Entity.ts
CHANGED
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
// @import-as-namespace
|
|
6
6
|
|
|
7
|
+
import * as Schema from 'effect/Schema';
|
|
8
|
+
|
|
7
9
|
import type { ForeignKey } from '@dxos/echo-protocol';
|
|
8
|
-
import type {
|
|
10
|
+
import type { EntityId, URI } from '@dxos/keys';
|
|
9
11
|
|
|
10
12
|
import * as internal from './internal';
|
|
13
|
+
import type * as Ref from './Ref';
|
|
11
14
|
import type * as Relation from './Relation';
|
|
12
|
-
import type * as
|
|
15
|
+
import type * as Tag from './Tag';
|
|
16
|
+
import * as Type from './Type';
|
|
13
17
|
|
|
14
18
|
// Re-export KindId and SnapshotKindId from internal.
|
|
15
19
|
export const KindId = internal.KindId;
|
|
@@ -31,7 +35,7 @@ export const KindSchema = internal.EntityKindSchema;
|
|
|
31
35
|
*/
|
|
32
36
|
export interface OfKind<K extends Kind> {
|
|
33
37
|
readonly [KindId]: K;
|
|
34
|
-
readonly id:
|
|
38
|
+
readonly id: EntityId;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
@@ -39,7 +43,7 @@ export interface OfKind<K extends Kind> {
|
|
|
39
43
|
*/
|
|
40
44
|
export interface SnapshotOfKind<K extends Kind> {
|
|
41
45
|
readonly [SnapshotKindId]: K;
|
|
42
|
-
readonly id:
|
|
46
|
+
readonly id: EntityId;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
/**
|
|
@@ -52,6 +56,27 @@ export type Entity<Props> = OfKind<Kind> & Props;
|
|
|
52
56
|
*/
|
|
53
57
|
export interface Unknown extends OfKind<Kind> {}
|
|
54
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Effect Schema for any ECHO entity (object or relation).
|
|
61
|
+
*
|
|
62
|
+
* Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates
|
|
63
|
+
* the structural shape (id + properties) without constraining `[KindId]`. Used
|
|
64
|
+
* in operation input schemas that accept any entity flavour (e.g.
|
|
65
|
+
* `Schema.Array(Entity.Unknown)`).
|
|
66
|
+
*
|
|
67
|
+
* The cast bridges the runtime structural schema to the branded `Unknown` type:
|
|
68
|
+
* `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,
|
|
69
|
+
* so the entity guarantee is carried at the type level only (same approach as
|
|
70
|
+
* `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it
|
|
71
|
+
* isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no
|
|
72
|
+
* `TypeAnnotation`.
|
|
73
|
+
*/
|
|
74
|
+
export const Unknown: Schema.Schema<Unknown> = Schema.Struct({
|
|
75
|
+
id: Schema.String,
|
|
76
|
+
}).pipe(
|
|
77
|
+
Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
|
78
|
+
) as unknown as Schema.Schema<Unknown>;
|
|
79
|
+
|
|
55
80
|
/**
|
|
56
81
|
* Snapshot of an Obj or Relation.
|
|
57
82
|
* Branded with SnapshotKindId instead of KindId.
|
|
@@ -80,12 +105,30 @@ export type Properties<T> = Omit<T, 'id' | KindId | Relation.Source | Relation.T
|
|
|
80
105
|
* Check if a value is an ECHO entity (object or relation).
|
|
81
106
|
* Returns `false` for snapshots.
|
|
82
107
|
*/
|
|
83
|
-
export const isEntity
|
|
84
|
-
|
|
85
|
-
|
|
108
|
+
export const isEntity: (value: unknown) => value is Unknown = internal.isEntity;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Test if a value is an instance of a given object or relation type.
|
|
112
|
+
*
|
|
113
|
+
* Kind-agnostic counterpart to `Obj.instanceOf` / `Relation.instanceOf` —
|
|
114
|
+
* use this when the caller's input type is `Type.AnyObj | Type.AnyRelation`.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* // Caller doesn't know whether `type` is object- or relation-kind.
|
|
119
|
+
* const matches = <T extends Type.AnyObj | Type.AnyRelation>(type: T, value: unknown) =>
|
|
120
|
+
* Entity.instanceOf(type, value);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export const instanceOf: {
|
|
124
|
+
<S extends Type.AnyEntity>(schema: S): (value: unknown) => value is Type.InstanceType<S>;
|
|
125
|
+
<S extends Type.AnyEntity>(schema: S, value: unknown): value is Type.InstanceType<S>;
|
|
126
|
+
} = ((...args: [schema: Type.AnyEntity, value?: unknown]) => {
|
|
127
|
+
if (args.length === 1) {
|
|
128
|
+
return (entity: unknown) => internal.isInstanceOf(args[0], entity);
|
|
86
129
|
}
|
|
87
|
-
return (
|
|
88
|
-
};
|
|
130
|
+
return internal.isInstanceOf(args[0], args[1]);
|
|
131
|
+
}) as any;
|
|
89
132
|
|
|
90
133
|
/**
|
|
91
134
|
* Check if a value is an ECHO entity snapshot.
|
|
@@ -123,25 +166,58 @@ export type Meta = typeof Meta;
|
|
|
123
166
|
export type JSON = internal.ObjectJSON;
|
|
124
167
|
|
|
125
168
|
/**
|
|
126
|
-
*
|
|
169
|
+
* Whether the entity is a type-kind entity (a `Type.Type` produced by
|
|
170
|
+
* `Type.makeObject` / `Type.makeRelation`, or a persisted schema). Type entities
|
|
171
|
+
* carry their identity (typename/version) on themselves rather than referencing a
|
|
172
|
+
* separate type, so the accessors below route them through the `Type.*` module.
|
|
127
173
|
*/
|
|
128
|
-
|
|
174
|
+
const isTypeEntity = (entity: unknown): boolean => internal.getEntityKindBrand(entity) === internal.EntityKind.Type;
|
|
129
175
|
|
|
130
176
|
/**
|
|
131
|
-
*
|
|
177
|
+
* Any value the read accessors operate on: a reactive entity or a snapshot.
|
|
178
|
+
* Type entities (`Type.AnyEntity`) are also accepted — they're first-class
|
|
179
|
+
* entities, and `Unknown`'s kind-agnostic brand already subsumes them.
|
|
132
180
|
*/
|
|
133
|
-
export
|
|
181
|
+
export type AnyInput = Unknown | Snapshot;
|
|
134
182
|
|
|
135
183
|
/**
|
|
136
|
-
* Get the
|
|
137
|
-
*
|
|
184
|
+
* Get the canonical URI of an entity (object, relation, or type). Returns `URI.URI` —
|
|
185
|
+
* an `EID` for object/relation instances and persisted types, or a typename
|
|
186
|
+
* `DXN` for static type entities; narrow with `EID.parse(uri)` or
|
|
187
|
+
* `DXN.tryMake(uri)` at the point of use.
|
|
138
188
|
*/
|
|
139
|
-
export const
|
|
189
|
+
export const getURI = (entity: AnyInput): URI.URI =>
|
|
190
|
+
isTypeEntity(entity) ? Type.getURI(entity as Type.AnyEntity) : internal.getUri(entity as Unknown);
|
|
140
191
|
|
|
141
192
|
/**
|
|
142
|
-
* Get the
|
|
193
|
+
* Get the DXN of an entity's type. For object/relation instances this is the URI
|
|
194
|
+
* of the type they were created from; for a type entity it is the URI of the
|
|
195
|
+
* meta-type ({@link Type.Type}, `dxn:org.dxos.type.schema:0.1.0`).
|
|
143
196
|
*/
|
|
144
|
-
export const
|
|
197
|
+
export const getTypeURI = (entity: AnyInput): URI.URI | undefined =>
|
|
198
|
+
isTypeEntity(entity) ? Type.getURI(Type.Type) : internal.getTypeURI(entity as Unknown);
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get the type entity (`Type.AnyEntity`) the instance was created from.
|
|
202
|
+
*
|
|
203
|
+
* Returns `undefined` when the entity's type isn't registered in this runtime
|
|
204
|
+
* (e.g. a freshly deserialized snapshot whose type entity hasn't been wired
|
|
205
|
+
* up yet, or an entity loaded from storage before its schema is known). To
|
|
206
|
+
* get the Effect Schema from the returned entity, use `Type.getSchema(...)`.
|
|
207
|
+
*
|
|
208
|
+
* For a type entity, returns the meta-type {@link Type.Type} (a type entity's
|
|
209
|
+
* type is "Type").
|
|
210
|
+
*/
|
|
211
|
+
export const getType = (entity: AnyInput): Type.AnyEntity | undefined =>
|
|
212
|
+
isTypeEntity(entity) ? Type.Type : (internal.getType(entity) as Type.AnyEntity | undefined);
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Get the typename of an entity's type. For object/relation instances this is the
|
|
216
|
+
* typename of the type they were created from; for a type entity it is the type's
|
|
217
|
+
* own typename (e.g. `com.example.type.person`).
|
|
218
|
+
*/
|
|
219
|
+
export const getTypename = (entity: AnyInput): string | undefined =>
|
|
220
|
+
isTypeEntity(entity) ? Type.getTypename(entity as Type.AnyEntity) : internal.getTypename(entity as Unknown);
|
|
145
221
|
|
|
146
222
|
/**
|
|
147
223
|
* Get the database an entity belongs to.
|
|
@@ -154,9 +230,9 @@ export const getDatabase = (entity: Unknown | Snapshot): any | undefined => inte
|
|
|
154
230
|
* Returns read-only meta when passed a regular entity or snapshot.
|
|
155
231
|
*/
|
|
156
232
|
// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.
|
|
157
|
-
export function getMeta(entity: Mutable<Unknown>): internal.
|
|
233
|
+
export function getMeta(entity: Mutable<Unknown>): internal.EntityMeta;
|
|
158
234
|
export function getMeta(entity: Unknown | Snapshot): internal.ReadonlyMeta;
|
|
159
|
-
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.
|
|
235
|
+
export function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.EntityMeta | internal.ReadonlyMeta {
|
|
160
236
|
return internal.getMetaChecked(entity);
|
|
161
237
|
}
|
|
162
238
|
|
|
@@ -172,14 +248,31 @@ export const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDel
|
|
|
172
248
|
|
|
173
249
|
/**
|
|
174
250
|
* Get the label of an entity.
|
|
251
|
+
*
|
|
252
|
+
* @param options.fallback `'typename'` returns the entity's typename when no
|
|
253
|
+
* label is set (e.g. `org.dxos.type.table`).
|
|
254
|
+
*/
|
|
255
|
+
export const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>
|
|
256
|
+
internal.getLabel(entity, options);
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Set the label of an entity.
|
|
260
|
+
* Must be called within an `Entity.update` / `Obj.update` / `Relation.update` callback.
|
|
175
261
|
*/
|
|
176
|
-
export const
|
|
262
|
+
export const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);
|
|
177
263
|
|
|
178
264
|
/**
|
|
179
265
|
* Get the description of an entity.
|
|
180
266
|
*/
|
|
181
267
|
export const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);
|
|
182
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Get the icon annotation for an entity (object or relation), resolved via its type-level
|
|
271
|
+
* `IconAnnotation`. Returns the full `{ icon, hue }` annotation so callers can use both
|
|
272
|
+
* the phosphor icon name and the suggested colour.
|
|
273
|
+
*/
|
|
274
|
+
export const getIcon = (entity: Unknown | Snapshot): internal.IconAnnotation | undefined => internal.getIcon(entity);
|
|
275
|
+
|
|
183
276
|
/**
|
|
184
277
|
* Convert an entity to its JSON representation.
|
|
185
278
|
*/
|
|
@@ -234,10 +327,10 @@ export const update = <T extends Unknown>(entity: T, callback: internal.ChangeCa
|
|
|
234
327
|
* Add a tag to an entity.
|
|
235
328
|
* Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.
|
|
236
329
|
*/
|
|
237
|
-
export const addTag = (entity: Mutable<Unknown>, tag:
|
|
330
|
+
export const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);
|
|
238
331
|
|
|
239
332
|
/**
|
|
240
333
|
* Remove a tag from an entity.
|
|
241
334
|
* Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.
|
|
242
335
|
*/
|
|
243
|
-
export const removeTag = (entity: Mutable<Unknown>, tag:
|
|
336
|
+
export const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);
|
package/src/Err.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// @import-as-namespace
|
|
6
6
|
|
|
7
7
|
import { BaseError, type BaseErrorOptions } from '@dxos/errors';
|
|
8
|
-
import { type
|
|
8
|
+
import { type URI } from '@dxos/keys';
|
|
9
9
|
|
|
10
10
|
export class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {
|
|
11
11
|
constructor(schema: string, options?: BaseErrorOptions) {
|
|
@@ -13,9 +13,9 @@ export class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError',
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class
|
|
17
|
-
constructor(
|
|
18
|
-
super({ context: {
|
|
16
|
+
export class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {
|
|
17
|
+
constructor(uri: URI.URI, options?: BaseErrorOptions) {
|
|
18
|
+
super({ context: { uri }, ...options });
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
package/src/Feed.ts
CHANGED
|
@@ -10,7 +10,7 @@ import * as Layer from 'effect/Layer';
|
|
|
10
10
|
import type * as Option from 'effect/Option';
|
|
11
11
|
import * as Schema from 'effect/Schema';
|
|
12
12
|
|
|
13
|
-
import { DXN } from '@dxos/keys';
|
|
13
|
+
import { DXN, EID } from '@dxos/keys';
|
|
14
14
|
|
|
15
15
|
import * as Annotation from './Annotation';
|
|
16
16
|
import type * as Entity from './Entity';
|
|
@@ -43,21 +43,15 @@ export const Feed = Schema.Struct({
|
|
|
43
43
|
*/
|
|
44
44
|
namespace: Schema.optional(Schema.Literal('data', 'trace')),
|
|
45
45
|
}).pipe(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
internal.SystemTypeAnnotation.set(true),
|
|
51
|
-
Annotation.IconAnnotation.set({
|
|
52
|
-
icon: 'ph--rows--regular',
|
|
53
|
-
hue: 'yellow',
|
|
54
|
-
}),
|
|
46
|
+
internal.HiddenAnnotation.set(true),
|
|
47
|
+
Annotation.IconAnnotation.set({ icon: 'ph--rows--regular', hue: 'yellow' }),
|
|
48
|
+
Type.makeObject(DXN.make('org.dxos.type.feed', '0.1.0')),
|
|
55
49
|
);
|
|
56
50
|
|
|
57
51
|
/**
|
|
58
52
|
* TypeScript instance type for a Feed object.
|
|
59
53
|
*/
|
|
60
|
-
export
|
|
54
|
+
export type Feed = Type.InstanceType<typeof Feed>;
|
|
61
55
|
|
|
62
56
|
//
|
|
63
57
|
// Types
|
|
@@ -90,6 +84,19 @@ export interface SyncOptions {
|
|
|
90
84
|
shouldPull?: boolean;
|
|
91
85
|
}
|
|
92
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Queue replication backlog for a feed namespace.
|
|
89
|
+
* `0` / `0` means caught up on pull and push.
|
|
90
|
+
*/
|
|
91
|
+
export interface SyncState {
|
|
92
|
+
/** Blocks still to pull from remote. */
|
|
93
|
+
blocksToPull: number;
|
|
94
|
+
/** Unpositioned blocks still to push to remote. */
|
|
95
|
+
blocksToPush: number;
|
|
96
|
+
/** Total blocks stored locally for the feed namespace. */
|
|
97
|
+
totalBlocks: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
//
|
|
94
101
|
// Factory
|
|
95
102
|
//
|
|
@@ -106,18 +113,11 @@ export interface SyncOptions {
|
|
|
106
113
|
export const make = (props: Obj.MakeProps<typeof Feed> = {}): Feed => Obj.make(Feed, props);
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
|
-
*
|
|
110
|
-
* Returns `undefined` when the feed is not stored in a space yet.
|
|
116
|
+
* Returns the feed object's EID when the feed is stored in a space.
|
|
111
117
|
*
|
|
112
118
|
* Used internally by the feed service layer.
|
|
113
119
|
*/
|
|
114
|
-
export const
|
|
115
|
-
const self = Obj.getDXN(feed).asEchoDXN();
|
|
116
|
-
if (!self || !self.spaceId) {
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
return new DXN(DXN.kind.QUEUE, [feed.namespace ?? 'data', self.spaceId, self.echoId]);
|
|
120
|
-
};
|
|
120
|
+
export const getQueueUri = (feed: Feed): EID.EID | undefined => EID.tryParse(Obj.getURI(feed));
|
|
121
121
|
|
|
122
122
|
//
|
|
123
123
|
// Service
|
|
@@ -139,7 +139,6 @@ export class FeedService extends Context.Tag('@dxos/echo/Feed/FeedService')<
|
|
|
139
139
|
/**
|
|
140
140
|
* Removes items from a feed by ID.
|
|
141
141
|
*/
|
|
142
|
-
// TODO(dmaretskyi): Change type to ObjectId.
|
|
143
142
|
remove(feed: Feed, ids: string[]): Promise<void>;
|
|
144
143
|
|
|
145
144
|
/**
|
|
@@ -154,6 +153,11 @@ export class FeedService extends Context.Tag('@dxos/echo/Feed/FeedService')<
|
|
|
154
153
|
* Syncs the feed with the server.
|
|
155
154
|
*/
|
|
156
155
|
sync(feed: Feed, options?: SyncOptions): Promise<void>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Returns queue replication backlog for the feed's namespace.
|
|
159
|
+
*/
|
|
160
|
+
getSyncState(feed: Feed): Promise<SyncState>;
|
|
157
161
|
}
|
|
158
162
|
>() {}
|
|
159
163
|
|
|
@@ -167,6 +171,21 @@ export type Service = FeedService;
|
|
|
167
171
|
*/
|
|
168
172
|
export const Service = FeedService;
|
|
169
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Effect context service that holds the current feed for a scoped operation.
|
|
176
|
+
*
|
|
177
|
+
* @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures
|
|
178
|
+
* over hiding it behind a context service.
|
|
179
|
+
*/
|
|
180
|
+
export class ContextFeedService extends Context.Tag('@dxos/echo/Feed/ContextFeedService')<
|
|
181
|
+
ContextFeedService,
|
|
182
|
+
{
|
|
183
|
+
readonly feed: Feed;
|
|
184
|
+
}
|
|
185
|
+
>() {
|
|
186
|
+
static layer = (feed: Feed): Layer.Layer<ContextFeedService> => Layer.succeed(ContextFeedService, { feed });
|
|
187
|
+
}
|
|
188
|
+
|
|
170
189
|
/**
|
|
171
190
|
* Layer that provides a Feed service that throws when accessed.
|
|
172
191
|
* Useful as a default layer when no feed service is available.
|
|
@@ -184,27 +203,11 @@ export const notAvailable: Layer.Layer<FeedService> = Layer.succeed(FeedService,
|
|
|
184
203
|
sync: () => {
|
|
185
204
|
throw new Error('Feed.FeedService not available');
|
|
186
205
|
},
|
|
206
|
+
getSyncState: () => {
|
|
207
|
+
throw new Error('Feed.FeedService not available');
|
|
208
|
+
},
|
|
187
209
|
} as Context.Tag.Service<FeedService>);
|
|
188
210
|
|
|
189
|
-
//
|
|
190
|
-
// Context (per-call) service
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Effect service exposing a single `Feed.Feed` as the "current" feed for a call site.
|
|
195
|
-
*
|
|
196
|
-
* @deprecated Prefer threading a `Feed.Feed` explicitly through function signatures
|
|
197
|
-
* over hiding it behind a context service.
|
|
198
|
-
*/
|
|
199
|
-
export class ContextFeedService extends Context.Tag('@dxos/echo/Feed/ContextFeedService')<
|
|
200
|
-
ContextFeedService,
|
|
201
|
-
{
|
|
202
|
-
readonly feed: Feed;
|
|
203
|
-
}
|
|
204
|
-
>() {
|
|
205
|
-
static layer = (feed: Feed): Layer.Layer<ContextFeedService> => Layer.succeed(ContextFeedService, { feed });
|
|
206
|
-
}
|
|
207
|
-
|
|
208
211
|
//
|
|
209
212
|
// Operations
|
|
210
213
|
//
|
|
@@ -293,6 +296,20 @@ export const sync = (feed: Feed, options?: SyncOptions): Effect.Effect<void, nev
|
|
|
293
296
|
yield* Effect.promise(() => service.sync(feed, options));
|
|
294
297
|
});
|
|
295
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Returns queue replication backlog for the feed's namespace.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const { blocksToPull, blocksToPush } = yield* Feed.getSyncState(feed);
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
export const getSyncState = (feed: Feed): Effect.Effect<SyncState, never, FeedService> =>
|
|
308
|
+
Effect.gen(function* () {
|
|
309
|
+
const service = yield* FeedService;
|
|
310
|
+
return yield* Effect.promise(() => service.getSyncState(feed));
|
|
311
|
+
});
|
|
312
|
+
|
|
296
313
|
/**
|
|
297
314
|
* Creates a cursor for iterating over feed items.
|
|
298
315
|
* Currently stubbed — cursor operations are not yet implemented.
|
package/src/Filter.ts
CHANGED
|
@@ -11,11 +11,13 @@ import type * as Types from 'effect/Types';
|
|
|
11
11
|
|
|
12
12
|
import { type ForeignKey, type QueryAST } from '@dxos/echo-protocol';
|
|
13
13
|
import { assertArgument } from '@dxos/invariant';
|
|
14
|
-
import { DXN,
|
|
14
|
+
import { DXN, EID, EntityId, type URI } from '@dxos/keys';
|
|
15
15
|
|
|
16
16
|
import * as internal from './internal';
|
|
17
17
|
import type * as Obj from './Obj';
|
|
18
18
|
import * as Ref from './Ref';
|
|
19
|
+
// eslint-disable-next-line @dxos/rules/import-as-namespace
|
|
20
|
+
import type * as Type$ from './Type';
|
|
19
21
|
|
|
20
22
|
export interface Filter<T> {
|
|
21
23
|
// TODO(dmaretskyi): See new effect-schema approach to variance.
|
|
@@ -77,11 +79,11 @@ export const nothing = (): FilterClass => {
|
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
/*
|
|
80
|
-
* Filter by
|
|
82
|
+
* Filter by EntityId.
|
|
81
83
|
*/
|
|
82
|
-
export const id = (...ids:
|
|
84
|
+
export const id = (...ids: EntityId[]): Any => {
|
|
83
85
|
assertArgument(
|
|
84
|
-
ids.every((id) =>
|
|
86
|
+
ids.every((id) => EntityId.isValid(id)),
|
|
85
87
|
'ids',
|
|
86
88
|
'ids must be valid',
|
|
87
89
|
);
|
|
@@ -100,27 +102,46 @@ export const id = (...ids: ObjectId[]): Any => {
|
|
|
100
102
|
|
|
101
103
|
/**
|
|
102
104
|
* Filter by type.
|
|
105
|
+
*
|
|
106
|
+
* Accepts a `Type.Type` entity (the value produced by `Type.makeObject` /
|
|
107
|
+
* `Type.makeRelation`), a `Schema.Union` of such entities (for filtering across a
|
|
108
|
+
* union of ECHO types), or a non-qualified typename string.
|
|
103
109
|
*/
|
|
104
|
-
export const type
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
export const type: {
|
|
111
|
+
<T extends Type$.AnyEntity>(type: T, props?: Props<Type$.InstanceType<T>>): Filter<Type$.InstanceType<T>>;
|
|
112
|
+
// Schema-side overload restricted to the well-known unknown schemas and to
|
|
113
|
+
// `Schema.Union(...)` of `Type.Type` entities (for filtering across a union
|
|
114
|
+
// of ECHO types). Other raw schemas are rejected.
|
|
115
|
+
<S extends internal.UnknownTypeSchema<any, any>>(
|
|
116
|
+
schema: S,
|
|
117
|
+
props?: Props<Schema.Schema.Type<S>>,
|
|
118
|
+
): Filter<Schema.Schema.Type<S>>;
|
|
119
|
+
<S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(
|
|
120
|
+
union: S,
|
|
121
|
+
props?: Props<Schema.Schema.Type<S>>,
|
|
122
|
+
): Filter<Schema.Schema.Type<S>>;
|
|
123
|
+
(schema: string, props?: Props<unknown>): Filter<any>;
|
|
124
|
+
// Passthrough overload for callers that hold a `Type.AnyEntity | string` union
|
|
125
|
+
// (e.g. Query.type / Query.sourceOf / Query.targetOf impls). Listed last so the
|
|
126
|
+
// typed overloads above still win for monomorphic inputs.
|
|
127
|
+
(input: Type$.AnyEntity | string, props?: Props<unknown>): Filter<unknown>;
|
|
128
|
+
} = (input: Type$.AnyEntity | Schema.Schema.AnyNoContext | string, props?: Props<unknown>): any => {
|
|
129
|
+
if (Schema.isSchema(input) && SchemaAST.isUnion(input.ast)) {
|
|
130
|
+
const typenames = input.ast.types.map((t) => internal.getTypeURIFromSpecifier(Schema.make(t)));
|
|
110
131
|
return new FilterClass({
|
|
111
132
|
type: 'or',
|
|
112
133
|
filters: typenames.map((typename) => ({
|
|
113
134
|
type: 'object',
|
|
114
|
-
typename
|
|
135
|
+
typename,
|
|
115
136
|
props: {},
|
|
116
137
|
})),
|
|
117
138
|
});
|
|
118
139
|
}
|
|
119
140
|
|
|
120
|
-
const
|
|
141
|
+
const uri = internal.getTypeURIFromSpecifier(input);
|
|
121
142
|
return new FilterClass({
|
|
122
143
|
type: 'object',
|
|
123
|
-
typename:
|
|
144
|
+
typename: uri,
|
|
124
145
|
...propsFilterToAst(props ?? {}),
|
|
125
146
|
});
|
|
126
147
|
};
|
|
@@ -132,18 +153,19 @@ export const typename = (typename: string): Any => {
|
|
|
132
153
|
assertArgument(!typename.startsWith('dxn:'), 'typename', 'Typename must no be qualified');
|
|
133
154
|
return new FilterClass({
|
|
134
155
|
type: 'object',
|
|
135
|
-
typename: DXN.
|
|
156
|
+
typename: DXN.make(typename),
|
|
136
157
|
props: {},
|
|
137
158
|
});
|
|
138
159
|
};
|
|
139
160
|
|
|
140
161
|
/**
|
|
141
|
-
* Filter by fully qualified type DXN
|
|
162
|
+
* Filter by fully qualified type URI — either a typename DXN (for static schemas) or
|
|
163
|
+
* a schema-as-object EID (for stored dynamic schemas). See `getSchemaURI`.
|
|
142
164
|
*/
|
|
143
|
-
export const
|
|
165
|
+
export const typeURI = (uri: URI.URI): Any => {
|
|
144
166
|
return new FilterClass({
|
|
145
167
|
type: 'object',
|
|
146
|
-
typename:
|
|
168
|
+
typename: uri,
|
|
147
169
|
props: {},
|
|
148
170
|
});
|
|
149
171
|
};
|
|
@@ -223,14 +245,14 @@ export const text = (
|
|
|
223
245
|
/**
|
|
224
246
|
* Filter by foreign keys.
|
|
225
247
|
*/
|
|
226
|
-
export const foreignKeys = <S extends
|
|
227
|
-
schema: S
|
|
248
|
+
export const foreignKeys = <S extends Type$.AnyEntity | string>(
|
|
249
|
+
schema: S,
|
|
228
250
|
keys: ForeignKey[],
|
|
229
|
-
): Filter<
|
|
230
|
-
const
|
|
251
|
+
): Filter<S extends Type$.AnyEntity ? Type$.InstanceType<S> : unknown> => {
|
|
252
|
+
const uri = internal.getTypeURIFromSpecifier(schema);
|
|
231
253
|
return new FilterClass({
|
|
232
254
|
type: 'object',
|
|
233
|
-
typename:
|
|
255
|
+
typename: uri,
|
|
234
256
|
props: {},
|
|
235
257
|
foreignKeys: keys,
|
|
236
258
|
});
|
|
@@ -378,7 +400,7 @@ export type ChildOfOptions = {
|
|
|
378
400
|
/**
|
|
379
401
|
* Filter objects that are children of the specified parent(s).
|
|
380
402
|
* Accepts ECHO objects, Refs, or arrays of either.
|
|
381
|
-
* Refs are resolved to DXNs without loading; objects use {@link Obj.
|
|
403
|
+
* Refs are resolved to DXNs without loading; objects use {@link Obj.getURI}.
|
|
382
404
|
* With transitive=true (default), also matches grandchildren and beyond.
|
|
383
405
|
*/
|
|
384
406
|
export const childOf = (
|
|
@@ -388,9 +410,9 @@ export const childOf = (
|
|
|
388
410
|
const items = Array.isArray(parents) ? parents : [parents];
|
|
389
411
|
const dxns = items.map((item) => {
|
|
390
412
|
if (Ref.isRef(item)) {
|
|
391
|
-
return item.
|
|
413
|
+
return EID.parse(item.uri);
|
|
392
414
|
}
|
|
393
|
-
return internal.
|
|
415
|
+
return internal.getUri(item);
|
|
394
416
|
});
|
|
395
417
|
return new FilterClass({
|
|
396
418
|
type: 'child-of',
|
|
@@ -432,7 +454,7 @@ export const or = <Filters extends readonly Any[]>(...filters: Filters): Filter<
|
|
|
432
454
|
// TODO(dmaretskyi): Add `Filter.match` to support pattern matching on string props.
|
|
433
455
|
|
|
434
456
|
const propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {
|
|
435
|
-
let idFilter: readonly
|
|
457
|
+
let idFilter: readonly EntityId[] | undefined;
|
|
436
458
|
if ('id' in predicates) {
|
|
437
459
|
assertArgument(
|
|
438
460
|
typeof predicates.id === 'string' || Array.isArray(predicates.id),
|
|
@@ -440,7 +462,7 @@ const propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, '
|
|
|
440
462
|
'invalid id filter',
|
|
441
463
|
);
|
|
442
464
|
idFilter = typeof predicates.id === 'string' ? [predicates.id] : predicates.id;
|
|
443
|
-
Schema.Array(
|
|
465
|
+
Schema.Array(EntityId).pipe(Schema.validateSync)(idFilter);
|
|
444
466
|
}
|
|
445
467
|
|
|
446
468
|
return {
|
package/src/Hypergraph.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type URI } from '@dxos/keys';
|
|
6
6
|
|
|
7
7
|
import type * as Database from './Database';
|
|
8
8
|
import type * as Entity from './Entity';
|
|
9
9
|
import type * as internal from './internal';
|
|
10
10
|
import type * as Key from './Key';
|
|
11
11
|
import type * as Ref from './Ref';
|
|
12
|
-
import type * as
|
|
12
|
+
import type * as Registry from './Registry';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Resolution context.
|
|
@@ -22,10 +22,10 @@ export interface RefResolutionContext {
|
|
|
22
22
|
space?: Key.SpaceId;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Feed that the resolution is happening from
|
|
25
|
+
* Feed that the resolution is happening from.
|
|
26
26
|
* This feed will be searched first, and then the space it belongs to.
|
|
27
27
|
*/
|
|
28
|
-
feed?:
|
|
28
|
+
feed?: URI.URI;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface RefResolverOptions {
|
|
@@ -46,7 +46,12 @@ export interface RefResolverOptions {
|
|
|
46
46
|
* Manages cross-space database interactions.
|
|
47
47
|
*/
|
|
48
48
|
export interface Hypergraph extends Database.Queryable {
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* In-process registry of keyed objects and static schema types.
|
|
51
|
+
* Populated at startup via `registry.add(objects)` / `registry.add(schemas)`.
|
|
52
|
+
* Queries that include no explicit from() clause will fan out to this registry automatically.
|
|
53
|
+
*/
|
|
54
|
+
get registry(): Registry.Registry;
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Query objects.
|
|
@@ -57,11 +62,11 @@ export interface Hypergraph extends Database.Queryable {
|
|
|
57
62
|
* Creates a reference to an existing object in the database.
|
|
58
63
|
*
|
|
59
64
|
* NOTE: The reference may be dangling if the object is not present in the database.
|
|
60
|
-
* NOTE: Difference from `Ref.
|
|
61
|
-
* `Ref.
|
|
65
|
+
* NOTE: Difference from `Ref.fromURI`
|
|
66
|
+
* `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
|
|
62
67
|
* `db.makeRef(dxn)` is preferable in cases with access to the database.
|
|
63
68
|
*/
|
|
64
|
-
makeRef<T extends Entity.Unknown = Entity.Unknown>(
|
|
69
|
+
makeRef<T extends Entity.Unknown = Entity.Unknown>(uri: URI.URI): Ref.Ref<T>;
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
72
|
* @param hostDb Host database for reference resolution.
|
package/src/Json.test.ts
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { DXN,
|
|
7
|
+
import { DXN, EID, EntityId } from '@dxos/keys';
|
|
8
8
|
import { safeStringify } from '@dxos/util';
|
|
9
9
|
|
|
10
10
|
import * as Database from './Database';
|
|
11
11
|
import * as Json from './Json';
|
|
12
12
|
|
|
13
13
|
/** Mint a random ECHO object id usable as both a stub-db key and a DXN payload. */
|
|
14
|
-
const newId = (): string =>
|
|
14
|
+
const newId = (): string => EntityId.random();
|
|
15
15
|
|
|
16
16
|
/** Build a fake encoded ref for a local-space object id. */
|
|
17
|
-
const encodeRef = (id: string): { '/': string } => ({ '/':
|
|
17
|
+
const encodeRef = (id: string): { '/': string } => ({ '/': EID.make({ entityId: id }) });
|
|
18
18
|
|
|
19
19
|
/** Minimal stub: `createRefReplacer` only touches `db.getObjectById`. */
|
|
20
20
|
const makeStubDb = (objects: Record<string, unknown>): Database.Database => {
|
|
@@ -93,7 +93,7 @@ describe('createRefReplacer', () => {
|
|
|
93
93
|
|
|
94
94
|
test('leaves non-echo dxns untouched (e.g. type DXN)', () => {
|
|
95
95
|
// Type DXNs share the `dxn:` prefix but `asEchoDXN()` returns undefined.
|
|
96
|
-
const typeRef = { '/': DXN.
|
|
96
|
+
const typeRef = { '/': DXN.make('com.example.Thing') };
|
|
97
97
|
const replacer = Json.createRefReplacer({ db: makeStubDb({}) });
|
|
98
98
|
expect(stringifyWith(replacer, { ref: typeRef })).toEqual({ ref: typeRef });
|
|
99
99
|
});
|