@nestia/migrate 0.7.6 → 0.7.8

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 (76) 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/bundles/NEST_TEMPLATE.js +2 -2
  13. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  14. package/lib/internal/MigrateCommander.js +12 -1
  15. package/lib/internal/MigrateCommander.js.map +1 -1
  16. package/lib/module.d.ts +8 -0
  17. package/lib/module.js +8 -0
  18. package/lib/module.js.map +1 -1
  19. package/lib/programmers/MigrateApiFileProgrammer.d.ts +2 -2
  20. package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -1
  21. package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +2 -2
  22. package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -1
  23. package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +2 -2
  24. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
  25. package/lib/programmers/MigrateApiProgrammer.js +3 -3
  26. package/lib/programmers/MigrateApiProgrammer.js.map +1 -1
  27. package/lib/programmers/MigrateImportProgrammer.js +5 -5
  28. package/lib/programmers/MigrateImportProgrammer.js.map +1 -1
  29. package/lib/programmers/MigrateNestModuleProgrammer.js +1 -1
  30. package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -1
  31. package/lib/programmers/MigrateSchemaProgrammer.d.ts +1 -1
  32. package/lib/structures/IMigrateDto.d.ts +1 -1
  33. package/lib/structures/IMigrateProgram.d.ts +20 -4
  34. package/lib/structures/IMigrateRoute.d.ts +1 -1
  35. package/lib/structures/ISwaggerComponents.d.ts +1 -1
  36. package/lib/structures/ISwaggerRoute.d.ts +1 -1
  37. package/lib/structures/{ISwaggeSchema.js → ISwaggerSchema.js} +1 -1
  38. package/lib/structures/ISwaggerSchema.js.map +1 -0
  39. package/lib/utils/SwaggerTypeChecker.d.ts +1 -1
  40. package/package.json +70 -68
  41. package/src/MigrateApplication.ts +54 -48
  42. package/src/analyzers/MigrateAnalyzer.ts +9 -13
  43. package/src/analyzers/MigrateControllerAnalyzer.ts +139 -122
  44. package/src/analyzers/MigrateMethodAnalyzer.ts +350 -348
  45. package/src/archivers/MigrateFileArchiver.ts +38 -38
  46. package/src/bundles/NEST_TEMPLATE.ts +2 -2
  47. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  48. package/src/executable/bundle.ts +109 -109
  49. package/src/internal/MigrateCommander.ts +62 -51
  50. package/src/module.ts +14 -4
  51. package/src/programmers/MigrateApiFileProgrammer.ts +53 -53
  52. package/src/programmers/MigrateApiFunctionProgrammer.ts +203 -203
  53. package/src/programmers/MigrateApiNamespaceProgrammer.ts +430 -430
  54. package/src/programmers/MigrateApiProgrammer.ts +132 -132
  55. package/src/programmers/MigrateApiSimulatationProgrammer.ts +328 -328
  56. package/src/programmers/MigrateDtoProgrammer.ts +78 -78
  57. package/src/programmers/MigrateImportProgrammer.ts +114 -116
  58. package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
  59. package/src/programmers/MigrateNestMethodProgrammer.ts +249 -249
  60. package/src/programmers/MigrateNestModuleProgrammer.ts +63 -62
  61. package/src/programmers/MigrateNestProgrammer.ts +74 -74
  62. package/src/programmers/MigrateSchemaProgrammer.ts +257 -257
  63. package/src/structures/IMigrateDto.ts +8 -8
  64. package/src/structures/IMigrateProgram.ts +25 -9
  65. package/src/structures/IMigrateRoute.ts +46 -46
  66. package/src/structures/ISwaggerComponents.ts +7 -7
  67. package/src/structures/ISwaggerRoute.ts +55 -55
  68. package/src/structures/{ISwaggeSchema.ts → ISwaggerSchema.ts} +90 -90
  69. package/src/utils/FilePrinter.ts +36 -36
  70. package/src/utils/SwaggerTypeChecker.ts +67 -67
  71. package/lib/IMigrateConfig.d.ts +0 -4
  72. package/lib/IMigrateConfig.js +0 -3
  73. package/lib/IMigrateConfig.js.map +0 -1
  74. package/lib/structures/ISwaggeSchema.js.map +0 -1
  75. package/src/IMigrateConfig.ts +0 -4
  76. /package/lib/structures/{ISwaggeSchema.d.ts → ISwaggerSchema.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
- import { ISwaggerSchema } from "./ISwaggeSchema";
2
-
3
- export interface IMigrateDto {
4
- name: string;
5
- location: string;
6
- schema: ISwaggerSchema | null;
7
- children: IMigrateDto[];
8
- }
1
+ import { ISwaggerSchema } from "./ISwaggerSchema";
2
+
3
+ export interface IMigrateDto {
4
+ name: string;
5
+ location: string;
6
+ schema: ISwaggerSchema | null;
7
+ children: IMigrateDto[];
8
+ }
@@ -1,9 +1,25 @@
1
- import { IMigrateConfig } from "../IMigrateConfig";
2
- import { IMigrateController } from "./IMigrateController";
3
- import { ISwagger } from "./ISwagger";
4
-
5
- export interface IMigrateProgram {
6
- config: IMigrateConfig;
7
- controllers: IMigrateController[];
8
- swagger: ISwagger;
9
- }
1
+ import { IMigrateController } from "./IMigrateController";
2
+ import { IMigrateRoute } from "./IMigrateRoute";
3
+ import { ISwagger } from "./ISwagger";
4
+ import { ISwaggerRoute } from "./ISwaggerRoute";
5
+
6
+ export interface IMigrateProgram extends IMigrateProgram.IProps {
7
+ controllers: IMigrateController[];
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
+ }
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,7 +1,7 @@
1
- import { ISwaggerSchema } from "./ISwaggeSchema";
2
- import { ISwaggerSecurity } from "./ISwaggerSecurity";
3
-
4
- export interface ISwaggerComponents {
5
- schemas?: Record<string, ISwaggerSchema>;
6
- securitySchemes?: Record<string, ISwaggerSecurity>;
7
- }
1
+ import { ISwaggerSchema } from "./ISwaggerSchema";
2
+ import { ISwaggerSecurity } from "./ISwaggerSecurity";
3
+
4
+ export interface ISwaggerComponents {
5
+ schemas?: Record<string, ISwaggerSchema>;
6
+ securitySchemes?: Record<string, ISwaggerSecurity>;
7
+ }
@@ -1,55 +1,55 @@
1
- import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
2
-
3
- import { ISwaggerSchema } from "./ISwaggeSchema";
4
-
5
- export interface ISwaggerRoute {
6
- parameters?: ISwaggerRoute.IParameter[];
7
- requestBody?: ISwaggerRoute.IRequestBody;
8
- responses?: ISwaggerRoute.IResponseBody;
9
- summary?: string;
10
- description?: string;
11
- deprecated?: boolean;
12
- security?: Record<string, string[]>[];
13
- tags?: string[];
14
- "x-nestia-jsDocTags"?: IJsDocTagInfo[];
15
- }
16
- export namespace ISwaggerRoute {
17
- export interface IParameter {
18
- name?: string;
19
- in: "path" | "query" | "header" | "cookie";
20
- schema: ISwaggerSchema;
21
- required?: boolean;
22
- description?: string;
23
- }
24
- export interface IRequestBody {
25
- description?: string;
26
- content: IContent;
27
- required?: boolean;
28
- "x-nestia-encrypted"?: boolean;
29
- }
30
- export type IResponseBody = Record<
31
- string,
32
- {
33
- description?: string;
34
- content?: IContent;
35
- "x-nestia-encrypted"?: boolean;
36
- }
37
- >;
38
- export interface IContent {
39
- "text/plain"?: {
40
- schema: ISwaggerSchema;
41
- };
42
- "application/json"?: {
43
- schema: ISwaggerSchema;
44
- };
45
- "application/x-www-form-urlencoded"?: {
46
- schema: ISwaggerSchema;
47
- };
48
- "multipart/form-data"?: {
49
- schema: ISwaggerSchema;
50
- };
51
- "*/*"?: {
52
- schema: ISwaggerSchema;
53
- };
54
- }
55
- }
1
+ import { IJsDocTagInfo } from "typia/lib/schemas/metadata/IJsDocTagInfo";
2
+
3
+ import { ISwaggerSchema } from "./ISwaggerSchema";
4
+
5
+ export interface ISwaggerRoute {
6
+ parameters?: ISwaggerRoute.IParameter[];
7
+ requestBody?: ISwaggerRoute.IRequestBody;
8
+ responses?: ISwaggerRoute.IResponseBody;
9
+ summary?: string;
10
+ description?: string;
11
+ deprecated?: boolean;
12
+ security?: Record<string, string[]>[];
13
+ tags?: string[];
14
+ "x-nestia-jsDocTags"?: IJsDocTagInfo[];
15
+ }
16
+ export namespace ISwaggerRoute {
17
+ export interface IParameter {
18
+ name?: string;
19
+ in: "path" | "query" | "header" | "cookie";
20
+ schema: ISwaggerSchema;
21
+ required?: boolean;
22
+ description?: string;
23
+ }
24
+ export interface IRequestBody {
25
+ description?: string;
26
+ content: IContent;
27
+ required?: boolean;
28
+ "x-nestia-encrypted"?: boolean;
29
+ }
30
+ export type IResponseBody = Record<
31
+ string,
32
+ {
33
+ description?: string;
34
+ content?: IContent;
35
+ "x-nestia-encrypted"?: boolean;
36
+ }
37
+ >;
38
+ export interface IContent {
39
+ "text/plain"?: {
40
+ schema: ISwaggerSchema;
41
+ };
42
+ "application/json"?: {
43
+ schema: ISwaggerSchema;
44
+ };
45
+ "application/x-www-form-urlencoded"?: {
46
+ schema: ISwaggerSchema;
47
+ };
48
+ "multipart/form-data"?: {
49
+ schema: ISwaggerSchema;
50
+ };
51
+ "*/*"?: {
52
+ schema: ISwaggerSchema;
53
+ };
54
+ }
55
+ }
@@ -1,90 +1,90 @@
1
- export type ISwaggerSchema =
2
- | ISwaggerSchema.IUnknown
3
- | ISwaggerSchema.INullOnly
4
- | ISwaggerSchema.IAnyOf
5
- | ISwaggerSchema.IOneOf
6
- | ISwaggerSchema.IBoolean
7
- | ISwaggerSchema.IInteger
8
- | ISwaggerSchema.INumber
9
- | ISwaggerSchema.IString
10
- | ISwaggerSchema.IArray
11
- | ISwaggerSchema.IObject
12
- | ISwaggerSchema.IReference;
13
- export namespace ISwaggerSchema {
14
- export interface IUnknown extends IAttribute {
15
- type?: undefined;
16
- }
17
- export interface INullOnly extends IAttribute {
18
- type: "null";
19
- }
20
-
21
- export interface IAnyOf extends IAttribute {
22
- anyOf: ISwaggerSchema[];
23
- }
24
- export interface IOneOf extends IAttribute {
25
- oneOf: ISwaggerSchema[];
26
- }
27
-
28
- export interface IBoolean extends ISignificant<"boolean"> {
29
- default?: boolean;
30
- enum?: boolean[];
31
- }
32
- export interface IInteger extends ISignificant<"integer"> {
33
- /** @type int */ default?: number;
34
- /** @type int */ enum?: number[];
35
- /** @type int */ minimum?: number;
36
- /** @type int */ maximum?: number;
37
- /** @type int */ exclusiveMinimum?: boolean;
38
- /** @type int */ exclusiveMaximum?: boolean;
39
- /** @type uint */ multipleOf?: number;
40
- }
41
- export interface INumber extends ISignificant<"number"> {
42
- default?: number;
43
- enum?: number[];
44
- minimum?: number;
45
- maximum?: number;
46
- exclusiveMinimum?: boolean;
47
- exclusiveMaximum?: boolean;
48
- multipleOf?: number;
49
- }
50
- export interface IString extends ISignificant<"string"> {
51
- default?: string;
52
- enum?: string[];
53
- format?: string;
54
- pattern?: string;
55
- /** @type uint */ minLength?: number;
56
- /** @type uint */ maxLength?: number;
57
- }
58
-
59
- export interface IArray extends ISignificant<"array"> {
60
- items: ISwaggerSchema;
61
- /** @type uint */ minItems?: number;
62
- /** @type uint */ maxItems?: number;
63
- "x-typia-tuple"?: ITuple;
64
- }
65
- export interface ITuple extends ISignificant<"array"> {
66
- items: ISwaggerSchema[];
67
- }
68
- export interface IObject extends ISignificant<"object"> {
69
- properties?: Record<string, ISwaggerSchema>;
70
- required?: string[];
71
- additionalProperties?: ISwaggerSchema | boolean;
72
- "x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
73
- }
74
-
75
- export interface IReference extends IAttribute {
76
- $ref: string;
77
- }
78
-
79
- interface ISignificant<Type extends string> extends IAttribute {
80
- type: Type;
81
- nullable?: boolean;
82
- }
83
- interface IAttribute {
84
- title?: string;
85
- description?: string;
86
- deprecated?: boolean;
87
- "x-typia-optional"?: boolean;
88
- "x-typia-rest"?: boolean;
89
- }
90
- }
1
+ export type ISwaggerSchema =
2
+ | ISwaggerSchema.IUnknown
3
+ | ISwaggerSchema.INullOnly
4
+ | ISwaggerSchema.IAnyOf
5
+ | ISwaggerSchema.IOneOf
6
+ | ISwaggerSchema.IBoolean
7
+ | ISwaggerSchema.IInteger
8
+ | ISwaggerSchema.INumber
9
+ | ISwaggerSchema.IString
10
+ | ISwaggerSchema.IArray
11
+ | ISwaggerSchema.IObject
12
+ | ISwaggerSchema.IReference;
13
+ export namespace ISwaggerSchema {
14
+ export interface IUnknown extends IAttribute {
15
+ type?: undefined;
16
+ }
17
+ export interface INullOnly extends IAttribute {
18
+ type: "null";
19
+ }
20
+
21
+ export interface IAnyOf extends IAttribute {
22
+ anyOf: ISwaggerSchema[];
23
+ }
24
+ export interface IOneOf extends IAttribute {
25
+ oneOf: ISwaggerSchema[];
26
+ }
27
+
28
+ export interface IBoolean extends ISignificant<"boolean"> {
29
+ default?: boolean;
30
+ enum?: boolean[];
31
+ }
32
+ export interface IInteger extends ISignificant<"integer"> {
33
+ /** @type int */ default?: number;
34
+ /** @type int */ enum?: number[];
35
+ /** @type int */ minimum?: number;
36
+ /** @type int */ maximum?: number;
37
+ /** @type int */ exclusiveMinimum?: boolean;
38
+ /** @type int */ exclusiveMaximum?: boolean;
39
+ /** @type uint */ multipleOf?: number;
40
+ }
41
+ export interface INumber extends ISignificant<"number"> {
42
+ default?: number;
43
+ enum?: number[];
44
+ minimum?: number;
45
+ maximum?: number;
46
+ exclusiveMinimum?: boolean;
47
+ exclusiveMaximum?: boolean;
48
+ multipleOf?: number;
49
+ }
50
+ export interface IString extends ISignificant<"string"> {
51
+ default?: string;
52
+ enum?: string[];
53
+ format?: string;
54
+ pattern?: string;
55
+ /** @type uint */ minLength?: number;
56
+ /** @type uint */ maxLength?: number;
57
+ }
58
+
59
+ export interface IArray extends ISignificant<"array"> {
60
+ items: ISwaggerSchema;
61
+ /** @type uint */ minItems?: number;
62
+ /** @type uint */ maxItems?: number;
63
+ "x-typia-tuple"?: ITuple;
64
+ }
65
+ export interface ITuple extends ISignificant<"array"> {
66
+ items: ISwaggerSchema[];
67
+ }
68
+ export interface IObject extends ISignificant<"object"> {
69
+ properties?: Record<string, ISwaggerSchema>;
70
+ required?: string[];
71
+ additionalProperties?: ISwaggerSchema | boolean;
72
+ "x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
73
+ }
74
+
75
+ export interface IReference extends IAttribute {
76
+ $ref: string;
77
+ }
78
+
79
+ interface ISignificant<Type extends string> extends IAttribute {
80
+ type: Type;
81
+ nullable?: boolean;
82
+ }
83
+ interface IAttribute {
84
+ title?: string;
85
+ description?: string;
86
+ deprecated?: boolean;
87
+ "x-typia-optional"?: boolean;
88
+ "x-typia-rest"?: boolean;
89
+ }
90
+ }
@@ -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