@tsed/schema 7.0.0-beta.10 → 7.0.0-beta.13

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 (128) hide show
  1. package/lib/cjs/components/lazyRefMapper.js +1 -2
  2. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  3. package/lib/cjs/components/objectMapper.js +1 -1
  4. package/lib/cjs/components/objectMapper.js.map +1 -1
  5. package/lib/cjs/constants/httpStatusMessages.js +2 -4
  6. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  7. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  8. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  9. package/lib/cjs/decorators/common/description.js +1 -2
  10. package/lib/cjs/decorators/common/description.js.map +1 -1
  11. package/lib/cjs/decorators/operations/redirect.js +1 -2
  12. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  13. package/lib/cjs/decorators/operations/returns.js +20 -20
  14. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  15. package/lib/cjs/decorators/operations/route.js +1 -4
  16. package/lib/cjs/decorators/operations/route.js.map +1 -1
  17. package/lib/cjs/domain/DecoratorContext.js +6 -3
  18. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  19. package/lib/cjs/domain/JsonClassStore.js +4 -7
  20. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  21. package/lib/cjs/domain/JsonEntityStore.js +37 -1
  22. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  23. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  24. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  25. package/lib/cjs/domain/JsonMethodStore.js +12 -12
  26. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  27. package/lib/cjs/domain/JsonOperation.js +12 -16
  28. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  29. package/lib/cjs/domain/JsonOperationPathsMap.js +1 -4
  30. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  31. package/lib/cjs/domain/JsonOperationRoute.js +8 -6
  32. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  33. package/lib/cjs/domain/JsonParameter.js +4 -4
  34. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  35. package/lib/cjs/domain/JsonParameterStore.js +12 -5
  36. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  37. package/lib/cjs/domain/JsonPropertyStore.js +1 -4
  38. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  39. package/lib/cjs/domain/JsonResponse.js +3 -6
  40. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  41. package/lib/cjs/domain/JsonSchema.js +58 -60
  42. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  43. package/lib/cjs/hooks/alterIgnore.js +2 -3
  44. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  45. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  46. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  47. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  48. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  49. package/lib/cjs/utils/getJsonSchema.js +4 -5
  50. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  51. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  52. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  53. package/lib/cjs/utils/mapNullableType.js +1 -1
  54. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  55. package/lib/cjs/utils/mergeOperation.js +1 -2
  56. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  57. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  58. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  59. package/lib/cjs/utils/ref.js +2 -2
  60. package/lib/cjs/utils/ref.js.map +1 -1
  61. package/lib/cjs/utils/transformToOS2.js +2 -2
  62. package/lib/cjs/utils/transformToOS2.js.map +1 -1
  63. package/lib/esm/components/lazyRefMapper.js +1 -2
  64. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  65. package/lib/esm/components/objectMapper.js +1 -1
  66. package/lib/esm/components/objectMapper.js.map +1 -1
  67. package/lib/esm/constants/httpStatusMessages.js +2 -4
  68. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  69. package/lib/esm/decorators/collections/collectionOf.js +3 -4
  70. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  71. package/lib/esm/decorators/common/description.js +1 -2
  72. package/lib/esm/decorators/common/description.js.map +1 -1
  73. package/lib/esm/decorators/operations/redirect.js +1 -2
  74. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  75. package/lib/esm/decorators/operations/returns.js +20 -20
  76. package/lib/esm/decorators/operations/returns.js.map +1 -1
  77. package/lib/esm/decorators/operations/route.js +1 -4
  78. package/lib/esm/decorators/operations/route.js.map +1 -1
  79. package/lib/esm/domain/DecoratorContext.js +5 -2
  80. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  81. package/lib/esm/domain/JsonClassStore.js +4 -7
  82. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  83. package/lib/esm/domain/JsonEntityStore.js +37 -1
  84. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  85. package/lib/esm/domain/JsonLazyRef.js +2 -1
  86. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  87. package/lib/esm/domain/JsonMethodStore.js +12 -12
  88. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  89. package/lib/esm/domain/JsonOperation.js +12 -16
  90. package/lib/esm/domain/JsonOperation.js.map +1 -1
  91. package/lib/esm/domain/JsonOperationPathsMap.js +1 -4
  92. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  93. package/lib/esm/domain/JsonOperationRoute.js +8 -6
  94. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  95. package/lib/esm/domain/JsonParameter.js +4 -4
  96. package/lib/esm/domain/JsonParameter.js.map +1 -1
  97. package/lib/esm/domain/JsonParameterStore.js +12 -5
  98. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  99. package/lib/esm/domain/JsonPropertyStore.js +1 -4
  100. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  101. package/lib/esm/domain/JsonResponse.js +3 -6
  102. package/lib/esm/domain/JsonResponse.js.map +1 -1
  103. package/lib/esm/domain/JsonSchema.js +58 -60
  104. package/lib/esm/domain/JsonSchema.js.map +1 -1
  105. package/lib/esm/hooks/alterIgnore.js +2 -3
  106. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  107. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  108. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  109. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  110. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  111. package/lib/esm/utils/getJsonSchema.js +4 -5
  112. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  113. package/lib/esm/utils/getRequiredProperties.js +3 -3
  114. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  115. package/lib/esm/utils/mapNullableType.js +1 -1
  116. package/lib/esm/utils/mapNullableType.js.map +1 -1
  117. package/lib/esm/utils/mergeOperation.js +1 -2
  118. package/lib/esm/utils/mergeOperation.js.map +1 -1
  119. package/lib/esm/utils/operationIdFormatter.js +1 -1
  120. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  121. package/lib/esm/utils/ref.js +1 -1
  122. package/lib/esm/utils/ref.js.map +1 -1
  123. package/lib/esm/utils/transformToOS2.js +2 -2
  124. package/lib/esm/utils/transformToOS2.js.map +1 -1
  125. package/lib/types/utils/getJsonSchema.d.ts +1 -1
  126. package/package.json +12 -10
  127. package/readme.md +2 -1
  128. package/tsconfig.compile.esm.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"JsonEntityStore.js","sourceRoot":"","sources":["../../../src/domain/JsonEntityStore.ts"],"names":[],"mappings":";;;AAAA,qCAgBoB;AAOpB;;GAEG;AACU,QA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CAAC,GAAG,CAAI,GAAG,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAW;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAIS,SAAS,CAAC,IAAS;QAC3B,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAElB,wHAAwH;YACxH,IAAI,IAAI,CAAC,KAAK,IAAI,IAAA,oBAAa,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;aACrB;SACF;IACH,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAAgB;QAC1E,OAAO,eAAe,CAAC,IAAI,CAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC5E,CAAC;CACF;AA/OD,0CA+OC","sourcesContent":["import {\n classOf,\n decoratorTypeOf,\n DecoratorTypes,\n descriptorOf,\n isArrayOrArrayClass,\n isClass,\n isCollection,\n isDate,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n nameOf,\n prototypeOf,\n Store,\n Type\n} from \"@tsed/core\";\nimport type {JsonSchema} from \"./JsonSchema\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\n\n/**\n * @ignore\n */\nexport const JsonEntitiesContainer = new Map<DecoratorTypes, Type<JsonEntityStore>>();\n\nexport interface JsonEntityStoreOptions {\n decoratorType: DecoratorTypes;\n target: Type<any>;\n propertyKey?: string | symbol;\n index?: number;\n descriptor?: any;\n type?: Type<any>;\n collectionType?: Type<any>;\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n\n [key: string]: any;\n}\n\nexport abstract class JsonEntityStore implements JsonEntityStoreOptions {\n /**\n * Original property key decorated by the decorator\n */\n readonly propertyKey: string | symbol;\n /**\n * Alias of the property\n */\n readonly propertyName: string;\n /**\n * Parameter index\n */\n readonly index: number;\n /**\n * Method's descriptor\n */\n readonly descriptor: number;\n /**\n * Decorator type used to declare the JsonSchemaStore.\n */\n readonly decoratorType: DecoratorTypes;\n /**\n * Type of the collection (Array, Map, Set, etc...)\n */\n public collectionType: Type<any>;\n public token: Type<any>;\n readonly store: Store;\n readonly isStore = true;\n readonly parent: JsonEntityStore;\n readonly target: Type<any>;\n /**\n *\n */\n protected _type: Type<any>;\n /**\n * Ref to JsonSchema\n */\n protected _schema: JsonSchema;\n\n [key: string]: any;\n\n constructor(options: JsonEntityStoreOptions) {\n const {target, propertyKey, descriptor, index, decoratorType} = options;\n this.target = target;\n this.propertyKey = propertyKey!;\n this.propertyName = String(propertyKey);\n this.descriptor = descriptor;\n this.index = index!;\n this.decoratorType = decoratorType;\n this.token = target;\n this.store = options.store;\n this.parent = this;\n }\n\n /**\n * Return the class name of the entity.\n * @returns {string}\n */\n get targetName(): string {\n return nameOf(this.token);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isCollection(): boolean {\n return !!this.collectionType;\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isArray() {\n return isArrayOrArrayClass(this.collectionType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isPrimitive() {\n return isPrimitiveOrPrimitiveClass(this._type);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isDate() {\n return isDate(this.computedType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isObject() {\n return isObject(this.computedType);\n }\n\n /**\n *\n */\n get isClass() {\n return isClass(this.computedType);\n }\n\n /**\n * Return the JsonSchema\n */\n get schema(): JsonSchema {\n return this._schema;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.schema.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.schema.nestedGenerics = nestedGenerics;\n }\n\n /**\n *\n * @returns {Type<any>}\n */\n get type(): Type<any> | any {\n return this._type;\n }\n\n /**\n * Get original type without transformation\n * @param value\n */\n set type(value: Type<any> | any) {\n this._type = value;\n this.build();\n }\n\n /**\n * Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to\n * get the right type.\n */\n get computedType() {\n return this.itemSchema.getComputedType();\n }\n\n get itemSchema(): JsonSchema {\n return this.isCollection ? this.schema.itemSchema() : this.schema;\n }\n\n get parentSchema(): JsonSchema {\n return this.parent.schema;\n }\n\n /**\n *\n * @param target\n */\n static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;\n static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;\n static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;\n static from<T extends JsonMethodStore = JsonMethodStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor\n ): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T {\n if (args[0].isStore) {\n return args[0] as T;\n }\n\n const target = args[0];\n\n if (args.length > 1) {\n args[0] = prototypeOf(args[0]);\n }\n\n const store = Store.from(...args);\n\n if (!store.has(\"JsonEntityStore\")) {\n const decoratorType = decoratorTypeOf(args);\n const entityStore = JsonEntitiesContainer.get(decoratorType);\n\n // istanbul ignore next\n if (!entityStore) {\n throw Error(\"Unsupported json entity type\");\n }\n\n const jsonSchemaStore = new entityStore({\n store,\n decoratorType,\n target: classOf(target),\n propertyKey: args[1],\n index: typeof args[2] === \"number\" ? args[2] : undefined,\n descriptor: typeof args[2] === \"object\" ? args[2] : undefined\n });\n\n jsonSchemaStore.build();\n\n store.set(\"JsonEntityStore\", jsonSchemaStore);\n }\n\n return store.get<T>(\"JsonEntityStore\")!;\n }\n\n static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol) {\n return this.from<T>(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n get<T = any>(key: string, defaultValue?: any) {\n return this.store.get<T>(key, defaultValue);\n }\n\n set(key: string, value?: any) {\n return this.store.set(key, value);\n }\n\n protected abstract build(): void;\n\n protected buildType(type: any) {\n if (isCollection(type)) {\n this.collectionType = type;\n } else {\n this._type = type;\n\n // issue #1534: Enum metadata stored as plain object instead of String (see: https://github.com/tsedio/tsed/issues/1534)\n if (this._type && isPlainObject(this._type)) {\n this._type = String;\n }\n }\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: any) {\n return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonEntityStore.js","sourceRoot":"","sources":["../../../src/domain/JsonEntityStore.ts"],"names":[],"mappings":";;;AAAA,qCAgBoB;AAOpB;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAI,GAAG,EAAyC,CAAC;AAiBtF,MAAsB,eAAe;IACnC;;OAEG;IACM,WAAW,CAAkB;IACtC;;OAEG;IACM,YAAY,CAAS;IAC9B;;OAEG;IACM,KAAK,CAAS;IACvB;;OAEG;IACM,UAAU,CAAS;IAC5B;;OAEG;IACM,aAAa,CAAiB;IACvC;;OAEG;IACI,cAAc,CAAY;IAC1B,KAAK,CAAY;IACf,KAAK,CAAQ;IACb,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,CAAkB;IACxB,MAAM,CAAY;IAC3B;;OAEG;IACO,KAAK,CAAY;IAC3B;;OAEG;IACO,OAAO,CAAa;IAI9B,YAAY,OAA+B;QACzC,MAAM,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAC,GAAG,OAAO,CAAC;Q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3B,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAElB,wHAAwH;YACxH,IAAI,IAAI,CAAC,KAAK,IAAI,IAAA,oBAAa,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;aACrB;SACF;IACH,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAAgB;QAC1E,OAAO,eAAe,CAAC,IAAI,CAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC5E,CAAC;CACF;AA/OD,0CA+OC","sourcesContent":["import {\n classOf,\n decoratorTypeOf,\n DecoratorTypes,\n descriptorOf,\n isArrayOrArrayClass,\n isClass,\n isCollection,\n isDate,\n isObject,\n isPlainObject,\n isPrimitiveOrPrimitiveClass,\n nameOf,\n prototypeOf,\n Store,\n Type\n} from \"@tsed/core\";\nimport type {JsonSchema} from \"./JsonSchema\";\nimport type {JsonMethodStore} from \"./JsonMethodStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport type {JsonPropertyStore} from \"./JsonPropertyStore\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\n\n/**\n * @ignore\n */\nexport const JsonEntitiesContainer = new Map<DecoratorTypes, Type<JsonEntityStore>>();\n\nexport interface JsonEntityStoreOptions {\n decoratorType: DecoratorTypes;\n target: Type<any>;\n propertyKey?: string | symbol;\n index?: number;\n descriptor?: any;\n type?: Type<any>;\n collectionType?: Type<any>;\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n\n [key: string]: any;\n}\n\nexport abstract class JsonEntityStore implements JsonEntityStoreOptions {\n /**\n * Original property key decorated by the decorator\n */\n readonly propertyKey: string | symbol;\n /**\n * Alias of the property\n */\n readonly propertyName: string;\n /**\n * Parameter index\n */\n readonly index: number;\n /**\n * Method's descriptor\n */\n readonly descriptor: number;\n /**\n * Decorator type used to declare the JsonSchemaStore.\n */\n readonly decoratorType: DecoratorTypes;\n /**\n * Type of the collection (Array, Map, Set, etc...)\n */\n public collectionType: Type<any>;\n public token: Type<any>;\n readonly store: Store;\n readonly isStore = true;\n readonly parent: JsonEntityStore;\n readonly target: Type<any>;\n /**\n *\n */\n protected _type: Type<any>;\n /**\n * Ref to JsonSchema\n */\n protected _schema: JsonSchema;\n\n [key: string]: any;\n\n constructor(options: JsonEntityStoreOptions) {\n const {target, propertyKey, descriptor, index, decoratorType} = options;\n this.target = target;\n this.propertyKey = propertyKey!;\n this.propertyName = String(propertyKey);\n this.descriptor = descriptor;\n this.index = index!;\n this.decoratorType = decoratorType;\n this.token = target;\n this.store = options.store;\n this.parent = this;\n }\n\n /**\n * Return the class name of the entity.\n * @returns {string}\n */\n get targetName(): string {\n return nameOf(this.token);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isCollection(): boolean {\n return !!this.collectionType;\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isArray() {\n return isArrayOrArrayClass(this.collectionType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isPrimitive() {\n return isPrimitiveOrPrimitiveClass(this._type);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isDate() {\n return isDate(this.computedType);\n }\n\n /**\n *\n * @returns {boolean}\n */\n get isObject() {\n return isObject(this.computedType);\n }\n\n /**\n *\n */\n get isClass() {\n return isClass(this.computedType);\n }\n\n /**\n * Return the JsonSchema\n */\n get schema(): JsonSchema {\n return this._schema;\n }\n\n get nestedGenerics(): Type<any>[][] {\n return this.schema.nestedGenerics;\n }\n\n set nestedGenerics(nestedGenerics: Type<any>[][]) {\n this.schema.nestedGenerics = nestedGenerics;\n }\n\n /**\n *\n * @returns {Type<any>}\n */\n get type(): Type<any> | any {\n return this._type;\n }\n\n /**\n * Get original type without transformation\n * @param value\n */\n set type(value: Type<any> | any) {\n this._type = value;\n this.build();\n }\n\n /**\n * Return the itemSchema computed type. if the type is a function used for recursive model, the function will be called to\n * get the right type.\n */\n get computedType() {\n return this.itemSchema.getComputedType();\n }\n\n get itemSchema(): JsonSchema {\n return this.isCollection ? this.schema.itemSchema() : this.schema;\n }\n\n get parentSchema(): JsonSchema {\n return this.parent.schema;\n }\n\n /**\n *\n * @param target\n */\n static from<T extends JsonClassStore = JsonClassStore>(target: Type<any>): T;\n static from<T extends JsonPropertyStore = JsonPropertyStore>(target: Type<any> | any, propertyKey: string | symbol): T;\n static from<T extends JsonParameterStore = JsonParameterStore>(target: Type<any> | any, propertyKey: string | symbol, index: number): T;\n static from<T extends JsonMethodStore = JsonMethodStore>(\n target: Type<any> | any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor\n ): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T;\n static from<T extends JsonEntityStore = JsonEntityStore>(...args: any[]): T {\n if (args[0].isStore) {\n return args[0] as T;\n }\n\n const target = args[0];\n\n if (args.length > 1) {\n args[0] = prototypeOf(args[0]);\n }\n\n const store = Store.from(...args);\n\n if (!store.has(\"JsonEntityStore\")) {\n const decoratorType = decoratorTypeOf(args);\n const entityStore = JsonEntitiesContainer.get(decoratorType);\n\n // istanbul ignore next\n if (!entityStore) {\n throw Error(\"Unsupported json entity type\");\n }\n\n const jsonSchemaStore = new entityStore({\n store,\n decoratorType,\n target: classOf(target),\n propertyKey: args[1],\n index: typeof args[2] === \"number\" ? args[2] : undefined,\n descriptor: typeof args[2] === \"object\" ? args[2] : undefined\n });\n\n jsonSchemaStore.build();\n\n store.set(\"JsonEntityStore\", jsonSchemaStore);\n }\n\n return store.get<T>(\"JsonEntityStore\")!;\n }\n\n static fromMethod<T extends JsonMethodStore = JsonMethodStore>(target: any, propertyKey: string | symbol) {\n return this.from<T>(target, propertyKey, descriptorOf(target, propertyKey));\n }\n\n get<T = any>(key: string, defaultValue?: any) {\n return this.store.get<T>(key, defaultValue);\n }\n\n set(key: string, value?: any) {\n return this.store.set(key, value);\n }\n\n protected abstract build(): void;\n\n protected buildType(type: any) {\n if (isCollection(type)) {\n this.collectionType = type;\n } else {\n this._type = type;\n\n // issue #1534: Enum metadata stored as plain object instead of String (see: https://github.com/tsedio/tsed/issues/1534)\n if (this._type && isPlainObject(this._type)) {\n this._type = String;\n }\n }\n }\n\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: any) {\n return JsonEntityStore.from(prototypeOf(target), propertyKey, descriptor);\n }\n}\n"]}
