* Extends and validates the user options * @param {Object} [baseOptions] The source object instance that will be overridden * @param {Object} userOptions * @returns {Object}
(baseOptions, userOptions)
| 111 | * @returns {Object} |
| 112 | */ |
| 113 | function extend(baseOptions, userOptions) { |
| 114 | if (arguments.length === 1) { |
| 115 | userOptions = arguments[0]; |
| 116 | baseOptions = {}; |
| 117 | } |
| 118 | const options = utils.deepExtend(baseOptions, defaultOptions(), userOptions); |
| 119 | |
| 120 | if (!options.cloud) { |
| 121 | if (!Array.isArray(options.contactPoints) || options.contactPoints.length === 0) { |
| 122 | throw new TypeError('Contacts points are not defined.'); |
| 123 | } |
| 124 | |
| 125 | for (let i = 0; i < options.contactPoints.length; i++) { |
| 126 | const hostName = options.contactPoints[i]; |
| 127 | if (!hostName) { |
| 128 | throw new TypeError(util.format('Contact point %s (%s) is not a valid host name, ' + |
| 129 | 'the following values are valid contact points: ipAddress, hostName or ipAddress:port', i, hostName)); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | options.sni = undefined; |
| 134 | } else { |
| 135 | validateCloudOptions(options); |
| 136 | } |
| 137 | |
| 138 | if (!options.logEmitter) { |
| 139 | options.logEmitter = function () {}; |
| 140 | } |
| 141 | if (!options.queryOptions) { |
| 142 | throw new TypeError('queryOptions not defined in options'); |
| 143 | } |
| 144 | |
| 145 | if (options.requestTracker !== null && !(options.requestTracker instanceof tracker.RequestTracker)) { |
| 146 | throw new TypeError('requestTracker must be an instance of RequestTracker'); |
| 147 | } |
| 148 | |
| 149 | if (!(options.metrics instanceof metrics.ClientMetrics)) { |
| 150 | throw new TypeError('metrics must be an instance of ClientMetrics'); |
| 151 | } |
| 152 | |
| 153 | validatePoliciesOptions(options.policies); |
| 154 | |
| 155 | validateProtocolOptions(options.protocolOptions); |
| 156 | |
| 157 | validateSocketOptions(options.socketOptions); |
| 158 | |
| 159 | validateAuthenticationOptions(options); |
| 160 | |
| 161 | options.encoding = options.encoding || {}; |
| 162 | |
| 163 | validateEncodingOptions(options.encoding); |
| 164 | |
| 165 | if (options.profiles && !Array.isArray(options.profiles)) { |
| 166 | throw new TypeError('profiles must be an Array of ExecutionProfile instances'); |
| 167 | } |
| 168 | |
| 169 | validateApplicationInfo(options); |
| 170 |
nothing calls this directly
no test coverage detected