forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssql.d.ts
268 lines (238 loc) · 10.7 KB
/
mssql.d.ts
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// Type definitions for mssql v2.2.0
// Project: https://www.npmjs.com/package/mssql
// Definitions by: COLSA Corporation <http://www.colsa.com/>, Ben Farr <https://github.com/jaminfarr>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "mssql" {
import events = require('events');
type sqlTypeWithNoParams = { type: sqlTypeFactoryWithNoParams }
type sqlTypeWithLength = { type: sqlTypeFactoryWithLength, length: number }
type sqlTypeWithScale = { type: sqlTypeFactoryWithScale, scale: number }
type sqlTypeWithPrecisionScale = { type: sqlTypeFactoryWithPrecisionScale, precision: number, scale: number }
type sqlTypeWithTvpType = { type: sqlTypeFactoryWithTvpType, tvpType: any }
type sqlTypeFactoryWithNoParams = () => sqlTypeWithNoParams;
type sqlTypeFactoryWithLength = (length?: number) => sqlTypeWithLength;
type sqlTypeFactoryWithScale = (scale?: number) => sqlTypeWithScale;
type sqlTypeFactoryWithPrecisionScale = (precision?: number, scale?: number) => sqlTypeWithPrecisionScale;
type sqlTypeFactoryWithTvpType = (tvpType: any) => sqlTypeWithTvpType;
export var VarChar: sqlTypeFactoryWithLength;
export var NVarChar: sqlTypeFactoryWithLength;
export var Text: sqlTypeFactoryWithNoParams;
export var Int: sqlTypeFactoryWithNoParams;
export var BigInt: sqlTypeFactoryWithNoParams;
export var TinyInt: sqlTypeFactoryWithNoParams;
export var SmallInt: sqlTypeFactoryWithNoParams;
export var Bit: sqlTypeFactoryWithNoParams;
export var Float: sqlTypeFactoryWithNoParams;
export var Numeric: sqlTypeFactoryWithPrecisionScale;
export var Decimal: sqlTypeFactoryWithPrecisionScale;
export var Real: sqlTypeFactoryWithNoParams;
export var Date: sqlTypeFactoryWithNoParams;
export var DateTime: sqlTypeFactoryWithNoParams;
export var DateTime2: sqlTypeFactoryWithScale;
export var DateTimeOffset: sqlTypeFactoryWithScale;
export var SmallDateTime: sqlTypeFactoryWithNoParams;
export var Time: sqlTypeFactoryWithScale;
export var UniqueIdentifier: sqlTypeFactoryWithNoParams;
export var SmallMoney: sqlTypeFactoryWithNoParams;
export var Money: sqlTypeFactoryWithNoParams;
export var Binary: sqlTypeFactoryWithNoParams;
export var VarBinary: sqlTypeFactoryWithLength;
export var Image: sqlTypeFactoryWithNoParams;
export var Xml: sqlTypeFactoryWithNoParams;
export var Char: sqlTypeFactoryWithLength;
export var NChar: sqlTypeFactoryWithLength;
export var NText: sqlTypeFactoryWithNoParams;
export var TVP: sqlTypeFactoryWithTvpType;
export var UDT: sqlTypeFactoryWithNoParams;
export var Geography: sqlTypeFactoryWithNoParams;
export var Geometry: sqlTypeFactoryWithNoParams;
export var TYPES: {
VarChar: sqlTypeFactoryWithLength;
NVarChar: sqlTypeFactoryWithLength;
Text: sqlTypeFactoryWithNoParams;
Int: sqlTypeFactoryWithNoParams;
BigInt: sqlTypeFactoryWithNoParams;
TinyInt: sqlTypeFactoryWithNoParams;
SmallInt: sqlTypeFactoryWithNoParams;
Bit: sqlTypeFactoryWithNoParams;
Float: sqlTypeFactoryWithNoParams;
Numeric: sqlTypeFactoryWithPrecisionScale;
Decimal: sqlTypeFactoryWithPrecisionScale;
Real: sqlTypeFactoryWithNoParams;
Date: sqlTypeFactoryWithNoParams;
DateTime: sqlTypeFactoryWithNoParams;
DateTime2: sqlTypeFactoryWithScale;
DateTimeOffset: sqlTypeFactoryWithScale;
SmallDateTime: sqlTypeFactoryWithNoParams;
Time: sqlTypeFactoryWithScale;
UniqueIdentifier: sqlTypeFactoryWithNoParams;
SmallMoney: sqlTypeFactoryWithNoParams;
Money: sqlTypeFactoryWithNoParams;
Binary: sqlTypeFactoryWithNoParams;
VarBinary: sqlTypeFactoryWithLength;
Image: sqlTypeFactoryWithNoParams;
Xml: sqlTypeFactoryWithNoParams;
Char: sqlTypeFactoryWithLength;
NChar: sqlTypeFactoryWithLength;
NText: sqlTypeFactoryWithNoParams;
TVP: sqlTypeFactoryWithTvpType;
UDT: sqlTypeFactoryWithNoParams;
Geography: sqlTypeFactoryWithNoParams;
Geometry: sqlTypeFactoryWithNoParams;
};
export var MAX: number;
export var fix: boolean;
export var Promise: any;
interface IMap extends Array<{js: any, sql: any }> {
register(jstype: any, sql: any): void;
}
export var map: IMap;
export var DRIVERS: string[];
type recordSet = any;
type IIsolationLevel = number;
export var ISOLATION_LEVEL: {
READ_UNCOMMITTED: IIsolationLevel
READ_COMMITTED: IIsolationLevel
REPEATABLE_READ: IIsolationLevel
SERIALIZABLE: IIsolationLevel
SNAPSHOT: IIsolationLevel
}
export interface IOptions {
encrypt: boolean;
}
export interface IPool {
min: number;
max: number;
idleTimeoutMillis: number;
}
export var pool: IPool;
export interface config {
driver?: string;
user?: string;
password?: string;
server: string;
port?: number;
domain?: string;
database: string;
connectionTimeout?: number;
requestTimeout?: number;
stream?: boolean;
options?: IOptions;
pool?: IPool;
}
export class Connection extends events.EventEmitter {
public connected: boolean;
public connecting: boolean;
public driver: string;
public constructor(config: config, callback?: (err?: any) => void);
public connect(): Promise<void>;
public connect(callback: (err: any) => void): void;
public close(): Promise<void>;
public close(callback: (err: any) => void): void;
}
export class ConnectionError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
class columns {
public add(name: string, type: any, options: any): void;
}
class rows {
public add(...row: any[]): void;
}
export class Table {
public create: boolean;
public columns: columns;
public rows: rows;
public constructor(tableName: string);
}
interface IRequestParameters {
[name: string]: {
name: string;
type: any;
io: number;
value: any;
length: number;
scale: number;
precision: number;
tvpType: any;
}
}
export class Request extends events.EventEmitter {
public connection: Connection;
public transaction: Transaction;
public pstatement: PreparedStatement;
public parameters: IRequestParameters;
public verbose: boolean;
public multiple: boolean;
public canceled: boolean;
public stream: any;
public constructor(connection?: Connection);
public constructor(transaction: Transaction);
public constructor(preparedStatement: PreparedStatement);
public execute(procedure: string): Promise<recordSet>;
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public input(name: string, value: any): void;
public input(name: string, type: any, value: any): void;
public output(name: string, type: any, value?: any): void;
public pipe(stream: NodeJS.WritableStream): void;
public query(command: string): Promise<void>;
public query(command: string, callback: (err?: any, recordset?: any) => void): void;
public batch(batch: string): Promise<recordSet>;
public batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
public bulk(table: Table): Promise<void>;
public bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
public cancel(): void;
}
export class RequestError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
export class Transaction extends events.EventEmitter {
public connection: Connection;
public isolationLevel: IIsolationLevel;
public constructor(connection?: Connection);
public begin(isolationLevel?: IIsolationLevel): Promise<void>;
public begin(isolationLevel?: IIsolationLevel, callback?: (err?: any) => void): void;
public commit(): Promise<void>;
public commit(callback: (err?: any) => void): void;
public rollback(): Promise<void>;
public rollback(callback: (err?: any) => void): void;
}
export class TransactionError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
export class PreparedStatement extends events.EventEmitter {
public connection: Connection;
public transaction: Transaction;
public prepared: boolean;
public statement: string;
public parameters: IRequestParameters;
public multiple: boolean;
public stream: any;
public constructor(connection?: Connection);
public input(name: string, type: any): void;
public output(name: string, type: any): void;
public prepare(statement?: string): Promise<void>;
public prepare(statement?: string, callback?: (err?: any) => void): void;
public execute(values: Object): Promise<recordSet>;
public execute(values: Object, callback: (err: any, recordSet: recordSet) => void): void;
public unprepare(): Promise<void>;
public unprepare(callback: (err?: any) => void): void;
}
export class PreparedStatementError implements Error {
constructor(message: string, code?: any)
public name: string;
public message: string;
public code: string;
}
}