tedious-fabric 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/CLAUDE.md +91 -0
  2. package/LICENSE +21 -0
  3. package/README.md +67 -0
  4. package/appveyor.yml +67 -0
  5. package/eslint.config.mjs +314 -0
  6. package/lib/all-headers.d.ts +2 -0
  7. package/lib/all-headers.js +24 -0
  8. package/lib/all-headers.js.map +1 -0
  9. package/lib/always-encrypted/aead-aes-256-cbc-hmac-algorithm.js +82 -0
  10. package/lib/always-encrypted/aead-aes-256-cbc-hmac-algorithm.js.map +1 -0
  11. package/lib/always-encrypted/aead-aes-256-cbc-hmac-encryption-key.js +55 -0
  12. package/lib/always-encrypted/aead-aes-256-cbc-hmac-encryption-key.js.map +1 -0
  13. package/lib/always-encrypted/cek-entry.d.ts +11 -0
  14. package/lib/always-encrypted/cek-entry.js +42 -0
  15. package/lib/always-encrypted/cek-entry.js.map +1 -0
  16. package/lib/always-encrypted/get-parameter-encryption-metadata.js +90 -0
  17. package/lib/always-encrypted/get-parameter-encryption-metadata.js.map +1 -0
  18. package/lib/always-encrypted/key-crypto.js +94 -0
  19. package/lib/always-encrypted/key-crypto.js.map +1 -0
  20. package/lib/always-encrypted/keystore-provider-azure-key-vault.d.ts +21 -0
  21. package/lib/always-encrypted/keystore-provider-azure-key-vault.js +247 -0
  22. package/lib/always-encrypted/keystore-provider-azure-key-vault.js.map +1 -0
  23. package/lib/always-encrypted/symmetric-key-cache.js +36 -0
  24. package/lib/always-encrypted/symmetric-key-cache.js.map +1 -0
  25. package/lib/always-encrypted/symmetric-key.js +25 -0
  26. package/lib/always-encrypted/symmetric-key.js.map +1 -0
  27. package/lib/always-encrypted/types.d.ts +73 -0
  28. package/lib/always-encrypted/types.js +61 -0
  29. package/lib/always-encrypted/types.js.map +1 -0
  30. package/lib/always-encrypted/utils.js +23 -0
  31. package/lib/always-encrypted/utils.js.map +1 -0
  32. package/lib/bulk-load-payload.d.ts +8 -0
  33. package/lib/bulk-load-payload.js +23 -0
  34. package/lib/bulk-load-payload.js.map +1 -0
  35. package/lib/bulk-load.d.ts +275 -0
  36. package/lib/bulk-load.js +515 -0
  37. package/lib/bulk-load.js.map +1 -0
  38. package/lib/collation.d.ts +28 -0
  39. package/lib/collation.js +348 -0
  40. package/lib/collation.js.map +1 -0
  41. package/lib/connection.d.ts +1309 -0
  42. package/lib/connection.js +2732 -0
  43. package/lib/connection.js.map +1 -0
  44. package/lib/connector.d.ts +18 -0
  45. package/lib/connector.js +142 -0
  46. package/lib/connector.js.map +1 -0
  47. package/lib/data-type.d.ts +554 -0
  48. package/lib/data-type.js +428 -0
  49. package/lib/data-type.js.map +1 -0
  50. package/lib/data-types/bigint.d.ts +3 -0
  51. package/lib/data-types/bigint.js +53 -0
  52. package/lib/data-types/bigint.js.map +1 -0
  53. package/lib/data-types/binary.d.ts +5 -0
  54. package/lib/data-types/binary.js +67 -0
  55. package/lib/data-types/binary.js.map +1 -0
  56. package/lib/data-types/bit.d.ts +3 -0
  57. package/lib/data-types/bit.js +46 -0
  58. package/lib/data-types/bit.js.map +1 -0
  59. package/lib/data-types/bitn.d.ts +3 -0
  60. package/lib/data-types/bitn.js +29 -0
  61. package/lib/data-types/bitn.js.map +1 -0
  62. package/lib/data-types/char.d.ts +5 -0
  63. package/lib/data-types/char.js +86 -0
  64. package/lib/data-types/char.js.map +1 -0
  65. package/lib/data-types/date.d.ts +3 -0
  66. package/lib/data-types/date.js +72 -0
  67. package/lib/data-types/date.js.map +1 -0
  68. package/lib/data-types/datetime.d.ts +3 -0
  69. package/lib/data-types/datetime.js +93 -0
  70. package/lib/data-types/datetime.js.map +1 -0
  71. package/lib/data-types/datetime2.d.ts +5 -0
  72. package/lib/data-types/datetime2.js +118 -0
  73. package/lib/data-types/datetime2.js.map +1 -0
  74. package/lib/data-types/datetimen.d.ts +3 -0
  75. package/lib/data-types/datetimen.js +29 -0
  76. package/lib/data-types/datetimen.js.map +1 -0
  77. package/lib/data-types/datetimeoffset.d.ts +5 -0
  78. package/lib/data-types/datetimeoffset.js +111 -0
  79. package/lib/data-types/datetimeoffset.js.map +1 -0
  80. package/lib/data-types/decimal.d.ts +6 -0
  81. package/lib/data-types/decimal.js +107 -0
  82. package/lib/data-types/decimal.js.map +1 -0
  83. package/lib/data-types/decimaln.d.ts +3 -0
  84. package/lib/data-types/decimaln.js +29 -0
  85. package/lib/data-types/decimaln.js.map +1 -0
  86. package/lib/data-types/float.d.ts +3 -0
  87. package/lib/data-types/float.js +47 -0
  88. package/lib/data-types/float.js.map +1 -0
  89. package/lib/data-types/floatn.d.ts +3 -0
  90. package/lib/data-types/floatn.js +29 -0
  91. package/lib/data-types/floatn.js.map +1 -0
  92. package/lib/data-types/image.d.ts +3 -0
  93. package/lib/data-types/image.js +56 -0
  94. package/lib/data-types/image.js.map +1 -0
  95. package/lib/data-types/int.d.ts +3 -0
  96. package/lib/data-types/int.js +53 -0
  97. package/lib/data-types/int.js.map +1 -0
  98. package/lib/data-types/intn.d.ts +3 -0
  99. package/lib/data-types/intn.js +29 -0
  100. package/lib/data-types/intn.js.map +1 -0
  101. package/lib/data-types/money.d.ts +3 -0
  102. package/lib/data-types/money.js +59 -0
  103. package/lib/data-types/money.js.map +1 -0
  104. package/lib/data-types/moneyn.d.ts +3 -0
  105. package/lib/data-types/moneyn.js +29 -0
  106. package/lib/data-types/moneyn.js.map +1 -0
  107. package/lib/data-types/nchar.d.ts +5 -0
  108. package/lib/data-types/nchar.js +100 -0
  109. package/lib/data-types/nchar.js.map +1 -0
  110. package/lib/data-types/ntext.d.ts +3 -0
  111. package/lib/data-types/ntext.js +60 -0
  112. package/lib/data-types/ntext.js.map +1 -0
  113. package/lib/data-types/null.d.ts +3 -0
  114. package/lib/data-types/null.js +29 -0
  115. package/lib/data-types/null.js.map +1 -0
  116. package/lib/data-types/numeric.d.ts +6 -0
  117. package/lib/data-types/numeric.js +106 -0
  118. package/lib/data-types/numeric.js.map +1 -0
  119. package/lib/data-types/numericn.d.ts +3 -0
  120. package/lib/data-types/numericn.js +29 -0
  121. package/lib/data-types/numericn.js.map +1 -0
  122. package/lib/data-types/nvarchar.d.ts +5 -0
  123. package/lib/data-types/nvarchar.js +133 -0
  124. package/lib/data-types/nvarchar.js.map +1 -0
  125. package/lib/data-types/real.d.ts +3 -0
  126. package/lib/data-types/real.js +48 -0
  127. package/lib/data-types/real.js.map +1 -0
  128. package/lib/data-types/smalldatetime.d.ts +3 -0
  129. package/lib/data-types/smalldatetime.js +83 -0
  130. package/lib/data-types/smalldatetime.js.map +1 -0
  131. package/lib/data-types/smallint.d.ts +3 -0
  132. package/lib/data-types/smallint.js +53 -0
  133. package/lib/data-types/smallint.js.map +1 -0
  134. package/lib/data-types/smallmoney.d.ts +3 -0
  135. package/lib/data-types/smallmoney.js +51 -0
  136. package/lib/data-types/smallmoney.js.map +1 -0
  137. package/lib/data-types/sql-variant.d.ts +3 -0
  138. package/lib/data-types/sql-variant.js +29 -0
  139. package/lib/data-types/sql-variant.js.map +1 -0
  140. package/lib/data-types/text.d.ts +3 -0
  141. package/lib/data-types/text.js +69 -0
  142. package/lib/data-types/text.js.map +1 -0
  143. package/lib/data-types/time.d.ts +3 -0
  144. package/lib/data-types/time.js +96 -0
  145. package/lib/data-types/time.js.map +1 -0
  146. package/lib/data-types/tinyint.d.ts +3 -0
  147. package/lib/data-types/tinyint.js +53 -0
  148. package/lib/data-types/tinyint.js.map +1 -0
  149. package/lib/data-types/tvp.d.ts +3 -0
  150. package/lib/data-types/tvp.js +117 -0
  151. package/lib/data-types/tvp.js.map +1 -0
  152. package/lib/data-types/udt.d.ts +3 -0
  153. package/lib/data-types/udt.js +29 -0
  154. package/lib/data-types/udt.js.map +1 -0
  155. package/lib/data-types/uniqueidentifier.d.ts +3 -0
  156. package/lib/data-types/uniqueidentifier.js +50 -0
  157. package/lib/data-types/uniqueidentifier.js.map +1 -0
  158. package/lib/data-types/varbinary.d.ts +5 -0
  159. package/lib/data-types/varbinary.js +119 -0
  160. package/lib/data-types/varbinary.js.map +1 -0
  161. package/lib/data-types/varchar.d.ts +5 -0
  162. package/lib/data-types/varchar.js +112 -0
  163. package/lib/data-types/varchar.js.map +1 -0
  164. package/lib/data-types/xml.d.ts +3 -0
  165. package/lib/data-types/xml.js +29 -0
  166. package/lib/data-types/xml.js.map +1 -0
  167. package/lib/debug.d.ts +25 -0
  168. package/lib/debug.js +66 -0
  169. package/lib/debug.js.map +1 -0
  170. package/lib/errors.d.ts +17 -0
  171. package/lib/errors.js +23 -0
  172. package/lib/errors.js.map +1 -0
  173. package/lib/guid-parser.d.ts +3 -0
  174. package/lib/guid-parser.js +30 -0
  175. package/lib/guid-parser.js.map +1 -0
  176. package/lib/incoming-message-stream.d.ts +19 -0
  177. package/lib/incoming-message-stream.js +97 -0
  178. package/lib/incoming-message-stream.js.map +1 -0
  179. package/lib/instance-lookup.d.ts +13 -0
  180. package/lib/instance-lookup.js +91 -0
  181. package/lib/instance-lookup.js.map +1 -0
  182. package/lib/library.d.ts +1 -0
  183. package/lib/library.js +8 -0
  184. package/lib/library.js.map +1 -0
  185. package/lib/login7-payload.d.ts +51 -0
  186. package/lib/login7-payload.js +408 -0
  187. package/lib/login7-payload.js.map +1 -0
  188. package/lib/message-io.d.ts +28 -0
  189. package/lib/message-io.js +152 -0
  190. package/lib/message-io.js.map +1 -0
  191. package/lib/message.d.ts +11 -0
  192. package/lib/message.js +21 -0
  193. package/lib/message.js.map +1 -0
  194. package/lib/metadata-parser.d.ts +48 -0
  195. package/lib/metadata-parser.js +380 -0
  196. package/lib/metadata-parser.js.map +1 -0
  197. package/lib/ntlm-payload.d.ts +23 -0
  198. package/lib/ntlm-payload.js +135 -0
  199. package/lib/ntlm-payload.js.map +1 -0
  200. package/lib/ntlm.d.ts +4 -0
  201. package/lib/ntlm.js +72 -0
  202. package/lib/ntlm.js.map +1 -0
  203. package/lib/outgoing-message-stream.d.ts +15 -0
  204. package/lib/outgoing-message-stream.js +81 -0
  205. package/lib/outgoing-message-stream.js.map +1 -0
  206. package/lib/packet.d.ts +33 -0
  207. package/lib/packet.js +191 -0
  208. package/lib/packet.js.map +1 -0
  209. package/lib/prelogin-payload.d.ts +67 -0
  210. package/lib/prelogin-payload.js +228 -0
  211. package/lib/prelogin-payload.js.map +1 -0
  212. package/lib/request.d.ts +370 -0
  213. package/lib/request.js +387 -0
  214. package/lib/request.js.map +1 -0
  215. package/lib/rpcrequest-payload.d.ts +16 -0
  216. package/lib/rpcrequest-payload.js +109 -0
  217. package/lib/rpcrequest-payload.js.map +1 -0
  218. package/lib/sender.d.ts +5 -0
  219. package/lib/sender.js +78 -0
  220. package/lib/sender.js.map +1 -0
  221. package/lib/special-stored-procedure.d.ts +18 -0
  222. package/lib/special-stored-procedure.js +26 -0
  223. package/lib/special-stored-procedure.js.map +1 -0
  224. package/lib/sqlbatch-payload.d.ts +13 -0
  225. package/lib/sqlbatch-payload.js +34 -0
  226. package/lib/sqlbatch-payload.js.map +1 -0
  227. package/lib/tds-versions.d.ts +6 -0
  228. package/lib/tds-versions.js +19 -0
  229. package/lib/tds-versions.js.map +1 -0
  230. package/lib/tedious.d.ts +13 -0
  231. package/lib/tedious.js +73 -0
  232. package/lib/tedious.js.map +1 -0
  233. package/lib/token/colmetadata-token-parser.d.ts +12 -0
  234. package/lib/token/colmetadata-token-parser.js +124 -0
  235. package/lib/token/colmetadata-token-parser.js.map +1 -0
  236. package/lib/token/done-token-parser.d.ts +6 -0
  237. package/lib/token/done-token-parser.js +76 -0
  238. package/lib/token/done-token-parser.js.map +1 -0
  239. package/lib/token/env-change-token-parser.d.ts +5 -0
  240. package/lib/token/env-change-token-parser.js +190 -0
  241. package/lib/token/env-change-token-parser.js.map +1 -0
  242. package/lib/token/feature-ext-ack-parser.d.ts +5 -0
  243. package/lib/token/feature-ext-ack-parser.js +52 -0
  244. package/lib/token/feature-ext-ack-parser.js.map +1 -0
  245. package/lib/token/fedauth-info-parser.d.ts +5 -0
  246. package/lib/token/fedauth-info-parser.js +62 -0
  247. package/lib/token/fedauth-info-parser.js.map +1 -0
  248. package/lib/token/handler.d.ts +136 -0
  249. package/lib/token/handler.js +445 -0
  250. package/lib/token/handler.js.map +1 -0
  251. package/lib/token/helpers.d.ts +28 -0
  252. package/lib/token/helpers.js +205 -0
  253. package/lib/token/helpers.js.map +1 -0
  254. package/lib/token/infoerror-token-parser.d.ts +5 -0
  255. package/lib/token/infoerror-token-parser.js +80 -0
  256. package/lib/token/infoerror-token-parser.js.map +1 -0
  257. package/lib/token/loginack-token-parser.d.ts +5 -0
  258. package/lib/token/loginack-token-parser.js +75 -0
  259. package/lib/token/loginack-token-parser.js.map +1 -0
  260. package/lib/token/nbcrow-token-parser.d.ts +4 -0
  261. package/lib/token/nbcrow-token-parser.js +103 -0
  262. package/lib/token/nbcrow-token-parser.js.map +1 -0
  263. package/lib/token/order-token-parser.d.ts +5 -0
  264. package/lib/token/order-token-parser.js +34 -0
  265. package/lib/token/order-token-parser.js.map +1 -0
  266. package/lib/token/returnstatus-token-parser.d.ts +5 -0
  267. package/lib/token/returnstatus-token-parser.js +21 -0
  268. package/lib/token/returnstatus-token-parser.js.map +1 -0
  269. package/lib/token/returnvalue-token-parser.d.ts +4 -0
  270. package/lib/token/returnvalue-token-parser.js +93 -0
  271. package/lib/token/returnvalue-token-parser.js.map +1 -0
  272. package/lib/token/row-token-parser.d.ts +4 -0
  273. package/lib/token/row-token-parser.js +76 -0
  274. package/lib/token/row-token-parser.js.map +1 -0
  275. package/lib/token/sspi-token-parser.d.ts +5 -0
  276. package/lib/token/sspi-token-parser.js +42 -0
  277. package/lib/token/sspi-token-parser.js.map +1 -0
  278. package/lib/token/stream-parser.d.ts +34 -0
  279. package/lib/token/stream-parser.js +341 -0
  280. package/lib/token/stream-parser.js.map +1 -0
  281. package/lib/token/token-stream-parser.d.ts +15 -0
  282. package/lib/token/token-stream-parser.js +36 -0
  283. package/lib/token/token-stream-parser.js.map +1 -0
  284. package/lib/token/token.d.ts +312 -0
  285. package/lib/token/token.js +328 -0
  286. package/lib/token/token.js.map +1 -0
  287. package/lib/tracking-buffer/writable-tracking-buffer.d.ts +47 -0
  288. package/lib/tracking-buffer/writable-tracking-buffer.js +249 -0
  289. package/lib/tracking-buffer/writable-tracking-buffer.js.map +1 -0
  290. package/lib/transaction.d.ts +39 -0
  291. package/lib/transaction.js +137 -0
  292. package/lib/transaction.js.map +1 -0
  293. package/lib/transient-error-lookup.d.ts +3 -0
  294. package/lib/transient-error-lookup.js +19 -0
  295. package/lib/transient-error-lookup.js.map +1 -0
  296. package/lib/value-parser.d.ts +7 -0
  297. package/lib/value-parser.js +813 -0
  298. package/lib/value-parser.js.map +1 -0
  299. package/package.json +145 -0
  300. package/pull_request_template.md +9 -0
  301. package/tsconfig.build-types.json +15 -0
  302. package/tsconfig.json +30 -0
  303. package/types/js-md4.d.ts +7 -0
  304. package/types/native-duplexpair.d.ts +12 -0
