@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
|
@@ -8,7 +8,7 @@ import * as SchemaAST from 'effect/SchemaAST';
|
|
|
8
8
|
import { describe, expect, test } from 'vitest';
|
|
9
9
|
|
|
10
10
|
import { type JsonProp, findAnnotation } from '@dxos/effect';
|
|
11
|
-
import {
|
|
11
|
+
import { DXN, EntityId } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
|
|
14
14
|
import { TestSchema, prepareAstForCompare } from '../../testing';
|
|
@@ -26,7 +26,7 @@ import { EchoObjectSchema } from '../Entity';
|
|
|
26
26
|
import { Email, FormatAnnotation, TypeFormat } from '../Format';
|
|
27
27
|
import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../JsonSchema';
|
|
28
28
|
import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../Ref';
|
|
29
|
-
import {
|
|
29
|
+
import { TypeSchema } from '../Type';
|
|
30
30
|
import { toEffectSchema, toJsonSchema } from './json-schema';
|
|
31
31
|
|
|
32
32
|
const EXAMPLE_NAMESPACE = '@example';
|
|
@@ -34,26 +34,18 @@ const EXAMPLE_NAMESPACE = '@example';
|
|
|
34
34
|
describe('effect-to-json', () => {
|
|
35
35
|
test('type annotation', () => {
|
|
36
36
|
const Test = Schema.Struct({ name: Schema.String }).pipe(
|
|
37
|
-
Type.
|
|
38
|
-
typename: 'com.example.type.test',
|
|
39
|
-
version: '0.1.0',
|
|
40
|
-
}),
|
|
37
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
41
38
|
);
|
|
42
39
|
const jsonSchema = toJsonSchema(Test);
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
40
|
+
expect(jsonSchema.$id).toEqual('dxn:com.example.type.test:0.1.0');
|
|
41
|
+
expect(jsonSchema.version).toEqual('0.1.0');
|
|
45
42
|
});
|
|
46
43
|
|
|
47
44
|
test('property meta annotation', () => {
|
|
48
45
|
const meta = { maxLength: 0 };
|
|
49
46
|
const Test = Schema.Struct({
|
|
50
47
|
name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
|
|
51
|
-
}).pipe(
|
|
52
|
-
Type.object({
|
|
53
|
-
typename: 'com.example.type.test',
|
|
54
|
-
version: '0.1.0',
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
48
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
57
49
|
const jsonSchema = toJsonSchema(Test);
|
|
58
50
|
expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
|
|
59
51
|
});
|
|
@@ -61,20 +53,10 @@ describe('effect-to-json', () => {
|
|
|
61
53
|
test('reference annotation', () => {
|
|
62
54
|
const Nested = Schema.Struct({
|
|
63
55
|
name: Schema.String,
|
|
64
|
-
}).pipe(
|
|
65
|
-
Type.object({
|
|
66
|
-
typename: 'com.example.type.testNested',
|
|
67
|
-
version: '0.1.0',
|
|
68
|
-
}),
|
|
69
|
-
);
|
|
56
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
70
57
|
const Test = Schema.Struct({
|
|
71
58
|
name: Ref(Nested),
|
|
72
|
-
}).pipe(
|
|
73
|
-
Type.object({
|
|
74
|
-
typename: 'com.example.type.test',
|
|
75
|
-
version: '0.1.0',
|
|
76
|
-
}),
|
|
77
|
-
);
|
|
59
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
78
60
|
const jsonSchema = toJsonSchema(Test);
|
|
79
61
|
// log.info('schema', { jsonSchema });
|
|
80
62
|
const nested = jsonSchema.properties!.name;
|
|
@@ -86,20 +68,10 @@ describe('effect-to-json', () => {
|
|
|
86
68
|
test.skip('reference annotation with lookup property', () => {
|
|
87
69
|
const Nested = Schema.Struct({
|
|
88
70
|
name: Schema.String,
|
|
89
|
-
}).pipe(
|
|
90
|
-
Type.object({
|
|
91
|
-
typename: 'com.example.type.testNested',
|
|
92
|
-
version: '0.1.0',
|
|
93
|
-
}),
|
|
94
|
-
);
|
|
71
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
95
72
|
const Test = Schema.Struct({
|
|
96
73
|
name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
|
|
97
|
-
}).pipe(
|
|
98
|
-
Type.object({
|
|
99
|
-
typename: 'com.example.type.test',
|
|
100
|
-
version: '0.1.0',
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
74
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
103
75
|
const jsonSchema = toJsonSchema(Test);
|
|
104
76
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
105
77
|
|
|
@@ -110,20 +82,10 @@ describe('effect-to-json', () => {
|
|
|
110
82
|
test('array of references', () => {
|
|
111
83
|
const Nested = Schema.Struct({
|
|
112
84
|
name: Schema.String,
|
|
113
|
-
}).pipe(
|
|
114
|
-
Type.object({
|
|
115
|
-
typename: 'com.example.type.testNested',
|
|
116
|
-
version: '0.1.0',
|
|
117
|
-
}),
|
|
118
|
-
);
|
|
85
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
119
86
|
const Test = Schema.Struct({
|
|
120
87
|
name: Schema.Array(Ref(Nested)),
|
|
121
|
-
}).pipe(
|
|
122
|
-
Type.object({
|
|
123
|
-
typename: 'com.example.type.test',
|
|
124
|
-
version: '0.1.0',
|
|
125
|
-
}),
|
|
126
|
-
);
|
|
88
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
127
89
|
|
|
128
90
|
const jsonSchema = toJsonSchema(Test);
|
|
129
91
|
expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
|
|
@@ -132,20 +94,10 @@ describe('effect-to-json', () => {
|
|
|
132
94
|
test('optional references', () => {
|
|
133
95
|
const Nested = Schema.Struct({
|
|
134
96
|
name: Schema.String,
|
|
135
|
-
}).pipe(
|
|
136
|
-
Type.object({
|
|
137
|
-
typename: 'com.example.type.testNested',
|
|
138
|
-
version: '0.1.0',
|
|
139
|
-
}),
|
|
140
|
-
);
|
|
97
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
141
98
|
const Test = Schema.Struct({
|
|
142
99
|
name: Schema.optional(Ref(Nested)),
|
|
143
|
-
}).pipe(
|
|
144
|
-
Type.object({
|
|
145
|
-
typename: 'com.example.type.test',
|
|
146
|
-
version: '0.1.0',
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
100
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
149
101
|
const jsonSchema = toJsonSchema(Test);
|
|
150
102
|
expectReferenceAnnotation(jsonSchema.properties!.name);
|
|
151
103
|
});
|
|
@@ -163,17 +115,12 @@ describe('effect-to-json', () => {
|
|
|
163
115
|
email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
|
|
164
116
|
description: 'Email address',
|
|
165
117
|
}),
|
|
166
|
-
}).pipe(
|
|
167
|
-
Type.object({
|
|
168
|
-
typename: 'com.example.type.person',
|
|
169
|
-
version: '0.1.0',
|
|
170
|
-
}),
|
|
171
|
-
);
|
|
118
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
172
119
|
|
|
173
120
|
const jsonSchema = toJsonSchema(TempSchema);
|
|
174
121
|
expect(jsonSchema).to.deep.eq({
|
|
175
122
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
176
|
-
$id: 'dxn:
|
|
123
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
177
124
|
|
|
178
125
|
entityKind: EntityKind.Object,
|
|
179
126
|
typename: 'com.example.type.person',
|
|
@@ -214,29 +161,19 @@ describe('effect-to-json', () => {
|
|
|
214
161
|
test('reference property by ref', () => {
|
|
215
162
|
const Organization = Schema.Struct({
|
|
216
163
|
field: Schema.String,
|
|
217
|
-
}).pipe(
|
|
218
|
-
Type.object({
|
|
219
|
-
typename: 'com.example.type.organization',
|
|
220
|
-
version: '0.1.0',
|
|
221
|
-
}),
|
|
222
|
-
);
|
|
164
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
223
165
|
|
|
224
166
|
const Contact = Schema.Struct({
|
|
225
167
|
name: Schema.String,
|
|
226
168
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
227
|
-
}).pipe(
|
|
228
|
-
Type.object({
|
|
229
|
-
typename: 'com.example.type.person',
|
|
230
|
-
version: '0.1.0',
|
|
231
|
-
}),
|
|
232
|
-
);
|
|
169
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
233
170
|
|
|
234
171
|
// log.info('Contact', { ast: Contact.ast });
|
|
235
172
|
|
|
236
173
|
const jsonSchema = toJsonSchema(Contact);
|
|
237
174
|
expect(jsonSchema).toEqual({
|
|
238
175
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
239
|
-
$id: 'dxn:
|
|
176
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
240
177
|
|
|
241
178
|
entityKind: EntityKind.Object,
|
|
242
179
|
typename: 'com.example.type.person',
|
|
@@ -259,7 +196,7 @@ describe('effect-to-json', () => {
|
|
|
259
196
|
$ref: '/schemas/echo/ref',
|
|
260
197
|
reference: {
|
|
261
198
|
schema: {
|
|
262
|
-
$ref: 'dxn:
|
|
199
|
+
$ref: 'dxn:com.example.type.organization',
|
|
263
200
|
},
|
|
264
201
|
schemaVersion: '0.1.0',
|
|
265
202
|
},
|
|
@@ -276,31 +213,21 @@ describe('effect-to-json', () => {
|
|
|
276
213
|
test('add reference property', () => {
|
|
277
214
|
const Organization = Schema.Struct({
|
|
278
215
|
field: Schema.String,
|
|
279
|
-
}).pipe(
|
|
280
|
-
Type.object({
|
|
281
|
-
typename: 'com.example.type.organization',
|
|
282
|
-
version: '0.1.0',
|
|
283
|
-
}),
|
|
284
|
-
);
|
|
216
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
285
217
|
|
|
286
218
|
const Contact = Schema.Struct({
|
|
287
219
|
name: Schema.String,
|
|
288
220
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
289
|
-
}).pipe(
|
|
290
|
-
Type.object({
|
|
291
|
-
typename: 'com.example.type.person',
|
|
292
|
-
version: '0.1.0',
|
|
293
|
-
}),
|
|
294
|
-
);
|
|
221
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
295
222
|
|
|
296
223
|
const jsonSchema = toJsonSchema(Contact);
|
|
297
|
-
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization
|
|
224
|
+
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Type.getTypename(Organization)));
|
|
298
225
|
const { typename } = getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as JsonProp) ?? {}) ?? {};
|
|
299
|
-
expect(typename).to.eq(Organization
|
|
226
|
+
expect(typename).to.eq(Type.getTypename(Organization));
|
|
300
227
|
});
|
|
301
228
|
|
|
302
|
-
test('serialize circular schema (
|
|
303
|
-
const jsonSchema = toJsonSchema(
|
|
229
|
+
test('serialize circular schema (TypeSchema)', () => {
|
|
230
|
+
const jsonSchema = toJsonSchema(TypeSchema);
|
|
304
231
|
expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
|
|
305
232
|
|
|
306
233
|
// TODO(dmaretskyi): Currently unable to deserialize.
|
|
@@ -349,18 +276,18 @@ describe('effect-to-json', () => {
|
|
|
349
276
|
const schema = TestSchema.EmployedBy;
|
|
350
277
|
const jsonSchema = toJsonSchema(schema);
|
|
351
278
|
expect(jsonSchema).toEqual({
|
|
352
|
-
$id: 'dxn:
|
|
279
|
+
$id: 'dxn:com.example.type.employedBy:0.1.0',
|
|
353
280
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
354
281
|
entityKind: 'relation',
|
|
355
|
-
typename: 'com.example.type.
|
|
282
|
+
typename: 'com.example.type.employedBy',
|
|
356
283
|
version: '0.1.0',
|
|
357
284
|
relationSource: {
|
|
358
285
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
359
|
-
$ref: 'dxn:
|
|
286
|
+
$ref: 'dxn:com.example.type.person',
|
|
360
287
|
},
|
|
361
288
|
relationTarget: {
|
|
362
289
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
363
|
-
$ref: 'dxn:
|
|
290
|
+
$ref: 'dxn:com.example.type.organization',
|
|
364
291
|
},
|
|
365
292
|
type: 'object',
|
|
366
293
|
properties: {
|
|
@@ -382,19 +309,13 @@ describe('effect-to-json', () => {
|
|
|
382
309
|
|
|
383
310
|
test('label prop', () => {
|
|
384
311
|
const Organization = Schema.Struct({
|
|
385
|
-
id:
|
|
312
|
+
id: EntityId,
|
|
386
313
|
name: Schema.String,
|
|
387
|
-
}).pipe(
|
|
388
|
-
EchoObjectSchema({
|
|
389
|
-
typename: 'com.example.type.organization',
|
|
390
|
-
version: '0.1.0',
|
|
391
|
-
}),
|
|
392
|
-
LabelAnnotation.set(['name']),
|
|
393
|
-
);
|
|
314
|
+
}).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
|
|
394
315
|
|
|
395
316
|
const jsonSchema = toJsonSchema(Organization);
|
|
396
317
|
expect(jsonSchema).toEqual({
|
|
397
|
-
$id: 'dxn:
|
|
318
|
+
$id: 'dxn:com.example.type.organization:0.1.0',
|
|
398
319
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
399
320
|
typename: 'com.example.type.organization',
|
|
400
321
|
version: '0.1.0',
|
|
@@ -421,9 +342,9 @@ describe('effect-to-json', () => {
|
|
|
421
342
|
|
|
422
343
|
test('object id with description', () => {
|
|
423
344
|
const schema = Schema.Struct({
|
|
424
|
-
id:
|
|
345
|
+
id: EntityId.annotations({ description: 'The id' }),
|
|
425
346
|
});
|
|
426
|
-
// log.info('schema', { schema:
|
|
347
|
+
// log.info('schema', { schema: EntityId.ast });
|
|
427
348
|
const jsonSchema = toJsonSchema(schema);
|
|
428
349
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
429
350
|
{
|
|
@@ -467,7 +388,7 @@ describe('effect-to-json', () => {
|
|
|
467
388
|
const expectReferenceAnnotation = (object: JsonSchemaType) => {
|
|
468
389
|
expect(object.reference).to.deep.eq({
|
|
469
390
|
schema: {
|
|
470
|
-
$ref: 'dxn:
|
|
391
|
+
$ref: 'dxn:com.example.type.testNested',
|
|
471
392
|
},
|
|
472
393
|
schemaVersion: '0.1.0',
|
|
473
394
|
});
|
|
@@ -494,12 +415,7 @@ describe('json-to-effect', () => {
|
|
|
494
415
|
test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
|
|
495
416
|
const Organization = Schema.Struct({
|
|
496
417
|
field: Schema.String,
|
|
497
|
-
}).pipe(
|
|
498
|
-
Type.object({
|
|
499
|
-
typename: 'com.example.type.organization',
|
|
500
|
-
version: '0.1.0',
|
|
501
|
-
}),
|
|
502
|
-
);
|
|
418
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
503
419
|
|
|
504
420
|
const fields = {
|
|
505
421
|
string: Schema.String,
|
|
@@ -516,10 +432,7 @@ describe('json-to-effect', () => {
|
|
|
516
432
|
} as const;
|
|
517
433
|
|
|
518
434
|
const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
|
|
519
|
-
Type.
|
|
520
|
-
typename: 'com.example.type.test',
|
|
521
|
-
version: '0.1.0',
|
|
522
|
-
}),
|
|
435
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
523
436
|
);
|
|
524
437
|
|
|
525
438
|
const jsonSchema = toJsonSchema(Test);
|
|
@@ -527,11 +440,12 @@ describe('json-to-effect', () => {
|
|
|
527
440
|
|
|
528
441
|
const schema = toEffectSchema(jsonSchema);
|
|
529
442
|
|
|
530
|
-
|
|
531
|
-
expect(() => expect(
|
|
532
|
-
expect(() => expect(
|
|
443
|
+
const testAst = Type.getSchema(Test).ast;
|
|
444
|
+
expect(() => expect(schema.ast).to.deep.eq(testAst)).to.throw();
|
|
445
|
+
expect(() => expect(prepareAstForCompare(testAst)).to.deep.eq(testAst)).to.throw();
|
|
446
|
+
expect(() => expect(schema.ast).to.deep.eq(prepareAstForCompare(testAst))).to.throw();
|
|
533
447
|
// log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
|
|
534
|
-
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(
|
|
448
|
+
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
|
|
535
449
|
|
|
536
450
|
// TODO(dmaretskyi): Fix.
|
|
537
451
|
// expect(
|
|
@@ -579,7 +493,7 @@ describe('json-to-effect', () => {
|
|
|
579
493
|
typename: 'com.example.type.project',
|
|
580
494
|
version: '0.1.0',
|
|
581
495
|
});
|
|
582
|
-
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('
|
|
496
|
+
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
|
|
583
497
|
});
|
|
584
498
|
|
|
585
499
|
test('symbol annotations get compared', () => {
|
|
@@ -602,7 +516,7 @@ describe('json-to-effect', () => {
|
|
|
602
516
|
const schema = TestSchema.HasManager;
|
|
603
517
|
const jsonSchema = toJsonSchema(schema);
|
|
604
518
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
605
|
-
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
|
|
519
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
|
|
606
520
|
});
|
|
607
521
|
|
|
608
522
|
test('generator annotation', () => {
|
|
@@ -714,7 +628,7 @@ describe('json-to-effect', () => {
|
|
|
714
628
|
"$ref": "/schemas/echo/ref",
|
|
715
629
|
"reference": {
|
|
716
630
|
"schema": {
|
|
717
|
-
"$ref": "dxn:
|
|
631
|
+
"$ref": "dxn:com.example.type.person",
|
|
718
632
|
},
|
|
719
633
|
"schemaVersion": "0.1.0",
|
|
720
634
|
},
|
|
@@ -735,9 +649,9 @@ describe('json-to-effect', () => {
|
|
|
735
649
|
test('object nested inside another struct', () => {
|
|
736
650
|
const Contact = Schema.Struct({
|
|
737
651
|
name: Schema.String,
|
|
738
|
-
}).pipe(EchoObjectSchema(
|
|
652
|
+
}).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
|
|
739
653
|
const input = Schema.Struct({
|
|
740
|
-
contact: Contact,
|
|
654
|
+
contact: Type.getSchema(Contact),
|
|
741
655
|
});
|
|
742
656
|
const jsonSchema = toJsonSchema(input);
|
|
743
657
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
@@ -746,7 +660,7 @@ describe('json-to-effect', () => {
|
|
|
746
660
|
"additionalProperties": false,
|
|
747
661
|
"properties": {
|
|
748
662
|
"contact": {
|
|
749
|
-
"$id": "dxn:
|
|
663
|
+
"$id": "dxn:com.example.type.person:0.1.0",
|
|
750
664
|
"additionalProperties": false,
|
|
751
665
|
"entityKind": "object",
|
|
752
666
|
"properties": {
|
|
@@ -795,7 +709,7 @@ describe('reference', () => {
|
|
|
795
709
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
796
710
|
reference: {
|
|
797
711
|
schema: {
|
|
798
|
-
$ref: 'dxn:
|
|
712
|
+
$ref: 'dxn:com.example.type.person',
|
|
799
713
|
},
|
|
800
714
|
schemaVersion: '0.1.0',
|
|
801
715
|
},
|
|
@@ -813,7 +727,7 @@ describe('reference', () => {
|
|
|
813
727
|
$ref: '/schemas/echo/ref',
|
|
814
728
|
reference: {
|
|
815
729
|
schema: {
|
|
816
|
-
$ref: 'dxn:
|
|
730
|
+
$ref: 'dxn:com.example.type.person',
|
|
817
731
|
},
|
|
818
732
|
schemaVersion: '0.1.0',
|
|
819
733
|
},
|
|
@@ -834,7 +748,7 @@ describe('reference', () => {
|
|
|
834
748
|
$ref: '/schemas/echo/ref',
|
|
835
749
|
reference: {
|
|
836
750
|
schema: {
|
|
837
|
-
$ref: 'dxn:
|
|
751
|
+
$ref: 'dxn:com.example.type.person',
|
|
838
752
|
},
|
|
839
753
|
schemaVersion: '0.1.0',
|
|
840
754
|
},
|
|
@@ -853,8 +767,8 @@ describe('reference', () => {
|
|
|
853
767
|
const deserializedSchema = toEffectSchema(jsonSchema);
|
|
854
768
|
const refAst = getReferenceAst(deserializedSchema.ast);
|
|
855
769
|
expect(refAst).toEqual({
|
|
856
|
-
typename: TestSchema.Person
|
|
857
|
-
version: TestSchema.Person
|
|
770
|
+
typename: Type.getTypename(TestSchema.Person),
|
|
771
|
+
version: Type.getVersion(TestSchema.Person),
|
|
858
772
|
});
|
|
859
773
|
});
|
|
860
774
|
});
|
|
@@ -13,17 +13,20 @@ import type * as Types from 'effect/Types';
|
|
|
13
13
|
import { raise } from '@dxos/debug';
|
|
14
14
|
import { mapAst } from '@dxos/effect';
|
|
15
15
|
import { assertArgument, invariant } from '@dxos/invariant';
|
|
16
|
-
import { DXN,
|
|
16
|
+
import { DXN, EID, EntityId } from '@dxos/keys';
|
|
17
17
|
import { log } from '@dxos/log';
|
|
18
18
|
import { clearUndefined, orderKeys, removeProperties } from '@dxos/util';
|
|
19
19
|
|
|
20
|
+
import type * as Type from '../../Type';
|
|
21
|
+
import { type TypeAnnotation, TypeAnnotationId, TypeIdentifierAnnotationId } from '../Annotation/annotations';
|
|
22
|
+
import { makeTypeJsonSchemaAnnotation } from '../Annotation/util';
|
|
20
23
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
ANY_OBJECT_TYPENAME,
|
|
25
|
+
ANY_OBJECT_VERSION,
|
|
26
|
+
EntityKind,
|
|
27
|
+
EntityKindSchema,
|
|
28
|
+
getStaticTypeSchema,
|
|
29
|
+
} from '../common/types';
|
|
27
30
|
import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
|
|
28
31
|
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
29
32
|
import {
|
|
@@ -81,11 +84,22 @@ export type JsonSchemaOptions = {
|
|
|
81
84
|
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
82
85
|
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
83
86
|
export const toJsonSchema = (
|
|
84
|
-
schema: Schema.Schema.All,
|
|
87
|
+
schema: Schema.Schema.All | Type.AnyEntity,
|
|
85
88
|
options: JsonSchemaOptions = {},
|
|
86
89
|
): Types.DeepMutable<JsonSchemaType> => {
|
|
90
|
+
// Allow passing a `Type.Type` entity — use its hidden source schema (or its
|
|
91
|
+
// already-built jsonSchema as a fallback).
|
|
92
|
+
const slot = getStaticTypeSchema(schema);
|
|
93
|
+
if (slot != null) {
|
|
94
|
+
schema = slot;
|
|
95
|
+
} else if (!Schema.isSchema(schema)) {
|
|
96
|
+
const entityJsonSchema = (schema as { jsonSchema?: JsonSchemaType }).jsonSchema;
|
|
97
|
+
if (entityJsonSchema != null) {
|
|
98
|
+
return entityJsonSchema as Types.DeepMutable<JsonSchemaType>;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
87
101
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
88
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
102
|
+
let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
|
|
89
103
|
if (options.strict) {
|
|
90
104
|
// TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
|
|
91
105
|
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
@@ -340,9 +354,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
340
354
|
const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
341
355
|
// TODO(dmaretskyi): Is this branch still taken?
|
|
342
356
|
if ((echoRefinement as any)?.reference != null) {
|
|
343
|
-
const
|
|
357
|
+
const echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
|
|
344
358
|
return createEchoReferenceSchema(
|
|
345
|
-
|
|
359
|
+
echoUri,
|
|
346
360
|
(echoRefinement as any).reference.typename,
|
|
347
361
|
(echoRefinement as any).reference.version,
|
|
348
362
|
);
|
|
@@ -363,14 +377,11 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
363
377
|
throw new Error('Invalid reference field in ref schema');
|
|
364
378
|
}
|
|
365
379
|
|
|
366
|
-
const
|
|
367
|
-
|
|
380
|
+
const ref = reference.schema.$ref;
|
|
381
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
382
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
|
|
368
383
|
|
|
369
|
-
return createEchoReferenceSchema(
|
|
370
|
-
targetSchemaDXN.toString(),
|
|
371
|
-
targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
|
|
372
|
-
reference.schemaVersion,
|
|
373
|
-
);
|
|
384
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
374
385
|
};
|
|
375
386
|
|
|
376
387
|
//
|
|
@@ -391,10 +402,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
391
402
|
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
392
403
|
}
|
|
393
404
|
|
|
405
|
+
// For stored schemas the storage URI is the definitive identifier — it overrides
|
|
406
|
+
// the typename `$id` written above.
|
|
394
407
|
const echoIdentifier = annotations[TypeIdentifierAnnotationId];
|
|
395
408
|
if (echoIdentifier) {
|
|
396
|
-
schemaFields
|
|
397
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
409
|
+
schemaFields.$id = echoIdentifier;
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
// Custom (at end).
|
|
@@ -409,14 +421,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
409
421
|
};
|
|
410
422
|
|
|
411
423
|
const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
|
|
412
|
-
//
|
|
413
|
-
if (schema.$id && schema.$id.startsWith('dxn:echo:')) {
|
|
424
|
+
// For stored schemas `$id` IS the storage URI (echo:/… or legacy dxn:echo:…).
|
|
425
|
+
if (schema.$id && (schema.$id.startsWith('echo:') || schema.$id.startsWith('dxn:echo:'))) {
|
|
414
426
|
return schema.$id;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
427
|
+
}
|
|
428
|
+
// Legacy: older serializations stored the EID on echo.type.schemaId.
|
|
429
|
+
const legacySchemaId = schema.echo?.type?.schemaId;
|
|
430
|
+
if (legacySchemaId) {
|
|
431
|
+
return EntityId.isValid(legacySchemaId) ? EID.make({ entityId: legacySchemaId }) : legacySchemaId;
|
|
420
432
|
}
|
|
421
433
|
return undefined;
|
|
422
434
|
};
|
|
@@ -433,8 +445,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
|
|
|
433
445
|
if (annotation.kind === EntityKind.Relation) {
|
|
434
446
|
const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
|
|
435
447
|
const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
|
|
436
|
-
annotation.sourceSchema = DXN.
|
|
437
|
-
annotation.targetSchema = DXN.
|
|
448
|
+
annotation.sourceSchema = DXN.tryMake(source) ?? raise(new Error(`Invalid relation source: ${source}`));
|
|
449
|
+
annotation.targetSchema = DXN.tryMake(target) ?? raise(new Error(`Invalid relation target: ${target}`));
|
|
438
450
|
}
|
|
439
451
|
|
|
440
452
|
return annotation;
|
|
@@ -470,7 +482,9 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
|
|
|
470
482
|
if (typeAnnotation) {
|
|
471
483
|
annotations[TypeAnnotationId] = typeAnnotation;
|
|
472
484
|
annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
473
|
-
|
|
485
|
+
// $id is the typename DXN — the schema's type identity. The storage EID (if any)
|
|
486
|
+
// is preserved separately on TypeIdentifierAnnotation / echo.schemaId.
|
|
487
|
+
identifier: DXN.make(typeAnnotation.typename, typeAnnotation.version),
|
|
474
488
|
kind: typeAnnotation.kind,
|
|
475
489
|
typename: typeAnnotation.typename,
|
|
476
490
|
version: typeAnnotation.version,
|
|
@@ -7,7 +7,8 @@ import { deepMapValues } from '@dxos/util';
|
|
|
7
7
|
|
|
8
8
|
import type * as Obj from '../../Obj';
|
|
9
9
|
import { makeObject } from '../common/proxy';
|
|
10
|
-
import {
|
|
10
|
+
import { getSchema, getStaticTypeSchema, getType } from '../common/types';
|
|
11
|
+
import { getMeta } from '../common/types/meta';
|
|
11
12
|
import { Ref } from '../Ref';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -17,8 +18,12 @@ import { Ref } from '../Ref';
|
|
|
17
18
|
*/
|
|
18
19
|
export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T => {
|
|
19
20
|
const { id, ...data } = obj;
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Prefer cloning through the type entity so the cloned instance preserves
|
|
22
|
+
// `Obj.getType` identity. Falls back to the raw schema for older instances
|
|
23
|
+
// that don't have a type-entity back-reference set (e.g. deserialized).
|
|
24
|
+
const typeEntity = getType(obj);
|
|
25
|
+
const schema = typeEntity != null ? getStaticTypeSchema(typeEntity) : getSchema(obj);
|
|
26
|
+
invariant(schema != null, 'Object should have a type or schema');
|
|
22
27
|
const props: any = deepMapValues(data, (value, recurse) => {
|
|
23
28
|
if (Ref.isRef(value)) {
|
|
24
29
|
if (opts?.deep) {
|
|
@@ -44,5 +49,5 @@ export const clone = <T extends Obj.Any>(obj: T, opts?: Obj.CloneOptions): T =>
|
|
|
44
49
|
return recurse(value);
|
|
45
50
|
});
|
|
46
51
|
|
|
47
|
-
return makeObject(schema, props, meta);
|
|
52
|
+
return makeObject(schema, props, meta, typeEntity as object | undefined);
|
|
48
53
|
};
|
|
@@ -6,13 +6,15 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import { inspect } from 'util';
|
|
7
7
|
import { describe, expect, test } from 'vitest';
|
|
8
8
|
|
|
9
|
-
import { DXN } from '@dxos/keys';
|
|
9
|
+
import { DXN, EID } from '@dxos/keys';
|
|
10
10
|
|
|
11
11
|
import { Relation } from '../../index';
|
|
12
12
|
import { TestSchema } from '../../testing';
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import * as Type from '../../Type';
|
|
14
|
+
import { getTypeURI } from '../Annotation';
|
|
15
|
+
import { ATTR_TYPE, getSchema } from '../common/types';
|
|
16
|
+
import { ATTR_META } from '../common/types/meta';
|
|
17
|
+
import { ATTR_RELATION_SOURCE, ATTR_RELATION_TARGET, isInstanceOf } from '../Entity';
|
|
16
18
|
import { createObject } from './create-object';
|
|
17
19
|
import { objectToJSON } from './json-serializer';
|
|
18
20
|
|
|
@@ -40,7 +42,7 @@ describe('create (static version)', () => {
|
|
|
40
42
|
expect(contact.name).toBe('Bot');
|
|
41
43
|
expect(contact.email).toBe('bot@example.com');
|
|
42
44
|
expect((contact as any)['@type']).toBeUndefined();
|
|
43
|
-
expect(
|
|
45
|
+
expect(getTypeURI(contact)?.toString()).toBe(Type.getURI(TestSchema.Person).toString());
|
|
44
46
|
expect(isInstanceOf(TestSchema.Person, contact)).toBe(true);
|
|
45
47
|
});
|
|
46
48
|
|
|
@@ -53,7 +55,7 @@ describe('create (static version)', () => {
|
|
|
53
55
|
const json = JSON.parse(JSON.stringify(contact));
|
|
54
56
|
expect(json).toEqual({
|
|
55
57
|
id: contact.id,
|
|
56
|
-
'@type': DXN.
|
|
58
|
+
'@type': DXN.make(Type.getTypename(TestSchema.Person), Type.getVersion(TestSchema.Person)),
|
|
57
59
|
'@meta': {
|
|
58
60
|
keys: [],
|
|
59
61
|
},
|
|
@@ -81,9 +83,9 @@ describe('create (static version)', () => {
|
|
|
81
83
|
const json = JSON.parse(JSON.stringify(manager));
|
|
82
84
|
expect(json).toEqual({
|
|
83
85
|
id: manager.id,
|
|
84
|
-
[ATTR_TYPE]: DXN.
|
|
85
|
-
[ATTR_RELATION_SOURCE]:
|
|
86
|
-
[ATTR_RELATION_TARGET]:
|
|
86
|
+
[ATTR_TYPE]: DXN.make(Type.getTypename(TestSchema.HasManager), Type.getVersion(TestSchema.HasManager)),
|
|
87
|
+
[ATTR_RELATION_SOURCE]: EID.make({ entityId: person1.id }),
|
|
88
|
+
[ATTR_RELATION_TARGET]: EID.make({ entityId: person2.id }),
|
|
87
89
|
[ATTR_META]: {
|
|
88
90
|
keys: [],
|
|
89
91
|
},
|
|
@@ -96,7 +98,7 @@ describe('create (static version)', () => {
|
|
|
96
98
|
email: 'bot@example.com',
|
|
97
99
|
});
|
|
98
100
|
|
|
99
|
-
expect(getSchema(contact)).toBe(TestSchema.Person);
|
|
101
|
+
expect(getSchema(contact)).toBe(Type.getSchema(TestSchema.Person));
|
|
100
102
|
});
|
|
101
103
|
|
|
102
104
|
test('inspect', () => {
|