@nestia/migrate 14.0.0 → 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 (182) hide show
  1. package/README.md +1 -1
  2. package/lib/NestiaMigrateApplication.d.ts +111 -0
  3. package/lib/NestiaMigrateApplication.js +148 -9
  4. package/lib/NestiaMigrateApplication.js.map +1 -1
  5. package/lib/NestiaMigrateApplication.mjs +147 -5
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +58 -0
  7. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +88 -2
  8. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +20 -2
  10. package/lib/archivers/NestiaMigrateFileArchiver.d.ts +34 -0
  11. package/lib/archivers/NestiaMigrateFileArchiver.js +34 -0
  12. package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
  13. package/lib/bundles/NEST_TEMPLATE.js +1 -1
  14. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  15. package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
  16. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  17. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  18. package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
  19. package/lib/executable/NestiaMigrateCommander.d.ts +36 -0
  20. package/lib/executable/NestiaMigrateCommander.js +43 -1
  21. package/lib/executable/NestiaMigrateCommander.js.map +1 -1
  22. package/lib/executable/NestiaMigrateCommander.mjs +4 -2
  23. package/lib/executable/NestiaMigrateInquirer.d.ts +29 -0
  24. package/lib/executable/NestiaMigrateInquirer.js +27 -25
  25. package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
  26. package/lib/executable/NestiaMigrateInquirer.mjs +5 -7
  27. package/lib/factories/ExpressionFactory.d.ts +14 -0
  28. package/lib/factories/ExpressionFactory.js +14 -0
  29. package/lib/factories/ExpressionFactory.js.map +1 -1
  30. package/lib/factories/IdentifierFactory.d.ts +20 -0
  31. package/lib/factories/IdentifierFactory.js +20 -0
  32. package/lib/factories/IdentifierFactory.js.map +1 -1
  33. package/lib/factories/LiteralFactory.d.ts +18 -2
  34. package/lib/factories/LiteralFactory.js +18 -2
  35. package/lib/factories/LiteralFactory.js.map +1 -1
  36. package/lib/factories/StatementFactory.d.ts +26 -1
  37. package/lib/factories/StatementFactory.js +26 -1
  38. package/lib/factories/StatementFactory.js.map +1 -1
  39. package/lib/factories/SupportedStringFormats.d.ts +6 -0
  40. package/lib/factories/SupportedStringFormats.js +33 -0
  41. package/lib/factories/SupportedStringFormats.js.map +1 -0
  42. package/lib/factories/SupportedStringFormats.mjs +34 -0
  43. package/lib/factories/SupportedStringFormats.mjs.map +1 -0
  44. package/lib/factories/TypeFactory.d.ts +21 -0
  45. package/lib/factories/TypeFactory.js +13 -0
  46. package/lib/factories/TypeFactory.js.map +1 -1
  47. package/lib/factories/TypeLiteralFactory.d.ts +18 -0
  48. package/lib/factories/TypeLiteralFactory.js +18 -0
  49. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  50. package/lib/internal/ts.d.ts +153 -0
  51. package/lib/internal/ts.js.map +1 -1
  52. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
  53. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
  54. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
  55. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
  56. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +34 -5
  57. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  58. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.mjs +4 -2
  59. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
  60. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +57 -13
  61. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  62. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.mjs +17 -8
  63. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
  64. package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
  65. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  66. package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
  67. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
  68. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +51 -22
  69. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  70. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.mjs +13 -20
  71. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
  72. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
  73. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  74. package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
  75. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
  76. package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
  77. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
  78. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
  79. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +46 -5
  80. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  81. package/lib/programmers/NestiaMigrateE2eFileProgrammer.mjs +6 -2
  82. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
  83. package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
  84. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
  85. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
  86. package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
  87. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  88. package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
  89. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
  90. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
  91. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
  92. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
  93. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +85 -13
  94. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  95. package/lib/programmers/NestiaMigrateNestMethodProgrammer.mjs +46 -9
  96. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
  97. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
  98. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
  99. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
  100. package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
  101. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
  102. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
  103. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +45 -9
  104. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  105. package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +19 -8
  106. package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
  107. package/lib/structures/INestiaMigrateContext.d.ts +15 -0
  108. package/lib/structures/INestiaMigrateController.d.ts +13 -0
  109. package/lib/structures/INestiaMigrateFile.d.ts +11 -0
  110. package/lib/utils/FilePrinter.d.ts +33 -0
  111. package/lib/utils/FilePrinter.js +33 -0
  112. package/lib/utils/FilePrinter.js.map +1 -1
  113. package/lib/utils/MapUtil.d.ts +17 -0
  114. package/lib/utils/MapUtil.js +19 -3
  115. package/lib/utils/MapUtil.js.map +1 -1
  116. package/lib/utils/MapUtil.mjs +1 -2
  117. package/lib/utils/PathTemplate.d.ts +41 -0
  118. package/lib/utils/PathTemplate.js +56 -0
  119. package/lib/utils/PathTemplate.js.map +1 -0
  120. package/lib/utils/PathTemplate.mjs +34 -0
  121. package/lib/utils/PathTemplate.mjs.map +1 -0
  122. package/lib/utils/RequestBody.d.ts +22 -0
  123. package/lib/utils/RequestBody.js +29 -0
  124. package/lib/utils/RequestBody.js.map +1 -0
  125. package/lib/utils/RequestBody.mjs +9 -0
  126. package/lib/utils/RequestBody.mjs.map +1 -0
  127. package/lib/utils/StringUtil.d.ts +55 -0
  128. package/lib/utils/StringUtil.js +93 -8
  129. package/lib/utils/StringUtil.js.map +1 -1
  130. package/lib/utils/StringUtil.mjs +30 -8
  131. package/lib/utils/SuccessStatus.d.ts +34 -0
  132. package/lib/utils/SuccessStatus.js +48 -0
  133. package/lib/utils/SuccessStatus.js.map +1 -0
  134. package/lib/utils/SuccessStatus.mjs +14 -0
  135. package/lib/utils/SuccessStatus.mjs.map +1 -0
  136. package/package.json +5 -4
  137. package/src/NestiaMigrateApplication.ts +151 -13
  138. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +94 -2
  139. package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
  140. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  141. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  142. package/src/executable/NestiaMigrateCommander.ts +47 -1
  143. package/src/executable/NestiaMigrateInquirer.ts +41 -26
  144. package/src/factories/ExpressionFactory.ts +14 -0
  145. package/src/factories/IdentifierFactory.ts +20 -0
  146. package/src/factories/LiteralFactory.ts +18 -2
  147. package/src/factories/StatementFactory.ts +26 -1
  148. package/src/factories/SupportedStringFormats.ts +29 -0
  149. package/src/factories/TypeFactory.ts +21 -0
  150. package/src/factories/TypeLiteralFactory.ts +18 -0
  151. package/src/internal/ts.ts +153 -0
  152. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
  153. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +53 -4
  154. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +83 -20
  155. package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
  156. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +66 -73
  157. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
  158. package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
  159. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +83 -8
  160. package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
  161. package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
  162. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
  163. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +122 -29
  164. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
  165. package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
  166. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +53 -18
  167. package/src/structures/INestiaMigrateConfig.ts +26 -0
  168. package/src/structures/INestiaMigrateContext.ts +17 -0
  169. package/src/structures/INestiaMigrateController.ts +16 -0
  170. package/src/structures/INestiaMigrateFile.ts +13 -0
  171. package/src/utils/FilePrinter.ts +33 -0
  172. package/src/utils/MapUtil.ts +18 -2
  173. package/src/utils/PathTemplate.ts +61 -0
  174. package/src/utils/RequestBody.ts +27 -0
  175. package/src/utils/StringUtil.ts +101 -9
  176. package/src/utils/SuccessStatus.ts +49 -0
  177. package/lib/factories/FormatCheatSheet.d.ts +0 -25
  178. package/lib/factories/FormatCheatSheet.js +0 -34
  179. package/lib/factories/FormatCheatSheet.js.map +0 -1
  180. package/lib/factories/FormatCheatSheet.mjs +0 -31
  181. package/lib/factories/FormatCheatSheet.mjs.map +0 -1
  182. package/src/factories/FormatCheatSheet.ts +0 -71
