@nestia/sdk 3.10.0 → 3.11.0-dev.20240813

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 (279) hide show
  1. package/lib/NestiaSdkApplication.d.ts +1 -3
  2. package/lib/NestiaSdkApplication.js +138 -136
  3. package/lib/NestiaSdkApplication.js.map +1 -1
  4. package/lib/analyses/ConfigAnalyzer.d.ts +2 -2
  5. package/lib/analyses/ConfigAnalyzer.js +39 -80
  6. package/lib/analyses/ConfigAnalyzer.js.map +1 -1
  7. package/lib/analyses/ExceptionAnalyzer.d.ts +0 -16
  8. package/lib/analyses/ExceptionAnalyzer.js +142 -105
  9. package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
  10. package/lib/analyses/GenericAnalyzer.d.ts +1 -2
  11. package/lib/analyses/GenericAnalyzer.js.map +1 -1
  12. package/lib/analyses/ImportAnalyzer.d.ts +6 -11
  13. package/lib/analyses/ImportAnalyzer.js +70 -42
  14. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  15. package/lib/analyses/ReflectControllerAnalyzer.d.ts +7 -1
  16. package/lib/analyses/ReflectControllerAnalyzer.js +28 -99
  17. package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
  18. package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +6 -2
  19. package/lib/analyses/ReflectHttpOperationAnalyzer.js +72 -152
  20. package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
  21. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +15 -0
  22. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +215 -0
  23. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -0
  24. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +15 -0
  25. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +81 -0
  26. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -0
  27. package/lib/analyses/ReflectMetadataAnalyzer.d.ts +1 -3
  28. package/lib/analyses/ReflectMetadataAnalyzer.js +0 -4
  29. package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
  30. package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +6 -2
  31. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +72 -48
  32. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
  33. package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +15 -0
  34. package/lib/analyses/TypedHttpRouteAnalyzer.js +111 -0
  35. package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -0
  36. package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +10 -0
  37. package/lib/analyses/TypedWebSocketRouteAnalyzer.js +9 -0
  38. package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -0
  39. package/lib/decorators/OperationMetadata.d.ts +2 -0
  40. package/lib/decorators/OperationMetadata.js +10 -0
  41. package/lib/decorators/OperationMetadata.js.map +1 -0
  42. package/lib/executable/internal/NestiaConfigLoader.d.ts +1 -1
  43. package/lib/executable/internal/NestiaConfigLoader.js +34 -3
  44. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  45. package/lib/executable/internal/NestiaSdkCommand.js +1 -1
  46. package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
  47. package/lib/generates/CloneGenerator.d.ts +0 -5
  48. package/lib/generates/CloneGenerator.js +60 -60
  49. package/lib/generates/CloneGenerator.js.map +1 -1
  50. package/lib/generates/E2eGenerator.d.ts +2 -3
  51. package/lib/generates/E2eGenerator.js +9 -8
  52. package/lib/generates/E2eGenerator.js.map +1 -1
  53. package/lib/generates/OpenAiGenerator.d.ts +2 -4
  54. package/lib/generates/OpenAiGenerator.js +13 -3
  55. package/lib/generates/OpenAiGenerator.js.map +1 -1
  56. package/lib/generates/SdkGenerator.d.ts +4 -4
  57. package/lib/generates/SdkGenerator.js +63 -73
  58. package/lib/generates/SdkGenerator.js.map +1 -1
  59. package/lib/generates/SwaggerGenerator.d.ts +6 -18
  60. package/lib/generates/SwaggerGenerator.js +60 -235
  61. package/lib/generates/SwaggerGenerator.js.map +1 -1
  62. package/lib/generates/internal/E2eFileProgrammer.js +5 -9
  63. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  64. package/lib/generates/internal/SdkAliasCollection.d.ts +6 -4
  65. package/lib/generates/internal/SdkAliasCollection.js +33 -31
  66. package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
  67. package/lib/generates/internal/SdkDistributionComposer.d.ts +4 -1
  68. package/lib/generates/internal/SdkDistributionComposer.js +6 -6
  69. package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
  70. package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -4
  71. package/lib/generates/internal/SdkFileProgrammer.js +6 -6
  72. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  73. package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +0 -12
  74. package/lib/generates/internal/SdkHttpCloneProgrammer.js +142 -97
  75. package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
  76. package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +4 -3
  77. package/lib/generates/internal/SdkHttpFunctionProgrammer.js +37 -59
  78. package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
  79. package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +4 -3
  80. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +31 -48
  81. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
  82. package/lib/generates/internal/SdkHttpRouteProgrammer.js +7 -3
  83. package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
  84. package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +4 -3
  85. package/lib/generates/internal/SdkHttpSimulationProgrammer.js +7 -13
  86. package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
  87. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +1 -2
  88. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +11 -16
  89. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
  90. package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +1 -2
  91. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +7 -10
  92. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
  93. package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +23 -0
  94. package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -0
  95. package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -0
  96. package/lib/generates/internal/SwaggerOperationComposer.d.ts +12 -0
  97. package/lib/generates/internal/SwaggerOperationComposer.js +68 -0
  98. package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -0
  99. package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +18 -0
  100. package/lib/generates/internal/SwaggerOperationParameterComposer.js +99 -0
  101. package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -0
  102. package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +9 -0
  103. package/lib/generates/internal/SwaggerOperationResponseComposer.js +91 -0
  104. package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -0
  105. package/lib/structures/INestiaProject.d.ts +5 -5
  106. package/lib/structures/INestiaSdkInput.d.ts +20 -0
  107. package/lib/structures/{ISwaggerError.js → INestiaSdkInput.js} +1 -1
  108. package/lib/structures/INestiaSdkInput.js.map +1 -0
  109. package/lib/structures/IReflectApplication.d.ts +6 -0
  110. package/lib/structures/IReflectApplication.js +3 -0
  111. package/lib/structures/IReflectApplication.js.map +1 -0
  112. package/lib/structures/IReflectController.d.ts +3 -5
  113. package/lib/structures/IReflectHttpOperation.d.ts +13 -65
  114. package/lib/structures/IReflectHttpOperationException.d.ts +14 -0
  115. package/lib/structures/IReflectHttpOperationException.js +3 -0
  116. package/lib/structures/IReflectHttpOperationException.js.map +1 -0
  117. package/lib/structures/IReflectHttpOperationParameter.d.ts +35 -0
  118. package/lib/structures/IReflectHttpOperationParameter.js +3 -0
  119. package/lib/structures/IReflectHttpOperationParameter.js.map +1 -0
  120. package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -0
  121. package/lib/structures/IReflectHttpOperationSuccess.js +3 -0
  122. package/lib/structures/IReflectHttpOperationSuccess.js.map +1 -0
  123. package/lib/structures/IReflectOperationError.d.ts +16 -0
  124. package/lib/structures/IReflectOperationError.js +23 -0
  125. package/lib/structures/IReflectOperationError.js.map +1 -0
  126. package/lib/structures/IReflectType.d.ts +4 -0
  127. package/lib/structures/{IErrorReport.js → IReflectType.js} +1 -1
  128. package/lib/structures/IReflectType.js.map +1 -0
  129. package/lib/structures/IReflectTypeImport.d.ts +4 -0
  130. package/lib/structures/{ISwaggerLazySchema.js → IReflectTypeImport.js} +1 -1
  131. package/lib/structures/IReflectTypeImport.js.map +1 -0
  132. package/lib/structures/IReflectWebSocketOperation.d.ts +8 -9
  133. package/lib/structures/IReflectWebSocketOperationParameter.d.ts +23 -0
  134. package/lib/structures/IReflectWebSocketOperationParameter.js +3 -0
  135. package/lib/structures/IReflectWebSocketOperationParameter.js.map +1 -0
  136. package/lib/structures/ITypedApplication.d.ts +7 -0
  137. package/lib/structures/{INormalizedInput.js → ITypedApplication.js} +1 -1
  138. package/lib/structures/ITypedApplication.js.map +1 -0
  139. package/lib/structures/ITypedHttpRoute.d.ts +14 -42
  140. package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
  141. package/lib/structures/ITypedHttpRouteException.js +3 -0
  142. package/lib/structures/ITypedHttpRouteException.js.map +1 -0
  143. package/lib/structures/ITypedHttpRouteParameter.d.ts +31 -0
  144. package/lib/structures/ITypedHttpRouteParameter.js +3 -0
  145. package/lib/structures/ITypedHttpRouteParameter.js.map +1 -0
  146. package/lib/structures/ITypedHttpRouteSuccess.d.ts +19 -0
  147. package/lib/structures/{ISwaggerLazyProperty.js → ITypedHttpRouteSuccess.js} +1 -1
  148. package/lib/structures/ITypedHttpRouteSuccess.js.map +1 -0
  149. package/lib/structures/ITypedWebSocketRoute.d.ts +8 -44
  150. package/lib/structures/ITypedWebSocketRouteParameter.d.ts +2 -0
  151. package/lib/structures/ITypedWebSocketRouteParameter.js +3 -0
  152. package/lib/structures/ITypedWebSocketRouteParameter.js.map +1 -0
  153. package/lib/transform.d.ts +3 -0
  154. package/lib/transform.js +8 -0
  155. package/lib/transform.js.map +1 -0
  156. package/lib/transformers/IOperationMetadata.d.ts +36 -0
  157. package/lib/transformers/IOperationMetadata.js +3 -0
  158. package/lib/transformers/IOperationMetadata.js.map +1 -0
  159. package/lib/transformers/ISdkTransformerContext.d.ts +7 -0
  160. package/lib/transformers/ISdkTransformerContext.js +3 -0
  161. package/lib/transformers/ISdkTransformerContext.js.map +1 -0
  162. package/lib/transformers/SdkMetadataProgrammer.d.ts +11 -0
  163. package/lib/transformers/SdkMetadataProgrammer.js +159 -0
  164. package/lib/transformers/SdkMetadataProgrammer.js.map +1 -0
  165. package/lib/transformers/SdkTransformer.d.ts +4 -0
  166. package/lib/transformers/SdkTransformer.js +88 -0
  167. package/lib/transformers/SdkTransformer.js.map +1 -0
  168. package/lib/transformers/TextPlainValidator.d.ts +4 -0
  169. package/lib/transformers/TextPlainValidator.js +19 -0
  170. package/lib/transformers/TextPlainValidator.js.map +1 -0
  171. package/lib/utils/StringUtil.d.ts +1 -0
  172. package/lib/utils/StringUtil.js +1 -0
  173. package/lib/utils/StringUtil.js.map +1 -1
  174. package/package.json +8 -8
  175. package/src/NestiaSdkApplication.ts +173 -160
  176. package/src/analyses/ConfigAnalyzer.ts +50 -98
  177. package/src/analyses/ExceptionAnalyzer.ts +142 -142
  178. package/src/analyses/GenericAnalyzer.ts +3 -5
  179. package/src/analyses/ImportAnalyzer.ts +130 -115
  180. package/src/analyses/ReflectControllerAnalyzer.ts +63 -115
  181. package/src/analyses/ReflectHttpOperationAnalyzer.ts +142 -278
  182. package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +319 -0
  183. package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +117 -0
  184. package/src/analyses/ReflectMetadataAnalyzer.ts +1 -18
  185. package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +143 -78
  186. package/src/analyses/TypedHttpRouteAnalyzer.ts +178 -0
  187. package/src/analyses/TypedWebSocketRouteAnalyzer.ts +18 -0
  188. package/src/decorators/OperationMetadata.ts +15 -0
  189. package/src/executable/internal/NestiaConfigLoader.ts +18 -3
  190. package/src/executable/internal/NestiaSdkCommand.ts +1 -4
  191. package/src/generates/CloneGenerator.ts +60 -59
  192. package/src/generates/E2eGenerator.ts +20 -21
  193. package/src/generates/OpenAiGenerator.ts +44 -45
  194. package/src/generates/SdkGenerator.ts +97 -125
  195. package/src/generates/SwaggerGenerator.ts +114 -416
  196. package/src/generates/internal/E2eFileProgrammer.ts +5 -14
  197. package/src/generates/internal/SdkAliasCollection.ts +33 -41
  198. package/src/generates/internal/SdkDistributionComposer.ts +9 -6
  199. package/src/generates/internal/SdkFileProgrammer.ts +11 -14
  200. package/src/generates/internal/SdkHttpCloneProgrammer.ts +142 -142
  201. package/src/generates/internal/SdkHttpFunctionProgrammer.ts +20 -47
  202. package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +245 -275
  203. package/src/generates/internal/SdkHttpRouteProgrammer.ts +7 -7
  204. package/src/generates/internal/SdkHttpSimulationProgrammer.ts +11 -23
  205. package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +197 -233
  206. package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +5 -15
  207. package/src/generates/internal/{SwaggerDescriptionGenerator.ts → SwaggerDescriptionComposer.ts} +25 -5
  208. package/src/generates/internal/SwaggerOperationComposer.ts +90 -0
  209. package/src/generates/internal/SwaggerOperationParameterComposer.ts +173 -0
  210. package/src/generates/internal/SwaggerOperationResponseComposer.ts +110 -0
  211. package/src/structures/INestiaProject.ts +5 -5
  212. package/src/structures/INestiaSdkInput.ts +25 -0
  213. package/src/structures/IReflectApplication.ts +8 -0
  214. package/src/structures/IReflectController.ts +3 -5
  215. package/src/structures/IReflectHttpOperation.ts +14 -76
  216. package/src/structures/IReflectHttpOperationException.ts +19 -0
  217. package/src/structures/IReflectHttpOperationParameter.ts +81 -0
  218. package/src/structures/IReflectHttpOperationSuccess.ts +22 -0
  219. package/src/structures/IReflectOperationError.ts +26 -0
  220. package/src/structures/IReflectType.ts +4 -0
  221. package/src/structures/IReflectTypeImport.ts +4 -0
  222. package/src/structures/IReflectWebSocketOperation.ts +9 -9
  223. package/src/structures/IReflectWebSocketOperationParameter.ts +38 -0
  224. package/src/structures/ITypedApplication.ts +8 -0
  225. package/src/structures/ITypedHttpRoute.ts +15 -45
  226. package/src/structures/ITypedHttpRouteException.ts +15 -0
  227. package/src/structures/ITypedHttpRouteParameter.ts +41 -0
  228. package/src/structures/ITypedHttpRouteSuccess.ts +22 -0
  229. package/src/structures/ITypedWebSocketRoute.ts +8 -56
  230. package/src/structures/ITypedWebSocketRouteParameter.ts +3 -0
  231. package/src/transform.ts +9 -0
  232. package/src/transformers/IOperationMetadata.ts +38 -0
  233. package/src/transformers/ISdkTransformerContext.ts +8 -0
  234. package/src/transformers/SdkMetadataProgrammer.ts +227 -0
  235. package/src/transformers/SdkTransformer.ts +168 -0
  236. package/src/transformers/TextPlainValidator.ts +17 -0
  237. package/src/utils/StringUtil.ts +3 -0
  238. package/lib/analyses/TypedControllerAnalyzer.d.ts +0 -8
  239. package/lib/analyses/TypedControllerAnalyzer.js +0 -77
  240. package/lib/analyses/TypedControllerAnalyzer.js.map +0 -1
  241. package/lib/analyses/TypedHttpOperationAnalyzer.d.ts +0 -15
  242. package/lib/analyses/TypedHttpOperationAnalyzer.js +0 -263
  243. package/lib/analyses/TypedHttpOperationAnalyzer.js.map +0 -1
  244. package/lib/analyses/TypedWebSocketOperationAnalyzer.d.ts +0 -15
  245. package/lib/analyses/TypedWebSocketOperationAnalyzer.js +0 -226
  246. package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +0 -1
  247. package/lib/generates/internal/SwaggerDescriptionGenerator.d.ts +0 -14
  248. package/lib/generates/internal/SwaggerDescriptionGenerator.js +0 -33
  249. package/lib/generates/internal/SwaggerDescriptionGenerator.js.map +0 -1
  250. package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +0 -21
  251. package/lib/generates/internal/SwaggerSchemaGenerator.js +0 -289
  252. package/lib/generates/internal/SwaggerSchemaGenerator.js.map +0 -1
  253. package/lib/generates/internal/SwaggerSchemaValidator.d.ts +0 -7
  254. package/lib/generates/internal/SwaggerSchemaValidator.js +0 -191
  255. package/lib/generates/internal/SwaggerSchemaValidator.js.map +0 -1
  256. package/lib/structures/IErrorReport.d.ts +0 -6
  257. package/lib/structures/IErrorReport.js.map +0 -1
  258. package/lib/structures/INormalizedInput.d.ts +0 -19
  259. package/lib/structures/INormalizedInput.js.map +0 -1
  260. package/lib/structures/ISwaggerError.d.ts +0 -6
  261. package/lib/structures/ISwaggerError.js.map +0 -1
  262. package/lib/structures/ISwaggerLazyProperty.d.ts +0 -6
  263. package/lib/structures/ISwaggerLazyProperty.js.map +0 -1
  264. package/lib/structures/ISwaggerLazySchema.d.ts +0 -6
  265. package/lib/structures/ISwaggerLazySchema.js.map +0 -1
  266. package/lib/structures/ITypeTuple.d.ts +0 -5
  267. package/lib/structures/ITypeTuple.js +0 -3
  268. package/lib/structures/ITypeTuple.js.map +0 -1
  269. package/src/analyses/TypedControllerAnalyzer.ts +0 -92
  270. package/src/analyses/TypedHttpOperationAnalyzer.ts +0 -365
  271. package/src/analyses/TypedWebSocketOperationAnalyzer.ts +0 -375
  272. package/src/generates/internal/SwaggerSchemaGenerator.ts +0 -473
  273. package/src/generates/internal/SwaggerSchemaValidator.ts +0 -206
  274. package/src/structures/IErrorReport.ts +0 -6
  275. package/src/structures/INormalizedInput.ts +0 -20
  276. package/src/structures/ISwaggerError.ts +0 -8
  277. package/src/structures/ISwaggerLazyProperty.ts +0 -7
  278. package/src/structures/ISwaggerLazySchema.ts +0 -7
  279. package/src/structures/ITypeTuple.ts +0 -6
