import {ISnowflakeConfig, ISnowflakeConnectionConfig} from './interfaces' import {getGlobalConfig, setGlobalConfig} from '../../global'; const {cloneDeep} = require('lodash') let config: ISnowflakeConnectionConfig | null = null; /** * Setting up config in the singleation, use this function on your application init * @sync * @stable * @param serviceEnv * @param awsSecretKey * @param snowflakeConfig */ export const setSnowflakeConnectionConfig = (serviceEnv: string, awsSecretKey: string, snowflakeConfig: ISnowflakeConfig) => { config = { serviceEnv, awsSecretKey, snowflakeConfig, client: '' } setGlobalConfig(config, 'snowflakeConfig') } /** * Used to get config from the singleation, mostly used internally * @sync * @stable * @internal * @param client * @param instanceKey */ export const getSnowflakeConnectionConfig = (client?: string, instanceKey: string = 'default'): ISnowflakeConnectionConfig => { const newConfig = cloneDeep(getGlobalConfig('snowflakeConfig', instanceKey)); newConfig.client = client || null return newConfig; }