snowflake-sdk
Version:
Node.js driver for Snowflake
33 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildConnectionShapePayload = buildConnectionShapePayload;
function isNonEmptyString(value) {
return typeof value === 'string' && value !== '';
}
const stringify = (b) => (b ? 'true' : 'false');
function buildConnectionShapePayload(options) {
let accountProvided = false;
let accountWithRegion = false;
let accountOrgProvided = false;
const account = options.account;
if (isNonEmptyString(account)) {
accountProvided = true;
// Mirrors gosnowflake's `recordAccountShape` (gates on `i > 0`):
// a leading dot leaves the full raw string as the account portion
// and the dash search runs over the whole value.
const dotIndex = account.indexOf('.');
const accountPortion = dotIndex > 0 ? account.substring(0, dotIndex) : account;
accountWithRegion = dotIndex > 0;
accountOrgProvided = accountPortion.includes('-');
}
return {
account_provided: stringify(accountProvided),
account_with_region: stringify(accountWithRegion),
account_org_provided: stringify(accountOrgProvided),
region_provided: stringify(isNonEmptyString(options.region)),
// `host` and `accessUrl` collapse into one flag: both mean "user
// supplied an explicit endpoint". Wire schema stays five-keys flat.
host_provided: stringify(isNonEmptyString(options.host) || isNonEmptyString(options.accessUrl)),
};
}
//# sourceMappingURL=connection_identifier_shape.js.map