@nestia/migrate 14.0.1 → 14.0.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 (167) hide show
  1. package/lib/NestiaMigrateApplication.d.ts +111 -0
  2. package/lib/NestiaMigrateApplication.js +148 -9
  3. package/lib/NestiaMigrateApplication.js.map +1 -1
  4. package/lib/NestiaMigrateApplication.mjs +147 -5
  5. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +45 -0
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +59 -3
  7. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  8. package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +9 -3
  9. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +34 -0
  10. package/lib/archivers/NestiaMigrateFileArchiver.js +34 -0
  11. package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
  12. package/lib/bundles/NEST_TEMPLATE.js +1 -1
  13. package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
  14. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  15. package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
  16. package/lib/executable/NestiaMigrateCommander.d.ts +36 -0
  17. package/lib/executable/NestiaMigrateCommander.js +38 -0
  18. package/lib/executable/NestiaMigrateCommander.js.map +1 -1
  19. package/lib/executable/NestiaMigrateCommander.mjs +3 -1
  20. package/lib/executable/NestiaMigrateInquirer.d.ts +29 -0
  21. package/lib/executable/NestiaMigrateInquirer.js +20 -0
  22. package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
  23. package/lib/factories/ExpressionFactory.d.ts +14 -0
  24. package/lib/factories/ExpressionFactory.js +14 -0
  25. package/lib/factories/ExpressionFactory.js.map +1 -1
  26. package/lib/factories/IdentifierFactory.d.ts +20 -0
  27. package/lib/factories/IdentifierFactory.js +20 -0
  28. package/lib/factories/IdentifierFactory.js.map +1 -1
  29. package/lib/factories/LiteralFactory.d.ts +18 -2
  30. package/lib/factories/LiteralFactory.js +18 -2
  31. package/lib/factories/LiteralFactory.js.map +1 -1
  32. package/lib/factories/StatementFactory.d.ts +26 -1
  33. package/lib/factories/StatementFactory.js +26 -1
  34. package/lib/factories/StatementFactory.js.map +1 -1
  35. package/lib/factories/SupportedStringFormats.d.ts +6 -0
  36. package/lib/factories/SupportedStringFormats.js +33 -0
  37. package/lib/factories/SupportedStringFormats.js.map +1 -0
  38. package/lib/factories/SupportedStringFormats.mjs +34 -0
  39. package/lib/factories/SupportedStringFormats.mjs.map +1 -0
  40. package/lib/factories/TypeFactory.d.ts +21 -0
  41. package/lib/factories/TypeFactory.js +13 -0
  42. package/lib/factories/TypeFactory.js.map +1 -1
  43. package/lib/factories/TypeLiteralFactory.d.ts +18 -0
  44. package/lib/factories/TypeLiteralFactory.js +18 -0
  45. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  46. package/lib/internal/ts.d.ts +153 -0
  47. package/lib/internal/ts.js.map +1 -1
  48. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
  49. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
  50. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
  51. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
  52. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +27 -0
  53. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  54. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
  55. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +26 -0
  56. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  57. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
  58. package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
  59. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  60. package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
  61. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
  62. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +27 -0
  63. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  64. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
  65. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
  66. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  67. package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
  68. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
  69. package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
  70. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
  71. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
  72. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +26 -0
  73. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  74. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
  75. package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
  76. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
  77. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
  78. package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
  79. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  80. package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
  81. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
  82. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
  83. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
  84. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
  85. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +16 -0
  86. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  87. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
  88. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
  89. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
  90. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
  91. package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
  92. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
  93. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
  94. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +20 -5
  95. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  96. package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +4 -4
  97. package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
  98. package/lib/structures/INestiaMigrateContext.d.ts +15 -0
  99. package/lib/structures/INestiaMigrateController.d.ts +13 -0
  100. package/lib/structures/INestiaMigrateFile.d.ts +11 -0
  101. package/lib/utils/FilePrinter.d.ts +33 -0
  102. package/lib/utils/FilePrinter.js +33 -0
  103. package/lib/utils/FilePrinter.js.map +1 -1
  104. package/lib/utils/MapUtil.d.ts +17 -0
  105. package/lib/utils/MapUtil.js +19 -3
  106. package/lib/utils/MapUtil.js.map +1 -1
  107. package/lib/utils/MapUtil.mjs +1 -2
  108. package/lib/utils/PathTemplate.d.ts +23 -1
  109. package/lib/utils/PathTemplate.js +15 -1
  110. package/lib/utils/PathTemplate.js.map +1 -1
  111. package/lib/utils/RequestBody.d.ts +13 -0
  112. package/lib/utils/RequestBody.js +13 -0
  113. package/lib/utils/RequestBody.js.map +1 -1
  114. package/lib/utils/StringUtil.d.ts +55 -0
  115. package/lib/utils/StringUtil.js +93 -8
  116. package/lib/utils/StringUtil.js.map +1 -1
  117. package/lib/utils/StringUtil.mjs +30 -8
  118. package/lib/utils/SuccessStatus.d.ts +21 -1
  119. package/lib/utils/SuccessStatus.js +21 -1
  120. package/lib/utils/SuccessStatus.js.map +1 -1
  121. package/package.json +4 -3
  122. package/src/NestiaMigrateApplication.ts +151 -13
  123. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +59 -4
  124. package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
  125. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  126. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  127. package/src/executable/NestiaMigrateCommander.ts +40 -0
  128. package/src/executable/NestiaMigrateInquirer.ts +29 -0
  129. package/src/factories/ExpressionFactory.ts +14 -0
  130. package/src/factories/IdentifierFactory.ts +20 -0
  131. package/src/factories/LiteralFactory.ts +18 -2
  132. package/src/factories/StatementFactory.ts +26 -1
  133. package/src/factories/SupportedStringFormats.ts +29 -0
  134. package/src/factories/TypeFactory.ts +21 -0
  135. package/src/factories/TypeLiteralFactory.ts +18 -0
  136. package/src/internal/ts.ts +153 -0
  137. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
  138. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +43 -0
  139. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +42 -0
  140. package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
  141. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +43 -0
  142. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
  143. package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
  144. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +42 -0
  145. package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
  146. package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
  147. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
  148. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +34 -0
  149. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
  150. package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
  151. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +25 -8
  152. package/src/structures/INestiaMigrateConfig.ts +26 -0
  153. package/src/structures/INestiaMigrateContext.ts +17 -0
  154. package/src/structures/INestiaMigrateController.ts +16 -0
  155. package/src/structures/INestiaMigrateFile.ts +13 -0
  156. package/src/utils/FilePrinter.ts +33 -0
  157. package/src/utils/MapUtil.ts +18 -2
  158. package/src/utils/PathTemplate.ts +23 -1
  159. package/src/utils/RequestBody.ts +13 -0
  160. package/src/utils/StringUtil.ts +101 -9
  161. package/src/utils/SuccessStatus.ts +21 -1
  162. package/lib/factories/FormatCheatSheet.d.ts +0 -25
  163. package/lib/factories/FormatCheatSheet.js +0 -34
  164. package/lib/factories/FormatCheatSheet.js.map +0 -1
  165. package/lib/factories/FormatCheatSheet.mjs +0 -31
  166. package/lib/factories/FormatCheatSheet.mjs.map +0 -1
  167. package/src/factories/FormatCheatSheet.ts +0 -71
