/
index.js
138 lines (120 loc) · 2.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
'use strict'
const ConnectionPool = require('./connection-pool')
const PreparedStatement = require('./prepared-statement')
const Request = require('./request')
const Transaction = require('./transaction')
const { ConnectionError, TransactionError, RequestError, PreparedStatementError, MSSQLError } = require('../error')
const shared = require('../shared')
const Table = require('../table')
const ISOLATION_LEVEL = require('../isolationlevel')
const { TYPES } = require('../datatypes')
const { connect, close, on, off, removeListener, query, batch } = require('../global-connection')
module.exports = {
ConnectionPool,
Transaction,
Request,
PreparedStatement,
ConnectionError,
TransactionError,
RequestError,
PreparedStatementError,
MSSQLError,
driver: shared.driver,
exports: {
ConnectionError,
TransactionError,
RequestError,
PreparedStatementError,
MSSQLError,
Table,
ISOLATION_LEVEL,
TYPES,
MAX: 65535, // (1 << 16) - 1
map: shared.map,
getTypeByValue: shared.getTypeByValue,
connect,
close,
on,
removeListener,
off,
query,
batch
}
}
Object.defineProperty(module.exports, 'Promise', {
enumerable: true,
get: () => {
return shared.Promise
},
set: (value) => {
shared.Promise = value
}
})
Object.defineProperty(module.exports, 'valueHandler', {
enumerable: true,
value: shared.valueHandler,
writable: false,
configurable: false
})
for (const key in TYPES) {
const value = TYPES[key]
module.exports.exports[key] = value
module.exports.exports[key.toUpperCase()] = value
}
/**
* @callback Request~requestCallback
* @param {Error} err Error on error, otherwise null.
* @param {Object} [result] Request result.
*/
/**
* @callback Request~bulkCallback
* @param {Error} err Error on error, otherwise null.
* @param {Number} [rowsAffected] Number of affected rows.
*/
/**
* @callback basicCallback
* @param {Error} err Error on error, otherwise null.
* @param {Connection} [connection] Acquired connection.
*/
/**
* @callback acquireCallback
* @param {Error} err Error on error, otherwise null.
* @param {Connection} [connection] Acquired connection.
* @param {Object} [config] Connection config
*/
/**
* Dispatched after connection has established.
* @event ConnectionPool#connect
*/
/**
* Dispatched after connection has closed a pool (by calling close).
* @event ConnectionPool#close
*/
/**
* Dispatched when transaction begin.
* @event Transaction#begin
*/
/**
* Dispatched on successful commit.
* @event Transaction#commit
*/
/**
* Dispatched on successful rollback.
* @event Transaction#rollback
*/
/**
* Dispatched when metadata for new recordset are parsed.
* @event Request#recordset
*/
/**
* Dispatched when new row is parsed.
* @event Request#row
*/
/**
* Dispatched when request is complete.
* @event Request#done
*/
/**
* Dispatched on error.
* @event Request#error
*/