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