@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
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { invariant } from '@dxos/invariant';
|
|
6
|
-
import { type
|
|
6
|
+
import { type EID } from '@dxos/keys';
|
|
7
7
|
import { assumeType } from '@dxos/util';
|
|
8
8
|
|
|
9
9
|
import type { AnyEntity } from '../common/types';
|
|
10
10
|
import { type InternalObjectProps, ObjectDatabaseId } from './model';
|
|
11
|
-
import {
|
|
11
|
+
import { getObjectEchoUri } from './util';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Get the
|
|
14
|
+
* Get the canonical EID of an entity.
|
|
15
15
|
* Accepts both reactive entities and snapshots.
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
18
|
-
const
|
|
19
|
-
invariant(
|
|
20
|
-
return
|
|
17
|
+
export const getUri = (entity: AnyEntity): EID.EID => {
|
|
18
|
+
const uri = getObjectEchoUri(entity);
|
|
19
|
+
invariant(uri != null, 'Invalid entity.');
|
|
20
|
+
return uri;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -3,47 +3,119 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
|
-
import
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
import type * as Types from 'effect/Types';
|
|
8
8
|
|
|
9
|
+
import { DXN, EntityId } from '@dxos/keys';
|
|
9
10
|
import { type ToMutable } from '@dxos/util';
|
|
10
11
|
|
|
11
|
-
import { type
|
|
12
|
-
import {
|
|
12
|
+
import { type TypeAnnotation, TypeAnnotationId } from '../Annotation/annotations';
|
|
13
|
+
import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
|
|
14
|
+
import { defineHiddenProperty } from '../common/proxy/define-hidden-property';
|
|
15
|
+
import { makeObject } from '../common/proxy/make-object';
|
|
16
|
+
import { getProxyTarget } from '../common/proxy/proxy-utils';
|
|
17
|
+
import {
|
|
18
|
+
type AnyEntity,
|
|
19
|
+
EntityKind,
|
|
20
|
+
InstancePhantomId,
|
|
21
|
+
KindId,
|
|
22
|
+
SchemaKindId,
|
|
23
|
+
StaticTypeSchemaSlot,
|
|
24
|
+
} from '../common/types';
|
|
25
|
+
import { type EntityMeta } from '../common/types/meta';
|
|
26
|
+
import { JsonSchemaType } from '../JsonSchema/json-schema-type';
|
|
13
27
|
|
|
14
28
|
// TODO(burdon): Define Schema type for `typename` and use consistently for all DXN-like properties.
|
|
15
29
|
|
|
16
30
|
// type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
17
31
|
export type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<AnyEntity & ToMutable<T> & ExtraFields>;
|
|
18
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Options accepted by every `Type.makeObject` / `Type.makeRelation` / type-kind
|
|
35
|
+
* factory. Defaults are derived from `(typename, version)` so callers normally
|
|
36
|
+
* pass nothing.
|
|
37
|
+
*/
|
|
38
|
+
export type EchoTypeOptions = {
|
|
39
|
+
/**
|
|
40
|
+
* Override the entity id stamped on the in-memory `Type.Type` value.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to `EntityId.deterministic(typename, version)` — stable across processes
|
|
43
|
+
* and workerd-safe (no `crypto.getRandomValues()` at module-evaluation time).
|
|
44
|
+
* Pass an explicit id (typically `EntityId.random()`) to opt out of the
|
|
45
|
+
* deterministic default.
|
|
46
|
+
*/
|
|
47
|
+
id?: EntityId;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* In-memory `Type.Type` entity shape produced by `Type.makeObject(dxn)` /
|
|
52
|
+
* `Type.makeRelation({...})`. A live reactive `TypeSchema` instance —
|
|
53
|
+
* identical to a persisted `Type.Type` except for database attachment.
|
|
54
|
+
*
|
|
55
|
+
* NOT a `Schema.Schema`. The underlying Effect Schema is cached on the hidden
|
|
56
|
+
* `StaticTypeSchemaSlot` slot — retrieve it via `Type.getSchema(...)`.
|
|
57
|
+
*/
|
|
19
58
|
// TODO(burdon): Rename EchoEntitySchema.
|
|
20
59
|
export interface EchoTypeSchema<
|
|
21
60
|
Self extends Schema.Schema.Any,
|
|
22
61
|
ExtraFields = {},
|
|
23
62
|
K extends EntityKind = EntityKind,
|
|
24
63
|
Fields extends Schema.Struct.Fields = Schema.Struct.Fields,
|
|
25
|
-
>
|
|
26
|
-
extends
|
|
27
|
-
TypeMeta,
|
|
28
|
-
Schema.AnnotableClass<
|
|
29
|
-
EchoTypeSchema<Self, ExtraFields, K, Fields>,
|
|
30
|
-
EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>,
|
|
31
|
-
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>, ExtraFields>,
|
|
32
|
-
Schema.Schema.Context<Self>
|
|
33
|
-
> {
|
|
64
|
+
> {
|
|
34
65
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
66
|
+
* Entity-kind brand. Type entities are their own kind (`Type`) regardless of
|
|
67
|
+
* the kind of instance they describe — `[SchemaKindId]` carries the latter.
|
|
68
|
+
* This lets predicates like `Obj.isObject` / `Relation.isRelation` cleanly
|
|
69
|
+
* reject type entities without also having to inspect `[SchemaKindId]`.
|
|
37
70
|
*/
|
|
71
|
+
readonly [KindId]: EntityKind.Type;
|
|
72
|
+
|
|
73
|
+
/** Schema-kind brand indicating what kind of instance this type describes. */
|
|
38
74
|
readonly [SchemaKindId]: K;
|
|
39
75
|
|
|
40
76
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
77
|
+
* Entity id. Always present — stamped at construction — but NOT the type's
|
|
78
|
+
* identity while in-memory: an unattached type resolves its URI to the typename
|
|
79
|
+
* DXN, switching to `echo:/<id>` only once attached to a database (see
|
|
80
|
+
* `getTypeURIFromSpecifier`, which discriminates by database attachment).
|
|
43
81
|
*/
|
|
82
|
+
readonly id: EntityId;
|
|
83
|
+
|
|
84
|
+
/** Source Effect Schema (kept on a hidden slot for `Type.getSchema`). */
|
|
85
|
+
readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
86
|
+
|
|
87
|
+
// NOTE: `typename` / `version` are intentionally NOT fields. They live in
|
|
88
|
+
// `EntityMeta` (`key` / `version`); read via `Type.getTypename(self)` /
|
|
89
|
+
// `Type.getVersion(self)`.
|
|
90
|
+
readonly jsonSchema: JsonSchemaType;
|
|
91
|
+
|
|
92
|
+
/** Struct fields for introspection. */
|
|
44
93
|
readonly fields: Fields;
|
|
45
94
|
|
|
46
|
-
|
|
95
|
+
/** Phantom — instance type produced by `Obj.make(self, ...)`. */
|
|
96
|
+
readonly _instance?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Phantom slot mirroring `Type<A>` so internal helpers (`makeObject`,
|
|
100
|
+
* `createObject`, `Ref.make`) infer the instance type uniformly whether
|
|
101
|
+
* the caller passes an `EchoTypeSchema` or a top-level `Type.Type` entity.
|
|
102
|
+
*
|
|
103
|
+
* Includes the instance-kind brand (`[KindId]`) so the phantom is assignable
|
|
104
|
+
* to the matching public-side interface in `Type.ts` (`Type.Obj` /
|
|
105
|
+
* `Type.Relation` / `Type.Type`). Each kind projects identity: instances of
|
|
106
|
+
* an object-kind schema are object-kind entities, type-kind schemas produce
|
|
107
|
+
* type-kind (persisted Type.Type) entities — the latter additionally carry
|
|
108
|
+
* the `[SchemaKindId]` / `[StaticTypeSchemaSlot]` brands the echo-handler
|
|
109
|
+
* proxy exposes on persisted Type entities.
|
|
110
|
+
*/
|
|
111
|
+
readonly [InstancePhantomId]?: EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields> & {
|
|
112
|
+
readonly [KindId]: K;
|
|
113
|
+
} & (K extends EntityKind.Type
|
|
114
|
+
? {
|
|
115
|
+
readonly [SchemaKindId]: EntityKind.Type;
|
|
116
|
+
readonly [StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;
|
|
117
|
+
}
|
|
118
|
+
: {});
|
|
47
119
|
}
|
|
48
120
|
|
|
49
121
|
// type MakeProps =
|
|
@@ -77,8 +149,60 @@ export interface EchoTypeSchema<
|
|
|
77
149
|
// const _getDisableValidationMakeOption = (options: MakeProps | undefined): boolean =>
|
|
78
150
|
// Predicate.isBoolean(options) ? options : options?.disableValidation ?? false;
|
|
79
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Identity (typename + version) of the type meta-schema — the `Type.Type` that
|
|
154
|
+
* every ECHO type entity is itself an instance of. Shared by the materialisation
|
|
155
|
+
* vehicle ({@link persistentEntitySchema}) and `TypeSchema` so the two cannot
|
|
156
|
+
* drift on identity.
|
|
157
|
+
*/
|
|
158
|
+
export const TypeMetaSchemaDXN = DXN.make('org.dxos.type.schema', '0.1.0');
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Effect Schema that every `Type.Type` entity is an instance of: the meta-schema
|
|
162
|
+
* struct `{ name?, jsonSchema, id }` branded as a type-kind ECHO entity. This is
|
|
163
|
+
* the materialisation vehicle for `makeObject` below — the canonical user-facing
|
|
164
|
+
* entity is `Type/type-schema.ts`'s `TypeSchema`, which carries the same shape
|
|
165
|
+
* plus UI annotations.
|
|
166
|
+
*
|
|
167
|
+
* Kept self-contained (no import of `TypeSchema`) to avoid a bootstrap cycle:
|
|
168
|
+
* `TypeSchema` is itself produced via `makeEchoTypeSchema`, so this builder must
|
|
169
|
+
* not depend on it. `jsonSchema` is declared optional here (only on the
|
|
170
|
+
* materialisation vehicle — the canonical `TypeSchema` keeps it required) so the
|
|
171
|
+
* construction-time `Schema.asserts` does not force the field before it is
|
|
172
|
+
* attached; it is populated immediately after via a lazy accessor (see
|
|
173
|
+
* `makeEchoTypeSchema`).
|
|
174
|
+
*/
|
|
175
|
+
// TODO(wittjosiah): Reconcile with `TypeSchema` (`Type/type-schema.ts`).
|
|
176
|
+
// Both describe the same `org.dxos.type.schema` shape.
|
|
177
|
+
const persistentEntitySchema: Schema.Schema.AnyNoContext = (() => {
|
|
178
|
+
const typename = DXN.getName(TypeMetaSchemaDXN);
|
|
179
|
+
const version = DXN.getVersion(TypeMetaSchemaDXN)!;
|
|
180
|
+
const struct = Schema.Struct({
|
|
181
|
+
name: Schema.optional(Schema.String),
|
|
182
|
+
jsonSchema: JsonSchemaType.pipe(Schema.optional),
|
|
183
|
+
id: EntityId,
|
|
184
|
+
});
|
|
185
|
+
const ast = SchemaAST.annotations(struct.ast, {
|
|
186
|
+
[TypeAnnotationId]: { kind: EntityKind.Type, typename, version } satisfies TypeAnnotation,
|
|
187
|
+
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({ kind: EntityKind.Type, typename, version }),
|
|
188
|
+
});
|
|
189
|
+
return Schema.make(ast);
|
|
190
|
+
})();
|
|
191
|
+
|
|
80
192
|
/**
|
|
81
193
|
* @internal
|
|
194
|
+
*
|
|
195
|
+
* Build an in-memory `Type.Type` entity (the value returned by `Type.makeObject`
|
|
196
|
+
* / `Type.makeRelation`). The result is a LIVE reactive `TypeSchema`
|
|
197
|
+
* instance — identical in every respect to a persisted `Type.Type` except that
|
|
198
|
+
* it is not yet attached to a database. It is mutable via `Type.update`, can be
|
|
199
|
+
* passed to `db.add(...)` (which keeps the same proxy and swaps the handler),
|
|
200
|
+
* and round-trips through `jsonSchema`.
|
|
201
|
+
*
|
|
202
|
+
* The source Effect Schema describing the user's type is cached on
|
|
203
|
+
* `[StaticTypeSchemaSlot]` so `Type.getSchema(...)` returns it without a
|
|
204
|
+
* jsonSchema round-trip; the cache is invalidated by the proxy set-trap when
|
|
205
|
+
* `jsonSchema` is mutated (see `typed-handler.ts`).
|
|
82
206
|
*/
|
|
83
207
|
export const makeEchoTypeSchema = <
|
|
84
208
|
Self extends Schema.Schema.Any,
|
|
@@ -91,38 +215,63 @@ export const makeEchoTypeSchema = <
|
|
|
91
215
|
typename: string,
|
|
92
216
|
version: string,
|
|
93
217
|
kind: K,
|
|
218
|
+
computeJsonSchema: () => JsonSchemaType,
|
|
219
|
+
explicitId?: EntityId,
|
|
94
220
|
): EchoTypeSchema<Self, {}, K, Fields> => {
|
|
95
|
-
|
|
221
|
+
// Source Effect Schema describing the user's type — cached for `Type.getSchema`.
|
|
222
|
+
const sourceSchema = Schema.make<
|
|
96
223
|
EchoTypeSchemaProps<Schema.Schema.Type<Self>>,
|
|
97
224
|
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>>,
|
|
98
225
|
Schema.Schema.Context<Self>
|
|
99
|
-
>(ast)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
226
|
+
>(ast);
|
|
227
|
+
|
|
228
|
+
// `typename` / `version` route through `EntityMeta` (`key` / `version`) — the
|
|
229
|
+
// canonical registry-provenance pair — not data fields. `keys` is empty for
|
|
230
|
+
// in-memory declarations until persisted.
|
|
231
|
+
const meta: Partial<EntityMeta> = { keys: [], key: typename, version };
|
|
232
|
+
|
|
233
|
+
// Default to a deterministic id derived from `(typename, version)` so that
|
|
234
|
+
// constructing a `Type.Type` entity never reaches `crypto.getRandomValues()`.
|
|
235
|
+
// Cloudflare workerd forbids RNG calls in global scope, and the ~hundreds of
|
|
236
|
+
// `Type.makeObject(...)` call sites across the monorepo execute at module top.
|
|
237
|
+
// `setIdOnTarget` (see `proxy/make-object.ts`) short-circuits on a pre-supplied
|
|
238
|
+
// valid id, so this also bypasses the `EntityId.random()` path inside `makeObject`.
|
|
239
|
+
// Callers can override via `Type.makeObject(dxn, { id })` when they want a fresh
|
|
240
|
+
// random id (e.g. inside a request handler where workerd does allow RNG).
|
|
241
|
+
const id = explicitId ?? EntityId.deterministic(typename, version);
|
|
242
|
+
|
|
243
|
+
// Materialise as a live reactive meta-schema instance. `jsonSchema` is attached
|
|
244
|
+
// below as a getter (not passed here as data) for two reasons; see that accessor.
|
|
245
|
+
const entity = makeObject(persistentEntitySchema, { id } as any, meta);
|
|
246
|
+
|
|
247
|
+
const target = getProxyTarget(entity)!;
|
|
248
|
+
// `jsonSchema` is always available, but computed once on first read rather than at
|
|
249
|
+
// construction: serializing the AST walks `Schema.suspend(...)` thunks, and for a
|
|
250
|
+
// self-referential type (`Schema.suspend(() => Self)`) that thunk hits `Self`'s TDZ
|
|
251
|
+
// while we're still inside its `const` initializer. A getter also lets reads return
|
|
252
|
+
// the raw object instead of a child reactive proxy.
|
|
253
|
+
let memoizedJsonSchema: JsonSchemaType | undefined;
|
|
254
|
+
Object.defineProperty(target, 'jsonSchema', {
|
|
255
|
+
configurable: true,
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get() {
|
|
258
|
+
return (memoizedJsonSchema ??= computeJsonSchema());
|
|
259
|
+
},
|
|
260
|
+
set(value: JsonSchemaType) {
|
|
261
|
+
memoizedJsonSchema = value;
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
// Cache the source Effect Schema (read by `Type.getSchema` via the proxy's
|
|
265
|
+
// `[StaticTypeSchemaSlot]` get-trap; invalidated on `jsonSchema` mutation).
|
|
266
|
+
defineHiddenProperty(target, StaticTypeSchemaSlot, sourceSchema);
|
|
267
|
+
// Schema-kind brand: what kind of instance this type describes. There is no
|
|
268
|
+
// database handler to derive it for in-memory entities, so stamp it directly.
|
|
269
|
+
defineHiddenProperty(target, SchemaKindId, kind);
|
|
270
|
+
// Struct fields for introspection. A getter (not a data property) so reads return
|
|
271
|
+
// the raw fields object rather than a child reactive proxy.
|
|
272
|
+
Object.defineProperty(target, 'fields', { configurable: true, enumerable: false, get: () => fields });
|
|
273
|
+
|
|
274
|
+
return entity as unknown as EchoTypeSchema<Self, {}, K, Fields>;
|
|
128
275
|
};
|
|
276
|
+
|
|
277
|
+
export { isEntity } from './guard';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Entity from '../../Entity';
|
|
6
|
+
import { KindId, SnapshotKindId } from '../common/types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the value is an ECHO entity instance (object or relation).
|
|
10
|
+
*/
|
|
11
|
+
export const isEntity = (value: unknown): value is Entity.Unknown => {
|
|
12
|
+
if (typeof value !== 'object' || value === null) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return (value as any)[KindId] !== undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the value is an ECHO entity snapshot.
|
|
20
|
+
*/
|
|
21
|
+
export const isSnapshot = (value: unknown): value is Entity.Snapshot => {
|
|
22
|
+
if (typeof value !== 'object' || value === null) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return (value as any)[SnapshotKindId] !== undefined;
|
|
26
|
+
};
|
|
@@ -6,24 +6,22 @@ import type * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { type ForeignKey } from '@dxos/echo-protocol';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import {
|
|
9
|
+
import { EID, EntityId, type URI } from '@dxos/keys';
|
|
10
10
|
import { assumeType } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import type * as Database from '../../Database';
|
|
13
13
|
import {
|
|
14
|
-
type ATTR_META,
|
|
15
14
|
type ATTR_PARENT,
|
|
16
15
|
type ATTR_TYPE,
|
|
17
16
|
ATTR_DELETED,
|
|
18
17
|
ATTR_RELATION_SOURCE,
|
|
19
18
|
ATTR_RELATION_TARGET,
|
|
20
|
-
|
|
19
|
+
ATTR_SELF_URI,
|
|
20
|
+
ATTR_SELF_URI_LEGACY,
|
|
21
21
|
EntityKind,
|
|
22
22
|
KindId,
|
|
23
|
-
type MetaId,
|
|
24
23
|
ObjectDatabaseId,
|
|
25
24
|
ObjectDeletedId,
|
|
26
|
-
type ObjectMeta,
|
|
27
25
|
ObjectVersionId,
|
|
28
26
|
type ParentId,
|
|
29
27
|
RelationSourceDXNId,
|
|
@@ -31,12 +29,21 @@ import {
|
|
|
31
29
|
RelationTargetDXNId,
|
|
32
30
|
RelationTargetId,
|
|
33
31
|
type SchemaId,
|
|
34
|
-
|
|
32
|
+
SelfURIId,
|
|
35
33
|
TypeId,
|
|
36
34
|
type Version,
|
|
37
35
|
} from '../common/types';
|
|
36
|
+
import { type ATTR_META, type MetaId, type EntityMeta } from '../common/types/meta';
|
|
38
37
|
|
|
39
|
-
export {
|
|
38
|
+
export {
|
|
39
|
+
ATTR_DELETED,
|
|
40
|
+
ATTR_SELF_URI,
|
|
41
|
+
ATTR_SELF_URI_LEGACY,
|
|
42
|
+
ObjectDatabaseId,
|
|
43
|
+
ObjectDeletedId,
|
|
44
|
+
ObjectVersionId,
|
|
45
|
+
SelfURIId,
|
|
46
|
+
};
|
|
40
47
|
|
|
41
48
|
/**
|
|
42
49
|
* Internal runtime representation of an object.
|
|
@@ -44,18 +51,18 @@ export { ATTR_DELETED, ATTR_SELF_DXN, ObjectDatabaseId, ObjectDeletedId, ObjectV
|
|
|
44
51
|
*/
|
|
45
52
|
// NOTE: Each symbol has a jsdoc describing its purpose.
|
|
46
53
|
export interface InternalObjectProps {
|
|
47
|
-
readonly id:
|
|
48
|
-
readonly [
|
|
54
|
+
readonly id: EntityId;
|
|
55
|
+
readonly [SelfURIId]: EID.EID;
|
|
49
56
|
readonly [KindId]: EntityKind;
|
|
50
57
|
readonly [SchemaId]: Schema.Schema.AnyNoContext;
|
|
51
|
-
readonly [TypeId]:
|
|
52
|
-
readonly [MetaId]?:
|
|
58
|
+
readonly [TypeId]: URI.URI;
|
|
59
|
+
readonly [MetaId]?: EntityMeta;
|
|
53
60
|
[ParentId]?: InternalObjectProps;
|
|
54
61
|
readonly [ObjectDatabaseId]?: Database.Database;
|
|
55
62
|
readonly [ObjectDeletedId]?: boolean;
|
|
56
63
|
readonly [ObjectVersionId]?: Version;
|
|
57
|
-
readonly [RelationSourceDXNId]?:
|
|
58
|
-
readonly [RelationTargetDXNId]?:
|
|
64
|
+
readonly [RelationSourceDXNId]?: EID.EID;
|
|
65
|
+
readonly [RelationTargetDXNId]?: EID.EID;
|
|
59
66
|
readonly [RelationSourceId]?: InternalObjectProps;
|
|
60
67
|
readonly [RelationTargetId]?: InternalObjectProps;
|
|
61
68
|
}
|
|
@@ -63,7 +70,7 @@ export interface InternalObjectProps {
|
|
|
63
70
|
/**
|
|
64
71
|
* Entity metadata.
|
|
65
72
|
*/
|
|
66
|
-
export interface
|
|
73
|
+
export interface EntityMetaJSON {
|
|
67
74
|
keys: ForeignKey[];
|
|
68
75
|
tags?: string[];
|
|
69
76
|
key?: string;
|
|
@@ -74,14 +81,14 @@ export interface ObjectMetaJSON {
|
|
|
74
81
|
* JSON representation of an object or relation metadata.
|
|
75
82
|
*/
|
|
76
83
|
export interface ObjectJSON {
|
|
77
|
-
id:
|
|
78
|
-
[ATTR_TYPE]
|
|
79
|
-
[
|
|
80
|
-
[ATTR_PARENT]?:
|
|
84
|
+
id: EntityId;
|
|
85
|
+
[ATTR_TYPE]?: URI.URI;
|
|
86
|
+
[ATTR_SELF_URI]?: EID.EID;
|
|
87
|
+
[ATTR_PARENT]?: EID.EID; // Encoded reference
|
|
81
88
|
[ATTR_DELETED]?: boolean;
|
|
82
|
-
[ATTR_META]?:
|
|
83
|
-
[ATTR_RELATION_SOURCE]?:
|
|
84
|
-
[ATTR_RELATION_TARGET]?:
|
|
89
|
+
[ATTR_META]?: EntityMetaJSON;
|
|
90
|
+
[ATTR_RELATION_SOURCE]?: EID.EID;
|
|
91
|
+
[ATTR_RELATION_TARGET]?: EID.EID;
|
|
85
92
|
|
|
86
93
|
/**
|
|
87
94
|
* Application-specific properties.
|
|
@@ -95,17 +102,17 @@ export interface ObjectJSON {
|
|
|
95
102
|
export function assertObjectModel(obj: unknown): asserts obj is InternalObjectProps {
|
|
96
103
|
invariant(typeof obj === 'object' && obj !== null, 'Invalid object model: not an object');
|
|
97
104
|
assumeType<InternalObjectProps>(obj);
|
|
98
|
-
invariant(
|
|
99
|
-
invariant(obj[TypeId] === undefined || obj[TypeId]
|
|
105
|
+
invariant(EntityId.isValid(obj.id), 'Invalid object model: invalid id');
|
|
106
|
+
invariant(obj[TypeId] === undefined || typeof obj[TypeId] === 'string', 'Invalid object model: invalid type');
|
|
100
107
|
invariant(
|
|
101
|
-
obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation,
|
|
108
|
+
obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation || obj[KindId] === EntityKind.Type,
|
|
102
109
|
'Invalid object model: invalid entity kind',
|
|
103
110
|
);
|
|
104
111
|
|
|
105
112
|
if (obj[KindId] === EntityKind.Relation) {
|
|
106
|
-
invariant(obj[RelationSourceDXNId]
|
|
107
|
-
invariant(obj[RelationTargetDXNId]
|
|
108
|
-
invariant(!(obj[RelationSourceId]
|
|
109
|
-
invariant(!(obj[RelationTargetId]
|
|
113
|
+
invariant(EID.isEID(obj[RelationSourceDXNId]), 'Invalid object model: invalid relation source');
|
|
114
|
+
invariant(EID.isEID(obj[RelationTargetDXNId]), 'Invalid object model: invalid relation target');
|
|
115
|
+
invariant(!EID.isEID(obj[RelationSourceId]), 'Invalid object model: source pointer is a DXN');
|
|
116
|
+
invariant(!EID.isEID(obj[RelationTargetId]), 'Invalid object model: target pointer is a DXN');
|
|
110
117
|
}
|
|
111
118
|
}
|
|
@@ -6,10 +6,13 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { DXN } from '@dxos/keys';
|
|
9
10
|
|
|
10
|
-
import { type TypeAnnotation, TypeAnnotationId
|
|
11
|
+
import { type TypeAnnotation, TypeAnnotationId } from '../Annotation/annotations';
|
|
12
|
+
import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
|
|
11
13
|
import { EntityKind } from '../common/types';
|
|
12
|
-
import {
|
|
14
|
+
import { toJsonSchema } from '../JsonSchema';
|
|
15
|
+
import { type EchoTypeOptions, type EchoTypeSchema, makeEchoTypeSchema } from './entity';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Object schema type with kind marker.
|
|
@@ -25,11 +28,16 @@ export type EchoObjectSchema<
|
|
|
25
28
|
*/
|
|
26
29
|
export const EchoObjectSchema: {
|
|
27
30
|
(
|
|
28
|
-
|
|
31
|
+
dxn: DXN.DXN,
|
|
32
|
+
options?: EchoTypeOptions,
|
|
29
33
|
): <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
30
34
|
self: Self & { fields?: Fields },
|
|
31
35
|
) => EchoObjectSchema<Self, Fields>;
|
|
32
|
-
} = (
|
|
36
|
+
} = (dxn, options) => {
|
|
37
|
+
const typename = DXN.getName(dxn);
|
|
38
|
+
const version = DXN.getVersion(dxn);
|
|
39
|
+
invariant(version, `Type.makeObject requires a versioned DXN: ${dxn}`);
|
|
40
|
+
|
|
33
41
|
return <Self extends Schema.Schema.Any, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>(
|
|
34
42
|
self: Self & { fields?: Fields },
|
|
35
43
|
): EchoObjectSchema<Self, Fields> => {
|
|
@@ -52,6 +60,14 @@ export const EchoObjectSchema: {
|
|
|
52
60
|
}),
|
|
53
61
|
});
|
|
54
62
|
|
|
55
|
-
return makeEchoTypeSchema<Self, EntityKind.Object, Fields>(
|
|
63
|
+
return makeEchoTypeSchema<Self, EntityKind.Object, Fields>(
|
|
64
|
+
fields,
|
|
65
|
+
ast,
|
|
66
|
+
typename,
|
|
67
|
+
version,
|
|
68
|
+
EntityKind.Object,
|
|
69
|
+
() => toJsonSchema(Schema.make(ast)),
|
|
70
|
+
options?.id,
|
|
71
|
+
);
|
|
56
72
|
};
|
|
57
73
|
};
|