@dxos/echo 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/dist/lib/browser/{chunk-MWLA34S5.mjs → chunk-7GH6RXJ3.mjs} +2513 -2673
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -19
- package/dist/lib/browser/internal/index.mjs +55 -45
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +247 -217
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YTNLFBIK.mjs → chunk-M4B6BMD2.mjs} +2513 -2673
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -19
- package/dist/lib/node-esm/internal/index.mjs +55 -45
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +247 -217
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +137 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +36 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +9 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +85 -62
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +10 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +14 -11
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +39 -49
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +14 -18
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +174 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +26 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +10 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
- package/dist/types/src/internal/entities/expando.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +70 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +11 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +55 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +2 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +7 -7
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +6 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +2 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -5
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +9 -10
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +2 -2
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/object/ids.d.ts.map +1 -1
- package/dist/types/src/internal/object/index.d.ts +3 -12
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/index.d.ts +3 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +15 -12
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +9 -9
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +3 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
- package/dist/types/src/internal/types/base.d.ts +37 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +5 -2
- package/dist/types/src/internal/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/{object → types}/meta.d.ts +20 -11
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/query/filter.d.ts +167 -0
- package/dist/types/src/query/filter.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +3 -1
- package/dist/types/src/query/index.d.ts.map +1 -1
- package/dist/types/src/query/order.d.ts +12 -0
- package/dist/types/src/query/order.d.ts.map +1 -0
- package/dist/types/src/query/query.d.ts +9 -144
- package/dist/types/src/query/query.d.ts.map +1 -1
- package/dist/types/src/query/testing.d.ts +51 -0
- package/dist/types/src/query/testing.d.ts.map +1 -0
- package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
- package/dist/types/src/query/types.d.ts.map +1 -0
- package/dist/types/src/query/util.d.ts +8 -0
- package/dist/types/src/query/util.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +337 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -38
- package/src/Annotation.ts +17 -0
- package/src/Database.ts +189 -0
- package/src/Entity.ts +51 -0
- package/src/Format.ts +11 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.ts +260 -147
- package/src/Ref.ts +9 -9
- package/src/Relation.ts +58 -44
- package/src/Tag.ts +40 -0
- package/src/Type.ts +96 -83
- package/src/index.ts +10 -4
- package/src/internal/README.md +83 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
- package/src/internal/annotations/annotations.ts +463 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +70 -0
- package/src/internal/entities/entity.ts +109 -0
- package/src/internal/{object → entities}/expando.ts +7 -5
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +129 -0
- package/src/internal/entities/object.ts +45 -0
- package/src/internal/entities/relation.ts +155 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +1 -1
- package/src/internal/formats/date.ts +5 -5
- package/src/internal/formats/format.test.ts +5 -5
- package/src/internal/formats/format.ts +3 -0
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +2 -2
- package/src/internal/formats/string.ts +9 -9
- package/src/internal/formats/types.ts +44 -39
- package/src/internal/index.ts +29 -13
- package/src/internal/{json → json-schema}/annotations.ts +1 -1
- package/src/internal/json-schema/index.ts +2 -0
- package/src/internal/json-schema/json-schema-type.ts +4 -3
- package/src/internal/{json → json-schema}/json-schema.test.ts +230 -97
- package/src/internal/{json → json-schema}/json-schema.ts +67 -87
- package/src/internal/object/common.ts +3 -4
- package/src/internal/object/{create.test.ts → create-object.test.ts} +31 -33
- package/src/internal/object/{create.ts → create-object.ts} +34 -35
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +3 -12
- package/src/internal/object/inspect.ts +3 -5
- package/src/internal/object/json-serializer.test.ts +33 -38
- package/src/internal/object/json-serializer.ts +43 -38
- package/src/internal/object/schema-validator.ts +3 -2
- package/src/internal/object/typed-object.test.ts +1 -1
- package/src/internal/object/typed-object.ts +17 -4
- package/src/internal/proxy/handler.test.ts +30 -20
- package/src/internal/proxy/index.ts +6 -0
- package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
- package/src/internal/proxy/schema.test.ts +5 -4
- package/src/internal/proxy/typed-handler.test.ts +28 -28
- package/src/internal/proxy/typed-handler.ts +11 -6
- package/src/internal/proxy/typed-object.test.ts +17 -12
- package/src/internal/ref/ref.test.ts +9 -8
- package/src/internal/ref/ref.ts +24 -20
- package/src/internal/{projection → schema}/compose.test.ts +5 -6
- package/src/internal/{projection → schema}/compose.ts +2 -1
- package/src/internal/schema/echo-schema.ts +30 -28
- package/src/internal/schema/index.ts +3 -4
- package/src/internal/schema/manipulation.ts +7 -1
- package/src/internal/schema/persistent-schema.ts +28 -0
- package/src/internal/schema/runtime-schema-registry.ts +4 -4
- package/src/internal/types/base.ts +58 -0
- package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/{object → types}/meta.ts +32 -18
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/query/filter.ts +455 -0
- package/src/query/index.ts +4 -1
- package/src/query/order.ts +34 -0
- package/src/query/query.test.ts +188 -216
- package/src/query/query.ts +24 -505
- package/src/query/testing.ts +64 -0
- package/src/query/util.ts +25 -0
- package/src/testing/api.test.ts +100 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +213 -0
- package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
- package/dist/lib/browser/chunk-MWLA34S5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OAZJQHVO.mjs +0 -453
- package/dist/lib/browser/chunk-OAZJQHVO.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORIE2FMS.mjs +0 -514
- package/dist/lib/browser/chunk-ORIE2FMS.mjs.map +0 -7
- package/dist/lib/browser/query/index.mjs +0 -23
- package/dist/lib/browser/query/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs +0 -453
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs +0 -514
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTNLFBIK.mjs.map +0 -7
- package/dist/lib/node-esm/query/index.mjs +0 -23
- package/dist/lib/node-esm/query/index.mjs.map +0 -7
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -119
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -29
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -22
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typed-relation.d.ts +0 -32
- package/dist/types/src/internal/object/typed-relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -455
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/tag.d.ts +0 -18
- package/dist/types/src/query/tag.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -113
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -212
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -115
- package/src/internal/object/entity.ts +0 -204
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-relation.ts +0 -85
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/query/index.ts +0 -5
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/index.ts +0 -6
- package/src/internal/testing/types.ts +0 -211
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/tag.ts +0 -35
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -91
- /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
- /package/src/{internal/query/query.ts → query/types.ts} +0 -0
|
@@ -11,21 +11,22 @@ import { type JsonProp, findAnnotation } from '@dxos/effect';
|
|
|
11
11
|
import { ObjectId } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
|
|
14
|
+
import { TestSchema, prepareAstForCompare } from '../../testing';
|
|
15
|
+
import * as Type from '../../Type';
|
|
14
16
|
import {
|
|
15
|
-
EntityKind,
|
|
16
17
|
FieldLookupAnnotationId,
|
|
17
18
|
GeneratorAnnotation,
|
|
18
19
|
LabelAnnotation,
|
|
19
20
|
PropertyMeta,
|
|
20
21
|
getTypeAnnotation,
|
|
21
22
|
getTypeIdentifierAnnotation,
|
|
22
|
-
} from '../
|
|
23
|
-
import {
|
|
23
|
+
} from '../annotations';
|
|
24
|
+
import { EchoObjectSchema } from '../entities';
|
|
25
|
+
import { Email, FormatAnnotation, TypeFormat } from '../formats';
|
|
24
26
|
import { JsonSchemaType, getNormalizedEchoAnnotations, getSchemaProperty, setSchemaProperty } from '../json-schema';
|
|
25
|
-
import { EchoObject, TypedObject } from '../object';
|
|
26
27
|
import { Ref, createSchemaReference, getReferenceAst, getSchemaReference } from '../ref';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
28
|
+
import { PersistentSchema } from '../schema';
|
|
29
|
+
import { EntityKind } from '../types';
|
|
29
30
|
|
|
30
31
|
import { toEffectSchema, toJsonSchema } from './json-schema';
|
|
31
32
|
|
|
@@ -33,10 +34,12 @@ const EXAMPLE_NAMESPACE = '@example';
|
|
|
33
34
|
|
|
34
35
|
describe('effect-to-json', () => {
|
|
35
36
|
test('type annotation', () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const Test = Schema.Struct({ name: Schema.String }).pipe(
|
|
38
|
+
Type.Obj({
|
|
39
|
+
typename: 'example.com/type/Test',
|
|
40
|
+
version: '0.1.0',
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
40
43
|
const jsonSchema = toJsonSchema(Test);
|
|
41
44
|
expect((jsonSchema as any).$id).toEqual('dxn:type:example.com/type/Test');
|
|
42
45
|
expect((jsonSchema as any).version).toEqual('0.1.0');
|
|
@@ -44,23 +47,35 @@ describe('effect-to-json', () => {
|
|
|
44
47
|
|
|
45
48
|
test('property meta annotation', () => {
|
|
46
49
|
const meta = { maxLength: 0 };
|
|
47
|
-
|
|
48
|
-
typename: 'example.com/type/Test',
|
|
49
|
-
version: '0.1.0',
|
|
50
|
-
})({
|
|
50
|
+
const Test = Schema.Struct({
|
|
51
51
|
name: Schema.String.pipe(PropertyMeta(EXAMPLE_NAMESPACE, meta)),
|
|
52
|
-
})
|
|
52
|
+
}).pipe(
|
|
53
|
+
Type.Obj({
|
|
54
|
+
typename: 'example.com/type/Test',
|
|
55
|
+
version: '0.1.0',
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
53
58
|
const jsonSchema = toJsonSchema(Test);
|
|
54
59
|
expect(getNormalizedEchoAnnotations(jsonSchema.properties!.name!)!.meta![EXAMPLE_NAMESPACE]).to.deep.eq(meta);
|
|
55
60
|
});
|
|
56
61
|
|
|
57
62
|
test('reference annotation', () => {
|
|
58
|
-
|
|
63
|
+
const Nested = Schema.Struct({
|
|
59
64
|
name: Schema.String,
|
|
60
|
-
})
|
|
61
|
-
|
|
65
|
+
}).pipe(
|
|
66
|
+
Type.Obj({
|
|
67
|
+
typename: 'example.com/type/TestNested',
|
|
68
|
+
version: '0.1.0',
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
const Test = Schema.Struct({
|
|
62
72
|
name: Ref(Nested),
|
|
63
|
-
})
|
|
73
|
+
}).pipe(
|
|
74
|
+
Type.Obj({
|
|
75
|
+
typename: 'example.com/type/Test',
|
|
76
|
+
version: '0.1.0',
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
64
79
|
const jsonSchema = toJsonSchema(Test);
|
|
65
80
|
// log.info('schema', { jsonSchema });
|
|
66
81
|
const nested = jsonSchema.properties!.name;
|
|
@@ -70,12 +85,22 @@ describe('effect-to-json', () => {
|
|
|
70
85
|
// TODO(ZaymonFC): @dmaretskyi we still need to fix this.
|
|
71
86
|
// TODO(dmaretskyi): Remove FieldLookupAnnotationId.
|
|
72
87
|
test.skip('reference annotation with lookup property', () => {
|
|
73
|
-
|
|
88
|
+
const Nested = Schema.Struct({
|
|
74
89
|
name: Schema.String,
|
|
75
|
-
})
|
|
76
|
-
|
|
90
|
+
}).pipe(
|
|
91
|
+
Type.Obj({
|
|
92
|
+
typename: 'example.com/type/TestNested',
|
|
93
|
+
version: '0.1.0',
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
const Test = Schema.Struct({
|
|
77
97
|
name: Ref(Nested).annotations({ [FieldLookupAnnotationId]: 'name' }),
|
|
78
|
-
})
|
|
98
|
+
}).pipe(
|
|
99
|
+
Type.Obj({
|
|
100
|
+
typename: 'example.com/type/Test',
|
|
101
|
+
version: '0.1.0',
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
79
104
|
const jsonSchema = toJsonSchema(Test);
|
|
80
105
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
81
106
|
|
|
@@ -84,24 +109,44 @@ describe('effect-to-json', () => {
|
|
|
84
109
|
});
|
|
85
110
|
|
|
86
111
|
test('array of references', () => {
|
|
87
|
-
|
|
112
|
+
const Nested = Schema.Struct({
|
|
88
113
|
name: Schema.String,
|
|
89
|
-
})
|
|
90
|
-
|
|
114
|
+
}).pipe(
|
|
115
|
+
Type.Obj({
|
|
116
|
+
typename: 'example.com/type/TestNested',
|
|
117
|
+
version: '0.1.0',
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
const Test = Schema.Struct({
|
|
91
121
|
name: Schema.Array(Ref(Nested)),
|
|
92
|
-
})
|
|
122
|
+
}).pipe(
|
|
123
|
+
Type.Obj({
|
|
124
|
+
typename: 'example.com/type/Test',
|
|
125
|
+
version: '0.1.0',
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
93
128
|
|
|
94
129
|
const jsonSchema = toJsonSchema(Test);
|
|
95
130
|
expectReferenceAnnotation((jsonSchema.properties!.name as any).items);
|
|
96
131
|
});
|
|
97
132
|
|
|
98
133
|
test('optional references', () => {
|
|
99
|
-
|
|
134
|
+
const Nested = Schema.Struct({
|
|
100
135
|
name: Schema.String,
|
|
101
|
-
})
|
|
102
|
-
|
|
136
|
+
}).pipe(
|
|
137
|
+
Type.Obj({
|
|
138
|
+
typename: 'example.com/type/TestNested',
|
|
139
|
+
version: '0.1.0',
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
const Test = Schema.Struct({
|
|
103
143
|
name: Schema.optional(Ref(Nested)),
|
|
104
|
-
})
|
|
144
|
+
}).pipe(
|
|
145
|
+
Type.Obj({
|
|
146
|
+
typename: 'example.com/type/Test',
|
|
147
|
+
version: '0.1.0',
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
105
150
|
const jsonSchema = toJsonSchema(Test);
|
|
106
151
|
expectReferenceAnnotation(jsonSchema.properties!.name);
|
|
107
152
|
});
|
|
@@ -114,19 +159,25 @@ describe('effect-to-json', () => {
|
|
|
114
159
|
});
|
|
115
160
|
|
|
116
161
|
test('annotations', () => {
|
|
117
|
-
|
|
162
|
+
const TempSchema = Schema.Struct({
|
|
118
163
|
name: Schema.String.annotations({ description: 'Person name', title: 'Name' }),
|
|
119
|
-
email: Schema.String.pipe(FormatAnnotation.set(
|
|
164
|
+
email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)).annotations({
|
|
120
165
|
description: 'Email address',
|
|
121
166
|
}),
|
|
122
|
-
})
|
|
123
|
-
|
|
167
|
+
}).pipe(
|
|
168
|
+
Type.Obj({
|
|
169
|
+
typename: 'example.com/type/Person',
|
|
170
|
+
version: '0.1.0',
|
|
171
|
+
}),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const jsonSchema = toJsonSchema(TempSchema);
|
|
124
175
|
expect(jsonSchema).to.deep.eq({
|
|
125
176
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
126
|
-
$id: 'dxn:type:example.com/type/
|
|
177
|
+
$id: 'dxn:type:example.com/type/Person',
|
|
127
178
|
|
|
128
179
|
entityKind: EntityKind.Object,
|
|
129
|
-
typename: 'example.com/type/
|
|
180
|
+
typename: 'example.com/type/Person',
|
|
130
181
|
version: '0.1.0',
|
|
131
182
|
|
|
132
183
|
type: 'object',
|
|
@@ -147,37 +198,47 @@ describe('effect-to-json', () => {
|
|
|
147
198
|
});
|
|
148
199
|
|
|
149
200
|
test('handles suspend -- Contact schema serialization', () => {
|
|
150
|
-
const schema = toJsonSchema(
|
|
201
|
+
const schema = toJsonSchema(TestSchema.Person);
|
|
151
202
|
expect(Object.keys(schema.properties!)).toEqual([
|
|
152
203
|
'id',
|
|
153
204
|
'name',
|
|
154
205
|
'username',
|
|
155
206
|
'email',
|
|
156
|
-
'phoneNumbers',
|
|
157
207
|
'tasks',
|
|
208
|
+
'employer',
|
|
158
209
|
'address',
|
|
159
210
|
]);
|
|
160
211
|
});
|
|
161
212
|
|
|
162
213
|
test('reference property by ref', () => {
|
|
163
|
-
|
|
214
|
+
const Organization = Schema.Struct({
|
|
164
215
|
field: Schema.String,
|
|
165
|
-
})
|
|
216
|
+
}).pipe(
|
|
217
|
+
Type.Obj({
|
|
218
|
+
typename: 'example.com/type/Organization',
|
|
219
|
+
version: '0.1.0',
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
166
222
|
|
|
167
|
-
|
|
223
|
+
const Contact = Schema.Struct({
|
|
168
224
|
name: Schema.String,
|
|
169
225
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
170
|
-
})
|
|
226
|
+
}).pipe(
|
|
227
|
+
Type.Obj({
|
|
228
|
+
typename: 'example.com/type/Person',
|
|
229
|
+
version: '0.1.0',
|
|
230
|
+
}),
|
|
231
|
+
);
|
|
171
232
|
|
|
172
233
|
// log.info('Contact', { ast: Contact.ast });
|
|
173
234
|
|
|
174
235
|
const jsonSchema = toJsonSchema(Contact);
|
|
175
236
|
expect(jsonSchema).toEqual({
|
|
176
237
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
177
|
-
$id: 'dxn:type:example.com/type/
|
|
238
|
+
$id: 'dxn:type:example.com/type/Person',
|
|
178
239
|
|
|
179
240
|
entityKind: EntityKind.Object,
|
|
180
|
-
typename: 'example.com/type/
|
|
241
|
+
typename: 'example.com/type/Person',
|
|
181
242
|
version: '0.1.0',
|
|
182
243
|
|
|
183
244
|
type: 'object',
|
|
@@ -212,14 +273,24 @@ describe('effect-to-json', () => {
|
|
|
212
273
|
});
|
|
213
274
|
|
|
214
275
|
test('add reference property', () => {
|
|
215
|
-
|
|
276
|
+
const Organization = Schema.Struct({
|
|
216
277
|
field: Schema.String,
|
|
217
|
-
})
|
|
278
|
+
}).pipe(
|
|
279
|
+
Type.Obj({
|
|
280
|
+
typename: 'example.com/type/Organization',
|
|
281
|
+
version: '0.1.0',
|
|
282
|
+
}),
|
|
283
|
+
);
|
|
218
284
|
|
|
219
|
-
|
|
285
|
+
const Contact = Schema.Struct({
|
|
220
286
|
name: Schema.String,
|
|
221
287
|
organization: Ref(Organization).annotations({ description: 'Contact organization' }),
|
|
222
|
-
})
|
|
288
|
+
}).pipe(
|
|
289
|
+
Type.Obj({
|
|
290
|
+
typename: 'example.com/type/Person',
|
|
291
|
+
version: '0.1.0',
|
|
292
|
+
}),
|
|
293
|
+
);
|
|
223
294
|
|
|
224
295
|
const jsonSchema = toJsonSchema(Contact);
|
|
225
296
|
setSchemaProperty(jsonSchema, 'organization' as JsonProp, createSchemaReference(Organization.typename));
|
|
@@ -227,8 +298,8 @@ describe('effect-to-json', () => {
|
|
|
227
298
|
expect(typename).to.eq(Organization.typename);
|
|
228
299
|
});
|
|
229
300
|
|
|
230
|
-
test('serialize circular schema (
|
|
231
|
-
const jsonSchema = toJsonSchema(
|
|
301
|
+
test('serialize circular schema (PersistentSchema)', () => {
|
|
302
|
+
const jsonSchema = toJsonSchema(PersistentSchema);
|
|
232
303
|
expect(Object.keys(jsonSchema.properties!).length).toBeGreaterThan(0);
|
|
233
304
|
|
|
234
305
|
// TODO(dmaretskyi): Currently unable to deserialize.
|
|
@@ -251,7 +322,7 @@ describe('effect-to-json', () => {
|
|
|
251
322
|
|
|
252
323
|
test('reference with title annotation', () => {
|
|
253
324
|
const schema = Schema.Struct({
|
|
254
|
-
contact: Ref(
|
|
325
|
+
contact: Ref(TestSchema.Person).annotations({ title: 'Custom Title' }),
|
|
255
326
|
});
|
|
256
327
|
|
|
257
328
|
// log.info('schema before', { ast: schema.ast });
|
|
@@ -274,33 +345,36 @@ describe('effect-to-json', () => {
|
|
|
274
345
|
});
|
|
275
346
|
|
|
276
347
|
test('relation schema', () => {
|
|
277
|
-
const schema =
|
|
348
|
+
const schema = TestSchema.EmployedBy;
|
|
278
349
|
const jsonSchema = toJsonSchema(schema);
|
|
279
350
|
expect(jsonSchema).toEqual({
|
|
280
|
-
$id: 'dxn:type:example.com/type/
|
|
351
|
+
$id: 'dxn:type:example.com/type/EmployedBy',
|
|
281
352
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
282
353
|
entityKind: 'relation',
|
|
283
|
-
typename: 'example.com/type/
|
|
354
|
+
typename: 'example.com/type/EmployedBy',
|
|
284
355
|
version: '0.1.0',
|
|
285
356
|
relationSource: {
|
|
286
357
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
287
|
-
$ref: 'dxn:type:example.com/type/
|
|
358
|
+
$ref: 'dxn:type:example.com/type/Person',
|
|
288
359
|
},
|
|
289
360
|
relationTarget: {
|
|
290
361
|
// TODO(dmaretskyi): Should those point to specific schema version?
|
|
291
|
-
$ref: 'dxn:type:example.com/type/
|
|
362
|
+
$ref: 'dxn:type:example.com/type/Organization',
|
|
292
363
|
},
|
|
293
364
|
type: 'object',
|
|
294
365
|
properties: {
|
|
295
366
|
id: {
|
|
296
367
|
type: 'string',
|
|
297
368
|
},
|
|
369
|
+
role: {
|
|
370
|
+
type: 'string',
|
|
371
|
+
},
|
|
298
372
|
since: {
|
|
299
373
|
type: 'string',
|
|
300
374
|
},
|
|
301
375
|
},
|
|
302
|
-
propertyOrder: ['since', 'id'],
|
|
303
|
-
required: ['id'],
|
|
376
|
+
propertyOrder: ['role', 'since', 'id'],
|
|
377
|
+
required: ['role', 'id'],
|
|
304
378
|
additionalProperties: false,
|
|
305
379
|
});
|
|
306
380
|
});
|
|
@@ -310,7 +384,7 @@ describe('effect-to-json', () => {
|
|
|
310
384
|
id: ObjectId,
|
|
311
385
|
name: Schema.String,
|
|
312
386
|
}).pipe(
|
|
313
|
-
|
|
387
|
+
EchoObjectSchema({
|
|
314
388
|
typename: 'example.com/type/Organization',
|
|
315
389
|
version: '0.1.0',
|
|
316
390
|
}),
|
|
@@ -417,26 +491,35 @@ describe('json-to-effect', () => {
|
|
|
417
491
|
|
|
418
492
|
for (const partial of [false, true]) {
|
|
419
493
|
test(`deserialized equals original ${partial ? 'with partial' : ''}`, () => {
|
|
420
|
-
|
|
494
|
+
const Organization = Schema.Struct({
|
|
421
495
|
field: Schema.String,
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
496
|
+
}).pipe(
|
|
497
|
+
Type.Obj({
|
|
498
|
+
typename: 'example.com/type/Organization',
|
|
499
|
+
version: '0.1.0',
|
|
500
|
+
}),
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
const fields = {
|
|
504
|
+
string: Schema.String,
|
|
505
|
+
number: Schema.Number.pipe(PropertyMeta(EXAMPLE_NAMESPACE, { is_date: true })),
|
|
506
|
+
boolean: Schema.Boolean,
|
|
507
|
+
array: Schema.Array(Schema.String),
|
|
508
|
+
twoDArray: Schema.Array(Schema.Array(Schema.String)),
|
|
509
|
+
record: Schema.Record({ key: Schema.String, value: Schema.Number }),
|
|
510
|
+
object: Schema.Struct({ id: Schema.String, field: Ref(Organization) }),
|
|
511
|
+
echoObject: Ref(Organization),
|
|
512
|
+
echoObjectArray: Schema.Array(Ref(Organization)),
|
|
513
|
+
email: Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email)),
|
|
514
|
+
null: Schema.Null,
|
|
515
|
+
} as const;
|
|
516
|
+
|
|
517
|
+
const Test = (partial ? Schema.partial(Schema.Struct(fields)) : Schema.Struct(fields)).pipe(
|
|
518
|
+
Type.Obj({
|
|
519
|
+
typename: 'example.com/type/Test',
|
|
520
|
+
version: '0.1.0',
|
|
521
|
+
}),
|
|
522
|
+
);
|
|
440
523
|
|
|
441
524
|
const jsonSchema = toJsonSchema(Test);
|
|
442
525
|
// log.info('schema', { jsonSchema });
|
|
@@ -499,8 +582,8 @@ describe('json-to-effect', () => {
|
|
|
499
582
|
});
|
|
500
583
|
|
|
501
584
|
test('symbol annotations get compared', () => {
|
|
502
|
-
const schema1 = Schema.String.pipe(FormatAnnotation.set(
|
|
503
|
-
const schema2 = Schema.String.pipe(FormatAnnotation.set(
|
|
585
|
+
const schema1 = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Email));
|
|
586
|
+
const schema2 = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Currency));
|
|
504
587
|
expect(prepareAstForCompare(schema1.ast)).not.to.deep.eq(prepareAstForCompare(schema2.ast));
|
|
505
588
|
});
|
|
506
589
|
|
|
@@ -515,7 +598,7 @@ describe('json-to-effect', () => {
|
|
|
515
598
|
});
|
|
516
599
|
|
|
517
600
|
test('relation schema roundtrip', () => {
|
|
518
|
-
const schema =
|
|
601
|
+
const schema = TestSchema.HasManager;
|
|
519
602
|
const jsonSchema = toJsonSchema(schema);
|
|
520
603
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
521
604
|
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(schema.ast));
|
|
@@ -618,10 +701,8 @@ describe('json-to-effect', () => {
|
|
|
618
701
|
});
|
|
619
702
|
|
|
620
703
|
test('schema with optional referece', () => {
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
});
|
|
624
|
-
const jsonSchema = toJsonSchema(TestSchema);
|
|
704
|
+
const TempSchema = Schema.Struct({ contact: Schema.optional(Ref(TestSchema.Person)) });
|
|
705
|
+
const jsonSchema = toJsonSchema(TempSchema);
|
|
625
706
|
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
626
707
|
{
|
|
627
708
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
@@ -632,7 +713,7 @@ describe('json-to-effect', () => {
|
|
|
632
713
|
"$ref": "/schemas/echo/ref",
|
|
633
714
|
"reference": {
|
|
634
715
|
"schema": {
|
|
635
|
-
"$ref": "dxn:type:example.com/type/
|
|
716
|
+
"$ref": "dxn:type:example.com/type/Person",
|
|
636
717
|
},
|
|
637
718
|
"schemaVersion": "0.1.0",
|
|
638
719
|
},
|
|
@@ -647,13 +728,65 @@ describe('json-to-effect', () => {
|
|
|
647
728
|
`);
|
|
648
729
|
|
|
649
730
|
const effectSchema = toEffectSchema(jsonSchema);
|
|
650
|
-
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(
|
|
731
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(TempSchema.ast));
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
test('object nested inside another struct', () => {
|
|
735
|
+
const Contact = Schema.Struct({
|
|
736
|
+
name: Schema.String,
|
|
737
|
+
}).pipe(EchoObjectSchema({ typename: 'example.com/type/Person', version: '0.1.0' }));
|
|
738
|
+
const input = Schema.Struct({
|
|
739
|
+
contact: Contact,
|
|
740
|
+
});
|
|
741
|
+
const jsonSchema = toJsonSchema(input);
|
|
742
|
+
expect(jsonSchema).toMatchInlineSnapshot(`
|
|
743
|
+
{
|
|
744
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
745
|
+
"additionalProperties": false,
|
|
746
|
+
"properties": {
|
|
747
|
+
"contact": {
|
|
748
|
+
"$id": "dxn:type:example.com/type/Person",
|
|
749
|
+
"additionalProperties": false,
|
|
750
|
+
"entityKind": "object",
|
|
751
|
+
"properties": {
|
|
752
|
+
"id": {
|
|
753
|
+
"type": "string",
|
|
754
|
+
},
|
|
755
|
+
"name": {
|
|
756
|
+
"type": "string",
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
"propertyOrder": [
|
|
760
|
+
"name",
|
|
761
|
+
"id",
|
|
762
|
+
],
|
|
763
|
+
"required": [
|
|
764
|
+
"name",
|
|
765
|
+
"id",
|
|
766
|
+
],
|
|
767
|
+
"type": "object",
|
|
768
|
+
"typename": "example.com/type/Person",
|
|
769
|
+
"version": "0.1.0",
|
|
770
|
+
},
|
|
771
|
+
},
|
|
772
|
+
"propertyOrder": [
|
|
773
|
+
"contact",
|
|
774
|
+
],
|
|
775
|
+
"required": [
|
|
776
|
+
"contact",
|
|
777
|
+
],
|
|
778
|
+
"type": "object",
|
|
779
|
+
}
|
|
780
|
+
`);
|
|
781
|
+
|
|
782
|
+
const effectSchema = toEffectSchema(jsonSchema);
|
|
783
|
+
expect(prepareAstForCompare(effectSchema.ast)).to.deep.eq(prepareAstForCompare(input.ast));
|
|
651
784
|
});
|
|
652
785
|
});
|
|
653
786
|
|
|
654
787
|
describe('reference', () => {
|
|
655
788
|
test('reference annotation', () => {
|
|
656
|
-
const schema = Ref(
|
|
789
|
+
const schema = Ref(TestSchema.Person);
|
|
657
790
|
const jsonSchema = toJsonSchema(schema);
|
|
658
791
|
expect(jsonSchema).toEqual({
|
|
659
792
|
$id: '/schemas/echo/ref',
|
|
@@ -661,7 +794,7 @@ describe('reference', () => {
|
|
|
661
794
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
662
795
|
reference: {
|
|
663
796
|
schema: {
|
|
664
|
-
$ref: 'dxn:type:example.com/type/
|
|
797
|
+
$ref: 'dxn:type:example.com/type/Person',
|
|
665
798
|
},
|
|
666
799
|
schemaVersion: '0.1.0',
|
|
667
800
|
},
|
|
@@ -669,7 +802,7 @@ describe('reference', () => {
|
|
|
669
802
|
});
|
|
670
803
|
|
|
671
804
|
test('title annotation', () => {
|
|
672
|
-
const schema = Ref(
|
|
805
|
+
const schema = Ref(TestSchema.Person).annotations({ title: 'My custom title' });
|
|
673
806
|
const jsonSchema = toJsonSchema(schema);
|
|
674
807
|
expect(jsonSchema).toEqual({
|
|
675
808
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -679,7 +812,7 @@ describe('reference', () => {
|
|
|
679
812
|
$ref: '/schemas/echo/ref',
|
|
680
813
|
reference: {
|
|
681
814
|
schema: {
|
|
682
|
-
$ref: 'dxn:type:example.com/type/
|
|
815
|
+
$ref: 'dxn:type:example.com/type/Person',
|
|
683
816
|
},
|
|
684
817
|
schemaVersion: '0.1.0',
|
|
685
818
|
},
|
|
@@ -690,7 +823,7 @@ describe('reference', () => {
|
|
|
690
823
|
});
|
|
691
824
|
|
|
692
825
|
test('description annotation', () => {
|
|
693
|
-
const schema = Ref(
|
|
826
|
+
const schema = Ref(TestSchema.Person).annotations({ description: 'My custom description' });
|
|
694
827
|
const jsonSchema = toJsonSchema(schema);
|
|
695
828
|
expect(jsonSchema).toEqual({
|
|
696
829
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -700,7 +833,7 @@ describe('reference', () => {
|
|
|
700
833
|
$ref: '/schemas/echo/ref',
|
|
701
834
|
reference: {
|
|
702
835
|
schema: {
|
|
703
|
-
$ref: 'dxn:type:example.com/type/
|
|
836
|
+
$ref: 'dxn:type:example.com/type/Person',
|
|
704
837
|
},
|
|
705
838
|
schemaVersion: '0.1.0',
|
|
706
839
|
},
|
|
@@ -714,13 +847,13 @@ describe('reference', () => {
|
|
|
714
847
|
});
|
|
715
848
|
|
|
716
849
|
test('serialize and deserialize', () => {
|
|
717
|
-
const schema = Ref(
|
|
850
|
+
const schema = Ref(TestSchema.Person);
|
|
718
851
|
const jsonSchema = toJsonSchema(schema);
|
|
719
852
|
const deserializedSchema = toEffectSchema(jsonSchema);
|
|
720
853
|
const refAst = getReferenceAst(deserializedSchema.ast);
|
|
721
854
|
expect(refAst).toEqual({
|
|
722
|
-
typename:
|
|
723
|
-
version:
|
|
855
|
+
typename: TestSchema.Person.typename,
|
|
856
|
+
version: TestSchema.Person.version,
|
|
724
857
|
});
|
|
725
858
|
});
|
|
726
859
|
});
|