@nestia/migrate 6.0.6 → 7.0.0-dev.20250606
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/README.md +92 -92
 - package/lib/NestiaMigrateApplication.d.ts +23 -0
 - package/lib/NestiaMigrateApplication.js +17522 -0
 - package/lib/NestiaMigrateApplication.js.map +1 -0
 - package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +5 -0
 - package/lib/analyzers/{MigrateControllerAnalyzer.js → NestiaMigrateControllerAnalyzer.js} +10 -10
 - package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.d.ts +8 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.js +36 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -0
 - package/lib/bundles/NEST_TEMPLATE.d.ts +1 -5
 - package/lib/bundles/NEST_TEMPLATE.js +50 -242
 - package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
 - package/lib/bundles/SDK_TEMPLATE.d.ts +1 -5
 - package/lib/bundles/SDK_TEMPLATE.js +23 -107
 - package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
 - package/lib/{internal/MigrateCommander.d.ts → executable/NestiaMigrateCommander.d.ts} +1 -1
 - package/lib/{internal/MigrateCommander.js → executable/NestiaMigrateCommander.js} +23 -21
 - package/lib/executable/NestiaMigrateCommander.js.map +1 -0
 - package/lib/{internal/MigrateInquirer.d.ts → executable/NestiaMigrateInquirer.d.ts} +2 -1
 - package/lib/{internal/MigrateInquirer.js → executable/NestiaMigrateInquirer.js} +22 -9
 - package/lib/executable/NestiaMigrateInquirer.js.map +1 -0
 - package/lib/executable/migrate.js +2 -2
 - package/lib/executable/migrate.js.map +1 -1
 - package/lib/index.mjs +10041 -693
 - package/lib/index.mjs.map +1 -1
 - package/lib/module.d.ts +2 -5
 - package/lib/module.js +2 -5
 - package/lib/module.js.map +1 -1
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +13 -0
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.js +40 -0
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +132 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +237 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +4 -0
 - package/lib/programmers/{MigrateApiProgrammer.js → NestiaMigrateApiProgrammer.js} +31 -30
 - package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +14 -0
 - package/lib/programmers/{MigrateApiSimulationProgrammer.js → NestiaMigrateApiSimulationProgrammer.js} +54 -36
 - package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +4 -0
 - package/lib/programmers/{MigrateApiStartProgrammer.js → NestiaMigrateApiStartProgrammer.js} +23 -20
 - package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +15 -0
 - package/lib/programmers/{MigrateDtoProgrammer.js → NestiaMigrateDtoProgrammer.js} +14 -10
 - package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +81 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +4 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.js +32 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -0
 - package/lib/programmers/{MigrateImportProgrammer.d.ts → NestiaMigrateImportProgrammer.d.ts} +1 -1
 - package/lib/programmers/{MigrateImportProgrammer.js → NestiaMigrateImportProgrammer.js} +4 -4
 - package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +12 -0
 - package/lib/programmers/{MigrateNestControllerProgrammer.js → NestiaMigrateNestControllerProgrammer.js} +20 -13
 - package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +15 -0
 - package/lib/programmers/{MigrateNestMethodProgrammer.js → NestiaMigrateNestMethodProgrammer.js} +85 -69
 - package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +5 -0
 - package/lib/programmers/{MigrateNestModuleProgrammer.js → NestiaMigrateNestModuleProgrammer.js} +6 -6
 - package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +4 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.js +65 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +10 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.js +414 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -0
 - package/lib/structures/INestiaMigrateConfig.d.ts +10 -0
 - package/lib/structures/{IHttpMigrateFile.js → INestiaMigrateConfig.js} +1 -1
 - package/lib/structures/INestiaMigrateConfig.js.map +1 -0
 - package/lib/structures/INestiaMigrateContext.d.ts +9 -0
 - package/lib/structures/INestiaMigrateContext.js +3 -0
 - package/lib/structures/INestiaMigrateContext.js.map +1 -0
 - package/lib/structures/INestiaMigrateController.d.ts +7 -0
 - package/lib/structures/{IHttpMigrateController.js → INestiaMigrateController.js} +1 -1
 - package/lib/structures/INestiaMigrateController.js.map +1 -0
 - package/lib/structures/{IHttpMigrateDto.d.ts → INestiaMigrateDto.d.ts} +2 -2
 - package/lib/structures/{IHttpMigrateRoute.js → INestiaMigrateDto.js} +1 -1
 - package/lib/structures/INestiaMigrateDto.js.map +1 -0
 - package/lib/structures/{IHttpMigrateFile.d.ts → INestiaMigrateFile.d.ts} +1 -1
 - package/lib/structures/{IHttpMigrateDto.js → INestiaMigrateFile.js} +1 -1
 - package/lib/structures/INestiaMigrateFile.js.map +1 -0
 - package/lib/structures/INestiaMigrateProgram.d.ts +9 -0
 - package/lib/structures/INestiaMigrateProgram.js +3 -0
 - package/lib/structures/INestiaMigrateProgram.js.map +1 -0
 - package/lib/structures/INestiaMigrateSchema.d.ts +4 -0
 - package/lib/structures/{IHttpMigrateProgram.js → INestiaMigrateSchema.js} +1 -1
 - package/lib/structures/INestiaMigrateSchema.js.map +1 -0
 - package/lib/utils/openapi-down-convert/converter.js +2 -2
 - package/package.json +8 -8
 - package/src/NestiaMigrateApplication.ts +144 -0
 - package/src/analyzers/{MigrateControllerAnalyzer.ts → NestiaMigrateControllerAnalyzer.ts} +51 -51
 - package/src/archivers/NestiaMigrateFileArchiver.ts +28 -0
 - package/src/bundles/NEST_TEMPLATE.ts +50 -242
 - package/src/bundles/SDK_TEMPLATE.ts +23 -107
 - package/src/{internal/MigrateCommander.ts → executable/NestiaMigrateCommander.ts} +98 -94
 - package/src/{internal/MigrateInquirer.ts → executable/NestiaMigrateInquirer.ts} +106 -89
 - package/src/executable/bundle.js +129 -127
 - package/src/executable/migrate.ts +7 -7
 - package/src/factories/TypeLiteralFactory.ts +57 -57
 - package/src/index.ts +4 -4
 - package/src/module.ts +2 -8
 - package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -0
 - package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -0
 - package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +524 -0
 - package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -0
 - package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -0
 - package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -0
 - package/src/programmers/{MigrateDtoProgrammer.ts → NestiaMigrateDtoProgrammer.ts} +101 -96
 - package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -0
 - package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -0
 - package/src/programmers/{MigrateImportProgrammer.ts → NestiaMigrateImportProgrammer.ts} +118 -118
 - package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -0
 - package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -0
 - package/src/programmers/{MigrateNestModuleProgrammer.ts → NestiaMigrateNestModuleProgrammer.ts} +65 -65
 - package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -0
 - package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -0
 - package/src/structures/INestiaMigrateConfig.ts +10 -0
 - package/src/structures/INestiaMigrateContext.ts +15 -0
 - package/src/structures/INestiaMigrateController.ts +8 -0
 - package/src/structures/{IHttpMigrateDto.ts → INestiaMigrateDto.ts} +8 -8
 - package/src/structures/{IHttpMigrateFile.ts → INestiaMigrateFile.ts} +5 -5
 - package/src/structures/INestiaMigrateProgram.ts +11 -0
 - package/src/structures/INestiaMigrateSchema.ts +4 -0
 - package/src/utils/FilePrinter.ts +38 -38
 - package/src/utils/MapUtil.ts +13 -13
 - package/src/utils/OpenApiTypeChecker.ts +73 -73
 - package/src/utils/SetupWizard.ts +12 -12
 - package/src/utils/StringUtil.ts +113 -113
 - package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
 - package/src/utils/openapi-down-convert/converter.ts +527 -527
 - package/lib/MigrateApplication.d.ts +0 -28
 - package/lib/MigrateApplication.js +0 -7994
 - package/lib/MigrateApplication.js.map +0 -1
 - package/lib/analyzers/MigrateApplicationAnalyzer.d.ts +0 -4
 - package/lib/analyzers/MigrateApplicationAnalyzer.js +0 -12
 - package/lib/analyzers/MigrateApplicationAnalyzer.js.map +0 -1
 - package/lib/analyzers/MigrateControllerAnalyzer.d.ts +0 -7
 - package/lib/analyzers/MigrateControllerAnalyzer.js.map +0 -1
 - package/lib/archivers/MigrateFileArchiver.d.ts +0 -8
 - package/lib/archivers/MigrateFileArchiver.js +0 -35
 - package/lib/archivers/MigrateFileArchiver.js.map +0 -1
 - package/lib/internal/MigrateCommander.js.map +0 -1
 - package/lib/internal/MigrateInquirer.js.map +0 -1
 - package/lib/programmers/MigrateApiFileProgrammer.d.ts +0 -11
 - package/lib/programmers/MigrateApiFileProgrammer.js +0 -30
 - package/lib/programmers/MigrateApiFileProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateApiFunctionProgrammer.js +0 -102
 - package/lib/programmers/MigrateApiFunctionProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateApiNamespaceProgrammer.js +0 -142
 - package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateApiProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiSimulationProgrammer.d.ts +0 -8
 - package/lib/programmers/MigrateApiSimulationProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiStartProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateApiStartProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateDtoProgrammer.d.ts +0 -12
 - package/lib/programmers/MigrateDtoProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateE2eFileProgrammer.d.ts +0 -8
 - package/lib/programmers/MigrateE2eFileProgrammer.js +0 -45
 - package/lib/programmers/MigrateE2eFileProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateE2eProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateE2eProgrammer.js +0 -25
 - package/lib/programmers/MigrateE2eProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateImportProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestControllerProgrammer.d.ts +0 -7
 - package/lib/programmers/MigrateNestControllerProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestMethodProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateNestMethodProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestModuleProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateNestModuleProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateNestProgrammer.js +0 -69
 - package/lib/programmers/MigrateNestProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateSchemaProgrammer.d.ts +0 -6
 - package/lib/programmers/MigrateSchemaProgrammer.js +0 -335
 - package/lib/programmers/MigrateSchemaProgrammer.js.map +0 -1
 - package/lib/structures/IHttpMigrateController.d.ts +0 -7
 - package/lib/structures/IHttpMigrateController.js.map +0 -1
 - package/lib/structures/IHttpMigrateDto.js.map +0 -1
 - package/lib/structures/IHttpMigrateFile.js.map +0 -1
 - package/lib/structures/IHttpMigrateProgram.d.ts +0 -33
 - package/lib/structures/IHttpMigrateProgram.js.map +0 -1
 - package/lib/structures/IHttpMigrateRoute.d.ts +0 -1
 - package/lib/structures/IHttpMigrateRoute.js.map +0 -1
 - package/lib/structures/IHttpMigrateSchema.d.ts +0 -4
 - package/lib/structures/IHttpMigrateSchema.js +0 -3
 - package/lib/structures/IHttpMigrateSchema.js.map +0 -1
 - package/src/MigrateApplication.ts +0 -124
 - package/src/analyzers/MigrateApplicationAnalyzer.ts +0 -18
 - package/src/archivers/MigrateFileArchiver.ts +0 -38
 - package/src/programmers/MigrateApiFileProgrammer.ts +0 -51
 - package/src/programmers/MigrateApiFunctionProgrammer.ts +0 -213
 - package/src/programmers/MigrateApiNamespaceProgrammer.ts +0 -418
 - package/src/programmers/MigrateApiProgrammer.ts +0 -104
 - package/src/programmers/MigrateApiSimulationProgrammer.ts +0 -324
 - package/src/programmers/MigrateApiStartProgrammer.ts +0 -194
 - package/src/programmers/MigrateE2eFileProgrammer.ts +0 -117
 - package/src/programmers/MigrateE2eProgrammer.ts +0 -34
 - package/src/programmers/MigrateNestControllerProgrammer.ts +0 -57
 - package/src/programmers/MigrateNestMethodProgrammer.ts +0 -397
 - package/src/programmers/MigrateNestProgrammer.ts +0 -84
 - package/src/programmers/MigrateSchemaProgrammer.ts +0 -378
 - package/src/structures/IHttpMigrateController.ts +0 -8
 - package/src/structures/IHttpMigrateProgram.ts +0 -35
 - package/src/structures/IHttpMigrateRoute.ts +0 -1
 - package/src/structures/IHttpMigrateSchema.ts +0 -4
 