@@ -0,0 +1,1309 @@
1
+ import * as tls from 'tls';
2
+ import * as net from 'net';
3
+ import { type SecureContextOptions } from 'tls';
4
+ import { type TokenCredential } from '@azure/core-auth';
5
+ import BulkLoad, { type Options as BulkLoadOptions, type Callback as BulkLoadCallback } from './bulk-load';
6
+ import Debug from './debug';
7
+ import { EventEmitter } from 'events';
8
+ import { TransientErrorLookup } from './transient-error-lookup';
9
+ import PreloginPayload from './prelogin-payload';
10
+ import Request from './request';
11
+ import MessageIO from './message-io';
12
+ import { Parser as TokenStreamParser } from './token/token-stream-parser';
13
+ import { ISOLATION_LEVEL } from './transaction';
14
+ import { ConnectionError } from './errors';
15
+ import Message from './message';
16
+ import { type Metadata } from './metadata-parser';
17
+ import { ColumnEncryptionAzureKeyVaultProvider } from './always-encrypted/keystore-provider-azure-key-vault';
18
+ import { Collation } from './collation';
19
+ import { TokenHandler } from './token/handler';
20
+ type BeginTransactionCallback =
21
+ /**
22
+ * The callback is called when the request to start the transaction has completed,
23
+ * either successfully or with an error.
24
+ * If an error occurred then `err` will describe the error.
25
+ *
26
+ * As only one request at a time may be executed on a connection, another request should not
27
+ * be initiated until this callback is called.
28
+ *
29
+ * @param err If an error occurred, an [[Error]] object with details of the error.
30
+ * @param transactionDescriptor A Buffer that describe the transaction
31
+ */
32
+ (err: Error | null | undefined, transactionDescriptor?: Buffer) => void;
33
+ type SaveTransactionCallback =
34
+ /**
35
+ * The callback is called when the request to set a savepoint within the
36
+ * transaction has completed, either successfully or with an error.
37
+ * If an error occurred then `err` will describe the error.
38
+ *
39
+ * As only one request at a time may be executed on a connection, another request should not
40
+ * be initiated until this callback is called.
41
+ *
42
+ * @param err If an error occurred, an [[Error]] object with details of the error.
43
+ */
44
+ (err: Error | null | undefined) => void;
45
+ type CommitTransactionCallback =
46
+ /**
47
+ * The callback is called when the request to commit the transaction has completed,
48
+ * either successfully or with an error.
49
+ * If an error occurred then `err` will describe the error.
50
+ *
51
+ * As only one request at a time may be executed on a connection, another request should not
52
+ * be initiated until this callback is called.
53
+ *
54
+ * @param err If an error occurred, an [[Error]] object with details of the error.
55
+ */
56
+ (err: Error | null | undefined) => void;
57
+ type RollbackTransactionCallback =
58
+ /**
59
+ * The callback is called when the request to rollback the transaction has
60
+ * completed, either successfully or with an error.
61
+ * If an error occurred then err will describe the error.
62
+ *
63
+ * As only one request at a time may be executed on a connection, another request should not
64
+ * be initiated until this callback is called.
65
+ *
66
+ * @param err If an error occurred, an [[Error]] object with details of the error.
67
+ */
68
+ (err: Error | null | undefined) => void;
69
+ type ResetCallback =
70
+ /**
71
+ * The callback is called when the connection reset has completed,
72
+ * either successfully or with an error.
73
+ *
74
+ * If an error occurred then `err` will describe the error.
75
+ *
76
+ * As only one request at a time may be executed on a connection, another
77
+ * request should not be initiated until this callback is called
78
+ *
79
+ * @param err If an error occurred, an [[Error]] object with details of the error.
80
+ */
81
+ (err: Error | null | undefined) => void;
82
+ type TransactionDoneCallback = (err: Error | null | undefined, ...args: any[]) => void;
83
+ type CallbackParameters<T extends (err: Error | null | undefined, ...args: any[]) => any> = T extends (err: Error | null | undefined, ...args: infer P) => any ? P : never;
84
+ interface AzureActiveDirectoryMsiAppServiceAuthentication {
85
+ type: 'azure-active-directory-msi-app-service';
86
+ options: {
87
+ /**
88
+ * If you user want to connect to an Azure app service using a specific client account
89
+ * they need to provide `clientId` associate to their created identity.
90
+ *
91
+ * This is optional for retrieve token from azure web app service
92
+ */
93
+ clientId?: string;
94
+ };
95
+ }
96
+ interface AzureActiveDirectoryMsiVmAuthentication {
97
+ type: 'azure-active-directory-msi-vm';
98
+ options: {
99
+ /**
100
+ * If you want to connect using a specific client account
101
+ * they need to provide `clientId` associated to their created identity.
102
+ *
103
+ * This is optional for retrieve a token
104
+ */
105
+ clientId?: string;
106
+ };
107
+ }
108
+ interface AzureActiveDirectoryDefaultAuthentication {
109
+ type: 'azure-active-directory-default';
110
+ options: {
111
+ /**
112
+ * If you want to connect using a specific client account
113
+ * they need to provide `clientId` associated to their created identity.
114
+ *
115
+ * This is optional for retrieving a token
116
+ */
117
+ clientId?: string;
118
+ };
119
+ }
120
+ interface AzureActiveDirectoryAccessTokenAuthentication {
121
+ type: 'azure-active-directory-access-token';
122
+ options: {
123
+ /**
124
+ * A user need to provide `token` which they retrieved else where
125
+ * to forming the connection.
126
+ */
127
+ token: string;
128
+ };
129
+ }
130
+ interface AzureActiveDirectoryPasswordAuthentication {
131
+ type: 'azure-active-directory-password';
132
+ options: {
133
+ /**
134
+ * A user need to provide `userName` associate to their account.
135
+ */
136
+ userName: string;
137
+ /**
138
+ * A user need to provide `password` associate to their account.
139
+ */
140
+ password: string;
141
+ /**
142
+ * A client id to use.
143
+ */
144
+ clientId: string;
145
+ /**
146
+ * Optional parameter for specific Azure tenant ID
147
+ */
148
+ tenantId: string;
149
+ };
150
+ }
151
+ interface AzureActiveDirectoryServicePrincipalSecret {
152
+ type: 'azure-active-directory-service-principal-secret';
153
+ options: {
154
+ /**
155
+ * Application (`client`) ID from your registered Azure application
156
+ */
157
+ clientId: string;
158
+ /**
159
+ * The created `client secret` for this registered Azure application
160
+ */
161
+ clientSecret: string;
162
+ /**
163
+ * Directory (`tenant`) ID from your registered Azure application
164
+ */
165
+ tenantId: string;
166
+ };
167
+ }
168
+ /** Structure that defines the options that are necessary to authenticate the Tedious.JS instance with an `@azure/identity` token credential. */
169
+ interface TokenCredentialAuthentication {
170
+ /** Unique designator for the type of authentication to be used. */
171
+ type: 'token-credential';
172
+ /** Set of configurations that are required or allowed with this authentication type. */
173
+ options: {
174
+ /** Credential object used to authenticate to the resource. */
175
+ credential: TokenCredential;
176
+ };
177
+ }
178
+ interface NtlmAuthentication {
179
+ type: 'ntlm';
180
+ options: {
181
+ /**
182
+ * User name from your windows account.
183
+ */
184
+ userName: string;
185
+ /**
186
+ * Password from your windows account.
187
+ */
188
+ password: string;
189
+ /**
190
+ * Once you set domain for ntlm authentication type, driver will connect to SQL Server using domain login.
191
+ *
192
+ * This is necessary for forming a connection using ntlm type
193
+ */
194
+ domain: string;
195
+ };
196
+ }
197
+ interface DefaultAuthentication {
198
+ type: 'default';
199
+ options: {
200
+ /**
201
+ * User name to use for sql server login.
202
+ */
203
+ userName?: string | undefined;
204
+ /**
205
+ * Password to use for sql server login.
206
+ */
207
+ password?: string | undefined;
208
+ };
209
+ }
210
+ export type ConnectionAuthentication = DefaultAuthentication | NtlmAuthentication | TokenCredentialAuthentication | AzureActiveDirectoryPasswordAuthentication | AzureActiveDirectoryMsiAppServiceAuthentication | AzureActiveDirectoryMsiVmAuthentication | AzureActiveDirectoryAccessTokenAuthentication | AzureActiveDirectoryServicePrincipalSecret | AzureActiveDirectoryDefaultAuthentication;
211
+ interface InternalConnectionConfig {
212
+ server: string;
213
+ authentication: ConnectionAuthentication;
214
+ options: InternalConnectionOptions;
215
+ }
216
+ export interface InternalConnectionOptions {
217
+ abortTransactionOnError: boolean;
218
+ appName: undefined | string;
219
+ camelCaseColumns: boolean;
220
+ cancelTimeout: number;
221
+ columnEncryptionKeyCacheTTL: number;
222
+ columnEncryptionSetting: boolean;
223
+ columnNameReplacer: undefined | ((colName: string, index: number, metadata: Metadata) => string);
224
+ connectionRetryInterval: number;
225
+ connector: undefined | (() => Promise<net.Socket>);
226
+ connectTimeout: number;
227
+ connectionIsolationLevel: typeof ISOLATION_LEVEL[keyof typeof ISOLATION_LEVEL];
228
+ cryptoCredentialsDetails: SecureContextOptions;
229
+ database: undefined | string;
230
+ datefirst: number;
231
+ dateFormat: string;
232
+ debug: {
233
+ data: boolean;
234
+ packet: boolean;
235
+ payload: boolean;
236
+ token: boolean;
237
+ };
238
+ enableAnsiNull: null | boolean;
239
+ enableAnsiNullDefault: null | boolean;
240
+ enableAnsiPadding: null | boolean;
241
+ enableAnsiWarnings: null | boolean;
242
+ enableArithAbort: null | boolean;
243
+ enableConcatNullYieldsNull: null | boolean;
244
+ enableCursorCloseOnCommit: null | boolean;
245
+ enableImplicitTransactions: null | boolean;
246
+ enableNumericRoundabort: null | boolean;
247
+ enableQuotedIdentifier: null | boolean;
248
+ encrypt: string | boolean;
249
+ encryptionKeyStoreProviders: KeyStoreProviderMap | undefined;
250
+ fallbackToDefaultDb: boolean;
251
+ instanceName: undefined | string;
252
+ isolationLevel: typeof ISOLATION_LEVEL[keyof typeof ISOLATION_LEVEL];
253
+ language: string;
254
+ localAddress: undefined | string;
255
+ maxRetriesOnTransientErrors: number;
256
+ multiSubnetFailover: boolean;
257
+ packetSize: number;
258
+ port: undefined | number;
259
+ readOnlyIntent: boolean;
260
+ requestTimeout: number;
261
+ rowCollectionOnDone: boolean;
262
+ rowCollectionOnRequestCompletion: boolean;
263
+ serverName: undefined | string;
264
+ serverSupportsColumnEncryption: boolean;
265
+ tdsVersion: string;
266
+ textsize: number;
267
+ trustedServerNameAE: string | undefined;
268
+ trustServerCertificate: boolean;
269
+ useColumnNames: boolean;
270
+ useUTC: boolean;
271
+ workstationId: undefined | string;
272
+ lowerCaseGuids: boolean;
273
+ }
274
+ interface KeyStoreProviderMap {
275
+ [key: string]: ColumnEncryptionAzureKeyVaultProvider;
276
+ }
277
+ /**
278
+ * @private
279
+ */
280
+ interface State {
281
+ name: string;
282
+ enter?(this: Connection): void;
283
+ exit?(this: Connection, newState: State): void;
284
+ events: {
285
+ socketError?(this: Connection, err: Error): void;
286
+ message?(this: Connection, message: Message): void;
287
+ };
288
+ }
289
+ type Authentication = DefaultAuthentication | NtlmAuthentication | TokenCredentialAuthentication | AzureActiveDirectoryPasswordAuthentication | AzureActiveDirectoryMsiAppServiceAuthentication | AzureActiveDirectoryMsiVmAuthentication | AzureActiveDirectoryAccessTokenAuthentication | AzureActiveDirectoryServicePrincipalSecret | AzureActiveDirectoryDefaultAuthentication;
290
+ type AuthenticationType = Authentication['type'];
291
+ export interface ConnectionConfiguration {
292
+ /**
293
+ * Hostname to connect to.
294
+ */
295
+ server: string;
296
+ /**
297
+ * Configuration options for forming the connection.
298
+ */
299
+ options?: ConnectionOptions;
300
+ /**
301
+ * Authentication related options for connection.
302
+ */
303
+ authentication?: AuthenticationOptions;
304
+ }
305
+ interface DebugOptions {
306
+ /**
307
+ * A boolean, controlling whether [[debug]] events will be emitted with text describing packet data details
308
+ *
309
+ * (default: `false`)
310
+ */
311
+ data: boolean;
312
+ /**
313
+ * A boolean, controlling whether [[debug]] events will be emitted with text describing packet details
314
+ *
315
+ * (default: `false`)
316
+ */
317
+ packet: boolean;
318
+ /**
319
+ * A boolean, controlling whether [[debug]] events will be emitted with text describing packet payload details
320
+ *
321
+ * (default: `false`)
322
+ */
323
+ payload: boolean;
324
+ /**
325
+ * A boolean, controlling whether [[debug]] events will be emitted with text describing token stream tokens
326
+ *
327
+ * (default: `false`)
328
+ */
329
+ token: boolean;
330
+ }
331
+ interface AuthenticationOptions {
332
+ /**
333
+ * Type of the authentication method, valid types are `default`, `ntlm`,
334
+ * `azure-active-directory-password`, `azure-active-directory-access-token`,
335
+ * `azure-active-directory-msi-vm`, `azure-active-directory-msi-app-service`,
336
+ * `azure-active-directory-default`
337
+ * or `azure-active-directory-service-principal-secret`
338
+ */
339
+ type?: AuthenticationType;
340
+ /**
341
+ * Different options for authentication types:
342
+ *
343
+ * * `default`: [[DefaultAuthentication.options]]
344
+ * * `ntlm` :[[NtlmAuthentication]]
345
+ * * `token-credential`: [[CredentialChainAuthentication.options]]
346
+ * * `azure-active-directory-password` : [[AzureActiveDirectoryPasswordAuthentication.options]]
347
+ * * `azure-active-directory-access-token` : [[AzureActiveDirectoryAccessTokenAuthentication.options]]
348
+ * * `azure-active-directory-msi-vm` : [[AzureActiveDirectoryMsiVmAuthentication.options]]
349
+ * * `azure-active-directory-msi-app-service` : [[AzureActiveDirectoryMsiAppServiceAuthentication.options]]
350
+ * * `azure-active-directory-service-principal-secret` : [[AzureActiveDirectoryServicePrincipalSecret.options]]
351
+ * * `azure-active-directory-default` : [[AzureActiveDirectoryDefaultAuthentication.options]]
352
+ */
353
+ options?: any;
354
+ }
355
+ export interface ConnectionOptions {
356
+ /**
357
+ * A boolean determining whether to rollback a transaction automatically if any error is encountered
358
+ * during the given transaction's execution. This sets the value for `SET XACT_ABORT` during the
359
+ * initial SQL phase of a connection [documentation](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact-sql).
360
+ */
361
+ abortTransactionOnError?: boolean | undefined;
362
+ /**
363
+ * Application name used for identifying a specific application in profiling, logging or tracing tools of SQLServer.
364
+ *
365
+ * (default: `Tedious`)
366
+ */
367
+ appName?: string | undefined;
368
+ /**
369
+ * A boolean, controlling whether the column names returned will have the first letter converted to lower case
370
+ * (`true`) or not. This value is ignored if you provide a [[columnNameReplacer]].
371
+ *
372
+ * (default: `false`).
373
+ */
374
+ camelCaseColumns?: boolean;
375
+ /**
376
+ * The number of milliseconds before the [[Request.cancel]] (abort) of a request is considered failed
377
+ *
378
+ * (default: `5000`).
379
+ */
380
+ cancelTimeout?: number;
381
+ /**
382
+ * A function with parameters `(columnName, index, columnMetaData)` and returning a string. If provided,
383
+ * this will be called once per column per result-set. The returned value will be used instead of the SQL-provided
384
+ * column name on row and meta data objects. This allows you to dynamically convert between naming conventions.
385
+ *
386
+ * (default: `null`)
387
+ */
388
+ columnNameReplacer?: (colName: string, index: number, metadata: Metadata) => string;
389
+ /**
390
+ * Number of milliseconds before retrying to establish connection, in case of transient failure.
391
+ *
392
+ * (default:`500`)
393
+ */
394
+ connectionRetryInterval?: number;
395
+ /**
396
+ * Custom connector factory method.
397
+ *
398
+ * (default: `undefined`)
399
+ */
400
+ connector?: () => Promise<net.Socket>;
401
+ /**
402
+ * The number of milliseconds before the attempt to connect is considered failed
403
+ *
404
+ * (default: `15000`).
405
+ */
406
+ connectTimeout?: number;
407
+ /**
408
+ * The default isolation level for new connections. All out-of-transaction queries are executed with this setting.
409
+ *
410
+ * The isolation levels are available from `require('tedious').ISOLATION_LEVEL`.
411
+ * * `READ_UNCOMMITTED`
412
+ * * `READ_COMMITTED`
413
+ * * `REPEATABLE_READ`
414
+ * * `SERIALIZABLE`
415
+ * * `SNAPSHOT`
416
+ *
417
+ * (default: `READ_COMMITED`).
418
+ */
419
+ connectionIsolationLevel?: number;
420
+ /**
421
+ * When encryption is used, an object may be supplied that will be used
422
+ * for the first argument when calling [`tls.createSecurePair`](http://nodejs.org/docs/latest/api/tls.html#tls_tls_createsecurepair_credentials_isserver_requestcert_rejectunauthorized)
423
+ *
424
+ * (default: `{}`)
425
+ */
426
+ cryptoCredentialsDetails?: SecureContextOptions;
427
+ /**
428
+ * Database to connect to (default: dependent on server configuration).
429
+ */
430
+ database?: string | undefined;
431
+ /**
432
+ * Sets the first day of the week to a number from 1 through 7.
433
+ */
434
+ datefirst?: number;
435
+ /**
436
+ * A string representing position of month, day and year in temporal datatypes.
437
+ *
438
+ * (default: `mdy`)
439
+ */
440
+ dateFormat?: string;
441
+ debug?: DebugOptions;
442
+ /**
443
+ * A boolean, controls the way null values should be used during comparison operation.
444
+ *
445
+ * (default: `true`)
446
+ */
447
+ enableAnsiNull?: boolean;
448
+ /**
449
+ * If true, `SET ANSI_NULL_DFLT_ON ON` will be set in the initial sql. This means new columns will be
450
+ * nullable by default. See the [T-SQL documentation](https://msdn.microsoft.com/en-us/library/ms187375.aspx)
451
+ *
452
+ * (default: `true`).
453
+ */
454
+ enableAnsiNullDefault?: boolean;
455
+ /**
456
+ * A boolean, controls if padding should be applied for values shorter than the size of defined column.
457
+ *
458
+ * (default: `true`)
459
+ */
460
+ enableAnsiPadding?: boolean;
461
+ /**
462
+ * If true, SQL Server will follow ISO standard behavior during various error conditions. For details,
463
+ * see [documentation](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-ansi-warnings-transact-sql)
464
+ *
465
+ * (default: `true`)
466
+ */
467
+ enableAnsiWarnings?: boolean;
468
+ /**
469
+ * Ends a query when an overflow or divide-by-zero error occurs during query execution.
470
+ * See [documentation](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-arithabort-transact-sql?view=sql-server-2017)
471
+ * for more details.
472
+ *
473
+ * (default: `true`)
474
+ */
475
+ enableArithAbort?: boolean;
476
+ /**
477
+ * A boolean, determines if concatenation with NULL should result in NULL or empty string value, more details in
478
+ * [documentation](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-concat-null-yields-null-transact-sql)
479
+ *
480
+ * (default: `true`)
481
+ */
482
+ enableConcatNullYieldsNull?: boolean;
483
+ /**
484
+ * A boolean, controls whether cursor should be closed, if the transaction opening it gets committed or rolled
485
+ * back.
486
+ *
487
+ * (default: `null`)
488
+ */
489
+ enableCursorCloseOnCommit?: boolean | null;
490
+ /**
491
+ * A boolean, sets the connection to either implicit or autocommit transaction mode.
492
+ *
493
+ * (default: `false`)
494
+ */
495
+ enableImplicitTransactions?: boolean;
496
+ /**
497
+ * If false, error is not generated during loss of precession.
498
+ *
499
+ * (default: `false`)
500
+ */
501
+ enableNumericRoundabort?: boolean;
502
+ /**
503
+ * If true, characters enclosed in single quotes are treated as literals and those enclosed double quotes are treated as identifiers.
504
+ *
505
+ * (default: `true`)
506
+ */
507
+ enableQuotedIdentifier?: boolean;
508
+ /**
509
+ * A string value that can be only set to 'strict', which indicates the usage TDS 8.0 protocol. Otherwise,
510
+ * a boolean determining whether or not the connection will be encrypted.
511
+ *
512
+ * (default: `true`)
513
+ */
514
+ encrypt?: string | boolean;
515
+ /**
516
+ * By default, if the database requested by [[database]] cannot be accessed,
517
+ * the connection will fail with an error. However, if [[fallbackToDefaultDb]] is
518
+ * set to `true`, then the user's default database will be used instead
519
+ *
520
+ * (default: `false`)
521
+ */
522
+ fallbackToDefaultDb?: boolean;
523
+ /**
524
+ * The instance name to connect to.
525
+ * The SQL Server Browser service must be running on the database server,
526
+ * and UDP port 1434 on the database server must be reachable.
527
+ *
528
+ * (no default)
529
+ *
530
+ * Mutually exclusive with [[port]].
531
+ */
532
+ instanceName?: string | undefined;
533
+ /**
534
+ * The default isolation level that transactions will be run with.
535
+ *
536
+ * The isolation levels are available from `require('tedious').ISOLATION_LEVEL`.
537
+ * * `READ_UNCOMMITTED`
538
+ * * `READ_COMMITTED`
539
+ * * `REPEATABLE_READ`
540
+ * * `SERIALIZABLE`
541
+ * * `SNAPSHOT`
542
+ *
543
+ * (default: `READ_COMMITED`).
544
+ */
545
+ isolationLevel?: number;
546
+ /**
547
+ * Specifies the language environment for the session. The session language determines the datetime formats and system messages.
548
+ *
549
+ * (default: `us_english`).
550
+ */
551
+ language?: string;
552
+ /**
553
+ * A string indicating which network interface (ip address) to use when connecting to SQL Server.
554
+ */
555
+ localAddress?: string | undefined;
556
+ /**
557
+ * A boolean determining whether to parse unique identifier type with lowercase case characters.
558
+ *
559
+ * (default: `false`).
560
+ */
561
+ lowerCaseGuids?: boolean;
562
+ /**
563
+ * The maximum number of connection retries for transient errors.、
564
+ *
565
+ * (default: `3`).
566
+ */
567
+ maxRetriesOnTransientErrors?: number;
568
+ /**
569
+ * Sets the MultiSubnetFailover = True parameter, which can help minimize the client recovery latency when failovers occur.
570
+ *
571
+ * (default: `false`).
572
+ */
573
+ multiSubnetFailover?: boolean;
574
+ /**
575
+ * The size of TDS packets (subject to negotiation with the server).
576
+ * Should be a power of 2.
577
+ *
578
+ * (default: `4096`).
579
+ */
580
+ packetSize?: number;
581
+ /**
582
+ * Port to connect to (default: `1433`).
583
+ *
584
+ * Mutually exclusive with [[instanceName]]
585
+ */
586
+ port?: number | undefined;
587
+ /**
588
+ * A boolean, determining whether the connection will request read only access from a SQL Server Availability
589
+ * Group. For more information, see [here](http://msdn.microsoft.com/en-us/library/hh710054.aspx "Microsoft: Configure Read-Only Routing for an Availability Group (SQL Server)")
590
+ *
591
+ * (default: `false`).
592
+ */
593
+ readOnlyIntent?: boolean;
594
+ /**
595
+ * The number of milliseconds before a request is considered failed, or `0` for no timeout.
596
+ *
597
+ * As soon as a response is received, the timeout is cleared. This means that queries that immediately return a response have ability to run longer than this timeout.
598
+ *
599
+ * (default: `15000`).
600
+ */
601
+ requestTimeout?: number;
602
+ /**
603
+ * A boolean, that when true will expose received rows in Requests done related events:
604
+ * * [[Request.Event_doneInProc]]
605
+ * * [[Request.Event_doneProc]]
606
+ * * [[Request.Event_done]]
607
+ *
608
+ * (default: `false`)
609
+ *
610
+ * Caution: If many row are received, enabling this option could result in
611
+ * excessive memory usage.
612
+ */
613
+ rowCollectionOnDone?: boolean;
614
+ /**
615
+ * A boolean, that when true will expose received rows in Requests' completion callback.See [[Request.constructor]].
616
+ *
617
+ * (default: `false`)
618
+ *
619
+ * Caution: If many row are received, enabling this option could result in
620
+ * excessive memory usage.
621
+ */
622
+ rowCollectionOnRequestCompletion?: boolean;
623
+ /**
624
+ * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.
625
+ *
626
+ * The versions are available from `require('tedious').TDS_VERSION`.
627
+ * * `7_1`
628
+ * * `7_2`
629
+ * * `7_3_A`
630
+ * * `7_3_B`
631
+ * * `7_4`
632
+ *
633
+ * (default: `7_4`)
634
+ */
635
+ tdsVersion?: string | undefined;
636
+ /**
637
+ * Specifies the size of varchar(max), nvarchar(max), varbinary(max), text, ntext, and image data returned by a SELECT statement.
638
+ *
639
+ * (default: `2147483647`)
640
+ */
641
+ textsize?: number;
642
+ /**
643
+ * If "true", the SQL Server SSL certificate is automatically trusted when the communication layer is encrypted using SSL.
644
+ *
645
+ * If "false", the SQL Server validates the server SSL certificate. If the server certificate validation fails,
646
+ * the driver raises an error and terminates the connection. Make sure the value passed to serverName exactly
647
+ * matches the Common Name (CN) or DNS name in the Subject Alternate Name in the server certificate for an SSL connection to succeed.
648
+ *
649
+ * (default: `true`)
650
+ */
651
+ trustServerCertificate?: boolean;
652
+ /**
653
+ *
654
+ */
655
+ serverName?: string;
656
+ /**
657
+ * A boolean determining whether to return rows as arrays or key-value collections.
658
+ *
659
+ * (default: `false`).
660
+ */
661
+ useColumnNames?: boolean;
662
+ /**
663
+ * A boolean determining whether to pass time values in UTC or local time.
664
+ *
665
+ * (default: `true`).
666
+ */
667
+ useUTC?: boolean;
668
+ /**
669
+ * The workstation ID (WSID) of the client, default os.hostname().
670
+ * Used for identifying a specific client in profiling, logging or
671
+ * tracing client activity in SQLServer.
672
+ *
673
+ * The value is reported by the TSQL function HOST_NAME().
674
+ */
675
+ workstationId?: string | undefined;
676
+ }
677
+ interface RoutingData {
678
+ server: string;
679
+ port: number;
680
+ instance: string;
681
+ }
682
+ /**
683
+ * A [[Connection]] instance represents a single connection to a database server.
684
+ *
685
+ * ```js
686
+ * var Connection = require('tedious').Connection;
687
+ * var config = {
688
+ * "authentication": {
689
+ * ...,
690
+ * "options": {...}
691
+ * },
692
+ * "options": {...}
693
+ * };
694
+ * var connection = new Connection(config);
695
+ * ```
696
+ *
697
+ * Only one request at a time may be executed on a connection. Once a [[Request]]
698
+ * has been initiated (with [[Connection.callProcedure]], [[Connection.execSql]],
699
+ * or [[Connection.execSqlBatch]]), another should not be initiated until the
700
+ * [[Request]]'s completion callback is called.
701
+ */
702
+ declare class Connection extends EventEmitter {
703
+ /**
704
+ * @private
705
+ */
706
+ fedAuthRequired: boolean;
707
+ /**
708
+ * @private
709
+ */
710
+ config: InternalConnectionConfig;
711
+ /**
712
+ * @private
713
+ */
714
+ secureContextOptions: SecureContextOptions;
715
+ /**
716
+ * @private
717
+ */
718
+ inTransaction: boolean;
719
+ /**
720
+ * @private
721
+ */
722
+ transactionDescriptors: Buffer[];
723
+ /**
724
+ * @private
725
+ */
726
+ transactionDepth: number;
727
+ /**
728
+ * @private
729
+ */
730
+ isSqlBatch: boolean;
731
+ /**
732
+ * @private
733
+ */
734
+ curTransientRetryCount: number;
735
+ /**
736
+ * @private
737
+ */
738
+ transientErrorLookup: TransientErrorLookup;
739
+ /**
740
+ * @private
741
+ */
742
+ closed: boolean;
743
+ /**
744
+ * @private
745
+ */
746
+ loginError: undefined | AggregateError | ConnectionError;
747
+ /**
748
+ * @private
749
+ */
750
+ debug: Debug;
751
+ /**
752
+ * @private
753
+ */
754
+ ntlmpacket: undefined | any;
755
+ /**
756
+ * @private
757
+ */
758
+ ntlmpacketBuffer: undefined | Buffer;
759
+ /**
760
+ * @private
761
+ */
762
+ STATE: {
763
+ INITIALIZED: State;
764
+ CONNECTING: State;
765
+ SENT_PRELOGIN: State;
766
+ REROUTING: State;
767
+ TRANSIENT_FAILURE_RETRY: State;
768
+ SENT_TLSSSLNEGOTIATION: State;
769
+ SENT_LOGIN7_WITH_STANDARD_LOGIN: State;
770
+ SENT_LOGIN7_WITH_NTLM: State;
771
+ SENT_LOGIN7_WITH_FEDAUTH: State;
772
+ LOGGED_IN_SENDING_INITIAL_SQL: State;
773
+ LOGGED_IN: State;
774
+ SENT_CLIENT_REQUEST: State;
775
+ SENT_ATTENTION: State;
776
+ FINAL: State;
777
+ };
778
+ /**
779
+ * @private
780
+ */
781
+ routingData: undefined | RoutingData;
782
+ /**
783
+ * @private
784
+ */
785
+ messageIo: MessageIO;
786
+ /**
787
+ * @private
788
+ */
789
+ state: State;
790
+ /**
791
+ * @private
792
+ */
793
+ resetConnectionOnNextRequest: undefined | boolean;
794
+ /**
795
+ * @private
796
+ */
797
+ request: undefined | Request | BulkLoad;
798
+ /**
799
+ * @private
800
+ */
801
+ procReturnStatusValue: undefined | any;
802
+ /**
803
+ * @private
804
+ */
805
+ socket: undefined | net.Socket;
806
+ /**
807
+ * @private
808
+ */
809
+ messageBuffer: Buffer;
810
+ /**
811
+ * @private
812
+ */
813
+ cancelTimer: undefined | NodeJS.Timeout;
814
+ /**
815
+ * @private
816
+ */
817
+ requestTimer: undefined | NodeJS.Timeout;
818
+ /**
819
+ * @private
820
+ */
821
+ _cancelAfterRequestSent: () => void;
822
+ /**
823
+ * @private
824
+ */
825
+ databaseCollation: Collation | undefined;
826
+ /**
827
+ * @private
828
+ */
829
+ _onSocketClose: (hadError: boolean) => void;
830
+ /**
831
+ * @private
832
+ */
833
+ _onSocketError: (err: Error) => void;
834
+ /**
835
+ * @private
836
+ */
837
+ _onSocketEnd: () => void;
838
+ /**
839
+ * Note: be aware of the different options field:
840
+ * 1. config.authentication.options
841
+ * 2. config.options
842
+ *
843
+ * ```js
844
+ * const { Connection } = require('tedious');
845
+ *
846
+ * const config = {
847
+ * "authentication": {
848
+ * ...,
849
+ * "options": {...}
850
+ * },
851
+ * "options": {...}
852
+ * };
853
+ *
854
+ * const connection = new Connection(config);
855
+ * ```
856
+ *
857
+ * @param config
858
+ */
859
+ constructor(config: ConnectionConfiguration);
860
+ connect(connectListener?: (err?: Error) => void): void;
861
+ /**
862
+ * The server has reported that the charset has changed.
863
+ */
864
+ on(event: 'charsetChange', listener: (charset: string) => void): this;
865
+ /**
866
+ * The attempt to connect and validate has completed.
867
+ */
868
+ on(event: 'connect',
869
+ /**
870
+ * @param err If successfully connected, will be falsey. If there was a
871
+ * problem (with either connecting or validation), will be an [[Error]] object.
872
+ */
873
+ listener: (err: Error | undefined) => void): this;
874
+ /**
875
+ * The server has reported that the active database has changed.
876
+ * This may be as a result of a successful login, or a `use` statement.
877
+ */
878
+ on(event: 'databaseChange', listener: (databaseName: string) => void): this;
879
+ /**
880
+ * A debug message is available. It may be logged or ignored.
881
+ */
882
+ on(event: 'debug', listener: (messageText: string) => void): this;
883
+ /**
884
+ * Internal error occurs.
885
+ */
886
+ on(event: 'error', listener: (err: Error) => void): this;
887
+ /**
888
+ * The server has issued an error message.
889
+ */
890
+ on(event: 'errorMessage', listener: (message: import('./token/token').ErrorMessageToken) => void): this;
891
+ /**
892
+ * The connection has ended.
893
+ *
894
+ * This may be as a result of the client calling [[close]], the server
895
+ * closing the connection, or a network error.
896
+ */
897
+ on(event: 'end', listener: () => void): this;
898
+ /**
899
+ * The server has issued an information message.
900
+ */
901
+ on(event: 'infoMessage', listener: (message: import('./token/token').InfoMessageToken) => void): this;
902
+ /**
903
+ * The server has reported that the language has changed.
904
+ */
905
+ on(event: 'languageChange', listener: (languageName: string) => void): this;
906
+ /**
907
+ * The connection was reset.
908
+ */
909
+ on(event: 'resetConnection', listener: () => void): this;
910
+ /**
911
+ * A secure connection has been established.
912
+ */
913
+ on(event: 'secure', listener: (cleartext: import('tls').TLSSocket) => void): this;
914
+ /**
915
+ * @private
916
+ */
917
+ emit(event: 'charsetChange', charset: string): boolean;
918
+ /**
919
+ * @private
920
+ */
921
+ emit(event: 'connect', error?: Error): boolean;
922
+ /**
923
+ * @private
924
+ */
925
+ emit(event: 'databaseChange', databaseName: string): boolean;
926
+ /**
927
+ * @private
928
+ */
929
+ emit(event: 'databaseMirroringPartner', partnerInstanceName: string): boolean;
930
+ /**
931
+ * @private
932
+ */
933
+ emit(event: 'debug', messageText: string): boolean;
934
+ /**
935
+ * @private
936
+ */
937
+ emit(event: 'error', error: Error): boolean;
938
+ /**
939
+ * @private
940
+ */
941
+ emit(event: 'errorMessage', message: import('./token/token').ErrorMessageToken): boolean;
942
+ /**
943
+ * @private
944
+ */
945
+ emit(event: 'end'): boolean;
946
+ /**
947
+ * @private
948
+ */
949
+ emit(event: 'infoMessage', message: import('./token/token').InfoMessageToken): boolean;
950
+ /**
951
+ * @private
952
+ */
953
+ emit(event: 'languageChange', languageName: string): boolean;
954
+ /**
955
+ * @private
956
+ */
957
+ emit(event: 'secure', cleartext: import('tls').TLSSocket): boolean;
958
+ /**
959
+ * @private
960
+ */
961
+ emit(event: 'rerouting'): boolean;
962
+ /**
963
+ * @private
964
+ */
965
+ emit(event: 'resetConnection'): boolean;
966
+ /**
967
+ * @private
968
+ */
969
+ emit(event: 'retry'): boolean;
970
+ /**
971
+ * @private
972
+ */
973
+ emit(event: 'rollbackTransaction'): boolean;
974
+ /**
975
+ * Closes the connection to the database.
976
+ *
977
+ * The [[Event_end]] will be emitted once the connection has been closed.
978
+ */
979
+ close(): void;
980
+ /**
981
+ * @private
982
+ */
983
+ initialiseConnection(): Promise<void>;
984
+ /**
985
+ * @private
986
+ */
987
+ cleanupConnection(): void;
988
+ /**
989
+ * @private
990
+ */
991
+ createDebug(): Debug;
992
+ /**
993
+ * @private
994
+ */
995
+ createTokenStreamParser(message: Message, handler: TokenHandler): TokenStreamParser;
996
+ wrapWithTls(socket: net.Socket, signal: AbortSignal): Promise<tls.TLSSocket>;
997
+ connectOnPort(port: number, multiSubnetFailover: boolean, signal: AbortSignal, customConnector?: () => Promise<net.Socket>): Promise<net.Socket>;
998
+ /**
999
+ * @private
1000
+ */
1001
+ closeConnection(): void;
1002
+ /**
1003
+ * @private
1004
+ */
1005
+ createCancelTimer(): void;
1006
+ /**
1007
+ * @private
1008
+ */
1009
+ createRequestTimer(): void;
1010
+ /**
1011
+ * @private
1012
+ */
1013
+ cancelTimeout(): void;
1014
+ /**
1015
+ * @private
1016
+ */
1017
+ requestTimeout(): void;
1018
+ /**
1019
+ * @private
1020
+ */
1021
+ clearCancelTimer(): void;
1022
+ /**
1023
+ * @private
1024
+ */
1025
+ clearRequestTimer(): void;
1026
+ /**
1027
+ * @private
1028
+ */
1029
+ transitionTo(newState: State): void;
1030
+ /**
1031
+ * @private
1032
+ */
1033
+ getEventHandler<T extends keyof State['events']>(eventName: T): NonNullable<State['events'][T]>;
1034
+ /**
1035
+ * @private
1036
+ */
1037
+ dispatchEvent<T extends keyof State['events']>(eventName: T, ...args: Parameters<NonNullable<State['events'][T]>>): void;
1038
+ /**
1039
+ * @private
1040
+ */
1041
+ wrapSocketError(error: Error): ConnectionError;
1042
+ /**
1043
+ * @private
1044
+ */
1045
+ socketEnd(): void;
1046
+ /**
1047
+ * @private
1048
+ */
1049
+ socketClose(): void;
1050
+ /**
1051
+ * @private
1052
+ */
1053
+ sendPreLogin(): void;
1054
+ /**
1055
+ * @private
1056
+ */
1057
+ sendLogin7Packet(): void;
1058
+ /**
1059
+ * @private
1060
+ */
1061
+ sendFedAuthTokenMessage(token: string): void;
1062
+ /**
1063
+ * @private
1064
+ */
1065
+ sendInitialSql(): void;
1066
+ /**
1067
+ * @private
1068
+ */
1069
+ getInitialSql(): string;
1070
+ /**
1071
+ * Execute the SQL batch represented by [[Request]].
1072
+ * There is no param support, and unlike [[Request.execSql]],
1073
+ * it is not likely that SQL Server will reuse the execution plan it generates for the SQL.
1074
+ *
1075
+ * In almost all cases, [[Request.execSql]] will be a better choice.
1076
+ *
1077
+ * @param request A [[Request]] object representing the request.
1078
+ */
1079
+ execSqlBatch(request: Request): void;
1080
+ /**
1081
+ * Execute the SQL represented by [[Request]].
1082
+ *
1083
+ * As `sp_executesql` is used to execute the SQL, if the same SQL is executed multiples times
1084
+ * using this function, the SQL Server query optimizer is likely to reuse the execution plan it generates
1085
+ * for the first execution. This may also result in SQL server treating the request like a stored procedure
1086
+ * which can result in the [[Event_doneInProc]] or [[Event_doneProc]] events being emitted instead of the
1087
+ * [[Event_done]] event you might expect. Using [[execSqlBatch]] will prevent this from occurring but may have a negative performance impact.
1088
+ *
1089
+ * Beware of the way that scoping rules apply, and how they may [affect local temp tables](http://weblogs.sqlteam.com/mladenp/archive/2006/11/03/17197.aspx)
1090
+ * If you're running in to scoping issues, then [[execSqlBatch]] may be a better choice.
1091
+ * See also [issue #24](https://github.com/pekim/tedious/issues/24)
1092
+ *
1093
+ * @param request A [[Request]] object representing the request.
1094
+ */
1095
+ execSql(request: Request): void;
1096
+ /**
1097
+ * Creates a new BulkLoad instance.
1098
+ *
1099
+ * @param table The name of the table to bulk-insert into.
1100
+ * @param options A set of bulk load options.
1101
+ */
1102
+ newBulkLoad(table: string, callback: BulkLoadCallback): BulkLoad;
1103
+ newBulkLoad(table: string, options: BulkLoadOptions, callback: BulkLoadCallback): BulkLoad;
1104
+ /**
1105
+ * Execute a [[BulkLoad]].
1106
+ *
1107
+ * ```js
1108
+ * // We want to perform a bulk load into a table with the following format:
1109
+ * // CREATE TABLE employees (first_name nvarchar(255), last_name nvarchar(255), day_of_birth date);
1110
+ *
1111
+ * const bulkLoad = connection.newBulkLoad('employees', (err, rowCount) => {
1112
+ * // ...
1113
+ * });
1114
+ *
1115
+ * // First, we need to specify the columns that we want to write to,
1116
+ * // and their definitions. These definitions must match the actual table,
1117
+ * // otherwise the bulk load will fail.
1118
+ * bulkLoad.addColumn('first_name', TYPES.NVarchar, { nullable: false });
1119
+ * bulkLoad.addColumn('last_name', TYPES.NVarchar, { nullable: false });
1120
+ * bulkLoad.addColumn('date_of_birth', TYPES.Date, { nullable: false });
1121
+ *
1122
+ * // Execute a bulk load with a predefined list of rows.
1123
+ * //
1124
+ * // Note that these rows are held in memory until the
1125
+ * // bulk load was performed, so if you need to write a large
1126
+ * // number of rows (e.g. by reading from a CSV file),
1127
+ * // passing an `AsyncIterable` is advisable to keep memory usage low.
1128
+ * connection.execBulkLoad(bulkLoad, [
1129
+ * { 'first_name': 'Steve', 'last_name': 'Jobs', 'day_of_birth': new Date('02-24-1955') },
1130
+ * { 'first_name': 'Bill', 'last_name': 'Gates', 'day_of_birth': new Date('10-28-1955') }
1131
+ * ]);
1132
+ * ```
1133
+ *
1134
+ * @param bulkLoad A previously created [[BulkLoad]].
1135
+ * @param rows A [[Iterable]] or [[AsyncIterable]] that contains the rows that should be bulk loaded.
1136
+ */
1137
+ execBulkLoad(bulkLoad: BulkLoad, rows: AsyncIterable<unknown[] | {
1138
+ [columnName: string]: unknown;
1139
+ }> | Iterable<unknown[] | {
1140
+ [columnName: string]: unknown;
1141
+ }>): void;
1142
+ /**
1143
+ * Prepare the SQL represented by the request.
1144
+ *
1145
+ * The request can then be used in subsequent calls to
1146
+ * [[execute]] and [[unprepare]]
1147
+ *
1148
+ * @param request A [[Request]] object representing the request.
1149
+ * Parameters only require a name and type. Parameter values are ignored.
1150
+ */
1151
+ prepare(request: Request): void;
1152
+ /**
1153
+ * Release the SQL Server resources associated with a previously prepared request.
1154
+ *
1155
+ * @param request A [[Request]] object representing the request.
1156
+ * Parameters only require a name and type.
1157
+ * Parameter values are ignored.
1158
+ */
1159
+ unprepare(request: Request): void;
1160
+ /**
1161
+ * Execute previously prepared SQL, using the supplied parameters.
1162
+ *
1163
+ * @param request A previously prepared [[Request]].
1164
+ * @param parameters An object whose names correspond to the names of
1165
+ * parameters that were added to the [[Request]] before it was prepared.
1166
+ * The object's values are passed as the parameters' values when the
1167
+ * request is executed.
1168
+ */
1169
+ execute(request: Request, parameters?: {
1170
+ [key: string]: unknown;
1171
+ }): void;
1172
+ /**
1173
+ * Call a stored procedure represented by [[Request]].
1174
+ *
1175
+ * @param request A [[Request]] object representing the request.
1176
+ */
1177
+ callProcedure(request: Request): void;
1178
+ /**
1179
+ * Start a transaction.
1180
+ *
1181
+ * @param callback
1182
+ * @param name A string representing a name to associate with the transaction.
1183
+ * Optional, and defaults to an empty string. Required when `isolationLevel`
1184
+ * is present.
1185
+ * @param isolationLevel The isolation level that the transaction is to be run with.
1186
+ *
1187
+ * The isolation levels are available from `require('tedious').ISOLATION_LEVEL`.
1188
+ * * `READ_UNCOMMITTED`
1189
+ * * `READ_COMMITTED`
1190
+ * * `REPEATABLE_READ`
1191
+ * * `SERIALIZABLE`
1192
+ * * `SNAPSHOT`
1193
+ *
1194
+ * Optional, and defaults to the Connection's isolation level.
1195
+ */
1196
+ beginTransaction(callback: BeginTransactionCallback, name?: string, isolationLevel?: number): void;
1197
+ /**
1198
+ * Commit a transaction.
1199
+ *
1200
+ * There should be an active transaction - that is, [[beginTransaction]]
1201
+ * should have been previously called.
1202
+ *
1203
+ * @param callback
1204
+ * @param name A string representing a name to associate with the transaction.
1205
+ * Optional, and defaults to an empty string. Required when `isolationLevel`is present.
1206
+ */
1207
+ commitTransaction(callback: CommitTransactionCallback, name?: string): void;
1208
+ /**
1209
+ * Rollback a transaction.
1210
+ *
1211
+ * There should be an active transaction - that is, [[beginTransaction]]
1212
+ * should have been previously called.
1213
+ *
1214
+ * @param callback
1215
+ * @param name A string representing a name to associate with the transaction.
1216
+ * Optional, and defaults to an empty string.
1217
+ * Required when `isolationLevel` is present.
1218
+ */
1219
+ rollbackTransaction(callback: RollbackTransactionCallback, name?: string): void;
1220
+ /**
1221
+ * Set a savepoint within a transaction.
1222
+ *
1223
+ * There should be an active transaction - that is, [[beginTransaction]]
1224
+ * should have been previously called.
1225
+ *
1226
+ * @param callback
1227
+ * @param name A string representing a name to associate with the transaction.\
1228
+ * Optional, and defaults to an empty string.
1229
+ * Required when `isolationLevel` is present.
1230
+ */
1231
+ saveTransaction(callback: SaveTransactionCallback, name: string): void;
1232
+ /**
1233
+ * Run the given callback after starting a transaction, and commit or
1234
+ * rollback the transaction afterwards.
1235
+ *
1236
+ * This is a helper that employs [[beginTransaction]], [[commitTransaction]],
1237
+ * [[rollbackTransaction]], and [[saveTransaction]] to greatly simplify the
1238
+ * use of database transactions and automatically handle transaction nesting.
1239
+ *
1240
+ * @param cb
1241
+ * @param isolationLevel
1242
+ * The isolation level that the transaction is to be run with.
1243
+ *
1244
+ * The isolation levels are available from `require('tedious').ISOLATION_LEVEL`.
1245
+ * * `READ_UNCOMMITTED`
1246
+ * * `READ_COMMITTED`
1247
+ * * `REPEATABLE_READ`
1248
+ * * `SERIALIZABLE`
1249
+ * * `SNAPSHOT`
1250
+ *
1251
+ * Optional, and defaults to the Connection's isolation level.
1252
+ */
1253
+ transaction(cb: (err: Error | null | undefined, txDone?: <T extends TransactionDoneCallback>(err: Error | null | undefined, done: T, ...args: CallbackParameters<T>) => void) => void, isolationLevel?: typeof ISOLATION_LEVEL[keyof typeof ISOLATION_LEVEL]): void;
1254
+ /**
1255
+ * @private
1256
+ */
1257
+ makeRequest(request: Request | BulkLoad, packetType: number, payload: (Iterable<Buffer> | AsyncIterable<Buffer>) & {
1258
+ toString: (indent?: string) => string;
1259
+ }): void;
1260
+ /**
1261
+ * Cancel currently executed request.
1262
+ */
1263
+ cancel(): boolean;
1264
+ /**
1265
+ * Reset the connection to its initial state.
1266
+ * Can be useful for connection pool implementations.
1267
+ *
1268
+ * @param callback
1269
+ */
1270
+ reset(callback: ResetCallback): void;
1271
+ /**
1272
+ * @private
1273
+ */
1274
+ currentTransactionDescriptor(): Buffer<ArrayBufferLike>;
1275
+ /**
1276
+ * @private
1277
+ */
1278
+ getIsolationLevelText(isolationLevel: typeof ISOLATION_LEVEL[keyof typeof ISOLATION_LEVEL]): "read uncommitted" | "repeatable read" | "serializable" | "snapshot" | "read committed";
1279
+ /**
1280
+ * @private
1281
+ */
1282
+ performTlsNegotiation(preloginPayload: PreloginPayload, signal: AbortSignal): Promise<void>;
1283
+ readPreloginResponse(signal: AbortSignal): Promise<PreloginPayload>;
1284
+ /**
1285
+ * @private
1286
+ */
1287
+ performReRouting(): Promise<void>;
1288
+ /**
1289
+ * @private
1290
+ */
1291
+ performTransientFailureRetry(): Promise<void>;
1292
+ /**
1293
+ * @private
1294
+ */
1295
+ performSentLogin7WithStandardLogin(signal: AbortSignal): Promise<RoutingData | undefined>;
1296
+ /**
1297
+ * @private
1298
+ */
1299
+ performSentLogin7WithNTLMLogin(signal: AbortSignal): Promise<RoutingData | undefined>;
1300
+ /**
1301
+ * @private
1302
+ */
1303
+ performSentLogin7WithFedAuth(signal: AbortSignal): Promise<RoutingData | undefined>;
1304
+ /**
1305
+ * @private
1306
+ */
1307
+ performLoggedInSendingInitialSql(signal: AbortSignal): Promise<void>;
1308
+ }
1309
+ export default Connection;