@nestia/migrate 14.0.1 → 14.0.3

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 (183) 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/_virtual/_rolldown/runtime.mjs +6 -1
  6. package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +45 -0
  7. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +59 -3
  8. package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
  9. package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +9 -3
  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.mjs +1 -1
  15. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  16. package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
  17. package/lib/executable/NestiaMigrateCommander.d.ts +39 -1
  18. package/lib/executable/NestiaMigrateCommander.js +42 -2
  19. package/lib/executable/NestiaMigrateCommander.js.map +1 -1
  20. package/lib/executable/NestiaMigrateCommander.mjs +5 -3
  21. package/lib/executable/NestiaMigrateInquirer.d.ts +32 -1
  22. package/lib/executable/NestiaMigrateInquirer.js +33 -10
  23. package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
  24. package/lib/executable/NestiaMigrateInquirer.mjs +4 -3
  25. package/lib/executable/TemplateBundleCache.d.ts +23 -0
  26. package/lib/executable/TemplateBundleCache.js +60 -0
  27. package/lib/executable/TemplateBundleCache.js.map +1 -0
  28. package/lib/executable/TemplateBundleCache.mjs +39 -0
  29. package/lib/executable/TemplateBundleCache.mjs.map +1 -0
  30. package/lib/executable/bundle.d.ts +1 -0
  31. package/lib/executable/bundle.js +404 -0
  32. package/lib/executable/bundle.js.map +1 -0
  33. package/lib/executable/bundle.mjs +324 -0
  34. package/lib/executable/bundle.mjs.map +1 -0
  35. package/lib/factories/ExpressionFactory.d.ts +14 -0
  36. package/lib/factories/ExpressionFactory.js +14 -0
  37. package/lib/factories/ExpressionFactory.js.map +1 -1
  38. package/lib/factories/IdentifierFactory.d.ts +20 -0
  39. package/lib/factories/IdentifierFactory.js +20 -0
  40. package/lib/factories/IdentifierFactory.js.map +1 -1
  41. package/lib/factories/LiteralFactory.d.ts +18 -2
  42. package/lib/factories/LiteralFactory.js +18 -2
  43. package/lib/factories/LiteralFactory.js.map +1 -1
  44. package/lib/factories/StatementFactory.d.ts +26 -1
  45. package/lib/factories/StatementFactory.js +26 -1
  46. package/lib/factories/StatementFactory.js.map +1 -1
  47. package/lib/factories/SupportedStringFormats.d.ts +6 -0
  48. package/lib/factories/SupportedStringFormats.js +33 -0
  49. package/lib/factories/SupportedStringFormats.js.map +1 -0
  50. package/lib/factories/SupportedStringFormats.mjs +34 -0
  51. package/lib/factories/SupportedStringFormats.mjs.map +1 -0
  52. package/lib/factories/TypeFactory.d.ts +21 -0
  53. package/lib/factories/TypeFactory.js +13 -0
  54. package/lib/factories/TypeFactory.js.map +1 -1
  55. package/lib/factories/TypeLiteralFactory.d.ts +18 -0
  56. package/lib/factories/TypeLiteralFactory.js +18 -0
  57. package/lib/factories/TypeLiteralFactory.js.map +1 -1
  58. package/lib/internal/ts.d.ts +153 -0
  59. package/lib/internal/ts.js.map +1 -1
  60. package/lib/package.mjs +55 -0
  61. package/lib/package.mjs.map +1 -0
  62. package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
  63. package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
  64. package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
  65. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
  66. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +27 -0
  67. package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
  68. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
  69. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +26 -0
  70. package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
  71. package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
  72. package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
  73. package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
  74. package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
  75. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
  76. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +27 -0
  77. package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
  78. package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
  79. package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
  80. package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
  81. package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
  82. package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
  83. package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
  84. package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
  85. package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
  86. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +26 -0
  87. package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
  88. package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
  89. package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
  90. package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
  91. package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
  92. package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
  93. package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
  94. package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
  95. package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
  96. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
  97. package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
  98. package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
  99. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +16 -0
  100. package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
  101. package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
  102. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
  103. package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
  104. package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
  105. package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
  106. package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
  107. package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
  108. package/lib/programmers/NestiaMigrateSchemaProgrammer.js +20 -5
  109. package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
  110. package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +4 -4
  111. package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
  112. package/lib/structures/INestiaMigrateContext.d.ts +15 -0
  113. package/lib/structures/INestiaMigrateController.d.ts +13 -0
  114. package/lib/structures/INestiaMigrateFile.d.ts +11 -0
  115. package/lib/utils/FilePrinter.d.ts +33 -0
  116. package/lib/utils/FilePrinter.js +33 -0
  117. package/lib/utils/FilePrinter.js.map +1 -1
  118. package/lib/utils/MapUtil.d.ts +17 -0
  119. package/lib/utils/MapUtil.js +19 -3
  120. package/lib/utils/MapUtil.js.map +1 -1
  121. package/lib/utils/MapUtil.mjs +1 -2
  122. package/lib/utils/PathTemplate.d.ts +23 -1
  123. package/lib/utils/PathTemplate.js +15 -1
  124. package/lib/utils/PathTemplate.js.map +1 -1
  125. package/lib/utils/RequestBody.d.ts +13 -0
  126. package/lib/utils/RequestBody.js +13 -0
  127. package/lib/utils/RequestBody.js.map +1 -1
  128. package/lib/utils/StringUtil.d.ts +55 -0
  129. package/lib/utils/StringUtil.js +93 -8
  130. package/lib/utils/StringUtil.js.map +1 -1
  131. package/lib/utils/StringUtil.mjs +30 -8
  132. package/lib/utils/SuccessStatus.d.ts +21 -1
  133. package/lib/utils/SuccessStatus.js +21 -1
  134. package/lib/utils/SuccessStatus.js.map +1 -1
  135. package/package.json +5 -4
  136. package/src/NestiaMigrateApplication.ts +151 -13
  137. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +59 -4
  138. package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
  139. package/src/bundles/NEST_TEMPLATE.ts +1 -1
  140. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  141. package/src/executable/NestiaMigrateCommander.ts +44 -2
  142. package/src/executable/NestiaMigrateInquirer.ts +35 -3
  143. package/src/executable/TemplateBundleCache.ts +65 -0
  144. package/src/executable/{bundle.js → bundle.ts} +110 -43
  145. package/src/factories/ExpressionFactory.ts +14 -0
  146. package/src/factories/IdentifierFactory.ts +20 -0
  147. package/src/factories/LiteralFactory.ts +18 -2
  148. package/src/factories/StatementFactory.ts +26 -1
  149. package/src/factories/SupportedStringFormats.ts +29 -0
  150. package/src/factories/TypeFactory.ts +21 -0
  151. package/src/factories/TypeLiteralFactory.ts +18 -0
  152. package/src/internal/ts.ts +153 -0
  153. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
  154. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +43 -0
  155. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +42 -0
  156. package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
  157. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +43 -0
  158. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
  159. package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
  160. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +42 -0
  161. package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
  162. package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
  163. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
  164. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +34 -0
  165. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
  166. package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
  167. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +25 -8
  168. package/src/structures/INestiaMigrateConfig.ts +26 -0
  169. package/src/structures/INestiaMigrateContext.ts +17 -0
  170. package/src/structures/INestiaMigrateController.ts +16 -0
  171. package/src/structures/INestiaMigrateFile.ts +13 -0
  172. package/src/utils/FilePrinter.ts +33 -0
  173. package/src/utils/MapUtil.ts +18 -2
  174. package/src/utils/PathTemplate.ts +23 -1
  175. package/src/utils/RequestBody.ts +13 -0
  176. package/src/utils/StringUtil.ts +101 -9
  177. package/src/utils/SuccessStatus.ts +21 -1
  178. package/lib/factories/FormatCheatSheet.d.ts +0 -25
  179. package/lib/factories/FormatCheatSheet.js +0 -34
  180. package/lib/factories/FormatCheatSheet.js.map +0 -1
  181. package/lib/factories/FormatCheatSheet.mjs +0 -31
  182. package/lib/factories/FormatCheatSheet.mjs.map +0 -1
  183. package/src/factories/FormatCheatSheet.ts +0 -71
