/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { CORE_HASH_STRUCTURE } from '../../../../../../../graph/Core_HashUtils.js';
import { hashArray } from '@finos/legend-shared';
import { Connection, } from '../../../connection/Connection.js';
/**
 * TODO: to be modularized or handled differently
 *
 * @modularize
 * See https://github.com/finos/legend-studio/issues/946
 * See https://github.com/finos/legend-studio/issues/65
 */
export var DatabaseType;
(function (DatabaseType) {
    DatabaseType["DB2"] = "DB2";
    DatabaseType["H2"] = "H2";
    DatabaseType["MemSQL"] = "MemSQL";
    DatabaseType["Sybase"] = "Sybase";
    DatabaseType["SybaseIQ"] = "SybaseIQ";
    DatabaseType["Composite"] = "Composite";
    DatabaseType["Postgres"] = "Postgres";
    DatabaseType["SqlServer"] = "SqlServer";
    DatabaseType["Hive"] = "Hive";
    DatabaseType["Snowflake"] = "Snowflake";
    DatabaseType["Databricks"] = "Databricks";
    DatabaseType["Presto"] = "Presto";
    DatabaseType["Redshift"] = "Redshift";
    DatabaseType["BigQuery"] = "BigQuery";
    DatabaseType["Spanner"] = "Spanner";
    DatabaseType["Trino"] = "Trino";
    DatabaseType["DuckDB"] = "DuckDB";
})(DatabaseType || (DatabaseType = {}));
export class DatabaseConnection extends Connection {
    /**
     * For convenience, we use a Typescript enum instead of the native
     * Pure enumeration meta::relational::runtime::DatabaseType
     *
     * @discrepancy model
     */
    type;
    timeZone;
    quoteIdentifiers;
    queryTimeOutInSeconds;
    postProcessorWithParameter = [];
    queryGenerationConfigs = [];
    constructor(store, type) {
        super(store);
        this.type = type;
    }
}
export class RelationalDatabaseConnection extends DatabaseConnection {
    datasourceSpecification;
    authenticationStrategy;
    postProcessors = [];
    /**
     * HACKY: this is done to quickly add support for local connection
     * See https://github.com/finos/legend-engine/pull/1807
     */
    localMode;
    constructor(store, type, datasourceSpecification, authenticationStrategy) {
        super(store, type);
        this.datasourceSpecification = datasourceSpecification;
        this.authenticationStrategy = authenticationStrategy;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.RELATIONAL_DATABASE_CONNECTION,
            this.store?.valueForSerialization ?? '',
            this.timeZone ?? '',
            this.quoteIdentifiers?.toString() ?? '',
            this.datasourceSpecification,
            this.authenticationStrategy,
            this.localMode?.toString() ?? '',
            this.queryTimeOutInSeconds?.toString() ?? '',
            hashArray(this.postProcessors),
            hashArray(this.queryGenerationConfigs),
        ]);
    }
    accept_ConnectionVisitor(visitor) {
        return visitor.visit_RelationalDatabaseConnection(this);
    }
}
//# sourceMappingURL=RelationalDatabaseConnection.js.map