@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.
- package/lib/NestiaMigrateApplication.d.ts +111 -0
- package/lib/NestiaMigrateApplication.js +148 -9
- package/lib/NestiaMigrateApplication.js.map +1 -1
- package/lib/NestiaMigrateApplication.mjs +147 -5
- package/lib/_virtual/_rolldown/runtime.mjs +6 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +45 -0
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js +59 -3
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -1
- package/lib/analyzers/NestiaMigrateControllerAnalyzer.mjs +9 -3
- package/lib/archivers/NestiaMigrateFileArchiver.d.ts +34 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js +34 -0
- package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.js +1 -1
- package/lib/bundles/NEST_TEMPLATE.mjs +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/bundles/SDK_TEMPLATE.mjs +1 -1
- package/lib/executable/NestiaMigrateCommander.d.ts +39 -1
- package/lib/executable/NestiaMigrateCommander.js +42 -2
- package/lib/executable/NestiaMigrateCommander.js.map +1 -1
- package/lib/executable/NestiaMigrateCommander.mjs +5 -3
- package/lib/executable/NestiaMigrateInquirer.d.ts +32 -1
- package/lib/executable/NestiaMigrateInquirer.js +33 -10
- package/lib/executable/NestiaMigrateInquirer.js.map +1 -1
- package/lib/executable/NestiaMigrateInquirer.mjs +4 -3
- package/lib/executable/TemplateBundleCache.d.ts +23 -0
- package/lib/executable/TemplateBundleCache.js +60 -0
- package/lib/executable/TemplateBundleCache.js.map +1 -0
- package/lib/executable/TemplateBundleCache.mjs +39 -0
- package/lib/executable/TemplateBundleCache.mjs.map +1 -0
- package/lib/executable/bundle.d.ts +1 -0
- package/lib/executable/bundle.js +404 -0
- package/lib/executable/bundle.js.map +1 -0
- package/lib/executable/bundle.mjs +324 -0
- package/lib/executable/bundle.mjs.map +1 -0
- package/lib/factories/ExpressionFactory.d.ts +14 -0
- package/lib/factories/ExpressionFactory.js +14 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +20 -0
- package/lib/factories/IdentifierFactory.js +20 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +18 -2
- package/lib/factories/LiteralFactory.js +18 -2
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +26 -1
- package/lib/factories/StatementFactory.js +26 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/SupportedStringFormats.d.ts +6 -0
- package/lib/factories/SupportedStringFormats.js +33 -0
- package/lib/factories/SupportedStringFormats.js.map +1 -0
- package/lib/factories/SupportedStringFormats.mjs +34 -0
- package/lib/factories/SupportedStringFormats.mjs.map +1 -0
- package/lib/factories/TypeFactory.d.ts +21 -0
- package/lib/factories/TypeFactory.js +13 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypeLiteralFactory.d.ts +18 -0
- package/lib/factories/TypeLiteralFactory.js +18 -0
- package/lib/factories/TypeLiteralFactory.js.map +1 -1
- package/lib/internal/ts.d.ts +153 -0
- package/lib/internal/ts.js.map +1 -1
- package/lib/package.mjs +55 -0
- package/lib/package.mjs.map +1 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +31 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +40 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +27 -0
- package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +39 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +26 -0
- package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +18 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.js +18 -0
- package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiProgrammer.mjs +1 -1
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +40 -0
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js +27 -0
- package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +17 -0
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js +19 -8
- package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateApiStartProgrammer.mjs +1 -6
- package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +30 -0
- package/lib/programmers/NestiaMigrateDtoProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +39 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +26 -0
- package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.d.ts +75 -0
- package/lib/programmers/NestiaMigrateImportProgrammer.js +58 -3
- package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateImportProgrammer.mjs +58 -3
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +28 -0
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +30 -0
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js +16 -0
- package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +17 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js +17 -0
- package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +16 -0
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js +20 -5
- package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -1
- package/lib/programmers/NestiaMigrateSchemaProgrammer.mjs +4 -4
- package/lib/structures/INestiaMigrateConfig.d.ts +21 -0
- package/lib/structures/INestiaMigrateContext.d.ts +15 -0
- package/lib/structures/INestiaMigrateController.d.ts +13 -0
- package/lib/structures/INestiaMigrateFile.d.ts +11 -0
- package/lib/utils/FilePrinter.d.ts +33 -0
- package/lib/utils/FilePrinter.js +33 -0
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +17 -0
- package/lib/utils/MapUtil.js +19 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/MapUtil.mjs +1 -2
- package/lib/utils/PathTemplate.d.ts +23 -1
- package/lib/utils/PathTemplate.js +15 -1
- package/lib/utils/PathTemplate.js.map +1 -1
- package/lib/utils/RequestBody.d.ts +13 -0
- package/lib/utils/RequestBody.js +13 -0
- package/lib/utils/RequestBody.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +55 -0
- package/lib/utils/StringUtil.js +93 -8
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/StringUtil.mjs +30 -8
- package/lib/utils/SuccessStatus.d.ts +21 -1
- package/lib/utils/SuccessStatus.js +21 -1
- package/lib/utils/SuccessStatus.js.map +1 -1
- package/package.json +5 -4
- package/src/NestiaMigrateApplication.ts +151 -13
- package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +59 -4
- package/src/archivers/NestiaMigrateFileArchiver.ts +34 -0
- package/src/bundles/NEST_TEMPLATE.ts +1 -1
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/executable/NestiaMigrateCommander.ts +44 -2
- package/src/executable/NestiaMigrateInquirer.ts +35 -3
- package/src/executable/TemplateBundleCache.ts +65 -0
- package/src/executable/{bundle.js → bundle.ts} +110 -43
- package/src/factories/ExpressionFactory.ts +14 -0
- package/src/factories/IdentifierFactory.ts +20 -0
- package/src/factories/LiteralFactory.ts +18 -2
- package/src/factories/StatementFactory.ts +26 -1
- package/src/factories/SupportedStringFormats.ts +29 -0
- package/src/factories/TypeFactory.ts +21 -0
- package/src/factories/TypeLiteralFactory.ts +18 -0
- package/src/internal/ts.ts +153 -0
- package/src/programmers/NestiaMigrateApiFileProgrammer.ts +35 -0
- package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +43 -0
- package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +42 -0
- package/src/programmers/NestiaMigrateApiProgrammer.ts +18 -0
- package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +43 -0
- package/src/programmers/NestiaMigrateApiStartProgrammer.ts +19 -10
- package/src/programmers/NestiaMigrateDtoProgrammer.ts +33 -0
- package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +42 -0
- package/src/programmers/NestiaMigrateE2eProgrammer.ts +16 -0
- package/src/programmers/NestiaMigrateImportProgrammer.ts +86 -5
- package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +30 -0
- package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +34 -0
- package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +16 -0
- package/src/programmers/NestiaMigrateNestProgrammer.ts +17 -0
- package/src/programmers/NestiaMigrateSchemaProgrammer.ts +25 -8
- package/src/structures/INestiaMigrateConfig.ts +26 -0
- package/src/structures/INestiaMigrateContext.ts +17 -0
- package/src/structures/INestiaMigrateController.ts +16 -0
- package/src/structures/INestiaMigrateFile.ts +13 -0
- package/src/utils/FilePrinter.ts +33 -0
- package/src/utils/MapUtil.ts +18 -2
- package/src/utils/PathTemplate.ts +23 -1
- package/src/utils/RequestBody.ts +13 -0
- package/src/utils/StringUtil.ts +101 -9
- package/src/utils/SuccessStatus.ts +21 -1
- package/lib/factories/FormatCheatSheet.d.ts +0 -25
- package/lib/factories/FormatCheatSheet.js +0 -34
- package/lib/factories/FormatCheatSheet.js.map +0 -1
- package/lib/factories/FormatCheatSheet.mjs +0 -31
- package/lib/factories/FormatCheatSheet.mjs.map +0 -1
- package/src/factories/FormatCheatSheet.ts +0 -71
|
@@ -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,mFAAgF;AAEhF,IAAiB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateDtoProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateDtoProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAMpD,sDAAmD;AACnD,8CAA2C;AAC3C,oDAAiD;AAEjD,mFAAgF;AAEhF;;;;;;;GAOG;AACH,IAAiB,0BAA0B,CA6F1C;AA7FD,WAAiB,0BAA0B;IAsBzC;;;;;;;;OAQG;IACU,kCAAO,GAAG,CAAC,KAMvB,EAAwB,EAAE;;QACzB,MAAM,IAAI,GAAyB,IAAI,GAAG,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,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ateConfig";
|
|
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
|
|
@@ -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,IAAiB,kCAAkC,
|
|
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,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C,UAAU;oBAC1B,QAAQ,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,EAlNgB,kCAAkC,aAAlC,kCAAkC,GAAlC,kCAAkC,QAkNlD"}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateE2eProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateE2eProgrammer.ts"],"names":[],"mappings":";;;AAMA,sDAAmD;AACnD,qFA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AAE,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
|
|
30
|
-
this.dtos_.add(
|
|
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(
|
|
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,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateImportProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateImportProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAA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,CAAC,CACvC,CACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -3,14 +3,42 @@ import { TypeLiteralFactory } from "../factories/TypeLiteralFactory.mjs";
|
|
|
3
3
|
import { MapUtil } from "../utils/MapUtil.mjs";
|
|
4
4
|
import { SyntaxKind, factory } from "@ttsc/factory";
|
|
5
5
|
//#region src/programmers/NestiaMigrateImportProgrammer.ts
|
|
6
|
+
/**
|
|
7
|
+
* Collects the imports that generated code needs and turns them into import
|
|
8
|
+
* statements.
|
|
9
|
+
*
|
|
10
|
+
* @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.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One class with two collections and one emitter; the tag helper builds `typia.tags` references.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The imports follow the code that asks for them.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
14
|
+
*/
|
|
6
15
|
var NestiaMigrateImportProgrammer = class {
|
|
7
16
|
constructor() {
|
|
8
17
|
this.external_ = /* @__PURE__ */ new Map();
|
|
9
18
|
this.dtos_ = /* @__PURE__ */ new Set();
|
|
10
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Reports whether no import has been requested.
|
|
22
|
+
*
|
|
23
|
+
* @evidence contracts/common.md#principled-implementation The importer is empty exactly when both collections are empty.
|
|
24
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
25
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the state.
|
|
26
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the meaning.
|
|
27
|
+
*/
|
|
11
28
|
empty() {
|
|
12
29
|
return this.external_.size === 0 && this.dtos_.size === 0;
|
|
13
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Requests an import from a library and returns the local name to use.
|
|
33
|
+
*
|
|
34
|
+
* The returned name is the first segment of the requested name, so a nested
|
|
35
|
+
* name such as `tags.Type` imports `tags`.
|
|
36
|
+
*
|
|
37
|
+
* @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.
|
|
38
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over one map.
|
|
39
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The library and the name come from the caller.
|
|
40
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the returned name.
|
|
41
|
+
*/
|
|
14
42
|
external(props) {
|
|
15
43
|
const clause = MapUtil.take(this.external_)(props.library)(() => ({
|
|
16
44
|
default: null,
|
|
@@ -21,11 +49,29 @@ var NestiaMigrateImportProgrammer = class {
|
|
|
21
49
|
else clause.instances.add(name);
|
|
22
50
|
return name;
|
|
23
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Requests a DTO import and returns a reference to it, qualified by a
|
|
54
|
+
* namespace when one is given.
|
|
55
|
+
*
|
|
56
|
+
* @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.
|
|
57
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over one set.
|
|
58
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The name comes from the caller.
|
|
59
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the reference.
|
|
60
|
+
*/
|
|
24
61
|
dto(name, namespace) {
|
|
25
|
-
const
|
|
26
|
-
this.dtos_.add(
|
|
27
|
-
return factory.createTypeReferenceNode(namespace?.length ? factory.createQualifiedName(factory.createIdentifier(
|
|
62
|
+
const segments = name.split(".");
|
|
63
|
+
this.dtos_.add(segments[0]);
|
|
64
|
+
return factory.createTypeReferenceNode(namespace?.length ? segments.reduce((left, segment) => factory.createQualifiedName(left, factory.createIdentifier(segment)), factory.createIdentifier(namespace)) : name);
|
|
28
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Requests the `typia` tags import and returns a reference to a tag with an
|
|
68
|
+
* optional literal argument.
|
|
69
|
+
*
|
|
70
|
+
* @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.
|
|
71
|
+
* @evidence contracts/common.md#clear-and-simple-design One function delegating the literal building.
|
|
72
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The tag name and the argument come from the caller.
|
|
73
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the reference.
|
|
74
|
+
*/
|
|
29
75
|
tag(type, arg) {
|
|
30
76
|
const instance = this.external({
|
|
31
77
|
type: "instance",
|
|
@@ -34,6 +80,15 @@ var NestiaMigrateImportProgrammer = class {
|
|
|
34
80
|
});
|
|
35
81
|
return factory.createTypeReferenceNode(`${instance}.${type}`, arg === void 0 ? [] : [TypeLiteralFactory.generate(arg)]);
|
|
36
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns the import statements: the external imports, a blank line when both
|
|
85
|
+
* kinds exist, and the type-only DTO imports.
|
|
86
|
+
*
|
|
87
|
+
* @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.
|
|
88
|
+
* @evidence contracts/common.md#clear-and-simple-design One function with two emit sections.
|
|
89
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The specifier rule is the caller's.
|
|
90
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result and the self-import rule.
|
|
91
|
+
*/
|
|
37
92
|
toStatements(dtoPath, current) {
|
|
38
93
|
const modules = /* @__PURE__ */ new Map();
|
|
39
94
|
for (const name of this.dtos_) if (current === void 0 || name !== current.split(".")[0]) MapUtil.take(modules)(dtoPath(name))(() => []).push(name);
|
|
@@ -2,11 +2,39 @@ import { OpenApi } from "@typia/interface";
|
|
|
2
2
|
import ts from "../internal/ts";
|
|
3
3
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
4
4
|
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
|
5
|
+
/**
|
|
6
|
+
* Generates the source of one NestJS controller.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/common.md#principled-implementation The controller class is decorated with `@Controller` and its path, each route becomes a method written by the configured method programmer or the default one, and the DTO types are imported by package name because they live in the API package.
|
|
9
|
+
* @evidence contracts/common.md#clear-and-simple-design One function; the method programmer is replaceable through the configuration.
|
|
10
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The replaceable programmer is a documented extension point.
|
|
11
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
|
|
12
|
+
*/
|
|
5
13
|
export declare namespace NestiaMigrateNestControllerProgrammer {
|
|
14
|
+
/**
|
|
15
|
+
* The input of one controller: the configuration, the components, and the
|
|
16
|
+
* controller.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat 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 lists the fields.
|
|
22
|
+
*/
|
|
6
23
|
interface IProps {
|
|
24
|
+
/** Generation options and an optional controller-method writer. */
|
|
7
25
|
config: INestiaMigrateConfig;
|
|
26
|
+
/** Schemas needed by generated controller method types. */
|
|
8
27
|
components: OpenApi.IComponents;
|
|
28
|
+
/** Controller name, router prefix and grouped operations. */
|
|
9
29
|
controller: INestiaMigrateController;
|
|
10
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the statements of a controller file.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/common.md#principled-implementation Blank lines separate the methods, and the imports come first.
|
|
35
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
36
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The content follows the controller.
|
|
37
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
38
|
+
*/
|
|
11
39
|
const write: (props: IProps) => ts.Statement[];
|
|
12
40
|
}
|
|
@@ -5,8 +5,24 @@ const factory_1 = require("@ttsc/factory");
|
|
|
5
5
|
const FilePrinter_1 = require("../utils/FilePrinter");
|
|
6
6
|
const NestiaMigrateImportProgrammer_1 = require("./NestiaMigrateImportProgrammer");
|
|
7
7
|
const NestiaMigrateNestMethodProgrammer_1 = require("./NestiaMigrateNestMethodProgrammer");
|
|
8
|
+
/**
|
|
9
|
+
* Generates the source of one NestJS controller.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/common.md#principled-implementation The controller class is decorated with `@Controller` and its path, each route becomes a method written by the configured method programmer or the default one, and the DTO types are imported by package name because they live in the API package.
|
|
12
|
+
* @evidence contracts/common.md#clear-and-simple-design One function; the method programmer is replaceable through the configuration.
|
|
13
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The replaceable programmer is a documented extension point.
|
|
14
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
|
|
15
|
+
*/
|
|
8
16
|
var NestiaMigrateNestControllerProgrammer;
|
|
9
17
|
(function (NestiaMigrateNestControllerProgrammer) {
|
|
18
|
+
/**
|
|
19
|
+
* Returns the statements of a controller file.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation Blank lines separate the methods, and the imports come first.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The content follows the controller.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
25
|
+
*/
|
|
10
26
|
NestiaMigrateNestControllerProgrammer.write = (props) => {
|
|
11
27
|
const importer = new NestiaMigrateImportProgrammer_1.NestiaMigrateImportProgrammer();
|
|
12
28
|
const $class = factory_1.factory.createClassDeclaration([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaMigrateNestControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateNestControllerProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAMpD,sDAAmD;AACnD,mFAAgF;AAChF,2FAAwF;AAExF,IAAiB,qCAAqC,
|
|
1
|
+
{"version":3,"file":"NestiaMigrateNestControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/NestiaMigrateNestControllerProgrammer.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAMpD,sDAAmD;AACnD,mFAAgF;AAChF,2FAAwF;AAExF;;;;;;;GAOG;AACH,IAAiB,qCAAqC,CA6ErD;AA7ED,WAAiB,qCAAqC;IAqBpD;;;;;;;OAOG;IACU,2CAAK,GAAG,CAAC,KAAa,EAAkB,EAAE;QACrD,MAAM,QAAQ,GACZ,IAAI,6DAA6B,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,iBAAO,CAAC,sBAAsB,CAC3C;YACE,iBAAO,CAAC,eAAe,CACrB,iBAAO,CAAC,oBAAoB,CAC1B,iBAAO,CAAC,gBAAgB,CACtB,QAAQ,CAAC,QAAQ,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,gBAAgB;gBACzB,IAAI,EAAE,YAAY;aACnB,CAAC,CACH,EACD,EAAE,EACF,CAAC,iBAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CACrD,CACF;YACD,iBAAO,CAAC,WAAW,CAAC,oBAAU,CAAC,aAAa,CAAC;SAC9C,EACD,KAAK,CAAC,UAAU,CAAC,IAAI,EACrB,EAAE,EACF,EAAE,EACF,KAAK,CAAC,UAAU,CAAC,MAAM;aACpB,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,0BAAC;YACrB,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,OACE,MAAA,KAAK,CAAC,MAAM,CAAC,UAAU,0CAAE,gBAAgB,mCACzC,qEAAiC,CAAC,KAAK,CACxC,CAAC;gBACA,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,QAAQ;gBACR,KAAK;aACN,CAAC;SACH,GAAA,CAAC;aACD,IAAI,EAAE,CACV,CAAC;QACF,OAAO;YACL,kEAAkE;YAClE,sEAAsE;YACtE,uDAAuD;YACvD,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC;YAC3D,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,yBAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YACpD,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EA7EgB,qCAAqC,aAArC,qCAAqC,GAArC,qCAAqC,QA6ErD"}
|
|
@@ -4,13 +4,43 @@ import ts from "../internal/ts";
|
|
|
4
4
|
import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
|
|
5
5
|
import { INestiaMigrateController } from "../structures/INestiaMigrateController";
|
|
6
6
|
import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
|
|
7
|
+
/**
|
|
8
|
+
* Generates the controller method of one route.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The method carries `TypedRoute`, `TypedException`, `HumanRoute`, and example decorators as the route requires, one parameter per path, header, query, and body input with the matching typed decorator, and a body that mentions each parameter and returns `typia.random` of the response type.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One entry function and private writers for the description, the decorators, and the parameters.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The output derives from the route; the body is a stub that returns random data because the document does not define the behavior.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what is generated.
|
|
14
|
+
*/
|
|
7
15
|
export declare namespace NestiaMigrateNestMethodProgrammer {
|
|
16
|
+
/**
|
|
17
|
+
* The input of one method: the configuration, the components, the importer,
|
|
18
|
+
* the controller, and the route.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation The record holds exactly what the generation needs.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the fields.
|
|
24
|
+
*/
|
|
8
25
|
interface IContext {
|
|
26
|
+
/** Generation options, including the author tag used on the handler. */
|
|
9
27
|
config: INestiaMigrateConfig;
|
|
28
|
+
/** Component schemas referenced by request and response types. */
|
|
10
29
|
components: OpenApi.IComponents;
|
|
30
|
+
/** Controller-file import collector shared by all its methods. */
|
|
11
31
|
importer: NestiaMigrateImportProgrammer;
|
|
32
|
+
/** Controller prefix removed from this operation's router path. */
|
|
12
33
|
controller: INestiaMigrateController;
|
|
34
|
+
/** Analyzed operation supplying method, schemas and examples. */
|
|
13
35
|
route: IHttpMigrateRoute;
|
|
14
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns the method declaration of a route.
|
|
39
|
+
*
|
|
40
|
+
* @evidence contracts/common.md#principled-implementation The decorators and the parameters follow the route's HTTP method, path relative to the controller, and inputs.
|
|
41
|
+
* @evidence contracts/common.md#clear-and-simple-design One function composing the private writers.
|
|
42
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The method follows the route.
|
|
43
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
44
|
+
*/
|
|
15
45
|
const write: (ctx: IContext) => ts.MethodDeclaration;
|
|
16
46
|
}
|