"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHasOneDirectiveTransformer = void 0;
const has_one_directive_ddb_fields_transformer_1 = require("./has-one-directive-ddb-fields-transformer");
const has_one_directive_sql_transformer_1 = require("./has-one-directive-sql-transformer");
const has_one_directive_ddb_references_transformer_1 = require("./has-one-directive-ddb-references-transformer");
const hasOneDirectiveMySqlTransformer = new has_one_directive_sql_transformer_1.HasOneDirectiveSQLTransformer();
const hasOneDirectivePostgresTransformer = new has_one_directive_sql_transformer_1.HasOneDirectiveSQLTransformer();
const hasOneDirectiveDdbFieldsTransformer = new has_one_directive_ddb_fields_transformer_1.HasOneDirectiveDDBFieldsTransformer();
const hasOneDirectiveDdbReferencesTransformer = new has_one_directive_ddb_references_transformer_1.HasOneDirectiveDDBReferencesTransformer();
const getHasOneDirectiveTransformer = (dbType, config) => {
    switch (dbType) {
        case 'MYSQL':
            return hasOneDirectiveMySqlTransformer;
        case 'POSTGRES':
            return hasOneDirectivePostgresTransformer;
        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 hasOneDirectiveDdbReferencesTransformer;
            }
            return hasOneDirectiveDdbFieldsTransformer;
    }
};
exports.getHasOneDirectiveTransformer = getHasOneDirectiveTransformer;
//# sourceMappingURL=has-one-directive-transformer-factory.js.map