@nestia/migrate 12.0.0-dev.20260601.1 → 12.0.0-dev.20260612.1

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.
Files changed (50) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/NestiaMigrateApplication.js +19 -1
  4. package/lib/NestiaMigrateApplication.js.map +1 -1
  5. package/lib/bundles/NEST_TEMPLATE.js +47 -47
  6. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  7. package/lib/bundles/SDK_TEMPLATE.js +20 -20
  8. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  9. package/lib/index.mjs +94 -77
  10. package/lib/index.mjs.map +1 -1
  11. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +6 -2
  12. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  13. package/package.json +5 -5
  14. package/src/NestiaMigrateApplication.ts +196 -167
  15. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  16. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  17. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  18. package/src/bundles/SDK_TEMPLATE.ts +20 -20
  19. package/src/executable/NestiaMigrateCommander.ts +115 -115
  20. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  21. package/src/executable/bundle.js +349 -349
  22. package/src/executable/migrate.ts +7 -7
  23. package/src/factories/TypeLiteralFactory.ts +63 -63
  24. package/src/index.ts +4 -4
  25. package/src/internal/ts.ts +94 -94
  26. package/src/module.ts +6 -6
  27. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +58 -58
  28. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +373 -369
  29. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +528 -528
  30. package/src/programmers/NestiaMigrateApiProgrammer.ts +108 -108
  31. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +314 -314
  32. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  33. package/src/programmers/NestiaMigrateDtoProgrammer.ts +99 -99
  34. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +156 -156
  35. package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
  36. package/src/programmers/NestiaMigrateImportProgrammer.ts +119 -119
  37. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +70 -70
  38. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +414 -414
  39. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +66 -66
  40. package/src/programmers/NestiaMigrateNestProgrammer.ts +89 -89
  41. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +477 -477
  42. package/src/programmers/index.ts +15 -15
  43. package/src/structures/INestiaMigrateConfig.ts +19 -19
  44. package/src/structures/INestiaMigrateContext.ts +9 -9
  45. package/src/structures/INestiaMigrateController.ts +8 -8
  46. package/src/structures/INestiaMigrateFile.ts +5 -5
  47. package/src/structures/index.ts +4 -4
  48. package/src/utils/FilePrinter.ts +44 -44
  49. package/src/utils/MapUtil.ts +13 -13
  50. package/src/utils/StringUtil.ts +109 -109
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
2
- import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
-
4
- NestiaMigrateCommander.main().catch((exp) => {
5
- console.error(exp);
6
- process.exit(-1);
7
- });
1
+ #!/usr/bin/env node
2
+ import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
+
4
+ NestiaMigrateCommander.main().catch((exp) => {
5
+ console.error(exp);
6
+ process.exit(-1);
7
+ });
@@ -1,63 +1,63 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import * as typiaUtils from "@typia/utils";
3
- import ts from "../internal/ts";
4
-
5
- const { NamingConvention } =
6
- (typiaUtils as { default?: typeof typiaUtils }).default ?? typiaUtils;
7
-
8
- export namespace TypeLiteralFactory {
9
- export const generate = (value: any): ts.TypeNode =>
10
- typeof value === "boolean"
11
- ? generateBoolean(value)
12
- : typeof value === "number"
13
- ? generateNumber(value)
14
- : typeof value === "string"
15
- ? generatestring(value)
16
- : typeof value === "object"
17
- ? value === null
18
- ? generateNull()
19
- : Array.isArray(value)
20
- ? generateTuple(value)
21
- : generateObject(value)
22
- : TypeScriptFactory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
23
-
24
- const generatestring = (str: string) =>
25
- TypeScriptFactory.createLiteralTypeNode(
26
- TypeScriptFactory.createStringLiteral(str),
27
- );
28
-
29
- const generateNumber = (num: number) =>
30
- TypeScriptFactory.createLiteralTypeNode(
31
- num < 0
32
- ? TypeScriptFactory.createPrefixUnaryExpression(
33
- ts.SyntaxKind.MinusToken,
34
- TypeScriptFactory.createNumericLiteral(-num),
35
- )
36
- : TypeScriptFactory.createNumericLiteral(num),
37
- );
38
-
39
- const generateBoolean = (bool: boolean) =>
40
- TypeScriptFactory.createLiteralTypeNode(
41
- bool ? TypeScriptFactory.createTrue() : TypeScriptFactory.createFalse(),
42
- );
43
-
44
- const generateNull = () =>
45
- TypeScriptFactory.createLiteralTypeNode(TypeScriptFactory.createNull());
46
-
47
- const generateTuple = (items: any[]) =>
48
- TypeScriptFactory.createTupleTypeNode(items.map(generate));
49
-
50
- const generateObject = (obj: object) =>
51
- TypeScriptFactory.createTypeLiteralNode(
52
- Object.entries(obj).map(([key, value]) =>
53
- TypeScriptFactory.createPropertySignature(
54
- undefined,
55
- NamingConvention.variable(key)
56
- ? TypeScriptFactory.createIdentifier(key)
57
- : TypeScriptFactory.createStringLiteral(key),
58
- undefined,
59
- generate(value),
60
- ),
61
- ),
62
- );
63
- }
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import * as typiaUtils from "@typia/utils";
3
+ import ts from "../internal/ts";
4
+
5
+ const { NamingConvention } =
6
+ (typiaUtils as { default?: typeof typiaUtils }).default ?? typiaUtils;
7
+
8
+ export namespace TypeLiteralFactory {
9
+ export const generate = (value: any): ts.TypeNode =>
10
+ typeof value === "boolean"
11
+ ? generateBoolean(value)
12
+ : typeof value === "number"
13
+ ? generateNumber(value)
14
+ : typeof value === "string"
15
+ ? generatestring(value)
16
+ : typeof value === "object"
17
+ ? value === null
18
+ ? generateNull()
19
+ : Array.isArray(value)
20
+ ? generateTuple(value)
21
+ : generateObject(value)
22
+ : TypeScriptFactory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
23
+
24
+ const generatestring = (str: string) =>
25
+ TypeScriptFactory.createLiteralTypeNode(
26
+ TypeScriptFactory.createStringLiteral(str),
27
+ );
28
+
29
+ const generateNumber = (num: number) =>
30
+ TypeScriptFactory.createLiteralTypeNode(
31
+ num < 0
32
+ ? TypeScriptFactory.createPrefixUnaryExpression(
33
+ ts.SyntaxKind.MinusToken,
34
+ TypeScriptFactory.createNumericLiteral(-num),
35
+ )
36
+ : TypeScriptFactory.createNumericLiteral(num),
37
+ );
38
+
39
+ const generateBoolean = (bool: boolean) =>
40
+ TypeScriptFactory.createLiteralTypeNode(
41
+ bool ? TypeScriptFactory.createTrue() : TypeScriptFactory.createFalse(),
42
+ );
43
+
44
+ const generateNull = () =>
45
+ TypeScriptFactory.createLiteralTypeNode(TypeScriptFactory.createNull());
46
+
47
+ const generateTuple = (items: any[]) =>
48
+ TypeScriptFactory.createTupleTypeNode(items.map(generate));
49
+
50
+ const generateObject = (obj: object) =>
51
+ TypeScriptFactory.createTypeLiteralNode(
52
+ Object.entries(obj).map(([key, value]) =>
53
+ TypeScriptFactory.createPropertySignature(
54
+ undefined,
55
+ NamingConvention.variable(key)
56
+ ? TypeScriptFactory.createIdentifier(key)
57
+ : TypeScriptFactory.createStringLiteral(key),
58
+ undefined,
59
+ generate(value),
60
+ ),
61
+ ),
62
+ );
63
+ }
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";
@@ -1,94 +1,94 @@
1
- // Compatibility shim that replaces `import ts from "./ts"`. The values
2
- // (`ts.factory`, `ts.SyntaxKind`, `ts.NodeFlags`) are routed to @nestia/factory
3
- // so the migration generators run without a `typescript` dependency, while the
4
- // type aliases (`ts.Expression`, `ts.ParameterDeclaration`, …) collapse to the
5
- // shared @nestia/factory `Node` so existing annotations type-check unchanged.
6
- //
7
- // Every alias is intentionally `Node`; the migrate package treats AST nodes as
8
- // opaque tokens it composes and prints — it never inspects them with
9
- // TypeScript-Compiler-API guards that would need the original brands.
10
-
11
- import {
12
- NodeFlags,
13
- SyntaxKind,
14
- TypeScriptFactory,
15
- type Node,
16
- } from "@nestia/factory";
17
-
18
- interface MutableEmitNode {
19
- leadingComments?: Array<{
20
- kind: number;
21
- text: string;
22
- hasTrailingNewLine?: boolean;
23
- }>;
24
- }
25
-
26
- interface TsValue {
27
- factory: typeof TypeScriptFactory;
28
- NodeFlags: typeof NodeFlags;
29
- SyntaxKind: typeof SyntaxKind;
30
- addSyntheticLeadingComment(
31
- node: Node,
32
- kind: number,
33
- text: string,
34
- hasTrailingNewLine?: boolean,
35
- ): Node;
36
- isUnionTypeNode(node: Node | undefined): node is Node;
37
- isTypeReferenceNode(node: Node | undefined): node is Node;
38
- isIdentifier(node: Node | undefined): node is Node;
39
- }
40
-
41
- const ts: TsValue = {
42
- factory: TypeScriptFactory,
43
- NodeFlags,
44
- SyntaxKind,
45
- // Pushes a synthetic leading comment onto the node's emit metadata, matching
46
- // the surface of the TypeScript-Compiler-API helper of the same name. The
47
- // @nestia/factory printer reads `emitNode.leadingComments` and emits them
48
- // before the node body.
49
- addSyntheticLeadingComment: (
50
- node: Node,
51
- kind: number,
52
- text: string,
53
- hasTrailingNewLine?: boolean,
54
- ): Node => {
55
- const mutable = node as Node & { emitNode?: MutableEmitNode };
56
- const emitNode = (mutable.emitNode ??= {});
57
- (emitNode.leadingComments ??= []).push({
58
- kind,
59
- text,
60
- hasTrailingNewLine,
61
- });
62
- return node;
63
- },
64
- isUnionTypeNode: (node: Node | undefined): node is Node =>
65
- !!node && node.kind === SyntaxKind.UnionType,
66
- isTypeReferenceNode: (node: Node | undefined): node is Node =>
67
- !!node && node.kind === SyntaxKind.TypeReference,
68
- isIdentifier: (node: Node | undefined): node is Node =>
69
- !!node && node.kind === SyntaxKind.Identifier,
70
- };
71
-
72
- type _Node = Node;
73
-
74
- declare namespace ts {
75
- export type Node = _Node;
76
- export type CallExpression = Node;
77
- export type ConciseBody = Node;
78
- export type Decorator = Node;
79
- export type Expression = Node;
80
- export type FunctionDeclaration = Node;
81
- export type Identifier = Node;
82
- export type KeywordTypeNode = Node;
83
- export type MethodDeclaration = Node;
84
- export type ModuleDeclaration = Node;
85
- export type ParameterDeclaration = Node;
86
- export type Statement = Node;
87
- export type TypeAliasDeclaration = Node;
88
- export type TypeNode = Node;
89
- export type TypeReferenceNode = Node;
90
- export type UnionTypeNode = Node;
91
- export type VariableStatement = Node;
92
- }
93
-
94
- export default ts;
1
+ // Compatibility shim that replaces `import ts from "./ts"`. The values
2
+ // (`ts.factory`, `ts.SyntaxKind`, `ts.NodeFlags`) are routed to @nestia/factory
3
+ // so the migration generators run without a `typescript` dependency, while the
4
+ // type aliases (`ts.Expression`, `ts.ParameterDeclaration`, …) collapse to the
5
+ // shared @nestia/factory `Node` so existing annotations type-check unchanged.
6
+ //
7
+ // Every alias is intentionally `Node`; the migrate package treats AST nodes as
8
+ // opaque tokens it composes and prints — it never inspects them with
9
+ // TypeScript-Compiler-API guards that would need the original brands.
10
+
11
+ import {
12
+ NodeFlags,
13
+ SyntaxKind,
14
+ TypeScriptFactory,
15
+ type Node,
16
+ } from "@nestia/factory";
17
+
18
+ interface MutableEmitNode {
19
+ leadingComments?: Array<{
20
+ kind: number;
21
+ text: string;
22
+ hasTrailingNewLine?: boolean;
23
+ }>;
24
+ }
25
+
26
+ interface TsValue {
27
+ factory: typeof TypeScriptFactory;
28
+ NodeFlags: typeof NodeFlags;
29
+ SyntaxKind: typeof SyntaxKind;
30
+ addSyntheticLeadingComment(
31
+ node: Node,
32
+ kind: number,
33
+ text: string,
34
+ hasTrailingNewLine?: boolean,
35
+ ): Node;
36
+ isUnionTypeNode(node: Node | undefined): node is Node;
37
+ isTypeReferenceNode(node: Node | undefined): node is Node;
38
+ isIdentifier(node: Node | undefined): node is Node;
39
+ }
40
+
41
+ const ts: TsValue = {
42
+ factory: TypeScriptFactory,
43
+ NodeFlags,
44
+ SyntaxKind,
45
+ // Pushes a synthetic leading comment onto the node's emit metadata, matching
46
+ // the surface of the TypeScript-Compiler-API helper of the same name. The
47
+ // @nestia/factory printer reads `emitNode.leadingComments` and emits them
48
+ // before the node body.
49
+ addSyntheticLeadingComment: (
50
+ node: Node,
51
+ kind: number,
52
+ text: string,
53
+ hasTrailingNewLine?: boolean,
54
+ ): Node => {
55
+ const mutable = node as Node & { emitNode?: MutableEmitNode };
56
+ const emitNode = (mutable.emitNode ??= {});
57
+ (emitNode.leadingComments ??= []).push({
58
+ kind,
59
+ text,
60
+ hasTrailingNewLine,
61
+ });
62
+ return node;
63
+ },
64
+ isUnionTypeNode: (node: Node | undefined): node is Node =>
65
+ !!node && node.kind === SyntaxKind.UnionType,
66
+ isTypeReferenceNode: (node: Node | undefined): node is Node =>
67
+ !!node && node.kind === SyntaxKind.TypeReference,
68
+ isIdentifier: (node: Node | undefined): node is Node =>
69
+ !!node && node.kind === SyntaxKind.Identifier,
70
+ };
71
+
72
+ type _Node = Node;
73
+
74
+ declare namespace ts {
75
+ export type Node = _Node;
76
+ export type CallExpression = Node;
77
+ export type ConciseBody = Node;
78
+ export type Decorator = Node;
79
+ export type Expression = Node;
80
+ export type FunctionDeclaration = Node;
81
+ export type Identifier = Node;
82
+ export type KeywordTypeNode = Node;
83
+ export type MethodDeclaration = Node;
84
+ export type ModuleDeclaration = Node;
85
+ export type ParameterDeclaration = Node;
86
+ export type Statement = Node;
87
+ export type TypeAliasDeclaration = Node;
88
+ export type TypeNode = Node;
89
+ export type TypeReferenceNode = Node;
90
+ export type UnionTypeNode = Node;
91
+ export type VariableStatement = Node;
92
+ }
93
+
94
+ 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,58 +1,58 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
3
- import ts from "../internal/ts";
4
-
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
- TypeScriptFactory.createExportDeclaration(
46
- undefined,
47
- false,
48
- TypeScriptFactory.createNamespaceExport(
49
- TypeScriptFactory.createIdentifier(child),
50
- ),
51
- TypeScriptFactory.createStringLiteral(`./${child}/index`),
52
- undefined,
53
- ),
54
- ),
55
- ...statements,
56
- ];
57
- };
58
- }
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import { IHttpMigrateRoute, OpenApi } from "@typia/interface";
3
+ import ts from "../internal/ts";
4
+
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
+ TypeScriptFactory.createExportDeclaration(
46
+ undefined,
47
+ false,
48
+ TypeScriptFactory.createNamespaceExport(
49
+ TypeScriptFactory.createIdentifier(child),
50
+ ),
51
+ TypeScriptFactory.createStringLiteral(`./${child}/index`),
52
+ undefined,
53
+ ),
54
+ ),
55
+ ...statements,
56
+ ];
57
+ };
58
+ }