"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePivotTables = void 0;
/* eslint-disable no-await-in-loop */
const path = require("node:path");
const config_1 = require("../../config");
const types_1 = require("../../types");
const utils_1 = require("../../utils");
const generatePivotTables = async (generateCommandState) => {
    for (const property of generateCommandState.schema.properties.withRelationshipManyToMany) {
        // only create table if has in pivotPath
        if (property.pivotPath === `${generateCommandState.schema.boundedContextName}/${generateCommandState.schema.moduleName}`) {
            // create module files
            await utils_1.TemplateGenerator.generateStaticContents(generateCommandState.command, types_1.TemplateElement.BACK_PIVOT, path.join('src', config_1.cliterConfig.appContainer), generateCommandState.schema.boundedContextName.toLowerCase().toKebabCase(), {
                boundedContextName: generateCommandState.schema.boundedContextName,
                moduleName: generateCommandState.schema.moduleName,
                moduleNames: generateCommandState.schema.moduleNames,
                force: generateCommandState.flags.force,
                verbose: generateCommandState.flags.verbose,
                excludeFiles: generateCommandState.schema.excluded,
                lockFiles: generateCommandState.lockFiles,
                templateData: {
                    ...generateCommandState,
                    relationship: types_1.SqlRelationship,
                },
                currentProperty: property,
            });
            /* FileManager.generateContents(
                generateCommandState.command,
                path.join(TemplateGenerator.templatePath,  ...TemplateElement.BACK_PIVOT.split('/')),
                path.join('src', cliterConfig.appContainer), // relativeTargetBasePath
                generateCommandState.schema.boundedContextName.toLowerCase().toKebabCase(), // relativeTargetPath,
                {
                    boundedContextName: generateCommandState.schema.boundedContextName,
                    moduleName        : generateCommandState.schema.moduleName,
                    moduleNames       : generateCommandState.schema.moduleNames,
                    force             : generateCommandState.flags.force,
                    verbose           : generateCommandState.flags.verbose,
                    excludeFiles      : generateCommandState.schema.excluded,
                    lockFiles         : generateCommandState.lockFiles,
                    templateData      : { ...generateCommandState },
                    currentProperty   : property,
                },
            ); */
        }
    }
};
exports.generatePivotTables = generatePivotTables;
