@tsed/schema 7.0.0-beta.7 → 7.0.0-rc.1

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.
Files changed (142) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/components/lazyRefMapper.js +1 -2
  4. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  5. package/lib/cjs/components/objectMapper.js +1 -1
  6. package/lib/cjs/components/objectMapper.js.map +1 -1
  7. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  8. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  9. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  10. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  11. package/lib/cjs/decorators/common/description.js +1 -2
  12. package/lib/cjs/decorators/common/description.js.map +1 -1
  13. package/lib/cjs/decorators/operations/redirect.js +1 -2
  14. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  15. package/lib/cjs/decorators/operations/returns.js +43 -21
  16. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  17. package/lib/cjs/decorators/operations/route.js +1 -4
  18. package/lib/cjs/decorators/operations/route.js.map +1 -1
  19. package/lib/cjs/domain/DecoratorContext.js +6 -3
  20. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  21. package/lib/cjs/domain/JsonClassStore.js +4 -7
  22. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  23. package/lib/cjs/domain/JsonEntityStore.js +40 -1
  24. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  25. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  26. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  27. package/lib/cjs/domain/JsonMethodStore.js +19 -15
  28. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperation.js +12 -16
  30. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  31. package/lib/cjs/domain/JsonOperationPathsMap.js +2 -16
  32. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  33. package/lib/cjs/domain/JsonOperationRoute.js +7 -8
  34. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  35. package/lib/cjs/domain/JsonParameter.js +4 -4
  36. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  37. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  38. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  39. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  40. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  41. package/lib/cjs/domain/JsonResponse.js +6 -7
  42. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  43. package/lib/cjs/domain/JsonSchema.js +58 -60
  44. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  45. package/lib/cjs/hooks/alterIgnore.js +2 -3
  46. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  47. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  48. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  49. package/lib/cjs/utils/concatPath.js +16 -1
  50. package/lib/cjs/utils/concatPath.js.map +1 -1
  51. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  52. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  53. package/lib/cjs/utils/getJsonSchema.js +4 -5
  54. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  55. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  56. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  57. package/lib/cjs/utils/mapNullableType.js +1 -1
  58. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  59. package/lib/cjs/utils/mergeOperation.js +1 -2
  60. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  61. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  62. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  63. package/lib/cjs/utils/ref.js +2 -2
  64. package/lib/cjs/utils/ref.js.map +1 -1
  65. package/lib/cjs/utils/transformToOS2.js +2 -2
  66. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  67. package/lib/esm/components/lazyRefMapper.js +1 -2
  68. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  69. package/lib/esm/components/objectMapper.js +1 -1
  70. package/lib/esm/components/objectMapper.js.map +1 -1
  71. package/lib/esm/constants/httpStatusMessages.js +2 -4
  72. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  73. package/lib/esm/decorators/collections/collectionOf.js +3 -4
  74. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  75. package/lib/esm/decorators/common/description.js +1 -2
  76. package/lib/esm/decorators/common/description.js.map +1 -1
  77. package/lib/esm/decorators/operations/redirect.js +1 -2
  78. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  79. package/lib/esm/decorators/operations/returns.js +43 -21
  80. package/lib/esm/decorators/operations/returns.js.map +1 -1
  81. package/lib/esm/decorators/operations/route.js +1 -4
  82. package/lib/esm/decorators/operations/route.js.map +1 -1
  83. package/lib/esm/domain/DecoratorContext.js +5 -2
  84. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  85. package/lib/esm/domain/JsonClassStore.js +4 -7
  86. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  87. package/lib/esm/domain/JsonEntityStore.js +40 -1
  88. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  89. package/lib/esm/domain/JsonLazyRef.js +2 -1
  90. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  91. package/lib/esm/domain/JsonMethodStore.js +19 -15
  92. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  93. package/lib/esm/domain/JsonOperation.js +12 -16
  94. package/lib/esm/domain/JsonOperation.js.map +1 -1
  95. package/lib/esm/domain/JsonOperationPathsMap.js +2 -16
  96. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  97. package/lib/esm/domain/JsonOperationRoute.js +7 -8
  98. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  99. package/lib/esm/domain/JsonParameter.js +4 -4
  100. package/lib/esm/domain/JsonParameter.js.map +1 -1
  101. package/lib/esm/domain/JsonParameterStore.js +12 -5
  102. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  103. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  104. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  105. package/lib/esm/domain/JsonResponse.js +6 -7
  106. package/lib/esm/domain/JsonResponse.js.map +1 -1
  107. package/lib/esm/domain/JsonSchema.js +58 -60
  108. package/lib/esm/domain/JsonSchema.js.map +1 -1
  109. package/lib/esm/hooks/alterIgnore.js +2 -3
  110. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  111. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  112. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  113. package/lib/esm/utils/concatPath.js +16 -1
  114. package/lib/esm/utils/concatPath.js.map +1 -1
  115. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  116. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  117. package/lib/esm/utils/getJsonSchema.js +4 -5
  118. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  119. package/lib/esm/utils/getRequiredProperties.js +3 -3
  120. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  121. package/lib/esm/utils/mapNullableType.js +1 -1
  122. package/lib/esm/utils/mapNullableType.js.map +1 -1
  123. package/lib/esm/utils/mergeOperation.js +1 -2
  124. package/lib/esm/utils/mergeOperation.js.map +1 -1
  125. package/lib/esm/utils/operationIdFormatter.js +1 -1
  126. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  127. package/lib/esm/utils/ref.js +1 -1
  128. package/lib/esm/utils/ref.js.map +1 -1
  129. package/lib/esm/utils/transformToOS2.js +2 -2
  130. package/lib/esm/utils/transformToOS2.js.map +1 -1
  131. package/lib/types/decorators/operations/returns.d.ts +7 -2
  132. package/lib/types/domain/JsonEntityStore.d.ts +1 -0
  133. package/lib/types/domain/JsonMethodStore.d.ts +5 -2
  134. package/lib/types/domain/JsonOperation.d.ts +0 -1
  135. package/lib/types/domain/JsonOperationPathsMap.d.ts +0 -2
  136. package/lib/types/domain/JsonOperationRoute.d.ts +2 -3
  137. package/lib/types/domain/JsonResponse.d.ts +1 -0
  138. package/lib/types/utils/concatPath.d.ts +1 -1
  139. package/lib/types/utils/getJsonSchema.d.ts +1 -1
  140. package/package.json +13 -11
  141. package/readme.md +3 -2
  142. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
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,CAAC;QAPjB;;WAEG;QACM,cAAS,GAAkB,IAAI,6BAAa,EAAE,CAAC;QAC/C,WAAM,GAAoB,iCAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAI3F,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;IACpD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACvC,CAAC;IAED,IAAI,cAAc,CAAC,cAA6B;QAC9C,IAAI,CAAC,SA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I,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
+ {"version":3,"file":"JsonParameterStore.js","sourceRoot":"","sources":["../../../src/domain/JsonParameterStore.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f, 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"]}
@@ -7,10 +7,7 @@ const JsonEntityStore_1 = require("./JsonEntityStore");
7
7
  const JsonSchema_1 = require("./JsonSchema");
