@tsed/schema 6.102.5 → 6.102.8-rc.2

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 (181) hide show
  1. package/lib/cjs/constants/httpStatusMessages.js +12 -96
  2. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  3. package/lib/cjs/decorators/common/description.js.map +1 -1
  4. package/lib/cjs/decorators/common/ignore.js.map +1 -1
  5. package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
  6. package/lib/cjs/decorators/operations/in.js +6 -4
  7. package/lib/cjs/decorators/operations/in.js.map +1 -1
  8. package/lib/cjs/domain/JsonMap.js.map +1 -1
  9. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  10. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  11. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  12. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  13. package/lib/cjs/index.js +135 -13
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/cjs/package.json +3 -0
  16. package/lib/cjs/utils/from.js +9 -8
  17. package/lib/cjs/utils/from.js.map +1 -1
  18. package/lib/cjs/utils/generics.js.map +1 -1
  19. package/lib/cjs/utils/getJsonSchema.js +1 -1
  20. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  21. package/lib/cjs/utils/getSpec.js.map +1 -1
  22. package/lib/esm/components/anyMapper.js +4 -4
  23. package/lib/esm/components/classMapper.js +4 -4
  24. package/lib/esm/components/genericsMapper.js +4 -4
  25. package/lib/esm/components/inheritedClassMapper.js +2 -2
  26. package/lib/esm/components/itemMapper.js +1 -1
  27. package/lib/esm/components/lazyRefMapper.js +3 -3
  28. package/lib/esm/components/mapMapper.js +2 -2
  29. package/lib/esm/components/objectMapper.js +3 -3
  30. package/lib/esm/components/ofMapper.js +1 -1
  31. package/lib/esm/components/propertiesMapper.js +1 -1
  32. package/lib/esm/components/schemaMapper.js +6 -6
  33. package/lib/esm/constants/httpStatusMessages.js +11 -96
  34. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  35. package/lib/esm/decorators/class/children.js +1 -1
  36. package/lib/esm/decorators/collections/collectionContains.js +1 -1
  37. package/lib/esm/decorators/collections/collectionOf.js +1 -1
  38. package/lib/esm/decorators/collections/maxItems.js +1 -1
  39. package/lib/esm/decorators/collections/maxProperties.js +1 -1
  40. package/lib/esm/decorators/collections/minItems.js +1 -1
  41. package/lib/esm/decorators/collections/minProperties.js +1 -1
  42. package/lib/esm/decorators/collections/uniqueItems.js +1 -1
  43. package/lib/esm/decorators/common/additionalProperties.js +1 -1
  44. package/lib/esm/decorators/common/allOf.js +1 -1
  45. package/lib/esm/decorators/common/allow.js +2 -2
  46. package/lib/esm/decorators/common/any.js +1 -1
  47. package/lib/esm/decorators/common/anyOf.js +1 -1
  48. package/lib/esm/decorators/common/const.js +1 -1
  49. package/lib/esm/decorators/common/customKey.js +1 -1
  50. package/lib/esm/decorators/common/default.js +1 -1
  51. package/lib/esm/decorators/common/description.js +1 -1
  52. package/lib/esm/decorators/common/description.js.map +1 -1
  53. package/lib/esm/decorators/common/enum.js +1 -1
  54. package/lib/esm/decorators/common/example.js +1 -1
  55. package/lib/esm/decorators/common/examples.js +1 -1
  56. package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
  57. package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
  58. package/lib/esm/decorators/common/format.js +2 -2
  59. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  60. package/lib/esm/decorators/common/groups.js +2 -2
  61. package/lib/esm/decorators/common/ignore.js +1 -1
  62. package/lib/esm/decorators/common/ignore.js.map +1 -1
  63. package/lib/esm/decorators/common/integer.js +1 -1
  64. package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
  65. package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
  66. package/lib/esm/decorators/common/maxLength.js +1 -1
  67. package/lib/esm/decorators/common/maximum.js +1 -1
  68. package/lib/esm/decorators/common/minLength.js +1 -1
  69. package/lib/esm/decorators/common/minimum.js +1 -1
  70. package/lib/esm/decorators/common/multipleOf.js +1 -1
  71. package/lib/esm/decorators/common/name.js +1 -1
  72. package/lib/esm/decorators/common/nullable.js +2 -2
  73. package/lib/esm/decorators/common/oneOf.js +1 -1
  74. package/lib/esm/decorators/common/optional.js +1 -1
  75. package/lib/esm/decorators/common/pattern.js +1 -1
  76. package/lib/esm/decorators/common/property.js +1 -1
  77. package/lib/esm/decorators/common/readOnly.js +1 -1
  78. package/lib/esm/decorators/common/required.js +2 -2
  79. package/lib/esm/decorators/common/requiredGroups.js +2 -2
  80. package/lib/esm/decorators/common/schema.js +1 -1
  81. package/lib/esm/decorators/common/title.js +1 -1
  82. package/lib/esm/decorators/common/writeOnly.js +1 -1
  83. package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
  84. package/lib/esm/decorators/generics/genericOf.js +2 -2
  85. package/lib/esm/decorators/generics/generics.js +1 -1
  86. package/lib/esm/decorators/operations/acceptMime.js +1 -1
  87. package/lib/esm/decorators/operations/consumes.js +1 -1
  88. package/lib/esm/decorators/operations/contentType.js +1 -1
  89. package/lib/esm/decorators/operations/deprecated.js +1 -1
  90. package/lib/esm/decorators/operations/header.js +1 -1
  91. package/lib/esm/decorators/operations/in.js +3 -1
  92. package/lib/esm/decorators/operations/in.js.map +1 -1
  93. package/lib/esm/decorators/operations/inFile.js +5 -5
  94. package/lib/esm/decorators/operations/location.js +1 -1
  95. package/lib/esm/decorators/operations/operationId.js +1 -1
  96. package/lib/esm/decorators/operations/operationPath.js +1 -1
  97. package/lib/esm/decorators/operations/partial.js +1 -1
  98. package/lib/esm/decorators/operations/path.js +1 -1
  99. package/lib/esm/decorators/operations/produces.js +1 -1
  100. package/lib/esm/decorators/operations/redirect.js +2 -2
  101. package/lib/esm/decorators/operations/returns.js +8 -8
  102. package/lib/esm/decorators/operations/route.js +3 -3
  103. package/lib/esm/decorators/operations/security.js +1 -1
  104. package/lib/esm/decorators/operations/status.js +1 -1
  105. package/lib/esm/decorators/operations/summary.js +1 -1
  106. package/lib/esm/decorators/operations/tags.js +1 -1
  107. package/lib/esm/domain/DecoratorContext.js +1 -1
  108. package/lib/esm/domain/JsonClassStore.js +3 -3
  109. package/lib/esm/domain/JsonLazyRef.js +2 -2
  110. package/lib/esm/domain/JsonMap.js +1 -1
  111. package/lib/esm/domain/JsonMap.js.map +1 -1
  112. package/lib/esm/domain/JsonMethodStore.js +4 -4
  113. package/lib/esm/domain/JsonOperation.js +8 -8
  114. package/lib/esm/domain/JsonOperation.js.map +1 -1
  115. package/lib/esm/domain/JsonOperationPathsMap.js +1 -1
  116. package/lib/esm/domain/JsonOperationRoute.js +1 -1
  117. package/lib/esm/domain/JsonParameter.js +6 -6
  118. package/lib/esm/domain/JsonParameter.js.map +1 -1
  119. package/lib/esm/domain/JsonParameterStore.js +4 -4
  120. package/lib/esm/domain/JsonPropertyStore.js +3 -3
  121. package/lib/esm/domain/JsonRequestBody.js +2 -2
  122. package/lib/esm/domain/JsonResponse.js +4 -4
  123. package/lib/esm/domain/JsonResponse.js.map +1 -1
  124. package/lib/esm/domain/JsonSchema.js +6 -6
  125. package/lib/esm/domain/JsonSchema.js.map +1 -1
  126. package/lib/esm/index.js +142 -20
  127. package/lib/esm/index.js.map +1 -1
  128. package/lib/esm/package.json +3 -0
  129. package/lib/esm/utils/from.js +5 -4
  130. package/lib/esm/utils/from.js.map +1 -1
  131. package/lib/esm/utils/generics.js.map +1 -1
  132. package/lib/esm/utils/getInheritedStores.js +1 -1
  133. package/lib/esm/utils/getJsonEntityStore.js +5 -5
  134. package/lib/esm/utils/getJsonSchema.js +4 -4
  135. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  136. package/lib/esm/utils/getOperationsRoutes.js +3 -3
  137. package/lib/esm/utils/getOperationsStores.js +4 -4
  138. package/lib/esm/utils/getPropertiesStores.js +3 -3
  139. package/lib/esm/utils/getRequiredProperties.js +1 -1
  140. package/lib/esm/utils/getSpec.js +6 -6
  141. package/lib/esm/utils/getSpec.js.map +1 -1
  142. package/lib/esm/utils/mapNullableType.js +1 -1
  143. package/lib/esm/utils/mapRouteOptions.js +1 -1
  144. package/lib/esm/utils/mergeOperation.js +3 -3
  145. package/lib/esm/utils/ref.js +1 -1
  146. package/lib/esm/utils/toJsonMapCollection.js +1 -1
  147. package/lib/types/constants/httpStatusMessages.d.ts +2 -263
  148. package/lib/types/decorators/common/ignore.d.ts +1 -1
  149. package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
  150. package/lib/types/decorators/operations/in.d.ts +1 -1
  151. package/lib/types/domain/JsonMap.d.ts +1 -1
  152. package/lib/types/domain/JsonOperation.d.ts +2 -1
  153. package/lib/types/domain/JsonParameter.d.ts +1 -1
  154. package/lib/types/domain/JsonResponse.d.ts +2 -1
  155. package/lib/types/domain/JsonSchema.d.ts +1 -1
  156. package/lib/types/index.d.ts +135 -13
  157. package/lib/types/utils/generics.d.ts +1 -1
  158. package/lib/types/utils/getJsonSchema.d.ts +2 -2
  159. package/lib/types/utils/getSpec.d.ts +1 -1
  160. package/package.json +21 -8
  161. package/tsconfig.compile.esm.json +1 -0
  162. package/lib/cjs/components/index.js +0 -15
  163. package/lib/cjs/components/index.js.map +0 -1
  164. package/lib/cjs/decorators/index.js +0 -79
  165. package/lib/cjs/decorators/index.js.map +0 -1
  166. package/lib/cjs/domain/index.js +0 -20
  167. package/lib/cjs/domain/index.js.map +0 -1
  168. package/lib/cjs/interfaces/index.js +0 -8
  169. package/lib/cjs/interfaces/index.js.map +0 -1
  170. package/lib/esm/components/index.js +0 -12
  171. package/lib/esm/components/index.js.map +0 -1
  172. package/lib/esm/decorators/index.js +0 -76
  173. package/lib/esm/decorators/index.js.map +0 -1
  174. package/lib/esm/domain/index.js +0 -17
  175. package/lib/esm/domain/index.js.map +0 -1
  176. package/lib/esm/interfaces/index.js +0 -5
  177. package/lib/esm/interfaces/index.js.map +0 -1
  178. package/lib/types/components/index.d.ts +0 -11
  179. package/lib/types/decorators/index.d.ts +0 -70
  180. package/lib/types/domain/index.d.ts +0 -16
  181. package/lib/types/interfaces/index.d.ts +0 -4