@@ -1,20 +1,48 @@
1
- import { SyntaxKind, factory } from "@ttsc/factory";
1
+ import { type EntityName, SyntaxKind, factory } from "@ttsc/factory";
2
2
 
3
3
  import { TypeLiteralFactory } from "../factories/TypeLiteralFactory";
4
4
  import ts from "../internal/ts";
5
5
  import { FilePrinter } from "../utils/FilePrinter";
6
6
  import { MapUtil } from "../utils/MapUtil";
7
7
 
8
+ /**
9
+ * Collects the imports that generated code needs and turns them into import
10
+ * statements.
11
+ *
12
+ * @evidence contracts/common.md#principled-implementation External imports are grouped by library into one clause with an optional default and a set of named instances, DTO imports are grouped by module specifier and emitted type-only, and a DTO is never imported into its own file.
13
+ * @evidence contracts/common.md#clear-and-simple-design One class with two collections and one emitter; the tag helper builds `typia.tags` references.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The imports follow the code that asks for them.
15
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
16
+ */
8
17
  export class NestiaMigrateImportProgrammer {
9
18
  private external_: Map<string, IClause> = new Map();
10
19
  private dtos_: Set<string> = new Set();
11
20
 
12
21
  public constructor() {}
13
22
 
23
+ /**
24
+ * Reports whether no import has been requested.
25
+ *
26
+ * @evidence contracts/common.md#principled-implementation The importer is empty exactly when both collections are empty.
27
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
28
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the state.
29
+ * @evidence contracts/common.md#meaningful-documentation The comment states the meaning.
30
+ */
14
31
  public empty(): boolean {
15
32
  return this.external_.size === 0 && this.dtos_.size === 0;
16
33
  }
17
34
 
35
+ /**
36
+ * Requests an import from a library and returns the local name to use.
37
+ *
38
+ * The returned name is the first segment of the requested name, so a nested
39
+ * name such as `tags.Type` imports `tags`.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation A default import replaces the clause's default and an instance import adds a named import, and the first segment of a dotted name is what the code refers to.
42
+ * @evidence contracts/common.md#clear-and-simple-design One function over one map.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The library and the name come from the caller.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment states the returned name.
45
+ */
18
46
  public external(props: MigrateImportProgrammer.IProps): string {
19
47
  const clause: IClause = MapUtil.take(this.external_)(props.library)(() => ({
20
48
  default: null,
@@ -26,19 +54,41 @@ export class NestiaMigrateImportProgrammer {
26
54
  return name;
27
55
  }
28
56
 
57
+ /**
58
+ * Requests a DTO import and returns a reference to it, qualified by a
59
+ * namespace when one is given.
60
+ *
61
+ * @evidence contracts/common.md#principled-implementation The DTO is recorded by the first segment of its dotted name, which is the file that exports it, and the returned reference keeps the full name, with the namespace prepended when one is given.
62
+ * @evidence contracts/common.md#clear-and-simple-design One function over one set.
63
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The name comes from the caller.
64
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
65
+ */
29
66
  public dto(name: string, namespace?: string): ts.TypeReferenceNode {
30
- const file: string = name.split(".")[0]!;
31
- this.dtos_.add(file);
67
+ const segments: string[] = name.split(".");
68
+ this.dtos_.add(segments[0]!);
32
69
  return factory.createTypeReferenceNode(
33
70
  namespace?.length
34
- ? factory.createQualifiedName(
71
+ ? segments.reduce<EntityName>(
72
+ (left, segment) =>
73
+ factory.createQualifiedName(
74
+ left,
75
+ factory.createIdentifier(segment),
76
+ ),
35
77
  factory.createIdentifier(namespace),
36
- factory.createIdentifier(file),
37
78
  )
38
79
  : name,
39
80
  );
40
81
  }
41
82
 
83
+ /**
84
+ * Requests the `typia` tags import and returns a reference to a tag with an
85
+ * optional literal argument.
86
+ *
87
+ * @evidence contracts/common.md#principled-implementation The argument is converted to a literal type, so `Minimum<3>` is written as a type reference with the literal.
88
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the literal building.
89
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The tag name and the argument come from the caller.
90
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
91
+ */
42
92
  public tag(type: string, arg?: any): ts.TypeReferenceNode {
43
93
  const instance: string = this.external({
44
94
  type: "instance",
@@ -51,6 +101,15 @@ export class NestiaMigrateImportProgrammer {
51
101
  );
52
102
  }
53
103
 
104
+ /**
105
+ * Returns the import statements: the external imports, a blank line when both
106
+ * kinds exist, and the type-only DTO imports.
107
+ *
108
+ * @evidence contracts/common.md#principled-implementation DTO names are grouped by the specifier that `dtoPath` returns, a name equal to the current file is skipped so a file never imports itself, and package specifiers merge into one clause.
109
+ * @evidence contracts/common.md#clear-and-simple-design One function with two emit sections.
110
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The specifier rule is the caller's.
111
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result and the self-import rule.
112
+ */
54
113
  public toStatements(
55
114
  dtoPath: (name: string) => string,
56
115
  current?: string,
@@ -114,10 +173,32 @@ export class NestiaMigrateImportProgrammer {
114
173
  ];
115
174
  }
116
175
  }
176
+ /**
177
+ * Types of the importer: the properties of an external import request.
178
+ *
179
+ * @evidence contracts/common.md#principled-implementation The record names the import kind, the library, and the name.
180
+ * @evidence contracts/common.md#clear-and-simple-design One namespace with one interface.
181
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It contains types only.
182
+ * @evidence contracts/common.md#meaningful-documentation The comment names its content.
183
+ */
117
184
  export namespace MigrateImportProgrammer {
185
+ /**
186
+ * An external import request: `default` or `instance`, the library, and the
187
+ * name.
188
+ *
189
+ * @evidence contracts/common.md#principled-implementation The kind selects between the default clause and a named import.
190
+ * @evidence contracts/common.md#clear-and-simple-design A three-field record.
191
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
192
+ * @evidence contracts/common.md#meaningful-documentation The comment states each field.
193
+ */
118
194
  export interface IProps {
195
+ /** Select the default export or a named import. */
119
196
  type: "default" | "instance";
197
+
198
+ /** Module specifier emitted in the import declaration. */
120
199
  library: string;
200
+
201
+ /** Requested binding; named imports use its leading dotted segment. */
121
202
  name: string;
122
203
  }
123
204
  }
@@ -8,13 +8,43 @@ import { FilePrinter } from "../utils/FilePrinter";
8
8
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
9
9
  import { NestiaMigrateNestMethodProgrammer } from "./NestiaMigrateNestMethodProgrammer";
10
10
 
11
+ /**
12
+ * Generates the source of one NestJS controller.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation The controller class is decorated with `@Controller` and its path, each route becomes a method written by the configured method programmer or the default one, and the DTO types are imported by package name because they live in the API package.
15
+ * @evidence contracts/common.md#clear-and-simple-design One function; the method programmer is replaceable through the configuration.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The replaceable programmer is a documented extension point.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
18
+ */
11
19
  export namespace NestiaMigrateNestControllerProgrammer {
20
+ /**
21
+ * The input of one controller: the configuration, the components, and the
22
+ * controller.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.
25
+ * @evidence contracts/common.md#clear-and-simple-design A flat record.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
28
+ */
12
29
  export interface IProps {
30
+ /** Generation options and an optional controller-method writer. */
13
31
  config: INestiaMigrateConfig;
32
+
33
+ /** Schemas needed by generated controller method types. */
14
34
  components: OpenApi.IComponents;
35
+
36
+ /** Controller name, router prefix and grouped operations. */
15
37
  controller: INestiaMigrateController;
16
38
  }
17
39
 
40
+ /**
41
+ * Returns the statements of a controller file.
42
+ *
43
+ * @evidence contracts/common.md#principled-implementation Blank lines separate the methods, and the imports come first.
44
+ * @evidence contracts/common.md#clear-and-simple-design One function.
45
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The content follows the controller.
46
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
47
+ */
18
48
  export const write = (props: IProps): ts.Statement[] => {
19
49
  const importer: NestiaMigrateImportProgrammer =
20
50
  new NestiaMigrateImportProgrammer();
@@ -17,15 +17,49 @@ import { SuccessStatus } from "../utils/SuccessStatus";
17
17
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
18
18
  import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
19
19
 
20
+ /**
21
+ * Generates the controller method of one route.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation The method carries `TypedRoute`, `TypedException`, `HumanRoute`, and example decorators as the route requires, one parameter per path, header, query, and body input with the matching typed decorator, and a body that mentions each parameter and returns `typia.random` of the response type.
24
+ * @evidence contracts/common.md#clear-and-simple-design One entry function and private writers for the description, the decorators, and the parameters.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route; the body is a stub that returns random data because the document does not define the behavior.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
27
+ */
20
28
  export namespace NestiaMigrateNestMethodProgrammer {
29
+ /**
30
+ * The input of one method: the configuration, the components, the importer,
31
+ * the controller, and the route.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.
34
+ * @evidence contracts/common.md#clear-and-simple-design A flat record.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
37
+ */
21
38
  export interface IContext {
39
+ /** Generation options, including the author tag used on the handler. */
22
40
  config: INestiaMigrateConfig;
41
+
42
+ /** Component schemas referenced by request and response types. */
23
43
  components: OpenApi.IComponents;
44
+
45
+ /** Controller-file import collector shared by all its methods. */
24
46
  importer: NestiaMigrateImportProgrammer;
47
+
48
+ /** Controller prefix removed from this operation's router path. */
25
49
  controller: INestiaMigrateController;
50
+
51
+ /** Analyzed operation supplying method, schemas and examples. */
26
52
  route: IHttpMigrateRoute;
27
53
  }
28
54
 
55
+ /**
56
+ * Returns the method declaration of a route.
57
+ *
58
+ * @evidence contracts/common.md#principled-implementation The decorators and the parameters follow the route's HTTP method, path relative to the controller, and inputs.
59
+ * @evidence contracts/common.md#clear-and-simple-design One function composing the private writers.
60
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The method follows the route.
61
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
62
+ */
29
63
  export const write = (ctx: IContext): ts.MethodDeclaration => {
30
64
  const output: ts.TypeNode = ctx.route.success
31
65
  ? NestiaMigrateSchemaProgrammer.write({
@@ -4,7 +4,23 @@ import ts from "../internal/ts";
4
4
  import { INestiaMigrateController } from "../structures/INestiaMigrateController";
5
5
  import { FilePrinter } from "../utils/FilePrinter";
6
6
 
7
+ /**
8
+ * Generates the NestJS module that lists the controllers.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation The module imports every controller from its location and lists them in the `controllers` array of a decorated class.
11
+ * @evidence contracts/common.md#clear-and-simple-design One function and one private import builder.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The controllers follow the analysis.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
14
+ */
7
15
  export namespace NestiaMigrateNestModuleProgrammer {
16
+ /**
17
+ * Returns the statements of the module file.
18
+ *
19
+ * @evidence contracts/common.md#principled-implementation The import paths turn the `src/` prefix of a controller location into `./`, so the module can import from its own directory.
20
+ * @evidence contracts/common.md#clear-and-simple-design One function.
21
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the controllers.
22
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
23
+ */
8
24
  export const write = (
9
25
  controllers: INestiaMigrateController[],
10
26
  ): ts.Statement[] => [
@@ -10,7 +10,24 @@ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
10
  import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
11
11
  import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
12
12
 
13
+ /**
14
+ * Generates the NestJS side of a monorepo project: the module, the controllers,
15
+ * and the DTO structures.
16
+ *
17
+ * @evidence contracts/common.md#principled-implementation The controllers come from the analyzer, each DTO tree becomes a structure file, and a barrel file re-exports every non-empty structure file so the template's module keeps working.
18
+ * @evidence contracts/common.md#clear-and-simple-design One public function and private helpers for the DTO files and the barrel.
19
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the analysis.
20
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
21
+ */
13
22
  export namespace NestiaMigrateNestProgrammer {
23
+ /**
24
+ * Returns the map from file path to content of the NestJS files.
25
+ *
26
+ * @evidence contracts/common.md#principled-implementation The barrel is computed from the generated structure files, sorted by name, so its content is deterministic.
27
+ * @evidence contracts/common.md#clear-and-simple-design One function.
28
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the document.
29
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
30
+ */
14
31
  export const write = (
15
32
  context: INestiaMigrateContext,
16
33
  ): Record<string, string> => {
@@ -2,17 +2,33 @@ import { SyntaxKind, factory } from "@ttsc/factory";
2
2
  import { NamingConvention, OpenApiTypeChecker } from "@typia/utils";
3
3
  import type { OpenApi } from "typia";
4
4
 
5
- import { FormatCheatSheet } from "../factories/FormatCheatSheet";
5
+ import { SUPPORTED_STRING_FORMATS } from "../factories/SupportedStringFormats";
6
6
  import { TypeFactory } from "../factories/TypeFactory";
7
7
  import ts from "../internal/ts";
8
8
  import { FilePrinter } from "../utils/FilePrinter";
9
9
  import { StringUtil } from "../utils/StringUtil";
10
10
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
11
11
 
12
+ /**
13
+ * Generates the TypeScript type of an OpenAPI schema.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation The schema kind is decided by the type checker of `@typia/utils`, and each kind becomes a type: constants as literal types, numbers, integers, and strings with their constraints as `typia.tags` intersections, arrays, tuples, objects, references, and unions, with `any` for an unknown schema.
16
+ * @evidence contracts/common.md#clear-and-simple-design One entry function that dispatches to one private writer per kind.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch follows the schema kinds of OpenAPI, and no schema name is special-cased.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
19
+ */
12
20
  export namespace NestiaMigrateSchemaProgrammer {
13
21
  /* -----------------------------------------------------------
14
22
  FACADE
15
23
  ----------------------------------------------------------- */
24
+ /**
25
+ * Returns the type node of a schema.
26
+ *
27
+ * @evidence contracts/common.md#principled-implementation An unknown schema is `any`, a `oneOf` becomes a TypeScript union, integer formats outside the supported four use the migration default `int64`, a binary string becomes `File`, and known string formats become typia tags. TypeScript unions do not encode oneOf exclusivity, and unsupported formats impose no generated constraint.
28
+ * @evidence contracts/common.md#clear-and-simple-design One function with an ordered chain of schema kind tests.
29
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Schema-kind dispatch applies uniformly; the int64 fallback and supported-format table are generator policies rather than constraints supplied by the document.
30
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
31
+ */
16
32
  export const write = (props: {
17
33
  components: OpenApi.IComponents;
18
34
  importer: NestiaMigrateImportProgrammer;
@@ -209,8 +225,7 @@ export namespace NestiaMigrateSchemaProgrammer {
209
225
  intersection.push(props.importer.tag("Pattern", props.schema.pattern));
210
226
  if (
211
227
  props.schema.format !== undefined &&
212
- (FormatCheatSheet as Record<string, string>)[props.schema.format] !==
213
- undefined
228
+ SUPPORTED_STRING_FORMATS.has(props.schema.format)
214
229
  )
215
230
  intersection.push(props.importer.tag("Format", props.schema.format));
216
231
  if (props.schema.contentMediaType !== undefined)
@@ -267,11 +282,13 @@ export namespace NestiaMigrateSchemaProgrammer {
267
282
  props.schema.additionalItems !== null
268
283
  ? [
269
284
  factory.createRestTypeNode(
270
- write({
271
- components: props.components,
272
- importer: props.importer,
273
- schema: props.schema.additionalItems,
274
- }),
285
+ factory.createArrayTypeNode(
286
+ write({
287
+ components: props.components,
288
+ importer: props.importer,
289
+ schema: props.schema.additionalItems,
290
+ }),
291
+ ),
275
292
  ),
276
293
  ]
277
294
  : props.schema.additionalItems === true
@@ -1,15 +1,41 @@
1
1
  import ts from "../internal/ts";
2
2
  import { NestiaMigrateNestMethodProgrammer } from "../programmers/NestiaMigrateNestMethodProgrammer";
3
3
 
4
+ /**
5
+ * Options of the migration: simulation, e2e tests, the package name, keyword
6
+ * parameters, the author tag, and a replaceable controller method programmer.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation The flags choose which parts are generated and the parameter style, the package name replaces the placeholder in every file, and the programmer option lets a caller generate controller methods differently.
9
+ * @evidence contracts/common.md#clear-and-simple-design A flat record whose optional members are the extension points.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
11
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the options.
12
+ */
4
13
  export interface INestiaMigrateConfig {
14
+ /** Include runtime request validation and random-response simulator members. */
5
15
  simulate: boolean;
16
+
17
+ /** Emit a generated test feature for each migrated operation. */
6
18
  e2e: boolean;
19
+
20
+ /** Replace the template package placeholder; omission retains the placeholder. */
7
21
  package?: string;
22
+
23
+ /**
24
+ * Use a props object when true; false or omission selects positional
25
+ * parameters.
26
+ */
8
27
  keyword?: boolean;
28
+
29
+ /** Override the generated declaration attribution tag and its text. */
9
30
  author?: {
10
31
  tag: string;
11
32
  value: string;
12
33
  };
34
+
35
+ /**
36
+ * Replace controller method emission while retaining the surrounding
37
+ * controller.
38
+ */
13
39
  programmer?: {
14
40
  controllerMethod?: (
15
41
  ctx: NestiaMigrateNestMethodProgrammer.IContext,
@@ -2,8 +2,25 @@ import { IHttpMigrateApplication } from "@typia/interface";
2
2
 
3
3
  import { INestiaMigrateConfig } from "./INestiaMigrateConfig";
4
4
 
5
+ /**
6
+ * The shared input of the programmers: the mode, the analyzed application, and
7
+ * the configuration.
8
+ *
9
+ * @evidence contracts/common.md#principled-implementation The record is built once per migration, so every programmer sees the same routes and options.
10
+ * @evidence contracts/common.md#clear-and-simple-design A three-member record.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
12
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the members.
13
+ */
5
14
  export interface INestiaMigrateContext {
15
+ /** Select backend/API workspace output or a standalone SDK project. */
6
16
  mode: "nest" | "sdk";
17
+
18
+ /**
19
+ * Generation-local route/accessor copies backed by the shared analyzed
20
+ * document.
21
+ */
7
22
  application: IHttpMigrateApplication;
23
+
24
+ /** Options used consistently by each programmer in this generation. */
8
25
  config: INestiaMigrateConfig;
9
26
  }
@@ -1,8 +1,24 @@
1
1
  import { IHttpMigrateRoute } from "@typia/interface";
2
2
 
3
+ /**
4
+ * A controller to generate: its name, its path, its source location, and its
5
+ * routes.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation The record is the output of the analyzer and the input of the controller programmer.
8
+ * @evidence contracts/common.md#clear-and-simple-design A four-member record.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
10
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the members.
11
+ */
3
12
  export interface INestiaMigrateController {
13
+ /** Class identifier shared by its declaration, filename and module import. */
4
14
  name: string;
15
+
16
+ /** Shared router path prefix, including router escapes for literal characters. */
5
17
  path: string;
18
+
19
+ /** Slash-separated source directory relative to the backend package. */
6
20
  location: string;
21
+
22
+ /** Operations grouped into this controller, in document order. */
7
23
  routes: IHttpMigrateRoute[];
8
24
  }
@@ -1,5 +1,18 @@
1
+ /**
2
+ * A generated file: its directory, its name, and its content.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation The record separates the location from the name so the writers can join them per mode.
5
+ * @evidence contracts/common.md#clear-and-simple-design A three-member record.
6
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
7
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the members.
8
+ */
1
9
  export interface INestiaMigrateFile {
10
+ /** Slash-separated output directory relative to the generated project root. */
2
11
  location: string;
12
+
13
+ /** Filename within location. */
3
14
  file: string;
15
+
16
+ /** Complete source text written without another generation step. */
4
17
  content: string;
5
18
  }
@@ -7,7 +7,24 @@ import {
7
7
 
8
8
  import ts from "../internal/ts";
9
9
 
10
+ /**
11
+ * Helpers that turn statements and comments into file text.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation The namespace attaches a JSDoc comment to a node, builds a blank line, and prints a file from statements.
14
+ * @evidence contracts/common.md#clear-and-simple-design Three small functions.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The comment text is escaped so it cannot end the comment early.
16
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
17
+ */
10
18
  export namespace FilePrinter {
19
+ /**
20
+ * Attaches a JSDoc comment made from the text to the node, and leaves the
21
+ * node alone when the text is empty.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation Line endings are normalized, each line is prefixed, and every comment terminator in the text is replaced by an escaped form, so a description can never end the comment early and inject code.
24
+ * @evidence contracts/common.md#clear-and-simple-design One function with an early return.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The escaping applies to every line.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states the empty case and the escaping.
27
+ */
11
28
  export const description = <Node extends ts.Node>(
12
29
  node: Node,
13
30
  comment: string,
@@ -33,9 +50,25 @@ export namespace FilePrinter {
33
50
  return node;
34
51
  };
35
52
 
53
+ /**
54
+ * Builds a statement that prints as a blank line.
55
+ *
56
+ * @evidence contracts/common.md#principled-implementation The printer emits the identifier text as it is, so an identifier holding a newline produces an empty line between statements.
57
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
58
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is the way the printer offers to space statements.
59
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the statement prints.
60
+ */
36
61
  export const newLine = () =>
37
62
  factory.createExpressionStatement(factory.createIdentifier("\n"));
38
63
 
64
+ /**
65
+ * Prints the statements as a file, with an optional text at the top.
66
+ *
67
+ * @evidence contracts/common.md#principled-implementation The statements are printed by the factory package's printer, so the output is the source of the syntax tree.
68
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
69
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It prints what it is given.
70
+ * @evidence contracts/common.md#meaningful-documentation The comment states the top text.
71
+ */
39
72
  export const write = (props: {
40
73
  statements: ts.Statement[];
41
74
  top?: string;
@@ -1,10 +1,26 @@
1
+ /**
2
+ * Helpers for maps.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation The namespace holds the get-or-create helper.
5
+ * @evidence contracts/common.md#clear-and-simple-design One function.
6
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.
7
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
8
+ */
1
9
  export namespace MapUtil {
10
+ /**
11
+ * Returns the value of a key, creating and storing it with the generator when
12
+ * the key is absent.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation Presence is tested with `has`, so a stored falsy value is returned and not created again, and the generator runs once per key.
15
+ * @evidence contracts/common.md#clear-and-simple-design One check, one generator call, and one store.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The stored value is returned as it is.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states when the generator runs.
18
+ */
2
19
  export const take =
3
20
  <Key, T>(dict: Map<Key, T>) =>
4
21
  (key: Key) =>
5
22
  (generator: () => T): T => {
6
- const oldbie: T | undefined = dict.get(key);
7
- if (oldbie) return oldbie;
23
+ if (dict.has(key)) return dict.get(key) as T;
8
24
 
9
25
  const value: T = generator();
10
26
  dict.set(key, value);
@@ -1,6 +1,22 @@
1
1
  import { IHttpMigrateRoute } from "@typia/interface";
2
2
 
3
+ /**
4
+ * Splits a route path template into literal and parameter segments.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation The namespace scans the template for `{name}` placeholders and matches each with the route's parameter of that name.
7
+ * @evidence contracts/common.md#clear-and-simple-design One type and one function.
8
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The scan is by the template syntax.
9
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
10
+ */
3
11
  export namespace PathTemplate {
12
+ /**
13
+ * A segment of a path: a literal text or a parameter.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation The union is discriminated by `type`, so a consumer handles each case once.
16
+ * @evidence contracts/common.md#clear-and-simple-design A two-member union.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment names the two cases.
19
+ */
4
20
  export type ISegment =
5
21
  | { type: "literal"; value: string }
6
22
  | { type: "param"; parameter: IHttpMigrateRoute.IParameter };
@@ -11,7 +27,13 @@ export namespace PathTemplate {
11
27
  * parameter name. The emended path (`/files/:id.json`) cannot be split back:
12
28
  * its `:id.json` could name `id` or `id.json`, and a name such as `item-id`
13
29
  * would read as `item` followed by `-id`. It always starts with `/`, as the
14
- * emended path does.
30
+ * emended path does. A placeholder without a matching route parameter remains
31
+ * literal text; adjacent literals are merged.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The scan uses a regular expression over the placeholders and joins the text between them, and merging adjacent literals keeps the segment list minimal.
34
+ * @evidence contracts/common.md#clear-and-simple-design One function with one helper for merging.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It never drops text of the template.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states the merging and the unmatched placeholder rule.
15
37
  */
16
38
  export const segments = (route: IHttpMigrateRoute): ISegment[] => {
17
39
  const path: string = route.path.startsWith("/")
@@ -1,10 +1,23 @@
1
1
  import { IHttpMigrateRoute } from "@typia/interface";
2
2
 
3
+ /**
4
+ * Helpers about the request body of a route.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation The namespace holds the optional-body predicate.
7
+ * @evidence contracts/common.md#clear-and-simple-design One function.
8
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.
9
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
10
+ */
3
11
  export namespace RequestBody {
4
12
  /**
5
13
  * Whether the route's body may be omitted: a JSON or text body the document
6
14
  * does not require. The SDK's positional and keyword functions and the Nest
7
15
  * controller all read this one rule.
16
+ *
17
+ * @evidence contracts/common.md#principled-implementation The requirement flag is read from the operation and only an explicit `false` makes the body optional.
18
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
19
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the document.
20
+ * @evidence contracts/common.md#meaningful-documentation The comment states the condition.
8
21
  */
9
22
  export const optional = (route: IHttpMigrateRoute): boolean =>
10
23
  route.body !== null &&