8
8
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
9
9
  let JsonPropertyStore = class JsonPropertyStore extends JsonEntityStore_1.JsonEntityStore {
10
- constructor() {
11
- super(...arguments);
12
- this.parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
13
- }
10
+ parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
14
11
  /**
15
12
  * Return the required state.
16
13
  * @returns {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"JsonPropertyStore.js","sourceRoot":"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,CAAC;QAElC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAExD,IAAI,MAAM,GAAe,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEvD,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAElD,MAAM,GAAG,uBAAU,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI;aACvC,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;SACF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B;QACxD,OAAO,iCAAe,CAAC,IAAI,CAAoB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;CACF,CAAA;AAnEY,iBAAiB;IAD7B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,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
+ {"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;IAC3C,MAAM,GAAmB,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpE;;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AE,IAAI,CAAC,CAAC;YAElD,MAAM,GAAG,uBAAU,CAAC,IAAI,CAAC;gBACvB,IAAI,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI;aACvC,CAAC,CAAC;YAEH,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC9B;SACF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B;QACxD,OAAO,iCAAe,CAAC,IAAI,CAAoB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;CACF,CAAA;AAnEY,iBAAiB;IAD7B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,IAAI,CAAC;GAC5B,iBAAiB,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"]}
@@ -5,10 +5,8 @@ const mapHeaders_1 = require("../utils/mapHeaders");
5
5
  const toJsonMapCollection_1 = require("../utils/toJsonMapCollection");
6
6
  const JsonMap_1 = require("./JsonMap");
7
7
  class JsonMedia extends JsonMap_1.JsonMap {
8
- constructor() {
9
- super(...arguments);
10
- this.groups = [];
11
- }
8
+ groups = [];
9
+ allowedGroups;
12
10
  schema(schema) {
13
11
  this.set("schema", schema);
14
12
  return this;
@@ -18,11 +16,13 @@ class JsonMedia extends JsonMap_1.JsonMap {
18
16
  return this;
19
17
  }
20
18
  toJSON(options = {}) {
21
- return super.toJSON({ ...options, groups: this.groups });
19
+ let groups = [...(this.groups || [])];
20
+ return super.toJSON({ ...options, groups });
22
21
  }
23
22
  }
24
23
  exports.JsonMedia = JsonMedia;
25
24
  class JsonResponse extends JsonMap_1.JsonMap {
25
+ status;
26
26
  constructor(obj = {}) {
27
27
  super(obj);
28
28
  this.content(obj.content || {});
@@ -43,9 +43,8 @@ class JsonResponse extends JsonMap_1.JsonMap {
43
43
  return this.get("content");
44
44
  }
45
45
  getMedia(mediaType, create = true) {
46
- var _a;
47
46
  create && this.addMedia(mediaType);
48
- return (_a = this.getContent()) === null || _a === void 0 ? void 0 : _a.get(mediaType);
47
+ return this.getContent()?.get(mediaType);
49
48
  }
50
49
  addMedia(mediaType) {
51
50
  const content = this.get("content");
@@ -1 +1 @@
1
- {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;AAIA,oDAA+C;AAC/C,sEAAiE;AACjE,uCAAkC;AAMlC,MAAa,SAAU,SAAQ,iBAAiC;IAAhE;;QACE,WAAM,GAAa,EAAE,CAAC;IAiBxB,CAAC;IAfC,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAa;QACpB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC,CAAC;IACzD,CAAC;CACF;AAlBD,8BAkBC;AAED,MAAa,YAAa,SAAQ,iBAA4B;IAG5D,YAAY,MAAoC,EAAE;QAChD,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAK,EAAU,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,C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,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"]}
1
+ {"version":3,"file":"JsonResponse.js","sourceRoot":"","sources":["../../../src/domain/JsonResponse.ts"],"names":[],"mappings":";;;AAGA,oDAA+C;AAC/C,sEAAiE;AACjE,uCAAkC;AAKlC,MAAa,SAAU,SAAQ,iBAAiC;IAC9D,MAAM,GAAa,EAAE,CAAC;IACtB,aAAa,CAAe;IAE5B,MAAM,CAAC,MAAkB;QACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAa;QACpB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QAEtC,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,MAAM,EAAC,CAAC,CAAC;IAC5C,CAAC;CACF;AArBD,8BAqBC;AAED,MAAa,YAAa,SAAQ,iBAA4B;IAC5D,MAAM,CAAS;IAEf,YAAY,MAAoC,EAAE;QAChD,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAK,EAAU,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,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,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 {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\";\n\nexport type JsonResponseOptions = OS3Response<JsonSchema, string | JsonHeader>;\n\nexport class JsonMedia extends JsonMap<OS3MediaType<JsonSchema>> {\n groups: string[] = [];\n allowedGroups?: Set<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 let groups = [...(this.groups || [])];\n\n return super.toJSON({...options, 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"]}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _JsonSchema_nullable, _JsonSchema_genericLabels, _JsonSchema_nestedGenerics, _JsonSchema_alias, _JsonSchema_itemSchema, _JsonSchema_target, _JsonSchema_isGeneric, _JsonSchema_isCollection, _JsonSchema_ref;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.JsonSchema = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const core_1 = require("@tsed/core");
7
5
  const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
8
6
  const getComputedType_1 = require("../utils/getComputedType");
@@ -36,55 +34,56 @@ function mapToJsonSchema(item) {
36
34
  return item;
37
35
  }
38
36
  class JsonSchema extends Map {
37
+ isJsonSchema = true;
38
+ $hooks = new core_1.Hooks();
39
+ $required = new Set();
40
+ $allow = [];
41
+ $selfRequired;
42
+ $forwardGroups = false;
43
+ #nullable = false;
44
+ #genericLabels;
45
+ #nestedGenerics = [];
46
+ #alias = new Map();
47
+ #itemSchema;
48
+ #target;
49
+ #isGeneric = false;
50
+ #isCollection = false;
51
+ #ref = false;
39
52
  constructor(obj = {}) {
40
53
  super();
41
- this.isJsonSchema = true;
42
- this.$hooks = new core_1.Hooks();
43
- this.$required = new Set();
44
- this.$allow = [];
45
- this.$forwardGroups = false;
46
- _JsonSchema_nullable.set(this, false);
47
- _JsonSchema_genericLabels.set(this, void 0);
48
- _JsonSchema_nestedGenerics.set(this, []);
49
- _JsonSchema_alias.set(this, new Map());
50
- _JsonSchema_itemSchema.set(this, void 0);
51
- _JsonSchema_target.set(this, void 0);
52
- _JsonSchema_isGeneric.set(this, false);
53
- _JsonSchema_isCollection.set(this, false);
54
- _JsonSchema_ref.set(this, false);
55
54
  if (obj) {
56
55
  this.assign(obj);
57
56
  }
58
57
  }
59
58
  get alias() {
60
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f");
59
+ return this.#alias;
61
60
  }
62
61
  get nestedGenerics() {
63
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_nestedGenerics, "f");
62
+ return this.#nestedGenerics;
64
63
  }
65
64
  set nestedGenerics(value) {
66
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_nestedGenerics, value, "f");
65
+ this.#nestedGenerics = value;
67
66
  }
68
67
  get genericLabels() {
69
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_genericLabels, "f");
68
+ return this.#genericLabels;
70
69
  }
71
70
  set genericLabels(value) {
72
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_genericLabels, value, "f");
71
+ this.#genericLabels = value;
73
72
  }
74
73
  get isClass() {
75
- return (0, core_1.isClass)(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f"));
74
+ return (0, core_1.isClass)(this.class) && ![Map, Array, Set, Object, Date, Boolean, Number, String].includes(this.#target);
76
75
  }
77
76
  /**
78
77
  * Current schema is a collection
79
78
  */
80
79
  get isCollection() {
81
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_isCollection, "f");
80
+ return this.#isCollection;
82
81
  }