@@ -9,8 +9,22 @@ import {
9
9
  * Numeric-literal helper that handles negative values via a leading
10
10
  * `MinusToken` prefix unary, matching how the TypeScript factory itself emits
11
11
  * negative numeric literals.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation The namespace holds the number literal builder that the generators need.
14
+ * @evidence contracts/common.md#clear-and-simple-design One function.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
16
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
12
17
  */
13
18
  export namespace ExpressionFactory {
19
+ /**
20
+ * Builds a numeric literal, using a prefix minus for a negative value,
21
+ * because a negative numeric literal is not a valid node.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation TypeScript represents a negative number as a prefix unary minus applied to a positive literal, so the function builds that shape for values below zero and a plain literal otherwise.
24
+ * @evidence contracts/common.md#clear-and-simple-design One conditional.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the syntax tree grammar.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states the negative case.
27
+ */
14
28
  export const number = (
15
29
  value: number,
16
30
  ): NumericLiteral | PrefixUnaryExpression =>
@@ -19,11 +19,21 @@ const isVariableName = (str: string): boolean => VARIABLE_REGEX.test(str);
19
19
  /**
20
20
  * Identifier and member-access helpers. The surface kept here is the subset
21
21
  * nestia generators actually call (`identifier`, `access`, `parameter`).
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation The functions decide between an identifier and a string literal by the syntax of the name, so any string can be used as a key.
24
+ * @evidence contracts/common.md#clear-and-simple-design Three small functions and one private predicate.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The variable-name test is a regular expression of the language's identifier syntax, which is inlined so that the package need not load a larger namespace.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
22
27
  */
23
28
  export namespace IdentifierFactory {
24
29
  /**
25
30
  * Build an identifier or string literal depending on whether `name` is a
26
31
  * valid JavaScript identifier.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The name is tested against the identifier grammar `[A-Za-z_$][A-Za-z0-9_$]*`, which is conservative: a valid name outside it, such as one with non-ASCII letters, becomes a quoted key, which is equivalent.
34
+ * @evidence contracts/common.md#clear-and-simple-design One conditional.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The test applies to every name.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states the two results.
27
37
  */
28
38
  export const identifier = (name: string): Identifier | StringLiteral =>
29
39
  isVariableName(name)
@@ -33,6 +43,11 @@ export namespace IdentifierFactory {
33
43
  /**
34
44
  * Member access on `input` by `key`. Falls back to element access when the
35
45
  * key is not a valid identifier.
46
+ *
47
+ * @evidence contracts/common.md#principled-implementation The postfix is built by `identifier`, and its kind selects the property form or the element form, with the chain token added when requested.
48
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the naming rule.
49
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It never concatenates source text.
50
+ * @evidence contracts/common.md#meaningful-documentation The comment states the forms.
36
51
  */
37
52
  export const access = (
38
53
  input: Expression,
@@ -60,6 +75,11 @@ export namespace IdentifierFactory {
60
75
  /**
61
76
  * Parameter declaration with default `any` type when the caller omits one.
62
77
  * Passing a `QuestionToken` as `init` marks the parameter optional.
78
+ *
79
+ * @evidence contracts/common.md#principled-implementation An initializer that is the question token becomes the optional marker and is not an initializer, and any other initializer is passed through.
80
+ * @evidence contracts/common.md#clear-and-simple-design One function with one branch.
81
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
82
+ * @evidence contracts/common.md#meaningful-documentation The comment states the optional marker and the default type.
63
83
  */
64
84
  export const parameter = (
65
85
  name: string | Identifier,
@@ -16,10 +16,26 @@ const isNode = (value: unknown): value is Expression =>
16
16
 
17
17
  /**
18
18
  * Recursive value-to-AST-literal builder. Hands back already-AST inputs
19
- * unchanged (so callers can mix factory output with raw JS values inside the
20
- * same object/array), and emits the appropriate literal node otherwise.
19
+ * unchanged for arrow functions, calls and identifiers (so callers can mix
20
+ * those factory expressions with raw values inside objects/arrays), and emits
21
+ * the appropriate literal node otherwise.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation The namespace maps null, booleans, numbers, strings, bigint text, arrays and object entries to literal expressions, passes through the three accepted AST kinds, maps functions to undefined and refuses unsupported primitive types.
24
+ * @evidence contracts/common.md#clear-and-simple-design One entry function and two private helpers for containers.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type, with no value special-cased.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
21
27
  */
22
28
  export namespace LiteralFactory {
29
+ /**
30
+ * Builds the expression of a value: `null`, a boolean, a number, a string, a
31
+ * bigint as its text, an array, an object without its `undefined` members, or
32
+ * an expression node as it is.
33
+ *
34
+ * @evidence contracts/common.md#principled-implementation The value is dispatched by type in a fixed order; nodes of the kinds arrow function, call, and identifier pass through, functions become `undefined`, and an unsupported type is a `TypeError`, so the result is total over the listed types.
35
+ * @evidence contracts/common.md#clear-and-simple-design One function with one branch per type.
36
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general, and a bigint becomes text because a literal bigint is not supported by the target syntax here.
37
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the mapping.
38
+ */
23
39
  export const write = (input: any): Expression => {
24
40
  if (input === null) return factory.createNull();
25
41
  if (isNode(input) && PASSTHROUGH_KINDS.has(input.kind)) return input;
@@ -8,8 +8,24 @@ import {
8
8
 
9
9
  import { TypeFactory } from "./TypeFactory";
10
10
 
11
- /** Variable-statement helpers. `constant` emits `const`, `mut` emits `let`. */
11
+ /**
12
+ * Variable-statement helpers. `constant` emits `const`, `mut` emits `let`.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation The namespace builds `let` and `const` statements from a name, an optional type, and an optional value.
15
+ * @evidence contracts/common.md#clear-and-simple-design Two functions.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
18
+ */
12
19
  export namespace StatementFactory {
20
+ /**
21
+ * Builds a `let` statement; a declaration without a type and without an
22
+ * initializer is typed `any`.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation A `let` without both a type and an initializer would be implicitly any, so the type is stated explicitly in that case.
25
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment states the default type.
28
+ */
13
29
  export const mut = (props: {
14
30
  name: string;
15
31
  type?: TypeNode | undefined;
@@ -34,6 +50,15 @@ export namespace StatementFactory {
34
50
  ),
35
51
  );
36
52
 
53
+ /**
54
+ * Builds a `const` statement from a name, an optional type, and an optional
55
+ * value.
56
+ *
57
+ * @evidence contracts/common.md#principled-implementation The declaration list carries the const flag and the given parts.
58
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
59
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
60
+ * @evidence contracts/common.md#meaningful-documentation The comment states its inputs.
61
+ */
37
62
  export const constant = (props: {
38
63
  name: string;
39
64
  type?: TypeNode | undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The string formats of the OpenAPI document that the typia `Format` tag
3
+ * validates, so a schema carrying one of them is generated as a `Format` tag
4
+ * and a schema carrying any other format stays a plain `string`.
5
+ */
6
+ export const SUPPORTED_STRING_FORMATS: ReadonlySet<string> = new Set([
7
+ "byte",
8
+ "password",
9
+ "regex",
10
+ "uuid",
11
+ "email",
12
+ "hostname",
13
+ "idn-email",
14
+ "idn-hostname",
15
+ "iri",
16
+ "iri-reference",
17
+ "ipv4",
18
+ "ipv6",
19
+ "uri",
20
+ "uri-reference",
21
+ "uri-template",
22
+ "url",
23
+ "date-time",
24
+ "date",
25
+ "time",
26
+ "duration",
27
+ "json-pointer",
28
+ "relative-json-pointer",
29
+ ]);
@@ -6,6 +6,11 @@ import { type KeywordTypeNode, SyntaxKind, factory } from "@ttsc/factory";
6
6
  * Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
7
7
  * generator code reads as `TypeFactory.keyword("any")` instead of selecting the
8
8
  * `SyntaxKind.AnyKeyword` token by hand.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation The namespace maps the names of the nine keyword types to their syntax kinds.
11
+ * @evidence contracts/common.md#clear-and-simple-design One table, one type, and one function.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
9
14
  */
10
15
  export namespace TypeFactory {
11
16
  const KEYWORDS = {
@@ -20,8 +25,24 @@ export namespace TypeFactory {
20
25
  undefined: SyntaxKind.UndefinedKeyword,
21
26
  } as const;
22
27
 
28
+ /**
29
+ * The names of the supported keyword types.
30
+ *
31
+ * @evidence contracts/common.md#principled-implementation The type is the key set of the table that maps names to syntax kinds, so a new keyword is one table entry.
32
+ * @evidence contracts/common.md#clear-and-simple-design One derived type.
33
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
34
+ * @evidence contracts/common.md#meaningful-documentation The comment names the set.
35
+ */
23
36
  export type Keyword = keyof typeof KEYWORDS;
24
37
 
38
+ /**
39
+ * Builds the keyword type node of a keyword name.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation The name is looked up in the table, so an unsupported name is a compile error.
42
+ * @evidence contracts/common.md#clear-and-simple-design One lookup.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the type grammar.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment states its input.
45
+ */
25
46
  export const keyword = (type: Keyword): KeywordTypeNode =>
26
47
  factory.createKeywordTypeNode(KEYWORDS[type]);
27
48
  }
@@ -3,7 +3,25 @@ import { NamingConvention } from "@typia/utils";
3
3
 
4
4
  import ts from "../internal/ts";
5
5
 
6
+ /**
7
+ * Builds type nodes from JavaScript values, so a value can be written as a
8
+ * literal type.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation The namespace maps booleans, numbers, strings, null, arrays as tuples, and objects as type literals, and anything else to `any`.
11
+ * @evidence contracts/common.md#clear-and-simple-design One entry function and small private builders per kind.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type, with no value special-cased.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
14
+ */
6
15
  export namespace TypeLiteralFactory {
16
+ /**
17
+ * Builds the literal type of a value: a literal for a primitive, a tuple for
18
+ * an array, a type literal for an object, and `any` for other values.
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The value is dispatched by type, negative numbers use a prefix minus as expressions do, and object keys that are not identifiers are quoted.
21
+ * @evidence contracts/common.md#clear-and-simple-design One function with one branch per kind.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the mapping.
24
+ */
7
25
  export const generate = (value: any): ts.TypeNode =>
8
26
  typeof value === "boolean"
9
27
  ? generateBoolean(value)
@@ -51,24 +51,177 @@ type _TypeReferenceNode = TypeReferenceNode;
51
51
  type _UnionTypeNode = UnionTypeNode;
52
52
  type _VariableStatement = VariableStatement;
53
53
 
54
+ /**
55
+ * A compatibility stand-in for `import ts from "typescript"`: the one value the
56
+ * generators still call, and the node types under the names they use.
57
+ *
58
+ * @evidence contracts/common.md#principled-implementation The value is the union-type guard, and the namespace aliases map each used compiler type name to the matching node type of the factory package, so existing annotations keep their exact shapes.
59
+ * @evidence contracts/common.md#clear-and-simple-design One value and one declaration-only namespace of aliases.
60
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It avoids loading the compiler; the guard is implemented on the node kind, not on a patched compiler.
61
+ * @evidence contracts/common.md#meaningful-documentation The leading comment explains why the shim exists.
62
+ */
54
63
  declare namespace ts {
64
+ /**
65
+ * The `Node` node type under the name the generators use.
66
+ *
67
+ * @evidence contracts/common.md#principled-implementation The alias names the `Node` node type of the factory package.
68
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
69
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
70
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
71
+ */
55
72
  export type Node = _Node;
73
+ /**
74
+ * The `Block` node type under the name the generators use.
75
+ *
76
+ * @evidence contracts/common.md#principled-implementation The alias names the `Block` node type of the factory package.
77
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
78
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
79
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
80
+ */
56
81
  export type Block = _Block;
82
+ /**
83
+ * The `CallExpression` node type under the name the generators use.
84
+ *
85
+ * @evidence contracts/common.md#principled-implementation The alias names the `CallExpression` node type of the factory package.
86
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
87
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
88
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
89
+ */
57
90
  export type CallExpression = _CallExpression;
91
+ /**
92
+ * The `ConciseBody` node type under the name the generators use.
93
+ *
94
+ * @evidence contracts/common.md#principled-implementation A concise body is a block or an expression, the same union the compiler defines.
95
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
96
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
97
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
98
+ */
58
99
  export type ConciseBody = _Block | _Expression;
100
+ /**
101
+ * The `Decorator` node type under the name the generators use.
102
+ *
103
+ * @evidence contracts/common.md#principled-implementation The alias names the `Decorator` node type of the factory package.
104
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
105
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
106
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
107
+ */
59
108
  export type Decorator = _Decorator;
109
+ /**
110
+ * The `Expression` node type under the name the generators use.
111
+ *
112
+ * @evidence contracts/common.md#principled-implementation The alias names the `Expression` node type of the factory package.
113
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
114
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
115
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
116
+ */
60
117
  export type Expression = _Expression;
118
+ /**
119
+ * The `FunctionDeclaration` node type under the name the generators use.
120
+ *
121
+ * @evidence contracts/common.md#principled-implementation The alias names the `FunctionDeclaration` node type of the factory package.
122
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
123
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
124
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
125
+ */
61
126
  export type FunctionDeclaration = _FunctionDeclaration;
127
+ /**
128
+ * The `Identifier` node type under the name the generators use.
129
+ *
130
+ * @evidence contracts/common.md#principled-implementation The alias names the `Identifier` node type of the factory package.
131
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
132
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
133
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
134
+ */
62
135
  export type Identifier = _Identifier;
136
+ /**
137
+ * The `KeywordTypeNode` node type under the name the generators use.
138
+ *
139
+ * @evidence contracts/common.md#principled-implementation The alias names the `KeywordTypeNode` node type of the factory package.
140
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
141
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
142
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
143
+ */
63
144
  export type KeywordTypeNode = _KeywordTypeNode;
145
+ /**
146
+ * The `MethodDeclaration` node type under the name the generators use.
147
+ *
148
+ * @evidence contracts/common.md#principled-implementation The alias names the `MethodDeclaration` node type of the factory package.
149
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
150
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
151
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
152
+ */
64
153
  export type MethodDeclaration = _MethodDeclaration;
154
+ /**
155
+ * The `ModuleDeclaration` node type under the name the generators use.
156
+ *
157
+ * @evidence contracts/common.md#principled-implementation The alias names the `ModuleDeclaration` node type of the factory package.
158
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
159
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
160
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
161
+ */
65
162
  export type ModuleDeclaration = _ModuleDeclaration;
163
+ /**
164
+ * The `ParameterDeclaration` node type under the name the generators use.
165
+ *
166
+ * @evidence contracts/common.md#principled-implementation The alias names the `ParameterDeclaration` node type of the factory package.
167
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
168
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
169
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
170
+ */
66
171
  export type ParameterDeclaration = _ParameterDeclaration;
172
+ /**
173
+ * The `Statement` node type under the name the generators use.
174
+ *
175
+ * @evidence contracts/common.md#principled-implementation The alias names the `Statement` node type of the factory package.
176
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
177
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
178
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
179
+ */
67
180
  export type Statement = _Statement;
181
+ /**
182
+ * The `TypeAliasDeclaration` node type under the name the generators use.
183
+ *
184
+ * @evidence contracts/common.md#principled-implementation The alias names the `TypeAliasDeclaration` node type of the factory package.
185
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
186
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
187
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
188
+ */
68
189
  export type TypeAliasDeclaration = _TypeAliasDeclaration;
190
+ /**
191
+ * The `TypeNode` node type under the name the generators use.
192
+ *
193
+ * @evidence contracts/common.md#principled-implementation The alias names the `TypeNode` node type of the factory package.
194
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
195
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
196
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
197
+ */
69
198
  export type TypeNode = _TypeNode;
199
+ /**
200
+ * The `TypeReferenceNode` node type under the name the generators use.
201
+ *
202
+ * @evidence contracts/common.md#principled-implementation The alias names the `TypeReferenceNode` node type of the factory package.
203
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
204
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
205
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
206
+ */
70
207
  export type TypeReferenceNode = _TypeReferenceNode;
208
+ /**
209
+ * The `UnionTypeNode` node type under the name the generators use.
210
+ *
211
+ * @evidence contracts/common.md#principled-implementation The alias names the `UnionTypeNode` node type of the factory package.
212
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
213
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
214
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
215
+ */
71
216
  export type UnionTypeNode = _UnionTypeNode;
217
+ /**
218
+ * The `VariableStatement` node type under the name the generators use.
219
+ *
220
+ * @evidence contracts/common.md#principled-implementation The alias names the `VariableStatement` node type of the factory package.
221
+ * @evidence contracts/common.md#clear-and-simple-design One alias.
222
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
223
+ * @evidence contracts/common.md#meaningful-documentation The alias is named after the compiler type it replaces, and the file comment explains the shim.
224
+ */
72
225
  export type VariableStatement = _VariableStatement;
73
226
  }
74
227
 
@@ -8,15 +8,50 @@ import { NestiaMigrateApiFunctionProgrammer } from "./NestiaMigrateApiFunctionPr
8
8
  import { NestiaMigrateApiNamespaceProgrammer } from "./NestiaMigrateApiNamespaceProgrammer";
9
9
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
10
 
11
+ /**
12
+ * Generates one file of the functional API: the imports, the exports of the
13
+ * child namespaces, and the functions of the routes at this level.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation Each route contributes its function and its namespace, the imports are collected by one importer and emitted first, and each child namespace is re-exported, so a file is a complete module.
16
+ * @evidence contracts/common.md#clear-and-simple-design One function over the two per-route programmers and the importer.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the routes and the configuration.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment states the file's content.
19
+ */
11
20
  export namespace NestiaMigrateApiFileProgrammer {
21
+ /**
22
+ * The input of one API file: the configuration, the components, the namespace
23
+ * path, the routes, and the child namespaces.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation The record holds exactly what a file needs, so files can be generated independently.
26
+ * @evidence contracts/common.md#clear-and-simple-design A flat record.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
28
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
29
+ */
12
30
  export interface IProps {
31
+ /** Calling convention and optional generated features for this operation. */
13
32
  config: INestiaMigrateConfig;
33
+
34
+ /** Component schemas used to resolve DTO references. */
14
35
  components: OpenApi.IComponents;
36
+
37
+ /** Accessor prefix locating this functional API index. */
15
38
  namespace: string[];
39
+
40
+ /** Operations whose functions belong directly to this index. */
16
41
  routes: IHttpMigrateRoute[];
42
+
43
+ /** Immediate child namespace names re-exported by this index. */
17
44
  children: Set<string>;
18
45
  }
19
46
 
47
+ /**
48
+ * Returns the statements of one API file.
49
+ *
50
+ * @evidence contracts/common.md#principled-implementation The relative path to the structures directory is derived from the namespace depth, so imports resolve from every level.
51
+ * @evidence contracts/common.md#clear-and-simple-design One function.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The depth is computed, not hardcoded.
53
+ * @evidence contracts/common.md#meaningful-documentation The comment states its result.
54
+ */
20
55
  export const write = (props: IProps): ts.Statement[] => {
21
56
  const importer: NestiaMigrateImportProgrammer =
22
57
  new NestiaMigrateImportProgrammer();
@@ -7,17 +7,52 @@ import { StatementFactory } from "../factories/StatementFactory";
7
7
  import ts from "../internal/ts";
8
8
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
9
9
  import { FilePrinter } from "../utils/FilePrinter";
10
+ import { RequestBody } from "../utils/RequestBody";
11
+ import { SuccessStatus } from "../utils/SuccessStatus";
10
12
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
11
13
  import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
12
14
 
15
+ /**
16
+ * Generates the function of one route in the SDK.
17
+ *
18
+ * @evidence contracts/common.md#principled-implementation The function has the connection parameter, the path, query, header, and body parameters in positional or keyword form, and its body calls the plain or the encrypted fetcher, or the simulator when the connection asks for it, and copies response headers when the description asks.
19
+ * @evidence contracts/common.md#clear-and-simple-design One entry function, one public parameter builder shared with the simulation programmer, and private helpers for the body and the header directives.
20
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route and the configuration, and the header directives are read from the documented tags.
21
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
22
+ */
13
23
  export namespace NestiaMigrateApiFunctionProgrammer {
24
+ /**
25
+ * The input of one function: the configuration, the components, the importer,
26
+ * and the route.
27
+ *
28
+ * @evidence contracts/common.md#principled-implementation The record holds exactly what the function generation needs.
29
+ * @evidence contracts/common.md#clear-and-simple-design A flat record.
30
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
31
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
32
+ */
14
33
  export interface IContext {
34
+ /** Calling convention and optional generated features for this operation. */
15
35
  config: INestiaMigrateConfig;
36
+
37
+ /** Component schemas used to resolve DTO references. */
16
38
  components: OpenApi.IComponents;
39
+
40
+ /** File-local import collector shared with the surrounding file writer. */
17
41
  importer: NestiaMigrateImportProgrammer;
42
+
43
+ /** Analyzed operation, with the accessor chosen for this generation. */
18
44
  route: IHttpMigrateRoute;
19
45
  }
20
46
 
47
+ /**
48
+ * Returns the exported async function declaration of the route, with its
49
+ * description.
50
+ *
51
+ * @evidence contracts/common.md#principled-implementation The function name is the last accessor segment, the return type is the namespace's response type or void, and the description comes from the route comment with the path, the accessor, and the author tag.
52
+ * @evidence contracts/common.md#clear-and-simple-design One expression over the private parts.
53
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the accessor.
54
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
55
+ */
21
56
  export const write = (ctx: IContext): ts.FunctionDeclaration =>
22
57
  FilePrinter.description(
23
58
  factory.createFunctionDeclaration(
@@ -41,6 +76,16 @@ export namespace NestiaMigrateApiFunctionProgrammer {
41
76
  writeDescription(ctx.config, ctx.route),
42
77
  );
43
78
 
79
+ /**
80
+ * Returns the parameters of the function: the connection first, then either
81
+ * one `props` parameter in keyword mode or the path, query, and body
82
+ * parameters in positional mode.
83
+ *
84
+ * @evidence contracts/common.md#principled-implementation The connection type carries the route's header type when it has one, keyword mode adds `props` only when there is something to pass, and an optional body is marked optional.
85
+ * @evidence contracts/common.md#clear-and-simple-design One function with the two modes as two returns.
86
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The shape follows the configuration.
87
+ * @evidence contracts/common.md#meaningful-documentation The comment states the two modes.
88
+ */
44
89
  export const writeParameterDeclarations = (
45
90
  ctx: IContext,
46
91
  connectionName?: string,
@@ -110,9 +155,7 @@ export namespace NestiaMigrateApiFunctionProgrammer {
110
155
  factory.createTypeReferenceNode(
111
156
  `${ctx.route.accessor.at(-1)!}.Body`,
112
157
  ),
113
- (ctx.route.body.type === "application/json" ||
114
- ctx.route.body.type === "text/plain") &&
115
- ctx.route.operation().requestBody?.required === false
158
+ RequestBody.optional(ctx.route)
116
159
  ? factory.createToken(SyntaxKind.QuestionToken)
117
160
  : undefined,
118
161
  ),
@@ -208,9 +251,15 @@ export namespace NestiaMigrateApiFunctionProgrammer {
208
251
  getArguments(ctx, false),
209
252
  ),
210
253
  ),
254
+ // the fetcher reads only 200, 201, and this status as success
211
255
  factory.createPropertyAssignment(
212
256
  "status",
213
- factory.createNull(),
257
+ ((status) =>
258
+ status === null
259
+ ? factory.createNull()
260
+ : factory.createNumericLiteral(status))(
261
+ SuccessStatus.of(ctx.route),
262
+ ),
214
263
  ),
215
264
  ],
216
265
  true,