@dxos/echo 0.8.4-main.40e3dcdf1b → 0.8.4-main.43cb759274
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/LICENSE +102 -5
- package/README.md +7 -7
- package/dist/lib/neutral/Annotation.mjs +29 -6
- package/dist/lib/neutral/Database.mjs +8 -9
- package/dist/lib/neutral/Entity.mjs +29 -18
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +27 -19
- package/dist/lib/neutral/Filter.mjs +25 -15
- 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 +18 -0
- package/dist/lib/neutral/Obj.mjs +25 -19
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -16
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +10 -9
- package/dist/lib/neutral/Registry.mjs +14 -0
- package/dist/lib/neutral/Registry.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +26 -24
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Scope.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +17 -13
- 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-CIRHIEMW.mjs → chunk-4SFPZJVA.mjs} +92 -112
- package/dist/lib/neutral/chunk-4SFPZJVA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YWXWXIE5.mjs → chunk-4Z6GET2X.mjs} +3 -3
- package/dist/lib/neutral/chunk-4Z6GET2X.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7LOUAPYZ.mjs} +9 -5
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-43Y5DOS6.mjs → chunk-7OAFN3OX.mjs} +75 -112
- package/dist/lib/neutral/chunk-7OAFN3OX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BOZZPUXE.mjs → chunk-7PRCIDHH.mjs} +41 -81
- package/dist/lib/neutral/chunk-7PRCIDHH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-BBFJWWAV.mjs} +6 -6
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BDQGMDIX.mjs +132 -0
- 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-OMUPQMLR.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-UTBRYVQC.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-FXEG7EOK.mjs → chunk-J3MNM65T.mjs} +9 -6
- 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-WYOKA6AE.mjs → chunk-O6BH7EPN.mjs} +31 -4
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-KTAWP7GI.mjs → chunk-OIYW7R2G.mjs} +99 -46
- package/dist/lib/neutral/chunk-OIYW7R2G.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TQQZLKB7.mjs → chunk-OYUG4FHF.mjs} +648 -1228
- package/dist/lib/neutral/chunk-OYUG4FHF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NQRLRYJM.mjs → chunk-Q5FKCVBC.mjs} +173 -60
- package/dist/lib/neutral/chunk-Q5FKCVBC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Q62IHV2N.mjs +41 -0
- package/dist/lib/neutral/chunk-Q62IHV2N.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UFDK26FO.mjs → chunk-QVJDDG44.mjs} +69 -34
- package/dist/lib/neutral/chunk-QVJDDG44.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B5OXLWZL.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-TTCSATUD.mjs} +1 -1
- package/dist/lib/neutral/{chunk-FZO7LQO7.mjs → chunk-VKWOFXT2.mjs} +22 -2
- package/dist/lib/neutral/{chunk-FZO7LQO7.mjs.map → chunk-VKWOFXT2.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-NXMFBIT5.mjs → chunk-ZACMEAYV.mjs} +89 -23
- package/dist/lib/neutral/chunk-ZACMEAYV.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +58 -38
- package/dist/lib/neutral/internal/index.mjs +131 -64
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +222 -177
- 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 +56 -24
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +17 -6
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +102 -26
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +27 -27
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +89 -25
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +74 -11
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +14 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +2 -2
- 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 +72 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +108 -65
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +35 -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 -7
- 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 +72 -44
- 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 +21 -5
- 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 +357 -96
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +2 -5
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +8 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +79 -37
- 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/sorting.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +14 -5
- 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 +20 -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/Entity/version.d.ts.map +1 -1
- 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/number.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/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +28 -28
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +3 -2
- 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/common.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/deleted.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 +11 -10
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.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 +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +42 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Type/compose.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 +14 -11
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/event-batch.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/ownership.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.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/base.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +63 -6
- 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 +23 -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/version.d.ts +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 +2 -0
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +83 -89
- 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 +27 -19
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +152 -4
- package/src/Collection.ts +6 -5
- package/src/Database.ts +117 -57
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +130 -31
- package/src/Err.ts +4 -4
- package/src/Feed.ts +138 -43
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +143 -27
- package/src/Hypergraph.ts +14 -9
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +103 -0
- package/src/Key.ts +1 -1
- package/src/Migration.ts +114 -0
- package/src/Obj.test.ts +122 -19
- package/src/Obj.ts +279 -97
- package/src/Query.test.ts +317 -131
- package/src/Query.ts +181 -73
- package/src/QueryResult.ts +11 -0
- package/src/Ref.ts +22 -4
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +112 -71
- 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 +602 -132
- package/src/View.ts +11 -15
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +9 -3
- package/src/internal/Annotation/annotations.test.ts +82 -13
- package/src/internal/Annotation/annotations.ts +153 -115
- 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/sorting.ts +0 -1
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +7 -8
- 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 +37 -28
- package/src/internal/Entity/object.ts +21 -6
- 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/Entity/version.ts +0 -1
- package/src/internal/Format/date.test.ts +0 -1
- package/src/internal/Format/date.ts +0 -4
- package/src/internal/Format/format.test.ts +21 -1
- 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-type.ts +1 -1
- package/src/internal/JsonSchema/json-schema.test.ts +55 -142
- package/src/internal/JsonSchema/json-schema.ts +44 -31
- package/src/internal/Obj/clone.ts +9 -4
- package/src/internal/Obj/create-object.test.ts +13 -13
- package/src/internal/Obj/create-object.ts +68 -24
- package/src/internal/Obj/deleted.ts +1 -1
- package/src/internal/Obj/index.ts +0 -1
- package/src/internal/Obj/inspect.ts +4 -3
- package/src/internal/Obj/json-serializer.test.ts +102 -24
- package/src/internal/Obj/json-serializer.ts +105 -43
- package/src/internal/Obj/set-value.test.ts +31 -54
- package/src/internal/Obj/set-value.ts +1 -1
- 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 +159 -0
- package/src/internal/Ref/ref-array.ts +3 -4
- package/src/internal/Ref/ref.test.ts +17 -27
- package/src/internal/Ref/ref.ts +124 -59
- package/src/internal/Type/compose.test.ts +3 -2
- 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 +2 -2
- package/src/internal/common/api/meta.ts +19 -17
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/change.test.ts +118 -110
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +1 -3
- package/src/internal/common/proxy/json-serializer.ts +26 -16
- package/src/internal/common/proxy/make-object.ts +43 -21
- package/src/internal/common/proxy/ownership.ts +2 -3
- package/src/internal/common/proxy/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +11 -3
- package/src/internal/common/proxy/schema.test.ts +48 -86
- package/src/internal/common/proxy/typed-handler.test.ts +12 -12
- package/src/internal/common/proxy/typed-handler.ts +79 -19
- package/src/internal/common/proxy/typed-object.test.ts +16 -29
- package/src/internal/common/types/base.ts +4 -4
- package/src/internal/common/types/entity.ts +81 -2
- package/src/internal/common/types/index.ts +6 -1
- package/src/internal/common/types/meta.ts +49 -15
- 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 +6 -0
- package/src/testing/api.test.ts +15 -10
- package/src/testing/test-data.ts +159 -100
- package/src/testing/test-schema.ts +22 -58
- package/src/testing/util.ts +14 -11
- package/dist/lib/neutral/SchemaRegistry.mjs +0 -2
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-724GQYEN.mjs +0 -56
- package/dist/lib/neutral/chunk-724GQYEN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B5OXLWZL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs +0 -7
- package/dist/lib/neutral/chunk-BNCCGLJN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-CIRHIEMW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs +0 -102
- package/dist/lib/neutral/chunk-DYDJBZEG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-FXEG7EOK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KTAWP7GI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NEGC54NE.mjs +0 -130
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NQRLRYJM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OENWMTE6.mjs +0 -45
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs +0 -97
- package/dist/lib/neutral/chunk-RMLF7JOZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs +0 -355
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TQQZLKB7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UFDK26FO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs +0 -152
- package/dist/lib/neutral/chunk-VA2F47ZC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WYOKA6AE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YWXWXIE5.mjs.map +0 -7
- 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/SchemaRegistry.ts +0 -106
- package/src/internal/Obj/ids.ts +0 -12
- package/src/internal/Type/echo-schema.ts +0 -424
- package/src/internal/Type/persistent-schema.ts +0 -33
- /package/dist/lib/neutral/{SchemaRegistry.mjs.map → Migration.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UTBRYVQC.mjs.map → chunk-G6CFWUYH.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UI6MWK5W.mjs.map → chunk-TTCSATUD.mjs.map} +0 -0
|
@@ -20,9 +20,25 @@ import { FormatAnnotation, TypeFormat } from './types';
|
|
|
20
20
|
* }
|
|
21
21
|
* Note: optional third element for altitude.
|
|
22
22
|
*/
|
|
23
|
+
/** Decimal places retained for stored coordinates (~1.1cm at the equator). */
|
|
24
|
+
export const GEO_PRECISION = 7;
|
|
25
|
+
|
|
26
|
+
const roundCoordinate = (value: number): number => {
|
|
27
|
+
const factor = 10 ** GEO_PRECISION;
|
|
28
|
+
return Math.round(value * factor) / factor;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Longitude/latitude clamped to range and rounded to {@link GEO_PRECISION} decimal places. */
|
|
32
|
+
const Coordinate = (min: number, max: number, title: string) =>
|
|
33
|
+
Schema.transform(Schema.Number.pipe(Schema.clamp(min, max)), Schema.Number, {
|
|
34
|
+
strict: true,
|
|
35
|
+
decode: roundCoordinate,
|
|
36
|
+
encode: roundCoordinate,
|
|
37
|
+
}).annotations({ title });
|
|
38
|
+
|
|
23
39
|
export const GeoPoint = Schema.Tuple(
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
Coordinate(-180, 180, 'Longitude'),
|
|
41
|
+
Coordinate(-90, 90, 'Latitude'),
|
|
26
42
|
Schema.optionalElement(Schema.Number).annotations({
|
|
27
43
|
title: 'Height ASL (m)',
|
|
28
44
|
}),
|
|
@@ -52,8 +68,9 @@ export namespace GeoLocation {
|
|
|
52
68
|
*/
|
|
53
69
|
export const toGeoPoint = ({ longitude, latitude, height }: GeoLocation): GeoPoint => {
|
|
54
70
|
// TODO(ZaymonFC): Use schema validation instead of doing this manually.
|
|
55
|
-
|
|
56
|
-
const
|
|
71
|
+
// Clamp + round to match the `Format.GeoPoint` decode/encode path so both produce identical tuples.
|
|
72
|
+
const clampedLongitude = roundCoordinate(clamp(longitude, -180, 180));
|
|
73
|
+
const clampedLatitude = roundCoordinate(clamp(latitude, -90, 90));
|
|
57
74
|
return height !== undefined ? [clampedLongitude, clampedLatitude, height] : [clampedLongitude, clampedLatitude];
|
|
58
75
|
};
|
|
59
76
|
|
|
@@ -7,7 +7,7 @@ import type * as JSONSchema from 'effect/JSONSchema';
|
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
8
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
9
9
|
|
|
10
|
-
import { createAnnotationHelper } from '../Annotation';
|
|
10
|
+
import { createAnnotationHelper } from '../Annotation/util';
|
|
11
11
|
import { type JsonSchemaType } from '../JsonSchema';
|
|
12
12
|
|
|
13
13
|
// TODO(burdon): Rename PropertyType.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
|
|
7
|
-
import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation';
|
|
7
|
+
import { GeneratorAnnotationId, LabelAnnotationId, PropertyMetaAnnotationId } from '../Annotation/annotations';
|
|
8
8
|
import { CurrencyAnnotationId, FormatAnnotationId } from '../Format';
|
|
9
9
|
import { type JsonSchemaEchoAnnotations, type JsonSchemaType } from '../JsonSchema';
|
|
10
10
|
|
|
@@ -6,9 +6,9 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { JsonPath, type JsonProp } from '@dxos/effect';
|
|
8
8
|
|
|
9
|
-
import { FormatAnnotation, TypeFormat } from '../Format';
|
|
10
9
|
import { type Mutable } from '../common/proxy';
|
|
11
10
|
import { EntityKindSchema } from '../common/types';
|
|
11
|
+
import { FormatAnnotation, TypeFormat } from '../Format';
|
|
12
12
|
|
|
13
13
|
//
|
|
14
14
|
// JSON Schema
|
|
@@ -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';
|
|
@@ -21,13 +21,12 @@ import {
|
|
|
21
21
|
getTypeAnnotation,
|
|
22
22
|
getTypeIdentifierAnnotation,
|
|
23
23
|
} from '../Annotation';
|
|
24
|
+
import { EntityKind } from '../common/types';
|
|
24
25
|
import { EchoObjectSchema } from '../Entity';
|
|
25
26
|
import { Email, FormatAnnotation, TypeFormat } from '../Format';
|
|
26
27
|
import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../JsonSchema';
|
|
27
28
|
import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../Ref';
|
|
28
|
-
import {
|
|
29
|
-
import { EntityKind } from '../common/types';
|
|
30
|
-
|
|
29
|
+
import { TypeSchema } from '../Type';
|
|
31
30
|
import { toEffectSchema, toJsonSchema } from './json-schema';
|
|
32
31
|
|
|
33
32
|
const EXAMPLE_NAMESPACE = '@example';
|
|
@@ -35,26 +34,18 @@ const EXAMPLE_NAMESPACE = '@example';
|
|
|
35
34
|
describe('effect-to-json', () => {
|
|
36
35
|
test('type annotation', () => {
|
|
37
36
|
const Test = Schema.Struct({ name: Schema.String }).pipe(
|
|
38
|
-
Type.
|
|
39
|
-
typename: 'com.example.type.test',
|
|
40
|
-
version: '0.1.0',
|
|
41
|
-
}),
|
|
37
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
42
38
|
);
|
|
43
39
|
const jsonSchema = toJsonSchema(Test);
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
40
|
+
expect(jsonSchema.$id).toEqual('dxn:com.example.type.test:0.1.0');
|
|
41
|
+
expect(jsonSchema.version).toEqual('0.1.0');
|
|
46
42
|
});
|
|
47
43
|
|
|
48
44
|
test('property meta annotation', () => {
|
|
49
45
|
const meta = { maxLength: 0 };
|
|
50
46
|
const Test = Schema.Struct({
|
|
51
47
|
name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
|
|
52
|
-
}).pipe(
|
|
53
|
-
Type.object({
|
|
54
|
-
typename: 'com.example.type.test',
|
|
55
|
-
version: '0.1.0',
|
|
56
|
-
}),
|
|
57
|
-
);
|
|
48
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
58
49
|
const jsonSchema = toJsonSchema(Test);
|
|
59
50
|
expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
|
|
60
51
|
});
|
|
@@ -62,20 +53,10 @@ describe('effect-to-json', () => {
|
|
|
62
53
|
test('reference annotation', () => {
|
|
63
54
|
const Nested = Schema.Struct({
|
|
64
55
|
name: Schema.String,
|
|
65
|
-
}).pipe(
|
|
66
|
-
Type.object({
|
|
67
|
-
typename: 'com.example.type.testNested',
|
|
68
|
-
version: '0.1.0',
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
56
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
71
57
|
const Test = Schema.Struct({
|
|
72
58
|
name: Ref(Nested),
|
|
73
|
-
}).pipe(
|
|
74
|
-
Type.object({
|
|
75
|
-
typename: 'com.example.type.test',
|
|
76
|
-
version: '0.1.0',
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
59
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
79
60
|
const jsonSchema = toJsonSchema(Test);
|
|
80
61
|
// log.info('schema', { jsonSchema });
|
|
81
62
|
const nested = jsonSchema.properties!.name;
|
|
@@ -87,20 +68,10 @@ describe('effect-to-json', () => {
|
|
|
87
68
|
test.skip('reference annotation with lookup property', () => {
|
|
88
69
|
const Nested = Schema.Struct({
|
|
89
70
|
name: Schema.String,
|
|
90
|
-
}).pipe(
|
|
91
|
-
Type.object({
|
|
92
|
-
typename: 'com.example.type.testNested',
|
|
93
|
-
version: '0.1.0',
|
|
94
|
-
}),
|
|
95
|
-
);
|
|
71
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
96
72
|
const Test = Schema.Struct({
|
|
97
73
|
name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
|
|
98
|
-
}).pipe(
|
|
99
|
-
Type.object({
|
|
100
|
-
typename: 'com.example.type.test',
|
|
101
|
-
version: '0.1.0',
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
74
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
104
75
|
const jsonSchema = toJsonSchema(Test);
|
|
105
76
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
106
77
|
|
|
@@ -111,20 +82,10 @@ describe('effect-to-json', () => {
|
|
|
111
82
|
test('array of references', () => {
|
|
112
83
|
const Nested = Schema.Struct({
|
|
113
84
|
name: Schema.String,
|
|
114
|
-
}).pipe(
|
|
115
|
-
Type.object({
|
|
116
|
-
typename: 'com.example.type.testNested',
|
|
117
|
-
version: '0.1.0',
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
85
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
120
86
|
const Test = Schema.Struct({
|
|
121
87
|
name: Schema.Array(Ref(Nested)),
|
|
122
|
-
}).pipe(
|
|
123
|
-
Type.object({
|
|
124
|
-
typename: 'com.example.type.test',
|
|
125
|
-
version: '0.1.0',
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
88
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
128
89
|
|
|
129
90
|
const jsonSchema = toJsonSchema(Test);
|
|
130
91
|
expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
|
|
@@ -133,20 +94,10 @@ describe('effect-to-json', () => {
|
|
|
133
94
|
test('optional references', () => {
|
|
134
95
|
const Nested = Schema.Struct({
|
|
135
96
|
name: Schema.String,
|
|
136
|
-
}).pipe(
|
|
137
|
-
Type.object({
|
|
138
|
-
typename: 'com.example.type.testNested',
|
|
139
|
-
version: '0.1.0',
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
97
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.testNested', '0.1.0')));
|
|
142
98
|
const Test = Schema.Struct({
|
|
143
99
|
name: Schema.optional(Ref(Nested)),
|
|
144
|
-
}).pipe(
|
|
145
|
-
Type.object({
|
|
146
|
-
typename: 'com.example.type.test',
|
|
147
|
-
version: '0.1.0',
|
|
148
|
-
}),
|
|
149
|
-
);
|
|
100
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.test', '0.1.0')));
|
|
150
101
|
const jsonSchema = toJsonSchema(Test);
|
|
151
102
|
expectReferenceAnnotation(jsonSchema.properties!.name);
|
|
152
103
|
});
|
|
@@ -164,17 +115,12 @@ describe('effect-to-json', () => {
|
|
|
164
115
|
email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
|
|
165
116
|
description: 'Email address',
|
|
166
117
|
}),
|
|
167
|
-
}).pipe(
|
|
168
|
-
Type.object({
|
|
169
|
-
typename: 'com.example.type.person',
|
|
170
|
-
version: '0.1.0',
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
118
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
173
119
|
|
|
174
120
|
const jsonSchema = toJsonSchema(TempSchema);
|
|
175
121
|
expect(jsonSchema).to.deep.eq({
|
|
176
122
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
177
|
-
$id: 'dxn:
|
|
123
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
178
124
|
|
|
179
125
|
entityKind: EntityKind.Object,
|
|
180
126
|
typename: 'com.example.type.person',
|
|
@@ -215,29 +161,19 @@ describe('effect-to-json', () => {
|
|
|
215
161
|
test('reference property by ref', () => {
|
|
216
162
|
const Organization = Schema.Struct({
|
|
217
163
|
field: Schema.String,
|
|
218
|
-
}).pipe(
|
|
219
|
-
Type.object({
|
|
220
|
-
typename: 'com.example.type.organization',
|
|
221
|
-
version: '0.1.0',
|
|
222
|
-
}),
|
|
223
|
-
);
|
|
164
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
224
165
|
|
|
225
166
|
const Contact = Schema.Struct({
|
|
226
167
|
name: Schema.String,
|
|
227
168
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
228
|
-
}).pipe(
|
|
229
|
-
Type.object({
|
|
230
|
-
typename: 'com.example.type.person',
|
|
231
|
-
version: '0.1.0',
|
|
232
|
-
}),
|
|
233
|
-
);
|
|
169
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
234
170
|
|
|
235
171
|
// log.info('Contact', { ast: Contact.ast });
|
|
236
172
|
|
|
237
173
|
const jsonSchema = toJsonSchema(Contact);
|
|
238
174
|
expect(jsonSchema).toEqual({
|
|
239
175
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
240
|
-
$id: 'dxn:
|
|
176
|
+
$id: 'dxn:com.example.type.person:0.1.0',
|
|
241
177
|
|
|
242
178
|
entityKind: EntityKind.Object,
|
|
243
179
|
typename: 'com.example.type.person',
|
|
@@ -260,7 +196,7 @@ describe('effect-to-json', () => {
|
|
|
260
196
|
$ref: '/schemas/echo/ref',
|
|
261
197
|
reference: {
|
|
262
198
|
schema: {
|
|
263
|
-
$ref: 'dxn:
|
|
199
|
+
$ref: 'dxn:com.example.type.organization',
|
|
264
200
|
},
|
|
265
201
|
schemaVersion: '0.1.0',
|
|
266
202
|
},
|
|
@@ -277,31 +213,21 @@ describe('effect-to-json', () => {
|
|
|
277
213
|
test('add reference property', () => {
|
|
278
214
|
const Organization = Schema.Struct({
|
|
279
215
|
field: Schema.String,
|
|
280
|
-
}).pipe(
|
|
281
|
-
Type.object({
|
|
282
|
-
typename: 'com.example.type.organization',
|
|
283
|
-
version: '0.1.0',
|
|
284
|
-
}),
|
|
285
|
-
);
|
|
216
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
286
217
|
|
|
287
218
|
const Contact = Schema.Struct({
|
|
288
219
|
name: Schema.String,
|
|
289
220
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
290
|
-
}).pipe(
|
|
291
|
-
Type.object({
|
|
292
|
-
typename: 'com.example.type.person',
|
|
293
|
-
version: '0.1.0',
|
|
294
|
-
}),
|
|
295
|
-
);
|
|
221
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));
|
|
296
222
|
|
|
297
223
|
const jsonSchema = toJsonSchema(Contact);
|
|
298
|
-
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization
|
|
224
|
+
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Type.getTypename(Organization)));
|
|
299
225
|
const { typename } = getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as JsonProp) ?? {}) ?? {};
|
|
300
|
-
expect(typename).to.eq(Organization
|
|
226
|
+
expect(typename).to.eq(Type.getTypename(Organization));
|
|
301
227
|
});
|
|
302
228
|
|
|
303
|
-
test('serialize circular schema (
|
|
304
|
-
const jsonSchema = toJsonSchema(
|
|
229
|
+
test('serialize circular schema (TypeSchema)', () => {
|
|
230
|
+
const jsonSchema = toJsonSchema(TypeSchema);
|
|
305
231
|
expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
|
|
306
232
|
|
|
307
233
|
// TODO(dmaretskyi): Currently unable to deserialize.
|
|
@@ -350,18 +276,18 @@ describe('effect-to-json', () => {
|
|
|
350
276
|
const schema = TestSchema.EmployedBy;
|
|
351
277
|
const jsonSchema = toJsonSchema(schema);
|
|
352
278
|
expect(jsonSchema).toEqual({
|
|
353
|
-
$id: 'dxn:
|
|
279
|
+
$id: 'dxn:com.example.type.employedBy:0.1.0',
|
|
354
280
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
355
281
|
entityKind: 'relation',
|
|
356
|
-
typename: 'com.example.type.
|
|
282
|
+
typename: 'com.example.type.employedBy',
|
|
357
283
|
version: '0.1.0',
|
|
358
284
|
relationSource: {
|
|
359
285
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
360
|
-
$ref: 'dxn:
|
|
286
|
+
$ref: 'dxn:com.example.type.person',
|
|
361
287
|
},
|
|
362
288
|
relationTarget: {
|
|
363
289
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
364
|
-
$ref: 'dxn:
|
|
290
|
+
$ref: 'dxn:com.example.type.organization',
|
|
365
291
|
},
|
|
366
292
|
type: 'object',
|
|
367
293
|
properties: {
|
|
@@ -383,19 +309,13 @@ describe('effect-to-json', () => {
|
|
|
383
309
|
|
|
384
310
|
test('label prop', () => {
|
|
385
311
|
const Organization = Schema.Struct({
|
|
386
|
-
id:
|
|
312
|
+
id: EntityId,
|
|
387
313
|
name: Schema.String,
|
|
388
|
-
}).pipe(
|
|
389
|
-
EchoObjectSchema({
|
|
390
|
-
typename: 'com.example.type.organization',
|
|
391
|
-
version: '0.1.0',
|
|
392
|
-
}),
|
|
393
|
-
LabelAnnotation.set(['name']),
|
|
394
|
-
);
|
|
314
|
+
}).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
|
|
395
315
|
|
|
396
316
|
const jsonSchema = toJsonSchema(Organization);
|
|
397
317
|
expect(jsonSchema).toEqual({
|
|
398
|
-
$id: 'dxn:
|
|
318
|
+
$id: 'dxn:com.example.type.organization:0.1.0',
|
|
399
319
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
400
320
|
typename: 'com.example.type.organization',
|
|
401
321
|
version: '0.1.0',
|
|
@@ -422,9 +342,9 @@ describe('effect-to-json', () => {
|
|
|
422
342
|
|
|
423
343
|
test('object id with description', () => {
|
|
424
344
|
const schema = Schema.Struct({
|
|
425
|
-
id:
|
|
345
|
+
id: EntityId.annotations({ description: 'The id' }),
|
|
426
346
|
});
|
|
427
|
-
// log.info('schema', { schema:
|
|
347
|
+
// log.info('schema', { schema: EntityId.ast });
|
|
428
348
|
const jsonSchema = toJsonSchema(schema);
|
|
429
349
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
430
350
|
{
|
|
@@ -468,7 +388,7 @@ describe('effect-to-json', () => {
|
|
|
468
388
|
const expectReferenceAnnotation = (object: JsonSchemaType) => {
|
|
469
389
|
expect(object.reference).to.deep.eq({
|
|
470
390
|
schema: {
|
|
471
|
-
$ref: 'dxn:
|
|
391
|
+
$ref: 'dxn:com.example.type.testNested',
|
|
472
392
|
},
|
|
473
393
|
schemaVersion: '0.1.0',
|
|
474
394
|
});
|
|
@@ -495,12 +415,7 @@ describe('json-to-effect', () => {
|
|
|
495
415
|
test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
|
|
496
416
|
const Organization = Schema.Struct({
|
|
497
417
|
field: Schema.String,
|
|
498
|
-
}).pipe(
|
|
499
|
-
Type.object({
|
|
500
|
-
typename: 'com.example.type.organization',
|
|
501
|
-
version: '0.1.0',
|
|
502
|
-
}),
|
|
503
|
-
);
|
|
418
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
504
419
|
|
|
505
420
|
const fields = {
|
|
506
421
|
string: Schema.String,
|
|
@@ -517,10 +432,7 @@ describe('json-to-effect', () => {
|
|
|
517
432
|
} as const;
|
|
518
433
|
|
|
519
434
|
const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
|
|
520
|
-
Type.
|
|
521
|
-
typename: 'com.example.type.test',
|
|
522
|
-
version: '0.1.0',
|
|
523
|
-
}),
|
|
435
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
524
436
|
);
|
|
525
437
|
|
|
526
438
|
const jsonSchema = toJsonSchema(Test);
|
|
@@ -528,11 +440,12 @@ describe('json-to-effect', () => {
|
|
|
528
440
|
|
|
529
441
|
const schema = toEffectSchema(jsonSchema);
|
|
530
442
|
|
|
531
|
-
|
|
532
|
-
expect(() => expect(
|
|
533
|
-
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();
|
|
534
447
|
// log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
|
|
535
|
-
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(
|
|
448
|
+
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
|
|
536
449
|
|
|
537
450
|
// TODO(dmaretskyi): Fix.
|
|
538
451
|
// expect(
|
|
@@ -580,7 +493,7 @@ describe('json-to-effect', () => {
|
|
|
580
493
|
typename: 'com.example.type.project',
|
|
581
494
|
version: '0.1.0',
|
|
582
495
|
});
|
|
583
|
-
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('
|
|
496
|
+
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
|
|
584
497
|
});
|
|
585
498
|
|
|
586
499
|
test('symbol annotations get compared', () => {
|
|
@@ -603,7 +516,7 @@ describe('json-to-effect', () => {
|
|
|
603
516
|
const schema = TestSchema.HasManager;
|
|
604
517
|
const jsonSchema = toJsonSchema(schema);
|
|
605
518
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
606
|
-
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
|
|
519
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
|
|
607
520
|
});
|
|
608
521
|
|
|
609
522
|
test('generator annotation', () => {
|
|
@@ -715,7 +628,7 @@ describe('json-to-effect', () => {
|
|
|
715
628
|
"$ref": "/schemas/echo/ref",
|
|
716
629
|
"reference": {
|
|
717
630
|
"schema": {
|
|
718
|
-
"$ref": "dxn:
|
|
631
|
+
"$ref": "dxn:com.example.type.person",
|
|
719
632
|
},
|
|
720
633
|
"schemaVersion": "0.1.0",
|
|
721
634
|
},
|
|
@@ -736,9 +649,9 @@ describe('json-to-effect', () => {
|
|
|
736
649
|
test('object nested inside another struct', () => {
|
|
737
650
|
const Contact = Schema.Struct({
|
|
738
651
|
name: Schema.String,
|
|
739
|
-
}).pipe(EchoObjectSchema(
|
|
652
|
+
}).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
|
|
740
653
|
const input = Schema.Struct({
|
|
741
|
-
contact: Contact,
|
|
654
|
+
contact: Type.getSchema(Contact),
|
|
742
655
|
});
|
|
743
656
|
const jsonSchema = toJsonSchema(input);
|
|
744
657
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
@@ -747,7 +660,7 @@ describe('json-to-effect', () => {
|
|
|
747
660
|
"additionalProperties": false,
|
|
748
661
|
"properties": {
|
|
749
662
|
"contact": {
|
|
750
|
-
"$id": "dxn:
|
|
663
|
+
"$id": "dxn:com.example.type.person:0.1.0",
|
|
751
664
|
"additionalProperties": false,
|
|
752
665
|
"entityKind": "object",
|
|
753
666
|
"properties": {
|
|
@@ -796,7 +709,7 @@ describe('reference', () => {
|
|
|
796
709
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
797
710
|
reference: {
|
|
798
711
|
schema: {
|
|
799
|
-
$ref: 'dxn:
|
|
712
|
+
$ref: 'dxn:com.example.type.person',
|
|
800
713
|
},
|
|
801
714
|
schemaVersion: '0.1.0',
|
|
802
715
|
},
|
|
@@ -814,7 +727,7 @@ describe('reference', () => {
|
|
|
814
727
|
$ref: '/schemas/echo/ref',
|
|
815
728
|
reference: {
|
|
816
729
|
schema: {
|
|
817
|
-
$ref: 'dxn:
|
|
730
|
+
$ref: 'dxn:com.example.type.person',
|
|
818
731
|
},
|
|
819
732
|
schemaVersion: '0.1.0',
|
|
820
733
|
},
|
|
@@ -835,7 +748,7 @@ describe('reference', () => {
|
|
|
835
748
|
$ref: '/schemas/echo/ref',
|
|
836
749
|
reference: {
|
|
837
750
|
schema: {
|
|
838
|
-
$ref: 'dxn:
|
|
751
|
+
$ref: 'dxn:com.example.type.person',
|
|
839
752
|
},
|
|
840
753
|
schemaVersion: '0.1.0',
|
|
841
754
|
},
|
|
@@ -854,8 +767,8 @@ describe('reference', () => {
|
|
|
854
767
|
const deserializedSchema = toEffectSchema(jsonSchema);
|
|
855
768
|
const refAst = getReferenceAst(deserializedSchema.ast);
|
|
856
769
|
expect(refAst).toEqual({
|
|
857
|
-
typename: TestSchema.Person
|
|
858
|
-
version: TestSchema.Person
|
|
770
|
+
typename: Type.getTypename(TestSchema.Person),
|
|
771
|
+
version: Type.getVersion(TestSchema.Person),
|
|
859
772
|
});
|
|
860
773
|
});
|
|
861
774
|
});
|
|
@@ -13,19 +13,21 @@ 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
|
-
|
|
24
|
+
ANY_OBJECT_TYPENAME,
|
|
25
|
+
ANY_OBJECT_VERSION,
|
|
26
|
+
EntityKind,
|
|
27
|
+
EntityKindSchema,
|
|
28
|
+
getStaticTypeSchema,
|
|
29
|
+
} from '../common/types';
|
|
26
30
|
import { type JsonSchemaReferenceInfo, createEchoReferenceSchema } from '../Ref';
|
|
27
|
-
import { ANY_OBJECT_TYPENAME, ANY_OBJECT_VERSION, EntityKind, EntityKindSchema } from '../common/types';
|
|
28
|
-
|
|
29
31
|
import { CustomAnnotations, DecodedAnnotations, EchoAnnotations } from './annotations';
|
|
30
32
|
import {
|
|
31
33
|
ECHO_ANNOTATIONS_NS_DEPRECATED_KEY,
|
|
@@ -82,11 +84,22 @@ export type JsonSchemaOptions = {
|
|
|
82
84
|
// We add additional propertyOrder (but the object properties ARE ordered); and type "string" for literals.
|
|
83
85
|
// TODO(wittjosiah): This is mutable because its a pojo, perhaps should be left as readonly at type level though?
|
|
84
86
|
export const toJsonSchema = (
|
|
85
|
-
schema: Schema.Schema.All,
|
|
87
|
+
schema: Schema.Schema.All | Type.AnyEntity,
|
|
86
88
|
options: JsonSchemaOptions = {},
|
|
87
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
|
+
}
|
|
88
101
|
assertArgument(Schema.isSchema(schema), 'schema');
|
|
89
|
-
let jsonSchema = _toJsonSchemaAST(schema.ast);
|
|
102
|
+
let jsonSchema = _toJsonSchemaAST((schema as Schema.Schema.All).ast);
|
|
90
103
|
if (options.strict) {
|
|
91
104
|
// TOOD(burdon): Workaround to ensure JSON schema is valid (for agv parsing).
|
|
92
105
|
jsonSchema = removeProperties(jsonSchema, (key, value) => {
|
|
@@ -341,9 +354,9 @@ const anyToEffectSchema = (root: JSONSchema.JsonSchema7Any): Schema.Schema.AnyNo
|
|
|
341
354
|
const echoRefinement: JsonSchemaEchoAnnotations = (root as any)[ECHO_ANNOTATIONS_NS_DEPRECATED_KEY];
|
|
342
355
|
// TODO(dmaretskyi): Is this branch still taken?
|
|
343
356
|
if ((echoRefinement as any)?.reference != null) {
|
|
344
|
-
const
|
|
357
|
+
const echoUri = root.$id.startsWith('echo:') || root.$id.startsWith('dxn:echo:') ? root.$id : undefined;
|
|
345
358
|
return createEchoReferenceSchema(
|
|
346
|
-
|
|
359
|
+
echoUri,
|
|
347
360
|
(echoRefinement as any).reference.typename,
|
|
348
361
|
(echoRefinement as any).reference.version,
|
|
349
362
|
);
|
|
@@ -364,14 +377,11 @@ const refToEffectSchema = (root: any): Schema.Schema.AnyNoContext => {
|
|
|
364
377
|
throw new Error('Invalid reference field in ref schema');
|
|
365
378
|
}
|
|
366
379
|
|
|
367
|
-
const
|
|
368
|
-
|
|
380
|
+
const ref = reference.schema.$ref;
|
|
381
|
+
const targetSchemaDXN = DXN.tryMake(ref);
|
|
382
|
+
invariant(targetSchemaDXN, `Expected a type DXN, got: ${ref}`);
|
|
369
383
|
|
|
370
|
-
return createEchoReferenceSchema(
|
|
371
|
-
targetSchemaDXN.toString(),
|
|
372
|
-
targetSchemaDXN.kind === DXN.kind.TYPE ? targetSchemaDXN.parts[0] : undefined,
|
|
373
|
-
reference.schemaVersion,
|
|
374
|
-
);
|
|
384
|
+
return createEchoReferenceSchema(ref, DXN.getName(targetSchemaDXN), reference.schemaVersion);
|
|
375
385
|
};
|
|
376
386
|
|
|
377
387
|
//
|
|
@@ -392,10 +402,11 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
392
402
|
schemaFields[ECHO_ANNOTATIONS_NS_KEY] = echoAnnotations;
|
|
393
403
|
}
|
|
394
404
|
|
|
405
|
+
// For stored schemas the storage URI is the definitive identifier — it overrides
|
|
406
|
+
// the typename `$id` written above.
|
|
395
407
|
const echoIdentifier = annotations[TypeIdentifierAnnotationId];
|
|
396
408
|
if (echoIdentifier) {
|
|
397
|
-
schemaFields
|
|
398
|
-
schemaFields[ECHO_ANNOTATIONS_NS_KEY].schemaId = echoIdentifier;
|
|
409
|
+
schemaFields.$id = echoIdentifier;
|
|
399
410
|
}
|
|
400
411
|
|
|
401
412
|
// Custom (at end).
|
|
@@ -410,14 +421,14 @@ const annotations_toJsonSchemaFields = (annotations: SchemaAST.Annotations): Rec
|
|
|
410
421
|
};
|
|
411
422
|
|
|
412
423
|
const decodeTypeIdentifierAnnotation = (schema: JsonSchemaType): string | undefined => {
|
|
413
|
-
//
|
|
414
|
-
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:'))) {
|
|
415
426
|
return schema.$id;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
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;
|
|
421
432
|
}
|
|
422
433
|
return undefined;
|
|
423
434
|
};
|
|
@@ -434,8 +445,8 @@ const decodeTypeAnnotation = (schema: JsonSchemaType): TypeAnnotation | undefine
|
|
|
434
445
|
if (annotation.kind === EntityKind.Relation) {
|
|
435
446
|
const source = schema.relationSource?.$ref ?? raise(new Error('Relation source not set'));
|
|
436
447
|
const target = schema.relationTarget?.$ref ?? raise(new Error('Relation target not set'));
|
|
437
|
-
annotation.sourceSchema = DXN.
|
|
438
|
-
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}`));
|
|
439
450
|
}
|
|
440
451
|
|
|
441
452
|
return annotation;
|
|
@@ -471,7 +482,9 @@ const jsonSchemaFieldsToAnnotations = (schema: JsonSchemaType): SchemaAST.Annota
|
|
|
471
482
|
if (typeAnnotation) {
|
|
472
483
|
annotations[TypeAnnotationId] = typeAnnotation;
|
|
473
484
|
annotations[SchemaAST.JSONSchemaAnnotationId] = makeTypeJsonSchemaAnnotation({
|
|
474
|
-
|
|
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),
|
|
475
488
|
kind: typeAnnotation.kind,
|
|
476
489
|
typename: typeAnnotation.typename,
|
|
477
490
|
version: typeAnnotation.version,
|