| 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { OpenApi } from "@samchon/openapi";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import ts from "typescript";
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { INestiaMigrateController } from "../structures/INestiaMigrateController";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import { FilePrinter } from "../utils/FilePrinter";
         
     | 
| 
      
 7 
     | 
    
         
            +
            import { StringUtil } from "../utils/StringUtil";
         
     | 
| 
      
 8 
     | 
    
         
            +
            import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
         
     | 
| 
      
 9 
     | 
    
         
            +
            import { NestiaMigrateNestMethodProgrammer } from "./NestiaMigrateNestMethodProgrammer";
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            export namespace NestiaMigrateNestControllerProgrammer {
         
     | 
| 
      
 12 
     | 
    
         
            +
              export interface IProps {
         
     | 
| 
      
 13 
     | 
    
         
            +
                config: INestiaMigrateConfig;
         
     | 
| 
      
 14 
     | 
    
         
            +
                components: OpenApi.IComponents;
         
     | 
| 
      
 15 
     | 
    
         
            +
                controller: INestiaMigrateController;
         
     | 
| 
      
 16 
     | 
    
         
            +
              }
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              export const write = (props: IProps): ts.Statement[] => {
         
     | 
| 
      
 19 
     | 
    
         
            +
                const importer: NestiaMigrateImportProgrammer =
         
     | 
| 
      
 20 
     | 
    
         
            +
                  new NestiaMigrateImportProgrammer();
         
     | 
| 
      
 21 
     | 
    
         
            +
                const $class = ts.factory.createClassDeclaration(
         
     | 
| 
      
 22 
     | 
    
         
            +
                  [
         
     | 
| 
      
 23 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 24 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 25 
     | 
    
         
            +
                        ts.factory.createIdentifier(
         
     | 
| 
      
 26 
     | 
    
         
            +
                          importer.external({
         
     | 
| 
      
 27 
     | 
    
         
            +
                            type: "instance",
         
     | 
| 
      
 28 
     | 
    
         
            +
                            library: "@nestjs/common",
         
     | 
| 
      
 29 
     | 
    
         
            +
                            name: "Controller",
         
     | 
| 
      
 30 
     | 
    
         
            +
                          }),
         
     | 
| 
      
 31 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 32 
     | 
    
         
            +
                        [],
         
     | 
| 
      
 33 
     | 
    
         
            +
                        [ts.factory.createStringLiteral(props.controller.path)],
         
     | 
| 
      
 34 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 35 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 36 
     | 
    
         
            +
                    ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
         
     | 
| 
      
 37 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 38 
     | 
    
         
            +
                  props.controller.name,
         
     | 
| 
      
 39 
     | 
    
         
            +
                  [],
         
     | 
| 
      
 40 
     | 
    
         
            +
                  [],
         
     | 
| 
      
 41 
     | 
    
         
            +
                  props.controller.routes
         
     | 
| 
      
 42 
     | 
    
         
            +
                    .map((route, index) => [
         
     | 
| 
      
 43 
     | 
    
         
            +
                      ...(index !== 0 ? [FilePrinter.newLine() as any] : []),
         
     | 
| 
      
 44 
     | 
    
         
            +
                      NestiaMigrateNestMethodProgrammer.write({
         
     | 
| 
      
 45 
     | 
    
         
            +
                        config: props.config,
         
     | 
| 
      
 46 
     | 
    
         
            +
                        components: props.components,
         
     | 
| 
      
 47 
     | 
    
         
            +
                        controller: props.controller,
         
     | 
| 
      
 48 
     | 
    
         
            +
                        importer,
         
     | 
| 
      
 49 
     | 
    
         
            +
                        route,
         
     | 
| 
      
 50 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 51 
     | 
    
         
            +
                    ])
         
     | 
| 
      
 52 
     | 
    
         
            +
                    .flat(),
         
     | 
| 
      
 53 
     | 
    
         
            +
                );
         
     | 
| 
      
 54 
     | 
    
         
            +
                return [
         
     | 
| 
      
 55 
     | 
    
         
            +
                  ...importer.toStatements(
         
     | 
| 
      
 56 
     | 
    
         
            +
                    (ref) =>
         
     | 
| 
      
 57 
     | 
    
         
            +
                      `${"../".repeat(
         
     | 
| 
      
 58 
     | 
    
         
            +
                        StringUtil.splitWithNormalization(props.controller.location)
         
     | 
| 
      
 59 
     | 
    
         
            +
                          .length - 1,
         
     | 
| 
      
 60 
     | 
    
         
            +
                      )}api/structures/${ref}`,
         
     | 
| 
      
 61 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ...(importer.empty() ? [] : [FilePrinter.newLine()]),
         
     | 
| 
      
 63 
     | 
    
         
            +
                  $class,
         
     | 
| 
      
 64 
     | 
    
         
            +
                ];
         
     | 
| 
      
 65 
     | 
    
         
            +
              };
         
     | 
| 
      
 66 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,406 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import ts from "typescript";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import { TypeFactory } from "typia/lib/factories/TypeFactory";
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
         
     | 
| 
      
 9 
     | 
    
         
            +
            import { INestiaMigrateController } from "../structures/INestiaMigrateController";
         
     | 
| 
      
 10 
     | 
    
         
            +
            import { FilePrinter } from "../utils/FilePrinter";
         
     | 
| 
      
 11 
     | 
    
         
            +
            import { StringUtil } from "../utils/StringUtil";
         
     | 
| 
      
 12 
     | 
    
         
            +
            import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
         
     | 
| 
      
 13 
     | 
    
         
            +
            import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            export namespace NestiaMigrateNestMethodProgrammer {
         
     | 
| 
      
 16 
     | 
    
         
            +
              export interface IContext {
         
     | 
| 
      
 17 
     | 
    
         
            +
                config: INestiaMigrateConfig;
         
     | 
| 
      
 18 
     | 
    
         
            +
                components: OpenApi.IComponents;
         
     | 
| 
      
 19 
     | 
    
         
            +
                importer: NestiaMigrateImportProgrammer;
         
     | 
| 
      
 20 
     | 
    
         
            +
                controller: INestiaMigrateController;
         
     | 
| 
      
 21 
     | 
    
         
            +
                route: IHttpMigrateRoute;
         
     | 
| 
      
 22 
     | 
    
         
            +
              }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              export const write = (ctx: IContext): ts.MethodDeclaration => {
         
     | 
| 
      
 25 
     | 
    
         
            +
                const output: ts.TypeNode = ctx.route.success
         
     | 
| 
      
 26 
     | 
    
         
            +
                  ? NestiaMigrateSchemaProgrammer.write({
         
     | 
| 
      
 27 
     | 
    
         
            +
                      components: ctx.components,
         
     | 
| 
      
 28 
     | 
    
         
            +
                      importer: ctx.importer,
         
     | 
| 
      
 29 
     | 
    
         
            +
                      schema: ctx.route.success.schema,
         
     | 
| 
      
 30 
     | 
    
         
            +
                    })
         
     | 
| 
      
 31 
     | 
    
         
            +
                  : TypeFactory.keyword("void");
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration(
         
     | 
| 
      
 34 
     | 
    
         
            +
                  [
         
     | 
| 
      
 35 
     | 
    
         
            +
                    ...writeMethodDecorators(ctx),
         
     | 
| 
      
 36 
     | 
    
         
            +
                    ts.factory.createToken(ts.SyntaxKind.PublicKeyword),
         
     | 
| 
      
 37 
     | 
    
         
            +
                    ts.factory.createToken(ts.SyntaxKind.AsyncKeyword),
         
     | 
| 
      
 38 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 39 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 40 
     | 
    
         
            +
                  ctx.route.accessor.at(-1)!,
         
     | 
| 
      
 41 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 42 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 43 
     | 
    
         
            +
                  writeParameters(ctx),
         
     | 
| 
      
 44 
     | 
    
         
            +
                  ts.factory.createTypeReferenceNode("Promise", [output]),
         
     | 
| 
      
 45 
     | 
    
         
            +
                  ts.factory.createBlock(
         
     | 
| 
      
 46 
     | 
    
         
            +
                    [
         
     | 
| 
      
 47 
     | 
    
         
            +
                      ...[
         
     | 
| 
      
 48 
     | 
    
         
            +
                        ...ctx.route.parameters.map((p) => p.key),
         
     | 
| 
      
 49 
     | 
    
         
            +
                        ...(ctx.route.headers ? ["headers"] : []),
         
     | 
| 
      
 50 
     | 
    
         
            +
                        ...(ctx.route.query ? ["query"] : []),
         
     | 
| 
      
 51 
     | 
    
         
            +
                        ...(ctx.route.body ? ["body"] : []),
         
     | 
| 
      
 52 
     | 
    
         
            +
                      ].map((str) =>
         
     | 
| 
      
 53 
     | 
    
         
            +
                        ts.factory.createExpressionStatement(
         
     | 
| 
      
 54 
     | 
    
         
            +
                          ts.factory.createIdentifier(str),
         
     | 
| 
      
 55 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 56 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 57 
     | 
    
         
            +
                      ts.factory.createReturnStatement(
         
     | 
| 
      
 58 
     | 
    
         
            +
                        ts.factory.createCallExpression(
         
     | 
| 
      
 59 
     | 
    
         
            +
                          IdentifierFactory.access(
         
     | 
| 
      
 60 
     | 
    
         
            +
                            ts.factory.createIdentifier(
         
     | 
| 
      
 61 
     | 
    
         
            +
                              ctx.importer.external({
         
     | 
| 
      
 62 
     | 
    
         
            +
                                type: "default",
         
     | 
| 
      
 63 
     | 
    
         
            +
                                library: "typia",
         
     | 
| 
      
 64 
     | 
    
         
            +
                                name: "typia",
         
     | 
| 
      
 65 
     | 
    
         
            +
                              }),
         
     | 
| 
      
 66 
     | 
    
         
            +
                            ),
         
     | 
| 
      
 67 
     | 
    
         
            +
                            "random",
         
     | 
| 
      
 68 
     | 
    
         
            +
                          ),
         
     | 
| 
      
 69 
     | 
    
         
            +
                          [output],
         
     | 
| 
      
 70 
     | 
    
         
            +
                          undefined,
         
     | 
| 
      
 71 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 72 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 73 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 74 
     | 
    
         
            +
                    true,
         
     | 
| 
      
 75 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 76 
     | 
    
         
            +
                );
         
     | 
| 
      
 77 
     | 
    
         
            +
                return FilePrinter.description(
         
     | 
| 
      
 78 
     | 
    
         
            +
                  method,
         
     | 
| 
      
 79 
     | 
    
         
            +
                  writeDescription(ctx.config, ctx.route),
         
     | 
| 
      
 80 
     | 
    
         
            +
                );
         
     | 
| 
      
 81 
     | 
    
         
            +
              };
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              const writeDescription = (
         
     | 
| 
      
 84 
     | 
    
         
            +
                config: INestiaMigrateConfig,
         
     | 
| 
      
 85 
     | 
    
         
            +
                method: IHttpMigrateRoute,
         
     | 
| 
      
 86 
     | 
    
         
            +
              ): string =>
         
     | 
| 
      
 87 
     | 
    
         
            +
                [
         
     | 
| 
      
 88 
     | 
    
         
            +
                  method.comment(),
         
     | 
| 
      
 89 
     | 
    
         
            +
                  `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
         
     | 
| 
      
 90 
     | 
    
         
            +
                ].join("\n");
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              const writeMethodDecorators = (ctx: IContext): ts.Decorator[] => {
         
     | 
| 
      
 93 
     | 
    
         
            +
                const external = (lib: string, instance: string): ts.Identifier =>
         
     | 
| 
      
 94 
     | 
    
         
            +
                  ts.factory.createIdentifier(
         
     | 
| 
      
 95 
     | 
    
         
            +
                    ctx.importer.external({
         
     | 
| 
      
 96 
     | 
    
         
            +
                      type: "instance",
         
     | 
| 
      
 97 
     | 
    
         
            +
                      library: lib,
         
     | 
| 
      
 98 
     | 
    
         
            +
                      name: instance,
         
     | 
| 
      
 99 
     | 
    
         
            +
                    }),
         
     | 
| 
      
 100 
     | 
    
         
            +
                  );
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                // EXAMPLES
         
     | 
| 
      
 103 
     | 
    
         
            +
                const decorators: ts.Decorator[] = [];
         
     | 
| 
      
 104 
     | 
    
         
            +
                if (ctx.route.success)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  decorators.push(
         
     | 
| 
      
 106 
     | 
    
         
            +
                    ...writeExampleDecorators("Response")(ctx.importer)(
         
     | 
| 
      
 107 
     | 
    
         
            +
                      ctx.route.success.media(),
         
     | 
| 
      
 108 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 109 
     | 
    
         
            +
                  );
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                // HUMAN-ONLY
         
     | 
| 
      
 112 
     | 
    
         
            +
                if (ctx.route.operation()["x-samchon-human"] === true)
         
     | 
| 
      
 113 
     | 
    
         
            +
                  decorators.push(
         
     | 
| 
      
 114 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 115 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 116 
     | 
    
         
            +
                        external("@nestia/core", "HumanRoute"),
         
     | 
| 
      
 117 
     | 
    
         
            +
                        undefined,
         
     | 
| 
      
 118 
     | 
    
         
            +
                        undefined,
         
     | 
| 
      
 119 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 120 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 121 
     | 
    
         
            +
                  );
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                // ROUTER
         
     | 
| 
      
 124 
     | 
    
         
            +
                const localPath: string = ctx.route.emendedPath
         
     | 
| 
      
 125 
     | 
    
         
            +
                  .slice(ctx.controller.path.length)
         
     | 
| 
      
 126 
     | 
    
         
            +
                  .split("/")
         
     | 
| 
      
 127 
     | 
    
         
            +
                  .filter((str) => !!str.length)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  .join("/");
         
     | 
| 
      
 129 
     | 
    
         
            +
                const router = (instance: string) =>
         
     | 
| 
      
 130 
     | 
    
         
            +
                  ts.factory.createDecorator(
         
     | 
| 
      
 131 
     | 
    
         
            +
                    ts.factory.createCallExpression(
         
     | 
| 
      
 132 
     | 
    
         
            +
                      IdentifierFactory.access(
         
     | 
| 
      
 133 
     | 
    
         
            +
                        external("@nestia/core", instance),
         
     | 
| 
      
 134 
     | 
    
         
            +
                        StringUtil.capitalize(ctx.route.method),
         
     | 
| 
      
 135 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 136 
     | 
    
         
            +
                      [],
         
     | 
| 
      
 137 
     | 
    
         
            +
                      localPath.length
         
     | 
| 
      
 138 
     | 
    
         
            +
                        ? [ts.factory.createStringLiteral(localPath)]
         
     | 
| 
      
 139 
     | 
    
         
            +
                        : undefined,
         
     | 
| 
      
 140 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 141 
     | 
    
         
            +
                  );
         
     | 
| 
      
 142 
     | 
    
         
            +
                if (ctx.route.success?.["x-nestia-encrypted"])
         
     | 
| 
      
 143 
     | 
    
         
            +
                  decorators.push(router("EncryptedRoute"));
         
     | 
| 
      
 144 
     | 
    
         
            +
                else if (ctx.route.success?.type === "text/plain")
         
     | 
| 
      
 145 
     | 
    
         
            +
                  decorators.push(
         
     | 
| 
      
 146 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 147 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 148 
     | 
    
         
            +
                        external("@nestjs/common", StringUtil.capitalize(ctx.route.method)),
         
     | 
| 
      
 149 
     | 
    
         
            +
                        [],
         
     | 
| 
      
 150 
     | 
    
         
            +
                        [ts.factory.createStringLiteral(ctx.route.path)],
         
     | 
| 
      
 151 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 152 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 153 
     | 
    
         
            +
                  );
         
     | 
| 
      
 154 
     | 
    
         
            +
                else if (ctx.route.success?.type === "application/x-www-form-urlencoded")
         
     | 
| 
      
 155 
     | 
    
         
            +
                  decorators.push(router("TypedQuery"));
         
     | 
| 
      
 156 
     | 
    
         
            +
                else if (ctx.route.method === "head")
         
     | 
| 
      
 157 
     | 
    
         
            +
                  decorators.push(
         
     | 
| 
      
 158 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 159 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 160 
     | 
    
         
            +
                        external("@nestjs/common", "Head"),
         
     | 
| 
      
 161 
     | 
    
         
            +
                        [],
         
     | 
| 
      
 162 
     | 
    
         
            +
                        [ts.factory.createStringLiteral(ctx.route.path)],
         
     | 
| 
      
 163 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 164 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 165 
     | 
    
         
            +
                  );
         
     | 
| 
      
 166 
     | 
    
         
            +
                else if (
         
     | 
| 
      
 167 
     | 
    
         
            +
                  ctx.route.success === null ||
         
     | 
| 
      
 168 
     | 
    
         
            +
                  ctx.route.success?.type === "application/json"
         
     | 
| 
      
 169 
     | 
    
         
            +
                )
         
     | 
| 
      
 170 
     | 
    
         
            +
                  decorators.push(router("TypedRoute"));
         
     | 
| 
      
 171 
     | 
    
         
            +
                for (const [key, value] of Object.entries(ctx.route.exceptions ?? {}))
         
     | 
| 
      
 172 
     | 
    
         
            +
                  decorators.push(
         
     | 
| 
      
 173 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 174 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 175 
     | 
    
         
            +
                        external("@nestia/core", "TypedException"),
         
     | 
| 
      
 176 
     | 
    
         
            +
                        [
         
     | 
| 
      
 177 
     | 
    
         
            +
                          NestiaMigrateSchemaProgrammer.write({
         
     | 
| 
      
 178 
     | 
    
         
            +
                            components: ctx.components,
         
     | 
| 
      
 179 
     | 
    
         
            +
                            importer: ctx.importer,
         
     | 
| 
      
 180 
     | 
    
         
            +
                            schema: value.schema,
         
     | 
| 
      
 181 
     | 
    
         
            +
                          }),
         
     | 
| 
      
 182 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 183 
     | 
    
         
            +
                        [
         
     | 
| 
      
 184 
     | 
    
         
            +
                          isNaN(Number(key))
         
     | 
| 
      
 185 
     | 
    
         
            +
                            ? ts.factory.createStringLiteral(key)
         
     | 
| 
      
 186 
     | 
    
         
            +
                            : ExpressionFactory.number(Number(key)),
         
     | 
| 
      
 187 
     | 
    
         
            +
                          ...(value.response().description?.length
         
     | 
| 
      
 188 
     | 
    
         
            +
                            ? [
         
     | 
| 
      
 189 
     | 
    
         
            +
                                ts.factory.createStringLiteral(
         
     | 
| 
      
 190 
     | 
    
         
            +
                                  value.response().description!,
         
     | 
| 
      
 191 
     | 
    
         
            +
                                ),
         
     | 
| 
      
 192 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 193 
     | 
    
         
            +
                            : []),
         
     | 
| 
      
 194 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 195 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 196 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 197 
     | 
    
         
            +
                  );
         
     | 
| 
      
 198 
     | 
    
         
            +
                return decorators;
         
     | 
| 
      
 199 
     | 
    
         
            +
              };
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
              const writeParameters = (ctx: IContext): ts.ParameterDeclaration[] => [
         
     | 
| 
      
 202 
     | 
    
         
            +
                ...ctx.route.parameters.map((p) =>
         
     | 
| 
      
 203 
     | 
    
         
            +
                  ts.factory.createParameterDeclaration(
         
     | 
| 
      
 204 
     | 
    
         
            +
                    [
         
     | 
| 
      
 205 
     | 
    
         
            +
                      ...writeExampleDecorators("Parameter")(ctx.importer)(p.parameter()),
         
     | 
| 
      
 206 
     | 
    
         
            +
                      ts.factory.createDecorator(
         
     | 
| 
      
 207 
     | 
    
         
            +
                        ts.factory.createCallExpression(
         
     | 
| 
      
 208 
     | 
    
         
            +
                          ts.factory.createIdentifier(
         
     | 
| 
      
 209 
     | 
    
         
            +
                            ctx.importer.external({
         
     | 
| 
      
 210 
     | 
    
         
            +
                              type: "instance",
         
     | 
| 
      
 211 
     | 
    
         
            +
                              library: "@nestia/core",
         
     | 
| 
      
 212 
     | 
    
         
            +
                              name: "TypedParam",
         
     | 
| 
      
 213 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 214 
     | 
    
         
            +
                          ),
         
     | 
| 
      
 215 
     | 
    
         
            +
                          undefined,
         
     | 
| 
      
 216 
     | 
    
         
            +
                          [ts.factory.createStringLiteral(p.key)],
         
     | 
| 
      
 217 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 218 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 219 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 220 
     | 
    
         
            +
                    undefined,
         
     | 
| 
      
 221 
     | 
    
         
            +
                    p.key,
         
     | 
| 
      
 222 
     | 
    
         
            +
                    undefined,
         
     | 
| 
      
 223 
     | 
    
         
            +
                    NestiaMigrateSchemaProgrammer.write({
         
     | 
| 
      
 224 
     | 
    
         
            +
                      components: ctx.components,
         
     | 
| 
      
 225 
     | 
    
         
            +
                      importer: ctx.importer,
         
     | 
| 
      
 226 
     | 
    
         
            +
                      schema: p.schema,
         
     | 
| 
      
 227 
     | 
    
         
            +
                    }),
         
     | 
| 
      
 228 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 229 
     | 
    
         
            +
                ),
         
     | 
| 
      
 230 
     | 
    
         
            +
                ...(ctx.route.headers
         
     | 
| 
      
 231 
     | 
    
         
            +
                  ? [
         
     | 
| 
      
 232 
     | 
    
         
            +
                      writeDtoParameter({
         
     | 
| 
      
 233 
     | 
    
         
            +
                        method: "TypedHeaders",
         
     | 
| 
      
 234 
     | 
    
         
            +
                        variable: "headers",
         
     | 
| 
      
 235 
     | 
    
         
            +
                        arguments: [],
         
     | 
| 
      
 236 
     | 
    
         
            +
                      })(ctx.components)(ctx.importer)({
         
     | 
| 
      
 237 
     | 
    
         
            +
                        required: true,
         
     | 
| 
      
 238 
     | 
    
         
            +
                        schema: ctx.route.headers.schema,
         
     | 
| 
      
 239 
     | 
    
         
            +
                        example: ctx.route.headers.example(),
         
     | 
| 
      
 240 
     | 
    
         
            +
                        examples: ctx.route.headers.examples(),
         
     | 
| 
      
 241 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 242 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 243 
     | 
    
         
            +
                  : []),
         
     | 
| 
      
 244 
     | 
    
         
            +
                ...(ctx.route.query
         
     | 
| 
      
 245 
     | 
    
         
            +
                  ? [
         
     | 
| 
      
 246 
     | 
    
         
            +
                      writeDtoParameter({
         
     | 
| 
      
 247 
     | 
    
         
            +
                        method: "TypedQuery",
         
     | 
| 
      
 248 
     | 
    
         
            +
                        variable: "query",
         
     | 
| 
      
 249 
     | 
    
         
            +
                        arguments: [],
         
     | 
| 
      
 250 
     | 
    
         
            +
                      })(ctx.components)(ctx.importer)({
         
     | 
| 
      
 251 
     | 
    
         
            +
                        required: true,
         
     | 
| 
      
 252 
     | 
    
         
            +
                        schema: ctx.route.query.schema,
         
     | 
| 
      
 253 
     | 
    
         
            +
                        example: ctx.route.query.example(),
         
     | 
| 
      
 254 
     | 
    
         
            +
                        examples: ctx.route.query.examples(),
         
     | 
| 
      
 255 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 256 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 257 
     | 
    
         
            +
                  : []),
         
     | 
| 
      
 258 
     | 
    
         
            +
                ...(ctx.route.body
         
     | 
| 
      
 259 
     | 
    
         
            +
                  ? [
         
     | 
| 
      
 260 
     | 
    
         
            +
                      writeDtoParameter({
         
     | 
| 
      
 261 
     | 
    
         
            +
                        method: ctx.route.body["x-nestia-encrypted"]
         
     | 
| 
      
 262 
     | 
    
         
            +
                          ? "EncryptedBody"
         
     | 
| 
      
 263 
     | 
    
         
            +
                          : ctx.route.body.type === "application/json"
         
     | 
| 
      
 264 
     | 
    
         
            +
                            ? "TypedBody"
         
     | 
| 
      
 265 
     | 
    
         
            +
                            : ctx.route.body.type === "application/x-www-form-urlencoded"
         
     | 
| 
      
 266 
     | 
    
         
            +
                              ? ["TypedQuery", "Body"]
         
     | 
| 
      
 267 
     | 
    
         
            +
                              : ctx.route.body.type === "text/plain"
         
     | 
| 
      
 268 
     | 
    
         
            +
                                ? "PlainBody"
         
     | 
| 
      
 269 
     | 
    
         
            +
                                : ctx.route.body.type === "multipart/form-data"
         
     | 
| 
      
 270 
     | 
    
         
            +
                                  ? ["TypedFormData", "Body"]
         
     | 
| 
      
 271 
     | 
    
         
            +
                                  : "TypedBody",
         
     | 
| 
      
 272 
     | 
    
         
            +
                        variable: "body",
         
     | 
| 
      
 273 
     | 
    
         
            +
                        arguments:
         
     | 
| 
      
 274 
     | 
    
         
            +
                          ctx.route.body.type === "multipart/form-data"
         
     | 
| 
      
 275 
     | 
    
         
            +
                            ? [
         
     | 
| 
      
 276 
     | 
    
         
            +
                                ts.factory.createArrowFunction(
         
     | 
| 
      
 277 
     | 
    
         
            +
                                  undefined,
         
     | 
| 
      
 278 
     | 
    
         
            +
                                  undefined,
         
     | 
| 
      
 279 
     | 
    
         
            +
                                  [],
         
     | 
| 
      
 280 
     | 
    
         
            +
                                  undefined,
         
     | 
| 
      
 281 
     | 
    
         
            +
                                  undefined,
         
     | 
| 
      
 282 
     | 
    
         
            +
                                  ts.factory.createCallExpression(
         
     | 
| 
      
 283 
     | 
    
         
            +
                                    ts.factory.createIdentifier(
         
     | 
| 
      
 284 
     | 
    
         
            +
                                      ctx.importer.external({
         
     | 
| 
      
 285 
     | 
    
         
            +
                                        type: "default",
         
     | 
| 
      
 286 
     | 
    
         
            +
                                        library: "multer",
         
     | 
| 
      
 287 
     | 
    
         
            +
                                        name: "Multer",
         
     | 
| 
      
 288 
     | 
    
         
            +
                                      }),
         
     | 
| 
      
 289 
     | 
    
         
            +
                                    ),
         
     | 
| 
      
 290 
     | 
    
         
            +
                                    undefined,
         
     | 
| 
      
 291 
     | 
    
         
            +
                                    undefined,
         
     | 
| 
      
 292 
     | 
    
         
            +
                                  ),
         
     | 
| 
      
 293 
     | 
    
         
            +
                                ),
         
     | 
| 
      
 294 
     | 
    
         
            +
                              ]
         
     | 
| 
      
 295 
     | 
    
         
            +
                            : [],
         
     | 
| 
      
 296 
     | 
    
         
            +
                      })(ctx.components)(ctx.importer)({
         
     | 
| 
      
 297 
     | 
    
         
            +
                        schema: ctx.route.body.schema,
         
     | 
| 
      
 298 
     | 
    
         
            +
                        required: !(
         
     | 
| 
      
 299 
     | 
    
         
            +
                          (ctx.route.body.type === "application/json" ||
         
     | 
| 
      
 300 
     | 
    
         
            +
                            ctx.route.body.type === "text/plain") &&
         
     | 
| 
      
 301 
     | 
    
         
            +
                          ctx.route.operation().requestBody?.required === false
         
     | 
| 
      
 302 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 303 
     | 
    
         
            +
                        example: ctx.route.body.media().example,
         
     | 
| 
      
 304 
     | 
    
         
            +
                        examples: ctx.route.body.media().examples,
         
     | 
| 
      
 305 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 306 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 307 
     | 
    
         
            +
                  : []),
         
     | 
| 
      
 308 
     | 
    
         
            +
              ];
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
              const writeDtoParameter =
         
     | 
| 
      
 311 
     | 
    
         
            +
                (accessor: {
         
     | 
| 
      
 312 
     | 
    
         
            +
                  method: string | [string, string];
         
     | 
| 
      
 313 
     | 
    
         
            +
                  variable: string;
         
     | 
| 
      
 314 
     | 
    
         
            +
                  arguments: ts.Expression[];
         
     | 
| 
      
 315 
     | 
    
         
            +
                }) =>
         
     | 
| 
      
 316 
     | 
    
         
            +
                (components: OpenApi.IComponents) =>
         
     | 
| 
      
 317 
     | 
    
         
            +
                (importer: NestiaMigrateImportProgrammer) =>
         
     | 
| 
      
 318 
     | 
    
         
            +
                (props: {
         
     | 
| 
      
 319 
     | 
    
         
            +
                  schema: OpenApi.IJsonSchema;
         
     | 
| 
      
 320 
     | 
    
         
            +
                  required: boolean;
         
     | 
| 
      
 321 
     | 
    
         
            +
                  example?: any;
         
     | 
| 
      
 322 
     | 
    
         
            +
                  examples?: Record<string, any>;
         
     | 
| 
      
 323 
     | 
    
         
            +
                }): ts.ParameterDeclaration => {
         
     | 
| 
      
 324 
     | 
    
         
            +
                  const instance = ts.factory.createIdentifier(
         
     | 
| 
      
 325 
     | 
    
         
            +
                    importer.external({
         
     | 
| 
      
 326 
     | 
    
         
            +
                      type: "instance",
         
     | 
| 
      
 327 
     | 
    
         
            +
                      library: "@nestia/core",
         
     | 
| 
      
 328 
     | 
    
         
            +
                      name:
         
     | 
| 
      
 329 
     | 
    
         
            +
                        typeof accessor.method === "string"
         
     | 
| 
      
 330 
     | 
    
         
            +
                          ? accessor.method
         
     | 
| 
      
 331 
     | 
    
         
            +
                          : accessor.method[0],
         
     | 
| 
      
 332 
     | 
    
         
            +
                    }),
         
     | 
| 
      
 333 
     | 
    
         
            +
                  );
         
     | 
| 
      
 334 
     | 
    
         
            +
                  return ts.factory.createParameterDeclaration(
         
     | 
| 
      
 335 
     | 
    
         
            +
                    [
         
     | 
| 
      
 336 
     | 
    
         
            +
                      ...writeExampleDecorators("Parameter")(importer)(props),
         
     | 
| 
      
 337 
     | 
    
         
            +
                      ts.factory.createDecorator(
         
     | 
| 
      
 338 
     | 
    
         
            +
                        ts.factory.createCallExpression(
         
     | 
| 
      
 339 
     | 
    
         
            +
                          typeof accessor.method === "string"
         
     | 
| 
      
 340 
     | 
    
         
            +
                            ? instance
         
     | 
| 
      
 341 
     | 
    
         
            +
                            : IdentifierFactory.access(instance, accessor.method[1]),
         
     | 
| 
      
 342 
     | 
    
         
            +
                          undefined,
         
     | 
| 
      
 343 
     | 
    
         
            +
                          accessor.arguments,
         
     | 
| 
      
 344 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 345 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 346 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 347 
     | 
    
         
            +
                    undefined,
         
     | 
| 
      
 348 
     | 
    
         
            +
                    accessor.variable,
         
     | 
| 
      
 349 
     | 
    
         
            +
                    props.required === false
         
     | 
| 
      
 350 
     | 
    
         
            +
                      ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
         
     | 
| 
      
 351 
     | 
    
         
            +
                      : undefined,
         
     | 
| 
      
 352 
     | 
    
         
            +
                    NestiaMigrateSchemaProgrammer.write({
         
     | 
| 
      
 353 
     | 
    
         
            +
                      components,
         
     | 
| 
      
 354 
     | 
    
         
            +
                      importer,
         
     | 
| 
      
 355 
     | 
    
         
            +
                      schema: props.schema,
         
     | 
| 
      
 356 
     | 
    
         
            +
                    }),
         
     | 
| 
      
 357 
     | 
    
         
            +
                  );
         
     | 
| 
      
 358 
     | 
    
         
            +
                };
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
      
 360 
     | 
    
         
            +
              const writeExampleDecorators =
         
     | 
| 
      
 361 
     | 
    
         
            +
                (kind: "Response" | "Parameter") =>
         
     | 
| 
      
 362 
     | 
    
         
            +
                (importer: NestiaMigrateImportProgrammer) =>
         
     | 
| 
      
 363 
     | 
    
         
            +
                (media: {
         
     | 
| 
      
 364 
     | 
    
         
            +
                  example?: any;
         
     | 
| 
      
 365 
     | 
    
         
            +
                  examples?: Record<string, any>;
         
     | 
| 
      
 366 
     | 
    
         
            +
                }): ts.Decorator[] => [
         
     | 
| 
      
 367 
     | 
    
         
            +
                  ...(media.example !== undefined
         
     | 
| 
      
 368 
     | 
    
         
            +
                    ? [
         
     | 
| 
      
 369 
     | 
    
         
            +
                        ts.factory.createDecorator(
         
     | 
| 
      
 370 
     | 
    
         
            +
                          ts.factory.createCallExpression(
         
     | 
| 
      
 371 
     | 
    
         
            +
                            IdentifierFactory.access(
         
     | 
| 
      
 372 
     | 
    
         
            +
                              ts.factory.createIdentifier(
         
     | 
| 
      
 373 
     | 
    
         
            +
                                importer.external({
         
     | 
| 
      
 374 
     | 
    
         
            +
                                  type: "instance",
         
     | 
| 
      
 375 
     | 
    
         
            +
                                  library: "@nestia/core",
         
     | 
| 
      
 376 
     | 
    
         
            +
                                  name: "SwaggerExample",
         
     | 
| 
      
 377 
     | 
    
         
            +
                                }),
         
     | 
| 
      
 378 
     | 
    
         
            +
                              ),
         
     | 
| 
      
 379 
     | 
    
         
            +
                              kind,
         
     | 
| 
      
 380 
     | 
    
         
            +
                            ),
         
     | 
| 
      
 381 
     | 
    
         
            +
                            [],
         
     | 
| 
      
 382 
     | 
    
         
            +
                            [LiteralFactory.write(media.example)],
         
     | 
| 
      
 383 
     | 
    
         
            +
                          ),
         
     | 
| 
      
 384 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 385 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 386 
     | 
    
         
            +
                    : []),
         
     | 
| 
      
 387 
     | 
    
         
            +
                  ...Object.entries(media.examples ?? {}).map(([key, value]) =>
         
     | 
| 
      
 388 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 389 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 390 
     | 
    
         
            +
                        IdentifierFactory.access(
         
     | 
| 
      
 391 
     | 
    
         
            +
                          ts.factory.createIdentifier(
         
     | 
| 
      
 392 
     | 
    
         
            +
                            importer.external({
         
     | 
| 
      
 393 
     | 
    
         
            +
                              type: "instance",
         
     | 
| 
      
 394 
     | 
    
         
            +
                              library: "@nestia/core",
         
     | 
| 
      
 395 
     | 
    
         
            +
                              name: "SwaggerExample",
         
     | 
| 
      
 396 
     | 
    
         
            +
                            }),
         
     | 
| 
      
 397 
     | 
    
         
            +
                          ),
         
     | 
| 
      
 398 
     | 
    
         
            +
                          kind,
         
     | 
| 
      
 399 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 400 
     | 
    
         
            +
                        [],
         
     | 
| 
      
 401 
     | 
    
         
            +
                        [ts.factory.createStringLiteral(key), LiteralFactory.write(value)],
         
     | 
| 
      
 402 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 403 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 404 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 405 
     | 
    
         
            +
                ];
         
     | 
| 
      
 406 
     | 
    
         
            +
            }
         
     | 
    
        package/src/programmers/{MigrateNestModuleProgrammer.ts → NestiaMigrateNestModuleProgrammer.ts}
    RENAMED
    
    | 
         @@ -1,65 +1,65 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import ts from "typescript";
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            import {  
     | 
| 
       4 
     | 
    
         
            -
            import { FilePrinter } from "../utils/FilePrinter";
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            export namespace  
     | 
| 
       7 
     | 
    
         
            -
              export const write = (
         
     | 
| 
       8 
     | 
    
         
            -
                controllers:  
     | 
| 
       9 
     | 
    
         
            -
              ): ts.Statement[] => [
         
     | 
| 
       10 
     | 
    
         
            -
                $import("@nestjs/common")("Module"),
         
     | 
| 
       11 
     | 
    
         
            -
                ...(controllers.length ? [FilePrinter.newLine()] : []),
         
     | 
| 
       12 
     | 
    
         
            -
                ...controllers.map((c) =>
         
     | 
| 
       13 
     | 
    
         
            -
                  $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
         
     | 
| 
       14 
     | 
    
         
            -
                ),
         
     | 
| 
       15 
     | 
    
         
            -
                ...(controllers.length ? [FilePrinter.newLine()] : []),
         
     | 
| 
       16 
     | 
    
         
            -
                ts.factory.createClassDeclaration(
         
     | 
| 
       17 
     | 
    
         
            -
                  [
         
     | 
| 
       18 
     | 
    
         
            -
                    ts.factory.createDecorator(
         
     | 
| 
       19 
     | 
    
         
            -
                      ts.factory.createCallExpression(
         
     | 
| 
       20 
     | 
    
         
            -
                        ts.factory.createIdentifier("Module"),
         
     | 
| 
       21 
     | 
    
         
            -
                        undefined,
         
     | 
| 
       22 
     | 
    
         
            -
                        [
         
     | 
| 
       23 
     | 
    
         
            -
                          ts.factory.createObjectLiteralExpression(
         
     | 
| 
       24 
     | 
    
         
            -
                            [
         
     | 
| 
       25 
     | 
    
         
            -
                              ts.factory.createPropertyAssignment(
         
     | 
| 
       26 
     | 
    
         
            -
                                ts.factory.createIdentifier("controllers"),
         
     | 
| 
       27 
     | 
    
         
            -
                                ts.factory.createArrayLiteralExpression(
         
     | 
| 
       28 
     | 
    
         
            -
                                  controllers.map((c) =>
         
     | 
| 
       29 
     | 
    
         
            -
                                    ts.factory.createIdentifier(c.name),
         
     | 
| 
       30 
     | 
    
         
            -
                                  ),
         
     | 
| 
       31 
     | 
    
         
            -
                                  true,
         
     | 
| 
       32 
     | 
    
         
            -
                                ),
         
     | 
| 
       33 
     | 
    
         
            -
                              ),
         
     | 
| 
       34 
     | 
    
         
            -
                            ],
         
     | 
| 
       35 
     | 
    
         
            -
                            true,
         
     | 
| 
       36 
     | 
    
         
            -
                          ),
         
     | 
| 
       37 
     | 
    
         
            -
                        ],
         
     | 
| 
       38 
     | 
    
         
            -
                      ),
         
     | 
| 
       39 
     | 
    
         
            -
                    ),
         
     | 
| 
       40 
     | 
    
         
            -
                    ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
         
     | 
| 
       41 
     | 
    
         
            -
                  ],
         
     | 
| 
       42 
     | 
    
         
            -
                  "MyModule",
         
     | 
| 
       43 
     | 
    
         
            -
                  undefined,
         
     | 
| 
       44 
     | 
    
         
            -
                  undefined,
         
     | 
| 
       45 
     | 
    
         
            -
                  [],
         
     | 
| 
       46 
     | 
    
         
            -
                ),
         
     | 
| 
       47 
     | 
    
         
            -
              ];
         
     | 
| 
       48 
     | 
    
         
            -
            }
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            const $import = (file: string) => (instance: string) =>
         
     | 
| 
       51 
     | 
    
         
            -
              ts.factory.createImportDeclaration(
         
     | 
| 
       52 
     | 
    
         
            -
                undefined,
         
     | 
| 
       53 
     | 
    
         
            -
                ts.factory.createImportClause(
         
     | 
| 
       54 
     | 
    
         
            -
                  false,
         
     | 
| 
       55 
     | 
    
         
            -
                  undefined,
         
     | 
| 
       56 
     | 
    
         
            -
                  ts.factory.createNamedImports([
         
     | 
| 
       57 
     | 
    
         
            -
                    ts.factory.createImportSpecifier(
         
     | 
| 
       58 
     | 
    
         
            -
                      false,
         
     | 
| 
       59 
     | 
    
         
            -
                      undefined,
         
     | 
| 
       60 
     | 
    
         
            -
                      ts.factory.createIdentifier(instance),
         
     | 
| 
       61 
     | 
    
         
            -
                    ),
         
     | 
| 
       62 
     | 
    
         
            -
                  ]),
         
     | 
| 
       63 
     | 
    
         
            -
                ),
         
     | 
| 
       64 
     | 
    
         
            -
                ts.factory.createStringLiteral(file),
         
     | 
| 
       65 
     | 
    
         
            -
              );
         
     | 
| 
      
 1 
     | 
    
         
            +
            import ts from "typescript";
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            import { INestiaMigrateController } from "../structures/INestiaMigrateController";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { FilePrinter } from "../utils/FilePrinter";
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            export namespace NestiaMigrateNestModuleProgrammer {
         
     | 
| 
      
 7 
     | 
    
         
            +
              export const write = (
         
     | 
| 
      
 8 
     | 
    
         
            +
                controllers: INestiaMigrateController[],
         
     | 
| 
      
 9 
     | 
    
         
            +
              ): ts.Statement[] => [
         
     | 
| 
      
 10 
     | 
    
         
            +
                $import("@nestjs/common")("Module"),
         
     | 
| 
      
 11 
     | 
    
         
            +
                ...(controllers.length ? [FilePrinter.newLine()] : []),
         
     | 
| 
      
 12 
     | 
    
         
            +
                ...controllers.map((c) =>
         
     | 
| 
      
 13 
     | 
    
         
            +
                  $import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
         
     | 
| 
      
 14 
     | 
    
         
            +
                ),
         
     | 
| 
      
 15 
     | 
    
         
            +
                ...(controllers.length ? [FilePrinter.newLine()] : []),
         
     | 
| 
      
 16 
     | 
    
         
            +
                ts.factory.createClassDeclaration(
         
     | 
| 
      
 17 
     | 
    
         
            +
                  [
         
     | 
| 
      
 18 
     | 
    
         
            +
                    ts.factory.createDecorator(
         
     | 
| 
      
 19 
     | 
    
         
            +
                      ts.factory.createCallExpression(
         
     | 
| 
      
 20 
     | 
    
         
            +
                        ts.factory.createIdentifier("Module"),
         
     | 
| 
      
 21 
     | 
    
         
            +
                        undefined,
         
     | 
| 
      
 22 
     | 
    
         
            +
                        [
         
     | 
| 
      
 23 
     | 
    
         
            +
                          ts.factory.createObjectLiteralExpression(
         
     | 
| 
      
 24 
     | 
    
         
            +
                            [
         
     | 
| 
      
 25 
     | 
    
         
            +
                              ts.factory.createPropertyAssignment(
         
     | 
| 
      
 26 
     | 
    
         
            +
                                ts.factory.createIdentifier("controllers"),
         
     | 
| 
      
 27 
     | 
    
         
            +
                                ts.factory.createArrayLiteralExpression(
         
     | 
| 
      
 28 
     | 
    
         
            +
                                  controllers.map((c) =>
         
     | 
| 
      
 29 
     | 
    
         
            +
                                    ts.factory.createIdentifier(c.name),
         
     | 
| 
      
 30 
     | 
    
         
            +
                                  ),
         
     | 
| 
      
 31 
     | 
    
         
            +
                                  true,
         
     | 
| 
      
 32 
     | 
    
         
            +
                                ),
         
     | 
| 
      
 33 
     | 
    
         
            +
                              ),
         
     | 
| 
      
 34 
     | 
    
         
            +
                            ],
         
     | 
| 
      
 35 
     | 
    
         
            +
                            true,
         
     | 
| 
      
 36 
     | 
    
         
            +
                          ),
         
     | 
| 
      
 37 
     | 
    
         
            +
                        ],
         
     | 
| 
      
 38 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 39 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 40 
     | 
    
         
            +
                    ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
         
     | 
| 
      
 41 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 42 
     | 
    
         
            +
                  "MyModule",
         
     | 
| 
      
 43 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 44 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 45 
     | 
    
         
            +
                  [],
         
     | 
| 
      
 46 
     | 
    
         
            +
                ),
         
     | 
| 
      
 47 
     | 
    
         
            +
              ];
         
     | 
| 
      
 48 
     | 
    
         
            +
            }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            const $import = (file: string) => (instance: string) =>
         
     | 
| 
      
 51 
     | 
    
         
            +
              ts.factory.createImportDeclaration(
         
     | 
| 
      
 52 
     | 
    
         
            +
                undefined,
         
     | 
| 
      
 53 
     | 
    
         
            +
                ts.factory.createImportClause(
         
     | 
| 
      
 54 
     | 
    
         
            +
                  false,
         
     | 
| 
      
 55 
     | 
    
         
            +
                  undefined,
         
     | 
| 
      
 56 
     | 
    
         
            +
                  ts.factory.createNamedImports([
         
     | 
| 
      
 57 
     | 
    
         
            +
                    ts.factory.createImportSpecifier(
         
     | 
| 
      
 58 
     | 
    
         
            +
                      false,
         
     | 
| 
      
 59 
     | 
    
         
            +
                      undefined,
         
     | 
| 
      
 60 
     | 
    
         
            +
                      ts.factory.createIdentifier(instance),
         
     | 
| 
      
 61 
     | 
    
         
            +
                    ),
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ]),
         
     | 
| 
      
 63 
     | 
    
         
            +
                ),
         
     | 
| 
      
 64 
     | 
    
         
            +
                ts.factory.createStringLiteral(file),
         
     | 
| 
      
 65 
     | 
    
         
            +
              );
         
     | 
| 
         @@ -0,0 +1,88 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import ts from "typescript";
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            import { NestiaMigrateControllerAnalyzer } from "../analyzers/NestiaMigrateControllerAnalyzer";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { INestiaMigrateContext } from "../structures/INestiaMigrateContext";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { INestiaMigrateController } from "../structures/INestiaMigrateController";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import { FilePrinter } from "../utils/FilePrinter";
         
     | 
| 
      
 7 
     | 
    
         
            +
            import { NestiaMigrateDtoProgrammer } from "./NestiaMigrateDtoProgrammer";
         
     | 
| 
      
 8 
     | 
    
         
            +
            import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
         
     | 
| 
      
 9 
     | 
    
         
            +
            import { NestiaMigrateNestControllerProgrammer } from "./NestiaMigrateNestControllerProgrammer";
         
     | 
| 
      
 10 
     | 
    
         
            +
            import { NestiaMigrateNestModuleProgrammer } from "./NestiaMigrateNestModuleProgrammer";
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            export namespace NestiaMigrateNestProgrammer {
         
     | 
| 
      
 13 
     | 
    
         
            +
              export const write = (
         
     | 
| 
      
 14 
     | 
    
         
            +
                context: INestiaMigrateContext,
         
     | 
| 
      
 15 
     | 
    
         
            +
              ): Record<string, string> => {
         
     | 
| 
      
 16 
     | 
    
         
            +
                const controllers: INestiaMigrateController[] =
         
     | 
| 
      
 17 
     | 
    
         
            +
                  NestiaMigrateControllerAnalyzer.analyze(context.routes);
         
     | 
| 
      
 18 
     | 
    
         
            +
                const statements: [string, ts.Statement[]][] = [
         
     | 
| 
      
 19 
     | 
    
         
            +
                  ["src/MyModule.ts", NestiaMigrateNestModuleProgrammer.write(controllers)],
         
     | 
| 
      
 20 
     | 
    
         
            +
                  ...controllers.map(
         
     | 
| 
      
 21 
     | 
    
         
            +
                    (c) =>
         
     | 
| 
      
 22 
     | 
    
         
            +
                      [
         
     | 
| 
      
 23 
     | 
    
         
            +
                        `${c.location}/${c.name}.ts`,
         
     | 
| 
      
 24 
     | 
    
         
            +
                        NestiaMigrateNestControllerProgrammer.write({
         
     | 
| 
      
 25 
     | 
    
         
            +
                          config: context.config,
         
     | 
| 
      
 26 
     | 
    
         
            +
                          components: context.document.components,
         
     | 
| 
      
 27 
     | 
    
         
            +
                          controller: c,
         
     | 
| 
      
 28 
     | 
    
         
            +
                        }),
         
     | 
| 
      
 29 
     | 
    
         
            +
                      ] satisfies [string, ts.Statement[]],
         
     | 
| 
      
 30 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 31 
     | 
    
         
            +
                  ...[
         
     | 
| 
      
 32 
     | 
    
         
            +
                    ...NestiaMigrateDtoProgrammer.compose({
         
     | 
| 
      
 33 
     | 
    
         
            +
                      config: context.config,
         
     | 
| 
      
 34 
     | 
    
         
            +
                      components: context.document.components,
         
     | 
| 
      
 35 
     | 
    
         
            +
                    }).entries(),
         
     | 
| 
      
 36 
     | 
    
         
            +
                  ].map(
         
     | 
| 
      
 37 
     | 
    
         
            +
                    ([key, value]) =>
         
     | 
| 
      
 38 
     | 
    
         
            +
                      [`src/api/structures/${key}.ts`, writeDtoFile(key, value)] satisfies [
         
     | 
| 
      
 39 
     | 
    
         
            +
                        string,
         
     | 
| 
      
 40 
     | 
    
         
            +
                        ts.Statement[],
         
     | 
| 
      
 41 
     | 
    
         
            +
                      ],
         
     | 
| 
      
 42 
     | 
    
         
            +
                  ),
         
     | 
| 
      
 43 
     | 
    
         
            +
                ];
         
     | 
| 
      
 44 
     | 
    
         
            +
                return Object.fromEntries(
         
     | 
| 
      
 45 
     | 
    
         
            +
                  statements.map(([key, value]) => [
         
     | 
| 
      
 46 
     | 
    
         
            +
                    key,
         
     | 
| 
      
 47 
     | 
    
         
            +
                    FilePrinter.write({ statements: value }),
         
     | 
| 
      
 48 
     | 
    
         
            +
                  ]),
         
     | 
| 
      
 49 
     | 
    
         
            +
                );
         
     | 
| 
      
 50 
     | 
    
         
            +
              };
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              const writeDtoFile = (
         
     | 
| 
      
 53 
     | 
    
         
            +
                key: string,
         
     | 
| 
      
 54 
     | 
    
         
            +
                modulo: NestiaMigrateDtoProgrammer.IModule,
         
     | 
| 
      
 55 
     | 
    
         
            +
              ): ts.Statement[] => {
         
     | 
| 
      
 56 
     | 
    
         
            +
                const importer = new NestiaMigrateImportProgrammer();
         
     | 
| 
      
 57 
     | 
    
         
            +
                const statements: ts.Statement[] = iterate(importer)(modulo);
         
     | 
| 
      
 58 
     | 
    
         
            +
                if (statements.length === 0) return [];
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                return [
         
     | 
| 
      
 61 
     | 
    
         
            +
                  ...importer.toStatements((name) => `./${name}`, key),
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ...(importer.empty() ? [] : [FilePrinter.newLine()]),
         
     | 
| 
      
 63 
     | 
    
         
            +
                  ...statements,
         
     | 
| 
      
 64 
     | 
    
         
            +
                ];
         
     | 
| 
      
 65 
     | 
    
         
            +
              };
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              const iterate =
         
     | 
| 
      
 68 
     | 
    
         
            +
                (importer: NestiaMigrateImportProgrammer) =>
         
     | 
| 
      
 69 
     | 
    
         
            +
                (modulo: NestiaMigrateDtoProgrammer.IModule): ts.Statement[] => {
         
     | 
| 
      
 70 
     | 
    
         
            +
                  const output: ts.Statement[] = [];
         
     | 
| 
      
 71 
     | 
    
         
            +
                  if (modulo.programmer !== null) output.push(modulo.programmer(importer));
         
     | 
| 
      
 72 
     | 
    
         
            +
                  if (modulo.children.size) {
         
     | 
| 
      
 73 
     | 
    
         
            +
                    const internal: ts.Statement[] = [];
         
     | 
| 
      
 74 
     | 
    
         
            +
                    for (const child of modulo.children.values())
         
     | 
| 
      
 75 
     | 
    
         
            +
                      internal.push(...iterate(importer)(child));
         
     | 
| 
      
 76 
     | 
    
         
            +
                    output.push(
         
     | 
| 
      
 77 
     | 
    
         
            +
                      ts.factory.createModuleDeclaration(
         
     | 
| 
      
 78 
     | 
    
         
            +
                        [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
         
     | 
| 
      
 79 
     | 
    
         
            +
                        ts.factory.createIdentifier(modulo.name),
         
     | 
| 
      
 80 
     | 
    
         
            +
                        ts.factory.createModuleBlock(internal),
         
     | 
| 
      
 81 
     | 
    
         
            +
                        ts.NodeFlags.Namespace,
         
     | 
| 
      
 82 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 83 
     | 
    
         
            +
                    );
         
     | 
| 
      
 84 
     | 
    
         
            +
                  }
         
     | 
| 
      
 85 
     | 
    
         
            +
                  output.push(FilePrinter.newLine());
         
     | 
| 
      
 86 
     | 
    
         
            +
                  return output;
         
     | 
| 
      
 87 
     | 
    
         
            +
                };
         
     | 
| 
      
 88 
     | 
    
         
            +
            }
         
     |