@@ -1,5 +1,5 @@
1
1
  import { decoratorTypeOf, DecoratorTypes } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add a name metadata on the decorated element.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import { useDecorators } from "@tsed/core";
2
- import { Any } from "./any";
3
- import { Property } from "./property";
2
+ import { Any } from "./any.js";
3
+ import { Property } from "./property.js";
4
4
  /**
5
5
  * Set field as nullable.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorTypes } from "@tsed/core";
2
- import { JsonEntityFn } from "./jsonEntityFn";
2
+ import { JsonEntityFn } from "./jsonEntityFn.js";
3
3
  /**
4
4
  * Add optional annotation on Property or Parameter.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * The pattern and Pattern Properties keywords use regular expressions to express constraints.
4
4
  * The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.
@@ -1,5 +1,5 @@
1
1
  import { isClass } from "@tsed/core";
2
- import { JsonEntityFn } from "./jsonEntityFn";
2
+ import { JsonEntityFn } from "./jsonEntityFn.js";
3
3
  /**
4
4
  * Declare a new property on a model.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Set the property as readOnly.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { Allow } from "./allow";
2
- import { Optional } from "./optional";
1
+ import { Allow } from "./allow.js";
2
+ import { Optional } from "./optional.js";
3
3
  /**
4
4
  * Add required annotation on Property or Parameter.
5
5
  *
@@ -1,5 +1,5 @@
1
- import { matchGroups } from "../../utils/matchGroups";
2
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { matchGroups } from "../../utils/matchGroups.js";
2
+ import { JsonEntityFn } from "./jsonEntityFn.js";
3
3
  /**
4
4
  * Apply groups validation strategy for required property.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Write data formatted to JsonSchema.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Add title metadata on the decorated element.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Set the property as WriteOnly.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntitiesContainer } from "../../domain/JsonEntityStore";
1
+ import { JsonEntitiesContainer } from "../../domain/JsonEntityStore.js";
2
2
  /**
3
3
  * Declare a new JsonEntityStore class for a specific decorator type.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { isObject } from "@tsed/core";
2
- import { JsonEntityStore } from "../../domain/JsonEntityStore";
3
- import { string } from "../../utils/from";
2
+ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
3
+ import { string } from "../../utils/from.js";
4
4
  /**
5
5
  * @ignore
6
6
  */
