@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/Collection.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
10
|
+
|
|
9
11
|
import * as Annotation from './Annotation';
|
|
10
12
|
import * as internal from './internal';
|
|
11
13
|
import * as Obj from './Obj';
|
|
@@ -19,17 +21,11 @@ export const Collection = Schema.Struct({
|
|
|
19
21
|
name: Schema.String.pipe(Schema.optional),
|
|
20
22
|
objects: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(internal.FormInputAnnotation.set(false)),
|
|
21
23
|
}).pipe(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
version: '0.1.0',
|
|
25
|
-
}),
|
|
26
|
-
Annotation.IconAnnotation.set({
|
|
27
|
-
icon: 'ph--folder--regular',
|
|
28
|
-
hue: 'amber',
|
|
29
|
-
}),
|
|
24
|
+
Annotation.IconAnnotation.set({ icon: 'ph--folder--regular', hue: 'amber' }),
|
|
25
|
+
Type.makeObject(DXN.make('org.dxos.type.collection', '0.1.0')),
|
|
30
26
|
);
|
|
31
27
|
|
|
32
|
-
export
|
|
28
|
+
export type Collection = Type.InstanceType<typeof Collection>;
|
|
33
29
|
|
|
34
30
|
export const make = (props: Partial<Obj.MakeProps<typeof Collection>> = {}): Collection =>
|
|
35
31
|
Obj.make(Collection, { objects: [], ...props });
|
package/src/Database.ts
CHANGED
|
@@ -6,26 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
import * as Context from 'effect/Context';
|
|
8
8
|
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Effectable from 'effect/Effectable';
|
|
9
10
|
import * as Layer from 'effect/Layer';
|
|
10
11
|
import * as Option from 'effect/Option';
|
|
11
12
|
import * as Schema from 'effect/Schema';
|
|
12
|
-
import type * as Types from 'effect/Types';
|
|
13
13
|
|
|
14
14
|
import { promiseWithCauseCapture } from '@dxos/effect';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
|
-
import {
|
|
16
|
+
import { type SpaceId, type URI } from '@dxos/keys';
|
|
17
17
|
|
|
18
18
|
import type * as Entity from './Entity';
|
|
19
19
|
import * as Err from './Err';
|
|
20
20
|
import type * as Filter from './Filter';
|
|
21
21
|
import type * as Hypergraph from './Hypergraph';
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
22
|
+
import { type AnyProperties, EntityKind, KindId } from './internal/common/types';
|
|
23
|
+
// Deep import (not the `./internal/Entity` barrel) to avoid a cycle:
|
|
24
|
+
// Database → internal/Entity → entity → JsonSchema → Ref → Database.
|
|
25
|
+
import { isInstanceOf } from './internal/Entity/type-uri';
|
|
24
26
|
import type { Ref } from './internal/Ref/ref';
|
|
25
27
|
import type * as Obj from './Obj';
|
|
26
28
|
import type * as Query from './Query';
|
|
27
29
|
import type * as QueryResult from './QueryResult';
|
|
28
|
-
import type * as
|
|
30
|
+
import type * as Registry from './Registry';
|
|
29
31
|
import type * as Type from './Type';
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -62,6 +64,16 @@ export type AddOptions = {
|
|
|
62
64
|
placeIn?: ObjectPlacement;
|
|
63
65
|
};
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Rejects Type entities from {@link Database.add} at compile time via their `[KindId]` brand. Used
|
|
69
|
+
* as `T & RejectTypeEntity<T>` to preserve inference of `T`. Bounding `add` on
|
|
70
|
+
* `Obj.Unknown | Relation.Unknown` instead would reject broadly-typed instance adds (e.g.
|
|
71
|
+
* `Entity.Any`, `Obj.OfShape<T>`), forcing casts repo-wide.
|
|
72
|
+
*/
|
|
73
|
+
export type RejectTypeEntity<T> = T extends { readonly [KindId]: EntityKind.Type }
|
|
74
|
+
? { __error: 'Type entities must be persisted via db.addType(), not db.add().' }
|
|
75
|
+
: T;
|
|
76
|
+
|
|
65
77
|
export type FlushOptions = {
|
|
66
78
|
/**
|
|
67
79
|
* Write any pending changes to disk.
|
|
@@ -96,11 +108,15 @@ export interface Database extends Queryable {
|
|
|
96
108
|
|
|
97
109
|
get spaceId(): SpaceId;
|
|
98
110
|
|
|
99
|
-
// TODO(burdon): Can we move this into graph?
|
|
100
|
-
get schemaRegistry(): SchemaRegistry.SchemaRegistry;
|
|
101
|
-
|
|
102
111
|
get graph(): Hypergraph.Hypergraph;
|
|
103
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Registry for this database. Delegates type lookups to the shared hypergraph registry.
|
|
115
|
+
* To persist a schema so it replicates to other clients, add the type entity with
|
|
116
|
+
* {@link addType} (e.g. `await db.addType(Type.makeObjectFromJsonSchema(...))`).
|
|
117
|
+
*/
|
|
118
|
+
readonly registry: Registry.Registry;
|
|
119
|
+
|
|
104
120
|
toJSON(): object;
|
|
105
121
|
|
|
106
122
|
/**
|
|
@@ -120,16 +136,28 @@ export interface Database extends Queryable {
|
|
|
120
136
|
* Creates a reference to an existing object in the database.
|
|
121
137
|
*
|
|
122
138
|
* NOTE: The reference may be dangling if the object is not present in the database.
|
|
123
|
-
* NOTE: Difference from `Ref.
|
|
124
|
-
* `Ref.
|
|
139
|
+
* NOTE: Difference from `Ref.fromURI`
|
|
140
|
+
* `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
|
|
125
141
|
* `db.makeRef(dxn)` is preferable in cases with access to the database.
|
|
126
142
|
*/
|
|
127
|
-
makeRef<T extends Entity.Unknown = Entity.Unknown>(
|
|
143
|
+
makeRef<T extends Entity.Unknown = Entity.Unknown>(uri: URI.URI): Ref<T>;
|
|
128
144
|
|
|
129
145
|
/**
|
|
130
|
-
* Adds object to the database.
|
|
146
|
+
* Adds an object or relation to the database.
|
|
147
|
+
*
|
|
148
|
+
* Only Object and Relation entities are accepted. To persist a Type definition use
|
|
149
|
+
* {@link addType} — passing a Type entity is rejected at compile time (and at runtime).
|
|
131
150
|
*/
|
|
132
|
-
add<T extends Entity.Unknown = Entity.Unknown>(obj: T
|
|
151
|
+
add<T extends Entity.Unknown = Entity.Unknown>(obj: T & RejectTypeEntity<T>, opts?: AddOptions): T;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Persists a Type definition (clones/forks the entity) so it replicates to other peers.
|
|
155
|
+
*
|
|
156
|
+
* Runs a conflict query first: if a type with the same typename + version already exists in
|
|
157
|
+
* this space, the existing persisted entity is returned and no duplicate is created. This is
|
|
158
|
+
* the only supported way to add Type entities — {@link add} rejects them.
|
|
159
|
+
*/
|
|
160
|
+
addType<T extends Type.AnyEntity>(type: T): Promise<T>;
|
|
133
161
|
|
|
134
162
|
/**
|
|
135
163
|
* Removes object from the database.
|
|
@@ -201,19 +229,19 @@ export const spaceId = Effect.gen(function* () {
|
|
|
201
229
|
*/
|
|
202
230
|
export const resolve: {
|
|
203
231
|
// No type check.
|
|
204
|
-
(ref:
|
|
232
|
+
(ref: URI.URI | Ref<any>): Effect.Effect<Entity.Unknown, never, Service>;
|
|
205
233
|
// Check matches schema.
|
|
206
234
|
<S extends Type.AnyEntity>(
|
|
207
|
-
ref:
|
|
235
|
+
ref: URI.URI | Ref<any>,
|
|
208
236
|
schema: S,
|
|
209
|
-
): Effect.Effect<
|
|
237
|
+
): Effect.Effect<Type.InstanceType<S>, Err.EntityNotFoundError, Service>;
|
|
210
238
|
} = (<S extends Type.AnyEntity>(
|
|
211
|
-
ref:
|
|
239
|
+
ref: URI.URI | Ref<any>,
|
|
212
240
|
schema?: S,
|
|
213
|
-
): Effect.Effect<
|
|
241
|
+
): Effect.Effect<Type.InstanceType<S>, Err.EntityNotFoundError, Service> =>
|
|
214
242
|
Effect.gen(function* () {
|
|
215
243
|
const { db } = yield* Service;
|
|
216
|
-
const dxn = ref
|
|
244
|
+
const dxn = typeof ref === 'string' ? ref : ref.uri;
|
|
217
245
|
const object = yield* promiseWithCauseCapture(() =>
|
|
218
246
|
db.graph
|
|
219
247
|
.createRefResolver({
|
|
@@ -225,20 +253,22 @@ export const resolve: {
|
|
|
225
253
|
);
|
|
226
254
|
|
|
227
255
|
if (!object) {
|
|
228
|
-
return yield* Effect.fail(new Err.
|
|
256
|
+
return yield* Effect.fail(new Err.EntityNotFoundError(dxn));
|
|
229
257
|
}
|
|
230
|
-
|
|
258
|
+
// `isInstanceOf` uses a conditional generic that TS can't resolve through
|
|
259
|
+
// the local `S extends Type.AnyEntity` parameter — runtime accepts it fine.
|
|
260
|
+
invariant(!schema || isInstanceOf(schema as any, object), 'Object type mismatch.');
|
|
231
261
|
return object as any;
|
|
232
262
|
}).pipe(Effect.withSpan('Database.resolve'))) as any;
|
|
233
263
|
|
|
234
264
|
/**
|
|
235
265
|
* Loads an object reference.
|
|
236
266
|
*/
|
|
237
|
-
export const load: <T>(ref: Ref<T>) => Effect.Effect<T, Err.
|
|
267
|
+
export const load: <T>(ref: Ref<T>) => Effect.Effect<T, Err.EntityNotFoundError, never> = Effect.fn('Database.load')(
|
|
238
268
|
function* (ref) {
|
|
239
269
|
const object = yield* promiseWithCauseCapture(() => ref.tryLoad());
|
|
240
270
|
if (!object) {
|
|
241
|
-
return yield* Effect.fail(new Err.
|
|
271
|
+
return yield* Effect.fail(new Err.EntityNotFoundError(ref.uri));
|
|
242
272
|
}
|
|
243
273
|
return object;
|
|
244
274
|
},
|
|
@@ -251,17 +281,26 @@ export const load: <T>(ref: Ref<T>) => Effect.Effect<T, Err.ObjectNotFoundError,
|
|
|
251
281
|
export const loadOption: <T>(ref: Ref<T>) => Effect.Effect<Option.Option<T>, never, never> = Effect.fn(
|
|
252
282
|
'Database.loadOption',
|
|
253
283
|
)(function* (ref) {
|
|
254
|
-
const object = yield* load(ref).pipe(Effect.catchTag('
|
|
284
|
+
const object = yield* load(ref).pipe(Effect.catchTag('EntityNotFoundError', () => Effect.succeed(undefined)));
|
|
255
285
|
|
|
256
286
|
return Option.fromNullable(object);
|
|
257
287
|
});
|
|
258
288
|
|
|
259
289
|
/**
|
|
260
|
-
* Adds an object to the database.
|
|
290
|
+
* Adds an object or relation to the database.
|
|
261
291
|
* @see {@link Database.add}
|
|
262
292
|
*/
|
|
263
|
-
export const add = <T extends Entity.Unknown>(obj: T): Effect.Effect<T, never, Service> =>
|
|
264
|
-
Service.pipe(Effect.map(({ db }) => db.add(obj))).pipe(Effect.withSpan('Database.add'));
|
|
293
|
+
export const add = <T extends Entity.Unknown>(obj: T & RejectTypeEntity<T>): Effect.Effect<T, never, Service> =>
|
|
294
|
+
Service.pipe(Effect.map(({ db }) => db.add<T>(obj))).pipe(Effect.withSpan('Database.add'));
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Persists a Type definition to the database.
|
|
298
|
+
* @see {@link Database.addType}
|
|
299
|
+
*/
|
|
300
|
+
export const addType = <T extends Type.AnyEntity>(type: T): Effect.Effect<T, never, Service> =>
|
|
301
|
+
Service.pipe(Effect.flatMap(({ db }) => promiseWithCauseCapture(() => db.addType(type)))).pipe(
|
|
302
|
+
Effect.withSpan('Database.addType'),
|
|
303
|
+
);
|
|
265
304
|
|
|
266
305
|
/**
|
|
267
306
|
* Removes an object from the database.
|
|
@@ -283,16 +322,18 @@ export const flush = (opts?: FlushOptions) =>
|
|
|
283
322
|
* Creates a `QueryResult` object that can be subscribed to.
|
|
284
323
|
*/
|
|
285
324
|
export const query: {
|
|
286
|
-
<Q extends Query.Any>(query: Q):
|
|
287
|
-
<F extends Filter.Any>(filter: F):
|
|
325
|
+
<Q extends Query.Any>(query: Q): QueryResult.QueryResultEffect<Query.Type<Q>, never, Service>;
|
|
326
|
+
<F extends Filter.Any>(filter: F): QueryResult.QueryResultEffect<Filter.Type<F>, never, Service>;
|
|
288
327
|
} = (queryOrFilter: Query.Any | Filter.Any) =>
|
|
289
328
|
Service.pipe(
|
|
290
329
|
Effect.map(({ db }) => db.query(queryOrFilter as any) as QueryResult.QueryResult<any>),
|
|
291
330
|
Effect.withSpan('Database.query'),
|
|
331
|
+
makeQueryResultEffect,
|
|
292
332
|
);
|
|
293
333
|
|
|
294
334
|
/**
|
|
295
335
|
* Executes the query once and returns the results.
|
|
336
|
+
* @deprecated Use `yield* query(...).run` instead.
|
|
296
337
|
*/
|
|
297
338
|
export const runQuery: {
|
|
298
339
|
<Q extends Query.Any>(query: Q): Effect.Effect<Query.Type<Q>[], never, Service>;
|
|
@@ -305,6 +346,7 @@ export const runQuery: {
|
|
|
305
346
|
|
|
306
347
|
/**
|
|
307
348
|
* Executes the query once and returns the first result as or None.
|
|
349
|
+
* @deprecated Use `yield* query(...).first` instead.
|
|
308
350
|
*/
|
|
309
351
|
export const runQueryFirst: {
|
|
310
352
|
<Q extends Query.Any>(query: Q): Effect.Effect<Option.Option<Query.Type<Q>>, never, Service>;
|
|
@@ -317,36 +359,19 @@ export const runQueryFirst: {
|
|
|
317
359
|
Effect.withSpan('Database.runQueryFirst'),
|
|
318
360
|
);
|
|
319
361
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
)
|
|
327
|
-
|
|
328
|
-
Effect.flatMap(({ db }) => promiseWithCauseCapture(() => db.schemaRegistry.register(input))),
|
|
329
|
-
Effect.withSpan('Database.registerSchema'),
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Creates a schema query result that can be subscribed to.
|
|
334
|
-
*/
|
|
335
|
-
// TODO(dmaretskyi): Change API to `yield* Database.querySchema(...).first` and `yield* Database.querySchema(...).schema`.
|
|
336
|
-
export const schemaQuery = <Q extends Types.NoExcessProperties<SchemaRegistry.Query, Q>>(
|
|
337
|
-
schemaQueryOptions?: Q & SchemaRegistry.Query,
|
|
338
|
-
): Effect.Effect<QueryResult.QueryResult<SchemaRegistry.ExtractQueryResult<Q>>, never, Service> =>
|
|
339
|
-
Service.pipe(
|
|
340
|
-
Effect.map(({ db }) => db.schemaRegistry.query(schemaQueryOptions)),
|
|
341
|
-
Effect.withSpan('Database.schemaQuery'),
|
|
342
|
-
);
|
|
362
|
+
const makeQueryResultEffect = <T>(
|
|
363
|
+
eff: Effect.Effect<QueryResult.QueryResult<T>, never, Service>,
|
|
364
|
+
): QueryResult.QueryResultEffect<T, never, Service> => {
|
|
365
|
+
return {
|
|
366
|
+
run: Effect.flatMap(eff, (result) => promiseWithCauseCapture(() => result.run())),
|
|
367
|
+
first: Effect.flatMap(eff, (result) =>
|
|
368
|
+
promiseWithCauseCapture(async () => Option.fromNullable(await result.firstOrUndefined())),
|
|
369
|
+
),
|
|
343
370
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
Effect.flatMap((queryResult) => promiseWithCauseCapture(() => queryResult.run())),
|
|
352
|
-
);
|
|
371
|
+
// Effect internals
|
|
372
|
+
...Effectable.CommitPrototype,
|
|
373
|
+
commit() {
|
|
374
|
+
return eff;
|
|
375
|
+
},
|
|
376
|
+
} as any;
|
|
377
|
+
};
|
package/src/Dataset.ts
CHANGED
|
@@ -11,13 +11,21 @@ import * as Schema from 'effect/Schema';
|
|
|
11
11
|
import * as Collection from './Collection';
|
|
12
12
|
import * as Feed from './Feed';
|
|
13
13
|
import * as Obj from './Obj';
|
|
14
|
+
import * as Type from './Type';
|
|
14
15
|
import * as View from './View';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Abstract set of objects, represented by a view, feed, or collection.
|
|
19
|
+
* Schema-level union of the underlying type entities (rebuilt via
|
|
20
|
+
* `Type.getSchema`) so this can still be consumed by Schema-side APIs such
|
|
21
|
+
* as `Filter.type(...)` on a union.
|
|
18
22
|
*/
|
|
19
|
-
export const Dataset = Schema.Union(Feed.Feed, Collection.Collection, View.View);
|
|
20
23
|
export type Dataset = Feed.Feed | Collection.Collection | View.View;
|
|
24
|
+
export const Dataset = Schema.Union(
|
|
25
|
+
Type.getSchema(Feed.Feed),
|
|
26
|
+
Type.getSchema(Collection.Collection),
|
|
27
|
+
Type.getSchema(View.View),
|
|
28
|
+
);
|
|
21
29
|
|
|
22
30
|
export const isDataset: (value: unknown) => value is Dataset = pipe(
|
|
23
31
|
Obj.instanceOf(Feed.Feed),
|
package/src/Entity.test.ts
CHANGED
|
@@ -4,19 +4,129 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import * as Entity from './Entity';
|
|
8
8
|
import * as Obj from './Obj';
|
|
9
9
|
import * as Relation from './Relation';
|
|
10
10
|
import { TestSchema } from './testing';
|
|
11
|
+
import * as Type from './Type';
|
|
12
|
+
|
|
13
|
+
const makeObject = () =>
|
|
14
|
+
Obj.make(TestSchema.Person, {
|
|
15
|
+
name: 'Test',
|
|
16
|
+
username: 'test',
|
|
17
|
+
email: 'test@example.com',
|
|
18
|
+
tasks: [],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const makeRelation = (obj: TestSchema.Person) =>
|
|
22
|
+
Relation.make(TestSchema.HasManager, { [Relation.Source]: obj, [Relation.Target]: obj });
|
|
11
23
|
|
|
12
24
|
describe('Entity', () => {
|
|
13
25
|
test('Entity.Unknown accepts any object or relation', () => {
|
|
14
|
-
const obj =
|
|
15
|
-
const rel =
|
|
16
|
-
const doSomething = (entity: Entity.Unknown) =>
|
|
17
|
-
return entity;
|
|
18
|
-
};
|
|
26
|
+
const obj = makeObject();
|
|
27
|
+
const rel = makeRelation(obj);
|
|
28
|
+
const doSomething = (entity: Entity.Unknown) => entity;
|
|
19
29
|
expect(doSomething(obj)).toBe(obj);
|
|
20
30
|
expect(doSomething(rel)).toBe(rel);
|
|
21
31
|
});
|
|
32
|
+
|
|
33
|
+
// `isEntity` is a bare brand check (`[KindId] !== undefined`). All three entity
|
|
34
|
+
// kinds — objects, relations, and type entities — carry the brand, so all three
|
|
35
|
+
// are recognised as entities. (Type entities brand with `EntityKind.Type`.)
|
|
36
|
+
describe('isEntity / isSnapshot', () => {
|
|
37
|
+
test('object instance is an entity', () => {
|
|
38
|
+
const obj = makeObject();
|
|
39
|
+
expect(Entity.isEntity(obj)).toBe(true);
|
|
40
|
+
expect(Entity.isSnapshot(obj)).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('relation instance is an entity', () => {
|
|
44
|
+
const rel = makeRelation(makeObject());
|
|
45
|
+
expect(Entity.isEntity(rel)).toBe(true);
|
|
46
|
+
expect(Entity.isSnapshot(rel)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('type entity is an entity', () => {
|
|
50
|
+
expect(Entity.isEntity(TestSchema.Person)).toBe(true);
|
|
51
|
+
expect(Entity.isSnapshot(TestSchema.Person)).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('non-entities are rejected', () => {
|
|
55
|
+
expect(Entity.isEntity(null)).toBe(false);
|
|
56
|
+
expect(Entity.isEntity({})).toBe(false);
|
|
57
|
+
expect(Entity.isEntity({ id: 'x' })).toBe(false);
|
|
58
|
+
expect(Entity.isEntity('string')).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Object and relation instances behave identically across the Entity.* accessor
|
|
63
|
+
// surface: these accessors are written for runtime instances and read the
|
|
64
|
+
// instance's identity, type pointer and metadata.
|
|
65
|
+
describe.each([
|
|
66
|
+
['object', () => makeObject(), 'com.example.type.person'],
|
|
67
|
+
['relation', () => makeRelation(makeObject()), 'com.example.type.hasManager'],
|
|
68
|
+
] as const)('instance accessors (%s)', (_label, make, typename) => {
|
|
69
|
+
test('getURI returns an echo URI', () => {
|
|
70
|
+
const entity = make();
|
|
71
|
+
expect(Entity.getURI(entity)).toMatch(/^echo:/);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('getTypename returns the typename', () => {
|
|
75
|
+
expect(Entity.getTypename(make())).toBe(typename);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('getTypeURI returns the type DXN', () => {
|
|
79
|
+
expect(Entity.getTypeURI(make())).toBe(`dxn:${typename}:0.1.0`);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('getType resolves back to the type entity', () => {
|
|
83
|
+
const type = Entity.getType(make());
|
|
84
|
+
expect(type).toBeDefined();
|
|
85
|
+
expect(Type.getTypename(type!)).toBe(typename);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('getMeta returns metadata', () => {
|
|
89
|
+
expect(Entity.getMeta(make())).toBeDefined();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('isDeleted is false for a live entity', () => {
|
|
93
|
+
expect(Entity.isDeleted(make())).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('toJSON serializes the entity', () => {
|
|
97
|
+
const json = Entity.toJSON(make());
|
|
98
|
+
expect(json).toMatchObject({ '@type': expect.stringContaining(typename) });
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Type entities are first-class entities: the Entity.* accessors work on them too.
|
|
103
|
+
// `getURI`/`getTypename` return the type's OWN identity, while `getType`/`getTypeURI`
|
|
104
|
+
// (which mean "the type this entity is an instance of") resolve to the meta-type
|
|
105
|
+
// `Type.Type`.
|
|
106
|
+
describe('type entity', () => {
|
|
107
|
+
test('isEntity / getMeta / isDeleted', () => {
|
|
108
|
+
expect(Entity.isEntity(TestSchema.Person)).toBe(true);
|
|
109
|
+
expect(Entity.getMeta(TestSchema.Person)).toBeDefined();
|
|
110
|
+
expect(Entity.isDeleted(TestSchema.Person)).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('getURI / getTypename return the type entity’s own identity', () => {
|
|
114
|
+
expect(Entity.getURI(TestSchema.Person)).toBe('dxn:com.example.type.person:0.1.0');
|
|
115
|
+
expect(Entity.getTypename(TestSchema.Person)).toBe('com.example.type.person');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('getType / getTypeURI resolve to the meta-type (Type.Type)', () => {
|
|
119
|
+
expect(Entity.getType(TestSchema.Person)).toBe(Type.Type);
|
|
120
|
+
expect(Entity.getTypeURI(TestSchema.Person)).toBe('dxn:org.dxos.type.schema:0.1.0');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('Entity.* and Type.* agree on type identity', () => {
|
|
124
|
+
expect(Entity.getURI(TestSchema.Person)).toBe(Type.getURI(TestSchema.Person));
|
|
125
|
+
expect(Entity.getTypename(TestSchema.Person)).toBe(Type.getTypename(TestSchema.Person));
|
|
126
|
+
expect(Type.isType(TestSchema.Person)).toBe(true);
|
|
127
|
+
expect(Type.isObject(TestSchema.Person)).toBe(true);
|
|
128
|
+
expect(Type.isRelation(TestSchema.HasManager)).toBe(true);
|
|
129
|
+
expect(Type.getVersion(TestSchema.Person)).toBe('0.1.0');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
22
132
|
});
|