"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBelongsToDirectiveTransformer = void 0;
const belongs_to_directive_ddb_fields_transformer_1 = require("./belongs-to-directive-ddb-fields-transformer");
const belongs_to_directive_ddb_references_transformer_1 = require("./belongs-to-directive-ddb-references-transformer");
const belongs_to_directive_sql_transformer_1 = require("./belongs-to-directive-sql-transformer");
const belongsToDirectiveMySqlTransformer = new belongs_to_directive_sql_transformer_1.BelongsToDirectiveSQLTransformer();
const belongsToDirectivePostgresTransformer = new belongs_to_directive_sql_transformer_1.BelongsToDirectiveSQLTransformer();
const belongsToDirectiveDdbFieldsTransformer = new belongs_to_directive_ddb_fields_transformer_1.BelongsToDirectiveDDBFieldsTransformer();
const belongsToDirectiveDdbReferencesTransformer = new belongs_to_directive_ddb_references_transformer_1.BelongsToDirectiveDDBReferencesTransformer();
const getBelongsToDirectiveTransformer = (dbType, config) => {
    switch (dbType) {
        case 'MYSQL':
            return belongsToDirectiveMySqlTransformer;
        case 'POSTGRES':
            return belongsToDirectivePostgresTransformer;
        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 @belongsTo directive on ${config.field.name.value} - empty references list`);
                }
                return belongsToDirectiveDdbReferencesTransformer;
            }
            return belongsToDirectiveDdbFieldsTransformer;
    }
};
exports.getBelongsToDirectiveTransformer = getBelongsToDirectiveTransformer;
//# sourceMappingURL=belongs-to-directive-transformer-factory.js.map