"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateBulkMutationTypes = generateBulkMutationTypes;
const generator_1 = require("@postxl/generator");
function generateBulkMutationTypes(context) {
    const imports = generator_1.ImportGenerator.from(context.repositories.bulkMutation.location);
    const bulkMutations = [];
    for (const model of context.models.values()) {
        if (model.repository.kind === 'NoRepository') {
            continue;
        }
        imports.addType(model.types);
        imports.addType(model.types.id);
        bulkMutations.push(`${model.repository.bulkMutationEntry}?: BulkMutationForModel<${model.types.name}, ${model.types.id.name}>`);
    }
    imports.addType(context.types.dto.create);
    imports.addType(context.types.dto.update);
    imports.addType(context.types.dto.upsert);
    imports.addType(context.types.dto.genericModel);
    imports.addType(context.types.dto.idType);
    return /* ts */ `
${imports.generate()}

/**
 * Generic type for BulkMutation for a model.
 */
export type ${context.repositories.bulkMutationForModel.name}<Model extends ${context.types.dto.genericModel.name}<ID>, ID extends ${context.types.dto.idType.name}> = {
  create?: ${context.types.dto.create.name}<Model, ID>[]
  update?: ${context.types.dto.update.name}<Model, ID>[]
  upsert?: ${context.types.dto.upsert.name}<Model, ID>[]
  delete?: ID[]
}

/**
 * Bulk changes for all models.
 */
export type ${context.repositories.bulkMutation.name} = {
  ${bulkMutations.join(',\n')}
}
`;
}
//# sourceMappingURL=bulk-mutation-types.generator.js.map