import { SERVER_MAIN_RES_DIR } from '../generator-constants.js';
import { javaMainPackageTemplatesBlock } from '../server/support/index.js';
const domainFiles = [
    {
        condition: ctx => ctx.entityDomainLayer,
        ...javaMainPackageTemplatesBlock('_entityPackage_'),
        templates: ['domain/_persistClass_.java.jhi.spring_data_cassandra'],
    },
];
const repositoryFiles = [
    {
        condition: ctx => ctx.entityPersistenceLayer,
        ...javaMainPackageTemplatesBlock('_entityPackage_'),
        templates: ['repository/_entityClass_Repository.java', 'domain/_persistClass_.java.jhi.spring_data_cassandra'],
    },
];
export const entityFiles = {
    dbChangelog: [
        {
            condition: ctx => !ctx.skipDbChangelog,
            path: SERVER_MAIN_RES_DIR,
            templates: [
                {
                    file: 'config/cql/changelog/added_entity.cql',
                    renameTo: ctx => `config/cql/changelog/${ctx.changelogDate}_added_entity_${ctx.entityClass}.cql`,
                },
            ],
        },
    ],
    domainFiles,
    repositoryFiles,
};
export function cleanupCassandraEntityFilesTask() { }
export default async function writeEntityCassandraFiles({ application, entities }) {
    for (const entity of entities.filter(entity => !entity.skipServer)) {
        await this.writeFiles({
            sections: entity.builtIn ? { domainFiles } : entityFiles,
            context: { ...application, ...entity },
        });
    }
}
