@nestia/migrate 0.13.17 → 0.14.0
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/MigrateApplication.d.ts +1 -0
- package/lib/MigrateApplication.js +823 -873
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateAnalyzer.js +5 -2
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
- package/lib/analyzers/MigrateControllerAnalyzer.d.ts +2 -2
- package/lib/analyzers/MigrateControllerAnalyzer.js +14 -88
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +3 -3
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/executable/bundle.js +1 -1
- package/lib/internal/MigrateCommander.js +5 -2
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -9
- package/lib/programmers/MigrateApiFileProgrammer.js +4 -4
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +2 -8
- package/lib/programmers/MigrateApiFunctionProgrammer.js +33 -30
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -8
- package/lib/programmers/MigrateApiNamespaceProgrammer.js +31 -37
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiProgrammer.js +19 -70
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiSimulatationProgrammer.d.ts +2 -8
- package/lib/programmers/MigrateApiSimulatationProgrammer.js +16 -16
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -1
- package/lib/programmers/MigrateApiStartProgrammer.js +1 -1
- package/lib/programmers/MigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/MigrateE2eProgrammer.js +1 -3
- package/lib/programmers/MigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestMethodProgrammer.js +4 -4
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/MigrateNestProgrammer.js +27 -23
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/MigrateSchemaProgrammer.js +22 -22
- package/lib/structures/IMigrateProgram.d.ts +8 -8
- package/lib/structures/IMigrateRoute.d.ts +1 -46
- package/lib/utils/OpenApiTypeChecker.d.ts +1 -1
- package/lib/utils/StringUtil.d.ts +0 -4
- package/lib/utils/StringUtil.js +0 -31
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/openapi-down-convert/RefVisitor.js +4 -5
- package/lib/utils/openapi-down-convert/RefVisitor.js.map +1 -1
- package/package.json +8 -8
- package/src/MigrateApplication.ts +3 -2
- package/src/analyzers/MigrateAnalyzer.ts +10 -5
- package/src/analyzers/MigrateControllerAnalyzer.ts +17 -122
- package/src/bundles/NEST_TEMPLATE.ts +3 -3
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/internal/MigrateCommander.ts +8 -2
- package/src/programmers/MigrateApiFileProgrammer.ts +10 -14
- package/src/programmers/MigrateApiFunctionProgrammer.ts +43 -41
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +33 -51
- package/src/programmers/MigrateApiProgrammer.ts +26 -95
- package/src/programmers/MigrateApiSimulatationProgrammer.ts +17 -25
- package/src/programmers/MigrateApiStartProgrammer.ts +1 -1
- package/src/programmers/MigrateE2eProgrammer.ts +1 -3
- package/src/programmers/MigrateNestMethodProgrammer.ts +4 -4
- package/src/programmers/MigrateNestProgrammer.ts +10 -4
- package/src/structures/IMigrateProgram.ts +8 -8
- package/src/structures/IMigrateRoute.ts +1 -51
- package/src/utils/StringUtil.ts +0 -42
- package/lib/analyzers/MigrateMethodAnalyzer.d.ts +0 -9
- package/lib/analyzers/MigrateMethodAnalyzer.js +0 -304
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +0 -1
- package/src/analyzers/MigrateMethodAnalyzer.ts +0 -387
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.MigrateNestProgrammer = void 0;
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
8
|
+
const MigrateControllerAnalyzer_1 = require("../analyzers/MigrateControllerAnalyzer");
|
8
9
|
const FilePrinter_1 = require("../utils/FilePrinter");
|
9
10
|
const MigrateDtoProgrammer_1 = require("./MigrateDtoProgrammer");
|
10
11
|
const MigrateImportProgrammer_1 = require("./MigrateImportProgrammer");
|
@@ -12,29 +13,32 @@ const MigrateNestControllerProgrammer_1 = require("./MigrateNestControllerProgra
|
|
12
13
|
const MigrateNestModuleProgrammer_1 = require("./MigrateNestModuleProgrammer");
|
13
14
|
var MigrateNestProgrammer;
|
14
15
|
(function (MigrateNestProgrammer) {
|
15
|
-
MigrateNestProgrammer.write = (program) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
16
|
+
MigrateNestProgrammer.write = (program) => {
|
17
|
+
const controllers = MigrateControllerAnalyzer_1.MigrateControllerAnalyzer.analyze(program.routes);
|
18
|
+
return [
|
19
|
+
{
|
20
|
+
location: "src",
|
21
|
+
file: "MyModule.ts",
|
22
|
+
statements: MigrateNestModuleProgrammer_1.MigrateNestModuleProgrammer.write(controllers),
|
23
|
+
},
|
24
|
+
...controllers.map((c) => ({
|
25
|
+
location: c.location,
|
26
|
+
file: `${c.name}.ts`,
|
27
|
+
statements: MigrateNestControllerProgrammer_1.MigrateNestControllerProgrammer.write(program.document.components)(c),
|
28
|
+
})),
|
29
|
+
...[
|
30
|
+
...MigrateDtoProgrammer_1.MigrateDtoProgrammer.compose(program.document.components).entries(),
|
31
|
+
].map(([key, value]) => ({
|
32
|
+
location: "src/api/structures",
|
33
|
+
file: `${key}.ts`,
|
34
|
+
statements: writeDtoFile(key, value),
|
35
|
+
})),
|
36
|
+
].map((o) => ({
|
37
|
+
location: o.location,
|
38
|
+
file: o.file,
|
39
|
+
content: FilePrinter_1.FilePrinter.write({ statements: o.statements }),
|
40
|
+
}));
|
41
|
+
};
|
38
42
|
const writeDtoFile = (key, modulo) => {
|
39
43
|
const importer = new MigrateImportProgrammer_1.MigrateImportProgrammer();
|
40
44
|
const statements = iterate(importer)(modulo);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MigrateNestProgrammer.js","sourceRoot":"","sources":["../../src/programmers/MigrateNestProgrammer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;
|
1
|
+
{"version":3,"file":"MigrateNestProgrammer.js","sourceRoot":"","sources":["../../src/programmers/MigrateNestProgrammer.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAE5B,sFAAmF;AAInF,sDAAmD;AACnD,iEAA8D;AAC9D,uEAAoE;AACpE,uFAAoF;AACpF,+EAA4E;AAE5E,IAAiB,qBAAqB,CAmErC;AAnED,WAAiB,qBAAqB;IACvB,2BAAK,GAAG,CAAC,OAAwB,EAAkB,EAAE;QAChE,MAAM,WAAW,GAAyB,qDAAyB,CAAC,OAAO,CACzE,OAAO,CAAC,MAAM,CACf,CAAC;QACF,OAAO;YACL;gBACE,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,aAAa;gBACnB,UAAU,EAAE,yDAA2B,CAAC,KAAK,CAAC,WAAW,CAAC;aAC3D;YACD,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzB,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK;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U;SACd,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,OAAO,GACX,CAAC,QAAiC,EAAE,EAAE,CACtC,CAAC,MAAoC,EAAkB,EAAE;QACvD,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;YAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAmB,EAAE,CAAC;YACpC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC1C,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7C,MAAM,CAAC,IAAI,CACT,oBAAE,CAAC,OAAO,CAAC,uBAAuB,CAChC,CAAC,oBAAE,CAAC,OAAO,CAAC,cAAc,CAAC,oBAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EACxD,oBAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,EACxC,oBAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EACtC,oBAAE,CAAC,SAAS,CAAC,SAAS,CACvB,CACF,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACN,CAAC,EAnEgB,qBAAqB,qCAArB,qBAAqB,QAmErC"}
|
@@ -78,9 +78,9 @@ var MigrateSchemaProgrammer;
|
|
78
78
|
writePlugin({
|
79
79
|
importer,
|
80
80
|
regular: [
|
81
|
-
"description",
|
82
81
|
"const",
|
83
82
|
"title",
|
83
|
+
"description",
|
84
84
|
"deprecated"
|
85
85
|
],
|
86
86
|
intersection,
|
@@ -94,11 +94,11 @@ var MigrateSchemaProgrammer;
|
|
94
94
|
writePlugin({
|
95
95
|
importer,
|
96
96
|
regular: [
|
97
|
-
"description",
|
98
97
|
"default",
|
99
|
-
"type",
|
100
98
|
"title",
|
101
|
-
"
|
99
|
+
"description",
|
100
|
+
"deprecated",
|
101
|
+
"type"
|
102
102
|
],
|
103
103
|
intersection,
|
104
104
|
})(schema);
|
@@ -124,16 +124,16 @@ var MigrateSchemaProgrammer;
|
|
124
124
|
writePlugin({
|
125
125
|
importer,
|
126
126
|
regular: [
|
127
|
-
"description",
|
128
127
|
"default",
|
128
|
+
"title",
|
129
|
+
"description",
|
130
|
+
"deprecated",
|
131
|
+
"type",
|
129
132
|
"minimum",
|
130
133
|
"maximum",
|
131
134
|
"exclusiveMinimum",
|
132
135
|
"exclusiveMaximum",
|
133
|
-
"multipleOf"
|
134
|
-
"type",
|
135
|
-
"title",
|
136
|
-
"deprecated"
|
136
|
+
"multipleOf"
|
137
137
|
],
|
138
138
|
intersection,
|
139
139
|
})(schema);
|
@@ -162,16 +162,16 @@ var MigrateSchemaProgrammer;
|
|
162
162
|
writePlugin({
|
163
163
|
importer,
|
164
164
|
regular: [
|
165
|
-
"description",
|
166
165
|
"default",
|
166
|
+
"title",
|
167
|
+
"description",
|
168
|
+
"deprecated",
|
169
|
+
"type",
|
167
170
|
"contentMediaType",
|
168
171
|
"format",
|
169
172
|
"pattern",
|
170
173
|
"minLength",
|
171
|
-
"maxLength"
|
172
|
-
"type",
|
173
|
-
"title",
|
174
|
-
"deprecated"
|
174
|
+
"maxLength"
|
175
175
|
],
|
176
176
|
intersection,
|
177
177
|
})(schema);
|
@@ -195,14 +195,14 @@ var MigrateSchemaProgrammer;
|
|
195
195
|
writePlugin({
|
196
196
|
importer,
|
197
197
|
regular: [
|
198
|
+
"title",
|
198
199
|
"description",
|
200
|
+
"deprecated",
|
201
|
+
"type",
|
199
202
|
"items",
|
200
203
|
"uniqueItems",
|
201
204
|
"minItems",
|
202
|
-
"maxItems"
|
203
|
-
"type",
|
204
|
-
"title",
|
205
|
-
"deprecated"
|
205
|
+
"maxItems"
|
206
206
|
],
|
207
207
|
intersection,
|
208
208
|
})(schema);
|
@@ -228,15 +228,15 @@ var MigrateSchemaProgrammer;
|
|
228
228
|
writePlugin({
|
229
229
|
importer,
|
230
230
|
regular: [
|
231
|
+
"title",
|
231
232
|
"description",
|
233
|
+
"deprecated",
|
234
|
+
"type",
|
232
235
|
"uniqueItems",
|
233
236
|
"minItems",
|
234
237
|
"maxItems",
|
235
238
|
"prefixItems",
|
236
|
-
"additionalItems"
|
237
|
-
"type",
|
238
|
-
"title",
|
239
|
-
"deprecated"
|
239
|
+
"additionalItems"
|
240
240
|
],
|
241
241
|
intersection,
|
242
242
|
})(schema);
|
@@ -1,25 +1,25 @@
|
|
1
1
|
import { OpenApi } from "@samchon/openapi";
|
2
|
-
import { IMigrateController } from "./IMigrateController";
|
3
2
|
import { IMigrateRoute } from "./IMigrateRoute";
|
4
3
|
export interface IMigrateProgram extends IMigrateProgram.IProps {
|
5
|
-
|
4
|
+
routes: IMigrateRoute[];
|
5
|
+
errors: IMigrateProgram.IError[];
|
6
6
|
}
|
7
7
|
export declare namespace IMigrateProgram {
|
8
|
-
type Dictionary = Map<OpenApi.IOperation, IEntry>;
|
9
|
-
interface IEntry {
|
10
|
-
controller: IMigrateController;
|
11
|
-
route: IMigrateRoute;
|
12
|
-
}
|
13
8
|
interface IProps {
|
14
9
|
mode: "nest" | "sdk";
|
15
10
|
simulate: boolean;
|
16
11
|
e2e: boolean;
|
17
12
|
document: OpenApi.IDocument;
|
18
|
-
dictionary: Dictionary;
|
19
13
|
}
|
20
14
|
interface IConfig {
|
21
15
|
mode: "nest" | "sdk";
|
22
16
|
simulate: boolean;
|
23
17
|
e2e: boolean;
|
24
18
|
}
|
19
|
+
interface IError {
|
20
|
+
method: string;
|
21
|
+
path: string;
|
22
|
+
operation: () => OpenApi.IOperation;
|
23
|
+
messages: string[];
|
24
|
+
}
|
25
25
|
}
|
@@ -1,46 +1 @@
|
|
1
|
-
|
2
|
-
export interface IMigrateRoute {
|
3
|
-
name: string;
|
4
|
-
originalPath: string;
|
5
|
-
path: string;
|
6
|
-
method: string;
|
7
|
-
accessor: string[];
|
8
|
-
parameters: IMigrateRoute.IParameter[];
|
9
|
-
headers: IMigrateRoute.IHeaders | null;
|
10
|
-
query: IMigrateRoute.IQuery | null;
|
11
|
-
body: IMigrateRoute.IBody | null;
|
12
|
-
success: IMigrateRoute.IBody | null;
|
13
|
-
exceptions: Record<string, IMigrateRoute.IException>;
|
14
|
-
comment: () => string;
|
15
|
-
tags: string[];
|
16
|
-
deprecated: boolean;
|
17
|
-
}
|
18
|
-
export declare namespace IMigrateRoute {
|
19
|
-
interface IParameter {
|
20
|
-
name: string;
|
21
|
-
key: string;
|
22
|
-
schema: OpenApi.IJsonSchema;
|
23
|
-
description?: string;
|
24
|
-
}
|
25
|
-
interface IHeaders {
|
26
|
-
name: string;
|
27
|
-
key: string;
|
28
|
-
schema: OpenApi.IJsonSchema;
|
29
|
-
}
|
30
|
-
interface IQuery {
|
31
|
-
name: string;
|
32
|
-
key: string;
|
33
|
-
schema: OpenApi.IJsonSchema;
|
34
|
-
}
|
35
|
-
interface IBody {
|
36
|
-
name: string;
|
37
|
-
key: string;
|
38
|
-
type: "text/plain" | "application/json" | "application/x-www-form-urlencoded" | "multipart/form-data";
|
39
|
-
schema: OpenApi.IJsonSchema;
|
40
|
-
"x-nestia-encrypted"?: boolean;
|
41
|
-
}
|
42
|
-
interface IException {
|
43
|
-
description?: string;
|
44
|
-
schema: OpenApi.IJsonSchema;
|
45
|
-
}
|
46
|
-
}
|
1
|
+
export { IMigrateRoute } from "@samchon/openapi";
|
@@ -10,6 +10,6 @@ export declare namespace OpenApiTypeChecker {
|
|
10
10
|
const isArray: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IArray;
|
11
11
|
const isTuple: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.ITuple;
|
12
12
|
const isObject: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IObject;
|
13
|
-
const isReference: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IReference
|
13
|
+
const isReference: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IReference;
|
14
14
|
const isUnknown: (schema: OpenApi.IJsonSchema) => schema is OpenApi.IJsonSchema.IUnknown;
|
15
15
|
}
|
@@ -1,11 +1,7 @@
|
|
1
1
|
export declare namespace StringUtil {
|
2
2
|
const capitalize: (str: string) => string;
|
3
|
-
const pascal: (path: string) => string;
|
4
|
-
const camel: (path: string) => string;
|
5
3
|
const splitWithNormalization: (path: string) => string[];
|
6
|
-
const reJoinWithDecimalParameters: (path: string) => string;
|
7
4
|
const normalize: (str: string) => string;
|
8
|
-
const commonPrefix: (strs: string[]) => string;
|
9
5
|
const escapeDuplicate: (keep: string[]) => (change: string) => string;
|
10
6
|
const escapeNonVariableSymbols: (str: string) => string;
|
11
7
|
}
|
package/lib/utils/StringUtil.js
CHANGED
@@ -1,45 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.StringUtil = void 0;
|
4
|
-
const NamingConvention_1 = require("typia/lib/utils/NamingConvention");
|
5
4
|
var StringUtil;
|
6
5
|
(function (StringUtil) {
|
7
6
|
StringUtil.capitalize = (str) => str[0].toUpperCase() + str.slice(1).toLowerCase();
|
8
|
-
StringUtil.pascal = (path) => StringUtil.splitWithNormalization(path)
|
9
|
-
.filter((str) => str[0] !== "{")
|
10
|
-
.map(NamingConvention_1.NamingConvention.pascal)
|
11
|
-
.join("");
|
12
|
-
StringUtil.camel = (path) => StringUtil.splitWithNormalization(path)
|
13
|
-
.map((str, i) => i === 0 ? NamingConvention_1.NamingConvention.camel(str) : NamingConvention_1.NamingConvention.pascal(str))
|
14
|
-
.join("");
|
15
7
|
StringUtil.splitWithNormalization = (path) => path
|
16
8
|
.split("/")
|
17
9
|
.map((str) => StringUtil.normalize(str.trim()))
|
18
10
|
.filter((str) => !!str.length);
|
19
|
-
StringUtil.reJoinWithDecimalParameters = (path) => path
|
20
|
-
.split("/")
|
21
|
-
.filter((str) => !!str.length)
|
22
|
-
.map((str) => str[0] === "{" && str[str.length - 1] === "}"
|
23
|
-
? `:${str.substring(1, str.length - 1)}`
|
24
|
-
: str)
|
25
|
-
.join("/");
|
26
11
|
StringUtil.normalize = (str) => str.split(".").join("_").split("-").join("_");
|
27
|
-
StringUtil.commonPrefix = (strs) => {
|
28
|
-
if (strs.length === 0)
|
29
|
-
return "";
|
30
|
-
let prefix = strs[0];
|
31
|
-
for (let i = 1; i < strs.length; i++) {
|
32
|
-
while (strs[i].indexOf(prefix) !== 0) {
|
33
|
-
prefix = prefix.substring(0, prefix.length - 1);
|
34
|
-
if (prefix === "")
|
35
|
-
return "";
|
36
|
-
}
|
37
|
-
}
|
38
|
-
return prefix
|
39
|
-
.split("/")
|
40
|
-
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
|
41
|
-
.join("/");
|
42
|
-
};
|
43
12
|
StringUtil.escapeDuplicate = (keep) => (change) => keep.includes(change) ? StringUtil.escapeDuplicate(keep)(`_${change}`) : change;
|
44
13
|
StringUtil.escapeNonVariableSymbols = (str) => {
|
45
14
|
for (const [before, after] of VARIABLE_REPLACERS)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"StringUtil.js","sourceRoot":"","sources":["../../src/utils/StringUtil.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"StringUtil.js","sourceRoot":"","sources":["../../src/utils/StringUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,UAAU,CA8B1B;AA9BD,WAAiB,UAAU;IACZ,qBAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACxC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAEvC,iCAAsB,GAAG,CAAC,IAAY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AAC,EA9BgB,UAAU,0BAAV,UAAU,QA8B1B;AAED,MAAM,kBAAkB,GAAuB;IAC7C,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,QAAQ,CAAC;IACf,CAAC,GAAG,EAAE,UAAU,CAAC;IACjB,CAAC,GAAG,EAAE,WAAW,CAAC;IAClB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,QAAQ,CAAC;IACf,CAAC,GAAG,EAAE,UAAU,CAAC;IACjB,CAAC,GAAG,EAAE,UAAU,CAAC;IACjB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,QAAQ,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,YAAY,CAAC;IACnB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,KAAK,EAAE,QAAQ,CAAC;CAClB,CAAC"}
|
@@ -1,7 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.
|
4
|
+
exports.isRef = isRef;
|
5
|
+
exports.visitSchemaObjects = visitSchemaObjects;
|
6
|
+
exports.visitRefObjects = visitRefObjects;
|
7
|
+
exports.walkObject = walkObject;
|
5
8
|
/**
|
6
9
|
* Test if a JSON node is a `{ $ref: "uri" }` object
|
7
10
|
*/
|
@@ -11,7 +14,6 @@ function isRef(node) {
|
|
11
14
|
node.hasOwnProperty("$ref") &&
|
12
15
|
typeof node["$ref"] === "string");
|
13
16
|
}
|
14
|
-
exports.isRef = isRef;
|
15
17
|
/**
|
16
18
|
* Walk a JSON object and apply `schemaCallback` when a JSON schema is found.
|
17
19
|
* JSON Schema objects are items in components/schemas or in an item named `schema`
|
@@ -41,7 +43,6 @@ function visitSchemaObjects(node, schemaCallback) {
|
|
41
43
|
};
|
42
44
|
return walkObject(node, objectVisitor);
|
43
45
|
}
|
44
|
-
exports.visitSchemaObjects = visitSchemaObjects;
|
45
46
|
/**
|
46
47
|
* Walk a JSON object and apply `refCallback` when a JSON `{$ref: url }` is found
|
47
48
|
* @param node a node in the OpenAPI document
|
@@ -57,7 +58,6 @@ function visitRefObjects(node, refCallback) {
|
|
57
58
|
};
|
58
59
|
return walkObject(node, objectVisitor);
|
59
60
|
}
|
60
|
-
exports.visitRefObjects = visitRefObjects;
|
61
61
|
/**
|
62
62
|
* Walk a JSON object or array and apply objectCallback when a JSON object is found
|
63
63
|
* @param node a node in the OpenAPI document
|
@@ -96,5 +96,4 @@ function walkObject(node, objectCallback) {
|
|
96
96
|
return array;
|
97
97
|
}
|
98
98
|
}
|
99
|
-
exports.walkObject = walkObject;
|
100
99
|
//# sourceMappingURL=RefVisitor.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RefVisitor.js","sourceRoot":"","sources":["../../../src/utils/openapi-down-convert/RefVisitor.ts"],"names":[],"mappings":";AAAA,uDAAuD
|
1
|
+
{"version":3,"file":"RefVisitor.js","sourceRoot":"","sources":["../../../src/utils/openapi-down-convert/RefVisitor.ts"],"names":[],"mappings":";AAAA,uDAAuD;;AAyCvD,sBAOC;AASD,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AC;YACrD,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAa,CAAC;YACrC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC5C,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;YACxC,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,GAAiB,CAAO,CAAC;YACpD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nestia/migrate",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.14.0",
|
4
4
|
"description": "Migration program from swagger to NestJS",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"typings": "lib/index.d.ts",
|
@@ -36,9 +36,9 @@
|
|
36
36
|
},
|
37
37
|
"homepage": "https://nestia.io",
|
38
38
|
"devDependencies": {
|
39
|
-
"@nestia/core": "^3.2
|
39
|
+
"@nestia/core": "^3.3.2",
|
40
40
|
"@nestia/e2e": "^0.6.0",
|
41
|
-
"@nestia/fetcher": "^3.2
|
41
|
+
"@nestia/fetcher": "^3.3.2",
|
42
42
|
"@nestjs/common": "^10.3.8",
|
43
43
|
"@nestjs/core": "^10.3.8",
|
44
44
|
"@nestjs/platform-express": "^10.3.8",
|
@@ -57,19 +57,19 @@
|
|
57
57
|
"serialize-error": "^4.1.0",
|
58
58
|
"source-map-support": "^0.5.21",
|
59
59
|
"swagger-ui-express": "^5.0.0",
|
60
|
-
"tgrid": "^1.0.
|
60
|
+
"tgrid": "^1.0.2",
|
61
61
|
"ts-node": "^10.9.1",
|
62
|
-
"ts-patch": "^3.1
|
62
|
+
"ts-patch": "^3.2.1",
|
63
63
|
"typescript-transform-paths": "^3.4.6"
|
64
64
|
},
|
65
65
|
"dependencies": {
|
66
|
-
"@samchon/openapi": "^0.1
|
66
|
+
"@samchon/openapi": "^0.2.1",
|
67
67
|
"commander": "10.0.0",
|
68
68
|
"inquirer": "8.2.5",
|
69
69
|
"prettier": "^3.2.5",
|
70
70
|
"tstl": "^3.0.0",
|
71
|
-
"typescript": "
|
72
|
-
"typia": "^6.
|
71
|
+
"typescript": "^5.5.2",
|
72
|
+
"typia": "^6.3.1"
|
73
73
|
},
|
74
74
|
"files": [
|
75
75
|
"lib",
|
@@ -34,7 +34,6 @@ export class MigrateApplication {
|
|
34
34
|
const program: IMigrateProgram = MigrateAnalyzer.analyze({
|
35
35
|
mode: "nest",
|
36
36
|
document: this.document,
|
37
|
-
dictionary: new Map(),
|
38
37
|
simulate: config.simulate,
|
39
38
|
e2e: config.e2e,
|
40
39
|
});
|
@@ -46,6 +45,7 @@ export class MigrateApplication {
|
|
46
45
|
...MigrateApiProgrammer.write(program),
|
47
46
|
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
48
47
|
],
|
48
|
+
errors: program.errors,
|
49
49
|
};
|
50
50
|
}
|
51
51
|
|
@@ -53,7 +53,6 @@ export class MigrateApplication {
|
|
53
53
|
const program: IMigrateProgram = MigrateAnalyzer.analyze({
|
54
54
|
mode: "sdk",
|
55
55
|
document: this.document,
|
56
|
-
dictionary: new Map(),
|
57
56
|
simulate: config.simulate,
|
58
57
|
e2e: config.e2e,
|
59
58
|
});
|
@@ -70,6 +69,7 @@ export class MigrateApplication {
|
|
70
69
|
content: JSON.stringify(this.document, null, 2),
|
71
70
|
},
|
72
71
|
],
|
72
|
+
errors: program.errors,
|
73
73
|
};
|
74
74
|
}
|
75
75
|
}
|
@@ -77,6 +77,7 @@ export namespace MigrateApplication {
|
|
77
77
|
export interface IOutput {
|
78
78
|
program: IMigrateProgram;
|
79
79
|
files: IMigrateFile[];
|
80
|
+
errors: IMigrateProgram.IError[];
|
80
81
|
}
|
81
82
|
export interface IConfig {
|
82
83
|
simulate: boolean;
|
@@ -1,9 +1,14 @@
|
|
1
|
+
import { OpenApi } from "@samchon/openapi";
|
2
|
+
|
1
3
|
import { IMigrateProgram } from "../structures/IMigrateProgram";
|
2
|
-
import { MigrateControllerAnalyzer } from "./MigrateControllerAnalyzer";
|
3
4
|
|
4
5
|
export namespace MigrateAnalyzer {
|
5
|
-
export const analyze = (props: IMigrateProgram.IProps): IMigrateProgram =>
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
export const analyze = (props: IMigrateProgram.IProps): IMigrateProgram => {
|
7
|
+
const result = OpenApi.migrate(props.document);
|
8
|
+
return {
|
9
|
+
...props,
|
10
|
+
routes: result.routes,
|
11
|
+
errors: result.errors,
|
12
|
+
};
|
13
|
+
};
|
9
14
|
}
|