@tsed/schema 7.0.0-beta.1 → 7.0.0-beta.4
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/jest.config.js +4 -4
- package/lib/cjs/components/schemaMapper.js +1 -3
- package/lib/cjs/components/schemaMapper.js.map +1 -1
- package/lib/cjs/constants/httpStatusMessages.js +12 -96
- package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
- package/lib/cjs/decorators/common/description.js.map +1 -1
- package/lib/cjs/decorators/common/enum.js +1 -20
- package/lib/cjs/decorators/common/enum.js.map +1 -1
- package/lib/cjs/decorators/common/ignore.js.map +1 -1
- package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
- package/lib/cjs/decorators/common/recordOf.js +63 -0
- package/lib/cjs/decorators/common/recordOf.js.map +1 -0
- package/lib/cjs/decorators/operations/acceptMime.js +28 -0
- package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
- package/lib/cjs/decorators/operations/in.js +6 -4
- package/lib/cjs/decorators/operations/in.js.map +1 -1
- package/lib/cjs/decorators/operations/view.js +31 -0
- package/lib/cjs/decorators/operations/view.js.map +1 -0
- package/lib/cjs/domain/DecoratorContext.js.map +1 -1
- package/lib/cjs/domain/JsonClassStore.js +1 -1
- package/lib/cjs/domain/JsonMap.js.map +1 -1
- package/lib/cjs/domain/JsonMethodStore.js +66 -24
- package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
- package/lib/cjs/domain/JsonOperation.js +11 -26
- package/lib/cjs/domain/JsonOperation.js.map +1 -1
- package/lib/cjs/domain/JsonOperationRoute.js +4 -0
- package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
- package/lib/cjs/domain/JsonParameter.js +36 -74
- package/lib/cjs/domain/JsonParameter.js.map +1 -1
- package/lib/cjs/domain/JsonParameterStore.js +14 -5
- package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
- package/lib/cjs/domain/JsonPropertyStore.js +6 -2
- package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
- package/lib/cjs/domain/JsonResponse.js +1 -11
- package/lib/cjs/domain/JsonResponse.js.map +1 -1
- package/lib/cjs/domain/JsonSchema.js +47 -54
- package/lib/cjs/domain/JsonSchema.js.map +1 -1
- package/lib/cjs/domain/SpecTypes.js +0 -3
- package/lib/cjs/domain/SpecTypes.js.map +1 -1
- package/lib/cjs/index.js +149 -20
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/from.js +9 -8
- package/lib/cjs/utils/from.js.map +1 -1
- package/lib/cjs/utils/generateSpec.js +55 -0
- package/lib/cjs/utils/generateSpec.js.map +1 -0
- package/lib/cjs/utils/generics.js.map +1 -1
- package/lib/cjs/utils/getJsonSchema.js +11 -1
- package/lib/cjs/utils/getJsonSchema.js.map +1 -1
- package/lib/cjs/utils/getJsonType.js +1 -1
- package/lib/cjs/utils/getJsonType.js.map +1 -1
- package/lib/cjs/utils/getOperationsRoutes.js +2 -1
- package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
- package/lib/cjs/utils/getSpec.js +58 -43
- package/lib/cjs/utils/getSpec.js.map +1 -1
- package/lib/cjs/utils/getSpecType.js +21 -0
- package/lib/cjs/utils/getSpecType.js.map +1 -0
- package/lib/cjs/utils/mapNullableType.js +1 -6
- package/lib/cjs/utils/mapNullableType.js.map +1 -1
- package/lib/cjs/utils/mapOpenSpec.js +41 -0
- package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec2.js +34 -0
- package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec3.js +26 -0
- package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/cjs/utils/matchGroups.js +1 -1
- package/lib/cjs/utils/matchGroups.js.map +1 -1
- package/lib/cjs/utils/mergeOperation.js +1 -0
- package/lib/cjs/utils/mergeOperation.js.map +1 -1
- package/lib/cjs/utils/ref.js +0 -8
- package/lib/cjs/utils/ref.js.map +1 -1
- package/lib/cjs/utils/serializeEnumValues.js +26 -0
- package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
- package/lib/esm/components/anyMapper.js +4 -4
- package/lib/esm/components/classMapper.js +4 -4
- package/lib/esm/components/genericsMapper.js +4 -4
- package/lib/esm/components/inheritedClassMapper.js +2 -2
- package/lib/esm/components/itemMapper.js +1 -1
- package/lib/esm/components/lazyRefMapper.js +3 -3
- package/lib/esm/components/mapMapper.js +2 -2
- package/lib/esm/components/objectMapper.js +3 -3
- package/lib/esm/components/ofMapper.js +1 -1
- package/lib/esm/components/propertiesMapper.js +1 -1
- package/lib/esm/components/schemaMapper.js +7 -9
- package/lib/esm/components/schemaMapper.js.map +1 -1
- package/lib/esm/constants/httpStatusMessages.js +11 -96
- package/lib/esm/constants/httpStatusMessages.js.map +1 -1
- package/lib/esm/decorators/class/children.js +1 -1
- package/lib/esm/decorators/collections/collectionContains.js +1 -1
- package/lib/esm/decorators/collections/collectionOf.js +1 -1
- package/lib/esm/decorators/collections/maxItems.js +1 -1
- package/lib/esm/decorators/collections/maxProperties.js +1 -1
- package/lib/esm/decorators/collections/minItems.js +1 -1
- package/lib/esm/decorators/collections/minProperties.js +1 -1
- package/lib/esm/decorators/collections/uniqueItems.js +1 -1
- package/lib/esm/decorators/common/additionalProperties.js +1 -1
- package/lib/esm/decorators/common/allOf.js +1 -1
- package/lib/esm/decorators/common/allow.js +2 -2
- package/lib/esm/decorators/common/any.js +1 -1
- package/lib/esm/decorators/common/anyOf.js +1 -1
- package/lib/esm/decorators/common/const.js +1 -1
- package/lib/esm/decorators/common/customKey.js +1 -1
- package/lib/esm/decorators/common/default.js +1 -1
- package/lib/esm/decorators/common/description.js +1 -1
- package/lib/esm/decorators/common/description.js.map +1 -1
- package/lib/esm/decorators/common/enum.js +2 -21
- package/lib/esm/decorators/common/enum.js.map +1 -1
- package/lib/esm/decorators/common/example.js +1 -1
- package/lib/esm/decorators/common/examples.js +1 -1
- package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
- package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
- package/lib/esm/decorators/common/format.js +2 -2
- package/lib/esm/decorators/common/forwardGroups.js +1 -1
- package/lib/esm/decorators/common/groups.js +2 -2
- package/lib/esm/decorators/common/ignore.js +1 -1
- package/lib/esm/decorators/common/ignore.js.map +1 -1
- package/lib/esm/decorators/common/integer.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
- package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
- package/lib/esm/decorators/common/maxLength.js +1 -1
- package/lib/esm/decorators/common/maximum.js +1 -1
- package/lib/esm/decorators/common/minLength.js +1 -1
- package/lib/esm/decorators/common/minimum.js +1 -1
- package/lib/esm/decorators/common/multipleOf.js +1 -1
- package/lib/esm/decorators/common/name.js +1 -1
- package/lib/esm/decorators/common/nullable.js +2 -2
- package/lib/esm/decorators/common/oneOf.js +1 -1
- package/lib/esm/decorators/common/optional.js +1 -1
- package/lib/esm/decorators/common/pattern.js +1 -1
- package/lib/esm/decorators/common/property.js +1 -1
- package/lib/esm/decorators/common/readOnly.js +1 -1
- package/lib/esm/decorators/common/recordOf.js +59 -0
- package/lib/esm/decorators/common/recordOf.js.map +1 -0
- package/lib/esm/decorators/common/required.js +2 -2
- package/lib/esm/decorators/common/requiredGroups.js +2 -2
- package/lib/esm/decorators/common/schema.js +1 -1
- package/lib/esm/decorators/common/title.js +1 -1
- package/lib/esm/decorators/common/writeOnly.js +1 -1
- package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
- package/lib/esm/decorators/generics/genericOf.js +2 -2
- package/lib/esm/decorators/generics/generics.js +1 -1
- package/lib/esm/decorators/operations/acceptMime.js +24 -0
- package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
- package/lib/esm/decorators/operations/consumes.js +1 -1
- package/lib/esm/decorators/operations/contentType.js +1 -1
- package/lib/esm/decorators/operations/deprecated.js +1 -1
- package/lib/esm/decorators/operations/header.js +1 -1
- package/lib/esm/decorators/operations/in.js +3 -1
- package/lib/esm/decorators/operations/in.js.map +1 -1
- package/lib/esm/decorators/operations/inFile.js +5 -5
- package/lib/esm/decorators/operations/location.js +1 -1
- package/lib/esm/decorators/operations/operationId.js +1 -1
- package/lib/esm/decorators/operations/operationPath.js +1 -1
- package/lib/esm/decorators/operations/partial.js +1 -1
- package/lib/esm/decorators/operations/path.js +1 -1
- package/lib/esm/decorators/operations/produces.js +1 -1
- package/lib/esm/decorators/operations/redirect.js +2 -2
- package/lib/esm/decorators/operations/returns.js +8 -8
- package/lib/esm/decorators/operations/route.js +3 -3
- package/lib/esm/decorators/operations/security.js +1 -1
- package/lib/esm/decorators/operations/status.js +1 -1
- package/lib/esm/decorators/operations/summary.js +1 -1
- package/lib/esm/decorators/operations/tags.js +1 -1
- package/lib/esm/decorators/operations/view.js +27 -0
- package/lib/esm/decorators/operations/view.js.map +1 -0
- package/lib/esm/domain/DecoratorContext.js +1 -1
- package/lib/esm/domain/DecoratorContext.js.map +1 -1
- package/lib/esm/domain/JsonClassStore.js +3 -3
- package/lib/esm/domain/JsonLazyRef.js +2 -2
- package/lib/esm/domain/JsonMap.js +1 -1
- package/lib/esm/domain/JsonMap.js.map +1 -1
- package/lib/esm/domain/JsonMethodStore.js +68 -26
- package/lib/esm/domain/JsonMethodStore.js.map +1 -1
- package/lib/esm/domain/JsonOperation.js +10 -25
- package/lib/esm/domain/JsonOperation.js.map +1 -1
- package/lib/esm/domain/JsonOperationPathsMap.js +1 -1
- package/lib/esm/domain/JsonOperationRoute.js +5 -1
- package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
- package/lib/esm/domain/JsonParameter.js +40 -78
- package/lib/esm/domain/JsonParameter.js.map +1 -1
- package/lib/esm/domain/JsonParameterStore.js +17 -8
- package/lib/esm/domain/JsonParameterStore.js.map +1 -1
- package/lib/esm/domain/JsonPropertyStore.js +7 -3
- package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
- package/lib/esm/domain/JsonRequestBody.js +2 -2
- package/lib/esm/domain/JsonResponse.js +4 -14
- package/lib/esm/domain/JsonResponse.js.map +1 -1
- package/lib/esm/domain/JsonSchema.js +9 -16
- package/lib/esm/domain/JsonSchema.js.map +1 -1
- package/lib/esm/domain/SpecTypes.js +0 -3
- package/lib/esm/domain/SpecTypes.js.map +1 -1
- package/lib/esm/index.js +149 -20
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/from.js +5 -4
- package/lib/esm/utils/from.js.map +1 -1
- package/lib/esm/utils/generateSpec.js +50 -0
- package/lib/esm/utils/generateSpec.js.map +1 -0
- package/lib/esm/utils/generics.js.map +1 -1
- package/lib/esm/utils/getInheritedStores.js +1 -1
- package/lib/esm/utils/getJsonEntityStore.js +5 -5
- package/lib/esm/utils/getJsonSchema.js +14 -4
- package/lib/esm/utils/getJsonSchema.js.map +1 -1
- package/lib/esm/utils/getJsonType.js +2 -2
- package/lib/esm/utils/getJsonType.js.map +1 -1
- package/lib/esm/utils/getOperationsRoutes.js +5 -4
- package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
- package/lib/esm/utils/getOperationsStores.js +4 -4
- package/lib/esm/utils/getPropertiesStores.js +3 -3
- package/lib/esm/utils/getRequiredProperties.js +1 -1
- package/lib/esm/utils/getSpec.js +65 -50
- package/lib/esm/utils/getSpec.js.map +1 -1
- package/lib/esm/utils/getSpecType.js +16 -0
- package/lib/esm/utils/getSpecType.js.map +1 -0
- package/lib/esm/utils/mapNullableType.js +2 -7
- package/lib/esm/utils/mapNullableType.js.map +1 -1
- package/lib/esm/utils/mapOpenSpec.js +37 -0
- package/lib/esm/utils/mapOpenSpec.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec2.js +30 -0
- package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec3.js +22 -0
- package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
- package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
- package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/esm/utils/mapRouteOptions.js +1 -1
- package/lib/esm/utils/mergeOperation.js +4 -3
- package/lib/esm/utils/mergeOperation.js.map +1 -1
- package/lib/esm/utils/ref.js +1 -9
- package/lib/esm/utils/ref.js.map +1 -1
- package/lib/esm/utils/serializeEnumValues.js +21 -0
- package/lib/esm/utils/serializeEnumValues.js.map +1 -0
- package/lib/esm/utils/toJsonMapCollection.js +1 -1
- package/lib/types/constants/httpStatusMessages.d.ts +2 -263
- package/lib/types/decorators/common/ignore.d.ts +1 -1
- package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
- package/lib/types/decorators/common/recordOf.d.ts +46 -0
- package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
- package/lib/types/decorators/operations/in.d.ts +1 -1
- package/lib/types/decorators/operations/view.d.ts +23 -0
- package/lib/types/domain/JsonMap.d.ts +1 -1
- package/lib/types/domain/JsonMethodStore.d.ts +51 -2
- package/lib/types/domain/JsonOperation.d.ts +2 -1
- package/lib/types/domain/JsonOperationRoute.d.ts +5 -3
- package/lib/types/domain/JsonParameter.d.ts +2 -1
- package/lib/types/domain/JsonParameterStore.d.ts +23 -1
- package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
- package/lib/types/domain/JsonResponse.d.ts +2 -1
- package/lib/types/domain/JsonSchema.d.ts +2 -2
- package/lib/types/domain/SpecTypes.d.ts +0 -3
- package/lib/types/index.d.ts +142 -13
- package/lib/types/utils/generateSpec.d.ts +16 -0
- package/lib/types/utils/generics.d.ts +1 -1
- package/lib/types/utils/getJsonSchema.d.ts +12 -2
- package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
- package/lib/types/utils/getSpec.d.ts +6 -25
- package/lib/types/utils/getSpecType.d.ts +12 -0
- package/lib/types/utils/mapNullableType.d.ts +1 -1
- package/lib/types/utils/mapOpenSpec.d.ts +10 -0
- package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
- package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
- package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
- package/lib/types/utils/serializeEnumValues.d.ts +5 -0
- package/package.json +30 -15
- package/readme.md +1 -0
- package/tsconfig.compile.esm.json +2 -12
- package/benchmark/cold-start.js +0 -17
- package/lib/cjs/components/index.js +0 -15
- package/lib/cjs/components/index.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -77
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/domain/index.js +0 -20
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -8
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/esm/components/index.js +0 -12
- package/lib/esm/components/index.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -74
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/domain/index.js +0 -17
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -5
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/types/components/index.d.ts +0 -11
- package/lib/types/decorators/index.d.ts +0 -68
- package/lib/types/domain/index.d.ts +0 -16
- package/lib/types/interfaces/index.d.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.ts"],"names":[],"mappings":";;;;AAAA,qCAA+H;AAC/H,uDAA0E;AAE1E,mDAA8C;AAC9C,6CAAwC;AACxC,kFAA6E;AAa7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,iCAAe;IAcrD,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,C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AAW,CAAC,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC;YAElG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAElC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAM,EAAE,IAAI,CAAC,CAAC;YAE5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;YAEhE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEpC,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;aACpD;YAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,KAAe,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;SAC1E;IACH,CAAC;CACF,CAAA;AAhHY,kBAAkB;IAD9B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,KAAK,CAAC;;GAC7B,kBAAkB,CAgH9B;AAhHY,gDAAkB;AAsHlB,QAAA,aAAa,GAAG,kBAAkB,CAAC","sourcesContent":["import {ancestorsOf, DecoratorTypes, isClass, isCollection, isMethodDescriptor, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonParameterStoreOptions extends JsonEntityStoreOptions {\n dataPath?: string;\n paramType?: string;\n expression?: string;\n}\n\nexport interface PipeMethods<T = any, R = any> {\n transform(value: T, metadata: JsonParameterStore): R;\n}\n\n@JsonEntityComponent(DecoratorTypes.PARAM)\nexport class JsonParameterStore extends JsonEntityStore {\n public paramType: string;\n public expression: string;\n public dataPath: string;\n /**\n * Define pipes can be called by the framework to transform input parameter\n */\n public pipes: Type<PipeMethods>[];\n /**\n * Ref to JsonParameter when the decorated object is a parameter.\n */\n readonly parameter: JsonParameter = new JsonParameter();\n readonly parent: JsonMethodStore = JsonEntityStore.fromMethod(this.target, this.propertyKey);\n\n constructor(options: JsonParameterStoreOptions) {\n super(options);\n this.pipes = options.pipes || [];\n this.paramType = options.paramType || this.paramType;\n this.expression = options.expression || this.expression;\n this.dataPath = options.dataPath || this.dataPath;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.parameter.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.parameter.nestedGenerics = nestedGenerics;\n }\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return !!this.parameter.get(\"required\");\n }\n\n set required(value: boolean) {\n this.parameter.required(value);\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[] {\n const params: T[] = [];\n\n const klass = ancestorsOf(target)\n .reverse()\n .find((target) => {\n return isMethodDescriptor(target, propertyKey) && JsonEntityStore.fromMethod(target, propertyKey).children.size;\n });\n\n if (klass) {\n JsonEntityStore.fromMethod(klass, propertyKey).children.forEach((param: T, index) => {\n params[+index] = param;\n });\n\n return params;\n }\n\n return [];\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, index: number) {\n return JsonEntityStore.from<JsonParameterStore>(prototypeOf(target), propertyKey, index);\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected getSchema(type: any) {\n if (isCollection(type) || !isClass(type)) {\n return JsonSchema.from({\n type\n });\n }\n\n return JsonEntityStore.from(type).schema;\n }\n\n protected build() {\n if (!this._type) {\n const type: any = Metadata.getParamTypes(prototypeOf(this.target), this.propertyKey)[this.index!];\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n if (!this._schema) {\n this.parent.children.set(this.index!, this);\n\n this._schema = this.getSchema(this.collectionType || this.type);\n\n this.parameter.schema(this._schema);\n\n if (this.collectionType) {\n this._schema.itemSchema(this.getSchema(this.type));\n }\n\n this.parent.operation.addParameter(this.index as number, this.parameter);\n }\n }\n}\n\n/**\n * @alias JsonParameterStore\n */\nexport type ParamMetadata = JsonParameterStore;\nexport const ParamMetadata = JsonParameterStore;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonPropertyStore = void 0;
|
|
3
|
+
exports.PropertyMetadata = exports.JsonPropertyStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@tsed/core");
|
|
6
6
|
const JsonEntityStore_1 = require("./JsonEntityStore");
|
|
@@ -60,9 +60,13 @@ let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore_1.JsonEn
|
|
|
60
60
|
this.parent.schema.addProperty(this.propertyName, schema);
|
|
61
61
|
this._schema = schema;
|
|
62
62
|
}
|
|
63
|
+
static get(target, propertyKey) {
|
|
64
|
+
return JsonEntityStore_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey);
|
|
65
|
+
}
|
|
63
66
|
};
|
|
64
|
-
JsonPropertyStore =
|
|
67
|
+
JsonPropertyStore = tslib_1.__decorate([
|
|
65
68
|
(0, jsonEntityComponent_1.JsonEntityComponent)(core_1.DecoratorTypes.PROP)
|
|
66
69
|
], JsonPropertyStore);
|
|
67
70
|
exports.JsonPropertyStore = JsonPropertyStore;
|
|
71
|
+
exports.PropertyMetadata = JsonPropertyStore;
|
|
68
72
|
//# sourceMappingURL=JsonPropertyStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"JsonPropertyStore.js","sourceRoot":"","sources":["../../../src/domain/JsonPropertyStore.ts"],"names":[],"mappings":";;;;AAAA,qCAAuE;AACvE,uDAAkD;AAClD,6CAAwC;AACxC,kFAA6E;AAI7E,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,iCAAe;IAAtD;;QACW,WAAM,GAAmB,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAkEtE,CAAC;IAhEC;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;IACnE,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC5D;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAqB,CAAC,CAAC;SAC/D;IACH,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,KAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBA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iB,CAmE7B;AAnEY,8CAAiB;AAyEjB,QAAA,gBAAgB,GAAG,iBAAiB,CAAC","sourcesContent":["import {DecoratorTypes, Metadata, prototypeOf, Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\n\n@JsonEntityComponent(DecoratorTypes.PROP)\nexport class JsonPropertyStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n\n /**\n * Return the required state.\n * @returns {boolean}\n */\n get required(): boolean {\n return this.parent.schema.isRequired(this.propertyKey as string);\n }\n\n /**\n * Change the state of the required data.\n * @param value\n */\n set required(value: boolean) {\n if (value) {\n this.parent.schema.addRequired(this.propertyKey as string);\n } else {\n this.parent.schema.removeRequired(this.propertyKey as string);\n }\n }\n\n get allowedRequiredValues() {\n return this.schema.$allow;\n }\n\n /**\n * Check precondition between value, required and allowedRequiredValues to know if the entity is required.\n * @param value\n * @returns {boolean}\n */\n isRequired(value: any): boolean {\n return this.required && [undefined, null, \"\"].includes(value) && !this.allowedRequiredValues.includes(value);\n }\n\n protected build() {\n if (!this._type) {\n this.buildType(Metadata.getType(prototypeOf(this.target), this.propertyKey));\n }\n\n this._type = this._type || Object;\n\n const properties = this.parent.schema.get(\"properties\");\n\n let schema: JsonSchema = properties[this.propertyName];\n\n if (!schema) {\n this.parent.children.set(this.propertyName, this);\n\n schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n schema.itemSchema(this.type);\n }\n }\n\n this.parent.schema.addProperty(this.propertyName, schema);\n\n this._schema = schema;\n }\n\n static get(target: Type<any>, propertyKey: string | symbol) {\n return JsonEntityStore.from<JsonPropertyStore>(prototypeOf(target), propertyKey);\n }\n}\n\n/**\n * @alias JsonPropertyStore\n */\nexport type PropertyMetadata = JsonPropertyStore;\nexport const PropertyMetadata = JsonPropertyStore;\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonResponse = exports.JsonMedia = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
4
|
const mapHeaders_1 = require("../utils/mapHeaders");
|
|
6
5
|
const toJsonMapCollection_1 = require("../utils/toJsonMapCollection");
|
|
7
6
|
const JsonMap_1 = require("./JsonMap");
|
|
8
|
-
const SpecTypes_1 = require("./SpecTypes");
|
|
9
7
|
class JsonMedia extends JsonMap_1.JsonMap {
|
|
10
8
|
constructor() {
|
|
11
9
|
super(...arguments);
|
|
@@ -61,7 +59,7 @@ class JsonResponse extends JsonMap_1.JsonMap {
|
|
|
61
59
|
if (this.status === 204) {
|
|
62
60
|
delete response.content;
|
|
63
61
|
}
|
|
64
|
-
if (
|
|
62
|
+
if (response.headers) {
|
|
65
63
|
Object.entries(response.headers).forEach(([key, { type, ...props }]) => {
|
|
66
64
|
response.headers[key] = {
|
|
67
65
|
...props,
|
|
@@ -71,14 +69,6 @@ class JsonResponse extends JsonMap_1.JsonMap {
|
|
|
71
69
|
};
|
|
72
70
|
});
|
|
73
71
|
}
|
|
74
|
-
if (options.specType !== SpecTypes_1.SpecTypes.OPENAPI && response.content) {
|
|
75
|
-
const key = Object.keys(response.content)[0];
|
|
76
|
-
return (0, core_1.cleanObject)({
|
|
77
|
-
...response,
|
|
78
|
-
...response.content[key],
|
|
79
|
-
content: undefined
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
72
|
return response;
|
|
83
73
|
}
|
|
84
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;AAIA,o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,CAAC,SAAiB,EAAE,MAAM,GAAG,IAAI;;QACvC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEnC,OAAO,MAAA,IAAI,CAAC,UAAU,EAAE,0CAAE,GAAG,CAAC,SAAS,CAAQ,CAAC;IAClD,CAAC;IAED,QAAQ,CAAC,SAAiB;QACxB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;SACzC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE;YACvB,OAAO,QAAQ,CAAC,OAAO,CAAC;SACzB;QAED,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,CAAgB,EAAE,EAAE;gBAClF,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG;oBACtB,GAAG,KAAK;oBACR,MAAM,EAAE;wBACN,IAAI;qBACL;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAnED,oCAmEC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OS3MediaType, OS3Response} from \"@tsed/openspec\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {mapHeaders} from \"../utils/mapHeaders\";\nimport {toJsonMapCollection} from \"../utils/toJsonMapCollection\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {SpecTypes} from \"./SpecTypes\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n\n schema(schema: JsonSchema) {\n this.set(\"schema\", schema);\n\n return this;\n }\n\n examples(examples: any) {\n this.set(\"examples\", examples);\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n return super.toJSON({...options, groups: this.groups});\n }\n}\n\nexport class JsonResponse extends JsonMap<JsonResponseOptions> {\n status: number;\n\n constructor(obj: Partial<JsonResponseOptions> = {}) {\n super(obj);\n\n this.content(obj.content || ({} as any));\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n headers(headers: Record<string, string | JsonHeader>): this {\n this.set(\"headers\", mapHeaders(headers));\n\n return this;\n }\n\n content(content: Record<string, OS3MediaType<JsonSchema>>) {\n this.set(\"content\", toJsonMapCollection(content, JsonMedia));\n\n return this;\n }\n\n getContent(): JsonMap<JsonMedia> {\n return this.get(\"content\")!;\n }\n\n getMedia(mediaType: string, create = true): JsonMedia {\n create && this.addMedia(mediaType);\n\n return this.getContent()?.get(mediaType) as any;\n }\n\n addMedia(mediaType: string) {\n const content = this.get(\"content\");\n\n if (!content.has(mediaType)) {\n content.set(mediaType, new JsonMedia());\n }\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const response = super.toJSON(options);\n\n if (this.status === 204) {\n delete response.content;\n }\n\n if (response.headers) {\n Object.entries(response.headers).forEach(([key, {type, ...props}]: [string, any]) => {\n response.headers[key] = {\n ...props,\n schema: {\n type\n }\n };\n });\n }\n\n return response;\n }\n}\n"]}
|
|
@@ -9,6 +9,7 @@ const getComputedType_1 = require("../utils/getComputedType");
|
|
|
9
9
|
const getJsonType_1 = require("../utils/getJsonType");
|
|
10
10
|
const toJsonRegex_1 = require("../utils/toJsonRegex");
|
|
11
11
|
const JsonEntityStore_1 = require("./JsonEntityStore");
|
|
12
|
+
const serializeEnumValues_1 = require("../utils/serializeEnumValues");
|
|
12
13
|
function mapProperties(properties) {
|
|
13
14
|
// istanbul ignore next
|
|
14
15
|
if (properties instanceof JsonSchema) {
|
|
@@ -56,34 +57,34 @@ class JsonSchema extends Map {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
get alias() {
|
|
59
|
-
return
|
|
60
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f");
|
|
60
61
|
}
|
|
61
62
|
get nestedGenerics() {
|
|
62
|
-
return
|
|
63
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_nestedGenerics, "f");
|
|
63
64
|
}
|
|
64
65
|
set nestedGenerics(value) {
|
|
65
|
-
|
|
66
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_nestedGenerics, value, "f");
|
|
66
67
|
}
|
|
67
68
|
get genericLabels() {
|
|
68
|
-
return
|
|
69
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_genericLabels, "f");
|
|
69
70
|
}
|
|
70
71
|
set genericLabels(value) {
|
|
71
|
-
|
|
72
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_genericLabels, value, "f");
|
|
72
73
|
}
|
|
73
74
|
get isClass() {
|
|
74
|
-
return (0, core_1.isClass)(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(
|
|
75
|
+
return (0, core_1.isClass)(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f"));
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Current schema is a collection
|
|
78
79
|
*/
|
|
79
80
|
get isCollection() {
|
|
80
|
-
return
|
|
81
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_isCollection, "f");
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Current schema is a generic
|
|
84
85
|
*/
|
|
85
86
|
get isGeneric() {
|
|
86
|
-
return
|
|
87
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_isGeneric, "f");
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* Current schema has generics items
|
|
@@ -98,10 +99,10 @@ class JsonSchema extends Map {
|
|
|
98
99
|
return this.getComputedType();
|
|
99
100
|
}
|
|
100
101
|
get canRef() {
|
|
101
|
-
return
|
|
102
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_ref, "f");
|
|
102
103
|
}
|
|
103
104
|
get isNullable() {
|
|
104
|
-
return
|
|
105
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_nullable, "f") || this.$allow.includes(null);
|
|
105
106
|
}
|
|
106
107
|
get isReadOnly() {
|
|
107
108
|
return this.get("readOnly");
|
|
@@ -113,25 +114,25 @@ class JsonSchema extends Map {
|
|
|
113
114
|
return new JsonSchema(obj);
|
|
114
115
|
}
|
|
115
116
|
nullable(value) {
|
|
116
|
-
|
|
117
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_nullable, value, "f");
|
|
117
118
|
}
|
|
118
119
|
itemSchema(obj = {}) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
120
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_itemSchema, tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f") || mapToJsonSchema(obj), "f");
|
|
121
|
+
tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f").assign(obj);
|
|
122
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f");
|
|
122
123
|
}
|
|
123
124
|
getAliasOf(property) {
|
|
124
|
-
return
|
|
125
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").get(property);
|
|
125
126
|
}
|
|
126
127
|
addAlias(property, alias) {
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").set(property, alias);
|
|
129
|
+
tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").set(alias, property);
|
|
129
130
|
return this;
|
|
130
131
|
}
|
|
131
132
|
removeAlias(property) {
|
|
132
|
-
const alias =
|
|
133
|
-
alias &&
|
|
134
|
-
|
|
133
|
+
const alias = tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").get(property);
|
|
134
|
+
alias && tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").delete(alias);
|
|
135
|
+
tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").delete(property);
|
|
135
136
|
return this;
|
|
136
137
|
}
|
|
137
138
|
$id($id) {
|
|
@@ -151,7 +152,7 @@ class JsonSchema extends Map {
|
|
|
151
152
|
* @param name
|
|
152
153
|
*/
|
|
153
154
|
label(name) {
|
|
154
|
-
|
|
155
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_ref, true, "f");
|
|
155
156
|
super.set("name", name);
|
|
156
157
|
return this;
|
|
157
158
|
}
|
|
@@ -235,7 +236,7 @@ class JsonSchema extends Map {
|
|
|
235
236
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9
|
|
236
237
|
*/
|
|
237
238
|
items(items) {
|
|
238
|
-
super.set("items", (
|
|
239
|
+
super.set("items", (tslib_1.__classPrivateFieldSet(this, _JsonSchema_itemSchema, mapToJsonSchema(items), "f")));
|
|
239
240
|
return this;
|
|
240
241
|
}
|
|
241
242
|
/**
|
|
@@ -394,17 +395,9 @@ class JsonSchema extends Map {
|
|
|
394
395
|
super.set("propertyNames", mapToJsonSchema(propertyNames));
|
|
395
396
|
return this;
|
|
396
397
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* the array represents a possible value for the instance value. If
|
|
401
|
-
* this attribute is defined, the instance value MUST be one of the
|
|
402
|
-
* values in the array in order for the schema to be valid.
|
|
403
|
-
*
|
|
404
|
-
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23
|
|
405
|
-
*/
|
|
406
|
-
enum(enumValues) {
|
|
407
|
-
super.set("enum", (0, core_1.uniq)(enumValues));
|
|
398
|
+
enum(enumValue, ...enumValues) {
|
|
399
|
+
const { values, types } = (0, serializeEnumValues_1.serializeEnumValues)([enumValue, enumValues].flat());
|
|
400
|
+
super.set("enum", values).any(...types);
|
|
408
401
|
return this;
|
|
409
402
|
}
|
|
410
403
|
/**
|
|
@@ -529,24 +522,24 @@ class JsonSchema extends Map {
|
|
|
529
522
|
switch (type) {
|
|
530
523
|
case Map:
|
|
531
524
|
super.set("type", (0, getJsonType_1.getJsonType)(type));
|
|
532
|
-
|
|
533
|
-
|
|
525
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
|
|
526
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
|
|
534
527
|
if (!this.has("additionalProperties")) {
|
|
535
528
|
super.set("additionalProperties", this.itemSchema({}));
|
|
536
529
|
}
|
|
537
530
|
break;
|
|
538
531
|
case Array:
|
|
539
532
|
super.set("type", (0, getJsonType_1.getJsonType)(type));
|
|
540
|
-
|
|
541
|
-
|
|
533
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
|
|
534
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
|
|
542
535
|
if (!this.has("items")) {
|
|
543
536
|
super.set("items", this.itemSchema({}));
|
|
544
537
|
}
|
|
545
538
|
break;
|
|
546
539
|
case Set:
|
|
547
540
|
super.set("type", (0, getJsonType_1.getJsonType)(type));
|
|
548
|
-
|
|
549
|
-
|
|
541
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
|
|
542
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
|
|
550
543
|
this.uniqueItems(true);
|
|
551
544
|
if (!this.has("items")) {
|
|
552
545
|
super.set("items", this.itemSchema({}));
|
|
@@ -562,7 +555,7 @@ class JsonSchema extends Map {
|
|
|
562
555
|
case Number:
|
|
563
556
|
case String:
|
|
564
557
|
super.set("type", (0, getJsonType_1.getJsonType)(type));
|
|
565
|
-
|
|
558
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
|
|
566
559
|
if (!this.has("properties")) {
|
|
567
560
|
super.set("properties", {});
|
|
568
561
|
}
|
|
@@ -570,7 +563,7 @@ class JsonSchema extends Map {
|
|
|
570
563
|
default:
|
|
571
564
|
if ((0, core_1.isClass)(type) || (0, core_1.isFunction)(type)) {
|
|
572
565
|
super.set("type", undefined);
|
|
573
|
-
|
|
566
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
|
|
574
567
|
if (!this.has("properties")) {
|
|
575
568
|
super.set("properties", {});
|
|
576
569
|
}
|
|
@@ -578,7 +571,7 @@ class JsonSchema extends Map {
|
|
|
578
571
|
else {
|
|
579
572
|
const jsonType = (0, getJsonType_1.getJsonType)(type);
|
|
580
573
|
if (jsonType === "generic") {
|
|
581
|
-
|
|
574
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isGeneric, true, "f");
|
|
582
575
|
super.set("$ref", type);
|
|
583
576
|
}
|
|
584
577
|
else {
|
|
@@ -667,14 +660,14 @@ class JsonSchema extends Map {
|
|
|
667
660
|
obj.$required.forEach((key) => {
|
|
668
661
|
this.$required.add(key);
|
|
669
662
|
});
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
663
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_ref, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_ref, "f"), "f");
|
|
664
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_alias, new Map(tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").entries()), "f");
|
|
665
|
+
tslib_1.__classPrivateFieldGet(obj, _JsonSchema_genericLabels, "f") && (tslib_1.__classPrivateFieldSet(this, _JsonSchema_genericLabels, [...tslib_1.__classPrivateFieldGet(obj, _JsonSchema_genericLabels, "f")], "f"));
|
|
666
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_nestedGenerics, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_nestedGenerics, "f").map((item) => [...item]), "f");
|
|
667
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_target, "f"), "f");
|
|
668
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isGeneric, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_isGeneric, "f"), "f");
|
|
669
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_isCollection, "f"), "f");
|
|
670
|
+
tslib_1.__classPrivateFieldSet(this, _JsonSchema_ref, tslib_1.__classPrivateFieldGet(obj, _JsonSchema_ref, "f"), "f");
|
|
678
671
|
super.set("type", obj.get("type"));
|
|
679
672
|
}
|
|
680
673
|
return this;
|
|
@@ -694,10 +687,10 @@ class JsonSchema extends Map {
|
|
|
694
687
|
* the function will be called to get the right type.
|
|
695
688
|
*/
|
|
696
689
|
getComputedType() {
|
|
697
|
-
return (0, getComputedType_1.getComputedType)(
|
|
690
|
+
return (0, getComputedType_1.getComputedType)(tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f"));
|
|
698
691
|
}
|
|
699
692
|
getComputedItemType() {
|
|
700
|
-
return
|
|
693
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f") ? tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f").getComputedType() : this.getComputedType();
|
|
701
694
|
}
|
|
702
695
|
/**
|
|
703
696
|
* Return the Json type as string
|
|
@@ -706,13 +699,13 @@ class JsonSchema extends Map {
|
|
|
706
699
|
return this.get("type") || (0, getJsonType_1.getJsonType)(this.getComputedType());
|
|
707
700
|
}
|
|
708
701
|
getTarget() {
|
|
709
|
-
return
|
|
702
|
+
return tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f");
|
|
710
703
|
}
|
|
711
704
|
/**
|
|
712
705
|
* Get the symbolic name of the entity
|
|
713
706
|
*/
|
|
714
707
|
getName() {
|
|
715
|
-
return this.get("name") || (
|
|
708
|
+
return this.get("name") || (tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f") ? (0, core_1.nameOf)((0, core_1.classOf)(this.getComputedType())) : "");
|
|
716
709
|
}
|
|
717
710
|
clone() {
|
|
718
711
|
return new JsonSchema(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../../src/domain/JsonSchema.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+G;AAI/G,uFAAmE;AAEnE,8DAAyD;AACzD,sDAAiD;AACjD,sDAAiD;AAIjD,uDAAkD;AAWlD,SAAS,aAAa,CAAC,UAA+B;IACpD,uBAAuB;IACvB,IAAI,UAAU,YAAY,UAAU,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;QAC1E,UAAU,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAEvD,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,eAAe,CAAC,IAAS;IAChC,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAQ,IAAc,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC7C;IAED,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI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AAY,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IACxF,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAA,yBAAW,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,SAAS;QACP,OAAO,oCAAA,IAAI,0BAAQ,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,oCAAA,IAAI,0BAAQ,CAAC,CAAC,CAAC,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK;QACH,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AA70BD,gCA60BC","sourcesContent":["import {classOf, Hooks, isArray, isClass, isFunction, isObject, nameOf, Type, uniq, ValueOf} from \"@tsed/core\";\nimport type {JSONSchema6, JSONSchema6Definition, JSONSchema6Type, JSONSchema6TypeName, JSONSchema6Version} from \"json-schema\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {IgnoreCallback} from \"../interfaces/IgnoreCallback\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics} from \"../utils/generics\";\nimport {getComputedType} from \"../utils/getComputedType\";\nimport {getJsonType} from \"../utils/getJsonType\";\nimport {toJsonRegex} from \"../utils/toJsonRegex\";\nimport {AliasMap, AliasType} from \"./JsonAliasMap\";\nimport {JsonFormatTypes} from \"./JsonFormatTypes\";\nimport {JsonLazyRef} from \"./JsonLazyRef\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\n\nexport interface JsonSchemaObject extends JSONSchema6, Record<string, any> {\n type: (any | JSONSchema6TypeName) | (any | JSONSchema6TypeName)[];\n additionalProperties?: boolean | JSONSchema6 | any;\n propertyNames?: boolean | JSONSchema6 | any;\n items?: (any | JSONSchema6Definition) | (any | JSONSchema6Definition)[];\n}\n\nexport type AnyJsonSchema = Partial<JsonSchemaObject> | JsonSchema | JsonLazyRef | any;\n\nfunction mapProperties(properties: Record<string, any>) {\n // istanbul ignore next\n if (properties instanceof JsonSchema) {\n return properties;\n }\n\n return Object.entries(properties).reduce<any>((properties, [key, schema]) => {\n properties[toJsonRegex(key)] = mapToJsonSchema(schema);\n\n return properties;\n }, {});\n}\n\nfunction mapToJsonSchema(item: any): any {\n if (isArray(item)) {\n return (item as any[]).map(mapToJsonSchema);\n }\n\n if (item.isStore || item.isJsonSchema || item.isLazyRef) {\n return item;\n }\n\n if (classOf(item) !== Object && isClass(item)) {\n return JsonEntityStore.from(item).schema;\n }\n\n if (isObject(item)) {\n return JsonSchema.from(item as any);\n }\n\n return item;\n}\n\nexport class JsonSchema extends Map<string, any> implements NestedGenerics {\n readonly isJsonSchema = true;\n readonly $hooks = new Hooks();\n readonly $required: Set<string> = new Set();\n readonly $allow: any[] = [];\n public $selfRequired: boolean;\n public $forwardGroups: boolean = false;\n\n #nullable: boolean = false;\n #genericLabels: string[];\n #nestedGenerics: Type<any>[][] = [];\n #alias: AliasMap = new Map();\n #itemSchema: JsonSchema;\n #target: Type<any>;\n #isGeneric: boolean = false;\n #isCollection: boolean = false;\n #ref: boolean = false;\n\n constructor(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n super();\n\n if (obj) {\n this.assign(obj);\n }\n }\n\n get alias() {\n return this.#alias;\n }\n\n get nestedGenerics(): any[] {\n return this.#nestedGenerics;\n }\n\n set nestedGenerics(value: any[]) {\n this.#nestedGenerics = value;\n }\n\n get genericLabels(): string[] {\n return this.#genericLabels;\n }\n\n set genericLabels(value: string[]) {\n this.#genericLabels = value;\n }\n\n get isClass() {\n return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target as any);\n }\n\n /**\n * Current schema is a collection\n */\n get isCollection() {\n return this.#isCollection;\n }\n\n /**\n * Current schema is a generic\n */\n get isGeneric() {\n return this.#isGeneric;\n }\n\n /**\n * Current schema has generics items\n */\n get hasGenerics(): boolean {\n return !!(this.nestedGenerics && this.nestedGenerics.length);\n }\n\n get genericType(): string {\n return this.get(\"$ref\");\n }\n\n get class() {\n return this.getComputedType();\n }\n\n get canRef(): boolean {\n return this.#ref;\n }\n\n get isNullable(): boolean {\n return this.#nullable || this.$allow.includes(null);\n }\n\n get isReadOnly() {\n return this.get(\"readOnly\");\n }\n\n get isWriteOnly() {\n return this.get(\"writeOnly\");\n }\n\n static from(obj: Partial<JsonSchemaObject> = {}) {\n return new JsonSchema(obj);\n }\n\n nullable(value: boolean) {\n this.#nullable = value;\n }\n\n itemSchema(obj: AnyJsonSchema = {}) {\n this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);\n this.#itemSchema.assign(obj);\n\n return this.#itemSchema;\n }\n\n getAliasOf(property: AliasType) {\n return this.#alias.get(property as any);\n }\n\n addAlias(property: AliasType, alias: AliasType) {\n this.#alias.set(property, alias);\n this.#alias.set(alias, property);\n\n return this;\n }\n\n removeAlias(property: AliasType) {\n const alias = this.#alias.get(property);\n alias && this.#alias.delete(alias);\n this.#alias.delete(property);\n\n return this;\n }\n\n $id($id: string) {\n super.set(\"$id\", $id);\n\n return this;\n }\n\n $ref($ref: string) {\n super.set(\"$ref\", $ref);\n\n return this;\n }\n\n $schema($schema: JSONSchema6Version) {\n super.set(\"$schema\", $schema);\n\n return this;\n }\n\n /**\n * Create a ref and use name to sharing schema\n * @param name\n */\n label(name: string) {\n this.#ref = true;\n\n super.set(\"name\", name);\n\n return this;\n }\n\n name(name: string) {\n super.set(\"name\", name);\n\n return this;\n }\n\n ignore(cb: boolean | IgnoreCallback) {\n if (typeof cb === \"boolean\") {\n const bool = cb;\n cb = () => bool;\n }\n\n this.$hooks.on(\"ignore\", cb);\n\n return this;\n }\n\n /**\n * This keyword can be used to supply a default JSON value associated with a particular schema.\n * It is RECOMMENDED that a default value be valid against the associated schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3\n */\n default(value: JSONSchema6Type) {\n super.set(\"default\", value);\n\n return this;\n }\n\n /**\n * More readible form of a one-element \"enum\"\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24\n */\n const(value: JSONSchema6Type) {\n super.set(\"const\", value);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a full description of the of purpose the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n description(description: string) {\n super.set(\"description\", description);\n\n return this;\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * If \"items\" is an array of schemas, validation succeeds if every instance element\n * at a position greater than the size of \"items\" validates against \"additionalItems\".\n * Otherwise, \"additionalItems\" MUST be ignored, as the \"items\" schema\n * (possibly the default value of an empty schema) is applied to all elements.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10\n */\n additionalItems(additionalItems: boolean | AnyJsonSchema) {\n super.set(\"additionalItems\", mapToJsonSchema(additionalItems));\n\n return this;\n }\n\n /**\n * An array instance is valid against \"contains\" if at least one of its elements is valid against the given schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14\n */\n contains(contains: JSONSchema6Definition) {\n super.set(\"contains\", mapToJsonSchema(contains));\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n examples(examples: JSONSchema6Type[]) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n example(...examples: JSONSchema6Type[]) {\n return this.examples(examples);\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9\n */\n items(items: AnyJsonSchema | AnyJsonSchema[]) {\n super.set(\"items\", (this.#itemSchema = mapToJsonSchema(items)));\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11\n */\n maxItems(maxItems: number) {\n super.set(\"maxItems\", maxItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12\n */\n minItems(minItems: number) {\n super.set(\"minItems\", minItems);\n\n return this;\n }\n\n /**\n * If this keyword has boolean value false, the instance validates successfully.\n * If it has boolean value true, the instance validates successfully if all of its elements are unique.\n * Omitting this keyword has the same behavior as a value of false.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13\n */\n uniqueItems(uniqueItems: boolean) {\n super.set(\"uniqueItems\", uniqueItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15\n */\n maxProperties(maxProperties: number) {\n super.set(\"maxProperties\", maxProperties);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is greater than,\n * or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16\n */\n minProperties(minProperties: number) {\n super.set(\"minProperties\", minProperties);\n\n return this;\n }\n\n allow(...allow: any[]) {\n this.$allow.push(...allow);\n return this;\n }\n\n /**\n * Elements of this array must be unique.\n * An object instance is valid against this keyword if every item in the array is the name of a property in the instance.\n * Omitting this keyword has the same behavior as an empty array.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17\n */\n required(required: boolean | string[] = true) {\n if (isArray(required)) {\n this.$required.clear();\n\n required.forEach((value: any) => this.$required.add(value));\n } else {\n const schema = this.clone();\n schema.$selfRequired = required;\n return schema;\n }\n\n return this;\n }\n\n addRequired(property: string) {\n this.$required.add(property);\n\n return this;\n }\n\n removeRequired(property: string) {\n this.$required.delete(property);\n\n return this;\n }\n\n isRequired(property: string): boolean {\n return this.$required.has(property);\n }\n\n /**\n * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.\n * Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value,\n * the child instance for that name successfully validates against the corresponding schema.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18\n */\n properties(properties: AnyJsonSchema | Record<string, AnyJsonSchema>) {\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n addProperty(key: string, schema: AnyJsonSchema) {\n const properties = this.get(\"properties\") || {};\n\n properties[key] = schema;\n\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n /**\n * This attribute is an object that defines the schema for a set of property names of an object instance.\n * The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema.\n * If the pattern matches the name of a property on the instance object, the value of the instance's property\n * MUST be valid against the pattern name's schema value.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19\n */\n patternProperties(patternProperties: Record<string, AnyJsonSchema>) {\n super.set(\"patternProperties\", mapProperties(patternProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n */\n additionalProperties(additionalProperties: boolean | AnyJsonSchema) {\n super.set(\"additionalProperties\", mapToJsonSchema(additionalProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n * @alias additionalProperties\n * @param unknown\n */\n unknown(unknown: boolean = true) {\n return this.additionalProperties(unknown);\n }\n\n /**\n * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.\n * Each property specifies a dependency.\n * If the dependency value is an array, each element in the array must be unique.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21\n */\n dependencies(dependencies: {[p: string]: JSONSchema6Definition | JsonSchema | string[]}) {\n super.set(\"dependencies\", mapProperties(dependencies));\n\n return this;\n }\n\n /**\n * Takes a schema which validates the names of all properties rather than their values.\n * Note the property name that the schema is testing will always be a string.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22\n */\n propertyNames(propertyNames: JSONSchema6Definition | JsonSchema) {\n super.set(\"propertyNames\", mapToJsonSchema(propertyNames));\n\n return this;\n }\n\n /**\n * This provides an enumeration of all possible values that are valid\n * for the instance property. This MUST be an array, and each item in\n * the array represents a possible value for the instance value. If\n * this attribute is defined, the instance value MUST be one of the\n * values in the array in order for the schema to be valid.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23\n */\n enum(enumValues: JSONSchema6Type[]): this {\n super.set(\"enum\", uniq(enumValues));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1\n */\n definitions(definitions: Record<string, AnyJsonSchema>) {\n super.set(\"definitions\", mapProperties(definitions));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26\n */\n allOf(allOf: AnyJsonSchema[]) {\n super.set(\"allOf\", allOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n */\n anyOf(anyOf: AnyJsonSchema[]) {\n super.set(\"anyOf\", anyOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28\n */\n oneOf(oneOf: AnyJsonSchema[]) {\n super.set(\"oneOf\", oneOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29\n */\n not(not: AnyJsonSchema) {\n super.set(\"not\", mapToJsonSchema(not));\n\n return this;\n }\n\n /**\n * Must be strictly greater than 0.\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1\n */\n multipleOf(multipleOf: number): this {\n super.set(\"multipleOf\", multipleOf);\n\n return this;\n }\n\n /**\n * Representing an inclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is less than or exactly equal to \"maximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2\n */\n maximum(maximum: number): this {\n super.set(\"maximum\", maximum);\n\n return this;\n }\n\n /**\n * Representing an exclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is strictly less than (not equal to) to \"exclusiveMaximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3\n */\n exclusiveMaximum(exclusiveMaximum: number): this {\n super.set(\"exclusiveMaximum\", exclusiveMaximum);\n\n return this;\n }\n\n /**\n * Representing an inclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is greater than or exactly equal to \"minimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4\n */\n minimum(minimum: number): this {\n super.set(\"minimum\", minimum);\n\n return this;\n }\n\n /**\n * Representing an exclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is strictly greater than (not equal to) to \"exclusiveMinimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5\n */\n exclusiveMinimum(exclusiveMinimum: number): this {\n super.set(\"exclusiveMinimum\", exclusiveMinimum);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6\n */\n maxLength(maxLength: number): this {\n super.set(\"maxLength\", maxLength);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7\n */\n minLength(minLength: number): this {\n super.set(\"minLength\", minLength);\n\n return this;\n }\n\n /**\n * Should be a valid regular expression, according to the ECMA 262 regular expression dialect.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8\n */\n pattern(pattern: string | RegExp): this {\n super.set(\"pattern\", toJsonRegex(pattern));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8\n */\n format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this {\n super.set(\"format\", format);\n\n return this;\n }\n\n /**\n * A single type, or a union of simple types\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25\n */\n type(type: any | JSONSchema6TypeName | JSONSchema6TypeName[]): this {\n switch (type) {\n case Map:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n if (!this.has(\"additionalProperties\")) {\n super.set(\"additionalProperties\", this.itemSchema({}));\n }\n break;\n\n case Array:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case Set:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n this.uniqueItems(true);\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case \"integer\":\n super.set(\"type\", getJsonType(type));\n this.integer();\n break;\n\n case Object:\n case Date:\n case Boolean:\n case Number:\n case String:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n break;\n\n default:\n if (isClass(type) || isFunction(type)) {\n super.set(\"type\", undefined);\n this.#target = type;\n\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n } else {\n const jsonType = getJsonType(type);\n if (jsonType === \"generic\") {\n this.#isGeneric = true;\n super.set(\"$ref\", type);\n } else {\n super.set(\"type\", jsonType);\n }\n }\n }\n\n return this;\n }\n\n any(...types: any[]) {\n const hasClasses = types.filter((type) => isClass(type));\n\n if (hasClasses.length >= 2) {\n this.oneOf(\n types.filter((value) => {\n if (value !== null) {\n this.nullable(true);\n return true;\n }\n return false;\n })\n );\n } else {\n // TODO when OS3 will the only minimal supported version, we'll can remove this code\n if (types.length) {\n types = uniq(types).map(getJsonType);\n\n if (types.includes(\"null\")) {\n this.nullable(true);\n types = types.filter((o) => o !== \"null\");\n }\n } else {\n types = [\"integer\", \"number\", \"string\", \"boolean\", \"array\", \"object\"];\n this.nullable(true);\n }\n\n this.type(types.length === 1 ? types[0] : types);\n }\n\n return this;\n }\n\n integer() {\n super.set(\"type\", \"integer\");\n super.set(\"multipleOf\", 1.0);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a short description of the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n title(title: string): this {\n super.set(\"title\", title);\n\n return this;\n }\n\n readOnly(readOnly: boolean): this {\n super.set(\"readOnly\", readOnly);\n\n return this;\n }\n\n writeOnly(readOnly: boolean): this {\n super.set(\"writeOnly\", readOnly);\n\n return this;\n }\n\n customKey(key: string, value: any) {\n super.set(`#${key}`, value);\n\n return this;\n }\n\n toObject(options?: JsonSchemaOptions) {\n return this.toJSON(options);\n }\n\n toJSON(options?: JsonSchemaOptions) {\n let addDef = false;\n\n if (!options) {\n addDef = true;\n options = {schemas: {}};\n }\n\n const schema = execMapper(\"schema\", this, options);\n\n if (addDef && options.schemas && Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n return schema;\n }\n\n assign(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n const entries = obj instanceof JsonSchema ? [...obj.entries()] : Object.entries(obj);\n entries.forEach(([key, value]) => {\n this.set(key, value);\n });\n\n if (obj instanceof JsonSchema) {\n this.$selfRequired = obj.$selfRequired;\n\n obj.$required.forEach((key) => {\n this.$required.add(key);\n });\n\n this.#ref = obj.#ref;\n this.#alias = new Map(this.#alias.entries());\n obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);\n this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);\n this.#target = obj.#target;\n this.#isGeneric = obj.#isGeneric;\n this.#isCollection = obj.#isCollection;\n this.#ref = obj.#ref;\n\n super.set(\"type\", obj.get(\"type\"));\n }\n\n return this;\n }\n\n set(key: string, value: any): this {\n if (key in this) {\n isFunction((this as any)[key]) && (this as any)[key](value);\n } else {\n super.set(key, value);\n }\n\n return this;\n }\n\n /**\n * Return the itemSchema computed type.\n * If the type is a function used for recursive model,\n * the function will be called to get the right type.\n */\n getComputedType(): any {\n return getComputedType(this.#target);\n }\n\n getComputedItemType(): any {\n return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();\n }\n\n /**\n * Return the Json type as string\n */\n getJsonType(): string | string[] {\n return this.get(\"type\") || getJsonType(this.getComputedType());\n }\n\n getTarget() {\n return this.#target;\n }\n\n /**\n * Get the symbolic name of the entity\n */\n getName() {\n return this.get(\"name\") || (this.#target ? nameOf(classOf(this.getComputedType())) : \"\");\n }\n\n clone() {\n return new JsonSchema(this);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../../src/domain/JsonSchema.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+G;AAI/G,uFAAmE;AAEnE,8DAAyD;AACzD,sDAAiD;AACjD,sDAAiD;AAIjD,uDAAkD;AAClD,sEAAiE;AAWjE,SAAS,aAAa,CAAC,UAA+B;IACpD,uBAAuB;IACvB,IAAI,UAAU,YAAY,UAAU,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAM,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;QAC1E,UAAU,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAEvD,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,eAAe,CAAC,IAAS;IAChC,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAQ,IAAc,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC7C;IAED,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,EAAE;QACvD,OAAO,IAAI,CAAC;KACb;IAED,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,KAAK,MAAM,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QAC7C,OAAO,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;KAC1C;IAED,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;QAClB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAW,CAAC,CAAC;KACrC;IAED,OAAO,IAA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AC;IAED,SAAS;QACP,OAAO,+BAAA,IAAI,0BAAQ,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,+BAAA,IAAI,0BAAQ,CAAC,CAAC,CAAC,IAAA,aAAM,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK;QACH,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AAh1BD,gCAg1BC","sourcesContent":["import {classOf, Hooks, isArray, isClass, isFunction, isObject, nameOf, Type, uniq, ValueOf} from \"@tsed/core\";\nimport type {JSONSchema6, JSONSchema6Definition, JSONSchema6Type, JSONSchema6TypeName, JSONSchema6Version} from \"json-schema\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {IgnoreCallback} from \"../interfaces/IgnoreCallback\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics} from \"../utils/generics\";\nimport {getComputedType} from \"../utils/getComputedType\";\nimport {getJsonType} from \"../utils/getJsonType\";\nimport {toJsonRegex} from \"../utils/toJsonRegex\";\nimport {AliasMap, AliasType} from \"./JsonAliasMap\";\nimport {JsonFormatTypes} from \"./JsonFormatTypes\";\nimport {JsonLazyRef} from \"./JsonLazyRef\";\nimport {JsonEntityStore} from \"./JsonEntityStore\";\nimport {serializeEnumValues} from \"../utils/serializeEnumValues\";\n\nexport interface JsonSchemaObject extends JSONSchema6, Record<string, any> {\n type: (any | JSONSchema6TypeName) | (any | JSONSchema6TypeName)[];\n additionalProperties?: boolean | JSONSchema6 | any;\n propertyNames?: boolean | JSONSchema6 | any;\n items?: (any | JSONSchema6Definition) | (any | JSONSchema6Definition)[];\n}\n\nexport type AnyJsonSchema = Partial<JsonSchemaObject> | JsonSchema | JsonLazyRef | any;\n\nfunction mapProperties(properties: Record<string, any>) {\n // istanbul ignore next\n if (properties instanceof JsonSchema) {\n return properties;\n }\n\n return Object.entries(properties).reduce<any>((properties, [key, schema]) => {\n properties[toJsonRegex(key)] = mapToJsonSchema(schema);\n\n return properties;\n }, {});\n}\n\nfunction mapToJsonSchema(item: any): any {\n if (isArray(item)) {\n return (item as any[]).map(mapToJsonSchema);\n }\n\n if (item.isStore || item.isJsonSchema || item.isLazyRef) {\n return item;\n }\n\n if (classOf(item) !== Object && isClass(item)) {\n return JsonEntityStore.from(item).schema;\n }\n\n if (isObject(item)) {\n return JsonSchema.from(item as any);\n }\n\n return item;\n}\n\nexport class JsonSchema extends Map<string, any> implements NestedGenerics {\n readonly isJsonSchema = true;\n readonly $hooks = new Hooks();\n readonly $required: Set<string> = new Set();\n readonly $allow: any[] = [];\n public $selfRequired: boolean;\n public $forwardGroups: boolean = false;\n\n #nullable: boolean = false;\n #genericLabels: string[];\n #nestedGenerics: Type<any>[][] = [];\n #alias: AliasMap = new Map();\n #itemSchema: JsonSchema;\n #target: Type<any>;\n #isGeneric: boolean = false;\n #isCollection: boolean = false;\n #ref: boolean = false;\n\n constructor(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n super();\n\n if (obj) {\n this.assign(obj);\n }\n }\n\n get alias() {\n return this.#alias;\n }\n\n get nestedGenerics(): any[] {\n return this.#nestedGenerics;\n }\n\n set nestedGenerics(value: any[]) {\n this.#nestedGenerics = value;\n }\n\n get genericLabels(): string[] {\n return this.#genericLabels;\n }\n\n set genericLabels(value: string[]) {\n this.#genericLabels = value;\n }\n\n get isClass() {\n return isClass(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target as any);\n }\n\n /**\n * Current schema is a collection\n */\n get isCollection() {\n return this.#isCollection;\n }\n\n /**\n * Current schema is a generic\n */\n get isGeneric() {\n return this.#isGeneric;\n }\n\n /**\n * Current schema has generics items\n */\n get hasGenerics(): boolean {\n return !!(this.nestedGenerics && this.nestedGenerics.length);\n }\n\n get genericType(): string {\n return this.get(\"$ref\");\n }\n\n get class() {\n return this.getComputedType();\n }\n\n get canRef(): boolean {\n return this.#ref;\n }\n\n get isNullable(): boolean {\n return this.#nullable || this.$allow.includes(null);\n }\n\n get isReadOnly() {\n return this.get(\"readOnly\");\n }\n\n get isWriteOnly() {\n return this.get(\"writeOnly\");\n }\n\n static from(obj: Partial<JsonSchemaObject> = {}) {\n return new JsonSchema(obj);\n }\n\n nullable(value: boolean) {\n this.#nullable = value;\n }\n\n itemSchema(obj: AnyJsonSchema = {}) {\n this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);\n this.#itemSchema.assign(obj);\n\n return this.#itemSchema;\n }\n\n getAliasOf(property: AliasType) {\n return this.#alias.get(property as any);\n }\n\n addAlias(property: AliasType, alias: AliasType) {\n this.#alias.set(property, alias);\n this.#alias.set(alias, property);\n\n return this;\n }\n\n removeAlias(property: AliasType) {\n const alias = this.#alias.get(property);\n alias && this.#alias.delete(alias);\n this.#alias.delete(property);\n\n return this;\n }\n\n $id($id: string) {\n super.set(\"$id\", $id);\n\n return this;\n }\n\n $ref($ref: string) {\n super.set(\"$ref\", $ref);\n\n return this;\n }\n\n $schema($schema: JSONSchema6Version) {\n super.set(\"$schema\", $schema);\n\n return this;\n }\n\n /**\n * Create a ref and use name to sharing schema\n * @param name\n */\n label(name: string) {\n this.#ref = true;\n\n super.set(\"name\", name);\n\n return this;\n }\n\n name(name: string) {\n super.set(\"name\", name);\n\n return this;\n }\n\n ignore(cb: boolean | IgnoreCallback) {\n if (typeof cb === \"boolean\") {\n const bool = cb;\n cb = () => bool;\n }\n\n this.$hooks.on(\"ignore\", cb);\n\n return this;\n }\n\n /**\n * This keyword can be used to supply a default JSON value associated with a particular schema.\n * It is RECOMMENDED that a default value be valid against the associated schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3\n */\n default(value: JSONSchema6Type) {\n super.set(\"default\", value);\n\n return this;\n }\n\n /**\n * More readible form of a one-element \"enum\"\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24\n */\n const(value: JSONSchema6Type) {\n super.set(\"const\", value);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a full description of the of purpose the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n description(description: string) {\n super.set(\"description\", description);\n\n return this;\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * If \"items\" is an array of schemas, validation succeeds if every instance element\n * at a position greater than the size of \"items\" validates against \"additionalItems\".\n * Otherwise, \"additionalItems\" MUST be ignored, as the \"items\" schema\n * (possibly the default value of an empty schema) is applied to all elements.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10\n */\n additionalItems(additionalItems: boolean | AnyJsonSchema) {\n super.set(\"additionalItems\", mapToJsonSchema(additionalItems));\n\n return this;\n }\n\n /**\n * An array instance is valid against \"contains\" if at least one of its elements is valid against the given schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14\n */\n contains(contains: JSONSchema6Definition) {\n super.set(\"contains\", mapToJsonSchema(contains));\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n examples(examples: JSONSchema6Type[]) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n /**\n * Array of examples with no validation effect the value of \"default\" is usable as an example without repeating it under this keyword\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4\n */\n example(...examples: JSONSchema6Type[]) {\n return this.examples(examples);\n }\n\n /**\n * This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9\n */\n items(items: AnyJsonSchema | AnyJsonSchema[]) {\n super.set(\"items\", (this.#itemSchema = mapToJsonSchema(items)));\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11\n */\n maxItems(maxItems: number) {\n super.set(\"maxItems\", maxItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An array instance is valid against \"maxItems\" if its size is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12\n */\n minItems(minItems: number) {\n super.set(\"minItems\", minItems);\n\n return this;\n }\n\n /**\n * If this keyword has boolean value false, the instance validates successfully.\n * If it has boolean value true, the instance validates successfully if all of its elements are unique.\n * Omitting this keyword has the same behavior as a value of false.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13\n */\n uniqueItems(uniqueItems: boolean) {\n super.set(\"uniqueItems\", uniqueItems);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15\n */\n maxProperties(maxProperties: number) {\n super.set(\"maxProperties\", maxProperties);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * An object instance is valid against \"maxProperties\" if its number of properties is greater than,\n * or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16\n */\n minProperties(minProperties: number) {\n super.set(\"minProperties\", minProperties);\n\n return this;\n }\n\n allow(...allow: any[]) {\n this.$allow.push(...allow);\n return this;\n }\n\n /**\n * Elements of this array must be unique.\n * An object instance is valid against this keyword if every item in the array is the name of a property in the instance.\n * Omitting this keyword has the same behavior as an empty array.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17\n */\n required(required: boolean | string[] = true) {\n if (isArray(required)) {\n this.$required.clear();\n\n required.forEach((value: any) => this.$required.add(value));\n } else {\n const schema = this.clone();\n schema.$selfRequired = required;\n return schema;\n }\n\n return this;\n }\n\n addRequired(property: string) {\n this.$required.add(property);\n\n return this;\n }\n\n removeRequired(property: string) {\n this.$required.delete(property);\n\n return this;\n }\n\n isRequired(property: string): boolean {\n return this.$required.has(property);\n }\n\n /**\n * This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself.\n * Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value,\n * the child instance for that name successfully validates against the corresponding schema.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18\n */\n properties(properties: AnyJsonSchema | Record<string, AnyJsonSchema>) {\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n addProperty(key: string, schema: AnyJsonSchema) {\n const properties = this.get(\"properties\") || {};\n\n properties[key] = schema;\n\n super.set(\"properties\", mapProperties(properties));\n\n return this;\n }\n\n /**\n * This attribute is an object that defines the schema for a set of property names of an object instance.\n * The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema.\n * If the pattern matches the name of a property on the instance object, the value of the instance's property\n * MUST be valid against the pattern name's schema value.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19\n */\n patternProperties(patternProperties: Record<string, AnyJsonSchema>) {\n super.set(\"patternProperties\", mapProperties(patternProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n */\n additionalProperties(additionalProperties: boolean | AnyJsonSchema) {\n super.set(\"additionalProperties\", mapToJsonSchema(additionalProperties));\n\n return this;\n }\n\n /**\n * This attribute defines a schema for all properties that are not explicitly defined in an object type definition.\n * If specified, the value MUST be a schema or a boolean.\n * If false is provided, no additional properties are allowed beyond the properties defined in the schema.\n * The default value is an empty schema which allows any value for additional properties.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20\n * @alias additionalProperties\n * @param unknown\n */\n unknown(unknown: boolean = true) {\n return this.additionalProperties(unknown);\n }\n\n /**\n * This keyword specifies rules that are evaluated if the instance is an object and contains a certain property.\n * Each property specifies a dependency.\n * If the dependency value is an array, each element in the array must be unique.\n * Omitting this keyword has the same behavior as an empty object.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21\n */\n dependencies(dependencies: {[p: string]: JSONSchema6Definition | JsonSchema | string[]}) {\n super.set(\"dependencies\", mapProperties(dependencies));\n\n return this;\n }\n\n /**\n * Takes a schema which validates the names of all properties rather than their values.\n * Note the property name that the schema is testing will always be a string.\n * Omitting this keyword has the same behavior as an empty schema.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22\n */\n propertyNames(propertyNames: JSONSchema6Definition | JsonSchema) {\n super.set(\"propertyNames\", mapToJsonSchema(propertyNames));\n\n return this;\n }\n\n /**\n * This provides an enumeration of all possible values that are valid\n * for the instance property. This MUST be an array, and each item in\n * the array represents a possible value for the instance value. If\n * this attribute is defined, the instance value MUST be one of the\n * values in the array in order for the schema to be valid.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23\n */\n enum(...enumValues: any[]): this;\n enum(enumValue: any | any[], ...enumValues: any[]): this {\n const {values, types} = serializeEnumValues([enumValue, enumValues].flat());\n\n super.set(\"enum\", values).any(...types);\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1\n */\n definitions(definitions: Record<string, AnyJsonSchema>) {\n super.set(\"definitions\", mapProperties(definitions));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26\n */\n allOf(allOf: AnyJsonSchema[]) {\n super.set(\"allOf\", allOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n */\n anyOf(anyOf: AnyJsonSchema[]) {\n super.set(\"anyOf\", anyOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28\n */\n oneOf(oneOf: AnyJsonSchema[]) {\n super.set(\"oneOf\", oneOf.map(mapToJsonSchema));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29\n */\n not(not: AnyJsonSchema) {\n super.set(\"not\", mapToJsonSchema(not));\n\n return this;\n }\n\n /**\n * Must be strictly greater than 0.\n * A numeric instance is valid only if division by this keyword's value results in an integer.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1\n */\n multipleOf(multipleOf: number): this {\n super.set(\"multipleOf\", multipleOf);\n\n return this;\n }\n\n /**\n * Representing an inclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is less than or exactly equal to \"maximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2\n */\n maximum(maximum: number): this {\n super.set(\"maximum\", maximum);\n\n return this;\n }\n\n /**\n * Representing an exclusive upper limit for a numeric instance.\n * This keyword validates only if the instance is strictly less than (not equal to) to \"exclusiveMaximum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3\n */\n exclusiveMaximum(exclusiveMaximum: number): this {\n super.set(\"exclusiveMaximum\", exclusiveMaximum);\n\n return this;\n }\n\n /**\n * Representing an inclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is greater than or exactly equal to \"minimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4\n */\n minimum(minimum: number): this {\n super.set(\"minimum\", minimum);\n\n return this;\n }\n\n /**\n * Representing an exclusive lower limit for a numeric instance.\n * This keyword validates only if the instance is strictly greater than (not equal to) to \"exclusiveMinimum\".\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5\n */\n exclusiveMinimum(exclusiveMinimum: number): this {\n super.set(\"exclusiveMinimum\", exclusiveMinimum);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6\n */\n maxLength(maxLength: number): this {\n super.set(\"maxLength\", maxLength);\n\n return this;\n }\n\n /**\n * Must be a non-negative integer.\n * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.\n * Omitting this keyword has the same behavior as a value of 0.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7\n */\n minLength(minLength: number): this {\n super.set(\"minLength\", minLength);\n\n return this;\n }\n\n /**\n * Should be a valid regular expression, according to the ECMA 262 regular expression dialect.\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8\n */\n pattern(pattern: string | RegExp): this {\n super.set(\"pattern\", toJsonRegex(pattern));\n\n return this;\n }\n\n /**\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8\n */\n format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this {\n super.set(\"format\", format);\n\n return this;\n }\n\n /**\n * A single type, or a union of simple types\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25\n */\n type(type: any | JSONSchema6TypeName | JSONSchema6TypeName[]): this {\n switch (type) {\n case Map:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n if (!this.has(\"additionalProperties\")) {\n super.set(\"additionalProperties\", this.itemSchema({}));\n }\n break;\n\n case Array:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case Set:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n this.#isCollection = true;\n this.uniqueItems(true);\n\n if (!this.has(\"items\")) {\n super.set(\"items\", this.itemSchema({}));\n }\n break;\n\n case \"integer\":\n super.set(\"type\", getJsonType(type));\n this.integer();\n break;\n\n case Object:\n case Date:\n case Boolean:\n case Number:\n case String:\n super.set(\"type\", getJsonType(type));\n this.#target = type;\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n break;\n\n default:\n if (isClass(type) || isFunction(type)) {\n super.set(\"type\", undefined);\n this.#target = type;\n\n if (!this.has(\"properties\")) {\n super.set(\"properties\", {});\n }\n } else {\n const jsonType = getJsonType(type);\n if (jsonType === \"generic\") {\n this.#isGeneric = true;\n super.set(\"$ref\", type);\n } else {\n super.set(\"type\", jsonType);\n }\n }\n }\n\n return this;\n }\n\n any(...types: any[]) {\n const hasClasses = types.filter((type) => isClass(type));\n\n if (hasClasses.length >= 2) {\n this.oneOf(\n types.filter((value) => {\n if (value !== null) {\n this.nullable(true);\n return true;\n }\n return false;\n })\n );\n } else {\n // TODO when OS3 will the only minimal supported version, we'll can remove this code\n if (types.length) {\n types = uniq(types).map(getJsonType);\n\n if (types.includes(\"null\")) {\n this.nullable(true);\n types = types.filter((o) => o !== \"null\");\n }\n } else {\n types = [\"integer\", \"number\", \"string\", \"boolean\", \"array\", \"object\"];\n this.nullable(true);\n }\n\n this.type(types.length === 1 ? types[0] : types);\n }\n\n return this;\n }\n\n integer() {\n super.set(\"type\", \"integer\");\n super.set(\"multipleOf\", 1.0);\n\n return this;\n }\n\n /**\n * This attribute is a string that provides a short description of the instance property.\n *\n * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2\n */\n title(title: string): this {\n super.set(\"title\", title);\n\n return this;\n }\n\n readOnly(readOnly: boolean): this {\n super.set(\"readOnly\", readOnly);\n\n return this;\n }\n\n writeOnly(readOnly: boolean): this {\n super.set(\"writeOnly\", readOnly);\n\n return this;\n }\n\n customKey(key: string, value: any) {\n super.set(`#${key}`, value);\n\n return this;\n }\n\n toObject(options?: JsonSchemaOptions) {\n return this.toJSON(options);\n }\n\n toJSON(options?: JsonSchemaOptions) {\n let addDef = false;\n\n if (!options) {\n addDef = true;\n options = {schemas: {}};\n }\n\n const schema = execMapper(\"schema\", this, options);\n\n if (addDef && options.schemas && Object.keys(options.schemas).length) {\n schema.definitions = options.schemas;\n }\n\n return schema;\n }\n\n assign(obj: JsonSchema | Partial<JsonSchemaObject> = {}) {\n const entries = obj instanceof JsonSchema ? [...obj.entries()] : Object.entries(obj);\n entries.forEach(([key, value]) => {\n this.set(key, value);\n });\n\n if (obj instanceof JsonSchema) {\n this.$selfRequired = obj.$selfRequired;\n\n obj.$required.forEach((key) => {\n this.$required.add(key);\n });\n\n this.#ref = obj.#ref;\n this.#alias = new Map(this.#alias.entries());\n obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);\n this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);\n this.#target = obj.#target;\n this.#isGeneric = obj.#isGeneric;\n this.#isCollection = obj.#isCollection;\n this.#ref = obj.#ref;\n\n super.set(\"type\", obj.get(\"type\"));\n }\n\n return this;\n }\n\n set(key: string, value: any): this {\n if (key in this) {\n isFunction((this as any)[key]) && (this as any)[key](value);\n } else {\n super.set(key, value);\n }\n\n return this;\n }\n\n /**\n * Return the itemSchema computed type.\n * If the type is a function used for recursive model,\n * the function will be called to get the right type.\n */\n getComputedType(): any {\n return getComputedType(this.#target);\n }\n\n getComputedItemType(): any {\n return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();\n }\n\n /**\n * Return the Json type as string\n */\n getJsonType(): string | string[] {\n return this.get(\"type\") || getJsonType(this.getComputedType());\n }\n\n getTarget() {\n return this.#target;\n }\n\n /**\n * Get the symbolic name of the entity\n */\n getName() {\n return this.get(\"name\") || (this.#target ? nameOf(classOf(this.getComputedType())) : \"\");\n }\n\n clone() {\n return new JsonSchema(this);\n }\n}\n"]}
|