@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
@@ -7,11 +7,29 @@ const StatementFactory_1 = require("../factories/StatementFactory");
7
7
  const FilePrinter_1 = require("../utils/FilePrinter");
8
8
  const NestiaMigrateE2eFileProgrammer_1 = require("./NestiaMigrateE2eFileProgrammer");
9
9
  const NestiaMigrateImportProgrammer_1 = require("./NestiaMigrateImportProgrammer");
10
+ /**
11
+ * Generates the `test/start.ts` of an SDK project: a small program that calls
12
+ * one API function.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation The program builds a connection from the global test settings and the first server of the document, adds the simulate flag when requested, and calls the first route the way the generated e2e tests do, so one command can check that the SDK and a server agree.
15
+ * @evidence contracts/common.md#clear-and-simple-design One entry function and private helpers for the connection, the main function, and the starter.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The route is the first one, so the same document always generates the same file.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
18
+ */
10
19
  var NestiaMigrateApiStartProgrammer;
11
20
  (function (NestiaMigrateApiStartProgrammer) {
21
+ /**
22
+ * Returns the `test/start.ts` file of an SDK project.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation The file imports what the body uses, defines `main`, and starts it, exiting with a failure status when it rejects.
25
+ * @evidence contracts/common.md#clear-and-simple-design One function.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The content derives from the document.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
28
+ */
12
29
  NestiaMigrateApiStartProgrammer.write = (context) => {
13
30
  const importer = new NestiaMigrateImportProgrammer_1.NestiaMigrateImportProgrammer();
14
- const route = pick(context.application.routes);
31
+ // the first route, so the same document always generates the same file
32
+ const route = context.application.routes[0];
15
33
  const main = writeMain(context, importer, route);
16
34
  const statements = [
17
35
  ...importer.toStatements((name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`),
@@ -75,11 +93,4 @@ var NestiaMigrateApiStartProgrammer;
75
93
  ], true)),
76
94
  ]);
77
95
  })(NestiaMigrateApiStartProgrammer || (exports.NestiaMigrateApiStartProgrammer = NestiaMigrateApiStartProgrammer = {}));
78
- const pick = (array) => {
79
- if (array.length === 0)
80
- return undefined;
81
- const rand = Math.random() * array.length;
82
- const index = Math.min(array.length - 1, Math.floor(rand));
83
- return array[index];
84
- };
85
96
  //# sourceMappingURL=NestiaMigrateApiStartProgrammer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateApiStartProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiStartProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAG/D,sEAAmE;AACnE,oEAAiE;AAGjE,sDAAmD;AACnD,qFAAsF;AACtF,mFAAgF;AAEhF,IAAiB,+BAA+B,CA2L/C;AA3LD,WAAiB,+BAA+B;IACjC,qCAAK,GAAG,CACnB,OAA8B,EACN,EAAE;QAC1B,MAAM,QAAQ,GACZ,IAAI,6DAA6B,EAAE,CAAC;QACtC,MAAM,KAAK,GAAkC,IAAI,CAC/C,OAAO,CAAC,WAAW,CAAC,MAAM,CAC3B,CAAC;QACF,MAAM,IAAI,GAAyB,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvE,MAAM,UAAU,GAAmB;YACjC,GAAG,QAAQ,CAAC,YAAY,CACtB,CAAC,IAAI,EAAE,EAAE,CAAC,4CAA4C,IAAI,EAAE,CAC7D;YACD,yBAAW,CAAC,OAAO,EAAE;YACrB,GAAG,CAAC,KAAK,KAAK,SAAS;gBACrB,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC;oBACE,iBAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,iBAAO,CAAC,kBAAkB,CACxB,SAAS,EACT,SAAS,EACT,iBAAO,CAAC,kBAAkB,CAAC;wBACzB,iBAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,iBAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CACvC;qBACF,CAAC,CACH,EACD,iBAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAC5C;oBACD,yBAAW,CAAC,OAAO,EAAE;iBACtB,CAAC;YACN,IAAI;YACJ,iBAAO,CAAC,yBAAyB,CAAC,YAAY,EAAE,CAAC;SAClD,CAAC;QACF,OAAO;YACL,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AC,yBAAyB,CAC/B,iBAAO,CAAC,oBAAoB,CAC1B,iBAAO,CAAC,8BAA8B,CACpC,iBAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnC,KAAK,CACN,EACD,SAAS,EACT,CAAC,iBAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAClC,CACF;YACD,iBAAO,CAAC,yBAAyB,CAC/B,iBAAO,CAAC,oBAAoB,CAC1B,iBAAO,CAAC,8BAA8B,CACpC,iBAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnC,MAAM,CACP,EACD,SAAS,EACT;gBACE,iBAAO,CAAC,iBAAiB,CACvB,iBAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAClC;aACF,CACF,CACF;SACF,EACD,IAAI,CACL,CACF;KACF,CACF,CAAC;AACN,CAAC,EA3LgB,+BAA+B,aAA/B,+BAA+B,GAA/B,+BAA+B,QA2L/C;AAED,MAAM,IAAI,GAAG,CAAI,KAAU,EAAiB,EAAE;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,IAAI,GAAW,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC;IAClD,MAAM,KAAK,GAAW,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,KAAK,CAAE,CAAC;AACvB,CAAC,CAAC"}
1
+ {"version":3,"file":"NestiaMigrateApiStartProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateApiStartProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAG/D,sEAAmE;AACnE,oEAAiE;AAGjE,sDAAmD;AACnD,qFAAsF;AACtF,mFAAgF;AAEhF;;;;;;;;GAQG;AACH,IAAiB,+BAA+B,CAkM/C;AAlMD,WAAiB,+BAA+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O,CAAC,8BAA8B,CACpC,iBAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnC,MAAM,CACP,EACD,SAAS,EACT;gBACE,iBAAO,CAAC,iBAAiB,CACvB,iBAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAClC;aACF,CACF,CACF;SACF,EACD,IAAI,CACL,CACF;KACF,CACF,CAAC;AACN,CAAC,EAlMgB,+BAA+B,aAA/B,+BAA+B,GAA/B,+BAA+B,QAkM/C"}
@@ -9,7 +9,7 @@ let NestiaMigrateApiStartProgrammer;
9
9
  (function(_NestiaMigrateApiStartProgrammer) {
10
10
  _NestiaMigrateApiStartProgrammer.write = (context) => {
11
11
  const importer = new NestiaMigrateImportProgrammer();
12
- const route = pick(context.application.routes);
12
+ const route = context.application.routes[0];
13
13
  const main = writeMain(context, importer, route);
14
14
  const statements = [
15
15
  ...importer.toStatements((name) => `@ORGANIZATION/PROJECT-api/lib/structures/${name}`),
@@ -40,11 +40,6 @@ let NestiaMigrateApiStartProgrammer;
40
40
  ], true))], NodeFlags.Const));
41
41
  const writeStarter = () => factory.createCallExpression(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("main"), void 0, void 0), "catch"), void 0, [factory.createArrowFunction(void 0, void 0, [IdentifierFactory.parameter("exp")], void 0, void 0, factory.createBlock([factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("console"), "log"), void 0, [factory.createIdentifier("exp")])), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("process"), "exit"), void 0, [factory.createPrefixMinus(factory.createNumericLiteral("1"))]))], true))]);
42
42
  })(NestiaMigrateApiStartProgrammer || (NestiaMigrateApiStartProgrammer = {}));
43
- const pick = (array) => {
44
- if (array.length === 0) return void 0;
45
- const rand = Math.random() * array.length;
46
- return array[Math.min(array.length - 1, Math.floor(rand))];
47
- };
48
43
  //#endregion
49
44
  export { NestiaMigrateApiStartProgrammer };
50
45
 
@@ -2,14 +2,44 @@ import { OpenApi } from "@typia/interface";
2
2
  import ts from "../internal/ts";
3
3
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
4
4
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
5
+ /**
6
+ * Generates the DTO type aliases from the component schemas.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation Each component name is normalized into a valid dotted name, the dots become nested namespaces, and each schema becomes an exported type alias with its description and its tags as a comment.
9
+ * @evidence contracts/common.md#clear-and-simple-design One public function and private builders for the module tree and the alias.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names derive from the schema names.
11
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
12
+ */
5
13
  export declare namespace NestiaMigrateDtoProgrammer {
14
+ /**
15
+ * A node of the DTO namespace tree: its name, its children, and the writer of
16
+ * its alias, or `null` for a namespace without a type of its own.
17
+ *
18
+ * @evidence contracts/common.md#principled-implementation The tree mirrors the dotted names of the schemas, so a namespace exists exactly when a name passes through it.
19
+ * @evidence contracts/common.md#clear-and-simple-design A three-member record.
20
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
21
+ * @evidence contracts/common.md#meaningful-documentation The comment states the meaning of each member.
22
+ */
6
23
  interface IModule {
7
24
  name: string;
25
+ /** Child segments of qualified schema names, preserving insertion order. */
8
26
  children: Map<string, IModule>;
27
+ /** Alias writer for a schema at this node, or null for a namespace alone. */
9
28
  programmer: null | ((importer: NestiaMigrateImportProgrammer) => ts.TypeAliasDeclaration);
10
29
  }
30
+ /**
31
+ * Returns the root of the DTO tree: a map from the first name segment to its
32
+ * module.
33
+ *
34
+ * @evidence contracts/common.md#principled-implementation Each schema key is split on slashes, its segments are escaped into valid identifiers and joined, and the result is inserted along its dotted path.
35
+ * @evidence contracts/common.md#clear-and-simple-design One function over one insertion helper.
36
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the document.
37
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
38
+ */
11
39
  const compose: (props: {
40
+ /** Calling convention and optional generated features for this operation. */
12
41
  config: INestiaMigrateConfig;
42
+ /** Component schemas used to resolve DTO references. */
13
43
  components: OpenApi.IComponents;
14
44
  }) => Map<string, IModule>;
15
45
  }
@@ -6,8 +6,25 @@ const FilePrinter_1 = require("../utils/FilePrinter");
6
6
  const MapUtil_1 = require("../utils/MapUtil");
7
7
  const StringUtil_1 = require("../utils/StringUtil");
8
8
  const NestiaMigrateSchemaProgrammer_1 = require("./NestiaMigrateSchemaProgrammer");
9
+ /**
10
+ * Generates the DTO type aliases from the component schemas.
11
+ *
12
+ * @evidence contracts/common.md#principled-implementation Each component name is normalized into a valid dotted name, the dots become nested namespaces, and each schema becomes an exported type alias with its description and its tags as a comment.
13
+ * @evidence contracts/common.md#clear-and-simple-design One public function and private builders for the module tree and the alias.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names derive from the schema names.
15
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
16
+ */
9
17
  var NestiaMigrateDtoProgrammer;
10
18
  (function (NestiaMigrateDtoProgrammer) {
19
+ /**
20
+ * Returns the root of the DTO tree: a map from the first name segment to its
21
+ * module.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation Each schema key is split on slashes, its segments are escaped into valid identifiers and joined, and the result is inserted along its dotted path.
24
+ * @evidence contracts/common.md#clear-and-simple-design One function over one insertion helper.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the document.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
27
+ */
11
28
  NestiaMigrateDtoProgrammer.compose = (props) => {
12
29
  var _a;
13
30
  const dict = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateDtoProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateDtoProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAMpD,sDAAmD;AACnD,8CAA2C;AAC3C,oDAAiD;AAEjD,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AAI,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,GAAG,mCAAI,QAAQ,IAAI,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,KAAK,mCAAI,yDAAyD,EAAE;aAC1H;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AAEJ,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAsC,EAAE,CAC9E,OAAO,KAAK,KAAK,SAAS;IAC1B,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAO,KAAK,KAAK,QAAQ,CAAC"}
@@ -3,13 +3,52 @@ import { OpenApi } from "typia";
3
3
  import ts from "../internal/ts";
4
4
  import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
5
5
  import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
6
+ /**
7
+ * Generates the e2e test function of one route.
8
+ *
9
+ * @evidence contracts/common.md#principled-implementation The function calls the route through the SDK with random arguments made by `typia.random`, including generated headers, and asserts the response with `typia.assert`, so the test checks that the server's answer matches the declared type.
10
+ * @evidence contracts/common.md#clear-and-simple-design One entry function, one public body writer shared with the start programmer, and a private call writer.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The arguments are drawn at run time, and no route is special-cased.
12
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
13
+ */
6
14
  export declare namespace NestiaMigrateE2eFunctionProgrammer {
15
+ /**
16
+ * The input of one test function: the configuration, the components, the
17
+ * importer, and the route.
18
+ *
19
+ * @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.
20
+ * @evidence contracts/common.md#clear-and-simple-design A flat record.
21
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
22
+ * @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
23
+ */
7
24
  interface IContext {
25
+ /** Calling convention and optional generated features for this operation. */
8
26
  config: INestiaMigrateConfig;
27
+ /** Component schemas used to resolve DTO references. */
9
28
  components: OpenApi.IComponents;
29
+ /** File-local import collector shared with the surrounding file writer. */
10
30
  importer: NestiaMigrateImportProgrammer;
31
+ /** Analyzed operation, with the accessor chosen for this generation. */
11
32
  route: IHttpMigrateRoute;
12
33
  }
34
+ /**
35
+ * Returns the exported async test function of a route, named `test_api_`
36
+ * followed by its accessor.
37
+ *
38
+ * @evidence contracts/common.md#principled-implementation The name joins `test`, `api`, and the accessor with underscores, so it is unique for a route and matches the prefix that the e2e executor discovers.
39
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
40
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The name derives from the accessor.
41
+ * @evidence contracts/common.md#meaningful-documentation The comment states the naming rule.
42
+ */
13
43
  const write: (ctx: IContext) => ts.FunctionDeclaration;
44
+ /**
45
+ * Returns the statements of the test body: the call with random arguments and
46
+ * the type assertion of its output.
47
+ *
48
+ * @evidence contracts/common.md#principled-implementation The call expression follows the parameter mode of the configuration, and the output is typed by the response schema when there is one.
49
+ * @evidence contracts/common.md#clear-and-simple-design One function shared with the start programmer.
50
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The body follows the route.
51
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
52
+ */
14
53
  const writeBody: (ctx: IContext) => ts.Statement[];
15
54
  }
@@ -5,8 +5,25 @@ const factory_1 = require("@ttsc/factory");
5
5
  const IdentifierFactory_1 = require("../factories/IdentifierFactory");
6
6
  const LiteralFactory_1 = require("../factories/LiteralFactory");
7
7
  const NestiaMigrateSchemaProgrammer_1 = require("./NestiaMigrateSchemaProgrammer");
8
+ /**
9
+ * Generates the e2e test function of one route.
10
+ *
11
+ * @evidence contracts/common.md#principled-implementation The function calls the route through the SDK with random arguments made by `typia.random`, including generated headers, and asserts the response with `typia.assert`, so the test checks that the server's answer matches the declared type.
12
+ * @evidence contracts/common.md#clear-and-simple-design One entry function, one public body writer shared with the start programmer, and a private call writer.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The arguments are drawn at run time, and no route is special-cased.
14
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
15
+ */
8
16
  var NestiaMigrateE2eFunctionProgrammer;
9
17
  (function (NestiaMigrateE2eFunctionProgrammer) {
18
+ /**
19
+ * Returns the exported async test function of a route, named `test_api_`
20
+ * followed by its accessor.
21
+ *
22
+ * @evidence contracts/common.md#principled-implementation The name joins `test`, `api`, and the accessor with underscores, so it is unique for a route and matches the prefix that the e2e executor discovers.
23
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
24
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The name derives from the accessor.
25
+ * @evidence contracts/common.md#meaningful-documentation The comment states the naming rule.
26
+ */
10
27
  NestiaMigrateE2eFunctionProgrammer.write = (ctx) => factory_1.factory.createFunctionDeclaration([
11
28
  factory_1.factory.createModifier(factory_1.SyntaxKind.ExportKeyword),
12
29
  factory_1.factory.createModifier(factory_1.SyntaxKind.AsyncKeyword),
@@ -17,6 +34,15 @@ var NestiaMigrateE2eFunctionProgrammer;
17
34
  name: "api",
18
35
  })), factory_1.factory.createIdentifier("IConnection")))),
19
36
  ], undefined, factory_1.factory.createBlock(NestiaMigrateE2eFunctionProgrammer.writeBody(ctx), true));
37
+ /**
38
+ * Returns the statements of the test body: the call with random arguments and
39
+ * the type assertion of its output.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation The call expression follows the parameter mode of the configuration, and the output is typed by the response schema when there is one.
42
+ * @evidence contracts/common.md#clear-and-simple-design One function shared with the start programmer.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The body follows the route.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
45
+ */
20
46
  NestiaMigrateE2eFunctionProgrammer.writeBody = (ctx) => [
21
47
  factory_1.factory.createVariableStatement([], factory_1.factory.createVariableDeclarationList([
22
48
  factory_1.factory.createVariableDeclaration("output", undefined, ctx.route.success
@@ -35,16 +61,31 @@ var NestiaMigrateE2eFunctionProgrammer;
35
61
  ];
36
62
  const writeCallExpressionn = (ctx) => {
37
63
  const fetch = factory_1.factory.createPropertyAccessExpression(factory_1.factory.createIdentifier("api.functional"), factory_1.factory.createIdentifier(ctx.route.accessor.join(".")));
38
- const connection = factory_1.factory.createIdentifier("connection");
39
- if (ctx.route.parameters.length === 0 &&
40
- ctx.route.query === null &&
41
- ctx.route.body === null)
42
- return factory_1.factory.createCallExpression(fetch, undefined, [connection]);
43
64
  const random = factory_1.factory.createPropertyAccessExpression(factory_1.factory.createIdentifier(ctx.importer.external({
44
65
  type: "default",
45
66
  library: "typia",
46
67
  name: "typia",
47
68
  })), "random");
69
+ // the route's headers travel in the connection, as the server requires
70
+ const connection = ctx.route.headers
71
+ ? factory_1.factory.createObjectLiteralExpression([
72
+ factory_1.factory.createSpreadAssignment(factory_1.factory.createIdentifier("connection")),
73
+ factory_1.factory.createPropertyAssignment("headers", factory_1.factory.createObjectLiteralExpression([
74
+ factory_1.factory.createSpreadAssignment(factory_1.factory.createIdentifier("connection.headers")),
75
+ factory_1.factory.createSpreadAssignment(factory_1.factory.createCallExpression(random, [
76
+ NestiaMigrateSchemaProgrammer_1.NestiaMigrateSchemaProgrammer.write({
77
+ components: ctx.components,
78
+ importer: ctx.importer,
79
+ schema: ctx.route.headers.schema,
80
+ }),
81
+ ], undefined)),
82
+ ], true)),
83
+ ], true)
84
+ : factory_1.factory.createIdentifier("connection");
85
+ if (ctx.route.parameters.length === 0 &&
86
+ ctx.route.query === null &&
87
+ ctx.route.body === null)
88
+ return factory_1.factory.createCallExpression(fetch, undefined, [connection]);
48
89
  if (ctx.config.keyword === true)
49
90
  return factory_1.factory.createCallExpression(fetch, undefined, [
50
91
  connection,
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateE2eFileProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateE2eFileProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAI/D,sEAAmE;AACnE,gEAA6D;AAI7D,mFAAgF;AAEhF,I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EAAE,GAAG,CAAC,QAAQ;oBACtB,MAAM,EAAE,CAAC,CAAC,MAAM;iBACjB,CAAC;aACH,EACD,SAAS,CACV,CACF;SACJ,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,EA/IgB,kCAAkC,aAAlC,kCAAkC,GAAlC,kCAAkC,QA+IlD"}
1
+ {"version":3,"file":"NestiaMigrateE2eFileProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateE2eFileProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAI/D,sEAAmE;AACnE,gEAA6D;AAI7D,mFAAgF;AAEhF;;;;;;;GAOG;AACH,IAAiB,kCAAkC,CAkNlD;AAlND,WAAiB,kCAAkC;IAwBjD;;;;;;;;OAQG;IACU,wCAAK,GAAG,CAAC,GAAa,EAA0B,EAAE,CAC7D,iBAAO,CAAC,yBAAyB,CAC/B;QACE,iBAAO,CAAC,cAAc,CAAC,oBAAU,CAAC,aAAa,CAAC;QAChD,iBAAO,CAAC,cAAc,CAAC,oBAAU,CAAC,YAAY,CAAC;KAChD,EACD,SAAS,EACT,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAChD,SAAS,EACT;QACE,qCAAiB,CAAC,SAAS,CACzB,YAAY,EACZ,iBAAO,CAAC,uBAAuB,CAC7B,iBAAO,CAAC,mBAAmB,CACzB,iBAAO,CAAC,gBAAgB,CACtB,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACpB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,2BAA2B;YACpC,IAAI,EAAE,KAAK;SACZ,CAAC,CACH,EACD,iBAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CACxC,CACF,CACF;KACF,EACD,SAAS,EACT,iBAAO,CAAC,WAAW,CAAC,4CAAS,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAC1C,CAAC;IAEJ;;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AAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,EAlNgB,kCAAkC,aAAlC,kCAAkC,GAAlC,kCAAkC,QAkNlD"}
@@ -25,13 +25,17 @@ let NestiaMigrateE2eFunctionProgrammer;
25
25
  })), "assert"), void 0, [factory.createIdentifier("output")]))];
26
26
  const writeCallExpressionn = (ctx) => {
27
27
  const fetch = factory.createPropertyAccessExpression(factory.createIdentifier("api.functional"), factory.createIdentifier(ctx.route.accessor.join(".")));
28
- const connection = factory.createIdentifier("connection");
29
- if (ctx.route.parameters.length === 0 && ctx.route.query === null && ctx.route.body === null) return factory.createCallExpression(fetch, void 0, [connection]);
30
28
  const random = factory.createPropertyAccessExpression(factory.createIdentifier(ctx.importer.external({
31
29
  type: "default",
32
30
  library: "typia",
33
31
  name: "typia"
34
32
  })), "random");
33
+ const connection = ctx.route.headers ? factory.createObjectLiteralExpression([factory.createSpreadAssignment(factory.createIdentifier("connection")), factory.createPropertyAssignment("headers", factory.createObjectLiteralExpression([factory.createSpreadAssignment(factory.createIdentifier("connection.headers")), factory.createSpreadAssignment(factory.createCallExpression(random, [NestiaMigrateSchemaProgrammer.write({
34
+ components: ctx.components,
35
+ importer: ctx.importer,
36
+ schema: ctx.route.headers.schema
37
+ })], void 0))], true))], true) : factory.createIdentifier("connection");
38
+ if (ctx.route.parameters.length === 0 && ctx.route.query === null && ctx.route.body === null) return factory.createCallExpression(fetch, void 0, [connection]);
35
39
  if (ctx.config.keyword === true) return factory.createCallExpression(fetch, void 0, [connection, LiteralFactory.write(Object.fromEntries([
36
40
  ...ctx.route.parameters,
37
41
  ctx.route.query,
@@ -1,4 +1,20 @@
1
1
  import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
2
+ /**
3
+ * Generates the e2e test files, one per route.
4
+ *
5
+ * @evidence contracts/common.md#principled-implementation Each route becomes a file whose path depends on the mode and whose imports are resolved through the package name for a monorepo and through the built library path otherwise.
6
+ * @evidence contracts/common.md#clear-and-simple-design One public function and one private file writer.
7
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the accessors.
8
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
9
+ */
2
10
  export declare namespace NestiaMigrateE2eProgrammer {
11
+ /**
12
+ * Returns the map from file path to content of the e2e tests.
13
+ *
14
+ * @evidence contracts/common.md#principled-implementation The file name is `test_api_` plus the accessor, so each route has exactly one file.
15
+ * @evidence contracts/common.md#clear-and-simple-design One function.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the accessors.
17
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
18
+ */
3
19
  const write: (ctx: INestiaMigrateContext) => Record<string, string>;
4
20
  }
@@ -4,8 +4,24 @@ exports.NestiaMigrateE2eProgrammer = void 0;
4
4
  const FilePrinter_1 = require("../utils/FilePrinter");
5
5
  const NestiaMigrateE2eFileProgrammer_1 = require("./NestiaMigrateE2eFileProgrammer");
6
6
  const NestiaMigrateImportProgrammer_1 = require("./NestiaMigrateImportProgrammer");
7
+ /**
8
+ * Generates the e2e test files, one per route.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation Each route becomes a file whose path depends on the mode and whose imports are resolved through the package name for a monorepo and through the built library path otherwise.
11
+ * @evidence contracts/common.md#clear-and-simple-design One public function and one private file writer.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The layout follows the accessors.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
14
+ */
7
15
  var NestiaMigrateE2eProgrammer;
8
16
  (function (NestiaMigrateE2eProgrammer) {
17
+ /**
18
+ * Returns the map from file path to content of the e2e tests.
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The file name is `test_api_` plus the accessor, so each route has exactly one file.
21
+ * @evidence contracts/common.md#clear-and-simple-design One function.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The names follow the accessors.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
24
+ */
9
25
  NestiaMigrateE2eProgrammer.write = (ctx) => Object.fromEntries(ctx.application.routes
10
26
  .map((r) => writeFile(ctx.mode, ctx.config, ctx.application.document().components, r))
11
27
  .map((r) => [`${r.location}/${r.file}`, r.content]));
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateE2eProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateE2eProgrammer.ts"],"names":[],"mappings":";;;AAMA,sDAAmD;AACnD,qFAAsF;AACtF,mFAAgF;AAEhF,IAAiB,0BAA0B,CAmD1C;AAnDD,WAAiB,0BAA0B;IAC5B,gCAAK,GAAG,CAAC,GAA0B,EAA0B,EAAE,CAC1E,MAAM,CAAC,WAAW,CAChB,GAAG,CAAC,WAAW,CAAC,MAAM;SACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT,SAAS,CACP,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,UAAU,EACrC,CAAC,CACF,CACF;SACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CACtD,CAAC;IAEJ,MAAM,SAAS,GAAG,CAChB,IAAmC,EACnC,MAA4B,EAC5B,UAA+B,EAC/B,KAAwB,EACJ,EAAE;QACtB,MAAM,QAAQ,GACZ,IAAI,6DAA6B,EAAE,CAAC;QACtC,MAAM,IAAI,GACR,mEAAkC,CAAC,KAAK,CAAC;YACvC,MAAM;YACN,UAAU;YACV,QAAQ;YACR,KAAK;SACN,CAAC,CAAC;QACL,MAAM,UAAU,GAAmB;YACjC,uEAAuE;YACvE,sEAAsE;YACtE,wDAAwD;YACxD,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAChC,IAAI,KAAK,MAAM;gBACb,CAAC,CAAC,2BAA2B;gBAC7B,CAAC,CAAC,4CAA4C,IAAI,EA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AAM,QAAQ,GACZ,IAAI,6DAA6B,EAAE,CAAC;QACtC,MAAM,IAAI,GACR,mEAAkC,CAAC,KAAK,CAAC;YACvC,MAAM;YACN,UAAU;YACV,QAAQ;YACR,KAAK;SACN,CAAC,CAAC;QACL,MAAM,UAAU,GAAmB;YACjC,uEAAuE;YACvE,sEAAsE;YACtE,wDAAwD;YACxD,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAChC,IAAI,KAAK,MAAM;gBACb,CAAC,CAAC,2BAA2B;gBAC7B,CAAC,CAAC,4CAA4C,IAAI,EAAE,CACvD;YACD,yBAAW,CAAC,OAAO,EAAE;YACrB,IAAI;SACL,CAAC;QACF,OAAO;YACL,QAAQ,EACN,IAAI,KAAK,MAAM;gBACb,CAAC,CAAC,oCAAoC;gBACtC,CAAC,CAAC,mBAAmB;YACzB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK;YAC1D,OAAO,EAAE,yBAAW,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;SAC3C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EA3DgB,0BAA0B,aAA1B,0BAA0B,GAA1B,0BAA0B,QA2D1C"}
@@ -1,18 +1,93 @@
1
1
  import ts from "../internal/ts";
2
+ /**
3
+ * Collects the imports that generated code needs and turns them into import
4
+ * statements.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation External imports are grouped by library into one clause with an optional default and a set of named instances, DTO imports are grouped by module specifier and emitted type-only, and a DTO is never imported into its own file.
7
+ * @evidence contracts/common.md#clear-and-simple-design One class with two collections and one emitter; the tag helper builds `typia.tags` references.
8
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The imports follow the code that asks for them.
9
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
10
+ */
2
11
  export declare class NestiaMigrateImportProgrammer {
3
12
  private external_;
4
13
  private dtos_;
5
14
  constructor();
15
+ /**
16
+ * Reports whether no import has been requested.
17
+ *
18
+ * @evidence contracts/common.md#principled-implementation The importer is empty exactly when both collections are empty.
19
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
20
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the state.
21
+ * @evidence contracts/common.md#meaningful-documentation The comment states the meaning.
22
+ */
6
23
  empty(): boolean;
24
+ /**
25
+ * Requests an import from a library and returns the local name to use.
26
+ *
27
+ * The returned name is the first segment of the requested name, so a nested
28
+ * name such as `tags.Type` imports `tags`.
29
+ *
30
+ * @evidence contracts/common.md#principled-implementation A default import replaces the clause's default and an instance import adds a named import, and the first segment of a dotted name is what the code refers to.
31
+ * @evidence contracts/common.md#clear-and-simple-design One function over one map.
32
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The library and the name come from the caller.
33
+ * @evidence contracts/common.md#meaningful-documentation The comment states the returned name.
34
+ */
7
35
  external(props: MigrateImportProgrammer.IProps): string;
36
+ /**
37
+ * Requests a DTO import and returns a reference to it, qualified by a
38
+ * namespace when one is given.
39
+ *
40
+ * @evidence contracts/common.md#principled-implementation The DTO is recorded by the first segment of its dotted name, which is the file that exports it, and the returned reference keeps the full name, with the namespace prepended when one is given.
41
+ * @evidence contracts/common.md#clear-and-simple-design One function over one set.
42
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The name comes from the caller.
43
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
44
+ */
8
45
  dto(name: string, namespace?: string): ts.TypeReferenceNode;
46
+ /**
47
+ * Requests the `typia` tags import and returns a reference to a tag with an
48
+ * optional literal argument.
49
+ *
50
+ * @evidence contracts/common.md#principled-implementation The argument is converted to a literal type, so `Minimum<3>` is written as a type reference with the literal.
51
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the literal building.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The tag name and the argument come from the caller.
53
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
54
+ */
9
55
  tag(type: string, arg?: any): ts.TypeReferenceNode;
56
+ /**
57
+ * Returns the import statements: the external imports, a blank line when both
58
+ * kinds exist, and the type-only DTO imports.
59
+ *
60
+ * @evidence contracts/common.md#principled-implementation DTO names are grouped by the specifier that `dtoPath` returns, a name equal to the current file is skipped so a file never imports itself, and package specifiers merge into one clause.
61
+ * @evidence contracts/common.md#clear-and-simple-design One function with two emit sections.
62
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The specifier rule is the caller's.
63
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result and the self-import rule.
64
+ */
10
65
  toStatements(dtoPath: (name: string) => string, current?: string): ts.Statement[];
11
66
  }
67
+ /**
68
+ * Types of the importer: the properties of an external import request.
69
+ *
70
+ * @evidence contracts/common.md#principled-implementation The record names the import kind, the library, and the name.
71
+ * @evidence contracts/common.md#clear-and-simple-design One namespace with one interface.
72
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It contains types only.
73
+ * @evidence contracts/common.md#meaningful-documentation The comment names its content.
74
+ */
12
75
  export declare namespace MigrateImportProgrammer {
76
+ /**
77
+ * An external import request: `default` or `instance`, the library, and the
78
+ * name.
79
+ *
80
+ * @evidence contracts/common.md#principled-implementation The kind selects between the default clause and a named import.
81
+ * @evidence contracts/common.md#clear-and-simple-design A three-field record.
82
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
83
+ * @evidence contracts/common.md#meaningful-documentation The comment states each field.
84
+ */
13
85
  interface IProps {
86
+ /** Select the default export or a named import. */
14
87
  type: "default" | "instance";
88
+ /** Module specifier emitted in the import declaration. */
15
89
  library: string;
90
+ /** Requested binding; named imports use its leading dotted segment. */
16
91
  name: string;
17
92
  }
18
93
  }
@@ -5,14 +5,42 @@ const factory_1 = require("@ttsc/factory");
5
5
  const TypeLiteralFactory_1 = require("../factories/TypeLiteralFactory");
6
6
  const FilePrinter_1 = require("../utils/FilePrinter");
7
7
  const MapUtil_1 = require("../utils/MapUtil");
8
+ /**
9
+ * Collects the imports that generated code needs and turns them into import
10
+ * statements.
11
+ *
12
+ * @evidence contracts/common.md#principled-implementation External imports are grouped by library into one clause with an optional default and a set of named instances, DTO imports are grouped by module specifier and emitted type-only, and a DTO is never imported into its own file.
13
+ * @evidence contracts/common.md#clear-and-simple-design One class with two collections and one emitter; the tag helper builds `typia.tags` references.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The imports follow the code that asks for them.
15
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
16
+ */
8
17
  class NestiaMigrateImportProgrammer {
9
18
  constructor() {
10
19
  this.external_ = new Map();
11
20
  this.dtos_ = new Set();
12
21
  }
22
+ /**
23
+ * Reports whether no import has been requested.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation The importer is empty exactly when both collections are empty.
26
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the state.
28
+ * @evidence contracts/common.md#meaningful-documentation The comment states the meaning.
29
+ */
13
30
  empty() {
14
31
  return this.external_.size === 0 && this.dtos_.size === 0;
15
32
  }
33
+ /**
34
+ * Requests an import from a library and returns the local name to use.
35
+ *
36
+ * The returned name is the first segment of the requested name, so a nested
37
+ * name such as `tags.Type` imports `tags`.
38
+ *
39
+ * @evidence contracts/common.md#principled-implementation A default import replaces the clause's default and an instance import adds a named import, and the first segment of a dotted name is what the code refers to.
40
+ * @evidence contracts/common.md#clear-and-simple-design One function over one map.
41
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The library and the name come from the caller.
42
+ * @evidence contracts/common.md#meaningful-documentation The comment states the returned name.
43
+ */
16
44
  external(props) {
17
45
  const clause = MapUtil_1.MapUtil.take(this.external_)(props.library)(() => ({
18
46
  default: null,
@@ -25,13 +53,31 @@ class NestiaMigrateImportProgrammer {
25
53
  clause.instances.add(name);
26
54
  return name;
27
55
  }
56
+ /**
57
+ * Requests a DTO import and returns a reference to it, qualified by a
58
+ * namespace when one is given.
59
+ *
60
+ * @evidence contracts/common.md#principled-implementation The DTO is recorded by the first segment of its dotted name, which is the file that exports it, and the returned reference keeps the full name, with the namespace prepended when one is given.
61
+ * @evidence contracts/common.md#clear-and-simple-design One function over one set.
62
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The name comes from the caller.
63
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
64
+ */
28
65
  dto(name, namespace) {
29
- const file = name.split(".")[0];
30
- this.dtos_.add(file);
66
+ const segments = name.split(".");
67
+ this.dtos_.add(segments[0]);
31
68
  return factory_1.factory.createTypeReferenceNode((namespace === null || namespace === void 0 ? void 0 : namespace.length)
32
- ? factory_1.factory.createQualifiedName(factory_1.factory.createIdentifier(namespace), factory_1.factory.createIdentifier(file))
69
+ ? segments.reduce((left, segment) => factory_1.factory.createQualifiedName(left, factory_1.factory.createIdentifier(segment)), factory_1.factory.createIdentifier(namespace))
33
70
  : name);
34
71
  }
72
+ /**
73
+ * Requests the `typia` tags import and returns a reference to a tag with an
74
+ * optional literal argument.
75
+ *
76
+ * @evidence contracts/common.md#principled-implementation The argument is converted to a literal type, so `Minimum<3>` is written as a type reference with the literal.
77
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the literal building.
78
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The tag name and the argument come from the caller.
79
+ * @evidence contracts/common.md#meaningful-documentation The comment states the reference.
80
+ */
35
81
  tag(type, arg) {
36
82
  const instance = this.external({
37
83
  type: "instance",
@@ -40,6 +86,15 @@ class NestiaMigrateImportProgrammer {
40
86
  });
41
87
  return factory_1.factory.createTypeReferenceNode(`${instance}.${type}`, arg === undefined ? [] : [TypeLiteralFactory_1.TypeLiteralFactory.generate(arg)]);
42
88
  }
89
+ /**
90
+ * Returns the import statements: the external imports, a blank line when both
91
+ * kinds exist, and the type-only DTO imports.
92
+ *
93
+ * @evidence contracts/common.md#principled-implementation DTO names are grouped by the specifier that `dtoPath` returns, a name equal to the current file is skipped so a file never imports itself, and package specifiers merge into one clause.
94
+ * @evidence contracts/common.md#clear-and-simple-design One function with two emit sections.
95
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The specifier rule is the caller's.
96
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result and the self-import rule.
97
+ */
43
98
  toStatements(dtoPath, current) {
44
99
  // Group the DTO references by their resolved module specifier: relative
45
100
  // specifiers stay one-import-per-file, while package specifiers (e.g. the
@@ -1 +1 @@
1
- {"version":3,"file":"NestiaMigrateImportProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAEpD,wEAAqE;AAErE,sDAAmD;AACnD,8CAA2C;AAE3C;IAIE;QAHQ,cAAS,GAAyB,IAAI,GAAG,EAAE,CAAC;QAC5C,UAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEjB,CAAC;IAEhB,KAAK;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;IAC5D,CAAC;IAEM,QAAQ,CAAC,KAAqC;QACnD,MAAM,MAAM,GAAY,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YACzE,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,GAAG,EAAE;SACrB,CAAC,CAAC,CAAC;QACJ,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC;;YACrD,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,C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CACxB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACjB,iBAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,iBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAC/B,CACF,CACF,CACF,EACD,iBAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,CACvC,CACF;SACF,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"NestiaMigrateImportProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAqE;AAErE,wEAAqE;AAErE,sDAAmD;AACnD,8CAA2C;AAE3C;;;;;;;;GAQG;AACH;IAIE;QAHQ,cAAS,GAAyB,IAAI,GAAG,EAAE,CAAC;QAC5C,UAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEjB,CAAC;IAEvB;;;;;;;OAOG;IACI,KAAK;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;;OAUG;IACI,QAAQ,CAAC,KAAqC;QACnD,MAAM,MAAM,GAAY,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YACzE,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI,GAAG,EAAE;SACrB,CAAC,CAAC,CAAC;QACJ,MAAM,IAAI,GAAW,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC;;YACrD,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,OA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