export { }; import {secretPromise} from '../aws-secret-manager/aws-secret-manager' const snowflake = require('snowflake-sdk'); const mstime = require('mstime'); let randomNumber = () => { return ((Math.random() * 0x100000000) >>> 0) + 'NODE' + ((Math.random() * 0x100000000) >>> 0) } /** * Function to be consumed by the internally for building the connection, please use this if you want to pass custom config only * @internal * @stable * @async * @param config * @param secretName */ export const createConnectionn = (config: any, secretName: string) => { let id = randomNumber(); mstime.start(id); return new Promise((resolve, reject) => { secretPromise(config.username, secretName).then((secretData: any) => { let password = secretData[config.username] config.password = password; console.log(password) var connection = snowflake.createConnection(config); connection.connect(function (err: any, conn: any) { let result = mstime.end(id); if (err) { console.error('Unable to connect: ' + err.message); reject(err) } else { console.log(`Successfully connected to Snowflake with id: ${conn.getId()}, 🕒 Time taken: ${result.last} ms`); resolve(connection); } }); }).catch((error:any)=>{console.log(error)}) }) }