@@ -1,13 +1,124 @@
1
1
  import { IHttpMigrateApplication, OpenApi, OpenApiV3, OpenApiV3_1, OpenApiV3_2, SwaggerV2 } from "@typia/interface";
2
2
  import type { IValidation } from "@typia/interface";
3
3
  import { INestiaMigrateConfig } from "./structures/INestiaMigrateConfig";
4
+ /**
5
+ * Converts an OpenAPI document into a NestJS project or an SDK project, as a
6
+ * map from file path to file content.
7
+ *
8
+ * The constructor analyzes an emended OpenAPI document once; `assert` and
9
+ * `validate` upgrade a document of any supported version to that form first.
10
+ * `nest` and `sdk` then compose the files of the bundled template with the
11
+ * generated ones.
12
+ *
13
+ * The constructor analyzes the document once; generation walks templates and
14
+ * delegates per-route/schema emission, with the context builder’s accessor trie
15
+ * indexing strict prefixes.
16
+ *
17
+ * The instance shares its analyzed application between nest and sdk calls.
18
+ * Generation creates fresh context/accessor copies because its mode and config
19
+ * can differ.
20
+ *
21
+ * One instance retains its original document and analysis until callers release
22
+ * it; generated file maps are returned to callers rather than accumulated on
23
+ * the instance.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation The constructor analyzes the emended document into routes with `HttpMigration`, and the two generators start from the bundled template files, drop the paths the generators own (structures, functional API, controllers, feature tests), and add the generated files, so the result is the template with those trees replaced.
26
+ * @evidence contracts/common.md#clear-and-simple-design One class with two generators sharing one context builder; the accessor conflict escape and the package renaming are module-private functions.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Route analysis and the OpenAPI upgrade come from `@typia/utils`, and no document, path, or type name is special-cased; QUERY-method routes are left out because the SDK has no representation for them.
28
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the class produces, when the document is analyzed, and how the two generators use the template.
29
+ */
4
30
  export declare class NestiaMigrateApplication {
5
31
  readonly document: OpenApi.IDocument;
6
32
  private readonly data_;
7
33
  constructor(document: OpenApi.IDocument);
34
+ /**
35
+ * Creates the application from a document of any supported OpenAPI or Swagger
36
+ * version, and throws when the document cannot be upgraded.
37
+ *
38
+ * Version conversion and route analysis scale with the document’s routes and
39
+ * schemas; this wrapper delegates each once.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation The document is upgraded by `OpenApiConverter.upgradeDocument`, which owns the version differences, so this function only wraps a successful result.
42
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It does not repair or guess invalid documents.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment states the accepted versions and the throwing behavior.
45
+ */
8
46
  static assert(document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApiV3_2.IDocument | OpenApi.IDocument): NestiaMigrateApplication;
47
+ /**
48
+ * Creates the application, or returns the failure as an `IValidation` instead
49
+ * of throwing.
50
+ *
51
+ * Version conversion and route analysis scale with the document’s routes and
52
+ * schemas; validation delegates once and formats one caught failure.
53
+ *
54
+ * @evidence contracts/common.md#principled-implementation The upgrade runs inside a `try`, and an error becomes one validation error whose path is the input and whose value is the message, so a caller can report it.
55
+ * @evidence contracts/common.md#clear-and-simple-design The non-throwing twin of `assert`, sharing its constructor call.
56
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The failure is reported, not hidden, and the message is the original one.
57
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result shape.
58
+ */
9
59
  static validate(document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApiV3_2.IDocument | OpenApi.IDocument): IValidation<NestiaMigrateApplication>;
60
+ /**
61
+ * Returns the analyzed application: the routes and the operations that could
62
+ * not be migrated.
63
+ *
64
+ * Returning the existing analysis reference uses constant work.
65
+ *
66
+ * The constructor’s analysis is returned directly to every caller; callers
67
+ * receive mutable shared state rather than an independently refreshed view.
68
+ *
69
+ * @evidence contracts/common.md#principled-implementation The analysis is done once in the constructor and returned by reference.
70
+ * @evidence contracts/common.md#clear-and-simple-design One accessor.
71
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It exposes what the analysis produced.
72
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is returned.
73
+ */
10
74
  getData(): IHttpMigrateApplication;
75
+ /**
76
+ * Generates a NestJS monorepo project from the document.
77
+ *
78
+ * The files are the template, the controllers, the module, the DTO
79
+ * structures, the functional API, and, when requested, the e2e tests. A
80
+ * package name replaces the placeholder in every file.
81
+ *
82
+ * Template filtering and renaming scale with template/output bytes;
83
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
84
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
85
+ * first-route precedence with logarithmic updates, and each escape probes
86
+ * only the current D-segment path rather than scanning R routes. Trie state
87
+ * holds original/final prefixes only and is local to generation.
88
+ *
89
+ * The instance’s route analysis is reused. Each call recomputes
90
+ * mode/config-dependent output and copies accessors because conflict escaping
91
+ * mutates them; returned maps remain caller-owned.
92
+ *
93
+ * @evidence contracts/common.md#principled-implementation The context copies the routes and escapes accessors that would collide with a shorter accessor, the template entries of the generated trees are removed, the programmers write the replacements, and `keyword: false` rewrites the one template setting that selects keyword parameters.
94
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators; each generator owns its own files.
95
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and the only textual edit of it is the documented keyword setting.
96
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
97
+ */
11
98
  nest(config: INestiaMigrateConfig): Record<string, string>;
99
+ /**
100
+ * Generates an SDK project from the document.
101
+ *
102
+ * The files are the template, the DTO structures, the functional API, the
103
+ * start script, the swagger document in its emended form, and, when
104
+ * requested, the e2e tests. A package name replaces the placeholder in every
105
+ * file.
106
+ *
107
+ * Template filtering and renaming scale with template/output bytes;
108
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
109
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
110
+ * first-route precedence with logarithmic updates, and each escape probes
111
+ * only the current D-segment path rather than scanning R routes. Trie state
112
+ * holds original/final prefixes only and is local to generation.
113
+ *
114
+ * The instance’s route analysis is reused; mode/config-dependent output is
115
+ * recomputed with fresh accessor copies, and returned maps remain
116
+ * caller-owned.
117
+ *
118
+ * @evidence contracts/common.md#principled-implementation The context is built as for `nest`, the template entries of the generated trees are removed, the programmers write the replacements, and the emended document the application was built from, which is the input after any upgrade, is written beside them as `swagger.json`.
119
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators, sharing the context builder with `nest`.
120
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and no document is special-cased.
121
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
122
+ */
12
123
  sdk(config: INestiaMigrateConfig): Record<string, string>;
13
124
  }