@@ -1,473 +0,0 @@
1
- import { OpenApi } from "@samchon/openapi";
2
- import { Singleton, VariadicSingleton } from "tstl";
3
- import ts from "typescript";
4
- import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
5
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
6
- import { JsonApplicationProgrammer } from "typia/lib/programmers/json/JsonApplicationProgrammer";
7
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
8
- import { ValidationPipe } from "typia/lib/typings/ValidationPipe";
9
-
10
- import { INestiaConfig } from "../../INestiaConfig";
11
- import { ISwaggerError } from "../../structures/ISwaggerError";
12
- import { ISwaggerLazyProperty } from "../../structures/ISwaggerLazyProperty";
13
- import { ISwaggerLazySchema } from "../../structures/ISwaggerLazySchema";
14
- import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
15
- import { SwaggerDescriptionGenerator } from "./SwaggerDescriptionGenerator";
16
- import { SwaggerSchemaValidator } from "./SwaggerSchemaValidator";
17
-
18
- export namespace SwaggerSchemaGenerator {
19
- export interface IProps {
20
- config: INestiaConfig.ISwaggerConfig;
21
- checker: ts.TypeChecker;
22
- collection: MetadataCollection;
23
- lazySchemas: Array<ISwaggerLazySchema>;
24
- lazyProperties: Array<ISwaggerLazyProperty>;
25
- errors: ISwaggerError[];
26
- }
27
-
28
- export const response =
29
- (props: IProps) =>
30
- (route: ITypedHttpRoute): Record<string, OpenApi.IOperation.IResponse> => {
31
- const output: Record<string, OpenApi.IOperation.IResponse> = {};
32
-
33
- //----
34
- // EXCEPTION STATUSES
35
- //----
36
- // FROM DECORATOR
37
- for (const [status, exp] of Object.entries(route.exceptions)) {
38
- const result = MetadataFactory.analyze(props.checker)({
39
- escape: true,
40
- constant: true,
41
- absorb: false,
42
- validate: JsonApplicationProgrammer.validate,
43
- })(props.collection)(exp.type);
44
- if (result.success === false)
45
- props.errors.push(
46
- ...result.errors.map((e) => ({
47
- ...e,
48
- route,
49
- from: `response(status: ${status})`,
50
- })),
51
- );
52
-
53
- output[status] = {
54
- description: exp.description ?? "",
55
- content: {
56
- "application/json": {
57
- schema: coalesce(props)(result),
58
- },
59
- },
60
- };
61
- }
62
-
63
- // FROM COMMENT TAGS -> ANY
64
- for (const tag of route.jsDocTags) {
65
- if (tag.name !== "throw" && tag.name !== "throws") continue;
66
-
67
- const text: string | undefined = tag.text?.find(
68
- (elem) => elem.kind === "text",
69
- )?.text;
70
- if (text === undefined) continue;
71
-
72
- const elements: string[] = text.split(" ").map((str) => str.trim());
73
- const status: string = elements[0];
74
- if (
75
- isNaN(Number(status)) &&
76
- status !== "2XX" &&
77
- status !== "3XX" &&
78
- status !== "4XX" &&
79
- status !== "5XX"
80
- )
81
- continue;
82
-
83
- const description: string | undefined =
84
- elements.length === 1 ? undefined : elements.slice(1).join(" ");
85
- const oldbie = output[status];
86
- if (description && oldbie !== undefined)
87
- oldbie.description = description;
88
- else if (oldbie === undefined)
89
- output[status] = {
90
- description: description ?? "",
91
- content: {
92
- "application/json": {
93
- schema: {},
94
- },
95
- },
96
- };
97
- }
98
-
99
- //----
100
- // SUCCESS
101
- //----
102
- // STATUS
103
- const status: string =
104
- route.status !== undefined
105
- ? String(route.status)
106
- : route.method === "POST"
107
- ? "201"
108
- : "200";
109
-
110
- // SCHEMA
111
- const result = MetadataFactory.analyze(props.checker)({
112
- escape: true,
113
- constant: true,
114
- absorb: false,
115
- validate: (meta) => {
116
- const bigint: boolean =
117
- meta.atomics.some((a) => a.type === "bigint") ||
118
- meta.constants.some((a) => a.type === "bigint");
119
- return bigint ? ["bigint type is not allowed."] : [];
120
- },
121
- })(props.collection)(route.output.type);
122
- if (result.success === false)
123
- props.errors.push(
124
- ...result.errors.map((e) => ({
125
- ...e,
126
- route,
127
- from: "response",
128
- })),
129
- );
130
-
131
- // DO ASSIGN
132
- const description =
133
- describe(route, "return") ?? describe(route, "returns");
134
- output[status] = {
135
- description: route.encrypted
136
- ? `${warning.get(!!description, "response", route.method)}${
137
- description ?? ""
138
- }`
139
- : description ?? "",
140
- content:
141
- route.output.typeName === "void"
142
- ? undefined
143
- : {
144
- [route.output.contentType]: {
145
- schema: coalesce(props)(result),
146
- ...{
147
- example: route.example,
148
- examples: route.examples,
149
- },
150
- },
151
- },
152
- ...(props.config.additional === true
153
- ? {
154
- "x-nestia-encrypted": route.encrypted,
155
- }
156
- : route.encrypted === true
157
- ? {
158
- "x-nestia-encrypted": true,
159
- }
160
- : {}),
161
- };
162
- return output;
163
- };
164
-
165
- export const body =
166
- (props: IProps) =>
167
- (route: ITypedHttpRoute) =>
168
- (param: ITypedHttpRoute.IParameter): OpenApi.IOperation.IRequestBody => {
169
- // ANALZE TYPE WITH VALIDATION
170
- const result = MetadataFactory.analyze(props.checker)({
171
- escape: true,
172
- constant: true,
173
- absorb: true,
174
- validate: (meta) => {
175
- const bigint: boolean =
176
- meta.atomics.some((a) => a.type === "bigint") ||
177
- meta.constants.some((a) => a.type === "bigint");
178
- return bigint ? ["bigint type is not allowed."] : [];
179
- },
180
- })(props.collection)(param.type);
181
- if (result.success === false)
182
- props.errors.push(
183
- ...result.errors.map((e) => ({
184
- ...e,
185
- route,
186
- from: param.name,
187
- })),
188
- );
189
-
190
- // LIST UP PROPERTIES
191
- const contentType =
192
- param.custom && param.category === "body"
193
- ? param.contentType
194
- : "application/json";
195
- const encrypted: boolean =
196
- param.custom && param.category === "body" && param.encrypted;
197
- const description: string | undefined = describe(
198
- route,
199
- "param",
200
- param.name,
201
- );
202
-
203
- // RETURNS WITH LAZY CONSTRUCTION
204
- const schema: OpenApi.IJsonSchema = coalesce(props)(result);
205
- return {
206
- description: encrypted
207
- ? `${warning.get(!!description, "request")}${description ?? ""}`
208
- : description,
209
- content: {
210
- [contentType]: {
211
- schema,
212
- ...{
213
- example: param.example,
214
- examples: param.examples,
215
- },
216
- },
217
- },
218
- required: true,
219
- ...(props.config.additional === true
220
- ? {
221
- "x-nestia-encrypted": encrypted,
222
- }
223
- : encrypted === true
224
- ? {
225
- "x-nestia-encrypted": true,
226
- }
227
- : {}),
228
- };
229
- };
230
-
231
- export const parameter =
232
- (props: IProps) =>
233
- (route: ITypedHttpRoute) =>
234
- (param: ITypedHttpRoute.IParameter): OpenApi.IOperation.IParameter[] =>
235
- param.category === "headers"
236
- ? headers(props)(route)(param)
237
- : param.category === "param"
238
- ? [path(props)(route)(param)]
239
- : query(props)(route)(param);
240
-
241
- const path =
242
- (props: IProps) =>
243
- (route: ITypedHttpRoute) =>
244
- (param: ITypedHttpRoute.IParameter): OpenApi.IOperation.IParameter => {
245
- // ANALZE TYPE WITH VALIDATION
246
- const result = MetadataFactory.analyze(props.checker)({
247
- escape: false,
248
- constant: true,
249
- absorb: true,
250
- validate: SwaggerSchemaValidator.path,
251
- })(props.collection)(param.type);
252
- if (result.success === false)
253
- props.errors.push(
254
- ...result.errors.map((e) => ({
255
- ...e,
256
- route,
257
- from: param.name,
258
- })),
259
- );
260
-
261
- // RETURNS WITH LAZY CONSTRUCTION
262
- return lazy(props)(route)(param, result);
263
- };
264
-
265
- const headers =
266
- (props: IProps) =>
267
- (route: ITypedHttpRoute) =>
268
- (param: ITypedHttpRoute.IParameter): OpenApi.IOperation.IParameter[] =>
269
- decomposible(props)(route)(param)(
270
- MetadataFactory.analyze(props.checker)({
271
- escape: false,
272
- constant: true,
273
- absorb: true,
274
- validate: param.custom ? SwaggerSchemaValidator.headers : undefined,
275
- })(props.collection)(param.type),
276
- );
277
-
278
- const query =
279
- (props: IProps) =>
280
- (route: ITypedHttpRoute) =>
281
- (param: ITypedHttpRoute.IParameter): OpenApi.IOperation.IParameter[] =>
282
- decomposible(props)(route)(param)(
283
- MetadataFactory.analyze(props.checker)({
284
- escape: false,
285
- constant: true,
286
- absorb: true,
287
- validate: param.custom ? SwaggerSchemaValidator.query : undefined,
288
- })(props.collection)(param.type),
289
- );
290
-
291
- const decomposible =
292
- (props: IProps) =>
293
- (route: ITypedHttpRoute) =>
294
- (param: ITypedHttpRoute.IParameter) =>
295
- (
296
- result: ValidationPipe<Metadata, MetadataFactory.IError>,
297
- ): OpenApi.IOperation.IParameter[] => {
298
- const decoded: OpenApi.IOperation.IParameter = lazy(props)(route)(
299
- param,
300
- result,
301
- );
302
- if (result.success === false) {
303
- props.errors.push(
304
- ...result.errors.map((e) => ({
305
- ...e,
306
- route,
307
- from: param.name,
308
- })),
309
- );
310
- return [decoded];
311
- } else if (
312
- props.config.decompose === false ||
313
- result.data.objects.length === 0
314
- )
315
- return [decoded];
316
-
317
- return result.data.objects[0].properties
318
- .filter((p) => p.jsDocTags.every((tag) => tag.name !== "hidden"))
319
- .map((p) => {
320
- const schema: OpenApi.IJsonSchema = {};
321
- props.lazyProperties.push({
322
- schema,
323
- object: result.data.objects[0].name,
324
- property: p.key.constants[0].values[0].value as string,
325
- });
326
- return {
327
- name: p.key.constants[0].values[0].value as string,
328
- in:
329
- param.category === "headers"
330
- ? "header"
331
- : (param.category as "path"),
332
- schema,
333
- required: p.value.isRequired(),
334
- ...SwaggerDescriptionGenerator.generate({
335
- description: p.description ?? undefined,
336
- jsDocTags: p.jsDocTags,
337
- kind: "title",
338
- }),
339
- } satisfies OpenApi.IOperation.IParameter;
340
- });
341
- };
342
-
343
- const lazy =
344
- (props: IProps) =>
345
- (route: ITypedHttpRoute) =>
346
- (
347
- p: ITypedHttpRoute.IParameter,
348
- result: ValidationPipe<Metadata, MetadataFactory.IError>,
349
- ): OpenApi.IOperation.IParameter => {
350
- const schema: OpenApi.IJsonSchema = coalesce(props)(result);
351
- return {
352
- name: p.field ?? p.name,
353
- in:
354
- p.category === "headers"
355
- ? "header"
356
- : p.category === "param"
357
- ? "path"
358
- : "query",
359
- schema,
360
- required: result.success ? result.data.isRequired() : true,
361
- ...SwaggerDescriptionGenerator.generate({
362
- description:
363
- p.description ??
364
- p.jsDocTags.find((tag) => tag.name === "description")?.text?.[0]
365
- .text ??
366
- route.jsDocTags
367
- .find(
368
- (tag) => tag.name === "param" && tag.text?.[0].text === p.name,
369
- )
370
- ?.text?.map((e) => e.text)
371
- .join("")
372
- .substring(p.name.length),
373
- jsDocTags: p.jsDocTags,
374
- kind: "title",
375
- }),
376
- ...{
377
- example: p.example,
378
- examples: p.examples,
379
- },
380
- };
381
- };
382
-
383
- const coalesce =
384
- (props: IProps) =>
385
- (
386
- result: ValidationPipe<Metadata, MetadataFactory.IError>,
387
- ): OpenApi.IJsonSchema => {
388
- const schema: OpenApi.IJsonSchema = {} as any;
389
- props.lazySchemas.push({
390
- metadata: result.success ? result.data : any.get(),
391
- schema,
392
- });
393
- return schema;
394
- };
395
-
396
- const describe = (
397
- route: ITypedHttpRoute,
398
- tagName: string,
399
- parameterName?: string,
400
- ): string | undefined => {
401
- const parametric: (elem: ts.JSDocTagInfo) => boolean = parameterName
402
- ? (tag) =>
403
- tag.text!.find(
404
- (elem) =>
405
- elem.kind === "parameterName" && elem.text === parameterName,
406
- ) !== undefined
407
- : () => true;
408
-
409
- const tag: ts.JSDocTagInfo | undefined = route.jsDocTags.find(
410
- (tag) => tag.name === tagName && tag.text && parametric(tag),
411
- );
412
- return tag && tag.text
413
- ? tag.text.find((elem) => elem.kind === "text")?.text
414
- : undefined;
415
- };
416
- }
417
-
418
- const warning = new VariadicSingleton(
419
- (described: boolean, type: "request" | "response", method?: string) => {
420
- const summary =
421
- type === "request"
422
- ? "Request body must be encrypted."
423
- : "Response data have been encrypted.";
424
- const component =
425
- type === "request"
426
- ? "[EncryptedBody](https://github.com/samchon/@nestia/core#encryptedbody)"
427
- : `[EncryptedRoute.${method![0].toUpperCase()}.${method!
428
- .substring(1)
429
- .toLowerCase()}](https://github.com/samchon/@nestia/core#encryptedroute)`;
430
-
431
- const content: string[] = [
432
- "## Warning",
433
- "",
434
- summary,
435
- "",
436
- `The ${type} body data would be encrypted as "AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding", through the ${component} component.`,
437
- "",
438
- `Therefore, just utilize this swagger editor only for referencing. If you need to call the real API, using [SDK](https://github.com/samchon/nestia#software-development-kit) would be much better.`,
439
- ];
440
- if (described === true) content.push("", "----------------", "", "");
441
- return content.join("\n");
442
- },
443
- );
444
-
445
- const any = new Singleton(() =>
446
- Metadata.from(
447
- {
448
- any: true,
449
- required: true,
450
- optional: false,
451
- nullable: false,
452
- functional: false,
453
- atomics: [],
454
- constants: [],
455
- templates: [],
456
- escaped: null,
457
- rest: null,
458
- arrays: [],
459
- tuples: [],
460
- objects: [],
461
- aliases: [],
462
- natives: [],
463
- sets: [],
464
- maps: [],
465
- },
466
- {
467
- aliases: new Map(),
468
- arrays: new Map(),
469
- tuples: new Map(),
470
- objects: new Map(),
471
- },
472
- ),
473
- );
@@ -1,206 +0,0 @@
1
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
2
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
3
- import { MetadataArray } from "typia/lib/schemas/metadata/MetadataArray";
4
-
5
- export namespace SwaggerSchemaValidator {
6
- export const path = (meta: Metadata): string[] => {
7
- const errors: string[] = [];
8
- const insert = (msg: string) => errors.push(msg);
9
-
10
- if (meta.any) insert("do not allow any type");
11
- if (meta.isRequired() === false) insert("do not allow undefindable type");
12
-
13
- const atomics = CoreMetadataUtil.atomics(meta);
14
- const expected: number =
15
- meta.atomics.length +
16
- meta.templates.length +
17
- meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
18
- if (meta.size() !== expected || atomics.size === 0)
19
- insert("only atomic or constant types are allowed");
20
- if (atomics.size > 1) insert("do not allow union type");
21
-
22
- return errors;
23
- };
24
-
25
- export const query = (
26
- meta: Metadata,
27
- explore: MetadataFactory.IExplore,
28
- ): string[] => {
29
- const errors: string[] = [];
30
- const insert = (msg: string) => errors.push(msg);
31
-
32
- if (explore.top === true) {
33
- // TOP MUST BE ONLY OBJECT
34
- if (meta.objects.length !== 1 || meta.bucket() !== 1)
35
- insert("only one object type is allowed.");
36
- if (meta.nullable === true) insert("query parameters cannot be null.");
37
- if (meta.isRequired() === false) {
38
- const everyPropertiesAreOptional: boolean =
39
- meta.size() === 1 &&
40
- meta.objects.length === 1 &&
41
- meta.objects[0].properties.every((p) => p.value.optional);
42
- if (everyPropertiesAreOptional === false)
43
- insert(
44
- "query parameters can be optional only when every properties are optional.",
45
- );
46
- }
47
- } else if (
48
- explore.nested !== null &&
49
- explore.nested instanceof MetadataArray
50
- ) {
51
- const atomics = CoreMetadataUtil.atomics(meta);
52
- const expected: number =
53
- meta.atomics.length +
54
- meta.templates.length +
55
- meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
56
- if (atomics.size > 1) insert("union type is not allowed in array.");
57
- if (meta.nullable) insert("nullable type is not allowed in array.");
58
- if (meta.isRequired() === false)
59
- insert("optional type is not allowed in array.");
60
- if (meta.size() !== expected)
61
- insert("only atomic or constant types are allowed in array.");
62
- } else if (explore.object && explore.property !== null) {
63
- //----
64
- // COMMON
65
- //----
66
- // PROPERTY MUST BE SOLE
67
- if (typeof explore.property === "object")
68
- insert("dynamic property is not allowed.");
69
- // DO NOT ALLOW TUPLE TYPE
70
- if (meta.tuples.length) insert("tuple type is not allowed.");
71
- // DO NOT ALLOW UNION TYPE
72
- if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
73
- // DO NOT ALLOW NESTED OBJECT
74
- if (
75
- meta.objects.length ||
76
- meta.sets.length ||
77
- meta.maps.length ||
78
- meta.natives.length
79
- )
80
- insert("nested object type is not allowed.");
81
-
82
- //----
83
- // ARRAY CASES
84
- //----
85
- const isArray: boolean = meta.arrays.length > 1 || meta.tuples.length > 1;
86
- // ARRAY TYPE MUST BE REQUIRED
87
- if (isArray && meta.isRequired() === false)
88
- insert("optional type is not allowed when array.");
89
- // SET-COOKIE MUST BE ARRAY
90
- if (explore.property === "set-cookie" && !isArray)
91
- insert("set-cookie property must be array.");
92
- }
93
- return errors;
94
- };
95
-
96
- export const headers = (
97
- meta: Metadata,
98
- explore: MetadataFactory.IExplore,
99
- ): string[] => {
100
- const errors: string[] = [];
101
- const insert = (msg: string) => errors.push(msg);
102
-
103
- if (explore.top === true) {
104
- // TOP MUST BE ONLY OBJECT
105
- if (meta.objects.length !== 1 || meta.bucket() !== 1)
106
- insert("only one object type is allowed.");
107
- if (meta.nullable === true) insert("headers cannot be null.");
108
- if (meta.isRequired() === false) insert("headers cannot be null.");
109
- } else if (
110
- explore.nested !== null &&
111
- explore.nested instanceof MetadataArray
112
- ) {
113
- const atomics = CoreMetadataUtil.atomics(meta);
114
- const expected: number =
115
- meta.atomics.length +
116
- meta.templates.length +
117
- meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
118
- if (atomics.size > 1) insert("union type is not allowed in array.");
119
- if (meta.nullable) insert("nullable type is not allowed in array.");
120
- if (meta.isRequired() === false) insert("optional type is not allowed.");
121
- if (meta.size() !== expected)
122
- insert("only atomic or constant types are allowed in array.");
123
- } else if (explore.object && explore.property !== null) {
124
- //----
125
- // COMMON
126
- //----
127
- // PROPERTY MUST BE SOLE
128
- if (typeof explore.property === "object")
129
- insert("dynamic property is not allowed.");
130
- // DO NOT ALLOW TUPLE TYPE
131
- if (meta.tuples.length) insert("tuple type is not allowed.");
132
- // DO NOT ALLOW UNION TYPE
133
- if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
134
- // DO NOT ALLOW NESTED OBJECT
135
- if (
136
- meta.objects.length ||
137
- meta.sets.length ||
138
- meta.maps.length ||
139
- meta.natives.length
140
- )
141
- insert("nested object type is not allowed.");
142
- // DO NOT ALLOW NULLABLE
143
- if (meta.nullable) insert("nullable type is not allowed.");
144
-
145
- //----
146
- // ARRAY CASES
147
- //----
148
- const isArray: boolean = meta.arrays.length > 1;
149
- // ARRAY TYPE MUST BE REQUIRED
150
- if (isArray && meta.isRequired() === false)
151
- insert("optional type is not allowed when array.");
152
- // SET-COOKIE MUST BE ARRAY
153
- if (explore.property === "set-cookie" && !isArray)
154
- insert("set-cookie property must be array.");
155
- // MUST BE SINGULAR CASE
156
- if (
157
- typeof explore.property === "string" &&
158
- SINGULAR.has(explore.property) &&
159
- isArray
160
- )
161
- insert("property cannot be array.");
162
- }
163
- return errors;
164
- };
165
- }
166
-
167
- namespace CoreMetadataUtil {
168
- export const atomics = (
169
- meta: Metadata,
170
- ): Set<"boolean" | "bigint" | "number" | "string"> =>
171
- new Set([
172
- ...meta.atomics.map((a) => a.type),
173
- ...meta.constants.map((c) => c.type),
174
- ...(meta.templates.length ? (["string"] as const) : []),
175
- ]);
176
-
177
- export const isUnion = (meta: Metadata): boolean =>
178
- atomics(meta).size +
179
- meta.arrays.length +
180
- meta.tuples.length +
181
- meta.natives.length +
182
- meta.maps.length +
183
- meta.objects.length >
184
- 1;
185
- }
186
-
187
- const SINGULAR: Set<string> = new Set([
188
- "age",
189
- "authorization",
190
- "content-length",
191
- "content-type",
192
- "etag",
193
- "expires",
194
- "from",
195
- "host",
196
- "if-modified-since",
197
- "if-unmodified-since",
198
- "last-modified",
199
- "location",
200
- "max-forwards",
201
- "proxy-authorization",
202
- "referer",
203
- "retry-after",
204
- "server",
205
- "user-agent",
206
- ]);
@@ -1,6 +0,0 @@
1
- export interface IErrorReport {
2
- file: string;
3
- controller: string;
4
- function: string | null;
5
- message: string;
6
- }
@@ -1,20 +0,0 @@
1
- import { RouteInfo, VersionValue } from "@nestjs/common/interfaces";
2
-
3
- export interface INormalizedInput {
4
- include: INormalizedInput.IInput[];
5
- globalPrefix?: {
6
- prefix: string;
7
- exclude?: Array<string | RouteInfo>;
8
- };
9
- versioning?: {
10
- prefix: string;
11
- defaultVersion?: VersionValue;
12
- };
13
- }
14
- export namespace INormalizedInput {
15
- export interface IInput {
16
- paths: string[];
17
- file: string;
18
- controller?: Function;
19
- }
20
- }