@nestia/migrate 12.0.0-rc.2 → 12.0.0-rc.3
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/lib/_virtual/_tstl.mjs +2 -2
- package/lib/_virtual/index.mjs +2 -2
- package/lib/_virtual/index2.mjs +2 -2
- package/lib/_virtual/index3.mjs +2 -2
- package/lib/archivers/NestiaMigrateFileArchiver2.mjs +2 -2
- package/lib/archivers/NestiaMigrateFileArchiver2.mjs.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +47 -47
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE2.mjs +47 -47
- package/lib/bundles/NEST_TEMPLATE2.mjs.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +20 -20
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE2.mjs +20 -20
- package/lib/bundles/SDK_TEMPLATE2.mjs.map +1 -1
- package/lib/index2.mjs +1 -1
- package/lib/module2.mjs +2 -2
- package/lib/programmers/NestiaMigrateApiProgrammer2.mjs +4 -4
- package/lib/programmers/NestiaMigrateApiProgrammer2.mjs.map +1 -1
- package/lib/programmers/index2.mjs +1 -1
- package/lib/structures/index2.mjs +1 -1
- package/package.json +6 -6
- package/src/NestiaMigrateApplication.ts +196 -196
- package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
- package/src/bundles/NEST_TEMPLATE.ts +47 -47
- package/src/bundles/SDK_TEMPLATE.ts +20 -20
- package/src/executable/NestiaMigrateCommander.ts +115 -115
- package/src/executable/NestiaMigrateInquirer.ts +106 -106
- package/src/executable/bundle.js +323 -349
- package/src/executable/migrate.ts +7 -7
- package/src/factories/ExpressionFactory.ts +23 -23
- package/src/factories/FormatCheatSheet.ts +71 -71
- package/src/factories/IdentifierFactory.ts +84 -84
- package/src/factories/LiteralFactory.ts +54 -54
- package/src/factories/StatementFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +27 -27
- package/src/factories/TypeLiteralFactory.ts +62 -62
- package/src/index.ts +4 -4
- package/src/internal/ts.ts +75 -75
- package/src/module.ts +6 -6
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +358 -358
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +511 -511
- package/src/programmers/NestiaMigrateApiProgrammer.ts +108 -108
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +309 -309
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +117 -117
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +155 -155
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
- package/src/programmers/NestiaMigrateImportProgrammer.ts +119 -119
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +70 -70
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +402 -402
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +64 -64
- package/src/programmers/NestiaMigrateNestProgrammer.ts +89 -89
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
- package/src/programmers/index.ts +15 -15
- package/src/structures/INestiaMigrateConfig.ts +19 -19
- package/src/structures/INestiaMigrateContext.ts +9 -9
- package/src/structures/INestiaMigrateController.ts +8 -8
- package/src/structures/INestiaMigrateFile.ts +5 -5
- package/src/structures/index.ts +4 -4
- package/src/utils/FilePrinter.ts +44 -44
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/StringUtil.ts +109 -109
- package/README.md +0 -93
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { type KeywordTypeNode, SyntaxKind, factory } from "@ttsc/factory";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Higher-level type-keyword factory.
|
|
5
|
-
*
|
|
6
|
-
* Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
|
|
7
|
-
* generator code reads as `TypeFactory.keyword("any")` instead of selecting the
|
|
8
|
-
* `SyntaxKind.AnyKeyword` token by hand.
|
|
9
|
-
*/
|
|
10
|
-
export namespace TypeFactory {
|
|
11
|
-
const KEYWORDS = {
|
|
12
|
-
void: SyntaxKind.VoidKeyword,
|
|
13
|
-
any: SyntaxKind.AnyKeyword,
|
|
14
|
-
unknown: SyntaxKind.UnknownKeyword,
|
|
15
|
-
boolean: SyntaxKind.BooleanKeyword,
|
|
16
|
-
number: SyntaxKind.NumberKeyword,
|
|
17
|
-
bigint: SyntaxKind.BigIntKeyword,
|
|
18
|
-
string: SyntaxKind.StringKeyword,
|
|
19
|
-
never: SyntaxKind.NeverKeyword,
|
|
20
|
-
undefined: SyntaxKind.UndefinedKeyword,
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
export type Keyword = keyof typeof KEYWORDS;
|
|
24
|
-
|
|
25
|
-
export const keyword = (type: Keyword): KeywordTypeNode =>
|
|
26
|
-
factory.createKeywordTypeNode(KEYWORDS[type]);
|
|
27
|
-
}
|
|
1
|
+
import { type KeywordTypeNode, SyntaxKind, factory } from "@ttsc/factory";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Higher-level type-keyword factory.
|
|
5
|
+
*
|
|
6
|
+
* Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
|
|
7
|
+
* generator code reads as `TypeFactory.keyword("any")` instead of selecting the
|
|
8
|
+
* `SyntaxKind.AnyKeyword` token by hand.
|
|
9
|
+
*/
|
|
10
|
+
export namespace TypeFactory {
|
|
11
|
+
const KEYWORDS = {
|
|
12
|
+
void: SyntaxKind.VoidKeyword,
|
|
13
|
+
any: SyntaxKind.AnyKeyword,
|
|
14
|
+
unknown: SyntaxKind.UnknownKeyword,
|
|
15
|
+
boolean: SyntaxKind.BooleanKeyword,
|
|
16
|
+
number: SyntaxKind.NumberKeyword,
|
|
17
|
+
bigint: SyntaxKind.BigIntKeyword,
|
|
18
|
+
string: SyntaxKind.StringKeyword,
|
|
19
|
+
never: SyntaxKind.NeverKeyword,
|
|
20
|
+
undefined: SyntaxKind.UndefinedKeyword,
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export type Keyword = keyof typeof KEYWORDS;
|
|
24
|
+
|
|
25
|
+
export const keyword = (type: Keyword): KeywordTypeNode =>
|
|
26
|
+
factory.createKeywordTypeNode(KEYWORDS[type]);
|
|
27
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { SyntaxKind, factory } from "@ttsc/factory";
|
|
2
|
-
import * as typiaUtils from "@typia/utils";
|
|
3
|
-
|
|
4
|
-
import ts from "../internal/ts";
|
|
5
|
-
|
|
6
|
-
const { NamingConvention } =
|
|
7
|
-
(typiaUtils as { default?: typeof typiaUtils }).default ?? typiaUtils;
|
|
8
|
-
|
|
9
|
-
export namespace TypeLiteralFactory {
|
|
10
|
-
export const generate = (value: any): ts.TypeNode =>
|
|
11
|
-
typeof value === "boolean"
|
|
12
|
-
? generateBoolean(value)
|
|
13
|
-
: typeof value === "number"
|
|
14
|
-
? generateNumber(value)
|
|
15
|
-
: typeof value === "string"
|
|
16
|
-
? generatestring(value)
|
|
17
|
-
: typeof value === "object"
|
|
18
|
-
? value === null
|
|
19
|
-
? generateNull()
|
|
20
|
-
: Array.isArray(value)
|
|
21
|
-
? generateTuple(value)
|
|
22
|
-
: generateObject(value)
|
|
23
|
-
: factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
|
|
24
|
-
|
|
25
|
-
const generatestring = (str: string) =>
|
|
26
|
-
factory.createLiteralTypeNode(factory.createStringLiteral(str));
|
|
27
|
-
|
|
28
|
-
const generateNumber = (num: number) =>
|
|
29
|
-
factory.createLiteralTypeNode(
|
|
30
|
-
num < 0
|
|
31
|
-
? factory.createPrefixUnaryExpression(
|
|
32
|
-
SyntaxKind.MinusToken,
|
|
33
|
-
factory.createNumericLiteral(-num),
|
|
34
|
-
)
|
|
35
|
-
: factory.createNumericLiteral(num),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const generateBoolean = (bool: boolean) =>
|
|
39
|
-
factory.createLiteralTypeNode(
|
|
40
|
-
bool ? factory.createTrue() : factory.createFalse(),
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const generateNull = () =>
|
|
44
|
-
factory.createLiteralTypeNode(factory.createNull());
|
|
45
|
-
|
|
46
|
-
const generateTuple = (items: any[]) =>
|
|
47
|
-
factory.createTupleTypeNode(items.map(generate));
|
|
48
|
-
|
|
49
|
-
const generateObject = (obj: object) =>
|
|
50
|
-
factory.createTypeLiteralNode(
|
|
51
|
-
Object.entries(obj).map(([key, value]) =>
|
|
52
|
-
factory.createPropertySignature(
|
|
53
|
-
undefined,
|
|
54
|
-
NamingConvention.variable(key)
|
|
55
|
-
? factory.createIdentifier(key)
|
|
56
|
-
: factory.createStringLiteral(key),
|
|
57
|
-
undefined,
|
|
58
|
-
generate(value),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
1
|
+
import { SyntaxKind, factory } from "@ttsc/factory";
|
|
2
|
+
import * as typiaUtils from "@typia/utils";
|
|
3
|
+
|
|
4
|
+
import ts from "../internal/ts";
|
|
5
|
+
|
|
6
|
+
const { NamingConvention } =
|
|
7
|
+
(typiaUtils as { default?: typeof typiaUtils }).default ?? typiaUtils;
|
|
8
|
+
|
|
9
|
+
export namespace TypeLiteralFactory {
|
|
10
|
+
export const generate = (value: any): ts.TypeNode =>
|
|
11
|
+
typeof value === "boolean"
|
|
12
|
+
? generateBoolean(value)
|
|
13
|
+
: typeof value === "number"
|
|
14
|
+
? generateNumber(value)
|
|
15
|
+
: typeof value === "string"
|
|
16
|
+
? generatestring(value)
|
|
17
|
+
: typeof value === "object"
|
|
18
|
+
? value === null
|
|
19
|
+
? generateNull()
|
|
20
|
+
: Array.isArray(value)
|
|
21
|
+
? generateTuple(value)
|
|
22
|
+
: generateObject(value)
|
|
23
|
+
: factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
|
|
24
|
+
|
|
25
|
+
const generatestring = (str: string) =>
|
|
26
|
+
factory.createLiteralTypeNode(factory.createStringLiteral(str));
|
|
27
|
+
|
|
28
|
+
const generateNumber = (num: number) =>
|
|
29
|
+
factory.createLiteralTypeNode(
|
|
30
|
+
num < 0
|
|
31
|
+
? factory.createPrefixUnaryExpression(
|
|
32
|
+
SyntaxKind.MinusToken,
|
|
33
|
+
factory.createNumericLiteral(-num),
|
|
34
|
+
)
|
|
35
|
+
: factory.createNumericLiteral(num),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const generateBoolean = (bool: boolean) =>
|
|
39
|
+
factory.createLiteralTypeNode(
|
|
40
|
+
bool ? factory.createTrue() : factory.createFalse(),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const generateNull = () =>
|
|
44
|
+
factory.createLiteralTypeNode(factory.createNull());
|
|
45
|
+
|
|
46
|
+
const generateTuple = (items: any[]) =>
|
|
47
|
+
factory.createTupleTypeNode(items.map(generate));
|
|
48
|
+
|
|
49
|
+
const generateObject = (obj: object) =>
|
|
50
|
+
factory.createTypeLiteralNode(
|
|
51
|
+
Object.entries(obj).map(([key, value]) =>
|
|
52
|
+
factory.createPropertySignature(
|
|
53
|
+
undefined,
|
|
54
|
+
NamingConvention.variable(key)
|
|
55
|
+
? factory.createIdentifier(key)
|
|
56
|
+
: factory.createStringLiteral(key),
|
|
57
|
+
undefined,
|
|
58
|
+
generate(value),
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as migrate from "./module";
|
|
2
|
-
|
|
3
|
-
export default migrate;
|
|
4
|
-
export * from "./module";
|
|
1
|
+
import * as migrate from "./module";
|
|
2
|
+
|
|
3
|
+
export default migrate;
|
|
4
|
+
export * from "./module";
|
package/src/internal/ts.ts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
// Compatibility shim that replaces `import ts from "typescript"`. AST
|
|
2
|
-
// construction now goes through `@ttsc/factory`'s `factory`, `SyntaxKind`, and
|
|
3
|
-
// `NodeFlags`, imported directly where needed; the value side here exposes only
|
|
4
|
-
// the `isUnionTypeNode` guard the migrate generators still call. The type
|
|
5
|
-
// aliases (`ts.Expression`, `ts.ParameterDeclaration`, …) map to the matching
|
|
6
|
-
// `@ttsc/factory` node types so existing annotations keep their precise shapes.
|
|
7
|
-
import {
|
|
8
|
-
type Block,
|
|
9
|
-
type CallExpression,
|
|
10
|
-
type Decorator,
|
|
11
|
-
type Expression,
|
|
12
|
-
type FunctionDeclaration,
|
|
13
|
-
type Identifier,
|
|
14
|
-
type KeywordTypeNode,
|
|
15
|
-
type MethodDeclaration,
|
|
16
|
-
type ModuleDeclaration,
|
|
17
|
-
type Node,
|
|
18
|
-
type ParameterDeclaration,
|
|
19
|
-
type Statement,
|
|
20
|
-
type TypeAliasDeclaration,
|
|
21
|
-
type TypeNode,
|
|
22
|
-
type TypeReferenceNode,
|
|
23
|
-
type UnionTypeNode,
|
|
24
|
-
type VariableStatement,
|
|
25
|
-
} from "@ttsc/factory";
|
|
26
|
-
|
|
27
|
-
interface TsValue {
|
|
28
|
-
isUnionTypeNode(node: Node | undefined): node is UnionTypeNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const ts: TsValue = {
|
|
32
|
-
isUnionTypeNode: (node: Node | undefined): node is UnionTypeNode =>
|
|
33
|
-
!!node && node.kind === "UnionTypeNode",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type _Block = Block;
|
|
37
|
-
type _CallExpression = CallExpression;
|
|
38
|
-
type _Decorator = Decorator;
|
|
39
|
-
type _Expression = Expression;
|
|
40
|
-
type _FunctionDeclaration = FunctionDeclaration;
|
|
41
|
-
type _Identifier = Identifier;
|
|
42
|
-
type _KeywordTypeNode = KeywordTypeNode;
|
|
43
|
-
type _MethodDeclaration = MethodDeclaration;
|
|
44
|
-
type _ModuleDeclaration = ModuleDeclaration;
|
|
45
|
-
type _Node = Node;
|
|
46
|
-
type _ParameterDeclaration = ParameterDeclaration;
|
|
47
|
-
type _Statement = Statement;
|
|
48
|
-
type _TypeAliasDeclaration = TypeAliasDeclaration;
|
|
49
|
-
type _TypeNode = TypeNode;
|
|
50
|
-
type _TypeReferenceNode = TypeReferenceNode;
|
|
51
|
-
type _UnionTypeNode = UnionTypeNode;
|
|
52
|
-
type _VariableStatement = VariableStatement;
|
|
53
|
-
|
|
54
|
-
declare namespace ts {
|
|
55
|
-
export type Node = _Node;
|
|
56
|
-
export type Block = _Block;
|
|
57
|
-
export type CallExpression = _CallExpression;
|
|
58
|
-
export type ConciseBody = _Block | _Expression;
|
|
59
|
-
export type Decorator = _Decorator;
|
|
60
|
-
export type Expression = _Expression;
|
|
61
|
-
export type FunctionDeclaration = _FunctionDeclaration;
|
|
62
|
-
export type Identifier = _Identifier;
|
|
63
|
-
export type KeywordTypeNode = _KeywordTypeNode;
|
|
64
|
-
export type MethodDeclaration = _MethodDeclaration;
|
|
65
|
-
export type ModuleDeclaration = _ModuleDeclaration;
|
|
66
|
-
export type ParameterDeclaration = _ParameterDeclaration;
|
|
67
|
-
export type Statement = _Statement;
|
|
68
|
-
export type TypeAliasDeclaration = _TypeAliasDeclaration;
|
|
69
|
-
export type TypeNode = _TypeNode;
|
|
70
|
-
export type TypeReferenceNode = _TypeReferenceNode;
|
|
71
|
-
export type UnionTypeNode = _UnionTypeNode;
|
|
72
|
-
export type VariableStatement = _VariableStatement;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default ts;
|
|
1
|
+
// Compatibility shim that replaces `import ts from "typescript"`. AST
|
|
2
|
+
// construction now goes through `@ttsc/factory`'s `factory`, `SyntaxKind`, and
|
|
3
|
+
// `NodeFlags`, imported directly where needed; the value side here exposes only
|
|
4
|
+
// the `isUnionTypeNode` guard the migrate generators still call. The type
|
|
5
|
+
// aliases (`ts.Expression`, `ts.ParameterDeclaration`, …) map to the matching
|
|
6
|
+
// `@ttsc/factory` node types so existing annotations keep their precise shapes.
|
|
7
|
+
import {
|
|
8
|
+
type Block,
|
|
9
|
+
type CallExpression,
|
|
10
|
+
type Decorator,
|
|
11
|
+
type Expression,
|
|
12
|
+
type FunctionDeclaration,
|
|
13
|
+
type Identifier,
|
|
14
|
+
type KeywordTypeNode,
|
|
15
|
+
type MethodDeclaration,
|
|
16
|
+
type ModuleDeclaration,
|
|
17
|
+
type Node,
|
|
18
|
+
type ParameterDeclaration,
|
|
19
|
+
type Statement,
|
|
20
|
+
type TypeAliasDeclaration,
|
|
21
|
+
type TypeNode,
|
|
22
|
+
type TypeReferenceNode,
|
|
23
|
+
type UnionTypeNode,
|
|
24
|
+
type VariableStatement,
|
|
25
|
+
} from "@ttsc/factory";
|
|
26
|
+
|
|
27
|
+
interface TsValue {
|
|
28
|
+
isUnionTypeNode(node: Node | undefined): node is UnionTypeNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ts: TsValue = {
|
|
32
|
+
isUnionTypeNode: (node: Node | undefined): node is UnionTypeNode =>
|
|
33
|
+
!!node && node.kind === "UnionTypeNode",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type _Block = Block;
|
|
37
|
+
type _CallExpression = CallExpression;
|
|
38
|
+
type _Decorator = Decorator;
|
|
39
|
+
type _Expression = Expression;
|
|
40
|
+
type _FunctionDeclaration = FunctionDeclaration;
|
|
41
|
+
type _Identifier = Identifier;
|
|
42
|
+
type _KeywordTypeNode = KeywordTypeNode;
|
|
43
|
+
type _MethodDeclaration = MethodDeclaration;
|
|
44
|
+
type _ModuleDeclaration = ModuleDeclaration;
|
|
45
|
+
type _Node = Node;
|
|
46
|
+
type _ParameterDeclaration = ParameterDeclaration;
|
|
47
|
+
type _Statement = Statement;
|
|
48
|
+
type _TypeAliasDeclaration = TypeAliasDeclaration;
|
|
49
|
+
type _TypeNode = TypeNode;
|
|
50
|
+
type _TypeReferenceNode = TypeReferenceNode;
|
|
51
|
+
type _UnionTypeNode = UnionTypeNode;
|
|
52
|
+
type _VariableStatement = VariableStatement;
|
|
53
|
+
|
|
54
|
+
declare namespace ts {
|
|
55
|
+
export type Node = _Node;
|
|
56
|
+
export type Block = _Block;
|
|
57
|
+
export type CallExpression = _CallExpression;
|
|
58
|
+
export type ConciseBody = _Block | _Expression;
|
|
59
|
+
export type Decorator = _Decorator;
|
|
60
|
+
export type Expression = _Expression;
|
|
61
|
+
export type FunctionDeclaration = _FunctionDeclaration;
|
|
62
|
+
export type Identifier = _Identifier;
|
|
63
|
+
export type KeywordTypeNode = _KeywordTypeNode;
|
|
64
|
+
export type MethodDeclaration = _MethodDeclaration;
|
|
65
|
+
export type ModuleDeclaration = _ModuleDeclaration;
|
|
66
|
+
export type ParameterDeclaration = _ParameterDeclaration;
|
|
67
|
+
export type Statement = _Statement;
|
|
68
|
+
export type TypeAliasDeclaration = _TypeAliasDeclaration;
|
|
69
|
+
export type TypeNode = _TypeNode;
|
|
70
|
+
export type TypeReferenceNode = _TypeReferenceNode;
|
|
71
|
+
export type UnionTypeNode = _UnionTypeNode;
|
|
72
|
+
export type VariableStatement = _VariableStatement;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default ts;
|
package/src/module.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./NestiaMigrateApplication";
|
|
2
|
-
export * from "./structures/index";
|
|
3
|
-
|
|
4
|
-
export * from "./archivers/NestiaMigrateFileArchiver";
|
|
5
|
-
|
|
6
|
-
export * from "./programmers/index";
|
|
1
|
+
export * from "./NestiaMigrateApplication";
|
|
2
|
+
export * from "./structures/index";
|
|
3
|
+
|
|
4
|
+
export * from "./archivers/NestiaMigrateFileArchiver";
|
|
5
|
+
|
|
6
|
+
export * from "./programmers/index";
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { factory } from "@ttsc/factory";
|
|
2
|
-
import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
|
|
3
|
-
|
|
4
|
-
import ts from "../internal/ts";
|
|
5
|
-
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
6
|
-
import { FilePrinter } from "../utils/FilePrinter";
|
|
7
|
-
import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionProgrammer";
|
|
8
|
-
import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
|
|
9
|
-
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
|
10
|
-
|
|
11
|
-
export namespace NestiaMigrateApiFileProgrammer {
|
|
12
|
-
export interface IProps {
|
|
13
|
-
config: INestiaMigrateConfig;
|
|
14
|
-
components: OpenApi.IComponents;
|
|
15
|
-
namespace: string[];
|
|
16
|
-
routes: IHttpMigrateRoute[];
|
|
17
|
-
children: Set<string>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const write = (props: IProps): ts.Statement[] => {
|
|
21
|
-
const importer: NestiaMigrateImportProgrammer =
|
|
22
|
-
new NestiaMigrateImportProgrammer();
|
|
23
|
-
const statements: ts.Statement[] = props.routes
|
|
24
|
-
.map((route) => [
|
|
25
|
-
FilePrinter.newLine(),
|
|
26
|
-
NestiaMigrateApiFunctionProgrammer.write({
|
|
27
|
-
config: props.config,
|
|
28
|
-
components: props.components,
|
|
29
|
-
importer,
|
|
30
|
-
route,
|
|
31
|
-
}),
|
|
32
|
-
NestiaMigrateApiNamespaceProgrammer.write({
|
|
33
|
-
config: props.config,
|
|
34
|
-
components: props.components,
|
|
35
|
-
importer,
|
|
36
|
-
route,
|
|
37
|
-
}),
|
|
38
|
-
])
|
|
39
|
-
.flat();
|
|
40
|
-
return [
|
|
41
|
-
...importer.toStatements(
|
|
42
|
-
(ref) => `../${"../".repeat(props.namespace.length)}structures/${ref}`,
|
|
43
|
-
),
|
|
44
|
-
...[...props.children].map((child) =>
|
|
45
|
-
factory.createExportDeclaration(
|
|
46
|
-
undefined,
|
|
47
|
-
false,
|
|
48
|
-
factory.createNamespaceExport(factory.createIdentifier(child)),
|
|
49
|
-
factory.createStringLiteral(`./${child}/index`),
|
|
50
|
-
),
|
|
51
|
-
),
|
|
52
|
-
...statements,
|
|
53
|
-
];
|
|
54
|
-
};
|
|
55
|
-
}
|
|
1
|
+
import { factory } from "@ttsc/factory";
|
|
2
|
+
import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
|
|
3
|
+
|
|
4
|
+
import ts from "../internal/ts";
|
|
5
|
+
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
6
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
|
7
|
+
import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionProgrammer";
|
|
8
|
+
import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
|
|
9
|
+
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
|
10
|
+
|
|
11
|
+
export namespace NestiaMigrateApiFileProgrammer {
|
|
12
|
+
export interface IProps {
|
|
13
|
+
config: INestiaMigrateConfig;
|
|
14
|
+
components: OpenApi.IComponents;
|
|
15
|
+
namespace: string[];
|
|
16
|
+
routes: IHttpMigrateRoute[];
|
|
17
|
+
children: Set<string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const write = (props: IProps): ts.Statement[] => {
|
|
21
|
+
const importer: NestiaMigrateImportProgrammer =
|
|
22
|
+
new NestiaMigrateImportProgrammer();
|
|
23
|
+
const statements: ts.Statement[] = props.routes
|
|
24
|
+
.map((route) => [
|
|
25
|
+
FilePrinter.newLine(),
|
|
26
|
+
NestiaMigrateApiFunctionProgrammer.write({
|
|
27
|
+
config: props.config,
|
|
28
|
+
components: props.components,
|
|
29
|
+
importer,
|
|
30
|
+
route,
|
|
31
|
+
}),
|
|
32
|
+
NestiaMigrateApiNamespaceProgrammer.write({
|
|
33
|
+
config: props.config,
|
|
34
|
+
components: props.components,
|
|
35
|
+
importer,
|
|
36
|
+
route,
|
|
37
|
+
}),
|
|
38
|
+
])
|
|
39
|
+
.flat();
|
|
40
|
+
return [
|
|
41
|
+
...importer.toStatements(
|
|
42
|
+
(ref) => `../${"../".repeat(props.namespace.length)}structures/${ref}`,
|
|
43
|
+
),
|
|
44
|
+
...[...props.children].map((child) =>
|
|
45
|
+
factory.createExportDeclaration(
|
|
46
|
+
undefined,
|
|
47
|
+
false,
|
|
48
|
+
factory.createNamespaceExport(factory.createIdentifier(child)),
|
|
49
|
+
factory.createStringLiteral(`./${child}/index`),
|
|
50
|
+
),
|
|
51
|
+
),
|
|
52
|
+
...statements,
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
}
|