83
82
  /**
84
83
  * Current schema is a generic
85
84
  */
86
85
  get isGeneric() {
87
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_isGeneric, "f");
86
+ return this.#isGeneric;
88
87
  }
89
88
  /**
90
89
  * Current schema has generics items
@@ -99,10 +98,10 @@ class JsonSchema extends Map {
99
98
  return this.getComputedType();
100
99
  }
101
100
  get canRef() {
102
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_ref, "f");
101
+ return this.#ref;
103
102
  }
104
103
  get isNullable() {
105
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_nullable, "f") || this.$allow.includes(null);
104
+ return this.#nullable || this.$allow.includes(null);
106
105
  }
107
106
  get isReadOnly() {
108
107
  return this.get("readOnly");
@@ -114,25 +113,25 @@ class JsonSchema extends Map {
114
113
  return new JsonSchema(obj);
115
114
  }
116
115
  nullable(value) {
117
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_nullable, value, "f");
116
+ this.#nullable = value;
118
117
  }
119
118
  itemSchema(obj = {}) {
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");
119
+ this.#itemSchema = this.#itemSchema || mapToJsonSchema(obj);
120
+ this.#itemSchema.assign(obj);
121
+ return this.#itemSchema;
123
122
  }
124
123
  getAliasOf(property) {
125
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").get(property);
124
+ return this.#alias.get(property);
126
125
  }
127
126
  addAlias(property, alias) {
128
- tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").set(property, alias);
129
- tslib_1.__classPrivateFieldGet(this, _JsonSchema_alias, "f").set(alias, property);
127
+ this.#alias.set(property, alias);
128
+ this.#alias.set(alias, property);
130
129
  return this;
131
130
  }
132
131
  removeAlias(property) {
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);
132
+ const alias = this.#alias.get(property);
133
+ alias && this.#alias.delete(alias);
134
+ this.#alias.delete(property);
136
135
  return this;
137
136
  }
138
137
  $id($id) {
@@ -152,7 +151,7 @@ class JsonSchema extends Map {
152
151
  * @param name
153
152
  */