@@ -1,4 +1,4 @@
1
- import { JsonEntityStore } from "../../domain/JsonEntityStore";
1
+ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
2
2
  /**
3
3
  * Define generics list. This list is used by @@GenericOf@@ and the @@getJsonSchema@@ function to build the correct JsonSchema.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { StoreSet, useDecorators } from "@tsed/core";
2
- import { Produces } from "./produces";
2
+ import { Produces } from "./produces.js";
3
3
  /**
4
4
  * Set a mime list which are acceptable and checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add consumes metadata on the decorated element.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { Returns } from "./returns";
1
+ import { Returns } from "./returns.js";
2
2
  /**
3
3
  * Sets the Content-Type HTTP header to the MIME type as determined by mime.lookup() for the specified type.
4
4
  * If type contains the “/” character, then it sets the `Content-Type` to type.
@@ -1,5 +1,5 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add deprecated metadata on the decorated element.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { Returns } from "./returns";
1
+ import { Returns } from "./returns.js";
2
2
  /**
3
3
  * Sets the response’s HTTP header field to value. To set multiple fields at once, pass an object as the parameter.
4
4
  *
@@ -1,5 +1,7 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityStore, JsonParameter, JsonSchema } from "../../domain";
2
+ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
3
+ import { JsonParameter } from "../../domain/JsonParameter.js";
4
+ import { JsonSchema } from "../../domain/JsonSchema.js";
3
5
  /**
4
6
  * Add a input parameter.
5
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"in.js","sourceRoot":"","sources":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,CAAC;QAEnB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE;QAChC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,CAAC,WAAmB,EAAE,EAAE;QAC9C,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAEvC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,QAAQ,GAAG,CAAC,WAAoB,IAAI,EAAE,EAAE;QAChD,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,OAAO,GAAG,CAAC,OAAwB,EAAE,EAAE;QAC/C,OAAO,SAAS,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC;IACzD,CAAC,CAAC;IAEF,SAAS,CAAC,MAAM,GAAG,CAAC,OAAY,EAAE,EAAE;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/B,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorTypes, Type, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityStore, JsonMethodStore, JsonParameter, JsonParameterStore, JsonSchema, JsonSchemaObject} from \"../../domain\";\nimport {JsonParameterTypes} from \"../../domain/JsonParameterTypes\";\n\nexport interface InChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Object, propertyKey: string | symbol, parameterIndex: number): void;\n\n (target: Function): void;\n\n /**\n * Type of this in parameter\n * @param type\n */\n Type(type: Type<any>): this;\n\n /**\n *\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n *\n * @param required\n */\n Required(required?: boolean): this;\n\n /**\n * Add pattern constraint. Only available for OPENAPI.\n * @param pattern\n */\n Pattern(pattern: string | RegExp): this;\n\n /**\n * Add custom schema.\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject>): this;\n}\n\n/**\n * Add a input parameter.\n *\n * ::: warning\n * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.\n * But you can use this decorator on Method, to add extra in parameters like Authorization header.\n *\n * ```typescript\n * @Controller(\"/\")\n * class MyController {\n * @Get(\"/\")\n * @In(\"header\").Type(String).Name(\"Authorization\").Required()\n * method() {\n * }\n * }\n * ```\n * :::\n *\n * @param inType\n * @decorator\n * @swagger\n * @schema\n * @input\n * @operation\n */\nexport function In(inType: JsonParameterTypes | string): InChainedDecorators {\n const jsonParameter = new JsonParameter();\n const schema: any = {};\n\n const decorator = (target: any, propertyKey?: string | symbol, index?: PropertyDescriptor | number) => {\n const store = JsonEntityStore.from(target, propertyKey, index);\n\n switch (store.decoratorType) {\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.in(inType);\n break;\n case DecoratorTypes.METHOD:\n jsonParameter.in(inType);\n (store as JsonMethodStore).operation.addParameter(-1, jsonParameter);\n\n jsonParameter.schema(JsonSchema.from(schema));\n break;\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(target, decorator);\n break;\n\n default:\n throw new UnsupportedDecoratorType(In, [target, propertyKey, index]);\n }\n };\n\n decorator.Type = (type: Type<any>) => {\n schema.type = type;\n\n return decorator;\n };\n\n decorator.Name = (name: string) => {\n jsonParameter.name(name);\n\n return decorator;\n };\n\n decorator.Description = (description: string) => {\n jsonParameter.description(description);\n\n return decorator;\n };\n\n decorator.Required = (required: boolean = true) => {\n jsonParameter.required(required);\n\n return decorator;\n };\n\n decorator.Pattern = (pattern: string | RegExp) => {\n return decorator.Schema({pattern: pattern.toString()});\n };\n\n decorator.Schema = (_schema: any) => {\n Object.assign(schema, _schema);\n\n return decorator;\n };\n\n return decorator;\n}\n"]}
1
+ {"version":3,"file":"in.js","sourceRoot":"","sources":["../../../../src/decorators/operations/in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAQ,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAAC,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AA8CrE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,EAAE,CAAC,MAAmC;IACpD,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,WAA6B,EAAE,KAAmC,EAAE,EAAE;QACpG,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QAE/D,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBACnD,MAAM;YACR,KAAK,cAAc,CAAC,MAAM;gBACxB,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;gBACxB,KAAyB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;gBAErE,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC9C,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBACrC,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;SACxE;IACH,CAAC,CAAC;IAEF,SAAS,CAAC,IAAI,GAAG,CAAC,IAAe,EAAE,EAAE;QACnC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QAEnB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE;QAChC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzB,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,CAAC,WAAmB,EAAE,EAAE;QAC9C,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAEvC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,QAAQ,GAAG,CAAC,WAAoB,IAAI,EAAE,EAAE;QAChD,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,SAAS,CAAC,OAAO,GAAG,CAAC,OAAwB,EAAE,EAAE;QAC/C,OAAO,SAAS,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC;IACzD,CAAC,CAAC;IAEF,SAAS,CAAC,MAAM,GAAG,CAAC,OAAY,EAAE,EAAE;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/B,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {decorateMethodsOf, DecoratorTypes, Type, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport {JsonParameter} from \"../../domain/JsonParameter\";\nimport {JsonParameterStore} from \"../../domain/JsonParameterStore\";\nimport {JsonParameterTypes} from \"../../domain/JsonParameterTypes\";\nimport {JsonSchema, JsonSchemaObject} from \"../../domain/JsonSchema\";\n\nexport interface InChainedDecorators {\n <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;\n\n (target: Object, propertyKey: string | symbol, parameterIndex: number): void;\n\n (target: Function): void;\n\n /**\n * Type of this in parameter\n * @param type\n */\n Type(type: Type<any>): this;\n\n /**\n *\n * @param name\n */\n Name(name: string): this;\n\n /**\n *\n * @param description\n */\n Description(description: string): this;\n\n /**\n *\n * @param required\n */\n Required(required?: boolean): this;\n\n /**\n * Add pattern constraint. Only available for OPENAPI.\n * @param pattern\n */\n Pattern(pattern: string | RegExp): this;\n\n /**\n * Add custom schema.\n * @param schema\n */\n Schema(schema: Partial<JsonSchemaObject>): this;\n}\n\n/**\n * Add a input parameter.\n *\n * ::: warning\n * Don't use decorator with Ts.ED application to decorate parameters. Use @@BodyParams@@, @@PathParams@@, etc... instead.\n * But you can use this decorator on Method, to add extra in parameters like Authorization header.\n *\n * ```typescript\n * @Controller(\"/\")\n * class MyController {\n * @Get(\"/\")\n * @In(\"header\").Type(String).Name(\"Authorization\").Required()\n * method() {\n * }\n * }\n * ```\n * :::\n *\n * @param inType\n * @decorator\n * @swagger\n * @schema\n * @input\n * @operation\n */\nexport function In(inType: JsonParameterTypes | string): InChainedDecorators {\n const jsonParameter = new JsonParameter();\n const schema: any = {};\n\n const decorator = (target: any, propertyKey?: string | symbol, index?: PropertyDescriptor | number) => {\n const store = JsonEntityStore.from(target, propertyKey, index);\n\n switch (store.decoratorType) {\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.in(inType);\n break;\n case DecoratorTypes.METHOD:\n jsonParameter.in(inType);\n (store as JsonMethodStore).operation.addParameter(-1, jsonParameter);\n\n jsonParameter.schema(JsonSchema.from(schema));\n break;\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(target, decorator);\n break;\n\n default:\n throw new UnsupportedDecoratorType(In, [target, propertyKey, index]);\n }\n };\n\n decorator.Type = (type: Type<any>) => {\n schema.type = type;\n\n return decorator;\n };\n\n decorator.Name = (name: string) => {\n jsonParameter.name(name);\n\n return decorator;\n };\n\n decorator.Description = (description: string) => {\n jsonParameter.description(description);\n\n return decorator;\n };\n\n decorator.Required = (required: boolean = true) => {\n jsonParameter.required(required);\n\n return decorator;\n };\n\n decorator.Pattern = (pattern: string | RegExp) => {\n return decorator.Schema({pattern: pattern.toString()});\n };\n\n decorator.Schema = (_schema: any) => {\n Object.assign(schema, _schema);\n\n return decorator;\n };\n\n return decorator;\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Metadata, useDecorators, useMethodDecorators } from "@tsed/core";
2
- import { In } from "./in";
3
- import { JsonParameterTypes } from "../../domain/JsonParameterTypes";
4
- import { Returns } from "./returns";
5
- import { Name } from "../common/name";
6
- import { Consumes } from "./consumes";
2
+ import { In } from "./in.js";
3
+ import { JsonParameterTypes } from "../../domain/JsonParameterTypes.js";
4
+ import { Returns } from "./returns.js";
5
+ import { Name } from "../common/name.js";
6
+ import { Consumes } from "./consumes.js";
7
7
  /**
8
8
  * Add a input file parameter.
9
9
  *
@@ -1,4 +1,4 @@
1
- import { Returns } from "./returns";
1
+ import { Returns } from "./returns.js";
2
2
  /**
3
3
  * Sets the response Location HTTP header to the specified path parameter.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Set a swagger operationId explicitly.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Declare new Operation with his path and http method.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { Groups } from "../common/groups";
1
+ import { Groups } from "../common/groups.js";
2
2
  /**
3
3
  * Apply Partial group strategy on the input model
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Set class path to expose all endpoints
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add produces metadata on the decorated element.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import { isNumber, isString, useDecorators } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
3
- import { Returns } from "./returns";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
+ import { Returns } from "./returns.js";
4
4
  export function Redirect(...args) {
5
5
  const { status, url, meta } = args.reduce((options, value) => {
6
6
  if (isNumber(value)) {
@@ -1,12 +1,12 @@
1
1
  import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, isArray, isCollection, isObject, isPlainObject, isPrimitiveOrPrimitiveClass, isString } from "@tsed/core";
2
- import { getStatusMessage } from "../../constants/httpStatusMessages";
3
- import { DecoratorContext } from "../../domain/DecoratorContext";
4
- import { JsonEntityStore } from "../../domain/JsonEntityStore";
5
- import { JsonSchema } from "../../domain/JsonSchema";
6
- import { getStatusModel } from "../../utils/defineStatusModel";
7
- import { string } from "../../utils/from";
8
- import { isSuccessStatus } from "../../utils/isSuccessStatus";
9
- import { mapHeaders } from "../../utils/mapHeaders";
2
+ import { getStatusMessage } from "../../constants/httpStatusMessages.js";
3
+ import { DecoratorContext } from "../../domain/DecoratorContext.js";
4
+ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
5
+ import { JsonSchema } from "../../domain/JsonSchema.js";
6
+ import { getStatusModel } from "../../utils/defineStatusModel.js";
7
+ import { string } from "../../utils/from.js";
8
+ import { isSuccessStatus } from "../../utils/isSuccessStatus.js";
9
+ import { mapHeaders } from "../../utils/mapHeaders.js";
10
10
  /**
11
11
  * @ignore
12
12
  */
@@ -1,6 +1,6 @@
1
- import { DecoratorContext } from "../../domain/DecoratorContext";
2
- import { mapRouteOptions } from "../../utils/mapRouteOptions";
3
- import { OperationMethods } from "../../constants/httpMethods";
1
+ import { DecoratorContext } from "../../domain/DecoratorContext.js";
2
+ import { mapRouteOptions } from "../../utils/mapRouteOptions.js";
3
+ import { OperationMethods } from "../../constants/httpMethods.js";
4
4
  class RouteDecoratorContext extends DecoratorContext {
5
5
  constructor() {
6
6
  super(...arguments);
@@ -1,5 +1,5 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add security metadata on the decorated method.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { Returns } from "./returns";
1
+ import { Returns } from "./returns.js";
2
2
  /**
3
3
  * Add responses documentation for a specific status code.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add summary metadata on the decorated element.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  function mapTags(tags) {
4
4
  return tags.map((tag) => {
5
5
  if (typeof tag === "string") {
@@ -1,6 +1,6 @@
1
1
  import { DecoratorTypes } from "@tsed/core";
2
2
  import { pascalCase } from "pascal-case";
3
- import { JsonEntityStore } from "./JsonEntityStore";
3
+ import { JsonEntityStore } from "./JsonEntityStore.js";
4
4
  /**
5
5
  * @ignore
6
6
  */
@@ -1,8 +1,8 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { DecoratorTypes } from "@tsed/core";
3
- import { JsonEntityStore } from "./JsonEntityStore";
4
- import { JsonSchema } from "./JsonSchema";
5
- import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent";
3
+ import { JsonEntityStore } from "./JsonEntityStore.js";
4
+ import { JsonSchema } from "./JsonSchema.js";
5
+ import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
6
6
  let JsonClassStore = class JsonClassStore extends JsonEntityStore {
7
7
  constructor() {
8
8
  super(...arguments);
@@ -1,6 +1,6 @@
1
1
  import { nameOf } from "@tsed/core";
2
- import { execMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { getJsonEntityStore } from "../utils/getJsonEntityStore";
2
+ import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { getJsonEntityStore } from "../utils/getJsonEntityStore.js";
4
4
  export class JsonLazyRef {
5
5
  constructor(getType) {
6
6
  this.getType = getType;
@@ -1,5 +1,5 @@
1
1
  import { isFunction } from "@tsed/core";
2
- import { execMapper } from "../registries/JsonSchemaMapperContainer";
2
+ import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
3
3
  export class JsonMap extends Map {
4
4
  constructor(obj = {}) {
5
5
  super();
@@ -1 +1 @@
1
- {"version":3,"file":"JsonMap.js","sourceRoot":"","sources":["../../../src/domain/JsonMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,MAAM,OAAO,OAAW,SAAQ,GAAgB;IAG9C,YAAY,MAAkB,EAAE;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE;QAC/B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3C,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\n\nexport class JsonMap<T> extends Map<string, any> {\n [key: string]: any;\n\n constructor(obj: Partial<T> = {}) {\n super();\n\n this.assign(obj);\n }\n\n assign(obj: Partial<T> & any = {}) {\n Object.entries(obj).forEach(([key, value]) => {\n if (isFunction(this[key])) {\n this[key](value);\n } else {\n this.set(key, value);\n }\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n return execMapper(\"map\", this, options);\n }\n}\n"]}
1
+ {"version":3,"file":"JsonMap.js","sourceRoot":"","sources":["../../../src/domain/JsonMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,MAAM,OAAO,OAAW,SAAQ,GAAgB;IAG9C,YAAY,MAAkB,EAAE;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAwB,EAAE;QAC/B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3C,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;aAClB;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,UAA6B,EAAE;QACpC,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import {isFunction} from \"@tsed/core\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper} from \"../registries/JsonSchemaMapperContainer\";\n\nexport class JsonMap<T> extends Map<string, any> {\n [key: string]: any;\n\n constructor(obj: Partial<T> = {}) {\n super();\n\n this.assign(obj);\n }\n\n assign(obj: Partial<T> & any = {}) {\n Object.entries(obj).forEach(([key, value]) => {\n if (isFunction(this[key])) {\n this[key](value);\n } else {\n this.set(key, value);\n }\n });\n\n return this;\n }\n\n toJSON(options: JsonSchemaOptions = {}) {\n return execMapper(\"map\", this, options);\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { DecoratorTypes, deepMerge, descriptorOf, isCollection, isFunction, isPromise, Metadata, prototypeOf, Store } from "@tsed/core";
3
- import { JsonEntityStore } from "./JsonEntityStore";
4
- import { JsonOperation } from "./JsonOperation";
5
- import { JsonSchema } from "./JsonSchema";
6
- import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent";
3
+ import { JsonEntityStore } from "./JsonEntityStore.js";
4
+ import { JsonOperation } from "./JsonOperation.js";
5
+ import { JsonSchema } from "./JsonSchema.js";
6
+ import { JsonEntityComponent } from "../decorators/config/jsonEntityComponent.js";
7
7
  let JsonMethodStore = class JsonMethodStore extends JsonEntityStore {
8
8
  constructor(options) {
9
9
  super({
@@ -1,14 +1,14 @@
1
1
  var _JsonOperation_status, _JsonOperation_redirection;
2
2
  import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
3
  import { deepMerge, uniq, uniqBy } from "@tsed/core";
4
- import { getStatusMessage } from "../constants/httpStatusMessages";
5
- import { isRedirectionStatus, isSuccessStatus } from "../utils/isSuccessStatus";
6
- import { JsonMap } from "./JsonMap";
7
- import { isParameterType, JsonParameterTypes } from "./JsonParameterTypes";
8
- import { JsonRequestBody } from "./JsonRequestBody";
9
- import { JsonResponse } from "./JsonResponse";
10
- import { JsonSchema } from "./JsonSchema";
11
- import { SpecTypes } from "./SpecTypes";
4
+ import { getStatusMessage } from "../constants/httpStatusMessages.js";
5
+ import { isRedirectionStatus, isSuccessStatus } from "../utils/isSuccessStatus.js";
6
+ import { JsonMap } from "./JsonMap.js";
7
+ import { isParameterType, JsonParameterTypes } from "./JsonParameterTypes.js";
8
+ import { JsonRequestBody } from "./JsonRequestBody.js";
9
+ import { JsonResponse } from "./JsonResponse.js";
10
+ import { JsonSchema } from "./JsonSchema.js";
11
+ import { SpecTypes } from "./SpecTypes.js";
12
12
  export class JsonOperation extends JsonMap {
13
13
  constructor(obj = {}) {
14
14
  super({ parameters: [], responses: new JsonMap(), ...obj });
@@ -1 +1 @@
1
- {"version":3,"file":"JsonOperation.js","sourceRoot":"","sources":["../../../src/domain/JsonOperation.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAEnD,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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, JsonSchemaOptions} from \"../interfaces\";\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\";\nimport {SpecTypes} from \"./SpecTypes\";\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 if (options.specType === SpecTypes.OPENAPI) {\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n } else {\n operation.parameters.push(toJsonParameter(parameter));\n }\n }\n\n if (options.specType === SpecTypes.OPENAPI) {\n delete operation.consumes;\n delete operation.produces;\n }\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 toJsonParameter(parameter: any) {\n return {\n in: JsonParameterTypes.BODY,\n name: JsonParameterTypes.BODY,\n ...parameter\n };\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,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB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B,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\";\nimport {SpecTypes} from \"./SpecTypes\";\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 if (options.specType === SpecTypes.OPENAPI) {\n operation.requestBody = toRequestBody(this, parameter).toJSON(options);\n } else {\n operation.parameters.push(toJsonParameter(parameter));\n }\n }\n\n if (options.specType === SpecTypes.OPENAPI) {\n delete operation.consumes;\n delete operation.produces;\n }\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 toJsonParameter(parameter: any) {\n return {\n in: JsonParameterTypes.BODY,\n name: JsonParameterTypes.BODY,\n ...parameter\n };\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,4 +1,4 @@
1
- import { OperationMethods } from "../constants/httpMethods";
1
+ import { OperationMethods } from "../constants/httpMethods.js";
2
2
  export class JsonOperationPathsMap extends Map {
3
3
  constructor() {
4
4
  super(...arguments);
@@ -1,4 +1,4 @@
1
- import { concatPath } from "../utils/concatPath";
1
+ import { concatPath } from "../utils/concatPath.js";
2
2
  export class JsonOperationRoute {
3
3
  constructor(options) {
4
4
  Object.assign(this, options);
@@ -1,10 +1,10 @@
1
1
  import { cleanObject, toMap } from "@tsed/core";
2
- import { execMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { popGenerics } from "../utils/generics";
4
- import { JsonMap } from "./JsonMap";
5
- import { formatParameterType, isParameterType, JsonParameterTypes } from "./JsonParameterTypes";
6
- import { SpecTypes } from "./SpecTypes";
7
- import { createRefName } from "../utils/ref";
2
+ import { execMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { popGenerics } from "../utils/generics.js";
4
+ import { JsonMap } from "./JsonMap.js";
5
+ import { formatParameterType, isParameterType, JsonParameterTypes } from "./JsonParameterTypes.js";
6
+ import { SpecTypes } from "./SpecTypes.js";
7
+ import { createRefName } from "../utils/ref.js";
8
8
  const IGNORE_OS2_PROPS = ["example", "examples", "title"];
9
9
  export class JsonParameter extends JsonMap {
10
10
  constructor() {