@@ -2,12 +2,39 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NestiaMigrateApplication = void 0;
4
4
  const utils_1 = require("@typia/utils");
5
+ const tstl_1 = require("tstl");
5
6
  const NEST_TEMPLATE_1 = require("./bundles/NEST_TEMPLATE");
6
7
  const SDK_TEMPLATE_1 = require("./bundles/SDK_TEMPLATE");
7
8
  const NestiaMigrateApiProgrammer_1 = require("./programmers/NestiaMigrateApiProgrammer");
8
9
  const NestiaMigrateApiStartProgrammer_1 = require("./programmers/NestiaMigrateApiStartProgrammer");
9
10
  const NestiaMigrateE2eProgrammer_1 = require("./programmers/NestiaMigrateE2eProgrammer");
10
11
  const NestiaMigrateNestProgrammer_1 = require("./programmers/NestiaMigrateNestProgrammer");
12
+ /**
13
+ * Converts an OpenAPI document into a NestJS project or an SDK project, as a
14
+ * map from file path to file content.
15
+ *
16
+ * The constructor analyzes an emended OpenAPI document once; `assert` and
17
+ * `validate` upgrade a document of any supported version to that form first.
18
+ * `nest` and `sdk` then compose the files of the bundled template with the
19
+ * generated ones.
20
+ *
21
+ * The constructor analyzes the document once; generation walks templates and
22
+ * delegates per-route/schema emission, with the context builder’s accessor trie
23
+ * indexing strict prefixes.
24
+ *
25
+ * The instance shares its analyzed application between nest and sdk calls.
26
+ * Generation creates fresh context/accessor copies because its mode and config
27
+ * can differ.
28
+ *
29
+ * One instance retains its original document and analysis until callers release
30
+ * it; generated file maps are returned to callers rather than accumulated on
31
+ * the instance.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The constructor analyzes the emended document into routes with `HttpMigration`, and the two generators start from the bundled template files, drop the paths the generators own (structures, functional API, controllers, feature tests), and add the generated files, so the result is the template with those trees replaced.
34
+ * @evidence contracts/common.md#clear-and-simple-design One class with two generators sharing one context builder; the accessor conflict escape and the package renaming are module-private functions.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Route analysis and the OpenAPI upgrade come from `@typia/utils`, and no document, path, or type name is special-cased; QUERY-method routes are left out because the SDK has no representation for them.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the class produces, when the document is analyzed, and how the two generators use the template.
37
+ */
11
38
  class NestiaMigrateApplication {
12
39
  /* -----------------------------------------------------------
13
40
  CONSTRUCTORS
@@ -16,9 +43,33 @@ class NestiaMigrateApplication {
16
43
  this.document = document;
17
44
  this.data_ = utils_1.HttpMigration.application(document);
18
45
  }
46
+ /**
47
+ * Creates the application from a document of any supported OpenAPI or Swagger
48
+ * version, and throws when the document cannot be upgraded.
49
+ *
50
+ * Version conversion and route analysis scale with the document’s routes and
51
+ * schemas; this wrapper delegates each once.
52
+ *
53
+ * @evidence contracts/common.md#principled-implementation The document is upgraded by `OpenApiConverter.upgradeDocument`, which owns the version differences, so this function only wraps a successful result.
54
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
55
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It does not repair or guess invalid documents.
56
+ * @evidence contracts/common.md#meaningful-documentation The comment states the accepted versions and the throwing behavior.
57
+ */
19
58
  static assert(document) {
20
59
  return new NestiaMigrateApplication(utils_1.OpenApiConverter.upgradeDocument(document));
21
60
  }
61
+ /**
62
+ * Creates the application, or returns the failure as an `IValidation` instead
63
+ * of throwing.
64
+ *
65
+ * Version conversion and route analysis scale with the document’s routes and
66
+ * schemas; validation delegates once and formats one caught failure.
67
+ *
68
+ * @evidence contracts/common.md#principled-implementation The upgrade runs inside a `try`, and an error becomes one validation error whose path is the input and whose value is the message, so a caller can report it.
69
+ * @evidence contracts/common.md#clear-and-simple-design The non-throwing twin of `assert`, sharing its constructor call.
70
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The failure is reported, not hidden, and the message is the original one.
71
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result shape.
72
+ */
22
73
  static validate(document) {
23
74
  try {
24
75
  return {
@@ -44,9 +95,46 @@ class NestiaMigrateApplication {
44
95
  /* -----------------------------------------------------------
45
96
  ACCESSORS
46
97
  ----------------------------------------------------------- */
98
+ /**
99
+ * Returns the analyzed application: the routes and the operations that could
100
+ * not be migrated.
101
+ *
102
+ * Returning the existing analysis reference uses constant work.
103
+ *
104
+ * The constructor’s analysis is returned directly to every caller; callers
105
+ * receive mutable shared state rather than an independently refreshed view.
106
+ *
107
+ * @evidence contracts/common.md#principled-implementation The analysis is done once in the constructor and returned by reference.
108
+ * @evidence contracts/common.md#clear-and-simple-design One accessor.
109
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It exposes what the analysis produced.
110
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is returned.
111
+ */
47
112
  getData() {
48
113
  return this.data_;
49
114
  }
115
+ /**
116
+ * Generates a NestJS monorepo project from the document.
117
+ *
118
+ * The files are the template, the controllers, the module, the DTO
119
+ * structures, the functional API, and, when requested, the e2e tests. A
120
+ * package name replaces the placeholder in every file.
121
+ *
122
+ * Template filtering and renaming scale with template/output bytes;
123
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
124
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
125
+ * first-route precedence with logarithmic updates, and each escape probes
126
+ * only the current D-segment path rather than scanning R routes. Trie state
127
+ * holds original/final prefixes only and is local to generation.
128
+ *
129
+ * The instance’s route analysis is reused. Each call recomputes
130
+ * mode/config-dependent output and copies accessors because conflict escaping
131
+ * mutates them; returned maps remain caller-owned.
132
+ *
133
+ * @evidence contracts/common.md#principled-implementation The context copies the routes and escapes accessors that would collide with a shorter accessor, the template entries of the generated trees are removed, the programmers write the replacements, and `keyword: false` rewrites the one template setting that selects keyword parameters.
134
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators; each generator owns its own files.
135
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and the only textual edit of it is the documented keyword setting.
136
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
137
+ */
50
138
  nest(config) {
51
139
  const context = createContext("nest", this.data_, config);
52
140
  const files = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Object.fromEntries(Object.entries(NEST_TEMPLATE_1.NEST_TEMPLATE).filter(([key]) => key.startsWith("packages/api/src/structures") === false &&
@@ -59,6 +147,30 @@ class NestiaMigrateApplication {
59
147
  : {}));
60
148
  return config.package ? renameSlug(config.package, files) : files;
61
149
  }
150
+ /**
151
+ * Generates an SDK project from the document.
152
+ *
153
+ * The files are the template, the DTO structures, the functional API, the
154
+ * start script, the swagger document in its emended form, and, when
155
+ * requested, the e2e tests. A package name replaces the placeholder in every
156
+ * file.
157
+ *
158
+ * Template filtering and renaming scale with template/output bytes;
159
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
160
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
161
+ * first-route precedence with logarithmic updates, and each escape probes
162
+ * only the current D-segment path rather than scanning R routes. Trie state
163
+ * holds original/final prefixes only and is local to generation.
164
+ *
165
+ * The instance’s route analysis is reused; mode/config-dependent output is
166
+ * recomputed with fresh accessor copies, and returned maps remain
167
+ * caller-owned.
168
+ *
169
+ * @evidence contracts/common.md#principled-implementation The context is built as for `nest`, the template entries of the generated trees are removed, the programmers write the replacements, and the emended document the application was built from, which is the input after any upgrade, is written beside them as `swagger.json`.
170
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators, sharing the context builder with `nest`.
171
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and no document is special-cased.
172
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
173
+ */
62
174
  sdk(config) {
63
175
  const context = createContext("sdk", this.data_, config);
64
176
  const files = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, Object.fromEntries(Object.entries(SDK_TEMPLATE_1.SDK_TEMPLATE).filter(([key]) => key.startsWith("src/structures") === false &&
@@ -79,18 +191,45 @@ const createContext = (mode, application, config) => {
79
191
  };
80
192
  };
81
193
  const escapeConflictingAccessors = (routes) => {
82
- for (const route of routes)
194
+ const create = () => ({
195
+ children: new Map(),
196
+ terminal: new tstl_1.TreeSet(),
197
+ });
198
+ const root = create();
199
+ const insert = (accessor, index) => {
200
+ let node = root;
201
+ for (const segment of accessor) {
202
+ let child = node.children.get(segment);
203
+ if (child === undefined) {
204
+ child = create();
205
+ node.children.set(segment, child);
206
+ }
207
+ node = child;
208
+ }
209
+ node.terminal.insert(index);
210
+ return node;
211
+ };
212
+ const terminals = routes.map((route, index) => insert(route.accessor, index));
213
+ for (const [routeIndex, route] of routes.entries()) {
83
214
  while (true) {
84
- const neighbor = routes.find((candidate) => candidate !== route &&
85
- candidate.accessor.length < route.accessor.length &&
86
- route.accessor
87
- .slice(0, candidate.accessor.length)
88
- .every((value, index) => value === candidate.accessor[index]));
89
- if (neighbor === undefined)
215
+ let node = root;
216
+ let neighborIndex = Infinity;
217
+ for (let depth = 0; depth < route.accessor.length - 1; ++depth) {
218
+ const child = node.children.get(route.accessor[depth]);
219
+ if (child === undefined)
220
+ break;
221
+ node = child;
222
+ if (!node.terminal.empty())
223
+ neighborIndex = Math.min(neighborIndex, node.terminal.begin().value);
224
+ }
225
+ if (neighborIndex === Infinity)
90
226
  break;
91
- const index = neighbor.accessor.length - 1;
92
- route.accessor[index] = `_${route.accessor[index]}`;
227
+ const conflict = routes[neighborIndex].accessor.length - 1;
228
+ route.accessor[conflict] = `_${route.accessor[conflict]}`;
93
229
  }
230
+ terminals[routeIndex].terminal.erase(routeIndex);
231
+ insert(route.accessor, routeIndex);
232
+ }
94
233
  return routes;
95
234
  };
96
235
  const renameSlug = (slug, files) => {
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateApplication.js","sourceRoot":"","sources":["../src/NestiaMigrateApplication.ts"],"names":[],"mappings":";;;AAUA,wCAA+D;AAE/D,2DAAwD;AACxD,yDA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AAM,CAAC,aAAa,CAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5D,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,CAAC;QACD,SAAS,CAAC,UAAU,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CACjB,IAAY,EACZ,KAA6B,EACL,EAAE;IAC1B,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC1C,GAAG;QACH,KAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KAChD,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -5,15 +5,66 @@ import { NestiaMigrateApiStartProgrammer } from "./programmers/NestiaMigrateApiS
5
5
  import { NestiaMigrateE2eProgrammer } from "./programmers/NestiaMigrateE2eProgrammer.mjs";
6
6
  import { NestiaMigrateNestProgrammer } from "./programmers/NestiaMigrateNestProgrammer.mjs";
7
7
  import { HttpMigration, OpenApiConverter } from "@typia/utils";
8
+ import { TreeSet } from "tstl";
8
9
  //#region src/NestiaMigrateApplication.ts
10
+ /**
11
+ * Converts an OpenAPI document into a NestJS project or an SDK project, as a
12
+ * map from file path to file content.
13
+ *
14
+ * The constructor analyzes an emended OpenAPI document once; `assert` and
15
+ * `validate` upgrade a document of any supported version to that form first.
16
+ * `nest` and `sdk` then compose the files of the bundled template with the
17
+ * generated ones.
18
+ *
19
+ * The constructor analyzes the document once; generation walks templates and
20
+ * delegates per-route/schema emission, with the context builder’s accessor trie
21
+ * indexing strict prefixes.
22
+ *
23
+ * The instance shares its analyzed application between nest and sdk calls.
24
+ * Generation creates fresh context/accessor copies because its mode and config
25
+ * can differ.
26
+ *
27
+ * One instance retains its original document and analysis until callers release
28
+ * it; generated file maps are returned to callers rather than accumulated on
29
+ * the instance.
30
+ *
31
+ * @evidence contracts/common.md#principled-implementation The constructor analyzes the emended document into routes with `HttpMigration`, and the two generators start from the bundled template files, drop the paths the generators own (structures, functional API, controllers, feature tests), and add the generated files, so the result is the template with those trees replaced.
32
+ * @evidence contracts/common.md#clear-and-simple-design One class with two generators sharing one context builder; the accessor conflict escape and the package renaming are module-private functions.
33
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Route analysis and the OpenAPI upgrade come from `@typia/utils`, and no document, path, or type name is special-cased; QUERY-method routes are left out because the SDK has no representation for them.
34
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the class produces, when the document is analyzed, and how the two generators use the template.
35
+ */
9
36
  var NestiaMigrateApplication = class NestiaMigrateApplication {
10
37
  constructor(document) {
11
38
  this.document = document;
12
39
  this.data_ = HttpMigration.application(document);
13
40
  }
41
+ /**
42
+ * Creates the application from a document of any supported OpenAPI or Swagger
43
+ * version, and throws when the document cannot be upgraded.
44
+ *
45
+ * Version conversion and route analysis scale with the document’s routes and
46
+ * schemas; this wrapper delegates each once.
47
+ *
48
+ * @evidence contracts/common.md#principled-implementation The document is upgraded by `OpenApiConverter.upgradeDocument`, which owns the version differences, so this function only wraps a successful result.
49
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
50
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It does not repair or guess invalid documents.
51
+ * @evidence contracts/common.md#meaningful-documentation The comment states the accepted versions and the throwing behavior.
52
+ */
14
53
  static assert(document) {
15
54
  return new NestiaMigrateApplication(OpenApiConverter.upgradeDocument(document));
16
55
  }
56
+ /**
57
+ * Creates the application, or returns the failure as an `IValidation` instead
58
+ * of throwing.
59
+ *
60
+ * Version conversion and route analysis scale with the document’s routes and
61
+ * schemas; validation delegates once and formats one caught failure.
62
+ *
63
+ * @evidence contracts/common.md#principled-implementation The upgrade runs inside a `try`, and an error becomes one validation error whose path is the input and whose value is the message, so a caller can report it.
64
+ * @evidence contracts/common.md#clear-and-simple-design The non-throwing twin of `assert`, sharing its constructor call.
65
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The failure is reported, not hidden, and the message is the original one.
66
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result shape.
67
+ */
17
68
  static validate(document) {
18
69
  try {
19
70
  return {
@@ -32,9 +83,46 @@ var NestiaMigrateApplication = class NestiaMigrateApplication {
32
83
  };
33
84
  }
34
85
  }
86
+ /**
87
+ * Returns the analyzed application: the routes and the operations that could
88
+ * not be migrated.
89
+ *
90
+ * Returning the existing analysis reference uses constant work.
91
+ *
92
+ * The constructor’s analysis is returned directly to every caller; callers
93
+ * receive mutable shared state rather than an independently refreshed view.
94
+ *
95
+ * @evidence contracts/common.md#principled-implementation The analysis is done once in the constructor and returned by reference.
96
+ * @evidence contracts/common.md#clear-and-simple-design One accessor.
97
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It exposes what the analysis produced.
98
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is returned.
99
+ */
35
100
  getData() {
36
101
  return this.data_;
37
102
  }
103
+ /**
104
+ * Generates a NestJS monorepo project from the document.
105
+ *
106
+ * The files are the template, the controllers, the module, the DTO
107
+ * structures, the functional API, and, when requested, the e2e tests. A
108
+ * package name replaces the placeholder in every file.
109
+ *
110
+ * Template filtering and renaming scale with template/output bytes;
111
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
112
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
113
+ * first-route precedence with logarithmic updates, and each escape probes
114
+ * only the current D-segment path rather than scanning R routes. Trie state
115
+ * holds original/final prefixes only and is local to generation.
116
+ *
117
+ * The instance’s route analysis is reused. Each call recomputes
118
+ * mode/config-dependent output and copies accessors because conflict escaping
119
+ * mutates them; returned maps remain caller-owned.
120
+ *
121
+ * @evidence contracts/common.md#principled-implementation The context copies the routes and escapes accessors that would collide with a shorter accessor, the template entries of the generated trees are removed, the programmers write the replacements, and `keyword: false` rewrites the one template setting that selects keyword parameters.
122
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators; each generator owns its own files.
123
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and the only textual edit of it is the documented keyword setting.
124
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
125
+ */
38
126
  nest(config) {
39
127
  const context = createContext("nest", this.data_, config);
40
128
  const files = {
@@ -46,6 +134,30 @@ var NestiaMigrateApplication = class NestiaMigrateApplication {
46
134
  };
47
135
  return config.package ? renameSlug(config.package, files) : files;
48
136
  }
137
+ /**
138
+ * Generates an SDK project from the document.
139
+ *
140
+ * The files are the template, the DTO structures, the functional API, the
141
+ * start script, the swagger document in its emended form, and, when
142
+ * requested, the e2e tests. A package name replaces the placeholder in every
143
+ * file.
144
+ *
145
+ * Template filtering and renaming scale with template/output bytes;
146
+ * programmers traverse routes and schemas. Accessor conflict escape indexes R
147
+ * routes with at most D segments in a trie. Ordered terminal sets preserve
148
+ * first-route precedence with logarithmic updates, and each escape probes
149
+ * only the current D-segment path rather than scanning R routes. Trie state
150
+ * holds original/final prefixes only and is local to generation.
151
+ *
152
+ * The instance’s route analysis is reused; mode/config-dependent output is
153
+ * recomputed with fresh accessor copies, and returned maps remain
154
+ * caller-owned.
155
+ *
156
+ * @evidence contracts/common.md#principled-implementation The context is built as for `nest`, the template entries of the generated trees are removed, the programmers write the replacements, and the emended document the application was built from, which is the input after any upgrade, is written beside them as `swagger.json`.
157
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators, sharing the context builder with `nest`.
158
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The template is the published starter, and no document is special-cased.
159
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the package renaming.
160
+ */
49
161
  sdk(config) {
50
162
  const context = createContext("sdk", this.data_, config);
51
163
  const files = {
@@ -73,11 +185,41 @@ const createContext = (mode, application, config) => {
73
185
  };
74
186
  };
75
187
  const escapeConflictingAccessors = (routes) => {
76
- for (const route of routes) while (true) {
77
- const neighbor = routes.find((candidate) => candidate !== route && candidate.accessor.length < route.accessor.length && route.accessor.slice(0, candidate.accessor.length).every((value, index) => value === candidate.accessor[index]));
78
- if (neighbor === void 0) break;
79
- const index = neighbor.accessor.length - 1;
80
- route.accessor[index] = `_${route.accessor[index]}`;
188
+ const create = () => ({
189
+ children: /* @__PURE__ */ new Map(),
190
+ terminal: new TreeSet()
191
+ });
192
+ const root = create();
193
+ const insert = (accessor, index) => {
194
+ let node = root;
195
+ for (const segment of accessor) {
196
+ let child = node.children.get(segment);
197
+ if (child === void 0) {
198
+ child = create();
199
+ node.children.set(segment, child);
200
+ }
201
+ node = child;
202
+ }
203
+ node.terminal.insert(index);
204
+ return node;
205
+ };
206
+ const terminals = routes.map((route, index) => insert(route.accessor, index));
207
+ for (const [routeIndex, route] of routes.entries()) {
208
+ while (true) {
209
+ let node = root;
210
+ let neighborIndex = Infinity;
211
+ for (let depth = 0; depth < route.accessor.length - 1; ++depth) {
212
+ const child = node.children.get(route.accessor[depth]);
213
+ if (child === void 0) break;
214
+ node = child;
215
+ if (!node.terminal.empty()) neighborIndex = Math.min(neighborIndex, node.terminal.begin().value);
216
+ }
217
+ if (neighborIndex === Infinity) break;
218
+ const conflict = routes[neighborIndex].accessor.length - 1;
219
+ route.accessor[conflict] = `_${route.accessor[conflict]}`;
220
+ }
221
+ terminals[routeIndex].terminal.erase(routeIndex);
222
+ insert(route.accessor, routeIndex);
81
223
  }
82
224
  return routes;
83
225
  };
@@ -1,5 +1,6 @@
1
1
  //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
3
4
  var __exportAll = (all, no_symbols) => {
4
5
  let target = {};
5
6
  for (var name in all) __defProp(target, name, {
@@ -9,5 +10,9 @@ var __exportAll = (all, no_symbols) => {
9
10
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
11
  return target;
11
12
  };
13
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
14
+ if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
16
+ });
12
17
  //#endregion
13
- export { __exportAll };
18
+ export { __commonJSMin, __exportAll, __require };
@@ -1,6 +1,43 @@
1
1
  import { IHttpMigrateRoute } from "@typia/interface";
2
2
  import { INestiaMigrateController } from "../structures/INestiaMigrateController";
3
+ /**
4
+ * Groups the routes of an application into NestJS controllers.
5
+ *
6
+ * Generated controller locations use portable slash spelling and directoryName
7
+ * applies Windows filename constraints on every host: invalid/control
8
+ * characters and trailing dots/spaces become underscores, and device names,
9
+ * including extension and superscript-digit forms, receive a prefix. Router
10
+ * paths retain their original URL meaning. Directory normalization is
11
+ * intentionally many-to-one; distinct controllers retain their own filenames.
12
+ * Host filesystem case policy is not inferred.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation Routes are grouped by the controller name from the operation, or by the capitalized accessor prefix, and each controller path is the longest path prefix shared by all of its routes, so one controller covers one resource path.
15
+ * @evidence contracts/common.md#clear-and-simple-design One namespace with the grouping and the path formatting, and small private helpers for the shared-prefix computation.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Names and paths derive from the document, with no route or controller name special-cased.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
18
+ */
3
19
  export declare namespace NestiaMigrateControllerAnalyzer {
20
+ /**
21
+ * Returns the controllers of the routes, each with its name, its path, its
22
+ * source location, and its routes.
23
+ *
24
+ * The name is the `x-samchon-controller` extension of the operation when
25
+ * present, and otherwise the capitalized accessor prefix followed by
26
+ * `Controller`.
27
+ *
28
+ * Generated controller locations use portable slash spelling and
29
+ * directoryName applies Windows filename constraints on every host:
30
+ * invalid/control characters and trailing dots/spaces become underscores, and
31
+ * device names, including extension and superscript-digit forms, receive a
32
+ * prefix. Router paths retain their original URL meaning. Directory
33
+ * normalization is intentionally many-to-one; distinct controllers retain
34
+ * their own filenames. Host filesystem case policy is not inferred.
35
+ *
36
+ * @evidence contracts/common.md#principled-implementation Grouping uses a map keyed by controller name, and the common path prefix and the directory prefix are found by removing every segment after the first difference across the routes, so a controller path is a prefix of every route it owns.
37
+ * @evidence contracts/common.md#clear-and-simple-design One function with two phases: grouping, then prefix computation.
38
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The extension name is part of the generated document contract; no other name is assumed.
39
+ * @evidence contracts/common.md#meaningful-documentation The comment states how the name and the path are chosen.
40
+ */
4
41
  const analyze: (routes: IHttpMigrateRoute[]) => INestiaMigrateController[];
5
42
  /**
6
43
  * The route's path as NestJS reads it: each path parameter under the key its
@@ -13,6 +50,14 @@ export declare namespace NestiaMigrateControllerAnalyzer {
13
50
  * A literal character the router reserves is escaped, so an AIP custom
14
51
  * method's `/items:batchGet` stays a literal rather than a parameter
15
52
  * `batchGet`, and `(` or `*` no syntax error.
53
+ *
54
+ * This operation emits router protocol spelling and does not select native
55
+ * filenames or filesystem identities.
56
+ *
57
+ * @evidence contracts/common.md#principled-implementation The path template is split into literal and parameter segments, and every character that path-to-regexp treats specially in a literal is escaped with a backslash, so a literal never changes the route's meaning.
58
+ * @evidence contracts/common.md#clear-and-simple-design One expression over the shared path segmenter.
59
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The reserved set is the router's syntax and is applied to every literal.
60
+ * @evidence contracts/common.md#meaningful-documentation The comment states the escaping and the parameter form.
16
61
  */
17
62
  const routePath: (route: IHttpMigrateRoute) => string;
18
63
  }