154
153
  label(name) {
155
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_ref, true, "f");
154
+ this.#ref = true;
156
155
  super.set("name", name);
157
156
  return this;
158
157
  }
@@ -236,7 +235,7 @@ class JsonSchema extends Map {
236
235
  * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9
237
236
  */
238
237
  items(items) {
239
- super.set("items", (tslib_1.__classPrivateFieldSet(this, _JsonSchema_itemSchema, mapToJsonSchema(items), "f")));
238
+ super.set("items", (this.#itemSchema = mapToJsonSchema(items)));
240
239
  return this;
241
240
  }
242
241
  /**
@@ -522,24 +521,24 @@ class JsonSchema extends Map {
522
521
  switch (type) {
523
522
  case Map:
524
523
  super.set("type", (0, getJsonType_1.getJsonType)(type));
525
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
526
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
524
+ this.#target = type;
525
+ this.#isCollection = true;
527
526
  if (!this.has("additionalProperties")) {
528
527
  super.set("additionalProperties", this.itemSchema({}));
529
528
  }
530
529
  break;
531
530
  case Array:
532
531
  super.set("type", (0, getJsonType_1.getJsonType)(type));
533
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
534
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
532
+ this.#target = type;
533
+ this.#isCollection = true;
535
534
  if (!this.has("items")) {
536
535
  super.set("items", this.itemSchema({}));
537
536
  }
538
537
  break;
539
538
  case Set:
540
539
  super.set("type", (0, getJsonType_1.getJsonType)(type));
541
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
542
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_isCollection, true, "f");
540
+ this.#target = type;
541
+ this.#isCollection = true;
543
542
  this.uniqueItems(true);
544
543
  if (!this.has("items")) {
545
544
  super.set("items", this.itemSchema({}));
@@ -555,7 +554,7 @@ class JsonSchema extends Map {
555
554
  case Number:
556
555
  case String:
557
556
  super.set("type", (0, getJsonType_1.getJsonType)(type));
558
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
557
+ this.#target = type;
559
558
  if (!this.has("properties")) {
560
559
  super.set("properties", {});
561
560
  }
@@ -563,7 +562,7 @@ class JsonSchema extends Map {
563
562
  default:
564
563
  if ((0, core_1.isClass)(type) || (0, core_1.isFunction)(type)) {
565
564
  super.set("type", undefined);
566
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_target, type, "f");
565
+ this.#target = type;
567
566
  if (!this.has("properties")) {
568
567
  super.set("properties", {});
569
568
  }
@@ -571,7 +570,7 @@ class JsonSchema extends Map {
571
570
  else {
572
571
  const jsonType = (0, getJsonType_1.getJsonType)(type);
573
572
  if (jsonType === "generic") {
574
- tslib_1.__classPrivateFieldSet(this, _JsonSchema_isGeneric, true, "f");
573
+ this.#isGeneric = true;
575
574
  super.set("$ref", type);
576
575
  }
577
576
  else {
@@ -660,14 +659,14 @@ class JsonSchema extends Map {
660
659
  obj.$required.forEach((key) => {
661
660
  this.$required.add(key);
662
661
  });
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");
662
+ this.#ref = obj.#ref;
663
+ this.#alias = new Map(this.#alias.entries());
664
+ obj.#genericLabels && (this.#genericLabels = [...obj.#genericLabels]);
665
+ this.#nestedGenerics = obj.#nestedGenerics.map((item) => [...item]);
666
+ this.#target = obj.#target;
667
+ this.#isGeneric = obj.#isGeneric;
668
+ this.#isCollection = obj.#isCollection;
669
+ this.#ref = obj.#ref;
671
670
  super.set("type", obj.get("type"));
672
671
  }
673
672
  return this;
@@ -687,10 +686,10 @@ class JsonSchema extends Map {
687
686
  * the function will be called to get the right type.
688
687
  */
689
688
  getComputedType() {
690
- return (0, getComputedType_1.getComputedType)(tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f"));
689
+ return (0, getComputedType_1.getComputedType)(this.#target);
691
690
  }
692
691
  getComputedItemType() {
693
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f") ? tslib_1.__classPrivateFieldGet(this, _JsonSchema_itemSchema, "f").getComputedType() : this.getComputedType();
692
+ return this.#itemSchema ? this.#itemSchema.getComputedType() : this.getComputedType();
694
693
  }
695
694
  /**
696
695
  * Return the Json type as string
@@ -699,18 +698,17 @@ class JsonSchema extends Map {
699
698
  return this.get("type") || (0, getJsonType_1.getJsonType)(this.getComputedType());
700
699
  }
701
700
  getTarget() {
702
- return tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f");
701
+ return this.#target;
703
702
  }
704
703
  /**
705
704
  * Get the symbolic name of the entity
706
705
  */
707
706
  getName() {
708
- return this.get("name") || (tslib_1.__classPrivateFieldGet(this, _JsonSchema_target, "f") ? (0, core_1.nameOf)((0, core_1.classOf)(this.getComputedType())) : "");
707
+ return this.get("name") || (this.#target ? (0, core_1.nameOf)((0, core_1.classOf)(this.getComputedType())) : "");
709
708
  }
710
709
  clone() {
711
710
  return new JsonSchema(this);
712
711
  }
713
712
  }
714
713
  exports.JsonSchema = JsonSchema;
715
- _JsonSchema_nullable = new WeakMap(), _JsonSchema_genericLabels = new WeakMap(), _JsonSchema_nestedGenerics = new WeakMap(), _JsonSchema_alias = new WeakMap(), _JsonSchema_itemSchema = new WeakMap(), _JsonSchema_target = new WeakMap(), _JsonSchema_isGeneric = new WeakMap(), _JsonSchema_isCollection = new WeakMap(), _JsonSchema_ref = new WeakMap();
716
714
  //# sourceMappingURL=JsonSchema.js.map