@dxos/echo 0.8.4-staging.ac66bdf99f → 0.9.0
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 +37 -6
- package/dist/lib/neutral/Database.mjs +6 -17
- package/dist/lib/neutral/Entity.mjs +31 -20
- package/dist/lib/neutral/Err.mjs +3 -3
- package/dist/lib/neutral/Feed.mjs +23 -19
- package/dist/lib/neutral/Filter.mjs +13 -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 +11 -10
- package/dist/lib/neutral/Obj.mjs +29 -20
- package/dist/lib/neutral/Order.mjs +7 -3
- package/dist/lib/neutral/Query.mjs +17 -17
- 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/Relation.mjs +28 -25
- package/dist/lib/neutral/Scope.mjs +12 -0
- package/dist/lib/neutral/Tag.mjs +17 -14
- package/dist/lib/neutral/Type.mjs +54 -26
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-35INCYOE.mjs} +1 -1
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +101 -0
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +184 -0
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs +108 -0
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OS35K56T.mjs → chunk-5SUJPHAE.mjs} +3 -3
- package/dist/lib/neutral/{chunk-OS35K56T.mjs.map → chunk-5SUJPHAE.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-GZQTCRJB.mjs → chunk-6M2Z6WBH.mjs} +22 -2
- package/dist/lib/neutral/chunk-6M2Z6WBH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-V36VO5SS.mjs → chunk-6YDI3J37.mjs} +32 -40
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MOR5ERFM.mjs → chunk-7FPIAJIV.mjs} +701 -1256
- package/dist/lib/neutral/chunk-7FPIAJIV.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-JUXPFOEI.mjs → chunk-7PI7C4EF.mjs} +48 -88
- package/dist/lib/neutral/chunk-7PI7C4EF.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-UI6MWK5W.mjs → chunk-EVK6XBXO.mjs} +16 -2
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7RO7CPBZ.mjs → chunk-IGK6FN65.mjs} +2 -2
- package/dist/lib/neutral/{chunk-HBUZJNZO.mjs → chunk-LWXVKPPW.mjs} +94 -99
- package/dist/lib/neutral/chunk-LWXVKPPW.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BVOFLCVF.mjs → chunk-MZ7K3MLL.mjs} +9 -6
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TBKX6JQO.mjs → chunk-O6BH7EPN.mjs} +30 -3
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EAMSSLZC.mjs → chunk-QQIYS74I.mjs} +83 -46
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs +678 -0
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WAK4DMFV.mjs → chunk-RIVWNMSF.mjs} +12 -7
- package/dist/lib/neutral/chunk-RIVWNMSF.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-T6W2LEZU.mjs → chunk-SBVFRTST.mjs} +73 -38
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs +251 -0
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-DQYLD2RB.mjs → chunk-TFEWTY5A.mjs} +155 -129
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B4BASU6W.mjs → chunk-TYGKCRMK.mjs} +85 -76
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4OIBYSXE.mjs → chunk-UUP46KUQ.mjs} +78 -32
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +36 -0
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-G3IQMKF7.mjs → chunk-WTQJHC75.mjs} +111 -112
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs +31 -0
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TU3GW67D.mjs → chunk-ZGNNFYHS.mjs} +40 -40
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +47 -41
- package/dist/lib/neutral/internal/index.mjs +137 -72
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +261 -178
- package/dist/lib/neutral/testing/index.mjs.map +4 -4
- 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 -49
- 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 +101 -28
- 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 +66 -19
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +38 -12
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Format.d.ts +0 -2
- package/dist/types/src/Format.d.ts.map +1 -1
- 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 +26 -11
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +104 -61
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +10 -0
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +34 -12
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +21 -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 +73 -41
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +35 -0
- package/dist/types/src/Scope.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/Type.d.ts +362 -95
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +9 -12
- 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 +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +79 -38
- 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 +17 -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 +21 -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 +24 -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 +34 -34
- 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/atoms.d.ts +38 -0
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -0
- 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 +12 -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 +1 -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/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/index.d.ts +2 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -0
- package/dist/types/src/internal/{Query.d.ts → Query/pretty.d.ts} +1 -1
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +10 -0
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts +2 -2
- package/dist/types/src/internal/Ref/ref.d.ts +50 -19
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/utils.d.ts +8 -0
- package/dist/types/src/internal/Ref/utils.d.ts.map +1 -0
- 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 +62 -5
- 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 +33 -12
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +15 -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 -2
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/registry.d.ts +9 -0
- package/dist/types/src/testing/registry.d.ts.map +1 -0
- 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 +26 -24
- package/src/Annotation.test.ts +439 -0
- package/src/Annotation.ts +158 -4
- package/src/Collection.ts +5 -9
- package/src/Database.ts +93 -100
- package/src/Dataset.ts +10 -2
- package/src/Entity.test.ts +116 -6
- package/src/Entity.ts +134 -32
- package/src/Err.ts +4 -4
- package/src/Feed.ts +92 -44
- package/src/Filter.ts +70 -40
- package/src/Format.ts +0 -4
- 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 +39 -19
- package/src/Obj.test.ts +122 -20
- package/src/Obj.ts +168 -91
- package/src/Order.ts +22 -0
- package/src/Query.test.ts +183 -154
- package/src/Query.ts +172 -85
- package/src/QueryResult.ts +26 -0
- package/src/Ref.ts +22 -4
- package/src/Registry.ts +155 -0
- package/src/Relation.test.ts +10 -10
- package/src/Relation.ts +116 -69
- package/src/Scope.ts +50 -0
- package/src/Tag.md +88 -0
- package/src/Tag.ts +49 -6
- package/src/Type.test.ts +223 -18
- package/src/Type.ts +609 -131
- package/src/View.ts +14 -23
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +4 -4
- package/src/internal/Annotation/annotations.test.ts +31 -11
- package/src/internal/Annotation/annotations.ts +143 -111
- package/src/internal/Annotation/dictionary.ts +47 -0
- package/src/internal/Annotation/entity-dictionary.ts +74 -0
- package/src/internal/Annotation/index.ts +4 -2
- package/src/internal/Annotation/util.ts +17 -8
- package/src/internal/Entity/api.ts +54 -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 +38 -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 +92 -0
- package/src/internal/Entity/util.ts +9 -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-type.ts +4 -4
- package/src/internal/JsonSchema/json-schema.test.ts +71 -145
- package/src/internal/JsonSchema/json-schema.ts +49 -35
- package/src/internal/Obj/atoms.ts +244 -0
- 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 +68 -22
- package/src/internal/Obj/index.ts +1 -1
- package/src/internal/Obj/inspect.ts +5 -3
- package/src/internal/Obj/json-serializer.test.ts +101 -22
- package/src/internal/Obj/json-serializer.ts +89 -33
- package/src/internal/Obj/set-value.test.ts +22 -45
- package/src/internal/Obj/set-value.ts +12 -19
- package/src/internal/Obj/snapshot.ts +13 -4
- package/src/internal/Obj/typed-object.test.ts +9 -11
- package/src/internal/Obj/typed-object.ts +1 -1
- package/src/internal/Query/index.ts +5 -0
- package/src/internal/{Query.ts → Query/pretty.ts} +40 -12
- package/src/internal/Ref/atoms.ts +20 -0
- package/src/internal/Ref/ref-array.ts +3 -3
- package/src/internal/Ref/ref.test.ts +18 -27
- package/src/internal/Ref/ref.ts +137 -59
- package/src/internal/Ref/utils.ts +45 -0
- 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 +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 +91 -83
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +1 -1
- package/src/internal/common/proxy/json-serializer.ts +27 -16
- package/src/internal/common/proxy/make-object.ts +44 -20
- package/src/internal/common/proxy/ownership.ts +2 -2
- 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 -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 +78 -16
- package/src/internal/common/proxy/typed-object.test.ts +16 -28
- 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 +62 -20
- package/src/internal/common/types/model-symbols.ts +24 -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 -4
- package/src/testing/api.test.ts +15 -9
- package/src/testing/index.ts +1 -0
- package/src/testing/registry.ts +44 -0
- package/src/testing/test-data.ts +159 -99
- 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-2KHZ36F5.mjs +0 -361
- package/dist/lib/neutral/chunk-2KHZ36F5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4OIBYSXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs +0 -45
- package/dist/lib/neutral/chunk-4P3IXBLT.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-B4BASU6W.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-BVOFLCVF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-DQYLD2RB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EAMSSLZC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-G3IQMKF7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-GZQTCRJB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HBUZJNZO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JUXPFOEI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MOR5ERFM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PHU22NLC.mjs +0 -136
- package/dist/lib/neutral/chunk-PHU22NLC.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs +0 -97
- package/dist/lib/neutral/chunk-ROG4RXXL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T6W2LEZU.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TBKX6JQO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TU3GW67D.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UBEZSGXY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UI6MWK5W.mjs.map +0 -7
- package/dist/lib/neutral/chunk-V36VO5SS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WAK4DMFV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs +0 -56
- package/dist/lib/neutral/chunk-YAHXAYOW.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YS6Q3XAD.mjs +0 -50
- package/dist/lib/neutral/chunk-YS6Q3XAD.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/Query.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-7RO7CPBZ.mjs.map → chunk-IGK6FN65.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
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { SchemaEx } from '@dxos/effect';
|
|
8
8
|
|
|
9
9
|
import { type Mutable } from '../common/proxy';
|
|
10
10
|
import { EntityKindSchema } from '../common/types';
|
|
@@ -34,7 +34,7 @@ export const JsonSchemaEchoAnnotations = Schema.Struct({
|
|
|
34
34
|
* Label for this schema.
|
|
35
35
|
* Mapped from {@link LabelAnnotationId}.
|
|
36
36
|
*/
|
|
37
|
-
labelProp: Schema.optional(Schema.Union(JsonPath, Schema.Array(JsonPath))),
|
|
37
|
+
labelProp: Schema.optional(Schema.Union(SchemaEx.JsonPath, Schema.Array(SchemaEx.JsonPath))),
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Generator function for this schema.
|
|
@@ -339,14 +339,14 @@ export const JsonSchemaType: Schema.Schema<JsonSchemaType> = _JsonSchemaType;
|
|
|
339
339
|
|
|
340
340
|
// TODO(burdon): Factor out JSON schema utils.
|
|
341
341
|
|
|
342
|
-
export const getSchemaProperty = (schema: JsonSchemaType, property: JsonProp): JsonSchemaType | undefined => {
|
|
342
|
+
export const getSchemaProperty = (schema: JsonSchemaType, property: SchemaEx.JsonProp): JsonSchemaType | undefined => {
|
|
343
343
|
return schema.properties?.[property];
|
|
344
344
|
};
|
|
345
345
|
|
|
346
346
|
// TODO(burdon): Properties should be ordered.
|
|
347
347
|
export const setSchemaProperty = (
|
|
348
348
|
schema: Mutable<JsonSchemaType>,
|
|
349
|
-
property: JsonProp,
|
|
349
|
+
property: SchemaEx.JsonProp,
|
|
350
350
|
value: Mutable<JsonSchemaType>,
|
|
351
351
|
) => {
|
|
352
352
|
schema.properties ??= {};
|
|
@@ -7,8 +7,8 @@ import * as Schema from 'effect/Schema';
|
|
|
7
7
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
8
8
|
import { describe, expect, test } from 'vitest';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { SchemaEx } from '@dxos/effect';
|
|
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,44 +68,24 @@ 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
|
|
|
106
|
-
const annotation = findAnnotation<string>(effectSchema.ast, FieldLookupAnnotationId);
|
|
78
|
+
const annotation = SchemaEx.findAnnotation<string>(effectSchema.ast, FieldLookupAnnotationId);
|
|
107
79
|
expect(annotation).to.not.toBeUndefined();
|
|
108
80
|
});
|
|
109
81
|
|
|
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,26 @@ 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(
|
|
298
|
-
|
|
299
|
-
|
|
224
|
+
setSchemaProperty(
|
|
225
|
+
jsonSchema,
|
|
226
|
+
'organization' as SchemaEx.JsonProp,
|
|
227
|
+
createSchemaReference(Type.getTypename(Organization)),
|
|
228
|
+
);
|
|
229
|
+
const { typename } =
|
|
230
|
+
getSchemaReference(getSchemaProperty(jsonSchema, 'organization' as SchemaEx.JsonProp) ?? {}) ?? {};
|
|
231
|
+
expect(typename).to.eq(Type.getTypename(Organization));
|
|
300
232
|
});
|
|
301
233
|
|
|
302
|
-
test('serialize circular schema (
|
|
303
|
-
const jsonSchema = toJsonSchema(
|
|
234
|
+
test('serialize circular schema (TypeSchema)', () => {
|
|
235
|
+
const jsonSchema = toJsonSchema(TypeSchema);
|
|
304
236
|
expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
|
|
305
237
|
|
|
306
238
|
// TODO(dmaretskyi): Currently unable to deserialize.
|
|
@@ -349,18 +281,18 @@ describe('effect-to-json', () => {
|
|
|
349
281
|
const schema = TestSchema.EmployedBy;
|
|
350
282
|
const jsonSchema = toJsonSchema(schema);
|
|
351
283
|
expect(jsonSchema).toEqual({
|
|
352
|
-
$id: 'dxn:
|
|
284
|
+
$id: 'dxn:com.example.type.employedBy:0.1.0',
|
|
353
285
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
354
286
|
entityKind: 'relation',
|
|
355
|
-
typename: 'com.example.type.
|
|
287
|
+
typename: 'com.example.type.employedBy',
|
|
356
288
|
version: '0.1.0',
|
|
357
289
|
relationSource: {
|
|
358
290
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
359
|
-
$ref: 'dxn:
|
|
291
|
+
$ref: 'dxn:com.example.type.person',
|
|
360
292
|
},
|
|
361
293
|
relationTarget: {
|
|
362
294
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
363
|
-
$ref: 'dxn:
|
|
295
|
+
$ref: 'dxn:com.example.type.organization',
|
|
364
296
|
},
|
|
365
297
|
type: 'object',
|
|
366
298
|
properties: {
|
|
@@ -382,19 +314,13 @@ describe('effect-to-json', () => {
|
|
|
382
314
|
|
|
383
315
|
test('label prop', () => {
|
|
384
316
|
const Organization = Schema.Struct({
|
|
385
|
-
id:
|
|
317
|
+
id: EntityId,
|
|
386
318
|
name: Schema.String,
|
|
387
|
-
}).pipe(
|
|
388
|
-
EchoObjectSchema({
|
|
389
|
-
typename: 'com.example.type.organization',
|
|
390
|
-
version: '0.1.0',
|
|
391
|
-
}),
|
|
392
|
-
LabelAnnotation.set(['name']),
|
|
393
|
-
);
|
|
319
|
+
}).pipe(LabelAnnotation.set(['name']), EchoObjectSchema(DXN.make('com.example.type.organization', '0.1.0')));
|
|
394
320
|
|
|
395
321
|
const jsonSchema = toJsonSchema(Organization);
|
|
396
322
|
expect(jsonSchema).toEqual({
|
|
397
|
-
$id: 'dxn:
|
|
323
|
+
$id: 'dxn:com.example.type.organization:0.1.0',
|
|
398
324
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
399
325
|
typename: 'com.example.type.organization',
|
|
400
326
|
version: '0.1.0',
|
|
@@ -421,9 +347,9 @@ describe('effect-to-json', () => {
|
|
|
421
347
|
|
|
422
348
|
test('object id with description', () => {
|
|
423
349
|
const schema = Schema.Struct({
|
|
424
|
-
id:
|
|
350
|
+
id: EntityId.annotations({ description: 'The id' }),
|
|
425
351
|
});
|
|
426
|
-
// log.info('schema', { schema:
|
|
352
|
+
// log.info('schema', { schema: EntityId.ast });
|
|
427
353
|
const jsonSchema = toJsonSchema(schema);
|
|
428
354
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
429
355
|
{
|
|
@@ -467,7 +393,7 @@ describe('effect-to-json', () => {
|
|
|
467
393
|
const expectReferenceAnnotation = (object: JsonSchemaType) => {
|
|
468
394
|
expect(object.reference).to.deep.eq({
|
|
469
395
|
schema: {
|
|
470
|
-
$ref: 'dxn:
|
|
396
|
+
$ref: 'dxn:com.example.type.testNested',
|
|
471
397
|
},
|
|
472
398
|
schemaVersion: '0.1.0',
|
|
473
399
|
});
|
|
@@ -494,12 +420,7 @@ describe('json-to-effect', () => {
|
|
|
494
420
|
test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
|
|
495
421
|
const Organization = Schema.Struct({
|
|
496
422
|
field: Schema.String,
|
|
497
|
-
}).pipe(
|
|
498
|
-
Type.object({
|
|
499
|
-
typename: 'com.example.type.organization',
|
|
500
|
-
version: '0.1.0',
|
|
501
|
-
}),
|
|
502
|
-
);
|
|
423
|
+
}).pipe(Type.makeObject(DXN.make('com.example.type.organization', '0.1.0')));
|
|
503
424
|
|
|
504
425
|
const fields = {
|
|
505
426
|
string: Schema.String,
|
|
@@ -516,10 +437,7 @@ describe('json-to-effect', () => {
|
|
|
516
437
|
} as const;
|
|
517
438
|
|
|
518
439
|
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
|
-
}),
|
|
440
|
+
Type.makeObject(DXN.make('com.example.type.test', '0.1.0')),
|
|
523
441
|
);
|
|
524
442
|
|
|
525
443
|
const jsonSchema = toJsonSchema(Test);
|
|
@@ -527,11 +445,12 @@ describe('json-to-effect', () => {
|
|
|
527
445
|
|
|
528
446
|
const schema = toEffectSchema(jsonSchema);
|
|
529
447
|
|
|
530
|
-
|
|
531
|
-
expect(() => expect(
|
|
532
|
-
expect(() => expect(
|
|
448
|
+
const testAst = Type.getSchema(Test).ast;
|
|
449
|
+
expect(() => expect(schema.ast).to.deep.eq(testAst)).to.throw();
|
|
450
|
+
expect(() => expect(prepareAstForCompare(testAst)).to.deep.eq(testAst)).to.throw();
|
|
451
|
+
expect(() => expect(schema.ast).to.deep.eq(prepareAstForCompare(testAst))).to.throw();
|
|
533
452
|
// log.info('', { original: prepareAstForCompare(Schema.ast), deserialized: prepareAstForCompare(schema.ast) });
|
|
534
|
-
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(
|
|
453
|
+
expect(prepareAstForCompare(schema.ast)).to.deep.eq(prepareAstForCompare(testAst));
|
|
535
454
|
|
|
536
455
|
// TODO(dmaretskyi): Fix.
|
|
537
456
|
// expect(
|
|
@@ -542,9 +461,9 @@ describe('json-to-effect', () => {
|
|
|
542
461
|
});
|
|
543
462
|
}
|
|
544
463
|
|
|
545
|
-
test('legacy schema with
|
|
464
|
+
test('legacy schema with echo.type annotation gets decoded', () => {
|
|
546
465
|
const jsonSchema: JsonSchemaType = {
|
|
547
|
-
$id: 'dxn:
|
|
466
|
+
$id: 'dxn:com.example.type.project',
|
|
548
467
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
549
468
|
additionalProperties: false,
|
|
550
469
|
echo: {
|
|
@@ -579,7 +498,7 @@ describe('json-to-effect', () => {
|
|
|
579
498
|
typename: 'com.example.type.project',
|
|
580
499
|
version: '0.1.0',
|
|
581
500
|
});
|
|
582
|
-
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('
|
|
501
|
+
expect(getTypeIdentifierAnnotation(schema)).to.deep.eq('echo:/01JERV1HQCQZDQ4NVCJ42QB38F');
|
|
583
502
|
});
|
|
584
503
|
|
|
585
504
|
test('symbol annotations get compared', () => {
|
|
@@ -602,7 +521,7 @@ describe('json-to-effect', () => {
|
|
|
602
521
|
const schema = TestSchema.HasManager;
|
|
603
522
|
const jsonSchema = toJsonSchema(schema);
|
|
604
523
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
605
|
-
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
|
|
524
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(Type.getSchema(schema).ast));
|
|
606
525
|
});
|
|
607
526
|
|
|
608
527
|
test('generator annotation', () => {
|
|
@@ -714,7 +633,7 @@ describe('json-to-effect', () => {
|
|
|
714
633
|
"$ref": "/schemas/echo/ref",
|
|
715
634
|
"reference": {
|
|
716
635
|
"schema": {
|
|
717
|
-
"$ref": "dxn:
|
|
636
|
+
"$ref": "dxn:com.example.type.person",
|
|
718
637
|
},
|
|
719
638
|
"schemaVersion": "0.1.0",
|
|
720
639
|
},
|
|
@@ -735,9 +654,9 @@ describe('json-to-effect', () => {
|
|
|
735
654
|
test('object nested inside another struct', () => {
|
|
736
655
|
const Contact = Schema.Struct({
|
|
737
656
|
name: Schema.String,
|
|
738
|
-
}).pipe(EchoObjectSchema(
|
|
657
|
+
}).pipe(EchoObjectSchema(DXN.make('com.example.type.person', '0.1.0')));
|
|
739
658
|
const input = Schema.Struct({
|
|
740
|
-
contact: Contact,
|
|
659
|
+
contact: Type.getSchema(Contact),
|
|
741
660
|
});
|
|
742
661
|
const jsonSchema = toJsonSchema(input);
|
|
743
662
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
@@ -746,7 +665,7 @@ describe('json-to-effect', () => {
|
|
|
746
665
|
"additionalProperties": false,
|
|
747
666
|
"properties": {
|
|
748
667
|
"contact": {
|
|
749
|
-
"$id": "dxn:
|
|
668
|
+
"$id": "dxn:com.example.type.person:0.1.0",
|
|
750
669
|
"additionalProperties": false,
|
|
751
670
|
"entityKind": "object",
|
|
752
671
|
"properties": {
|
|
@@ -795,7 +714,7 @@ describe('reference', () => {
|
|
|
795
714
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
796
715
|
reference: {
|
|
797
716
|
schema: {
|
|
798
|
-
$ref: 'dxn:
|
|
717
|
+
$ref: 'dxn:com.example.type.person',
|
|
799
718
|
},
|
|
800
719
|
schemaVersion: '0.1.0',
|
|
801
720
|
},
|
|
@@ -813,7 +732,7 @@ describe('reference', () => {
|
|
|
813
732
|
$ref: '/schemas/echo/ref',
|
|
814
733
|
reference: {
|
|
815
734
|
schema: {
|
|
816
|
-
$ref: 'dxn:
|
|
735
|
+
$ref: 'dxn:com.example.type.person',
|
|
817
736
|
},
|
|
818
737
|
schemaVersion: '0.1.0',
|
|
819
738
|
},
|
|
@@ -834,7 +753,7 @@ describe('reference', () => {
|
|
|
834
753
|
$ref: '/schemas/echo/ref',
|
|
835
754
|
reference: {
|
|
836
755
|
schema: {
|
|
837
|
-
$ref: 'dxn:
|
|
756
|
+
$ref: 'dxn:com.example.type.person',
|
|
838
757
|
},
|
|
839
758
|
schemaVersion: '0.1.0',
|
|
840
759
|
},
|
|
@@ -853,8 +772,15 @@ describe('reference', () => {
|
|
|
853
772
|
const deserializedSchema = toEffectSchema(jsonSchema);
|
|
854
773
|
const refAst = getReferenceAst(deserializedSchema.ast);
|
|
855
774
|
expect(refAst).toEqual({
|
|
856
|
-
typename: TestSchema.Person
|
|
857
|
-
version: TestSchema.Person
|
|
775
|
+
typename: Type.getTypename(TestSchema.Person),
|
|
776
|
+
version: Type.getVersion(TestSchema.Person),
|
|
858
777
|
});
|
|
859
778
|
});
|
|
779
|
+
|
|
780
|
+
test('empty struct round-trips as TypeLiteral', () => {
|
|
781
|
+
const schema = Schema.Struct({});
|
|
782
|
+
const jsonSchema = toJsonSchema(schema);
|
|
783
|
+
const deserialized = toEffectSchema(jsonSchema);
|
|
784
|
+
expect(deserialized.ast._tag).toBe('TypeLiteral');
|
|
785
|
+
});
|
|
860
786
|
});
|