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

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,198 +1,198 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import { IdentifierFactory, StatementFactory } from "@nestia/factory";
3
- import { IHttpMigrateRoute } from "@typia/interface";
4
- import ts from "../internal/ts";
5
-
6
- import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
7
- import { FilePrinter } from "../utils/FilePrinter";
8
- import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
-
11
- export namespace NestiaMigrateApiStartProgrammer {
12
- export const write = (
13
- context: INestiaMigrateContext,
14
- ): Record<string, string> => {
15
- const importer: NestiaMigrateImportProgrammer =
16
- new NestiaMigrateImportProgrammer();
17
- const main: ts.VariableStatement = writeMain(
18
- context,
19
- importer,
20
- pick(context.application.routes),
21
- );
22
- const statements: ts.Statement[] = [
23
- ...importer.toStatements(
24
- (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
25
- ),
26
- FilePrinter.newLine(),
27
- TypeScriptFactory.createImportDeclaration(
28
- undefined,
29
- TypeScriptFactory.createImportClause(
30
- false,
31
- undefined,
32
- TypeScriptFactory.createNamedImports([
33
- TypeScriptFactory.createImportSpecifier(
34
- false,
35
- undefined,
36
- TypeScriptFactory.createIdentifier("TestGlobal"),
37
- ),
38
- ]),
39
- ),
40
- TypeScriptFactory.createStringLiteral("./TestGlobal"),
41
- undefined,
42
- ),
43
- FilePrinter.newLine(),
44
- main,
45
- TypeScriptFactory.createExpressionStatement(writeStarter()),
46
- ];
47
- return {
48
- "test/start.ts": FilePrinter.write({ statements }),
49
- };
50
- };
51
-
52
- const writeMain = (
53
- ctx: INestiaMigrateContext,
54
- importer: NestiaMigrateImportProgrammer,
55
- route: IHttpMigrateRoute,
56
- ): ts.VariableStatement =>
57
- StatementFactory.constant({
58
- name: "main",
59
- value: TypeScriptFactory.createArrowFunction(
60
- [TypeScriptFactory.createToken(ts.SyntaxKind.AsyncKeyword)],
61
- undefined,
62
- [],
63
- undefined,
64
- undefined,
65
- TypeScriptFactory.createBlock(
66
- [
67
- writeConnection(ctx, importer),
68
- ...NestiaMigrateE2eFunctionProgrammer.writeBody({
69
- config: ctx.config,
70
- components: ctx.application.document().components,
71
- importer,
72
- route,
73
- }),
74
- ],
75
- true,
76
- ),
77
- ),
78
- });
79
-
80
- const writeConnection = (
81
- ctx: INestiaMigrateContext,
82
- importer: NestiaMigrateImportProgrammer,
83
- ): ts.VariableStatement =>
84
- TypeScriptFactory.createVariableStatement(
85
- undefined,
86
- TypeScriptFactory.createVariableDeclarationList(
87
- [
88
- TypeScriptFactory.createVariableDeclaration(
89
- "connection",
90
- undefined,
91
- TypeScriptFactory.createTypeReferenceNode(
92
- TypeScriptFactory.createQualifiedName(
93
- TypeScriptFactory.createIdentifier(
94
- importer.external({
95
- type: "default",
96
- library: "@ORGANIZATION/PROJECT-api",
97
- name: "api",
98
- }),
99
- ),
100
- TypeScriptFactory.createIdentifier("IConnection"),
101
- ),
102
- ),
103
- TypeScriptFactory.createObjectLiteralExpression(
104
- [
105
- TypeScriptFactory.createSpreadAssignment(
106
- TypeScriptFactory.createCallExpression(
107
- TypeScriptFactory.createPropertyAccessExpression(
108
- TypeScriptFactory.createIdentifier("TestGlobal"),
109
- "connection",
110
- ),
111
- undefined,
112
- undefined,
113
- ),
114
- ),
115
- ...(ctx.application.document().servers?.[0]?.url?.length
116
- ? [
117
- TypeScriptFactory.createPropertyAssignment(
118
- "host",
119
- TypeScriptFactory.createStringLiteral(
120
- ctx.application.document().servers![0]!.url,
121
- ),
122
- ),
123
- ]
124
- : []),
125
- ...(ctx.config.simulate === true
126
- ? [
127
- TypeScriptFactory.createPropertyAssignment(
128
- "simulate",
129
- TypeScriptFactory.createTrue(),
130
- ),
131
- ]
132
- : []),
133
- ],
134
- true,
135
- ),
136
- ),
137
- ],
138
- ts.NodeFlags.Const,
139
- ),
140
- );
141
-
142
- const writeStarter = (): ts.CallExpression =>
143
- TypeScriptFactory.createCallExpression(
144
- TypeScriptFactory.createPropertyAccessExpression(
145
- TypeScriptFactory.createCallExpression(
146
- TypeScriptFactory.createIdentifier("main"),
147
- undefined,
148
- undefined,
149
- ),
150
- "catch",
151
- ),
152
- undefined,
153
- [
154
- TypeScriptFactory.createArrowFunction(
155
- undefined,
156
- undefined,
157
- [IdentifierFactory.parameter("exp")],
158
- undefined,
159
- undefined,
160
- TypeScriptFactory.createBlock(
161
- [
162
- TypeScriptFactory.createExpressionStatement(
163
- TypeScriptFactory.createCallExpression(
164
- TypeScriptFactory.createPropertyAccessExpression(
165
- TypeScriptFactory.createIdentifier("console"),
166
- "log",
167
- ),
168
- undefined,
169
- [TypeScriptFactory.createIdentifier("exp")],
170
- ),
171
- ),
172
- TypeScriptFactory.createExpressionStatement(
173
- TypeScriptFactory.createCallExpression(
174
- TypeScriptFactory.createPropertyAccessExpression(
175
- TypeScriptFactory.createIdentifier("process"),
176
- "exit",
177
- ),
178
- undefined,
179
- [
180
- TypeScriptFactory.createPrefixMinus(
181
- TypeScriptFactory.createNumericLiteral("1"),
182
- ),
183
- ],
184
- ),
185
- ),
186
- ],
187
- true,
188
- ),
189
- ),
190
- ],
191
- );
192
- }
193
-
194
- const pick = <T>(array: T[]): T => {
195
- const rand: number = Math.random() * array.length;
196
- const index: number = Math.min(array.length - 1, Math.floor(rand));
197
- return array[index]!;
198
- };
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import { IdentifierFactory, StatementFactory } from "@nestia/factory";
3
+ import { IHttpMigrateRoute } from "@typia/interface";
4
+ import ts from "../internal/ts";
5
+
6
+ import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
7
+ import { FilePrinter } from "../utils/FilePrinter";
8
+ import { NestiaMigrateE2eFunctionProgrammer } from "./NestiaMigrateE2eFileProgrammer";
9
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
+
11
+ export namespace NestiaMigrateApiStartProgrammer {
12
+ export const write = (
13
+ context: INestiaMigrateContext,
14
+ ): Record<string, string> => {
15
+ const importer: NestiaMigrateImportProgrammer =
16
+ new NestiaMigrateImportProgrammer();
17
+ const main: ts.VariableStatement = writeMain(
18
+ context,
19
+ importer,
20
+ pick(context.application.routes),
21
+ );
22
+ const statements: ts.Statement[] = [
23
+ ...importer.toStatements(
24
+ (name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`,
25
+ ),
26
+ FilePrinter.newLine(),
27
+ TypeScriptFactory.createImportDeclaration(
28
+ undefined,
29
+ TypeScriptFactory.createImportClause(
30
+ false,
31
+ undefined,
32
+ TypeScriptFactory.createNamedImports([
33
+ TypeScriptFactory.createImportSpecifier(
34
+ false,
35
+ undefined,
36
+ TypeScriptFactory.createIdentifier("TestGlobal"),
37
+ ),
38
+ ]),
39
+ ),
40
+ TypeScriptFactory.createStringLiteral("./TestGlobal"),
41
+ undefined,
42
+ ),
43
+ FilePrinter.newLine(),
44
+ main,
45
+ TypeScriptFactory.createExpressionStatement(writeStarter()),
46
+ ];
47
+ return {
48
+ "test/start.ts": FilePrinter.write({ statements }),
49
+ };
50
+ };
51
+
52
+ const writeMain = (
53
+ ctx: INestiaMigrateContext,
54
+ importer: NestiaMigrateImportProgrammer,
55
+ route: IHttpMigrateRoute,
56
+ ): ts.VariableStatement =>
57
+ StatementFactory.constant({
58
+ name: "main",
59
+ value: TypeScriptFactory.createArrowFunction(
60
+ [TypeScriptFactory.createToken(ts.SyntaxKind.AsyncKeyword)],
61
+ undefined,
62
+ [],
63
+ undefined,
64
+ undefined,
65
+ TypeScriptFactory.createBlock(
66
+ [
67
+ writeConnection(ctx, importer),
68
+ ...NestiaMigrateE2eFunctionProgrammer.writeBody({
69
+ config: ctx.config,
70
+ components: ctx.application.document().components,
71
+ importer,
72
+ route,
73
+ }),
74
+ ],
75
+ true,
76
+ ),
77
+ ),
78
+ });
79
+
80
+ const writeConnection = (
81
+ ctx: INestiaMigrateContext,
82
+ importer: NestiaMigrateImportProgrammer,
83
+ ): ts.VariableStatement =>
84
+ TypeScriptFactory.createVariableStatement(
85
+ undefined,
86
+ TypeScriptFactory.createVariableDeclarationList(
87
+ [
88
+ TypeScriptFactory.createVariableDeclaration(
89
+ "connection",
90
+ undefined,
91
+ TypeScriptFactory.createTypeReferenceNode(
92
+ TypeScriptFactory.createQualifiedName(
93
+ TypeScriptFactory.createIdentifier(
94
+ importer.external({
95
+ type: "default",
96
+ library: "@ORGANIZATION/PROJECT-api",
97
+ name: "api",
98
+ }),
99
+ ),
100
+ TypeScriptFactory.createIdentifier("IConnection"),
101
+ ),
102
+ ),
103
+ TypeScriptFactory.createObjectLiteralExpression(
104
+ [
105
+ TypeScriptFactory.createSpreadAssignment(
106
+ TypeScriptFactory.createCallExpression(
107
+ TypeScriptFactory.createPropertyAccessExpression(
108
+ TypeScriptFactory.createIdentifier("TestGlobal"),
109
+ "connection",
110
+ ),
111
+ undefined,
112
+ undefined,
113
+ ),
114
+ ),
115
+ ...(ctx.application.document().servers?.[0]?.url?.length
116
+ ? [
117
+ TypeScriptFactory.createPropertyAssignment(
118
+ "host",
119
+ TypeScriptFactory.createStringLiteral(
120
+ ctx.application.document().servers![0]!.url,
121
+ ),
122
+ ),
123
+ ]
124
+ : []),
125
+ ...(ctx.config.simulate === true
126
+ ? [
127
+ TypeScriptFactory.createPropertyAssignment(
128
+ "simulate",
129
+ TypeScriptFactory.createTrue(),
130
+ ),
131
+ ]
132
+ : []),
133
+ ],
134
+ true,
135
+ ),
136
+ ),
137
+ ],
138
+ ts.NodeFlags.Const,
139
+ ),
140
+ );
141
+
142
+ const writeStarter = (): ts.CallExpression =>
143
+ TypeScriptFactory.createCallExpression(
144
+ TypeScriptFactory.createPropertyAccessExpression(
145
+ TypeScriptFactory.createCallExpression(
146
+ TypeScriptFactory.createIdentifier("main"),
147
+ undefined,
148
+ undefined,
149
+ ),
150
+ "catch",
151
+ ),
152
+ undefined,
153
+ [
154
+ TypeScriptFactory.createArrowFunction(
155
+ undefined,
156
+ undefined,
157
+ [IdentifierFactory.parameter("exp")],
158
+ undefined,
159
+ undefined,
160
+ TypeScriptFactory.createBlock(
161
+ [
162
+ TypeScriptFactory.createExpressionStatement(
163
+ TypeScriptFactory.createCallExpression(
164
+ TypeScriptFactory.createPropertyAccessExpression(
165
+ TypeScriptFactory.createIdentifier("console"),
166
+ "log",
167
+ ),
168
+ undefined,
169
+ [TypeScriptFactory.createIdentifier("exp")],
170
+ ),
171
+ ),
172
+ TypeScriptFactory.createExpressionStatement(
173
+ TypeScriptFactory.createCallExpression(
174
+ TypeScriptFactory.createPropertyAccessExpression(
175
+ TypeScriptFactory.createIdentifier("process"),
176
+ "exit",
177
+ ),
178
+ undefined,
179
+ [
180
+ TypeScriptFactory.createPrefixMinus(
181
+ TypeScriptFactory.createNumericLiteral("1"),
182
+ ),
183
+ ],
184
+ ),
185
+ ),
186
+ ],
187
+ true,
188
+ ),
189
+ ),
190
+ ],
191
+ );
192
+ }
193
+
194
+ const pick = <T>(array: T[]): T => {
195
+ const rand: number = Math.random() * array.length;
196
+ const index: number = Math.min(array.length - 1, Math.floor(rand));
197
+ return array[index]!;
198
+ };
@@ -1,99 +1,99 @@
1
- import { TypeScriptFactory } from "@nestia/factory";
2
- import { OpenApi } from "@typia/interface";
3
- import { IPointer } from "tstl";
4
- import ts from "../internal/ts";
5
-
6
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
7
- import { FilePrinter } from "../utils/FilePrinter";
8
- import { MapUtil } from "../utils/MapUtil";
9
- import { StringUtil } from "../utils/StringUtil";
10
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
11
- import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
12
-
13
- export namespace NestiaMigrateDtoProgrammer {
14
- export interface IModule {
15
- name: string;
16
- children: Map<string, IModule>;
17
- programmer:
18
- | null
19
- | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
20
- }
21
-
22
- export const compose = (props: {
23
- config: INestiaMigrateConfig;
24
- components: OpenApi.IComponents;
25
- }): Map<string, IModule> => {
26
- const dict: Map<string, IModule> = new Map();
27
- for (const [key, value] of Object.entries(props.components.schemas ?? {})) {
28
- const emendedKey: string = key
29
- .split("/")
30
- .filter((str) => str.length !== 0)
31
- .map(StringUtil.escapeNonVariable)
32
- .join("");
33
- prepare(dict)(emendedKey)((importer) =>
34
- writeAlias(props.config)(props.components)(importer)(emendedKey, value),
35
- );
36
- }
37
- return dict;
38
- };
39
-
40
- const prepare =
41
- (dict: Map<string, IModule>) =>
42
- (name: string) =>
43
- (
44
- programmer: (
45
- importer: NestiaMigrateImportProgrammer,
46
- ) => ts.TypeAliasDeclaration,
47
- ) => {
48
- const accessors: string[] = name.split(".");
49
- const modulo: IPointer<IModule> = { value: null! };
50
-
51
- accessors.forEach((acc, i) => {
52
- modulo.value = MapUtil.take(dict)(acc)(() => ({
53
- name: acc,
54
- children: new Map(),
55
- programmer: null,
56
- }));
57
- if (i === accessors.length - 1) modulo.value.programmer = programmer;
58
- dict = modulo.value.children;
59
- });
60
- return modulo!;
61
- };
62
-
63
- const writeAlias =
64
- (config: INestiaMigrateConfig) =>
65
- (components: OpenApi.IComponents) =>
66
- (importer: NestiaMigrateImportProgrammer) =>
67
- (key: string, value: OpenApi.IJsonSchema) =>
68
- FilePrinter.description(
69
- TypeScriptFactory.createTypeAliasDeclaration(
70
- [TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword)],
71
- key.split(".").at(-1)!,
72
- [],
73
- NestiaMigrateSchemaProgrammer.write({
74
- components,
75
- importer,
76
- schema: value,
77
- }),
78
- ),
79
- writeComment(config)(value, key.indexOf(".") === -1),
80
- );
81
- }
82
-
83
- const writeComment =
84
- (config: INestiaMigrateConfig) =>
85
- (schema: OpenApi.IJsonSchema, top: boolean): string =>
86
- [
87
- ...(schema.description?.length ? [schema.description] : []),
88
- ...(schema.description?.length &&
89
- (schema.title !== undefined || schema.deprecated === true)
90
- ? [""]
91
- : []),
92
- ...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
93
- ...(schema.deprecated === true ? [`@deprecated`] : []),
94
- ...(top
95
- ? [
96
- `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
97
- ]
98
- : []),
99
- ].join("\n");
1
+ import { TypeScriptFactory } from "@nestia/factory";
2
+ import { OpenApi } from "@typia/interface";
3
+ import { IPointer } from "tstl";
4
+ import ts from "../internal/ts";
5
+
6
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
7
+ import { FilePrinter } from "../utils/FilePrinter";
8
+ import { MapUtil } from "../utils/MapUtil";
9
+ import { StringUtil } from "../utils/StringUtil";
10
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
11
+ import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
12
+
13
+ export namespace NestiaMigrateDtoProgrammer {
14
+ export interface IModule {
15
+ name: string;
16
+ children: Map<string, IModule>;
17
+ programmer:
18
+ | null
19
+ | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
20
+ }
21
+
22
+ export const compose = (props: {
23
+ config: INestiaMigrateConfig;
24
+ components: OpenApi.IComponents;
25
+ }): Map<string, IModule> => {
26
+ const dict: Map<string, IModule> = new Map();
27
+ for (const [key, value] of Object.entries(props.components.schemas ?? {})) {
28
+ const emendedKey: string = key
29
+ .split("/")
30
+ .filter((str) => str.length !== 0)
31
+ .map(StringUtil.escapeNonVariable)
32
+ .join("");
33
+ prepare(dict)(emendedKey)((importer) =>
34
+ writeAlias(props.config)(props.components)(importer)(emendedKey, value),
35
+ );
36
+ }
37
+ return dict;
38
+ };
39
+
40
+ const prepare =
41
+ (dict: Map<string, IModule>) =>
42
+ (name: string) =>
43
+ (
44
+ programmer: (
45
+ importer: NestiaMigrateImportProgrammer,
46
+ ) => ts.TypeAliasDeclaration,
47
+ ) => {
48
+ const accessors: string[] = name.split(".");
49
+ const modulo: IPointer<IModule> = { value: null! };
50
+
51
+ accessors.forEach((acc, i) => {
52
+ modulo.value = MapUtil.take(dict)(acc)(() => ({
53
+ name: acc,
54
+ children: new Map(),
55
+ programmer: null,
56
+ }));
57
+ if (i === accessors.length - 1) modulo.value.programmer = programmer;
58
+ dict = modulo.value.children;
59
+ });
60
+ return modulo!;
61
+ };
62
+
63
+ const writeAlias =
64
+ (config: INestiaMigrateConfig) =>
65
+ (components: OpenApi.IComponents) =>
66
+ (importer: NestiaMigrateImportProgrammer) =>
67
+ (key: string, value: OpenApi.IJsonSchema) =>
68
+ FilePrinter.description(
69
+ TypeScriptFactory.createTypeAliasDeclaration(
70
+ [TypeScriptFactory.createToken(ts.SyntaxKind.ExportKeyword)],
71
+ key.split(".").at(-1)!,
72
+ [],
73
+ NestiaMigrateSchemaProgrammer.write({
74
+ components,
75
+ importer,
76
+ schema: value,
77
+ }),
78
+ ),
79
+ writeComment(config)(value, key.indexOf(".") === -1),
80
+ );
81
+ }
82
+
83
+ const writeComment =
84
+ (config: INestiaMigrateConfig) =>
85
+ (schema: OpenApi.IJsonSchema, top: boolean): string =>
86
+ [
87
+ ...(schema.description?.length ? [schema.description] : []),
88
+ ...(schema.description?.length &&
89
+ (schema.title !== undefined || schema.deprecated === true)
90
+ ? [""]
91
+ : []),
92
+ ...(schema.title !== undefined ? [`@title ${schema.title}`] : []),
93
+ ...(schema.deprecated === true ? [`@deprecated`] : []),
94
+ ...(top
95
+ ? [
96
+ `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
97
+ ]
98
+ : []),
99
+ ].join("\n");