@@ -5,9 +5,10 @@ const core_1 = require("@tsed/core");
5
5
  const JsonSchemaMapperContainer_1 = require("../registries/JsonSchemaMapperContainer");
6
6
  const getJsonEntityStore_1 = require("../utils/getJsonEntityStore");
7
7
  class JsonLazyRef {
8
+ getType;
9
+ isLazyRef = true;
8
10
  constructor(getType) {
9
11
  this.getType = getType;
10
- this.isLazyRef = true;
11
12
  }
12
13
  get target() {
13
14
  return this.getType();
@@ -1 +1 @@
1
- {"version":3,"file":"JsonLazyRef.js","sourceRoot":"","sources":["../../../src/domain/JsonLazyRef.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC,uFAAmE;AACnE,oEAA+D;AAE/D,MAAa,WAAW;IAGtB,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAFpC,cAAS,GAAG,IAAI,CAAC;IAEsB,CAAC;IAEjD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAA,uCAAkB,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,IAAA,sCAAU,EAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;CACF;AApBD,kCAoBC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"../utils/getJsonEntityStore\";\n\nexport class JsonLazyRef {\n readonly isLazyRef = true;\n\n constructor(readonly getType: () => Type<any>) {}\n\n get target() {\n return this.getType();\n }\n\n get schema() {\n return getJsonEntityStore(this.getType()).schema;\n }\n\n get name() {\n return nameOf(this.getType());\n }\n\n toJSON(options?: JsonSchemaOptions) {\n return this.getType() && execMapper(\"schema\", this.schema, options);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonLazyRef.js","sourceRoot":"","sources":["../../../src/domain/JsonLazyRef.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAExC,uFAAmE;AACnE,oEAA+D;AAE/D,MAAa,WAAW;IAGD;IAFZ,SAAS,GAAG,IAAI,CAAC;IAE1B,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEjD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAA,uCAAkB,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,OAA2B;QAChC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,IAAA,sCAAU,EAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;CACF;AApBD,kCAoBC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getJsonEntityStore} from \"../utils/getJsonEntityStore\";\n\nexport class JsonLazyRef {\n readonly isLazyRef = true;\n\n constructor(readonly getType: () => Type<any>) {}\n\n get target() {\n return this.getType();\n }\n\n get schema() {\n return getJsonEntityStore(this.getType()).schema;\n }\n\n get name() {\n return nameOf(this.getType());\n }\n\n toJSON(options?: JsonSchemaOptions) {\n return this.getType() && execMapper(\"schema\", this.schema, options);\n }\n}\n"]}
@@ -8,24 +8,24 @@ const JsonOperation_1 = require("./JsonOperation");
8
8
  const JsonSchema_1 = require("./JsonSchema");
9
9
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
10
10
  let JsonMethodStore = class JsonMethodStore extends JsonEntityStore_1.JsonEntityStore {
11
+ parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
12
+ middlewares = [];
13
+ beforeMiddlewares = [];
14
+ afterMiddlewares = [];
15
+ /**
16
+ * Ref to JsonOperation when the decorated object is a method.
17
+ */
18
+ operation = new JsonOperation_1.JsonOperation();
19
+ /**
20
+ * List of children JsonEntityStore (properties or methods or params)
21
+ */
22
+ children = new Map();
11
23
  constructor(options) {
12
24
  super({
13
25
  store: core_1.Store.fromMethod(options.target, options.propertyKey),
14
26
  descriptor: (0, core_1.descriptorOf)(options.target, options.propertyKey),
15
27
  ...options
16
28
  });
17
- this.parent = JsonEntityStore_1.JsonEntityStore.from(this.target);
18
- this.middlewares = [];
19
- this.beforeMiddlewares = [];
20
- this.afterMiddlewares = [];
21
- /**
22
- * Ref to JsonOperation when the decorated object is a method.
23
- */
24
- this.operation = new JsonOperation_1.JsonOperation();
25
- /**
26
- * List of children JsonEntityStore (properties or methods or params)
27
- */
28
- this.children = new Map();
29
29
  const { beforeMiddlewares = [], middlewares = [], afterMiddlewares = [] } = options;
30
30
  this.after(afterMiddlewares);
31
31
  this.before(beforeMiddlewares);
@@ -1 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AC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;YACtE,IAAI,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;YAE1C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QAElC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAElD,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;YACjC,aAAa;YACb,OAAO,IAAI,CAAC,KAAK,CAAC;SACnB;QAED,IAAI,CAAC,OAAO,GAAG,uBAAU,CAAC,IAAI,CAAC;YAC7B,IAAI,EAAE,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI;SACvC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACpC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AAlKY,eAAe;IAD3B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;;GAC9B,eAAe,CAkK3B;AAlKY,0CAAe;AAuLf,QAAA,gBAAgB,GAAG,eAAe,CAAC","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonOperation} from \"./JsonOperation\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonViewOptions {\n path: string;\n options: any;\n}\n\nexport interface JsonRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class JsonMethodStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n public middlewares: any[] = [];\n public beforeMiddlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n /**\n * Ref to JsonOperation when the decorated object is a method.\n */\n readonly operation: JsonOperation = new JsonOperation();\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonParameterStore> = new Map();\n\n constructor(options: JsonEntityStoreOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get params(): JsonParameterStore[] {\n return this.parameters;\n }\n\n get view(): JsonViewOptions {\n return this.store.get(\"view\") as JsonViewOptions;\n }\n\n set view(view: JsonViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n get parameters(): JsonParameterStore[] {\n return [...this.children.values()] as JsonParameterStore[];\n }\n\n get operationPaths() {\n return this.operation.operationPaths;\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<JsonMethodStore>(prototypeOf(target), propertyKey, descriptor);\n }\n\n getResponseOptions(status: number, contentType: string = \"application/json\"): undefined | any {\n const media = this.operation.getResponseOf(status).getMedia(contentType, false);\n\n if (media && media.has(\"schema\")) {\n const schema = media.get(\"schema\") as JsonSchema;\n\n return {type: schema.getComputedItemType(), groups: media.groups};\n }\n\n return {type: this.type};\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n public get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n public getParamTypes(): Record<string, boolean> {\n return [...this.children.values()].reduce(\n (obj, item) => ({\n ...obj,\n [item.paramType]: true\n }),\n {}\n );\n }\n\n protected build() {\n if (!this._type) {\n let type: any = Metadata.getReturnType(this.target, this.propertyKey);\n type = isPromise(type) ? undefined : type;\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n this.parent.children.set(this.propertyName, this);\n\n if (isCollection(this._type)) {\n this.collectionType = this._type;\n // @ts-ignore\n delete this._type;\n }\n\n this._schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n this._schema.itemSchema(this.type);\n }\n\n this.parent.schema.addProperty(this.propertyName, this.schema);\n }\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored into endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *```typescript\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *```\n *\n * @alias JsonMethodStore\n */\nexport type EndpointMetadata = JsonMethodStore;\nexport const EndpointMetadata = JsonMethodStore;\n"]}
1
+ {"version":3,"file":"JsonMethodStore.js","sourceRoot":"","sources":["../../../src/domain/JsonMethodStore.ts"],"names":[],"mappings":";;;;AAAA,qCAA4I;AAC5I,uDAA0E;AAC1E,mDAA8C;AAC9C,6CAAwC;AAGxC,kFAA6E;AAa7E,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,iCAAe;IACzC,MAAM,GAAmB,iCAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7D,WAAW,GAAU,EAAE,CAAC;IACxB,iBAAiB,GAAU,EAAE,CAAC;IAC9B,gBAAgB,GAAU,EAAE,CAAC;IACpC;;OAEG;IACM,SAAS,GAAkB,IAAI,6BAAa,EAAE,CAAC;IACxD;;OAEG;IACM,QAAQ,GAA6C,IAAI,GAAG,EAAE,CAAC;IAExE,YAAY,OAA+B;QACzC,KAAK,CAAC;YACJ,KAAK,EAAE,YAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC7D,UAAU,EAAE,IAAA,mBAAY,EAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC9D,GAAG,OAAO;SACX,CAAC,CAAC;QAEH,MAAM,EAAC,iBAAiB,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAC,GAAG,OAAO,CAAC;QAElF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC7B,IAAI,CAAC,MA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Ae;IAD3B,IAAA,yCAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;;GAC9B,eAAe,CAkK3B;AAlKY,0CAAe;AAuLf,QAAA,gBAAgB,GAAG,eAAe,CAAC","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {JsonEntityStore, JsonEntityStoreOptions} from \"./JsonEntityStore\";\nimport {JsonOperation} from \"./JsonOperation\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport type {JsonParameterStore} from \"./JsonParameterStore\";\nimport type {JsonClassStore} from \"./JsonClassStore\";\nimport {JsonEntityComponent} from \"../decorators/config/jsonEntityComponent\";\n\nexport interface JsonViewOptions {\n path: string;\n options: any;\n}\n\nexport interface JsonRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class JsonMethodStore extends JsonEntityStore {\n readonly parent: JsonClassStore = JsonEntityStore.from(this.target);\n public middlewares: any[] = [];\n public beforeMiddlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n /**\n * Ref to JsonOperation when the decorated object is a method.\n */\n readonly operation: JsonOperation = new JsonOperation();\n /**\n * List of children JsonEntityStore (properties or methods or params)\n */\n readonly children: Map<string | number, JsonParameterStore> = new Map();\n\n constructor(options: JsonEntityStoreOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get params(): JsonParameterStore[] {\n return this.parameters;\n }\n\n get view(): JsonViewOptions {\n return this.store.get(\"view\") as JsonViewOptions;\n }\n\n set view(view: JsonViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n get parameters(): JsonParameterStore[] {\n return [...this.children.values()] as JsonParameterStore[];\n }\n\n get operationPaths() {\n return this.operation.operationPaths;\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): JsonMethodStore {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<JsonMethodStore>(prototypeOf(target), propertyKey, descriptor);\n }\n\n getResponseOptions(status: number, contentType: string = \"application/json\"): undefined | any {\n const media = this.operation.getResponseOf(status).getMedia(contentType, false);\n\n if (media && media.has(\"schema\")) {\n const schema = media.get(\"schema\") as JsonSchema;\n\n return {type: schema.getComputedItemType(), groups: media.groups};\n }\n\n return {type: this.type};\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Find the value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n public get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n public getParamTypes(): Record<string, boolean> {\n return [...this.children.values()].reduce(\n (obj, item) => ({\n ...obj,\n [item.paramType]: true\n }),\n {}\n );\n }\n\n protected build() {\n if (!this._type) {\n let type: any = Metadata.getReturnType(this.target, this.propertyKey);\n type = isPromise(type) ? undefined : type;\n\n this.buildType(type);\n }\n\n this._type = this._type || Object;\n\n this.parent.children.set(this.propertyName, this);\n\n if (isCollection(this._type)) {\n this.collectionType = this._type;\n // @ts-ignore\n delete this._type;\n }\n\n this._schema = JsonSchema.from({\n type: this.collectionType || this.type\n });\n\n if (this.collectionType) {\n this._schema.itemSchema(this.type);\n }\n\n this.parent.schema.addProperty(this.propertyName, this.schema);\n }\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored into endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *```typescript\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *```\n *\n * @alias JsonMethodStore\n */\nexport type EndpointMetadata = JsonMethodStore;\nexport const EndpointMetadata = JsonMethodStore;\n"]}
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _JsonOperation_status, _JsonOperation_redirection;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.JsonOperation = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const core_1 = require("@tsed/core");
7
5
  const httpStatusMessages_1 = require("../constants/httpStatusMessages");
8
6
  const isSuccessStatus_1 = require("../utils/isSuccessStatus");
@@ -12,17 +10,17 @@ const JsonRequestBody_1 = require("./JsonRequestBody");
12
10
  const JsonResponse_1 = require("./JsonResponse");
13
11
  const JsonSchema_1 = require("./JsonSchema");
14
12
  class JsonOperation extends JsonMap_1.JsonMap {
13
+ operationPaths = new Map();
14
+ #status;
15
+ #redirection = false;
15
16
  constructor(obj = {}) {
16
17
  super({ parameters: [], responses: new JsonMap_1.JsonMap(), ...obj });
17
- this.operationPaths = new Map();
18
- _JsonOperation_status.set(this, void 0);
19
- _JsonOperation_redirection.set(this, false);
20
18
  }
21
19
  get response() {
22
20
  return this.getResponses().get(this.getStatus().toString());
23
21
  }
24
22
  get status() {
25
- return tslib_1.__classPrivateFieldGet(this, _JsonOperation_status, "f");
23
+ return this.#status;
26
24
  }
27
25
  tags(tags) {
28
26
  super.set("tags", tags);
@@ -45,27 +43,27 @@ class JsonOperation extends JsonMap_1.JsonMap {
45
43
  return this;
46
44
  }
47
45
  defaultStatus(status) {
48
- tslib_1.__classPrivateFieldSet(this, _JsonOperation_status, status, "f");
46
+ this.#status = status;
49
47
  return this;
50
48
  }
51
49
  getStatus() {
52
- return tslib_1.__classPrivateFieldGet(this, _JsonOperation_status, "f") || 200;
50
+ return this.#status || 200;
53
51
  }
54
52
  setRedirection(status = 302) {
55
- tslib_1.__classPrivateFieldSet(this, _JsonOperation_redirection, true, "f");
56
- tslib_1.__classPrivateFieldSet(this, _JsonOperation_status, status, "f");
53
+ this.#redirection = true;
54
+ this.#status = status;
57
55
  return this;
58
56
  }
59
57
  isRedirection(status) {
60
- if (tslib_1.__classPrivateFieldGet(this, _JsonOperation_redirection, "f")) {
58
+ if (this.#redirection) {
61
59
  if (status) {
62
60
  return (0, isSuccessStatus_1.isRedirectionStatus)(status);
63
61
  }
64
62
  }
65
- return tslib_1.__classPrivateFieldGet(this, _JsonOperation_redirection, "f");
63
+ return this.#redirection;
66
64
  }
67
65
  addResponse(statusCode, response) {
68
- if (((0, isSuccessStatus_1.isSuccessStatus)(statusCode) || (0, isSuccessStatus_1.isRedirectionStatus)(statusCode)) && !tslib_1.__classPrivateFieldGet(this, _JsonOperation_status, "f")) {
66
+ if (((0, isSuccessStatus_1.isSuccessStatus)(statusCode) || (0, isSuccessStatus_1.isRedirectionStatus)(statusCode)) && !this.#status) {
69
67
  const res = this.getResponseOf(200);
70
68
  this.getResponses().set(statusCode.toString(), res).delete("200");
71
69
  this.defaultStatus(Number(statusCode));
@@ -186,11 +184,9 @@ class JsonOperation extends JsonMap_1.JsonMap {
186
184
  }
187
185
  }
188
186
  exports.JsonOperation = JsonOperation;
189
- _JsonOperation_status = new WeakMap(), _JsonOperation_redirection = new WeakMap();
190
187
  function toRequestBody(operation, { schema, in: _, ...props }) {
191
- var _a;
192
188
  const requestBody = new JsonRequestBody_1.JsonRequestBody(props);
193
- const consumes = ((_a = operation.get("consumes")) === null || _a === void 0 ? void 0 : _a.length) ? operation.get("consumes") : ["application/json"];
189
+ const consumes = operation.get("consumes")?.length ? operation.get("consumes") : ["application/json"];
194
190
  consumes.forEach((consume) => {
195
191
  requestBody.addContent(consume, schema);
196
192
  });
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":";;;;;AAAA,qCAAmD;AAEnD,wEAAiE;AAGjE,8DAA8E;AAC9E,uCAAkC;AAElC,6DAAyE;AACzE,uDAAkD;AAClD,iDAA4C;AAC5C,6CAAwC;AAexC,MAAa,aAAc,SAAQ,iBAA6B;IAK9D,YAAY,MAAqC,EAAE;QACjD,KAAK,CAAC,EAAC,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,iBAAO,EAAE,EAAE,GAAG,GAAG,EAAC,CAAC,CAAC;QALnD,mBAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;QACjE,wCAAgB;QAChB,qCAAwB,KAAK,EAAC;IAI9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,MAAM;QACR,OAAO,+BAAA,IAAI,6BAAQ,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAmB;QACtB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,IAAmB;QACzB,IAAI,GAAG,IAAA,aAAM,EAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAA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O,EAAE,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;aAChD,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACxB,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;gBAC5B,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;QAEL,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEhD,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,WAAW,CAChB,IAAI,EACJ,aAAa,CAAC,MAAM,IAAI;gBACtB,IAAI,EAAE,aAAa,CAAC,IAAI;aACzB,CACF,CAAC;YAEF,IAAI,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC7B,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aAC1B;YAED,WAAW,EAAE,CAAC;SACf;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,WAAW,EAAE;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;SAChB;KACF;IAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEtB,OAAO,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAC,CAAC;AACrE,CAAC","sourcesContent":["import {deepMerge, uniq, uniqBy} from \"@tsed/core\";\nimport {OpenSpecSecurity, OpenSpecTag, OS3Operation} from \"@tsed/openspec\";\nimport {getStatusMessage} from \"../constants/httpStatusMessages\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {isRedirectionStatus, isSuccessStatus} from \"../utils/isSuccessStatus\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonRequestBody} from \"./JsonRequestBody\";\nimport {JsonResponse} from \"./JsonResponse\";\nimport {JsonSchema} from \"./JsonSchema\";\n\nexport interface JsonMethodPath {\n path: string | RegExp;\n method: string;\n isFinal?: boolean;\n\n [key: string]: any;\n}\n\nexport interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {\n consumes: string[];\n produces: string[];\n}\n\nexport class JsonOperation extends JsonMap<JsonOperationOptions> {\n readonly operationPaths: Map<string, JsonMethodPath> = new Map();\n #status: number;\n #redirection: boolean = false;\n\n constructor(obj: Partial<JsonOperationOptions> = {}) {\n super({parameters: [], responses: new JsonMap(), ...obj});\n }\n\n get response(): JsonResponse | undefined {\n return this.getResponses().get(this.getStatus().toString());\n }\n\n get status() {\n return this.#status;\n }\n\n tags(tags: OpenSpecTag[]): this {\n super.set(\"tags\", tags);\n\n return this;\n }\n\n addTags(tags: OpenSpecTag[]) {\n tags = uniqBy([...(this.get(\"tags\") || []), ...tags], \"name\");\n\n return this.tags(tags);\n }\n\n summary(summary: string): this {\n super.set(\"summary\", summary);\n\n return this;\n }\n\n operationId(operationId: string): this {\n this.set(\"operationId\", operationId);\n\n return this;\n }\n\n responses(responses: JsonMap<any>): this {\n this.set(\"responses\", responses);\n\n return this;\n }\n\n defaultStatus(status: number) {\n this.#status = status;\n\n return this;\n }\n\n getStatus() {\n return this.#status || 200;\n }\n\n setRedirection(status = 302) {\n this.#redirection = true;\n this.#status = status;\n return this;\n }\n\n isRedirection(status?: number) {\n if (this.#redirection) {\n if (status) {\n return isRedirectionStatus(status);\n }\n }\n\n return this.#redirection;\n }\n\n addResponse(statusCode: string | number, response: JsonResponse) {\n if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !this.#status) {\n const res = this.getResponseOf(200);\n\n this.getResponses().set(statusCode.toString(), res).delete(\"200\");\n\n this.defaultStatus(Number(statusCode));\n }\n\n const currentCode = statusCode === \"default\" ? this.getStatus().toString() : statusCode.toString();\n const currentResponse = this.getResponses().get(currentCode);\n\n if (!currentResponse) {\n response.status = Number(currentCode);\n this.getResponses().set(currentCode, response);\n } else {\n response.forEach((value, key) => {\n if (![\"content\"].includes(key)) {\n currentResponse.set(key, deepMerge(currentResponse.get(key), value));\n }\n });\n currentResponse.status = Number(currentCode);\n }\n\n return this;\n }\n\n getResponses() {\n return this.get(\"responses\") as JsonMap<JsonResponse>;\n }\n\n getResponseOf(status: number | string): JsonResponse {\n return (status === \"default\" ? this.response : this.getResponses().get(String(status))) || new JsonResponse();\n }\n\n ensureResponseOf(status: number | string): JsonResponse {\n this.addResponse(status, this.getResponseOf(status));\n return this.getResponseOf(status);\n }\n\n getHeadersOf(status: number): Record<string, JsonHeader & {example: string}> {\n return this.getResponseOf(status).get(\"headers\") || {};\n }\n\n getContentTypeOf(status: number): any {\n return [...this.getResponseOf(status).get(\"content\").keys()].slice(-1)[0];\n }\n\n security(security: OpenSpecSecurity): this {\n this.set(\"security\", security);\n\n return this;\n }\n\n addSecurityScopes(name: string, scopes: string[]) {\n const security = this.get(\"security\") || {};\n security[name] = uniq([...(security[name] || []), ...scopes]);\n\n return this.security(security);\n }\n\n description(description: string): this {\n super.set(\"description\", description);\n\n return this;\n }\n\n deprecated(deprecated: boolean): this {\n super.set(\"deprecated\", deprecated);\n\n return this;\n }\n\n parameters(parameters: JsonParameter[]): this {\n super.set(\"parameters\", parameters);\n\n return this;\n }\n\n addParameter(index: number, parameter: JsonParameter) {\n if (index === -1) {\n index = this.get(\"parameters\").length;\n }\n this.get(\"parameters\")[index] = parameter;\n }\n\n consumes(consumes: string[]): this {\n super.set(\"consumes\", consumes);\n\n return this;\n }\n\n produces(produces: string[]): this {\n super.set(\"produces\", produces);\n\n return this;\n }\n\n addProduce(produce: string) {\n const produces = uniq([].concat(this.get(\"produces\"), produce as never)).filter(Boolean);\n\n this.set(\"produces\", produces);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n this.operationPaths.set(String(method) + String(path), {\n ...options,\n method,\n path\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const operation = super.toJSON({...options, ignore: [\"parameters\"]});\n const bodyParameters: JsonParameter[] = [];\n const parameters: any[] = [];\n\n if (operation.security) {\n operation.security = [].concat(operation.security);\n }\n\n this.get(\"parameters\").forEach((parameter: JsonParameter) => {\n if (!isParameterType(this.get(\"in\"))) {\n if (parameter.get(\"in\")) {\n if ([JsonParameterTypes.BODY, JsonParameterTypes.FILES].includes(parameter.get(\"in\"))) {\n bodyParameters.push(parameter);\n } else {\n parameters.push(...[].concat(parameter.toJSON(options)));\n }\n }\n }\n });\n\n operation.parameters = parameters.filter(Boolean);\n\n if (this.get(\"responses\").size === 0) {\n operation.responses = {\n \"200\": {\n description: getStatusMessage(200)\n }\n };\n }\n\n if (bodyParameters.length) {\n const parameter = buildSchemaFromBodyParameters(bodyParameters, options);\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n }\n\n delete operation.consumes;\n delete operation.produces;\n\n return operation;\n }\n}\n\nfunction toRequestBody(operation: JsonOperation, {schema, in: _, ...props}: any) {\n const requestBody = new JsonRequestBody(props);\n\n const consumes = operation.get(\"consumes\")?.length ? operation.get(\"consumes\") : [\"application/json\"];\n\n consumes.forEach((consume: string) => {\n requestBody.addContent(consume, schema);\n });\n\n return requestBody;\n}\n\nfunction buildSchemaFromBodyParameters(parameters: JsonParameter[], options: JsonSchemaOptions) {\n let schema = new JsonSchema();\n const props: any = {};\n const refs: JsonSchema[] = [];\n let propsLength = 0;\n\n parameters.forEach((parameter) => {\n const name = parameter.getName();\n\n Array.from(parameter.entries())\n .filter(([key]) => ![\"in\", \"name\"].includes(key))\n .forEach(([key, value]) => {\n if (props[key] === undefined) {\n props[key] = value;\n }\n });\n\n const jsonParameter = parameter.toJSON(options);\n\n if (name) {\n schema.addProperty(\n name,\n jsonParameter.schema || {\n type: jsonParameter.type\n }\n );\n\n if (parameter.get(\"required\")) {\n schema.addRequired(name);\n }\n\n propsLength++;\n } else {\n refs.push(jsonParameter);\n }\n });\n\n if (!propsLength) {\n if (refs.length === 1) {\n return refs[0];\n }\n }\n\n schema.type(\"object\");\n\n return {schema: schema.toJSON(options), required: false, ...props};\n}\n"]}
1
+ {"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAEnD,wEAAiE;AAGjE,8DAA8E;AAC9E,uCAAkC;AAElC,6DAAyE;AACzE,uDAAkD;AAClD,iDAA4C;AAC5C,6CAAwC;AAexC,MAAa,aAAc,SAAQ,iBAA6B;IACrD,cAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;IACjE,OAAO,CAAS;IAChB,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,MAAqC,EAAE;QACjD,KAAK,CAAC,EAAC,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,iBAAO,EAAE,EAAE,GAAG,GAAG,EAAC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,IAAmB;QACtB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,IAAmB;QACzB,IAAI,GAAG,IAAA,aAA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} from \"@tsed/openspec\";\nimport {getStatusMessage} from \"../constants/httpStatusMessages\";\nimport {JsonHeader} from \"../interfaces/JsonOpenSpec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {isRedirectionStatus, isSuccessStatus} from \"../utils/isSuccessStatus\";\nimport {JsonMap} from \"./JsonMap\";\nimport {JsonParameter} from \"./JsonParameter\";\nimport {isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonRequestBody} from \"./JsonRequestBody\";\nimport {JsonResponse} from \"./JsonResponse\";\nimport {JsonSchema} from \"./JsonSchema\";\n\nexport interface JsonMethodPath {\n path: string | RegExp;\n method: string;\n isFinal?: boolean;\n\n [key: string]: any;\n}\n\nexport interface JsonOperationOptions extends OS3Operation<JsonSchema, JsonParameter, JsonMap<JsonResponse>> {\n consumes: string[];\n produces: string[];\n}\n\nexport class JsonOperation extends JsonMap<JsonOperationOptions> {\n readonly operationPaths: Map<string, JsonMethodPath> = new Map();\n #status: number;\n #redirection: boolean = false;\n\n constructor(obj: Partial<JsonOperationOptions> = {}) {\n super({parameters: [], responses: new JsonMap(), ...obj});\n }\n\n get response(): JsonResponse | undefined {\n return this.getResponses().get(this.getStatus().toString());\n }\n\n get status() {\n return this.#status;\n }\n\n tags(tags: OpenSpecTag[]): this {\n super.set(\"tags\", tags);\n\n return this;\n }\n\n addTags(tags: OpenSpecTag[]) {\n tags = uniqBy([...(this.get(\"tags\") || []), ...tags], \"name\");\n\n return this.tags(tags);\n }\n\n summary(summary: string): this {\n super.set(\"summary\", summary);\n\n return this;\n }\n\n operationId(operationId: string): this {\n this.set(\"operationId\", operationId);\n\n return this;\n }\n\n responses(responses: JsonMap<any>): this {\n this.set(\"responses\", responses);\n\n return this;\n }\n\n defaultStatus(status: number) {\n this.#status = status;\n\n return this;\n }\n\n getStatus() {\n return this.#status || 200;\n }\n\n setRedirection(status = 302) {\n this.#redirection = true;\n this.#status = status;\n return this;\n }\n\n isRedirection(status?: number) {\n if (this.#redirection) {\n if (status) {\n return isRedirectionStatus(status);\n }\n }\n\n return this.#redirection;\n }\n\n addResponse(statusCode: string | number, response: JsonResponse) {\n if ((isSuccessStatus(statusCode) || isRedirectionStatus(statusCode)) && !this.#status) {\n const res = this.getResponseOf(200);\n\n this.getResponses().set(statusCode.toString(), res).delete(\"200\");\n\n this.defaultStatus(Number(statusCode));\n }\n\n const currentCode = statusCode === \"default\" ? this.getStatus().toString() : statusCode.toString();\n const currentResponse = this.getResponses().get(currentCode);\n\n if (!currentResponse) {\n response.status = Number(currentCode);\n this.getResponses().set(currentCode, response);\n } else {\n response.forEach((value, key) => {\n if (![\"content\"].includes(key)) {\n currentResponse.set(key, deepMerge(currentResponse.get(key), value));\n }\n });\n currentResponse.status = Number(currentCode);\n }\n\n return this;\n }\n\n getResponses() {\n return this.get(\"responses\") as JsonMap<JsonResponse>;\n }\n\n getResponseOf(status: number | string): JsonResponse {\n return (status === \"default\" ? this.response : this.getResponses().get(String(status))) || new JsonResponse();\n }\n\n ensureResponseOf(status: number | string): JsonResponse {\n this.addResponse(status, this.getResponseOf(status));\n return this.getResponseOf(status);\n }\n\n getHeadersOf(status: number): Record<string, JsonHeader & {example: string}> {\n return this.getResponseOf(status).get(\"headers\") || {};\n }\n\n getContentTypeOf(status: number): any {\n return [...this.getResponseOf(status).get(\"content\").keys()].slice(-1)[0];\n }\n\n security(security: OpenSpecSecurity): this {\n this.set(\"security\", security);\n\n return this;\n }\n\n addSecurityScopes(name: string, scopes: string[]) {\n const security = this.get(\"security\") || {};\n security[name] = uniq([...(security[name] || []), ...scopes]);\n\n return this.security(security);\n }\n\n description(description: string): this {\n super.set(\"description\", description);\n\n return this;\n }\n\n deprecated(deprecated: boolean): this {\n super.set(\"deprecated\", deprecated);\n\n return this;\n }\n\n parameters(parameters: JsonParameter[]): this {\n super.set(\"parameters\", parameters);\n\n return this;\n }\n\n addParameter(index: number, parameter: JsonParameter) {\n if (index === -1) {\n index = this.get(\"parameters\").length;\n }\n this.get(\"parameters\")[index] = parameter;\n }\n\n consumes(consumes: string[]): this {\n super.set(\"consumes\", consumes);\n\n return this;\n }\n\n produces(produces: string[]): this {\n super.set(\"produces\", produces);\n\n return this;\n }\n\n addProduce(produce: string) {\n const produces = uniq([].concat(this.get(\"produces\"), produce as never)).filter(Boolean);\n\n this.set(\"produces\", produces);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n this.operationPaths.set(String(method) + String(path), {\n ...options,\n method,\n path\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}): any {\n const operation = super.toJSON({...options, ignore: [\"parameters\"]});\n const bodyParameters: JsonParameter[] = [];\n const parameters: any[] = [];\n\n if (operation.security) {\n operation.security = [].concat(operation.security);\n }\n\n this.get(\"parameters\").forEach((parameter: JsonParameter) => {\n if (!isParameterType(this.get(\"in\"))) {\n if (parameter.get(\"in\")) {\n if ([JsonParameterTypes.BODY, JsonParameterTypes.FILES].includes(parameter.get(\"in\"))) {\n bodyParameters.push(parameter);\n } else {\n parameters.push(...[].concat(parameter.toJSON(options)));\n }\n }\n }\n });\n\n operation.parameters = parameters.filter(Boolean);\n\n if (this.get(\"responses\").size === 0) {\n operation.responses = {\n \"200\": {\n description: getStatusMessage(200)\n }\n };\n }\n\n if (bodyParameters.length) {\n const parameter = buildSchemaFromBodyParameters(bodyParameters, options);\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n }\n\n delete operation.consumes;\n delete operation.produces;\n\n return operation;\n }\n}\n\nfunction toRequestBody(operation: JsonOperation, {schema, in: _, ...props}: any) {\n const requestBody = new JsonRequestBody(props);\n\n const consumes = operation.get(\"consumes\")?.length ? operation.get(\"consumes\") : [\"application/json\"];\n\n consumes.forEach((consume: string) => {\n requestBody.addContent(consume, schema);\n });\n\n return requestBody;\n}\n\nfunction buildSchemaFromBodyParameters(parameters: JsonParameter[], options: JsonSchemaOptions) {\n let schema = new JsonSchema();\n const props: any = {};\n const refs: JsonSchema[] = [];\n let propsLength = 0;\n\n parameters.forEach((parameter) => {\n const name = parameter.getName();\n\n Array.from(parameter.entries())\n .filter(([key]) => ![\"in\", \"name\"].includes(key))\n .forEach(([key, value]) => {\n if (props[key] === undefined) {\n props[key] = value;\n }\n });\n\n const jsonParameter = parameter.toJSON(options);\n\n if (name) {\n schema.addProperty(\n name,\n jsonParameter.schema || {\n type: jsonParameter.type\n }\n );\n\n if (parameter.get(\"required\")) {\n schema.addRequired(name);\n }\n\n propsLength++;\n } else {\n refs.push(jsonParameter);\n }\n });\n\n if (!propsLength) {\n if (refs.length === 1) {\n return refs[0];\n }\n }\n\n schema.type(\"object\");\n\n return {schema: schema.toJSON(options), required: false, ...props};\n}\n"]}
@@ -3,10 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonOperationPathsMap = void 0;
4
4
  const httpMethods_1 = require("../constants/httpMethods");
5
5
  class JsonOperationPathsMap extends Map {
6
- constructor() {
7
- super(...arguments);
8
- this.getKey = (method, path) => `${method}-${path}`;
9
- }
10
6
  setOperationPath(operationPath) {
11
7
  if (operationPath.method !== httpMethods_1.OperationMethods.CUSTOM) {
12
8
  const key = this.getKey(operationPath.method, operationPath.path);
@@ -15,6 +11,7 @@ class JsonOperationPathsMap extends Map {
15
11
  this.setFinalRoute(key, operationPath);
16
12
  }
17
13
  }
14
+ getKey = (method, path) => `${method}-${path}`;
18
15
  updateFinalRouteState(key) {
19
16
  if (this.has(key)) {
20
17
  this.get(key).isFinal = false;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperationPathsMap.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationPathsMap.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAG1D,MAAa,qBAAsB,SAAQ,GAA2B;IAAtE;;QAUY,WAAM,GAAG,CAAC,MAAc,EAAE,IAAS,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;IAYxE,CAAC;IArBC,gBAAgB,CAAC,aAA6B;QAC5C,IAAI,aAAa,CAAC,MAAM,KAAK,8BAAgB,CAAC,MAAM,EAAE;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YAClE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,8BAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACxC;IACH,CAAC;IAIS,qBAAqB,CAAC,GAAW;QACzC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,GAAG,KAAK,CAAC;SAChC;IACH,CAAC;IAES,aAAa,CAAC,GAAW,EAAE,aAA6B;QAChE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAC7B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAtBD,sDAsBC","sourcesContent":["import {OperationMethods} from \"../constants/httpMethods\";\nimport {JsonMethodPath} from \"./JsonOperation\";\n\nexport class JsonOperationPathsMap extends Map<string, JsonMethodPath> {\n setOperationPath(operationPath: JsonMethodPath) {\n if (operationPath.method !== OperationMethods.CUSTOM) {\n const key = this.getKey(operationPath.method, operationPath.path);\n this.updateFinalRouteState(key);\n this.updateFinalRouteState(this.getKey(OperationMethods.ALL, operationPath.path));\n this.setFinalRoute(key, operationPath);\n }\n }\n\n protected getKey = (method: string, path: any) => `${method}-${path}`;\n\n protected updateFinalRouteState(key: string) {\n if (this.has(key)) {\n this.get(key)!.isFinal = false;\n }\n }\n\n protected setFinalRoute(key: string, operationPath: JsonMethodPath) {\n this.set(key, operationPath);\n operationPath.isFinal = true;\n }\n}\n"]}
1
+ {"version":3,"file":"JsonOperationPathsMap.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationPathsMap.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAG1D,MAAa,qBAAsB,SAAQ,GAA2B;IACpE,gBAAgB,CAAC,aAA6B;QAC5C,IAAI,aAAa,CAAC,MAAM,KAAK,8BAAgB,CAAC,MAAM,EAAE;YACpD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YAClE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,8BAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;SACxC;IACH,CAAC;IAES,MAAM,GAAG,CAAC,MAAc,EAAE,IAAS,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;IAE5D,qBAAqB,CAAC,GAAW;QACzC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,OAAO,GAAG,KAAK,CAAC;SAChC;IACH,CAAC;IAES,aAAa,CAAC,GAAW,EAAE,aAA6B;QAChE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAC7B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAtBD,sDAsBC","sourcesContent":["import {OperationMethods} from \"../constants/httpMethods\";\nimport {JsonMethodPath} from \"./JsonOperation\";\n\nexport class JsonOperationPathsMap extends Map<string, JsonMethodPath> {\n setOperationPath(operationPath: JsonMethodPath) {\n if (operationPath.method !== OperationMethods.CUSTOM) {\n const key = this.getKey(operationPath.method, operationPath.path);\n this.updateFinalRouteState(key);\n this.updateFinalRouteState(this.getKey(OperationMethods.ALL, operationPath.path));\n this.setFinalRoute(key, operationPath);\n }\n }\n\n protected getKey = (method: string, path: any) => `${method}-${path}`;\n\n protected updateFinalRouteState(key: string) {\n if (this.has(key)) {\n this.get(key)!.isFinal = false;\n }\n }\n\n protected setFinalRoute(key: string, operationPath: JsonMethodPath) {\n this.set(key, operationPath);\n operationPath.isFinal = true;\n }\n}\n"]}
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsonOperationRoute = void 0;
4
4
  const concatPath_1 = require("../utils/concatPath");
5
5
  class JsonOperationRoute {
6
+ token;
7
+ endpoint;
8
+ operationPath;
9
+ basePath;
10
+ paramsTypes;
6
11
  constructor(options) {
7
12
  Object.assign(this, options);
8
13
  this.paramsTypes = this.endpoint.getParamTypes();
@@ -11,19 +16,16 @@ class JsonOperationRoute {
11
16
  return this.fullPath;
12
17
  }
13
18
  get path() {
14
- var _a;
15
- return (_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.path;
19
+ return this.operationPath?.path;
16
20
  }
17
21
  get fullPath() {
18
22
  return (0, concatPath_1.concatPath)(this.basePath, this.path);
19
23
  }
20
24
  get method() {
21
- var _a;
22
- return ((_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.method) || "USE";
25
+ return this.operationPath?.method || "USE";
23
26
  }
24
27
  get isFinal() {
25
- var _a;
26
- return !!((_a = this.operationPath) === null || _a === void 0 ? void 0 : _a.isFinal);
28
+ return !!this.operationPath?.isFinal;
27
29
  }
28
30
  get name() {
29
31
  return `${this.endpoint.targetName}.${this.methodClassName}()`;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperationRoute.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationRoute.ts"],"names":[],"mappings":";;;AAGA,oDAA+C;AAE/C,MAAa,kBAAkB;IAO7B,YAAY,OAAoC;QAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC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C;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAxED,gDAwEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonMethodPath, JsonOperation} from \"./JsonOperation\";\nimport {concatPath} from \"../utils/concatPath\";\n\nexport class JsonOperationRoute<Entity extends JsonMethodStore = JsonMethodStore> {\n readonly token: Type<any>;\n readonly endpoint: Entity;\n readonly operationPath?: JsonMethodPath;\n readonly basePath?: string;\n readonly paramsTypes: Record<string, boolean>;\n\n constructor(options: Partial<JsonOperationRoute>) {\n Object.assign(this, options);\n\n this.paramsTypes = this.endpoint.getParamTypes();\n }\n\n get url() {\n return this.fullPath;\n }\n\n get path() {\n return this.operationPath?.path;\n }\n\n get fullPath() {\n return concatPath(this.basePath, this.path as any);\n }\n\n get method() {\n return this.operationPath?.method || \"USE\";\n }\n\n get isFinal() {\n return !!this.operationPath?.isFinal;\n }\n\n get name() {\n return `${this.endpoint.targetName}.${this.methodClassName}()`;\n }\n\n get className() {\n return this.endpoint.targetName;\n }\n\n get methodClassName() {\n return this.propertyKey;\n }\n\n get parameters() {\n return this.endpoint.parameters;\n }\n\n get propertyKey() {\n return String(this.endpoint.propertyKey);\n }\n\n get propertyName() {\n return this.endpoint.propertyName;\n }\n\n get store() {\n return this.endpoint.store;\n }\n\n get operation(): JsonOperation {\n return this.endpoint.operation as JsonOperation;\n }\n\n get operationId() {\n return this.operation.get(\"operationId\") || this.endpoint.propertyKey;\n }\n\n has(key: string) {\n return this.paramsTypes[key];\n }\n}\n"]}
1
+ {"version":3,"file":"JsonOperationRoute.js","sourceRoot":"","sources":["../../../src/domain/JsonOperationRoute.ts"],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,YAAY,CAAC;IACpC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,SAA0B,CAAC;IAClD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACxE,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAxED,gDAwEC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonMethodStore} from \"./JsonMethodStore\";\nimport {JsonMethodPath, JsonOperation} from \"./JsonOperation\";\nimport {concatPath} from \"../utils/concatPath\";\n\nexport class JsonOperationRoute<Entity extends JsonMethodStore = JsonMethodStore> {\n readonly token: Type<any>;\n readonly endpoint: Entity;\n readonly operationPath?: JsonMethodPath;\n readonly basePath?: string;\n readonly paramsTypes: Record<string, boolean>;\n\n constructor(options: Partial<JsonOperationRoute>) {\n Object.assign(this, options);\n\n this.paramsTypes = this.endpoint.getParamTypes();\n }\n\n get url() {\n return this.fullPath;\n }\n\n get path() {\n return this.operationPath?.path;\n }\n\n get fullPath() {\n return concatPath(this.basePath, this.path as any);\n }\n\n get method() {\n return this.operationPath?.method || \"USE\";\n }\n\n get isFinal() {\n return !!this.operationPath?.isFinal;\n }\n\n get name() {\n return `${this.endpoint.targetName}.${this.methodClassName}()`;\n }\n\n get className() {\n return this.endpoint.targetName;\n }\n\n get methodClassName() {\n return this.propertyKey;\n }\n\n get parameters() {\n return this.endpoint.parameters;\n }\n\n get propertyKey() {\n return String(this.endpoint.propertyKey);\n }\n\n get propertyName() {\n return this.endpoint.propertyName;\n }\n\n get store() {\n return this.endpoint.store;\n }\n\n get operation(): JsonOperation {\n return this.endpoint.operation as JsonOperation;\n }\n\n get operationId() {\n return this.operation.get(\"operationId\") || this.endpoint.propertyKey;\n }\n\n has(key: string) {\n return this.paramsTypes[key];\n }\n}\n"]}
@@ -8,10 +8,10 @@ const JsonMap_1 = require("./JsonMap");
8
8
  const JsonParameterTypes_1 = require("./JsonParameterTypes");
9
9
  const ref_1 = require("../utils/ref");
10
10
  class JsonParameter extends JsonMap_1.JsonMap {
11
- constructor() {
12
- super(...arguments);
13
- this.nestedGenerics = [];
14
- }
11
+ nestedGenerics = [];
12
+ groups;
13
+ $schema;
14
+ expression;
15
15
  getName() {
16
16
  const name = this.get("name");
17
17
  if (this.get("in") === "files") {
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAGpD,uFAAmE;AACnE,gDAA8D;AAC9D,uCAAkC;AAClC,6DAA8F;AAE9F,sCAA2C;AAE3C,MAAa,aAAc,SAAQ,iBAAiC;IAApE;;QACE,mBAAc,GAAkB,EAAE,CAAC;IAyIrC,CAAC;IApIC,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE;YAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAgD;QACvD,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,CAAC,aAA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AAC;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzD,OAAO,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACjD;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAC,WAAW,EAAE,GAAG,IAAI,EAAC,CAAgB,EAAE,EAAE;YAC7G,OAAO;gBACL,GAAG,MAAM;gBACT,IAAA,kBAAW,EAAC;oBACV,GAAG,SAAS;oBACZ,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC/C,WAAW;oBACX,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;iBAC5C,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AA1ID,sCA0IC","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {createRefName} from \"../utils/ref\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n switch (this.get(\"in\")) {\n case JsonParameterTypes.FILES:\n return this.getFileSchema(jsonSchema, parameter);\n case JsonParameterTypes.QUERY:\n if (jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n break;\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private getFileSchema(jsonSchema: any, parameter: Pick<any, string | number | symbol>) {\n const schema = {\n type: \"string\",\n format: \"binary\",\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const name = createRefName(this.$schema.getName(), options);\n const schema = options.schemas![name];\n\n if (options.schemas![name] && !schemasContainer.has(name)) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }, []);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonParameter.js","sourceRoot":"","sources":["../../../src/domain/JsonParameter.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAGpD,uFAAmE;AACnE,gDAA8D;AAC9D,uCAAkC;AAClC,6DAA8F;AAE9F,sCAA2C;AAE3C,MAAa,aAAc,SAAQ,iBAAiC;IAClE,cAAc,GAAkB,EAAE,CAAC;IACnC,MAAM,CAAW;IACjB,OAAO,CAAa;IACpB,UAAU,CAAS;IAEnB,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE;YAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,QAAgD;QACvD,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEhC,OAA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AI,GAAG,IAAA,mBAAa,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzD,OAAO,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACjD;QAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAC,WAAW,EAAE,GAAG,IAAI,EAAC,CAAgB,EAAE,EAAE;YAC7G,OAAO;gBACL,GAAG,MAAM;gBACT,IAAA,kBAAW,EAAC;oBACV,GAAG,SAAS;oBACZ,IAAI,EAAE,GAAG;oBACT,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC/C,WAAW;oBACX,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;iBAC5C,CAAC;aACH,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AA1ID,sCA0IC","sourcesContent":["import {cleanObject, toMap, Type} from \"@tsed/core\";\nimport {OpenSpecHash, OpenSpecRef, OS3Example, OS3Parameter, OS3Schema} from \"@tsed/openspec\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {NestedGenerics, popGenerics} from \"../utils/generics\";\nimport {JsonMap} from \"./JsonMap\";\nimport {formatParameterType, isParameterType, JsonParameterTypes} from \"./JsonParameterTypes\";\nimport {JsonSchema} from \"./JsonSchema\";\nimport {createRefName} from \"../utils/ref\";\n\nexport class JsonParameter extends JsonMap<OS3Parameter<JsonSchema>> implements NestedGenerics {\n nestedGenerics: Type<any>[][] = [];\n groups: string[];\n $schema: JsonSchema;\n expression: string;\n\n getName() {\n const name = this.get(\"name\");\n\n if (this.get(\"in\") === \"files\") {\n return name.split(\".\")[0];\n }\n\n return name;\n }\n\n name(name: string): this {\n this.set(\"name\", name);\n\n return this;\n }\n\n examples(examples: OpenSpecHash<OS3Example | OpenSpecRef>) {\n super.set(\"examples\", examples);\n\n return this;\n }\n\n description(description: string): this {\n this.set(\"description\", description);\n\n return this;\n }\n\n in(inType: string, expression: string | any = \"\"): this {\n this.set(\"in\", formatParameterType(inType));\n this.expression = expression;\n\n return this;\n }\n\n required(required: boolean): this {\n this.set(\"required\", required);\n\n return this;\n }\n\n schema(schema: JsonSchema): this {\n this.$schema = schema;\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n if (!isParameterType(this.get(\"in\"))) {\n return null;\n }\n\n const schemasContainer = toMap<string, OS3Schema>(options.schemas || {});\n\n return this.build({...options, groups: this.groups}, schemasContainer);\n }\n\n private build(options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const {type, schema, ...parameter} = super.toJSON(options);\n\n const jsonSchema = execMapper(\"item\", this.$schema, {\n ...options,\n ...popGenerics(this)\n });\n\n parameter.required = parameter.required || this.get(\"in\") === JsonParameterTypes.PATH;\n\n switch (this.get(\"in\")) {\n case JsonParameterTypes.FILES:\n return this.getFileSchema(jsonSchema, parameter);\n case JsonParameterTypes.QUERY:\n if (jsonSchema.$ref) {\n if (!parameter.name) {\n return this.refToParameters(parameter, options, schemasContainer);\n }\n\n parameter.style = \"deepObject\";\n }\n break;\n }\n\n parameter.schema = jsonSchema;\n\n return parameter;\n }\n\n private getFileSchema(jsonSchema: any, parameter: Pick<any, string | number | symbol>) {\n const schema = {\n type: \"string\",\n format: \"binary\",\n oneOf: undefined\n };\n\n if (jsonSchema.type === \"array\") {\n jsonSchema.items = cleanObject({\n ...jsonSchema.items,\n ...schema\n });\n\n parameter.schema = jsonSchema;\n } else {\n parameter.schema = cleanObject({\n ...jsonSchema,\n ...schema\n });\n }\n\n return parameter;\n }\n\n private refToParameters(parameter: any, options: JsonSchemaOptions, schemasContainer: Map<string, OS3Schema>) {\n const name = createRefName(this.$schema.getName(), options);\n const schema = options.schemas![name];\n\n if (options.schemas![name] && !schemasContainer.has(name)) {\n delete options.schemas![this.$schema.getName()];\n }\n\n return Object.entries(schema.properties || {}).reduce((params, [key, {description, ...prop}]: [string, any]) => {\n return [\n ...params,\n cleanObject({\n ...parameter,\n name: key,\n required: (schema.required || []).includes(key),\n description,\n schema: prop,\n style: prop.$ref ? \"deepObject\" : undefined\n })\n ];\n }, []);\n }\n}\n"]}
@@ -8,13 +8,20 @@ const JsonParameter_1 = require("./JsonParameter");
8
8
  const JsonSchema_1 = require("./JsonSchema");
9
9
  const jsonEntityComponent_1 = require("../decorators/config/jsonEntityComponent");
10
10
  let JsonParameterStore = class JsonParameterStore extends JsonEntityStore_1.JsonEntityStore {
11
+ paramType;
12
+ expression;
13
+ dataPath;
14
+ /**
15
+ * Define pipes can be called by the framework to transform input parameter
16
+ */
17
+ pipes;
18
+ /**
19
+ * Ref to JsonParameter when the decorated object is a parameter.
20
+ */
21
+ parameter = new JsonParameter_1.JsonParameter();
22
+ parent = JsonEntityStore_1.JsonEntityStore.fromMethod(this.target, this.propertyKey);
11
23
  constructor(options) {
12
24
  super(options);
13
- /**
14
- * Ref to JsonParameter when the decorated object is a parameter.
15
- */
16
- this.parameter = new JsonParameter_1.JsonParameter();
17
- this.parent = JsonEntityStore_1.JsonEntityStore.fromMethod(this.target, this.propertyKey);
18
25
  this.pipes = options.pipes || [];
19
26
  this.paramType = options.paramType || this.paramType;
20
27
  this.expression = options.expression || this.expression;
@@ -1 +1 @@
1
- {"version":3,"file":"JsonParame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ata, 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.ts"],"names":[],"mappings":";;;;AAAA,qCAA+H;AAC/H,uDAA0E;AAE1E,mDAA8C;AAC9C,6CAAwC;AACxC,kFAA6E;AAa7E,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,iCAAe;IAC9C,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,QAAQ,CAAS;IACxB;;OAEG;IACI,KAAK,CAAsB;IAClC;;OAEG;IACM,SAAS,GAAkB,IAAI,6BAAa,EAAE,CAAC;IAC/C,MAAM,GAAoB,iCAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAA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I,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"]}
@@ -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":"","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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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;;;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,C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O,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,7 @@ 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 = [];
12
9
  schema(schema) {
13
10
  this.set("schema", schema);
14
11
  return this;
@@ -23,6 +20,7 @@ class JsonMedia extends JsonMap_1.JsonMap {
23
20
  }
24
21
  exports.JsonMedia = JsonMedia;
25
22
  class JsonResponse extends JsonMap_1.JsonMap {
23
+ status;
26
24
  constructor(obj = {}) {
27
25
  super(obj);
28
26
  this.content(obj.content || {});
@@ -43,9 +41,8 @@ class JsonResponse extends JsonMap_1.JsonMap {
43
41
  return this.get("content");
44
42
  }
45
43
  getMedia(mediaType, create = true) {
46
- var _a;
47
44
  create && this.addMedia(mediaType);
48
- return (_a = this.getContent()) === null || _a === void 0 ? void 0 : _a.get(mediaType);
45
+ return this.getContent()?.get(mediaType);
49
46
  }
50
47
  addMedia(mediaType) {
51
48
  const content = this.get("content");