@nestia/sdk 3.10.0 → 3.11.0-dev.20240812
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/NestiaSdkApplication.d.ts +1 -3
- package/lib/NestiaSdkApplication.js +138 -136
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +2 -2
- package/lib/analyses/ConfigAnalyzer.js +39 -80
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +0 -16
- package/lib/analyses/ExceptionAnalyzer.js +142 -105
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/GenericAnalyzer.d.ts +1 -2
- package/lib/analyses/GenericAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +6 -11
- package/lib/analyses/ImportAnalyzer.js +70 -42
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +7 -1
- package/lib/analyses/ReflectControllerAnalyzer.js +28 -99
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +72 -152
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +215 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +81 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +1 -3
- package/lib/analyses/ReflectMetadataAnalyzer.js +0 -4
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +72 -48
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +15 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js +111 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +10 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +9 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -0
- package/lib/decorators/OperationMetadata.d.ts +2 -0
- package/lib/decorators/OperationMetadata.js +10 -0
- package/lib/decorators/OperationMetadata.js.map +1 -0
- package/lib/executable/internal/NestiaConfigLoader.d.ts +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +33 -3
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +0 -5
- package/lib/generates/CloneGenerator.js +60 -60
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +2 -3
- package/lib/generates/E2eGenerator.js +9 -8
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/OpenAiGenerator.d.ts +2 -4
- package/lib/generates/OpenAiGenerator.js +13 -3
- package/lib/generates/OpenAiGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +4 -4
- package/lib/generates/SdkGenerator.js +63 -73
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +6 -18
- package/lib/generates/SwaggerGenerator.js +60 -235
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +5 -9
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +6 -4
- package/lib/generates/internal/SdkAliasCollection.js +33 -31
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +4 -1
- package/lib/generates/internal/SdkDistributionComposer.js +6 -6
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -4
- package/lib/generates/internal/SdkFileProgrammer.js +6 -6
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +0 -12
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +142 -97
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +37 -59
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +31 -48
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +7 -3
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +7 -13
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +11 -16
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +7 -10
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +23 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +12 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +68 -0
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +99 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +9 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +91 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +5 -5
- package/lib/structures/INestiaSdkInput.d.ts +20 -0
- package/lib/structures/{ISwaggerError.js → INestiaSdkInput.js} +1 -1
- package/lib/structures/INestiaSdkInput.js.map +1 -0
- package/lib/structures/IReflectApplication.d.ts +6 -0
- package/lib/structures/IReflectApplication.js +3 -0
- package/lib/structures/IReflectApplication.js.map +1 -0
- package/lib/structures/IReflectController.d.ts +3 -5
- package/lib/structures/IReflectHttpOperation.d.ts +13 -65
- package/lib/structures/IReflectHttpOperationException.d.ts +14 -0
- package/lib/structures/IReflectHttpOperationException.js +3 -0
- package/lib/structures/IReflectHttpOperationException.js.map +1 -0
- package/lib/structures/IReflectHttpOperationParameter.d.ts +35 -0
- package/lib/structures/IReflectHttpOperationParameter.js +3 -0
- package/lib/structures/IReflectHttpOperationParameter.js.map +1 -0
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -0
- package/lib/structures/IReflectHttpOperationSuccess.js +3 -0
- package/lib/structures/IReflectHttpOperationSuccess.js.map +1 -0
- package/lib/structures/IReflectOperationError.d.ts +16 -0
- package/lib/structures/IReflectOperationError.js +23 -0
- package/lib/structures/IReflectOperationError.js.map +1 -0
- package/lib/structures/IReflectType.d.ts +4 -0
- package/lib/structures/{IErrorReport.js → IReflectType.js} +1 -1
- package/lib/structures/IReflectType.js.map +1 -0
- package/lib/structures/IReflectTypeImport.d.ts +4 -0
- package/lib/structures/{ISwaggerLazySchema.js → IReflectTypeImport.js} +1 -1
- package/lib/structures/IReflectTypeImport.js.map +1 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +8 -9
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +23 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js +3 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js.map +1 -0
- package/lib/structures/ITypedApplication.d.ts +7 -0
- package/lib/structures/{INormalizedInput.js → ITypedApplication.js} +1 -1
- package/lib/structures/ITypedApplication.js.map +1 -0
- package/lib/structures/ITypedHttpRoute.d.ts +14 -42
- package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteException.js +3 -0
- package/lib/structures/ITypedHttpRouteException.js.map +1 -0
- package/lib/structures/ITypedHttpRouteParameter.d.ts +31 -0
- package/lib/structures/ITypedHttpRouteParameter.js +3 -0
- package/lib/structures/ITypedHttpRouteParameter.js.map +1 -0
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +19 -0
- package/lib/structures/{ISwaggerLazyProperty.js → ITypedHttpRouteSuccess.js} +1 -1
- package/lib/structures/ITypedHttpRouteSuccess.js.map +1 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +8 -44
- package/lib/structures/ITypedWebSocketRouteParameter.d.ts +2 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js +3 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js.map +1 -0
- package/lib/transform.d.ts +3 -0
- package/lib/transform.js +8 -0
- package/lib/transform.js.map +1 -0
- package/lib/transformers/IOperationMetadata.d.ts +36 -0
- package/lib/transformers/IOperationMetadata.js +3 -0
- package/lib/transformers/IOperationMetadata.js.map +1 -0
- package/lib/transformers/ISdkTransformerContext.d.ts +7 -0
- package/lib/transformers/ISdkTransformerContext.js +3 -0
- package/lib/transformers/ISdkTransformerContext.js.map +1 -0
- package/lib/transformers/SdkMetadataProgrammer.d.ts +11 -0
- package/lib/transformers/SdkMetadataProgrammer.js +159 -0
- package/lib/transformers/SdkMetadataProgrammer.js.map +1 -0
- package/lib/transformers/SdkTransformer.d.ts +4 -0
- package/lib/transformers/SdkTransformer.js +88 -0
- package/lib/transformers/SdkTransformer.js.map +1 -0
- package/lib/transformers/TextPlainValidator.d.ts +4 -0
- package/lib/transformers/TextPlainValidator.js +19 -0
- package/lib/transformers/TextPlainValidator.js.map +1 -0
- package/lib/utils/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil.js +1 -0
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +8 -8
- package/src/NestiaSdkApplication.ts +173 -160
- package/src/analyses/ConfigAnalyzer.ts +50 -98
- package/src/analyses/ExceptionAnalyzer.ts +142 -142
- package/src/analyses/GenericAnalyzer.ts +3 -5
- package/src/analyses/ImportAnalyzer.ts +130 -115
- package/src/analyses/ReflectControllerAnalyzer.ts +63 -115
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +142 -278
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +319 -0
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +117 -0
- package/src/analyses/ReflectMetadataAnalyzer.ts +1 -18
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +143 -78
- package/src/analyses/TypedHttpRouteAnalyzer.ts +178 -0
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +18 -0
- package/src/decorators/OperationMetadata.ts +15 -0
- package/src/executable/internal/NestiaConfigLoader.ts +17 -3
- package/src/executable/internal/NestiaSdkCommand.ts +1 -4
- package/src/generates/CloneGenerator.ts +60 -59
- package/src/generates/E2eGenerator.ts +20 -21
- package/src/generates/OpenAiGenerator.ts +44 -45
- package/src/generates/SdkGenerator.ts +97 -125
- package/src/generates/SwaggerGenerator.ts +114 -416
- package/src/generates/internal/E2eFileProgrammer.ts +5 -14
- package/src/generates/internal/SdkAliasCollection.ts +33 -41
- package/src/generates/internal/SdkDistributionComposer.ts +9 -6
- package/src/generates/internal/SdkFileProgrammer.ts +11 -14
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +142 -142
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +20 -47
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +245 -275
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +7 -7
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +11 -23
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +197 -233
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +5 -15
- package/src/generates/internal/{SwaggerDescriptionGenerator.ts → SwaggerDescriptionComposer.ts} +25 -5
- package/src/generates/internal/SwaggerOperationComposer.ts +90 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +173 -0
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +110 -0
- package/src/structures/INestiaProject.ts +5 -5
- package/src/structures/INestiaSdkInput.ts +25 -0
- package/src/structures/IReflectApplication.ts +8 -0
- package/src/structures/IReflectController.ts +3 -5
- package/src/structures/IReflectHttpOperation.ts +14 -76
- package/src/structures/IReflectHttpOperationException.ts +19 -0
- package/src/structures/IReflectHttpOperationParameter.ts +81 -0
- package/src/structures/IReflectHttpOperationSuccess.ts +22 -0
- package/src/structures/IReflectOperationError.ts +26 -0
- package/src/structures/IReflectType.ts +4 -0
- package/src/structures/IReflectTypeImport.ts +4 -0
- package/src/structures/IReflectWebSocketOperation.ts +9 -9
- package/src/structures/IReflectWebSocketOperationParameter.ts +38 -0
- package/src/structures/ITypedApplication.ts +8 -0
- package/src/structures/ITypedHttpRoute.ts +15 -45
- package/src/structures/ITypedHttpRouteException.ts +15 -0
- package/src/structures/ITypedHttpRouteParameter.ts +41 -0
- package/src/structures/ITypedHttpRouteSuccess.ts +22 -0
- package/src/structures/ITypedWebSocketRoute.ts +8 -56
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -0
- package/src/transform.ts +9 -0
- package/src/transformers/IOperationMetadata.ts +38 -0
- package/src/transformers/ISdkTransformerContext.ts +8 -0
- package/src/transformers/SdkMetadataProgrammer.ts +227 -0
- package/src/transformers/SdkTransformer.ts +168 -0
- package/src/transformers/TextPlainValidator.ts +17 -0
- package/src/utils/StringUtil.ts +3 -0
- package/lib/analyses/TypedControllerAnalyzer.d.ts +0 -8
- package/lib/analyses/TypedControllerAnalyzer.js +0 -77
- package/lib/analyses/TypedControllerAnalyzer.js.map +0 -1
- package/lib/analyses/TypedHttpOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedHttpOperationAnalyzer.js +0 -263
- package/lib/analyses/TypedHttpOperationAnalyzer.js.map +0 -1
- package/lib/analyses/TypedWebSocketOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js +0 -226
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +0 -1
- package/lib/generates/internal/SwaggerDescriptionGenerator.d.ts +0 -14
- package/lib/generates/internal/SwaggerDescriptionGenerator.js +0 -33
- package/lib/generates/internal/SwaggerDescriptionGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +0 -21
- package/lib/generates/internal/SwaggerSchemaGenerator.js +0 -289
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaValidator.d.ts +0 -7
- package/lib/generates/internal/SwaggerSchemaValidator.js +0 -191
- package/lib/generates/internal/SwaggerSchemaValidator.js.map +0 -1
- package/lib/structures/IErrorReport.d.ts +0 -6
- package/lib/structures/IErrorReport.js.map +0 -1
- package/lib/structures/INormalizedInput.d.ts +0 -19
- package/lib/structures/INormalizedInput.js.map +0 -1
- package/lib/structures/ISwaggerError.d.ts +0 -6
- package/lib/structures/ISwaggerError.js.map +0 -1
- package/lib/structures/ISwaggerLazyProperty.d.ts +0 -6
- package/lib/structures/ISwaggerLazyProperty.js.map +0 -1
- package/lib/structures/ISwaggerLazySchema.d.ts +0 -6
- package/lib/structures/ISwaggerLazySchema.js.map +0 -1
- package/lib/structures/ITypeTuple.d.ts +0 -5
- package/lib/structures/ITypeTuple.js +0 -3
- package/lib/structures/ITypeTuple.js.map +0 -1
- package/src/analyses/TypedControllerAnalyzer.ts +0 -92
- package/src/analyses/TypedHttpOperationAnalyzer.ts +0 -365
- package/src/analyses/TypedWebSocketOperationAnalyzer.ts +0 -375
- package/src/generates/internal/SwaggerSchemaGenerator.ts +0 -473
- package/src/generates/internal/SwaggerSchemaValidator.ts +0 -206
- package/src/structures/IErrorReport.ts +0 -6
- package/src/structures/INormalizedInput.ts +0 -20
- package/src/structures/ISwaggerError.ts +0 -8
- package/src/structures/ISwaggerLazyProperty.ts +0 -7
- package/src/structures/ISwaggerLazySchema.ts +0 -7
- package/src/structures/ITypeTuple.ts +0 -6
|
@@ -5,140 +5,88 @@ import {
|
|
|
5
5
|
} from "@nestjs/common/constants";
|
|
6
6
|
|
|
7
7
|
import { INestiaProject } from "../structures/INestiaProject";
|
|
8
|
+
import { INestiaSdkInput } from "../structures/INestiaSdkInput";
|
|
8
9
|
import { IReflectController } from "../structures/IReflectController";
|
|
9
10
|
import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
10
11
|
import { IReflectWebSocketOperation } from "../structures/IReflectWebSocketOperation";
|
|
12
|
+
import { IOperationMetadata } from "../transformers/IOperationMetadata";
|
|
11
13
|
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
12
14
|
import { ReflectHttpOperationAnalyzer } from "./ReflectHttpOperationAnalyzer";
|
|
13
15
|
import { ReflectMetadataAnalyzer } from "./ReflectMetadataAnalyzer";
|
|
14
16
|
import { ReflectWebSocketOperationAnalyzer } from "./ReflectWebSocketOperationAnalyzer";
|
|
15
17
|
|
|
16
|
-
type IModule = {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
18
|
export namespace ReflectControllerAnalyzer {
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
prefixes: string[],
|
|
27
|
-
target?: Function,
|
|
28
|
-
): Promise<IReflectController[]> => {
|
|
29
|
-
const module: IModule = await (async () => {
|
|
30
|
-
try {
|
|
31
|
-
return await import(file);
|
|
32
|
-
} catch (exp) {
|
|
33
|
-
console.log(
|
|
34
|
-
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
35
|
-
);
|
|
36
|
-
console.log(`Error on "${file}" file. Check your code.`);
|
|
37
|
-
console.log(exp);
|
|
38
|
-
console.log(
|
|
39
|
-
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
|
|
40
|
-
);
|
|
41
|
-
process.exit(-1);
|
|
42
|
-
}
|
|
43
|
-
})();
|
|
44
|
-
const ret: IReflectController[] = [];
|
|
45
|
-
|
|
46
|
-
for (const [key, value] of Object.entries(module)) {
|
|
47
|
-
if (typeof value !== "function" || unique.has(value)) continue;
|
|
48
|
-
else if ((target ?? value) !== value) continue;
|
|
49
|
-
else unique.add(value);
|
|
50
|
-
|
|
51
|
-
const result: IReflectController | null = _Analyze_controller(project)({
|
|
52
|
-
file,
|
|
53
|
-
name: key,
|
|
54
|
-
creator: value,
|
|
55
|
-
prefixes,
|
|
56
|
-
});
|
|
57
|
-
if (result !== null) ret.push(result);
|
|
58
|
-
}
|
|
59
|
-
return ret;
|
|
60
|
-
};
|
|
61
|
-
|
|
19
|
+
export interface IProps {
|
|
20
|
+
project: INestiaProject;
|
|
21
|
+
controller: INestiaSdkInput.IController;
|
|
22
|
+
unique: WeakSet<Function>;
|
|
23
|
+
}
|
|
62
24
|
/* ---------------------------------------------------------
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
|
|
77
|
-
if (
|
|
78
|
-
!(
|
|
79
|
-
props.creator instanceof Function &&
|
|
80
|
-
props.creator.constructor instanceof Function
|
|
81
|
-
)
|
|
82
|
-
)
|
|
83
|
-
return null;
|
|
84
|
-
// MUST HAVE THOSE MATADATA
|
|
85
|
-
else if (
|
|
86
|
-
ArrayUtil.has(
|
|
87
|
-
Reflect.getMetadataKeys(props.creator),
|
|
88
|
-
PATH_METADATA,
|
|
89
|
-
HOST_METADATA,
|
|
90
|
-
SCOPE_OPTIONS_METADATA,
|
|
91
|
-
) === false
|
|
92
|
-
)
|
|
93
|
-
return null;
|
|
25
|
+
CONTROLLER
|
|
26
|
+
--------------------------------------------------------- */
|
|
27
|
+
export const analyze = (props: IProps): IReflectController | null => {
|
|
28
|
+
// MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
|
|
29
|
+
if (
|
|
30
|
+
ArrayUtil.has(
|
|
31
|
+
Reflect.getMetadataKeys(props.controller.class),
|
|
32
|
+
PATH_METADATA,
|
|
33
|
+
HOST_METADATA,
|
|
34
|
+
SCOPE_OPTIONS_METADATA,
|
|
35
|
+
) === false
|
|
36
|
+
)
|
|
37
|
+
return null;
|
|
94
38
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
name: props.name,
|
|
104
|
-
operations: [],
|
|
105
|
-
prefixes: props.prefixes,
|
|
106
|
-
paths: ReflectMetadataAnalyzer.paths(props.creator).filter((str) => {
|
|
39
|
+
// BASIC INFO
|
|
40
|
+
const controller: IReflectController = {
|
|
41
|
+
class: props.controller.class,
|
|
42
|
+
file: props.controller.location,
|
|
43
|
+
operations: [],
|
|
44
|
+
prefixes: props.controller.prefixes,
|
|
45
|
+
paths: ReflectMetadataAnalyzer.paths(props.controller.class).filter(
|
|
46
|
+
(str) => {
|
|
107
47
|
if (str.includes("*") === true) {
|
|
108
|
-
project.warnings.push({
|
|
109
|
-
file: props.
|
|
110
|
-
|
|
48
|
+
props.project.warnings.push({
|
|
49
|
+
file: props.controller.location,
|
|
50
|
+
class: props.controller.class.name,
|
|
111
51
|
function: null,
|
|
112
|
-
|
|
52
|
+
from: null,
|
|
53
|
+
contents: ["@nestia/sdk does not compose wildcard controller."],
|
|
113
54
|
});
|
|
114
55
|
return false;
|
|
115
56
|
}
|
|
116
57
|
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// PARSE CHILDREN DATA
|
|
125
|
-
for (const [key, value] of _Get_prototype_entries(props.creator)) {
|
|
126
|
-
if (typeof value !== "function") continue;
|
|
127
|
-
const next = {
|
|
128
|
-
controller: meta,
|
|
129
|
-
name: key,
|
|
130
|
-
function: value,
|
|
131
|
-
};
|
|
132
|
-
const child: IReflectHttpOperation | IReflectWebSocketOperation | null =
|
|
133
|
-
ReflectWebSocketOperationAnalyzer.analyze(project)(next) ??
|
|
134
|
-
ReflectHttpOperationAnalyzer.analyze(project)(next);
|
|
135
|
-
if (child !== null) meta.operations.push(child);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// RETURNS
|
|
139
|
-
return meta;
|
|
58
|
+
},
|
|
59
|
+
),
|
|
60
|
+
versions: ReflectMetadataAnalyzer.versions(props.controller.class),
|
|
61
|
+
security: ReflectMetadataAnalyzer.securities(props.controller.class),
|
|
62
|
+
tags:
|
|
63
|
+
Reflect.getMetadata("swagger/apiUseTags", props.controller.class) ?? [],
|
|
140
64
|
};
|
|
141
65
|
|
|
66
|
+
// OPERATORS
|
|
67
|
+
for (const [key, value] of _Get_prototype_entries(props.controller.class)) {
|
|
68
|
+
if (typeof value !== "function") continue;
|
|
69
|
+
const metadata: IOperationMetadata | undefined = Reflect.getMetadata(
|
|
70
|
+
"nestia/OperationMetadata",
|
|
71
|
+
props.controller.class.prototype,
|
|
72
|
+
key,
|
|
73
|
+
);
|
|
74
|
+
if (metadata === undefined) continue;
|
|
75
|
+
const next: ReflectHttpOperationAnalyzer.IProps = {
|
|
76
|
+
project: props.project,
|
|
77
|
+
controller: controller,
|
|
78
|
+
name: key,
|
|
79
|
+
function: value,
|
|
80
|
+
metadata,
|
|
81
|
+
};
|
|
82
|
+
const child: IReflectHttpOperation | IReflectWebSocketOperation | null =
|
|
83
|
+
ReflectWebSocketOperationAnalyzer.analyze(next) ??
|
|
84
|
+
ReflectHttpOperationAnalyzer.analyze(next);
|
|
85
|
+
if (child !== null) controller.operations.push(child);
|
|
86
|
+
}
|
|
87
|
+
return controller;
|
|
88
|
+
};
|
|
89
|
+
|
|
142
90
|
function _Get_prototype_entries(creator: any): Array<[string, unknown]> {
|
|
143
91
|
const keyList = Object.getOwnPropertyNames(creator.prototype);
|
|
144
92
|
const entries: Array<[string, unknown]> = keyList.map((key) => [
|
|
@@ -1,300 +1,164 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
HEADERS_METADATA,
|
|
4
|
-
HTTP_CODE_METADATA,
|
|
5
|
-
INTERCEPTORS_METADATA,
|
|
6
|
-
METHOD_METADATA,
|
|
7
|
-
PATH_METADATA,
|
|
8
|
-
ROUTE_ARGS_METADATA,
|
|
9
|
-
} from "@nestjs/common/constants";
|
|
10
|
-
import { RouteParamtypes } from "@nestjs/common/enums/route-paramtypes.enum";
|
|
1
|
+
import { METHOD_METADATA, PATH_METADATA } from "@nestjs/common/constants";
|
|
11
2
|
import { ranges } from "tstl";
|
|
12
3
|
|
|
13
|
-
import { IErrorReport } from "../structures/IErrorReport";
|
|
14
4
|
import { INestiaProject } from "../structures/INestiaProject";
|
|
15
5
|
import { IReflectController } from "../structures/IReflectController";
|
|
16
6
|
import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
17
|
-
import {
|
|
7
|
+
import { IReflectHttpOperationParameter } from "../structures/IReflectHttpOperationParameter";
|
|
8
|
+
import { IReflectHttpOperationSuccess } from "../structures/IReflectHttpOperationSuccess";
|
|
9
|
+
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
10
|
+
import { IOperationMetadata } from "../transformers/IOperationMetadata";
|
|
18
11
|
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
12
|
+
import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
19
13
|
import { PathAnalyzer } from "./PathAnalyzer";
|
|
14
|
+
import { ReflectHttpOperationParameterAnalyzer } from "./ReflectHttpOperationParameterAnalyzer";
|
|
15
|
+
import { ReflectHttpOperationResponseAnalyzer } from "./ReflectHttpOperationResponseAnalyzer";
|
|
20
16
|
import { ReflectMetadataAnalyzer } from "./ReflectMetadataAnalyzer";
|
|
21
17
|
|
|
22
18
|
export namespace ReflectHttpOperationAnalyzer {
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
19
|
+
export interface IProps {
|
|
20
|
+
project: INestiaProject;
|
|
21
|
+
controller: IReflectController;
|
|
22
|
+
function: Function;
|
|
23
|
+
name: string;
|
|
24
|
+
metadata: IOperationMetadata;
|
|
25
|
+
}
|
|
26
|
+
export const analyze = (props: IProps): IReflectHttpOperation | null => {
|
|
27
|
+
if (
|
|
28
|
+
ArrayUtil.has(
|
|
29
|
+
Reflect.getMetadataKeys(props.function),
|
|
30
|
+
PATH_METADATA,
|
|
31
|
+
METHOD_METADATA,
|
|
32
|
+
) === false
|
|
33
|
+
)
|
|
34
|
+
return null;
|
|
35
|
+
|
|
36
|
+
const errors: IReflectOperationError[] = [];
|
|
37
|
+
const method: string =
|
|
38
|
+
METHODS[Reflect.getMetadata(METHOD_METADATA, props.function)];
|
|
39
|
+
if (method === undefined || method === "OPTIONS") return null;
|
|
40
|
+
|
|
41
|
+
const parameters: IReflectHttpOperationParameter[] =
|
|
42
|
+
ReflectHttpOperationParameterAnalyzer.analyze({
|
|
43
|
+
controller: props.controller,
|
|
44
|
+
metadata: props.metadata,
|
|
45
|
+
httpMethod: method,
|
|
46
|
+
function: props.function,
|
|
47
|
+
functionName: props.name,
|
|
48
|
+
errors,
|
|
49
|
+
});
|
|
50
|
+
const success: IReflectHttpOperationSuccess | null = (() => {
|
|
51
|
+
const localErrors: IReflectOperationError[] = [];
|
|
52
|
+
const success = ReflectHttpOperationResponseAnalyzer.analyze({
|
|
53
|
+
controller: props.controller,
|
|
54
|
+
function: props.function,
|
|
55
|
+
functionName: props.name,
|
|
56
|
+
httpMethod: method,
|
|
57
|
+
metadata: props.metadata,
|
|
58
|
+
errors,
|
|
59
|
+
});
|
|
60
|
+
if (localErrors.length) {
|
|
61
|
+
errors.push(...localErrors);
|
|
37
62
|
return null;
|
|
63
|
+
}
|
|
64
|
+
return success;
|
|
65
|
+
})();
|
|
66
|
+
if (errors.length) {
|
|
67
|
+
props.project.errors.push(...errors);
|
|
68
|
+
return null;
|
|
69
|
+
} else if (success === null) return null;
|
|
70
|
+
|
|
71
|
+
// DO CONSTRUCT
|
|
72
|
+
const operation: IReflectHttpOperation = {
|
|
73
|
+
protocol: "http",
|
|
74
|
+
function: props.function,
|
|
75
|
+
name: props.name,
|
|
76
|
+
method: method === "ALL" ? "POST" : method,
|
|
77
|
+
paths: ReflectMetadataAnalyzer.paths(props.function).filter((str) => {
|
|
78
|
+
if (str.includes("*") === true) {
|
|
79
|
+
props.project.warnings.push({
|
|
80
|
+
file: props.controller.file,
|
|
81
|
+
class: props.controller.class.name,
|
|
82
|
+
function: props.name,
|
|
83
|
+
from: "",
|
|
84
|
+
contents: ["@nestia/sdk does not compose wildcard method."],
|
|
85
|
+
});
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}),
|
|
90
|
+
versions: ReflectMetadataAnalyzer.versions(props.function),
|
|
91
|
+
parameters,
|
|
92
|
+
success,
|
|
93
|
+
security: ReflectMetadataAnalyzer.securities(props.function),
|
|
94
|
+
exceptions: {} as any,
|
|
95
|
+
tags: Reflect.getMetadata("swagger/apiUseTags", props.function) ?? [],
|
|
96
|
+
imports: ImportAnalyzer.unique(
|
|
97
|
+
[
|
|
98
|
+
...props.metadata.parameters
|
|
99
|
+
.filter((x) => parameters.some((y) => x.index === y.index))
|
|
100
|
+
.map((x) => x.imports),
|
|
101
|
+
...props.metadata.success.imports,
|
|
102
|
+
].flat(),
|
|
103
|
+
),
|
|
104
|
+
description: props.metadata.description,
|
|
105
|
+
jsDocTags: props.metadata.jsDocTags,
|
|
106
|
+
operationId: props.metadata.jsDocTags
|
|
107
|
+
.find(({ name }) => name === "operationId")
|
|
108
|
+
?.text?.[0].text.split(" ")[0]
|
|
109
|
+
.trim(),
|
|
110
|
+
};
|
|
38
111
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
props.function,
|
|
47
|
-
);
|
|
48
|
-
const query: boolean = hasInterceptor("TypedQueryRouteInterceptor")(
|
|
49
|
-
props.function,
|
|
50
|
-
);
|
|
51
|
-
const method: string =
|
|
52
|
-
METHODS[Reflect.getMetadata(METHOD_METADATA, props.function)];
|
|
53
|
-
if (method === undefined || method === "OPTIONS") return null;
|
|
54
|
-
|
|
55
|
-
const parameters: IReflectHttpOperation.IParameter[] = (() => {
|
|
56
|
-
const nestParameters: NestParameters | undefined = Reflect.getMetadata(
|
|
57
|
-
ROUTE_ARGS_METADATA,
|
|
58
|
-
props.controller.constructor,
|
|
59
|
-
props.name,
|
|
112
|
+
// VALIDATE PATH ARGUMENTS
|
|
113
|
+
for (const controllerLocation of props.controller.paths)
|
|
114
|
+
for (const metaLocation of operation.paths) {
|
|
115
|
+
// NORMALIZE LOCATION
|
|
116
|
+
const location: string = PathAnalyzer.join(
|
|
117
|
+
controllerLocation,
|
|
118
|
+
metaLocation,
|
|
60
119
|
);
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
120
|
+
if (location.includes("*")) continue;
|
|
121
|
+
|
|
122
|
+
// LIST UP PARAMETERS
|
|
123
|
+
const binded: string[] | null = PathAnalyzer.parameters(location);
|
|
124
|
+
if (binded === null) {
|
|
125
|
+
props.project.errors.push({
|
|
126
|
+
file: props.controller.file,
|
|
127
|
+
class: props.controller.class.name,
|
|
128
|
+
function: props.name,
|
|
129
|
+
from: "{parameters}",
|
|
130
|
+
contents: [`invalid path (${JSON.stringify(location)})`],
|
|
131
|
+
});
|
|
132
|
+
continue;
|
|
68
133
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})();
|
|
84
|
-
|
|
85
|
-
// VALIDATE BODY
|
|
86
|
-
const body: IReflectHttpOperation.IParameter | undefined =
|
|
87
|
-
parameters.find((param) => param.category === "body");
|
|
88
|
-
if (body !== undefined && (method === "GET" || method === "HEAD")) {
|
|
89
|
-
project.errors.push({
|
|
90
|
-
file: props.controller.file,
|
|
91
|
-
controller: props.controller.name,
|
|
92
|
-
function: props.name,
|
|
93
|
-
message: `"body" parameter cannot be used in the "${method}" method.`,
|
|
94
|
-
});
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// DO CONSTRUCT
|
|
99
|
-
const example: SwaggerExample.IData<any> | undefined =
|
|
100
|
-
Reflect.getMetadata("nestia/SwaggerExample/Response", props.function);
|
|
101
|
-
const meta: IReflectHttpOperation = {
|
|
102
|
-
protocol: "http",
|
|
103
|
-
function: props.function,
|
|
104
|
-
name: props.name,
|
|
105
|
-
method: method === "ALL" ? "POST" : method,
|
|
106
|
-
paths: ReflectMetadataAnalyzer.paths(props.function).filter((str) => {
|
|
107
|
-
if (str.includes("*") === true) {
|
|
108
|
-
project.warnings.push({
|
|
109
|
-
file: props.controller.file,
|
|
110
|
-
controller: props.controller.name,
|
|
111
|
-
function: props.name,
|
|
112
|
-
message: "@nestia/sdk does not compose wildcard method.",
|
|
113
|
-
});
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
}),
|
|
118
|
-
versions: ReflectMetadataAnalyzer.versions(props.function),
|
|
119
|
-
parameters,
|
|
120
|
-
status: Reflect.getMetadata(HTTP_CODE_METADATA, props.function),
|
|
121
|
-
encrypted,
|
|
122
|
-
contentType: encrypted
|
|
123
|
-
? "text/plain"
|
|
124
|
-
: query
|
|
125
|
-
? "application/x-www-form-urlencoded"
|
|
126
|
-
: Reflect.getMetadata(HEADERS_METADATA, props.function)?.find(
|
|
127
|
-
(h: Record<string, string>) =>
|
|
128
|
-
typeof h?.name === "string" &&
|
|
129
|
-
typeof h?.value === "string" &&
|
|
130
|
-
h.name.toLowerCase() === "content-type",
|
|
131
|
-
)?.value ?? "application/json",
|
|
132
|
-
security: ReflectMetadataAnalyzer.securities(props.function),
|
|
133
|
-
exceptions: ReflectMetadataAnalyzer.exceptions(props.function),
|
|
134
|
-
swaggerTags: [
|
|
135
|
-
...new Set([
|
|
136
|
-
...props.controller.swaggerTgas,
|
|
137
|
-
...(Reflect.getMetadata("swagger/apiUseTags", props.function) ??
|
|
138
|
-
[]),
|
|
139
|
-
]),
|
|
140
|
-
],
|
|
141
|
-
...(example
|
|
142
|
-
? { example: example.example, examples: example.examples }
|
|
143
|
-
: {}),
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// VALIDATE PATH ARGUMENTS
|
|
147
|
-
for (const controllerLocation of props.controller.paths)
|
|
148
|
-
for (const metaLocation of meta.paths) {
|
|
149
|
-
// NORMALIZE LOCATION
|
|
150
|
-
const location: string = PathAnalyzer.join(
|
|
151
|
-
controllerLocation,
|
|
152
|
-
metaLocation,
|
|
153
|
-
);
|
|
154
|
-
if (location.includes("*")) continue;
|
|
155
|
-
|
|
156
|
-
// LIST UP PARAMETERS
|
|
157
|
-
const binded: string[] | null = PathAnalyzer.parameters(location);
|
|
158
|
-
if (binded === null) {
|
|
159
|
-
project.errors.push({
|
|
160
|
-
file: props.controller.file,
|
|
161
|
-
controller: props.controller.name,
|
|
162
|
-
function: props.name,
|
|
163
|
-
message: `invalid path (${JSON.stringify(location)})`,
|
|
164
|
-
});
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
const parameters: string[] = meta.parameters
|
|
168
|
-
.filter((param) => param.category === "param")
|
|
169
|
-
.map((param) => param.field!)
|
|
170
|
-
.sort();
|
|
171
|
-
|
|
172
|
-
// DO VALIDATE
|
|
173
|
-
if (ranges.equal(binded.sort(), parameters) === false)
|
|
174
|
-
errors.push({
|
|
175
|
-
file: props.controller.file,
|
|
176
|
-
controller: props.controller.name,
|
|
177
|
-
function: props.name,
|
|
178
|
-
message: `binded arguments in the "path" between function's decorator and parameters' decorators are different (function: [${binded.join(
|
|
134
|
+
const parameters: string[] = operation.parameters
|
|
135
|
+
.filter((param) => param.category === "param")
|
|
136
|
+
.map((param) => param.field!)
|
|
137
|
+
.sort();
|
|
138
|
+
|
|
139
|
+
// DO VALIDATE
|
|
140
|
+
if (ranges.equal(binded.sort(), parameters) === false)
|
|
141
|
+
errors.push({
|
|
142
|
+
file: props.controller.file,
|
|
143
|
+
class: props.controller.class.name,
|
|
144
|
+
function: props.name,
|
|
145
|
+
from: "{parameters}",
|
|
146
|
+
contents: [
|
|
147
|
+
`binded arguments in the "path" between function's decorator and parameters' decorators are different (function: [${binded.join(
|
|
179
148
|
", ",
|
|
180
149
|
)}], parameters: [${parameters.join(", ")}]).`,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// RETURNS
|
|
185
|
-
if (errors.length) {
|
|
186
|
-
project.errors.push(...errors);
|
|
187
|
-
return null;
|
|
150
|
+
],
|
|
151
|
+
});
|
|
188
152
|
}
|
|
189
|
-
return meta;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
function _Analyze_http_parameter(
|
|
193
|
-
key: string,
|
|
194
|
-
param: INestParam,
|
|
195
|
-
): IReflectHttpOperation.IParameter | null {
|
|
196
|
-
const symbol: string = key.split(":")[0];
|
|
197
|
-
if (symbol.indexOf("__custom") !== -1)
|
|
198
|
-
return _Analyze_http_custom_parameter(param);
|
|
199
|
-
|
|
200
|
-
const typeIndex: RouteParamtypes = Number(symbol[0]) as RouteParamtypes;
|
|
201
|
-
if (isNaN(typeIndex) === true) return null;
|
|
202
|
-
|
|
203
|
-
const type: ParamCategory | undefined = getNestParamType(typeIndex);
|
|
204
|
-
if (type === undefined) return null;
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
custom: false,
|
|
208
|
-
name: key,
|
|
209
|
-
category: type,
|
|
210
|
-
index: param.index,
|
|
211
|
-
field: param.data,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
153
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
param.factory.name === "PlainBody" ||
|
|
222
|
-
param.factory.name === "TypedQueryBody" ||
|
|
223
|
-
param.factory.name === "TypedBody" ||
|
|
224
|
-
param.factory.name === "TypedFormDataBody"
|
|
225
|
-
)
|
|
226
|
-
return {
|
|
227
|
-
custom: true,
|
|
228
|
-
category: "body",
|
|
229
|
-
index: param.index,
|
|
230
|
-
name: param.name,
|
|
231
|
-
field: param.data,
|
|
232
|
-
encrypted: param.factory.name === "EncryptedBody",
|
|
233
|
-
contentType:
|
|
234
|
-
param.factory.name === "PlainBody" ||
|
|
235
|
-
param.factory.name === "EncryptedBody"
|
|
236
|
-
? "text/plain"
|
|
237
|
-
: param.factory.name === "TypedQueryBody"
|
|
238
|
-
? "application/x-www-form-urlencoded"
|
|
239
|
-
: param.factory.name === "TypedFormDataBody"
|
|
240
|
-
? "multipart/form-data"
|
|
241
|
-
: "application/json",
|
|
242
|
-
};
|
|
243
|
-
else if (param.factory.name === "TypedHeaders")
|
|
244
|
-
return {
|
|
245
|
-
custom: true,
|
|
246
|
-
category: "headers",
|
|
247
|
-
name: param.name,
|
|
248
|
-
index: param.index,
|
|
249
|
-
field: param.data,
|
|
250
|
-
};
|
|
251
|
-
else if (param.factory.name === "TypedParam")
|
|
252
|
-
return {
|
|
253
|
-
custom: true,
|
|
254
|
-
category: "param",
|
|
255
|
-
name: param.name,
|
|
256
|
-
index: param.index,
|
|
257
|
-
field: param.data,
|
|
258
|
-
};
|
|
259
|
-
else if (param.factory.name === "TypedQuery")
|
|
260
|
-
return {
|
|
261
|
-
custom: true,
|
|
262
|
-
name: param.name,
|
|
263
|
-
category: "query",
|
|
264
|
-
index: param.index,
|
|
265
|
-
field: undefined,
|
|
266
|
-
};
|
|
267
|
-
else return null;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
interface INestParam {
|
|
272
|
-
name: string;
|
|
273
|
-
index: number;
|
|
274
|
-
factory?: (...args: any) => any;
|
|
275
|
-
data: string | undefined;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
type NestParameters = {
|
|
279
|
-
[key: string]: INestParam;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const hasInterceptor =
|
|
283
|
-
(name: string) =>
|
|
284
|
-
(proto: any): boolean => {
|
|
285
|
-
const meta = Reflect.getMetadata(INTERCEPTORS_METADATA, proto);
|
|
286
|
-
if (Array.isArray(meta) === false) return false;
|
|
287
|
-
return meta.some((elem) => elem?.constructor?.name === name);
|
|
154
|
+
// RETURNS
|
|
155
|
+
if (errors.length) {
|
|
156
|
+
props.project.errors.push(...errors);
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return operation;
|
|
288
160
|
};
|
|
289
|
-
|
|
290
|
-
// https://github.com/nestjs/nest/blob/master/packages/common/enums/route-paramtypes.enum.ts
|
|
291
|
-
const getNestParamType = (value: RouteParamtypes) => {
|
|
292
|
-
if (value === RouteParamtypes.BODY) return "body";
|
|
293
|
-
else if (value === RouteParamtypes.HEADERS) return "headers";
|
|
294
|
-
else if (value === RouteParamtypes.QUERY) return "query";
|
|
295
|
-
else if (value === RouteParamtypes.PARAM) return "param";
|
|
296
|
-
return undefined;
|
|
297
|
-
};
|
|
161
|
+
}
|
|
298
162
|
|
|
299
163
|
// node_modules/@nestjs/common/lib/enums/request-method.enum.ts
|
|
300
164
|
const METHODS = [
|