@nestia/sdk 6.0.6 → 7.0.0-dev.20250605
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/LICENSE +21 -21
- package/README.md +92 -92
- package/assets/bundle/api/HttpError.ts +1 -1
- package/assets/bundle/api/IConnection.ts +1 -1
- package/assets/bundle/api/Primitive.ts +1 -1
- package/assets/bundle/api/Resolved.ts +1 -1
- package/assets/bundle/api/index.ts +4 -4
- package/assets/bundle/api/module.ts +6 -6
- package/assets/bundle/distribute/README.md +37 -37
- package/assets/bundle/distribute/package.json +28 -28
- package/assets/bundle/distribute/tsconfig.json +109 -109
- package/assets/bundle/e2e/index.ts +42 -42
- package/assets/config/nestia.config.ts +97 -97
- package/lib/INestiaConfig.d.ts +66 -69
- package/lib/executable/internal/NestiaConfigLoader.js +10 -5
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/sdk.js +12 -12
- package/lib/generates/internal/E2eFileProgrammer.js +30 -14
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.js +13 -4
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +3 -2
- package/lib/generates/internal/SdkAliasCollection.js +8 -3
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +47 -35
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +50 -37
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +5 -4
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +28 -16
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +3 -3
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +2 -2
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/package.json +6 -6
- package/src/INestiaConfig.ts +269 -271
- package/src/NestiaSdkApplication.ts +307 -307
- package/src/NestiaSwaggerComposer.ts +138 -138
- package/src/analyses/AccessorAnalyzer.ts +67 -67
- package/src/analyses/ConfigAnalyzer.ts +155 -155
- package/src/analyses/ExceptionAnalyzer.ts +154 -154
- package/src/analyses/GenericAnalyzer.ts +49 -49
- package/src/analyses/ImportAnalyzer.ts +171 -171
- package/src/analyses/PathAnalyzer.ts +69 -69
- package/src/analyses/ReflectControllerAnalyzer.ts +105 -105
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +183 -183
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +71 -71
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +348 -348
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +127 -127
- package/src/analyses/ReflectMetadataAnalyzer.ts +44 -44
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +172 -172
- package/src/analyses/SecurityAnalyzer.ts +25 -25
- package/src/analyses/TypedHttpRouteAnalyzer.ts +186 -186
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +18 -18
- package/src/decorators/OperationMetadata.ts +15 -15
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +78 -78
- package/src/executable/internal/NestiaSdkCommand.ts +103 -103
- package/src/executable/sdk.ts +75 -75
- package/src/generates/CloneGenerator.ts +66 -66
- package/src/generates/E2eGenerator.ts +32 -32
- package/src/generates/SdkGenerator.ts +159 -159
- package/src/generates/SwaggerGenerator.ts +292 -292
- package/src/generates/internal/E2eFileProgrammer.ts +214 -183
- package/src/generates/internal/FilePrinter.ts +53 -53
- package/src/generates/internal/ImportDictionary.ts +159 -147
- package/src/generates/internal/SdkAliasCollection.ts +204 -185
- package/src/generates/internal/SdkDistributionComposer.ts +103 -103
- package/src/generates/internal/SdkFileProgrammer.ts +116 -116
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +124 -124
- package/src/generates/internal/SdkHttpCloneReferencer.ts +71 -71
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +325 -301
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +563 -529
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +119 -117
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +386 -362
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +18 -18
- package/src/generates/internal/SdkTypeProgrammer.ts +377 -377
- package/src/generates/internal/SdkTypeTagProgrammer.ts +102 -102
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +362 -362
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +265 -265
- package/src/generates/internal/SwaggerDescriptionComposer.ts +64 -64
- package/src/generates/internal/SwaggerOperationComposer.ts +119 -119
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +177 -177
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +110 -110
- package/src/index.ts +4 -4
- package/src/module.ts +3 -3
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INestiaSdkInput.ts +20 -20
- package/src/structures/IReflectApplication.ts +8 -8
- package/src/structures/IReflectController.ts +15 -15
- package/src/structures/IReflectHttpOperation.ts +26 -26
- package/src/structures/IReflectHttpOperationException.ts +19 -19
- package/src/structures/IReflectHttpOperationParameter.ts +81 -81
- package/src/structures/IReflectHttpOperationSuccess.ts +22 -22
- package/src/structures/IReflectOperationError.ts +26 -26
- package/src/structures/IReflectType.ts +4 -4
- package/src/structures/IReflectTypeImport.ts +4 -4
- package/src/structures/IReflectWebSocketOperation.ts +17 -17
- package/src/structures/IReflectWebSocketOperationParameter.ts +38 -38
- package/src/structures/ITypedApplication.ts +11 -11
- package/src/structures/ITypedHttpRoute.ts +30 -30
- package/src/structures/ITypedHttpRouteException.ts +15 -15
- package/src/structures/ITypedHttpRouteParameter.ts +41 -41
- package/src/structures/ITypedHttpRouteSuccess.ts +22 -22
- package/src/structures/ITypedWebSocketRoute.ts +20 -20
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -3
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/transform.ts +9 -9
- package/src/transformers/IOperationMetadata.ts +44 -44
- package/src/transformers/ISdkOperationTransformerContext.ts +8 -8
- package/src/transformers/SdkOperationProgrammer.ts +209 -209
- package/src/transformers/SdkOperationTransformer.ts +253 -253
- package/src/transformers/TextPlainValidator.ts +17 -17
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/MetadataUtil.ts +26 -26
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StringUtil.ts +17 -17
- package/src/utils/StripEnums.ts +5 -5
- package/src/utils/VersioningStrategy.ts +28 -28
- package/src/validators/HttpHeadersValidator.ts +34 -34
- package/src/validators/HttpQueryValidator.ts +34 -34
|
@@ -1,185 +1,204 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import typia from "typia";
|
|
3
|
-
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
4
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
5
|
-
|
|
6
|
-
import { INestiaProject } from "../../structures/INestiaProject";
|
|
7
|
-
import { IReflectHttpOperationParameter } from "../../structures/IReflectHttpOperationParameter";
|
|
8
|
-
import { IReflectType } from "../../structures/IReflectType";
|
|
9
|
-
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
10
|
-
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
11
|
-
import { ImportDictionary } from "./ImportDictionary";
|
|
12
|
-
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
13
|
-
|
|
14
|
-
export namespace SdkAliasCollection {
|
|
15
|
-
export const name = ({ type }: { type: IReflectType }): ts.TypeNode =>
|
|
16
|
-
ts.factory.createTypeReferenceNode(
|
|
17
|
-
type.name,
|
|
18
|
-
type.typeArguments
|
|
19
|
-
? type.typeArguments.map((a) => name({ type: a }))
|
|
20
|
-
: undefined,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
export const from =
|
|
24
|
-
(project: INestiaProject) =>
|
|
25
|
-
(importer: ImportDictionary) =>
|
|
26
|
-
(metadata: Metadata) =>
|
|
27
|
-
SdkTypeProgrammer.write(project)(importer)(metadata);
|
|
28
|
-
|
|
29
|
-
export const
|
|
30
|
-
(project: INestiaProject) =>
|
|
31
|
-
(importer: ImportDictionary) =>
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return param.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import typia from "typia";
|
|
3
|
+
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
4
|
+
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
5
|
+
|
|
6
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
7
|
+
import { IReflectHttpOperationParameter } from "../../structures/IReflectHttpOperationParameter";
|
|
8
|
+
import { IReflectType } from "../../structures/IReflectType";
|
|
9
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
10
|
+
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
11
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
12
|
+
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
13
|
+
|
|
14
|
+
export namespace SdkAliasCollection {
|
|
15
|
+
export const name = ({ type }: { type: IReflectType }): ts.TypeNode =>
|
|
16
|
+
ts.factory.createTypeReferenceNode(
|
|
17
|
+
type.name,
|
|
18
|
+
type.typeArguments
|
|
19
|
+
? type.typeArguments.map((a) => name({ type: a }))
|
|
20
|
+
: undefined,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const from =
|
|
24
|
+
(project: INestiaProject) =>
|
|
25
|
+
(importer: ImportDictionary) =>
|
|
26
|
+
(metadata: Metadata) =>
|
|
27
|
+
SdkTypeProgrammer.write(project)(importer)(metadata);
|
|
28
|
+
|
|
29
|
+
export const props =
|
|
30
|
+
(project: INestiaProject) =>
|
|
31
|
+
(importer: ImportDictionary) =>
|
|
32
|
+
(route: ITypedHttpRoute): ts.TypeNode =>
|
|
33
|
+
ts.factory.createTypeLiteralNode(
|
|
34
|
+
route.parameters
|
|
35
|
+
.filter((p) => p.category !== "headers")
|
|
36
|
+
.map((param) =>
|
|
37
|
+
ts.factory.createPropertySignature(
|
|
38
|
+
undefined,
|
|
39
|
+
param.name,
|
|
40
|
+
param.metadata.isRequired() === false
|
|
41
|
+
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
42
|
+
: undefined,
|
|
43
|
+
SdkTypeProgrammer.write(project)(importer)(param.metadata),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const headers =
|
|
49
|
+
(project: INestiaProject) =>
|
|
50
|
+
(importer: ImportDictionary) =>
|
|
51
|
+
(param: ITypedHttpRouteParameter.IHeaders): ts.TypeNode => {
|
|
52
|
+
if (project.config.clone === true)
|
|
53
|
+
return from(project)(importer)(param.metadata);
|
|
54
|
+
const type: ts.TypeNode = name(param);
|
|
55
|
+
if (project.config.primitive === false) return type;
|
|
56
|
+
return ts.factory.createTypeReferenceNode(
|
|
57
|
+
importer.external({
|
|
58
|
+
type: true,
|
|
59
|
+
library: "typia",
|
|
60
|
+
instance: "Resolved",
|
|
61
|
+
}),
|
|
62
|
+
[type],
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const query =
|
|
67
|
+
(project: INestiaProject) =>
|
|
68
|
+
(importer: ImportDictionary) =>
|
|
69
|
+
(param: ITypedHttpRouteParameter.IQuery): ts.TypeNode => {
|
|
70
|
+
if (project.config.clone === true)
|
|
71
|
+
return from(project)(importer)(param.metadata);
|
|
72
|
+
const type: ts.TypeNode = name(param);
|
|
73
|
+
if (project.config.primitive === false) return type;
|
|
74
|
+
return ts.factory.createTypeReferenceNode(
|
|
75
|
+
importer.external({
|
|
76
|
+
type: true,
|
|
77
|
+
library: "typia",
|
|
78
|
+
instance: "Resolved",
|
|
79
|
+
}),
|
|
80
|
+
[type],
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const body =
|
|
85
|
+
(project: INestiaProject) =>
|
|
86
|
+
(importer: ImportDictionary) =>
|
|
87
|
+
(param: ITypedHttpRouteParameter.IBody): ts.TypeNode => {
|
|
88
|
+
if (project.config.clone === true) {
|
|
89
|
+
const type: ts.TypeNode = from(project)(importer)(param.metadata);
|
|
90
|
+
return param.contentType === "multipart/form-data"
|
|
91
|
+
? formDataInput(importer)(type)
|
|
92
|
+
: type;
|
|
93
|
+
}
|
|
94
|
+
const type: ts.TypeNode = name(param);
|
|
95
|
+
if (param.contentType === "multipart/form-data")
|
|
96
|
+
return formDataInput(importer)(type);
|
|
97
|
+
else if (project.config.primitive === false) return type;
|
|
98
|
+
return ts.factory.createTypeReferenceNode(
|
|
99
|
+
importer.external({
|
|
100
|
+
type: true,
|
|
101
|
+
library: "typia",
|
|
102
|
+
instance:
|
|
103
|
+
typia.is<IReflectHttpOperationParameter.IBody>(param) &&
|
|
104
|
+
(param.contentType === "application/json" ||
|
|
105
|
+
param.encrypted === true)
|
|
106
|
+
? "Primitive"
|
|
107
|
+
: "Resolved",
|
|
108
|
+
}),
|
|
109
|
+
[type],
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const response =
|
|
114
|
+
(project: INestiaProject) =>
|
|
115
|
+
(importer: ImportDictionary) =>
|
|
116
|
+
(route: ITypedHttpRoute): ts.TypeNode => {
|
|
117
|
+
const schema = (p: { metadata: Metadata; type: IReflectType }) =>
|
|
118
|
+
p.metadata.size() === 0
|
|
119
|
+
? TypeFactory.keyword("void")
|
|
120
|
+
: project.config.clone === true
|
|
121
|
+
? from(project)(importer)(p.metadata)
|
|
122
|
+
: project.config.primitive !== false
|
|
123
|
+
? ts.factory.createTypeReferenceNode(
|
|
124
|
+
importer.external({
|
|
125
|
+
type: true,
|
|
126
|
+
library: "typia",
|
|
127
|
+
instance:
|
|
128
|
+
route.success.contentType === "application/json" ||
|
|
129
|
+
route.success.encrypted === true
|
|
130
|
+
? "Primitive"
|
|
131
|
+
: "Resolved",
|
|
132
|
+
}),
|
|
133
|
+
[name(p)],
|
|
134
|
+
)
|
|
135
|
+
: name(p);
|
|
136
|
+
if (project.config.propagate !== true) return schema(route.success);
|
|
137
|
+
|
|
138
|
+
const branches: IBranch[] = [
|
|
139
|
+
{
|
|
140
|
+
status: String(
|
|
141
|
+
route.success.status ?? (route.method === "POST" ? 201 : 200),
|
|
142
|
+
),
|
|
143
|
+
type: schema(route.success),
|
|
144
|
+
},
|
|
145
|
+
...Object.entries(route.exceptions).map(([status, value]) => ({
|
|
146
|
+
status,
|
|
147
|
+
type: schema(value),
|
|
148
|
+
})),
|
|
149
|
+
];
|
|
150
|
+
return ts.factory.createTypeReferenceNode(
|
|
151
|
+
importer.external({
|
|
152
|
+
type: true,
|
|
153
|
+
library: "@nestia/fetcher",
|
|
154
|
+
instance: "IPropagation",
|
|
155
|
+
}),
|
|
156
|
+
[
|
|
157
|
+
ts.factory.createTypeLiteralNode(
|
|
158
|
+
branches.map((b) =>
|
|
159
|
+
ts.factory.createPropertySignature(
|
|
160
|
+
undefined,
|
|
161
|
+
ts.factory.createNumericLiteral(b.status),
|
|
162
|
+
undefined,
|
|
163
|
+
b.type,
|
|
164
|
+
),
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
...(route.success.status
|
|
168
|
+
? [
|
|
169
|
+
ts.factory.createLiteralTypeNode(
|
|
170
|
+
ts.factory.createNumericLiteral(route.success.status),
|
|
171
|
+
),
|
|
172
|
+
]
|
|
173
|
+
: []),
|
|
174
|
+
],
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const responseBody =
|
|
179
|
+
(project: INestiaProject) =>
|
|
180
|
+
(importer: ImportDictionary) =>
|
|
181
|
+
(route: ITypedHttpRoute): ts.TypeNode =>
|
|
182
|
+
response({
|
|
183
|
+
...project,
|
|
184
|
+
config: {
|
|
185
|
+
...project.config,
|
|
186
|
+
propagate: false,
|
|
187
|
+
},
|
|
188
|
+
})(importer)(route);
|
|
189
|
+
|
|
190
|
+
const formDataInput = (importer: ImportDictionary) => (type: ts.TypeNode) =>
|
|
191
|
+
ts.factory.createTypeReferenceNode(
|
|
192
|
+
importer.external({
|
|
193
|
+
type: true,
|
|
194
|
+
library: "@nestia/fetcher",
|
|
195
|
+
instance: "FormDataInput",
|
|
196
|
+
}),
|
|
197
|
+
[type],
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface IBranch {
|
|
202
|
+
status: string;
|
|
203
|
+
type: ts.TypeNode;
|
|
204
|
+
}
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import cp from "child_process";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import typia from "typia";
|
|
5
|
-
|
|
6
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
7
|
-
|
|
8
|
-
export namespace SdkDistributionComposer {
|
|
9
|
-
export const compose = async (props: {
|
|
10
|
-
config: INestiaConfig;
|
|
11
|
-
websocket: boolean;
|
|
12
|
-
}) => {
|
|
13
|
-
if (!fs.existsSync(props.config.distribute!))
|
|
14
|
-
await fs.promises.mkdir(props.config.distribute!);
|
|
15
|
-
|
|
16
|
-
const root: string = process.cwd();
|
|
17
|
-
const output: string = path.resolve(props.config.output!);
|
|
18
|
-
process.chdir(props.config.distribute!);
|
|
19
|
-
|
|
20
|
-
const exit = () => process.chdir(root);
|
|
21
|
-
if (await configured()) return exit();
|
|
22
|
-
|
|
23
|
-
// COPY FILES
|
|
24
|
-
console.log("Composing SDK distribution environments...");
|
|
25
|
-
for (const file of await fs.promises.readdir(BUNDLE))
|
|
26
|
-
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
27
|
-
|
|
28
|
-
// CONFIGURE PATHS
|
|
29
|
-
for (const file of ["package.json", "tsconfig.json"])
|
|
30
|
-
await replace({ root, output })(file);
|
|
31
|
-
|
|
32
|
-
// INSTALL PACKAGES
|
|
33
|
-
const v: IDependencies = await dependencies();
|
|
34
|
-
execute("npm install --save-dev rimraf");
|
|
35
|
-
execute(`npm install --save @nestia/fetcher@${v.version}`);
|
|
36
|
-
execute(`npm install --save typia@${v.typia}`);
|
|
37
|
-
if (props.websocket) execute(`npm install --save tgrid@${v.tgrid}`);
|
|
38
|
-
execute("npx typia setup --manager npm");
|
|
39
|
-
|
|
40
|
-
exit();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const configured = async (): Promise<boolean> =>
|
|
44
|
-
["package.json", "tsconfig.json"].every(fs.existsSync) &&
|
|
45
|
-
(await (async () => {
|
|
46
|
-
const content = JSON.parse(
|
|
47
|
-
await fs.promises.readFile("package.json", "utf8"),
|
|
48
|
-
);
|
|
49
|
-
return !!content.dependencies?.["@nestia/fetcher"];
|
|
50
|
-
})());
|
|
51
|
-
|
|
52
|
-
const execute = (command: string) => {
|
|
53
|
-
console.log(` - ${command}`);
|
|
54
|
-
cp.execSync(command, { stdio: "ignore" });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const replace =
|
|
58
|
-
(props: { root: string; output: string }) =>
|
|
59
|
-
async (file: string): Promise<void> => {
|
|
60
|
-
const relative = (from: string) => (to: string) =>
|
|
61
|
-
path.relative(from, to).split("\\").join("/");
|
|
62
|
-
const root: string = relative(process.cwd())(props.root);
|
|
63
|
-
const output: string = relative(process.cwd())(props.output);
|
|
64
|
-
const current: string = relative(props.root)(process.cwd());
|
|
65
|
-
|
|
66
|
-
const content: string = await fs.promises.readFile(file, "utf8");
|
|
67
|
-
await fs.promises.writeFile(
|
|
68
|
-
file,
|
|
69
|
-
content
|
|
70
|
-
.split("${root}")
|
|
71
|
-
.join(root)
|
|
72
|
-
.split("${output}")
|
|
73
|
-
.join(output)
|
|
74
|
-
.split("${current}")
|
|
75
|
-
.join(current),
|
|
76
|
-
"utf8",
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const dependencies = async (): Promise<IDependencies> => {
|
|
81
|
-
const content: string = await fs.promises.readFile(
|
|
82
|
-
__dirname + "/../../../package.json",
|
|
83
|
-
"utf8",
|
|
84
|
-
);
|
|
85
|
-
const json: {
|
|
86
|
-
version: string;
|
|
87
|
-
dependencies: Record<string, string>;
|
|
88
|
-
devDependencies: Record<string, string>;
|
|
89
|
-
} = JSON.parse(content);
|
|
90
|
-
return typia.assert<IDependencies>({
|
|
91
|
-
...json.devDependencies,
|
|
92
|
-
...json.dependencies,
|
|
93
|
-
version: json.version,
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
interface IDependencies {
|
|
99
|
-
version: string;
|
|
100
|
-
typia: string;
|
|
101
|
-
tgrid: string;
|
|
102
|
-
}
|
|
103
|
-
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|
|
1
|
+
import cp from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import typia from "typia";
|
|
5
|
+
|
|
6
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
7
|
+
|
|
8
|
+
export namespace SdkDistributionComposer {
|
|
9
|
+
export const compose = async (props: {
|
|
10
|
+
config: INestiaConfig;
|
|
11
|
+
websocket: boolean;
|
|
12
|
+
}) => {
|
|
13
|
+
if (!fs.existsSync(props.config.distribute!))
|
|
14
|
+
await fs.promises.mkdir(props.config.distribute!);
|
|
15
|
+
|
|
16
|
+
const root: string = process.cwd();
|
|
17
|
+
const output: string = path.resolve(props.config.output!);
|
|
18
|
+
process.chdir(props.config.distribute!);
|
|
19
|
+
|
|
20
|
+
const exit = () => process.chdir(root);
|
|
21
|
+
if (await configured()) return exit();
|
|
22
|
+
|
|
23
|
+
// COPY FILES
|
|
24
|
+
console.log("Composing SDK distribution environments...");
|
|
25
|
+
for (const file of await fs.promises.readdir(BUNDLE))
|
|
26
|
+
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
27
|
+
|
|
28
|
+
// CONFIGURE PATHS
|
|
29
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
30
|
+
await replace({ root, output })(file);
|
|
31
|
+
|
|
32
|
+
// INSTALL PACKAGES
|
|
33
|
+
const v: IDependencies = await dependencies();
|
|
34
|
+
execute("npm install --save-dev rimraf");
|
|
35
|
+
execute(`npm install --save @nestia/fetcher@${v.version}`);
|
|
36
|
+
execute(`npm install --save typia@${v.typia}`);
|
|
37
|
+
if (props.websocket) execute(`npm install --save tgrid@${v.tgrid}`);
|
|
38
|
+
execute("npx typia setup --manager npm");
|
|
39
|
+
|
|
40
|
+
exit();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const configured = async (): Promise<boolean> =>
|
|
44
|
+
["package.json", "tsconfig.json"].every(fs.existsSync) &&
|
|
45
|
+
(await (async () => {
|
|
46
|
+
const content = JSON.parse(
|
|
47
|
+
await fs.promises.readFile("package.json", "utf8"),
|
|
48
|
+
);
|
|
49
|
+
return !!content.dependencies?.["@nestia/fetcher"];
|
|
50
|
+
})());
|
|
51
|
+
|
|
52
|
+
const execute = (command: string) => {
|
|
53
|
+
console.log(` - ${command}`);
|
|
54
|
+
cp.execSync(command, { stdio: "ignore" });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const replace =
|
|
58
|
+
(props: { root: string; output: string }) =>
|
|
59
|
+
async (file: string): Promise<void> => {
|
|
60
|
+
const relative = (from: string) => (to: string) =>
|
|
61
|
+
path.relative(from, to).split("\\").join("/");
|
|
62
|
+
const root: string = relative(process.cwd())(props.root);
|
|
63
|
+
const output: string = relative(process.cwd())(props.output);
|
|
64
|
+
const current: string = relative(props.root)(process.cwd());
|
|
65
|
+
|
|
66
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
67
|
+
await fs.promises.writeFile(
|
|
68
|
+
file,
|
|
69
|
+
content
|
|
70
|
+
.split("${root}")
|
|
71
|
+
.join(root)
|
|
72
|
+
.split("${output}")
|
|
73
|
+
.join(output)
|
|
74
|
+
.split("${current}")
|
|
75
|
+
.join(current),
|
|
76
|
+
"utf8",
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const dependencies = async (): Promise<IDependencies> => {
|
|
81
|
+
const content: string = await fs.promises.readFile(
|
|
82
|
+
__dirname + "/../../../package.json",
|
|
83
|
+
"utf8",
|
|
84
|
+
);
|
|
85
|
+
const json: {
|
|
86
|
+
version: string;
|
|
87
|
+
dependencies: Record<string, string>;
|
|
88
|
+
devDependencies: Record<string, string>;
|
|
89
|
+
} = JSON.parse(content);
|
|
90
|
+
return typia.assert<IDependencies>({
|
|
91
|
+
...json.devDependencies,
|
|
92
|
+
...json.dependencies,
|
|
93
|
+
version: json.version,
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface IDependencies {
|
|
99
|
+
version: string;
|
|
100
|
+
typia: string;
|
|
101
|
+
tgrid: string;
|
|
102
|
+
}
|
|
103
|
+
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|