snowflake-sdk
Version:
Node.js driver for Snowflake
47 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeConnectionOptions = normalizeConnectionOptions;
const KEY_ALIASES = {
user: 'username',
private_key_file: 'privateKeyPath',
};
const SNAKE_TO_CAMEL_OVERRIDES = {
client_request_mfa_token: 'clientRequestMFAToken',
disable_saml_url_check: 'disableSamlURLCheck',
crl_allow_certificates_without_crl_url: 'crlAllowCertificatesWithoutCrlURL',
};
function snakeToCamel(key) {
return key.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
}
function normalizeConnectionOptions(options) {
const normalized = {};
for (const [key, value] of Object.entries(options)) {
if (value === undefined) {
continue;
}
if (KEY_ALIASES[key]) {
if (normalized[KEY_ALIASES[key]] === undefined) {
normalized[KEY_ALIASES[key]] = value;
}
continue;
}
if (SNAKE_TO_CAMEL_OVERRIDES[key]) {
const target = SNAKE_TO_CAMEL_OVERRIDES[key];
if (normalized[target] === undefined) {
normalized[target] = value;
}
continue;
}
if (key === key.toLowerCase() && key.includes('_')) {
const camelKey = snakeToCamel(key);
if (normalized[camelKey] === undefined) {
normalized[camelKey] = value;
}
}
else {
normalized[key] = normalized[key] !== undefined ? normalized[key] : value;
}
}
return normalized;
}
//# sourceMappingURL=normalize_connection_options.js.map