@nestia/sdk 2.4.3-dev.20231207 → 3.0.0-dev.20231209
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/analyses/ReflectAnalyzer.js +1 -1
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/internal/SdkFunctionProgrammer.js +2 -2
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/lib/structures/IController.d.ts +1 -1
- package/lib/structures/IRoute.d.ts +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +234 -234
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/analyses/AccessorAnalyzer.ts +60 -60
- package/src/analyses/ConfigAnalyzer.ts +147 -147
- package/src/analyses/ControllerAnalyzer.ts +379 -379
- package/src/analyses/ExceptionAnalyzer.ts +115 -115
- package/src/analyses/GenericAnalyzer.ts +51 -51
- package/src/analyses/ImportAnalyzer.ts +138 -138
- package/src/analyses/PathAnalyzer.ts +98 -98
- package/src/analyses/ReflectAnalyzer.ts +1 -1
- package/src/analyses/SecurityAnalyzer.ts +20 -20
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +67 -67
- package/src/executable/internal/NestiaSdkCommand.ts +60 -60
- package/src/executable/sdk.ts +73 -73
- package/src/generates/E2eGenerator.ts +64 -64
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +372 -372
- package/src/generates/internal/E2eFileProgrammer.ts +123 -123
- package/src/generates/internal/SdkDistributionComposer.ts +91 -91
- package/src/generates/internal/SdkDtoGenerator.ts +424 -424
- package/src/generates/internal/SdkFileProgrammer.ts +106 -106
- package/src/generates/internal/SdkFunctionProgrammer.ts +2 -2
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +17 -17
- package/src/generates/internal/SdkSimulationProgrammer.ts +133 -133
- package/src/generates/internal/SdkTypeDefiner.ts +119 -119
- package/src/generates/internal/SwaggerSchemaGenerator.ts +22 -23
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +5 -1
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/IRoute.ts +2 -1
- package/src/structures/ISwagger.ts +91 -91
- package/src/structures/ISwaggerComponents.ts +29 -29
- package/src/structures/ISwaggerError.ts +8 -8
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerLazyProperty.ts +7 -7
- package/src/structures/ISwaggerLazySchema.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +51 -51
- package/src/structures/ISwaggerSecurityScheme.ts +65 -65
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +125 -125
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StripEnums.ts +5 -5
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
2
|
-
import { IRoute } from "../../structures/IRoute";
|
|
3
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
4
|
-
import { SdkDtoGenerator } from "./SdkDtoGenerator";
|
|
5
|
-
|
|
6
|
-
export namespace SdkTypeDefiner {
|
|
7
|
-
export const name =
|
|
8
|
-
(config: INestiaConfig) =>
|
|
9
|
-
(importer: ImportDictionary) =>
|
|
10
|
-
(p: IRoute.IParameter | IRoute.IOutput): string =>
|
|
11
|
-
p.metadata
|
|
12
|
-
? SdkDtoGenerator.decode(config)(importer)(p.metadata)
|
|
13
|
-
: p.typeName;
|
|
14
|
-
|
|
15
|
-
export const headers =
|
|
16
|
-
(config: INestiaConfig) =>
|
|
17
|
-
(importer: ImportDictionary) =>
|
|
18
|
-
(param: IRoute.IParameter): string => {
|
|
19
|
-
const type: string = name(config)(importer)(param);
|
|
20
|
-
if (config.primitive === false) return type;
|
|
21
|
-
|
|
22
|
-
const resolved: string = importer.external({
|
|
23
|
-
type: true,
|
|
24
|
-
library: "@nestia/fetcher",
|
|
25
|
-
instance: "Resolved",
|
|
26
|
-
});
|
|
27
|
-
return `${resolved}<${type}>`;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const query =
|
|
31
|
-
(config: INestiaConfig) =>
|
|
32
|
-
(importer: ImportDictionary) =>
|
|
33
|
-
(param: IRoute.IParameter): string => {
|
|
34
|
-
const type: string = name(config)(importer)(param);
|
|
35
|
-
if (config.primitive === false) return type;
|
|
36
|
-
|
|
37
|
-
const resolved: string = importer.external({
|
|
38
|
-
type: true,
|
|
39
|
-
library: "@nestia/fetcher",
|
|
40
|
-
instance: "Resolved",
|
|
41
|
-
});
|
|
42
|
-
return `${resolved}<${type}>`;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const input =
|
|
46
|
-
(config: INestiaConfig) =>
|
|
47
|
-
(importer: ImportDictionary) =>
|
|
48
|
-
(param: IRoute.IParameter): string => {
|
|
49
|
-
const type: string = name(config)(importer)(param);
|
|
50
|
-
if (config.primitive === false) return type;
|
|
51
|
-
|
|
52
|
-
const primitive: string = importer.external({
|
|
53
|
-
type: true,
|
|
54
|
-
library: "@nestia/fetcher",
|
|
55
|
-
instance: "Primitive",
|
|
56
|
-
});
|
|
57
|
-
return `${primitive}<${type}>`;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const output =
|
|
61
|
-
(config: INestiaConfig) =>
|
|
62
|
-
(importer: ImportDictionary) =>
|
|
63
|
-
(route: IRoute): string => {
|
|
64
|
-
if (config.propagate !== true) {
|
|
65
|
-
const type: string = name(config)(importer)(route.output);
|
|
66
|
-
if (type === "void" || config.primitive === false) return type;
|
|
67
|
-
|
|
68
|
-
const wrapper: string = importer.external({
|
|
69
|
-
type: true,
|
|
70
|
-
library: "@nestia/fetcher",
|
|
71
|
-
instance:
|
|
72
|
-
route.output.contentType === "application/x-www-form-urlencoded"
|
|
73
|
-
? "Resolved"
|
|
74
|
-
: "Primitive",
|
|
75
|
-
});
|
|
76
|
-
return `${wrapper}<${type}>`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const propagation: string = importer.external({
|
|
80
|
-
type: true,
|
|
81
|
-
library: "@nestia/fetcher",
|
|
82
|
-
instance: "IPropagation",
|
|
83
|
-
});
|
|
84
|
-
const branches: IBranch[] = [
|
|
85
|
-
{
|
|
86
|
-
status: String(route.status ?? (route.method === "POST" ? 201 : 200)),
|
|
87
|
-
type: name(config)(importer)(route.output),
|
|
88
|
-
},
|
|
89
|
-
...Object.entries(route.exceptions).map(([status, value]) => ({
|
|
90
|
-
status,
|
|
91
|
-
type: name(config)(importer)(value),
|
|
92
|
-
})),
|
|
93
|
-
];
|
|
94
|
-
return (
|
|
95
|
-
`${propagation}<{\n` +
|
|
96
|
-
branches
|
|
97
|
-
.map(
|
|
98
|
-
(b) =>
|
|
99
|
-
` ${
|
|
100
|
-
b.status.endsWith("XX") ? `"${b.status}"` : b.status
|
|
101
|
-
}: ${b.type};`,
|
|
102
|
-
)
|
|
103
|
-
.join("\n") +
|
|
104
|
-
"\n" +
|
|
105
|
-
` }${route.status ? `, ${route.status}` : ""}>`
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const responseBody =
|
|
110
|
-
(config: INestiaConfig) =>
|
|
111
|
-
(importer: ImportDictionary) =>
|
|
112
|
-
(route: IRoute): string =>
|
|
113
|
-
output({ ...config, propagate: false })(importer)(route);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface IBranch {
|
|
117
|
-
status: string;
|
|
118
|
-
type: string;
|
|
119
|
-
}
|
|
1
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
2
|
+
import { IRoute } from "../../structures/IRoute";
|
|
3
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
4
|
+
import { SdkDtoGenerator } from "./SdkDtoGenerator";
|
|
5
|
+
|
|
6
|
+
export namespace SdkTypeDefiner {
|
|
7
|
+
export const name =
|
|
8
|
+
(config: INestiaConfig) =>
|
|
9
|
+
(importer: ImportDictionary) =>
|
|
10
|
+
(p: IRoute.IParameter | IRoute.IOutput): string =>
|
|
11
|
+
p.metadata
|
|
12
|
+
? SdkDtoGenerator.decode(config)(importer)(p.metadata)
|
|
13
|
+
: p.typeName;
|
|
14
|
+
|
|
15
|
+
export const headers =
|
|
16
|
+
(config: INestiaConfig) =>
|
|
17
|
+
(importer: ImportDictionary) =>
|
|
18
|
+
(param: IRoute.IParameter): string => {
|
|
19
|
+
const type: string = name(config)(importer)(param);
|
|
20
|
+
if (config.primitive === false) return type;
|
|
21
|
+
|
|
22
|
+
const resolved: string = importer.external({
|
|
23
|
+
type: true,
|
|
24
|
+
library: "@nestia/fetcher",
|
|
25
|
+
instance: "Resolved",
|
|
26
|
+
});
|
|
27
|
+
return `${resolved}<${type}>`;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const query =
|
|
31
|
+
(config: INestiaConfig) =>
|
|
32
|
+
(importer: ImportDictionary) =>
|
|
33
|
+
(param: IRoute.IParameter): string => {
|
|
34
|
+
const type: string = name(config)(importer)(param);
|
|
35
|
+
if (config.primitive === false) return type;
|
|
36
|
+
|
|
37
|
+
const resolved: string = importer.external({
|
|
38
|
+
type: true,
|
|
39
|
+
library: "@nestia/fetcher",
|
|
40
|
+
instance: "Resolved",
|
|
41
|
+
});
|
|
42
|
+
return `${resolved}<${type}>`;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const input =
|
|
46
|
+
(config: INestiaConfig) =>
|
|
47
|
+
(importer: ImportDictionary) =>
|
|
48
|
+
(param: IRoute.IParameter): string => {
|
|
49
|
+
const type: string = name(config)(importer)(param);
|
|
50
|
+
if (config.primitive === false) return type;
|
|
51
|
+
|
|
52
|
+
const primitive: string = importer.external({
|
|
53
|
+
type: true,
|
|
54
|
+
library: "@nestia/fetcher",
|
|
55
|
+
instance: "Primitive",
|
|
56
|
+
});
|
|
57
|
+
return `${primitive}<${type}>`;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const output =
|
|
61
|
+
(config: INestiaConfig) =>
|
|
62
|
+
(importer: ImportDictionary) =>
|
|
63
|
+
(route: IRoute): string => {
|
|
64
|
+
if (config.propagate !== true) {
|
|
65
|
+
const type: string = name(config)(importer)(route.output);
|
|
66
|
+
if (type === "void" || config.primitive === false) return type;
|
|
67
|
+
|
|
68
|
+
const wrapper: string = importer.external({
|
|
69
|
+
type: true,
|
|
70
|
+
library: "@nestia/fetcher",
|
|
71
|
+
instance:
|
|
72
|
+
route.output.contentType === "application/x-www-form-urlencoded"
|
|
73
|
+
? "Resolved"
|
|
74
|
+
: "Primitive",
|
|
75
|
+
});
|
|
76
|
+
return `${wrapper}<${type}>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const propagation: string = importer.external({
|
|
80
|
+
type: true,
|
|
81
|
+
library: "@nestia/fetcher",
|
|
82
|
+
instance: "IPropagation",
|
|
83
|
+
});
|
|
84
|
+
const branches: IBranch[] = [
|
|
85
|
+
{
|
|
86
|
+
status: String(route.status ?? (route.method === "POST" ? 201 : 200)),
|
|
87
|
+
type: name(config)(importer)(route.output),
|
|
88
|
+
},
|
|
89
|
+
...Object.entries(route.exceptions).map(([status, value]) => ({
|
|
90
|
+
status,
|
|
91
|
+
type: name(config)(importer)(value),
|
|
92
|
+
})),
|
|
93
|
+
];
|
|
94
|
+
return (
|
|
95
|
+
`${propagation}<{\n` +
|
|
96
|
+
branches
|
|
97
|
+
.map(
|
|
98
|
+
(b) =>
|
|
99
|
+
` ${
|
|
100
|
+
b.status.endsWith("XX") ? `"${b.status}"` : b.status
|
|
101
|
+
}: ${b.type};`,
|
|
102
|
+
)
|
|
103
|
+
.join("\n") +
|
|
104
|
+
"\n" +
|
|
105
|
+
` }${route.status ? `, ${route.status}` : ""}>`
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const responseBody =
|
|
110
|
+
(config: INestiaConfig) =>
|
|
111
|
+
(importer: ImportDictionary) =>
|
|
112
|
+
(route: IRoute): string =>
|
|
113
|
+
output({ ...config, propagate: false })(importer)(route);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface IBranch {
|
|
117
|
+
status: string;
|
|
118
|
+
type: string;
|
|
119
|
+
}
|
|
@@ -372,30 +372,29 @@ export namespace SwaggerSchemaGenerator {
|
|
|
372
372
|
|
|
373
373
|
const warning = new VariadicSingleton(
|
|
374
374
|
(described: boolean, type: "request" | "response", method?: string) => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
375
|
+
const summary =
|
|
376
|
+
type === "request"
|
|
377
|
+
? "Request body must be encrypted."
|
|
378
|
+
: "Response data have been encrypted.";
|
|
379
|
+
const component =
|
|
380
|
+
type === "request"
|
|
381
|
+
? "[EncryptedBody](https://github.com/samchon/@nestia/core#encryptedbody)"
|
|
382
|
+
: `[EncryptedRoute.${method![0].toUpperCase()}.${method!
|
|
383
|
+
.substring(1)
|
|
384
|
+
.toLowerCase()}](https://github.com/samchon/@nestia/core#encryptedroute)`;
|
|
385
385
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
);
|
|
386
|
+
const content: string[] = [
|
|
387
|
+
"## Warning",
|
|
388
|
+
"",
|
|
389
|
+
summary,
|
|
390
|
+
"",
|
|
391
|
+
`The ${type} body data would be encrypted as "AES-128(256) / CBC mode / PKCS#5 Padding / Base64 Encoding", through the ${component} component.`,
|
|
392
|
+
"",
|
|
393
|
+
`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.`,
|
|
394
|
+
];
|
|
395
|
+
if (described === true) content.push("", "----------------", "", "");
|
|
396
|
+
return content.join("\n");
|
|
397
|
+
});
|
|
399
398
|
|
|
400
399
|
const any = new Singleton(() =>
|
|
401
400
|
Metadata.from(
|