"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHasManyDirectiveTransformer = void 0;
const has_many_directive_ddb_fields_transformer_1 = require("./has-many-directive-ddb-fields-transformer");
const has_many_directive_sql_transformer_1 = require("./has-many-directive-sql-transformer");
const has_many_directive_ddb_references_transformer_1 = require("./has-many-directive-ddb-references-transformer");
const hasManyDirectiveMySqlTransformer = new has_many_directive_sql_transformer_1.HasManyDirectiveSQLTransformer();
const hasManyDirectivePostgresTransformer = new has_many_directive_sql_transformer_1.HasManyDirectiveSQLTransformer();
const hasManyDirectiveDdbFieldsTransformer = new has_many_directive_ddb_fields_transformer_1.HasManyDirectiveDDBFieldsTransformer();
const hasManyDirectiveDdbReferencesTransformer = new has_many_directive_ddb_references_transformer_1.HasManyDirectiveDDBReferencesTransformer();
const getHasManyDirectiveTransformer = (dbType, config) => {
    switch (dbType) {
        case 'MYSQL':
            return hasManyDirectiveMySqlTransformer;
        case 'POSTGRES':
            return hasManyDirectivePostgresTransformer;
        case 'DYNAMODB':
            if (config.references) {
                if (config.fields) {
                    throw new Error('Something went wrong >> cannot have both references and fields.');
                }
                if (config.references.length < 1) {
                    throw new Error(`Invalid @hasMany directive on ${config.field.name.value} - empty references list`);
                }
                return hasManyDirectiveDdbReferencesTransformer;
            }
            return hasManyDirectiveDdbFieldsTransformer;
    }
};
exports.getHasManyDirectiveTransformer = getHasManyDirectiveTransformer;
//# sourceMappingURL=has-many-directive-transformer-factory.js.map