@nestia/migrate 0.7.6 → 0.7.7

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 (68) hide show
  1. package/lib/MigrateApplication.js +7 -4
  2. package/lib/MigrateApplication.js.map +1 -1
  3. package/lib/analyzers/MigrateAnalyzer.d.ts +2 -3
  4. package/lib/analyzers/MigrateAnalyzer.js +1 -5
  5. package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
  6. package/lib/analyzers/MigrateControllerAnalyzer.d.ts +2 -2
  7. package/lib/analyzers/MigrateControllerAnalyzer.js +22 -13
  8. package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/MigrateMethodAnalyzer.d.ts +2 -2
  10. package/lib/analyzers/MigrateMethodAnalyzer.js +16 -16
  11. package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -1
  12. package/lib/module.d.ts +8 -0
  13. package/lib/module.js +8 -0
  14. package/lib/module.js.map +1 -1
  15. package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
  16. package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
  17. package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +2 -2
  18. package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
  19. package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
  20. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
  21. package/lib/programmers/MigrateApiProgrammer.js +3 -3
  22. package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
  23. package/lib/programmers/MigrateImportProgrammer.js +5 -5
  24. package/lib/programmers/MigrateImportProgrammer.js.map +1 -1
  25. package/lib/programmers/MigrateSchemaProgrammer.d.ts +1 -1
  26. package/lib/structures/IMigrateDto.d.ts +1 -1
  27. package/lib/structures/IMigrateProgram.d.ts +20 -4
  28. package/lib/structures/IMigrateRoute.d.ts +1 -1
  29. package/lib/structures/ISwaggerComponents.d.ts +1 -1
  30. package/lib/structures/ISwaggerRoute.d.ts +1 -1
  31. package/lib/structures/{ISwaggeSchema.js → ISwaggerSchema.js} +1 -1
  32. package/lib/structures/ISwaggerSchema.js.map +1 -0
  33. package/lib/utils/SwaggerTypeChecker.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/src/MigrateApplication.ts +54 -48
  36. package/src/analyzers/MigrateAnalyzer.ts +9 -13
  37. package/src/analyzers/MigrateControllerAnalyzer.ts +139 -122
  38. package/src/analyzers/MigrateMethodAnalyzer.ts +350 -348
  39. package/src/archivers/MigrateFileArchiver.ts +38 -38
  40. package/src/executable/bundle.ts +109 -109
  41. package/src/internal/MigrateCommander.ts +51 -51
  42. package/src/module.ts +10 -0
  43. package/src/programmers/MigrateApiFileProgrammer.ts +53 -53
  44. package/src/programmers/MigrateApiFunctionProgrammer.ts +203 -203
  45. package/src/programmers/MigrateApiNamespaceProgrammer.ts +430 -430
  46. package/src/programmers/MigrateApiProgrammer.ts +132 -132
  47. package/src/programmers/MigrateApiSimulatationProgrammer.ts +328 -328
  48. package/src/programmers/MigrateDtoProgrammer.ts +78 -78
  49. package/src/programmers/MigrateImportProgrammer.ts +114 -116
  50. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  51. package/src/programmers/MigrateNestMethodProgrammer.ts +249 -249
  52. package/src/programmers/MigrateNestModuleProgrammer.ts +62 -62
  53. package/src/programmers/MigrateNestProgrammer.ts +74 -74
  54. package/src/programmers/MigrateSchemaProgrammer.ts +257 -257
  55. package/src/structures/IMigrateDto.ts +1 -1
  56. package/src/structures/IMigrateProgram.ts +20 -4
  57. package/src/structures/IMigrateRoute.ts +46 -46
  58. package/src/structures/ISwaggerComponents.ts +1 -1
  59. package/src/structures/ISwaggerRoute.ts +1 -1
  60. package/src/utils/FilePrinter.ts +36 -36
  61. package/src/utils/SwaggerTypeChecker.ts +67 -67
  62. package/lib/IMigrateConfig.d.ts +0 -4
  63. package/lib/IMigrateConfig.js +0 -3
  64. package/lib/IMigrateConfig.js.map +0 -1
  65. package/lib/structures/ISwaggeSchema.js.map +0 -1
  66. package/src/IMigrateConfig.ts +0 -4
  67. /package/lib/structures/{ISwaggeSchema.d.ts → ISwaggerSchema.d.ts} +0 -0
  68. /package/src/structures/{ISwaggeSchema.ts → ISwaggerSchema.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { ISwaggerSchema } from "./ISwaggeSchema";
1
+ import { ISwaggerSchema } from "./ISwaggerSchema";
2
2
 
3
3
  export interface IMigrateDto {
4
4
  name: string;
@@ -1,9 +1,25 @@
1
- import { IMigrateConfig } from "../IMigrateConfig";
2
1
  import { IMigrateController } from "./IMigrateController";
2
+ import { IMigrateRoute } from "./IMigrateRoute";
3
3
  import { ISwagger } from "./ISwagger";
4
+ import { ISwaggerRoute } from "./ISwaggerRoute";
4
5
 
5
- export interface IMigrateProgram {
6
- config: IMigrateConfig;
6
+ export interface IMigrateProgram extends IMigrateProgram.IProps {
7
7
  controllers: IMigrateController[];
8
- swagger: ISwagger;
8
+ }
9
+ export namespace IMigrateProgram {
10
+ export type Dictionary = Map<ISwaggerRoute, IEntry>;
11
+ export interface IEntry {
12
+ controller: IMigrateController;
13
+ route: IMigrateRoute;
14
+ }
15
+ export interface IProps {
16
+ mode: "nest" | "sdk";
17
+ simulate: boolean;
18
+ swagger: ISwagger;
19
+ dictionary: Dictionary;
20
+ }
21
+ export interface IConfig {
22
+ mode: "nest" | "sdk";
23
+ simulate: boolean;
24
+ }
9
25
  }
@@ -1,46 +1,46 @@
1
- import { ISwaggerSchema } from "./ISwaggeSchema";
2
-
3
- export interface IMigrateRoute {
4
- name: 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
- description?: string;
15
- tags: string[];
16
- deprecated: boolean;
17
- }
18
- export namespace IMigrateRoute {
19
- export interface IParameter {
20
- key: string;
21
- schema: ISwaggerSchema;
22
- description?: string;
23
- }
24
- export interface IHeaders {
25
- key: string;
26
- schema: ISwaggerSchema;
27
- }
28
- export interface IQuery {
29
- key: string;
30
- schema: ISwaggerSchema;
31
- }
32
- export interface IBody {
33
- key: string;
34
- type:
35
- | "text/plain"
36
- | "application/json"
37
- | "application/x-www-form-urlencoded"
38
- | "multipart/form-data";
39
- schema: ISwaggerSchema;
40
- "x-nestia-encrypted"?: boolean;
41
- }
42
- export interface IException {
43
- description?: string;
44
- schema: ISwaggerSchema;
45
- }
46
- }
1
+ import { ISwaggerSchema } from "./ISwaggerSchema";
2
+
3
+ export interface IMigrateRoute {
4
+ name: 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
+ description?: string;
15
+ tags: string[];
16
+ deprecated: boolean;
17
+ }
18
+ export namespace IMigrateRoute {
19
+ export interface IParameter {
20
+ key: string;
21
+ schema: ISwaggerSchema;
22
+ description?: string;
23
+ }
24
+ export interface IHeaders {
25
+ key: string;
26
+ schema: ISwaggerSchema;
27
+ }
28
+ export interface IQuery {
29
+ key: string;
30
+ schema: ISwaggerSchema;
31
+ }
32
+ export interface IBody {
33
+ key: string;
34
+ type:
35
+ | "text/plain"
36
+ | "application/json"
37
+ | "application/x-www-form-urlencoded"
38
+ | "multipart/form-data";
39
+ schema: ISwaggerSchema;
40
+ "x-nestia-encrypted"?: boolean;
41
+ }
42
+ export interface IException {
43
+ description?: string;
44
+ schema: ISwaggerSchema;
45
+ }
46
+ }
@@ -1,4 +1,4 @@
1
- import { ISwaggerSchema } from "./ISwaggeSchema";
1
+ import { ISwaggerSchema } from "./ISwaggerSchema";
2
2
  import { ISwaggerSecurity } from "./ISwaggerSecurity";
3
3
 
4
4
  export interface ISwaggerComponents {
@@ -1,6 +1,6 @@
1
1
  import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
2
2
 
3
- import { ISwaggerSchema } from "./ISwaggeSchema";
3
+ import { ISwaggerSchema } from "./ISwaggerSchema";
4
4
 
5
5
  export interface ISwaggerRoute {
6
6
  parameters?: ISwaggerRoute.IParameter[];
@@ -1,36 +1,36 @@
1
- import ts from "typescript";
2
-
3
- export namespace FilePrinter {
4
- export const description = <Node extends ts.Node>(
5
- node: Node,
6
- comment: string,
7
- ): Node => {
8
- if (comment.length === 0) return node;
9
- ts.addSyntheticLeadingComment(
10
- node,
11
- ts.SyntaxKind.MultiLineCommentTrivia,
12
- ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
- true,
14
- );
15
- return node;
16
- };
17
-
18
- export const newLine = () =>
19
- ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
-
21
- export const write = (props: {
22
- statements: ts.Statement[];
23
- top?: string;
24
- }): string => {
25
- const script: string = ts
26
- .createPrinter()
27
- .printFile(
28
- ts.factory.createSourceFile(
29
- props.statements,
30
- ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
31
- ts.NodeFlags.None,
32
- ),
33
- );
34
- return (props.top ?? "") + script;
35
- };
36
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace FilePrinter {
4
+ export const description = <Node extends ts.Node>(
5
+ node: Node,
6
+ comment: string,
7
+ ): Node => {
8
+ if (comment.length === 0) return node;
9
+ ts.addSyntheticLeadingComment(
10
+ node,
11
+ ts.SyntaxKind.MultiLineCommentTrivia,
12
+ ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
+ true,
14
+ );
15
+ return node;
16
+ };
17
+
18
+ export const newLine = () =>
19
+ ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
+
21
+ export const write = (props: {
22
+ statements: ts.Statement[];
23
+ top?: string;
24
+ }): string => {
25
+ const script: string = ts
26
+ .createPrinter()
27
+ .printFile(
28
+ ts.factory.createSourceFile(
29
+ props.statements,
30
+ ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
31
+ ts.NodeFlags.None,
32
+ ),
33
+ );
34
+ return (props.top ?? "") + script;
35
+ };
36
+ }
@@ -1,67 +1,67 @@
1
- import { ISwaggerSchema } from "../structures/ISwaggeSchema";
2
- import { ISwaggerComponents } from "../structures/ISwaggerComponents";
3
-
4
- export namespace SwaggerSwaggerChecker {
5
- export const isAnyOf = (
6
- schema: ISwaggerSchema,
7
- ): schema is ISwaggerSchema.IAnyOf => (schema as any).anyOf !== undefined;
8
-
9
- export const isOneOf = (
10
- schema: ISwaggerSchema,
11
- ): schema is ISwaggerSchema.IOneOf => (schema as any).oneOf !== undefined;
12
-
13
- export const isNullOnly = (
14
- schema: ISwaggerSchema,
15
- ): schema is ISwaggerSchema.INullOnly => (schema as any).type === "null";
16
-
17
- export const isBoolean = (
18
- schema: ISwaggerSchema,
19
- ): schema is ISwaggerSchema.IBoolean => (schema as any).type === "boolean";
20
-
21
- export const isInteger = (
22
- schema: ISwaggerSchema,
23
- ): schema is ISwaggerSchema.IInteger => (schema as any).type === "integer";
24
-
25
- export const isNumber = (
26
- schema: ISwaggerSchema,
27
- ): schema is ISwaggerSchema.INumber => (schema as any).type === "number";
28
-
29
- export const isString = (
30
- schema: ISwaggerSchema,
31
- ): schema is ISwaggerSchema.IString => (schema as any).type === "string";
32
-
33
- export const isArray = (
34
- schema: ISwaggerSchema,
35
- ): schema is ISwaggerSchema.IArray => (schema as any).type === "array";
36
-
37
- export const isObject = (
38
- schema: ISwaggerSchema,
39
- ): schema is ISwaggerSchema.IObject => (schema as any).type === "object";
40
-
41
- export const isReference = (
42
- schema: ISwaggerSchema,
43
- ): schema is ISwaggerSchema.IReference => (schema as any).$ref !== undefined;
44
-
45
- export const isUnknown = (
46
- schema: ISwaggerSchema,
47
- ): schema is ISwaggerSchema.IUnknown =>
48
- (schema as any).type === undefined &&
49
- !isAnyOf(schema) &&
50
- !isOneOf(schema) &&
51
- !isReference(schema);
52
-
53
- export const isNullable =
54
- (components: ISwaggerComponents) =>
55
- (schema: ISwaggerSchema): boolean => {
56
- if (SwaggerSwaggerChecker.isAnyOf(schema))
57
- return schema.anyOf.some(isNullable(components));
58
- else if (SwaggerSwaggerChecker.isOneOf(schema))
59
- return schema.oneOf.some(isNullable(components));
60
- else if (SwaggerSwaggerChecker.isReference(schema)) {
61
- const $id = schema.$ref.replace("#/components/schemas/", "");
62
- const target = (components.schemas ?? {})[$id];
63
- return target === undefined ? false : isNullable(components)(target);
64
- }
65
- return (schema as ISwaggerSchema.IString).nullable === true;
66
- };
67
- }
1
+ import { ISwaggerSchema } from "../structures/ISwaggerSchema";
2
+ import { ISwaggerComponents } from "../structures/ISwaggerComponents";
3
+
4
+ export namespace SwaggerSwaggerChecker {
5
+ export const isAnyOf = (
6
+ schema: ISwaggerSchema,
7
+ ): schema is ISwaggerSchema.IAnyOf => (schema as any).anyOf !== undefined;
8
+
9
+ export const isOneOf = (
10
+ schema: ISwaggerSchema,
11
+ ): schema is ISwaggerSchema.IOneOf => (schema as any).oneOf !== undefined;
12
+
13
+ export const isNullOnly = (
14
+ schema: ISwaggerSchema,
15
+ ): schema is ISwaggerSchema.INullOnly => (schema as any).type === "null";
16
+
17
+ export const isBoolean = (
18
+ schema: ISwaggerSchema,
19
+ ): schema is ISwaggerSchema.IBoolean => (schema as any).type === "boolean";
20
+
21
+ export const isInteger = (
22
+ schema: ISwaggerSchema,
23
+ ): schema is ISwaggerSchema.IInteger => (schema as any).type === "integer";
24
+
25
+ export const isNumber = (
26
+ schema: ISwaggerSchema,
27
+ ): schema is ISwaggerSchema.INumber => (schema as any).type === "number";
28
+
29
+ export const isString = (
30
+ schema: ISwaggerSchema,
31
+ ): schema is ISwaggerSchema.IString => (schema as any).type === "string";
32
+
33
+ export const isArray = (
34
+ schema: ISwaggerSchema,
35
+ ): schema is ISwaggerSchema.IArray => (schema as any).type === "array";
36
+
37
+ export const isObject = (
38
+ schema: ISwaggerSchema,
39
+ ): schema is ISwaggerSchema.IObject => (schema as any).type === "object";
40
+
41
+ export const isReference = (
42
+ schema: ISwaggerSchema,
43
+ ): schema is ISwaggerSchema.IReference => (schema as any).$ref !== undefined;
44
+
45
+ export const isUnknown = (
46
+ schema: ISwaggerSchema,
47
+ ): schema is ISwaggerSchema.IUnknown =>
48
+ (schema as any).type === undefined &&
49
+ !isAnyOf(schema) &&
50
+ !isOneOf(schema) &&
51
+ !isReference(schema);
52
+
53
+ export const isNullable =
54
+ (components: ISwaggerComponents) =>
55
+ (schema: ISwaggerSchema): boolean => {
56
+ if (SwaggerSwaggerChecker.isAnyOf(schema))
57
+ return schema.anyOf.some(isNullable(components));
58
+ else if (SwaggerSwaggerChecker.isOneOf(schema))
59
+ return schema.oneOf.some(isNullable(components));
60
+ else if (SwaggerSwaggerChecker.isReference(schema)) {
61
+ const $id = schema.$ref.replace("#/components/schemas/", "");
62
+ const target = (components.schemas ?? {})[$id];
63
+ return target === undefined ? false : isNullable(components)(target);
64
+ }
65
+ return (schema as ISwaggerSchema.IString).nullable === true;
66
+ };
67
+ }
@@ -1,4 +0,0 @@
1
- export interface IMigrateConfig {
2
- mode: "nest" | "sdk";
3
- simulate: boolean;
4
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IMigrateConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IMigrateConfig.js","sourceRoot":"","sources":["../src/IMigrateConfig.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ISwaggeSchema.js","sourceRoot":"","sources":["../../src/structures/ISwaggeSchema.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- export interface IMigrateConfig {
2
- mode: "nest" | "sdk";
3
- simulate: boolean;
4
- }