import BaseApplicationGenerator from '../base-application/index.mjs';
import { GENERATOR_SPRING_DATA_COUCHBASE, GENERATOR_BOOTSTRAP_APPLICATION } from '../generator-list.mjs';
import writeCouchbaseFilesTask, { cleanupCouchbaseFilesTask } from './files.mjs';
import writeCouchbaseEntityFilesTask, { cleanupCouchbaseEntityFilesTask } from './entity-files.mjs';
export default class CouchbaseGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints(GENERATOR_SPRING_DATA_COUCHBASE);
        }
        if (!this.delegateToBlueprint) {
            await this.dependsOnJHipster(GENERATOR_BOOTSTRAP_APPLICATION);
        }
    }
    get writing() {
        return {
            cleanupCouchbaseFilesTask,
            writeCouchbaseFilesTask,
        };
    }
    get [BaseApplicationGenerator.WRITING]() {
        return this.delegateTasksToBlueprint(() => this.writing);
    }
    get writingEntities() {
        return {
            cleanupCouchbaseEntityFilesTask,
            writeCouchbaseEntityFilesTask,
        };
    }
    get [BaseApplicationGenerator.WRITING_ENTITIES]() {
        return this.delegateTasksToBlueprint(() => this.writingEntities);
    }
    get postWriting() {
        return this.asPostWritingTaskGroup({
            addDependencies({ application, source }) {
                const { reactive } = application;
                if (application.buildToolMaven) {
                    source.addMavenDependency?.([
                        {
                            groupId: 'commons-codec',
                            artifactId: 'commons-codec',
                        },
                        {
                            groupId: 'com.couchbase.client',
                            artifactId: 'java-client',
                        },
                        {
                            groupId: 'com.github.differentway',
                            artifactId: 'couchmove',
                        },
                        {
                            groupId: 'org.springframework.boot',
                            artifactId: `spring-boot-starter-data-couchbase${reactive ? '-reactive' : ''}`,
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'junit-jupiter',
                            scope: 'test',
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'testcontainers',
                            scope: 'test',
                        },
                        {
                            groupId: 'org.testcontainers',
                            artifactId: 'couchbase',
                            scope: 'test',
                        },
                    ]);
                }
            },
        });
    }
    get [BaseApplicationGenerator.POST_WRITING]() {
        return this.asPostWritingTaskGroup(this.delegateTasksToBlueprint(() => this.postWriting));
    }
}
