function BulkLoad(table, options1, callback) { (0, _classCallCheck3.default)(this, BulkLoad); var _this = (0, _possibleConstructorReturn3.default)(this, (BulkLoad.__proto__ || (0, _getPrototypeOf2.default)(BulkLoad)).call (this)); _this.error = undefined; _this.canceled = false; _this.table = table; _this.options = options1; _this.callback = callback; _this.columns = []; _this.columnsByName = {}; _this.rowsData = new WritableTrackingBuffer(1024, 'ucs2', true); _this.firstRowWritten = false; return _this; }
n/a
function Connection(config) { (0, _classCallCheck3.default)(this, Connection); var _this = (0, _possibleConstructorReturn3.default)(this, (Connection.__proto__ || (0, _getPrototypeOf2.default)(Connection)). call(this)); if (!config) { throw new TypeError('No connection configuration given'); } if (typeof config.server !== 'string') { throw new TypeError('Invalid server: ' + config.server); } _this.config = { server: config.server, userName: config.userName, password: config.password, domain: config.domain && config.domain.toUpperCase(), options: { abortTransactionOnError: false, appName: undefined, camelCaseColumns: false, cancelTimeout: DEFAULT_CANCEL_TIMEOUT, columnNameReplacer: undefined, connectTimeout: DEFAULT_CONNECT_TIMEOUT, connectionIsolationLevel: ISOLATION_LEVEL.READ_COMMITTED, cryptoCredentialsDetails: {}, database: undefined, datefirst: DEFAULT_DATEFIRST, debug: { data: false, packet: false, payload: false, token: false }, enableArithAbort: false, enableAnsiNullDefault: true, encrypt: false, fallbackToDefaultDb: false, instanceName: undefined, isolationLevel: ISOLATION_LEVEL.READ_COMMITTED, localAddress: undefined, multiSubnetFailover: false, packetSize: DEFAULT_PACKET_SIZE, port: DEFAULT_PORT, readOnlyIntent: false, requestTimeout: DEFAULT_CLIENT_REQUEST_TIMEOUT, rowCollectionOnDone: false, rowCollectionOnRequestCompletion: false, tdsVersion: DEFAULT_TDS_VERSION, textsize: DEFAULT_TEXTSIZE, trustServerCertificate: true, useColumnNames: false, useUTC: true } }; if (config.options) { if (config.options.port && config.options.instanceName) { throw new Error('Port and instanceName are mutually exclusive, but ' + config.options.port + ' and ' + config.options.instanceName + ' provided'); } if (config.options.abortTransactionOnError != undefined) { _this.config.options.abortTransactionOnError = config.options.abortTransactionOnError; } if (config.options.appName != undefined) { _this.config.options.appName = config.options.appName; } if (config.options.camelCaseColumns != undefined) { _this.config.options.camelCaseColumns = config.options.camelCaseColumns; } if (config.options.cancelTimeout != undefined) { _this.config.options.cancelTimeout = config.options.cancelTimeout; } if (config.options.columnNameReplacer) { if (typeof config.options.columnNameReplacer !== 'function') { throw new TypeError('options.columnNameReplacer must be a function or null.'); } _this.config.options.columnNameReplacer = config.options.columnNameReplacer; } if (config.options.connectTimeout) { _this.config.options.connectTimeout = config.options.connectTimeout; } if (config.options.connectionIsolationLevel) { _this.config.options.connectionIsolationLevel = config.options.connectionIsolationLevel; } if (config.options.cryptoCredentialsDetails) { _this.config.options.cryptoCredentialsDetails = config.options.cryptoCredentialsDetails; } if (config.options.database != undefined) { _this.config.options.database = config.options.database; } if (config.options.datefirst) { if (config.options.datefirst < 1 || config.options.datefirst > 7) { throw new RangeError('DateFirst should be >= 1 and <= 7'); } _this.config.options.datefirst = config.options.datefirst; } if (config.options.debug) { if (config.options.debug.data != undefined) { _this.config.options.debug.data = config.options.debug.data; } if (config.options.debug.packet != undefined) { _this.config.options.debug.packet = config.options.debug.packet; } if (config.options.debug.payload != undefined) { _this.config.options.debug.payload = config.options.debug.payl ...
n/a
function ConnectionError(message, code) { if (!(this instanceof ConnectionError)) { if (message instanceof ConnectionError) { return message; } return new ConnectionError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function Error() { [native code] }
n/a
function Request(sqlTextOrProcedure, callback) { (0, _classCallCheck3.default)(this, Request); var _this = (0, _possibleConstructorReturn3.default)(this, (Request.__proto__ || (0, _getPrototypeOf2.default)(Request)).call( this)); _this.sqlTextOrProcedure = sqlTextOrProcedure; _this.callback = callback; _this.parameters = []; _this.parametersByName = {}; _this.userCallback = _this.callback; _this.callback = function () { if (this.preparing) { this.emit('prepared'); return this.preparing = false; } else { this.userCallback.apply(this, arguments); return this.emit('requestCompleted'); } }; return _this; }
n/a
function RequestError(message, code) { if (!(this instanceof RequestError)) { if (message instanceof RequestError) { return message; } return new RequestError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function metadataParse(parser, options, callback) { (options.tdsVersion < '7_2' ? parser.readUInt16LE : parser.readUInt32LE).call(parser, function (userType) { parser.readUInt16LE(function (flags) { parser.readUInt8(function (typeNumber) { var type = TYPE[typeNumber]; if (!type) { return parser.emit(new Error(sprintf('Unrecognised data type 0x%02X', typeNumber))); } readDataLength(parser, type, function (dataLength) { readPrecision(parser, type, function (precision) { readScale(parser, type, function (scale) { if (scale && type.dataLengthFromScale) { dataLength = type.dataLengthFromScale(scale); } readCollation(parser, type, function (collation) { readSchema(parser, type, function (schema) { readUDTInfo(parser, type, function (udtInfo) { callback({ userType: userType, flags: flags, type: type, collation: collation, precision: precision, scale: scale, dataLength: dataLength, schema: schema, udtInfo: udtInfo }); }); }); }); }); }); }); }); }); }); }
n/a
function ConnectionError(message, code) { if (!(this instanceof ConnectionError)) { if (message instanceof ConnectionError) { return message; } return new ConnectionError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function Error() { [native code] }
n/a
function Error() { [native code] }
n/a
function captureStackTrace() { [native code] }
...
}
Error.call(this);
this.message = message;
this.code = code;
Error.captureStackTrace(this, this.constructor);
}
util.inherits(ConnectionError, Error);
ConnectionError.prototype.name = 'ConnectionError';
module.exports.RequestError = RequestError;
...
function RequestError(message, code) { if (!(this instanceof RequestError)) { if (message instanceof RequestError) { return message; } return new RequestError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function Error() { [native code] }
n/a
function writeToTrackingBuffer(buffer, txnDescriptor, outstandingRequestCount) { buffer.writeUInt32LE(0); buffer.writeUInt32LE(TXNDESCRIPTOR_HEADER_LEN); buffer.writeUInt16LE(TYPE.TXN_DESCRIPTOR); buffer.writeBuffer(txnDescriptor); buffer.writeUInt32LE(outstandingRequestCount); var data = buffer.data; data.writeUInt32LE(data.length, 0); return buffer; }
n/a
function Connector(options, multiSubnetFailover) { (0, _classCallCheck3.default)(this, Connector); this.options = options; this.multiSubnetFailover = multiSubnetFailover; }
n/a
function ParallelConnectionStrategy(addresses, options) { (0, _classCallCheck3.default)(this, ParallelConnectionStrategy); this.addresses = addresses; this.options = options; }
n/a
function SequentialConnectionStrategy(addresses, options) { (0, _classCallCheck3.default)(this, SequentialConnectionStrategy); this.addresses = addresses; this.options = options; }
n/a
function ConnectionError(message, code) { if (!(this instanceof ConnectionError)) { if (message instanceof ConnectionError) { return message; } return new ConnectionError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function RequestError(message, code) { if (!(this instanceof RequestError)) { if (message instanceof RequestError) { return message; } return new RequestError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function arrayToGuid(array) { return MAP[array[3]] + MAP[array[2]] + MAP[array[1]] + MAP[array[0]] + '-' + MAP[array[5]] + MAP[array[4]] + '-' + MAP[array[7 ]] + MAP[array[6]] + '-' + MAP[array[8]] + MAP[array[9]] + '-' + MAP[array[10]] + MAP[array[11]] + MAP[array[12]] + MAP[array[13 ]] + MAP[array[14]] + MAP[array[15]]; }
...
case 'UniqueIdentifierN':
switch (dataLength) {
case 0:
return callback(null);
case 0x10:
return parser.readBuffer(0x10, function (data) {
callback(guidParser.arrayToGuid(data));
});
default:
return parser.emit('error', new Error(sprintf('Unsupported guid size %d', dataLength - 1)));
}
case 'UDT':
...
function guidToArray(guid) { return [CHARCODEMAP[guid.charCodeAt(6)][guid.charCodeAt(7)], CHARCODEMAP[guid.charCodeAt(4)][guid.charCodeAt(5)], CHARCODEMAP[ guid.charCodeAt(2)][guid.charCodeAt(3)], CHARCODEMAP[guid.charCodeAt(0)][guid.charCodeAt(1)], CHARCODEMAP[guid.charCodeAt(11)][guid .charCodeAt(12)], CHARCODEMAP[guid.charCodeAt(9)][guid.charCodeAt(10)], CHARCODEMAP[guid.charCodeAt(16)][guid.charCodeAt(17)], CHARCODEMAP [guid.charCodeAt(14)][guid.charCodeAt(15)], CHARCODEMAP[guid.charCodeAt(19)][guid.charCodeAt(20)], CHARCODEMAP[guid.charCodeAt(21 )][guid.charCodeAt(22)], CHARCODEMAP[guid.charCodeAt(24)][guid.charCodeAt(25)], CHARCODEMAP[guid.charCodeAt(26)][guid.charCodeAt (27)], CHARCODEMAP[guid.charCodeAt(28)][guid.charCodeAt(29)], CHARCODEMAP[guid.charCodeAt(30)][guid.charCodeAt(31)], CHARCODEMAP [guid.charCodeAt(32)][guid.charCodeAt(33)], CHARCODEMAP[guid.charCodeAt(34)][guid.charCodeAt(35)]]; }
...
buffer.writeUInt8(typeByName.UniqueIdentifierN.id);
return buffer.writeUInt8(0x10);
},
writeParameterData: function writeParameterData(buffer, parameter) {
if (parameter.value != null) {
buffer.writeUInt8(0x10);
return buffer.writeBuffer(new Buffer(guidParser.guidToArray(parameter.value)));
} else {
return buffer.writeUInt8(0);
}
},
validate: function validate(value) {
if (value == null) {
...
function InstanceLookup() { (0, _classCallCheck3.default)(this, InstanceLookup); }
n/a
function metadataParse(parser, options, callback) { (options.tdsVersion < '7_2' ? parser.readUInt16LE : parser.readUInt32LE).call(parser, function (userType) { parser.readUInt16LE(function (flags) { parser.readUInt8(function (typeNumber) { var type = TYPE[typeNumber]; if (!type) { return parser.emit(new Error(sprintf('Unrecognised data type 0x%02X', typeNumber))); } readDataLength(parser, type, function (dataLength) { readPrecision(parser, type, function (precision) { readScale(parser, type, function (scale) { if (scale && type.dataLengthFromScale) { dataLength = type.dataLengthFromScale(scale); } readCollation(parser, type, function (collation) { readSchema(parser, type, function (schema) { readUDTInfo(parser, type, function (udtInfo) { callback({ userType: userType, flags: flags, type: type, collation: collation, precision: precision, scale: scale, dataLength: dataLength, schema: schema, udtInfo: udtInfo }); }); }); }); }); }); }); }); }); }); }
n/a
function readCollation(parser, type, callback) { if (type.hasCollation) { // s2.2.5.1.2 parser.readBuffer(5, function (collationData) { var collation = {}; collation.lcid = (collationData[2] & 0x0F) << 16; collation.lcid |= collationData[1] << 8; collation.lcid |= collationData[0]; // This may not be extracting the correct nibbles in the correct order. collation.flags = collationData[3] >> 4; collation.flags |= collationData[2] & 0xF0; // This may not be extracting the correct nibble. collation.version = collationData[3] & 0x0F; collation.sortId = collationData[4]; collation.codepage = codepageBySortId[collation.sortId] || codepageByLcid[collation.lcid] || 'CP1252'; callback(collation); }); } else { callback(undefined); } }
n/a
function readPrecision(parser, type, callback) { if (type.hasPrecision) { parser.readUInt8(callback); } else { callback(undefined); } }
n/a
function readScale(parser, type, callback) { if (type.hasScale) { parser.readUInt8(callback); } else { callback(undefined); } }
n/a
function Packet(typeOrBuffer) { (0, _classCallCheck3.default)(this, Packet); if (typeOrBuffer instanceof Buffer) { this.buffer = typeOrBuffer; } else { var type = typeOrBuffer; this.buffer = new Buffer(HEADER_LENGTH); this.buffer.writeUInt8(type, OFFSET.Type); this.buffer.writeUInt8(STATUS.NORMAL, OFFSET.Status); this.buffer.writeUInt16BE(DEFAULT_SPID, OFFSET.SPID); this.buffer.writeUInt8(DEFAULT_PACKETID, OFFSET.PacketID); this.buffer.writeUInt8(DEFAULT_WINDOW, OFFSET.Window); this.setLength(); } }
n/a
function isPacketComplete(potentialPacketBuffer) { if (potentialPacketBuffer.length < HEADER_LENGTH) { return false; } else { return potentialPacketBuffer.length >= potentialPacketBuffer.readUInt16BE(OFFSET.Length); } }
n/a
function packetLength(potentialPacketBuffer) { return potentialPacketBuffer.readUInt16BE(OFFSET.Length); }
n/a
function ParallelSendStrategy(addresses, port, request) { (0, _classCallCheck3.default)(this, ParallelSendStrategy); this.addresses = addresses; this.port = port; this.request = request; this.socketV4 = null; this.socketV6 = null; this.onError = null; this.onMessage = null; }
n/a
function Sender(host, port, request) { (0, _classCallCheck3.default)(this, Sender); this.host = host; this.port = port; this.request = request; this.parallelSendStrategy = null; }
n/a
function BulkLoad(table, options1, callback) { (0, _classCallCheck3.default)(this, BulkLoad); var _this = (0, _possibleConstructorReturn3.default)(this, (BulkLoad.__proto__ || (0, _getPrototypeOf2.default)(BulkLoad)).call (this)); _this.error = undefined; _this.canceled = false; _this.table = table; _this.options = options1; _this.callback = callback; _this.columns = []; _this.columnsByName = {}; _this.rowsData = new WritableTrackingBuffer(1024, 'ucs2', true); _this.firstRowWritten = false; return _this; }
n/a
function Connection(config) { (0, _classCallCheck3.default)(this, Connection); var _this = (0, _possibleConstructorReturn3.default)(this, (Connection.__proto__ || (0, _getPrototypeOf2.default)(Connection)). call(this)); if (!config) { throw new TypeError('No connection configuration given'); } if (typeof config.server !== 'string') { throw new TypeError('Invalid server: ' + config.server); } _this.config = { server: config.server, userName: config.userName, password: config.password, domain: config.domain && config.domain.toUpperCase(), options: { abortTransactionOnError: false, appName: undefined, camelCaseColumns: false, cancelTimeout: DEFAULT_CANCEL_TIMEOUT, columnNameReplacer: undefined, connectTimeout: DEFAULT_CONNECT_TIMEOUT, connectionIsolationLevel: ISOLATION_LEVEL.READ_COMMITTED, cryptoCredentialsDetails: {}, database: undefined, datefirst: DEFAULT_DATEFIRST, debug: { data: false, packet: false, payload: false, token: false }, enableArithAbort: false, enableAnsiNullDefault: true, encrypt: false, fallbackToDefaultDb: false, instanceName: undefined, isolationLevel: ISOLATION_LEVEL.READ_COMMITTED, localAddress: undefined, multiSubnetFailover: false, packetSize: DEFAULT_PACKET_SIZE, port: DEFAULT_PORT, readOnlyIntent: false, requestTimeout: DEFAULT_CLIENT_REQUEST_TIMEOUT, rowCollectionOnDone: false, rowCollectionOnRequestCompletion: false, tdsVersion: DEFAULT_TDS_VERSION, textsize: DEFAULT_TEXTSIZE, trustServerCertificate: true, useColumnNames: false, useUTC: true } }; if (config.options) { if (config.options.port && config.options.instanceName) { throw new Error('Port and instanceName are mutually exclusive, but ' + config.options.port + ' and ' + config.options.instanceName + ' provided'); } if (config.options.abortTransactionOnError != undefined) { _this.config.options.abortTransactionOnError = config.options.abortTransactionOnError; } if (config.options.appName != undefined) { _this.config.options.appName = config.options.appName; } if (config.options.camelCaseColumns != undefined) { _this.config.options.camelCaseColumns = config.options.camelCaseColumns; } if (config.options.cancelTimeout != undefined) { _this.config.options.cancelTimeout = config.options.cancelTimeout; } if (config.options.columnNameReplacer) { if (typeof config.options.columnNameReplacer !== 'function') { throw new TypeError('options.columnNameReplacer must be a function or null.'); } _this.config.options.columnNameReplacer = config.options.columnNameReplacer; } if (config.options.connectTimeout) { _this.config.options.connectTimeout = config.options.connectTimeout; } if (config.options.connectionIsolationLevel) { _this.config.options.connectionIsolationLevel = config.options.connectionIsolationLevel; } if (config.options.cryptoCredentialsDetails) { _this.config.options.cryptoCredentialsDetails = config.options.cryptoCredentialsDetails; } if (config.options.database != undefined) { _this.config.options.database = config.options.database; } if (config.options.datefirst) { if (config.options.datefirst < 1 || config.options.datefirst > 7) { throw new RangeError('DateFirst should be >= 1 and <= 7'); } _this.config.options.datefirst = config.options.datefirst; } if (config.options.debug) { if (config.options.debug.data != undefined) { _this.config.options.debug.data = config.options.debug.data; } if (config.options.debug.packet != undefined) { _this.config.options.debug.packet = config.options.debug.packet; } if (config.options.debug.payload != undefined) { _this.config.options.debug.payload = config.options.debug.payl ...
n/a
function ConnectionError(message, code) { if (!(this instanceof ConnectionError)) { if (message instanceof ConnectionError) { return message; } return new ConnectionError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function Request(sqlTextOrProcedure, callback) { (0, _classCallCheck3.default)(this, Request); var _this = (0, _possibleConstructorReturn3.default)(this, (Request.__proto__ || (0, _getPrototypeOf2.default)(Request)).call( this)); _this.sqlTextOrProcedure = sqlTextOrProcedure; _this.callback = callback; _this.parameters = []; _this.parametersByName = {}; _this.userCallback = _this.callback; _this.callback = function () { if (this.preparing) { this.emit('prepared'); return this.preparing = false; } else { this.userCallback.apply(this, arguments); return this.emit('requestCompleted'); } }; return _this; }
n/a
function RequestError(message, code) { if (!(this instanceof RequestError)) { if (message instanceof RequestError) { return message; } return new RequestError(message, code); } Error.call(this); this.message = message; this.code = code; Error.captureStackTrace(this, this.constructor); }
n/a
function Transaction(name, isolationLevel) { (0, _classCallCheck3.default)(this, Transaction); this.name = name; this.isolationLevel = isolationLevel; this.outstandingRequestCount = 1; }
n/a