node-firebird 2.3.4 → 2.4.1
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.
- package/README.md +574 -20
- package/lib/callback.d.ts +20 -0
- package/lib/callback.js +6 -16
- package/lib/firebird.msg.json +1370 -1370
- package/lib/gdscodes.d.ts +1519 -1520
- package/lib/gdscodes.js +5 -5
- package/lib/ieee754-decimal.d.ts +38 -0
- package/lib/ieee754-decimal.js +71 -118
- package/lib/index.d.ts +37 -338
- package/lib/index.js +97 -86
- package/lib/messages.d.ts +6 -0
- package/lib/messages.js +135 -162
- package/lib/pool.d.ts +23 -0
- package/lib/pool.js +34 -47
- package/lib/srp.d.ts +51 -0
- package/lib/srp.js +62 -72
- package/lib/types.d.ts +375 -0
- package/lib/types.js +22 -0
- package/lib/unix-crypt.d.ts +1 -0
- package/lib/unix-crypt.js +126 -152
- package/lib/utils.d.ts +16 -0
- package/lib/utils.js +24 -48
- package/lib/wire/connection.d.ts +100 -0
- package/lib/wire/connection.js +1029 -1009
- package/lib/wire/const.d.ts +567 -0
- package/lib/wire/const.js +620 -599
- package/lib/wire/database.d.ts +57 -0
- package/lib/wire/database.js +111 -108
- package/lib/wire/eventConnection.d.ts +16 -0
- package/lib/wire/eventConnection.js +29 -31
- package/lib/wire/fbEventManager.d.ts +45 -0
- package/lib/wire/fbEventManager.js +38 -57
- package/lib/wire/serialize.d.ts +97 -0
- package/lib/wire/serialize.js +42 -141
- package/lib/wire/service.d.ts +66 -0
- package/lib/wire/service.js +374 -401
- package/lib/wire/socket.d.ts +59 -0
- package/lib/wire/socket.js +79 -40
- package/lib/wire/statement.d.ts +25 -0
- package/lib/wire/statement.js +13 -9
- package/lib/wire/transaction.d.ts +21 -0
- package/lib/wire/transaction.js +33 -61
- package/lib/wire/xsqlvar.d.ts +175 -0
- package/lib/wire/xsqlvar.js +169 -269
- package/package.json +12 -4
- package/src/callback.ts +55 -0
- package/{poc/node_modules/node-firebird/lib/gdscodes.js → src/gdscodes.ts} +3 -3
- package/{poc/node_modules/node-firebird/lib/ieee754-decimal.js → src/ieee754-decimal.ts} +7 -14
- package/src/index.ts +157 -0
- package/{poc/node_modules/node-firebird/lib/messages.js → src/messages.ts} +163 -162
- package/src/pool.ts +209 -0
- package/{poc/node_modules/node-firebird/lib/srp.js → src/srp.ts} +74 -33
- package/src/types.ts +419 -0
- package/{poc/node_modules/node-firebird/lib/unix-crypt.js → src/unix-crypt.ts} +6 -12
- package/{poc/node_modules/node-firebird/lib/utils.js → src/utils.ts} +11 -20
- package/{poc/node_modules/node-firebird/lib/wire/connection.js → src/wire/connection.ts} +611 -129
- package/{poc/node_modules/node-firebird/lib/wire/const.js → src/wire/const.ts} +96 -9
- package/{poc/node_modules/node-firebird/lib/wire/database.js → src/wire/database.ts} +110 -44
- package/{poc/node_modules/node-firebird/lib/wire/eventConnection.js → src/wire/eventConnection.ts} +29 -14
- package/{poc/node_modules/node-firebird/lib/wire/fbEventManager.js → src/wire/fbEventManager.ts} +39 -30
- package/{poc/node_modules/node-firebird/lib/wire/serialize.js → src/wire/serialize.ts} +78 -59
- package/{poc/node_modules/node-firebird/lib/wire/service.js → src/wire/service.ts} +90 -88
- package/src/wire/socket.ts +262 -0
- package/src/wire/statement.ts +71 -0
- package/{poc/node_modules/node-firebird/lib/wire/transaction.js → src/wire/transaction.ts} +25 -19
- package/{poc/node_modules/node-firebird/lib/wire/xsqlvar.js → src/wire/xsqlvar.ts} +244 -143
- package/.eslintrc.json +0 -12
- package/.github/workflows/codeql.yml +0 -76
- package/.github/workflows/node.js.yml +0 -95
- package/BIGINT_MIGRATION.md +0 -374
- package/CI_DEBUGGING_GUIDE.md +0 -148
- package/ENCRYPTION_CALLBACK.md +0 -152
- package/FIREBIRD_LOG_FEATURE.md +0 -145
- package/MINIMAL_CHANGES_SUMMARY.md +0 -136
- package/PR_SUMMARY.md +0 -96
- package/ROADMAP.md +0 -223
- package/SRP_PROTOCOL.md +0 -482
- package/poc/README.md +0 -160
- package/poc/helpers.js +0 -59
- package/poc/node_modules/.package-lock.json +0 -14
- package/poc/node_modules/node-firebird/.eslintrc.json +0 -12
- package/poc/node_modules/node-firebird/.github/workflows/codeql.yml +0 -76
- package/poc/node_modules/node-firebird/.github/workflows/node.js.yml +0 -95
- package/poc/node_modules/node-firebird/BIGINT_MIGRATION.md +0 -374
- package/poc/node_modules/node-firebird/CI_DEBUGGING_GUIDE.md +0 -148
- package/poc/node_modules/node-firebird/ENCRYPTION_CALLBACK.md +0 -152
- package/poc/node_modules/node-firebird/FIREBIRD_LOG_FEATURE.md +0 -145
- package/poc/node_modules/node-firebird/LICENSE +0 -373
- package/poc/node_modules/node-firebird/MINIMAL_CHANGES_SUMMARY.md +0 -136
- package/poc/node_modules/node-firebird/PR_SUMMARY.md +0 -96
- package/poc/node_modules/node-firebird/README.md +0 -794
- package/poc/node_modules/node-firebird/ROADMAP.md +0 -223
- package/poc/node_modules/node-firebird/SRP_PROTOCOL.md +0 -482
- package/poc/node_modules/node-firebird/lib/callback.js +0 -38
- package/poc/node_modules/node-firebird/lib/gdscodes.d.ts +0 -1524
- package/poc/node_modules/node-firebird/lib/index.d.ts +0 -316
- package/poc/node_modules/node-firebird/lib/index.js +0 -128
- package/poc/node_modules/node-firebird/lib/pool.js +0 -108
- package/poc/node_modules/node-firebird/lib/wire/socket.js +0 -175
- package/poc/node_modules/node-firebird/lib/wire/statement.js +0 -48
- package/poc/node_modules/node-firebird/package.json +0 -38
- package/poc/node_modules/node-firebird/vitest.config.js +0 -24
- package/poc/package-lock.json +0 -21
- package/poc/package.json +0 -12
- package/poc/reproduce-fixed.js +0 -150
- package/poc/reproduce.js +0 -133
- package/vitest.config.js +0 -27
- /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg +0 -0
- /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg.json +0 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,338 +1,37 @@
|
|
|
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
|
-
ignoreLimbo?: boolean;
|
|
39
|
-
readOnly?: boolean;
|
|
40
|
-
wait?: boolean;
|
|
41
|
-
waitTimeout?: number;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type QueryOptions = {
|
|
45
|
-
timeout: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Database {
|
|
49
|
-
detach(callback?: SimpleCallback): Database;
|
|
50
|
-
transaction(options: TransactionOptions|Isolation|TransactionCallback, callback?: TransactionCallback): Database;
|
|
51
|
-
query(query: string, params: any[], callback: QueryCallback, options?: QueryOptions): Database;
|
|
52
|
-
execute(query: string, params: any[], callback: QueryCallback, options?: QueryOptions): Database;
|
|
53
|
-
sequentially(query: string, params: any[], rowCallback: SequentialCallback, callback: SimpleCallback, options?: QueryOptions | boolean): Database;
|
|
54
|
-
drop(callback: SimpleCallback): void;
|
|
55
|
-
escape(value: any): string;
|
|
56
|
-
attachEvent(callback: any): this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface Transaction {
|
|
60
|
-
query(query: string, params: any[], callback: QueryCallback, options?: QueryOptions): void;
|
|
61
|
-
execute(query: string, params: any[], callback: QueryCallback, options?: QueryOptions): void;
|
|
62
|
-
sequentially(query: string, params: any[], rowCallback: SequentialCallback, callback: SimpleCallback, options?: QueryOptions | boolean): Database;
|
|
63
|
-
commit(callback?: SimpleCallback): void;
|
|
64
|
-
commitRetaining(callback?: SimpleCallback): void;
|
|
65
|
-
rollback(callback?: SimpleCallback): void;
|
|
66
|
-
rollbackRetaining(callback?: SimpleCallback): void;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type SupportedCharacterSet = |
|
|
70
|
-
'NONE' |
|
|
71
|
-
'CP943C' |
|
|
72
|
-
'DOS737' |
|
|
73
|
-
'DOS775' |
|
|
74
|
-
'DOS858' |
|
|
75
|
-
'DOS862' |
|
|
76
|
-
'DOS864' |
|
|
77
|
-
'DOS866' |
|
|
78
|
-
'DOS869' |
|
|
79
|
-
'GB18030' |
|
|
80
|
-
'GBK' |
|
|
81
|
-
'ISO8859_1' |
|
|
82
|
-
'ISO8859_2' |
|
|
83
|
-
'ISO8859_3' |
|
|
84
|
-
'ISO8859_4' |
|
|
85
|
-
'ISO8859_5' |
|
|
86
|
-
'ISO8859_6' |
|
|
87
|
-
'ISO8859_7' |
|
|
88
|
-
'ISO8859_8' |
|
|
89
|
-
'ISO8859_9' |
|
|
90
|
-
'ISO8859_13' |
|
|
91
|
-
'KOI8R' |
|
|
92
|
-
'KOI8U' |
|
|
93
|
-
'TIS620' |
|
|
94
|
-
'UTF8' |
|
|
95
|
-
'WIN1251' |
|
|
96
|
-
'WIN1252' |
|
|
97
|
-
'WIN1253' |
|
|
98
|
-
'WIN1254' |
|
|
99
|
-
'WIN1255' |
|
|
100
|
-
'WIN1256' |
|
|
101
|
-
'WIN1257' |
|
|
102
|
-
'WIN1258' |
|
|
103
|
-
'WIN_1258';
|
|
104
|
-
|
|
105
|
-
export interface Options {
|
|
106
|
-
host?: string;
|
|
107
|
-
port?: number;
|
|
108
|
-
database?: string;
|
|
109
|
-
user?: string;
|
|
110
|
-
password?: string;
|
|
111
|
-
lowercase_keys?: boolean;
|
|
112
|
-
role?: string;
|
|
113
|
-
pageSize?: number;
|
|
114
|
-
retryConnectionInterval?: number;
|
|
115
|
-
encoding?: SupportedCharacterSet;
|
|
116
|
-
blobAsText?: boolean; // only affects for blob subtype 1
|
|
117
|
-
/**
|
|
118
|
-
* Segment size in bytes used when WRITING blobs (op_batch_segments).
|
|
119
|
-
* Default 1024, max 65535. Use 65535 to minimize round-trips on
|
|
120
|
-
* remote/high-latency connections.
|
|
121
|
-
*/
|
|
122
|
-
blobChunkSize?: number;
|
|
123
|
-
/**
|
|
124
|
-
* Buffer size in bytes requested per op_get_segment when READING
|
|
125
|
-
* blobs. Default 1024, max 65535. Use 65535 to minimize round-trips
|
|
126
|
-
* on remote/high-latency connections (~64x fewer round-trips).
|
|
127
|
-
*/
|
|
128
|
-
blobReadChunkSize?: number;
|
|
129
|
-
wireCrypt?: number; // WIRE_CRYPT_DISABLE or WIRE_CRYPT_ENABLE
|
|
130
|
-
wireCompression?: boolean;
|
|
131
|
-
pluginName?: string;
|
|
132
|
-
dbCryptConfig?: string; // Database encryption key callback config (base64: prefix for base64, or plain string)
|
|
133
|
-
/**
|
|
134
|
-
* Timeout in milliseconds for a single pool.get() attach operation.
|
|
135
|
-
* If attach() does not complete within this time the slot is freed,
|
|
136
|
-
* the caller receives an error, and any late-arriving connection is
|
|
137
|
-
* safely discarded. Set to 0 or omit to disable (default: no timeout).
|
|
138
|
-
*
|
|
139
|
-
* Recommended value: 5000–10000 ms depending on network latency and
|
|
140
|
-
* expected Firebird server response time under load.
|
|
141
|
-
*/
|
|
142
|
-
connectTimeout?: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface SvcMgrOptions extends Options {
|
|
146
|
-
manager: true; // Attach to ServiceManager
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export interface ConnectionPool {
|
|
150
|
-
get(callback: DatabaseCallback): void;
|
|
151
|
-
destroy(callback?: SimpleCallback): void;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function attach(options: Options, callback: DatabaseCallback): void;
|
|
155
|
-
export function attach(options: SvcMgrOptions, callback: ServiceManagerCallback): void;
|
|
156
|
-
export function escape(value: any, protocolVersion?: number /*PROTOCOL_VERSION13*/): string;
|
|
157
|
-
export function create(options: Options, callback: DatabaseCallback): void;
|
|
158
|
-
export function attachOrCreate(options: Options, callback: DatabaseCallback): void;
|
|
159
|
-
export function pool(max: number, options: Options): ConnectionPool;
|
|
160
|
-
export function drop(options: Options, callback: SimpleCallback): void;
|
|
161
|
-
|
|
162
|
-
interface ReadableOptions {
|
|
163
|
-
optread?: 'byline' | 'buffer'; // default 'byline'
|
|
164
|
-
buffersize?: number; // default 'byline': 2048, 'buffer': 8192
|
|
165
|
-
timeout?: number;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface BackupOptions extends ReadableOptions {
|
|
169
|
-
database?: string;
|
|
170
|
-
files: string | { filename: string, sizefile: string }[];
|
|
171
|
-
factor?: number; // If backing up to a physical tape device, this switch lets you specify the tape's blocking factor
|
|
172
|
-
verbose?: boolean;
|
|
173
|
-
ignorechecksums?: boolean;
|
|
174
|
-
ignorelimbo?: boolean;
|
|
175
|
-
metadataonly?: boolean;
|
|
176
|
-
nogarbasecollect?: boolean;
|
|
177
|
-
olddescriptions?: boolean;
|
|
178
|
-
nontransportable?: boolean;
|
|
179
|
-
convert?: boolean;
|
|
180
|
-
expand?: boolean;
|
|
181
|
-
notriggers?: boolean;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface NBackupOptions extends ReadableOptions {
|
|
185
|
-
database?: string;
|
|
186
|
-
file: string;
|
|
187
|
-
level?: number; // nb day for incremental
|
|
188
|
-
notriggers?: boolean;
|
|
189
|
-
direct?: 'on' | 'off'; // default 'on'
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface RestoreOptions extends ReadableOptions {
|
|
193
|
-
database?: string;
|
|
194
|
-
files: string | string[];
|
|
195
|
-
verbose?: boolean;
|
|
196
|
-
cachebuffers?: number; // default 2048, gbak -buffers
|
|
197
|
-
pagesize?: boolean; // default 4096
|
|
198
|
-
readonly?: boolean; // default false
|
|
199
|
-
deactivateindexes?: boolean; // default false
|
|
200
|
-
noshadow?: boolean; // default false
|
|
201
|
-
novalidity?: boolean; // default false
|
|
202
|
-
individualcommit?: boolean; // default true
|
|
203
|
-
replace?: boolean; // default false
|
|
204
|
-
create?: boolean; // default true
|
|
205
|
-
useallspace?: boolean; // default false
|
|
206
|
-
metadataonly?: boolean; // default false
|
|
207
|
-
fixfssdata?: string; // default null
|
|
208
|
-
fixfssmetadata?: string; // default null
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export interface NRestoreOptions extends ReadableOptions {
|
|
212
|
-
database?: string;
|
|
213
|
-
files: string | string[];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export interface ValidateOptions extends ReadableOptions {
|
|
217
|
-
database?: string;
|
|
218
|
-
checkdb?: boolean;
|
|
219
|
-
ignorechecksums?: boolean;
|
|
220
|
-
killshadows?: boolean;
|
|
221
|
-
mend?: boolean;
|
|
222
|
-
validate?: boolean;
|
|
223
|
-
full?: boolean;
|
|
224
|
-
sweep?: boolean;
|
|
225
|
-
listlimbo?: boolean;
|
|
226
|
-
icu?: boolean;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export interface StatsOptions extends ReadableOptions {
|
|
230
|
-
database?: string;
|
|
231
|
-
record?: boolean;
|
|
232
|
-
nocreation?: boolean;
|
|
233
|
-
tables?: boolean;
|
|
234
|
-
pages?: boolean;
|
|
235
|
-
header?: boolean;
|
|
236
|
-
indexes?: boolean;
|
|
237
|
-
tablesystem?: boolean;
|
|
238
|
-
encryption?: boolean;
|
|
239
|
-
objects?: string; // space-separated list of object index,table,systemtable
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
interface UserInfo {
|
|
243
|
-
userid: number;
|
|
244
|
-
groupid: number;
|
|
245
|
-
username: string;
|
|
246
|
-
firstname: string;
|
|
247
|
-
middlename: string;
|
|
248
|
-
lastname: string
|
|
249
|
-
admin: number;
|
|
250
|
-
rolename?: string;
|
|
251
|
-
groupname?: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export interface ServerInfo {
|
|
255
|
-
result: number;
|
|
256
|
-
dbinfo?: { database: any[], nbattachment: number, nbdatabase: number };
|
|
257
|
-
fbconfig?: any;
|
|
258
|
-
svcversion?: number;
|
|
259
|
-
fbversion?: string;
|
|
260
|
-
fbimplementation?: string;
|
|
261
|
-
fbcapatibilities: string[];
|
|
262
|
-
pathsecuritydb?: string;
|
|
263
|
-
fbenv?: string;
|
|
264
|
-
fbenvlock?: string;
|
|
265
|
-
fbenvmsg?: string;
|
|
266
|
-
limbotrans?: number[];
|
|
267
|
-
fbusers?: UserInfo[]
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export interface ServerInfoReq {
|
|
271
|
-
dbinfo?: boolean;
|
|
272
|
-
fbconfig?: boolean;
|
|
273
|
-
svcversion?: boolean;
|
|
274
|
-
fbversion?: boolean;
|
|
275
|
-
fbimplementation?: boolean;
|
|
276
|
-
fbcapatibilities?: boolean;
|
|
277
|
-
pathsecuritydb?: boolean;
|
|
278
|
-
fbenv?: boolean;
|
|
279
|
-
fbenvlock?: boolean;
|
|
280
|
-
fbenvmsg?: boolean;
|
|
281
|
-
limbotrans?: boolean;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export interface TraceOptions extends ReadableOptions {
|
|
285
|
-
configfile?: string; // startTrace uses it
|
|
286
|
-
tracename?: string; // startTrace uses it
|
|
287
|
-
traceid?: number; // suspendTrace, stopTrace, and resumeTrace use it
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
type ServiceManagerCallback = (err: any, svc: ServiceManager) => void;
|
|
291
|
-
// @ts-ignore
|
|
292
|
-
type ReadableCallback = (err: any, reader: NodeJS.ReadableStream) => void;
|
|
293
|
-
type InfoCallback = (err: any, info: ServerInfo) => void;
|
|
294
|
-
type LineCallback = (err: any, data: { result: number, line: string }) => void;
|
|
295
|
-
|
|
296
|
-
export enum ShutdownMode { NORMAL = 0, MULTI = 1, SINGLE = 2, FULL = 3 }
|
|
297
|
-
export enum ShutdownKind { FORCED = 0, DENY_TRANSACTION = 1, DENY_ATTACHMENT = 2 }
|
|
298
|
-
|
|
299
|
-
export interface ServiceManager {
|
|
300
|
-
detach(callback?: SimpleCallback, force?: boolean): void;
|
|
301
|
-
backup(options: BackupOptions, callback: ReadableCallback): void;
|
|
302
|
-
nbackup(options: BackupOptions, callback: ReadableCallback): void;
|
|
303
|
-
restore(options: NRestoreOptions, callback: ReadableCallback): void;
|
|
304
|
-
nrestore(options: any, callback: Function): void;
|
|
305
|
-
setDialect(db: string, dialect: 1 | 3, callback: ReadableCallback): void;
|
|
306
|
-
setSweepinterval(db: string, interval: number, callback: Function): void; // gfix -h INTERVAL
|
|
307
|
-
setCachebuffer(db: string, nbpages: any, callback: ReadableCallback): void; // gfix -b NBPAGES
|
|
308
|
-
BringOnline(db: string, callback: ReadableCallback): void; // gfix -o
|
|
309
|
-
Shutdown(db: string, kind: ShutdownKind, delay: number, mode: ShutdownMode, callback: ReadableCallback): void; // server version >= 2.0
|
|
310
|
-
Shutdown(db: string, kind: ShutdownKind, delay: number, callback: ReadableCallback): void; // server version < 2.0
|
|
311
|
-
setShadow(db: string, val: boolean, callback: ReadableCallback): void;
|
|
312
|
-
setForcewrite(db: string, val: boolean, callback: ReadableCallback): void; // gfix -write
|
|
313
|
-
setReservespace(db: string, val: boolean, callback: ReadableCallback): void; // true: gfix -use reserve, false: gfix -use full
|
|
314
|
-
setReadonlyMode(db: string, callback: ReadableCallback): void; // gfix -mode read_only
|
|
315
|
-
setReadwriteMode(db: string, callback: ReadableCallback): void; // gfix -mode read_write
|
|
316
|
-
validate(options: ValidateOptions, callback: ReadableCallback): void; // gfix -validate
|
|
317
|
-
commit(db: string, transactid: number, callback: ReadableCallback): void; // gfix -commit
|
|
318
|
-
rollback(db: string, transactid: number, callback: ReadableCallback): void;
|
|
319
|
-
recover(db: string, transactid: number, callback: ReadableCallback): void;
|
|
320
|
-
getStats(options: StatsOptions, callback: ReadableCallback): void;
|
|
321
|
-
getLog(options: ReadableOptions, callback: ReadableCallback): void;
|
|
322
|
-
getUsers(username: string | null, callback: InfoCallback): void;
|
|
323
|
-
addUser(username: string, password: string, info: UserInfo, callback: ReadableCallback): void;
|
|
324
|
-
editUser(username: string, info: UserInfo, callback: ReadableCallback): void;
|
|
325
|
-
removeUser(username: string, rolename: string | null, callback: ReadableCallback): void;
|
|
326
|
-
getFbserverInfos(infos: ServerInfoReq, options: { buffersize?: number, timeout?: number }, callback: InfoCallback): void; // if infos is empty all options are asked to the service
|
|
327
|
-
startTrace(options: TraceOptions, callback: ReadableCallback): void;
|
|
328
|
-
suspendTrace(options: TraceOptions, callback: ReadableCallback): void;
|
|
329
|
-
resumeTrace(options: TraceOptions, callback: ReadableCallback): void;
|
|
330
|
-
stopTrace(options: TraceOptions, callback: ReadableCallback): void;
|
|
331
|
-
getTraceList(options: ReadableOptions, callback: ReadableCallback): void;
|
|
332
|
-
readline(options: ReadableOptions, callback: LineCallback): void;
|
|
333
|
-
readeof(options: ReadableOptions, callback: LineCallback): void;
|
|
334
|
-
hasRunningAction(options: ReadableOptions, callback: ReadableCallback): void;
|
|
335
|
-
readusers(options: ReadableOptions, callback: ReadableCallback): void;
|
|
336
|
-
readlimbo(options: ReadableOptions, callback: ReadableCallback): void;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
1
|
+
import Connection from './wire/connection';
|
|
2
|
+
import { escape as escapeValue } from './utils';
|
|
3
|
+
import type { Options, SvcMgrOptions, DatabaseCallback, ServiceManagerCallback, SimpleCallback, ConnectionPool } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export { GDSCode } from './gdscodes';
|
|
6
|
+
export declare const AUTH_PLUGIN_LEGACY: string;
|
|
7
|
+
export declare const AUTH_PLUGIN_SRP: string;
|
|
8
|
+
export declare const AUTH_PLUGIN_SRP256: string;
|
|
9
|
+
export declare const AUTH_PLUGIN_SRP384: string;
|
|
10
|
+
export declare const AUTH_PLUGIN_SRP512: string;
|
|
11
|
+
export declare const WIRE_CRYPT_DISABLE: number;
|
|
12
|
+
export declare const WIRE_CRYPT_ENABLE: number;
|
|
13
|
+
/** A transaction sees changes done by uncommitted transactions. */
|
|
14
|
+
export declare const ISOLATION_READ_UNCOMMITTED: number[];
|
|
15
|
+
/** A transaction sees only data committed before the statement has been executed. */
|
|
16
|
+
export declare const ISOLATION_READ_COMMITTED: number[];
|
|
17
|
+
/** A transaction sees during its lifetime only data committed before the transaction has been started. */
|
|
18
|
+
export declare const ISOLATION_REPEATABLE_READ: number[];
|
|
19
|
+
/**
|
|
20
|
+
* This is the strictest isolation level, which enforces transaction serialization.
|
|
21
|
+
* Data accessed in the context of a serializable transaction cannot be accessed by any other transaction.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ISOLATION_SERIALIZABLE: number[];
|
|
24
|
+
export declare const ISOLATION_READ_COMMITTED_READ_ONLY: number[];
|
|
25
|
+
export declare const escape: typeof escapeValue;
|
|
26
|
+
/**
|
|
27
|
+
* The most recent Connection created by attach()/create()/attachOrCreate().
|
|
28
|
+
* Kept for backwards compatibility with the previous CommonJS module where
|
|
29
|
+
* the connection was stored on the module object itself.
|
|
30
|
+
*/
|
|
31
|
+
export declare let connection: Connection | undefined;
|
|
32
|
+
export declare function attach(options: Options, callback: DatabaseCallback): void;
|
|
33
|
+
export declare function attach(options: SvcMgrOptions, callback: ServiceManagerCallback): void;
|
|
34
|
+
export declare function drop(options: Options, callback: SimpleCallback): void;
|
|
35
|
+
export declare function create(options: Options, callback: DatabaseCallback): void;
|
|
36
|
+
export declare function attachOrCreate(options: Options, callback: DatabaseCallback): void;
|
|
37
|
+
export declare function pool(max: number, options: Options): ConnectionPool;
|
package/lib/index.js
CHANGED
|
@@ -1,128 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.connection = exports.escape = exports.ISOLATION_READ_COMMITTED_READ_ONLY = exports.ISOLATION_SERIALIZABLE = exports.ISOLATION_REPEATABLE_READ = exports.ISOLATION_READ_COMMITTED = exports.ISOLATION_READ_UNCOMMITTED = exports.WIRE_CRYPT_ENABLE = exports.WIRE_CRYPT_DISABLE = exports.AUTH_PLUGIN_SRP512 = exports.AUTH_PLUGIN_SRP384 = exports.AUTH_PLUGIN_SRP256 = exports.AUTH_PLUGIN_SRP = exports.AUTH_PLUGIN_LEGACY = exports.GDSCode = void 0;
|
|
21
|
+
exports.attach = attach;
|
|
22
|
+
exports.drop = drop;
|
|
23
|
+
exports.create = create;
|
|
24
|
+
exports.attachOrCreate = attachOrCreate;
|
|
25
|
+
exports.pool = pool;
|
|
26
|
+
const const_1 = __importDefault(require("./wire/const"));
|
|
27
|
+
const callback_1 = require("./callback");
|
|
28
|
+
const connection_1 = __importDefault(require("./wire/connection"));
|
|
29
|
+
const pool_1 = __importDefault(require("./pool"));
|
|
30
|
+
const utils_1 = require("./utils");
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
|
+
var gdscodes_1 = require("./gdscodes");
|
|
33
|
+
Object.defineProperty(exports, "GDSCode", { enumerable: true, get: function () { return gdscodes_1.GDSCode; } });
|
|
34
|
+
if (typeof (setImmediate) === 'undefined') {
|
|
35
|
+
global.setImmediate = function (cb) {
|
|
9
36
|
process.nextTick(cb);
|
|
10
37
|
};
|
|
11
38
|
}
|
|
12
|
-
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
|
|
17
|
-
exports.WIRE_CRYPT_DISABLE =
|
|
18
|
-
exports.WIRE_CRYPT_ENABLE =
|
|
19
|
-
|
|
20
|
-
exports.ISOLATION_READ_UNCOMMITTED =
|
|
21
|
-
|
|
22
|
-
exports.
|
|
23
|
-
|
|
24
|
-
exports.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
exports.AUTH_PLUGIN_LEGACY = const_1.default.AUTH_PLUGIN_LEGACY;
|
|
40
|
+
exports.AUTH_PLUGIN_SRP = const_1.default.AUTH_PLUGIN_SRP;
|
|
41
|
+
exports.AUTH_PLUGIN_SRP256 = const_1.default.AUTH_PLUGIN_SRP256;
|
|
42
|
+
exports.AUTH_PLUGIN_SRP384 = const_1.default.AUTH_PLUGIN_SRP384;
|
|
43
|
+
exports.AUTH_PLUGIN_SRP512 = const_1.default.AUTH_PLUGIN_SRP512;
|
|
44
|
+
exports.WIRE_CRYPT_DISABLE = const_1.default.WIRE_CRYPT_DISABLE;
|
|
45
|
+
exports.WIRE_CRYPT_ENABLE = const_1.default.WIRE_CRYPT_ENABLE;
|
|
46
|
+
/** A transaction sees changes done by uncommitted transactions. */
|
|
47
|
+
exports.ISOLATION_READ_UNCOMMITTED = const_1.default.ISOLATION_READ_UNCOMMITTED;
|
|
48
|
+
/** A transaction sees only data committed before the statement has been executed. */
|
|
49
|
+
exports.ISOLATION_READ_COMMITTED = const_1.default.ISOLATION_READ_COMMITTED;
|
|
50
|
+
/** A transaction sees during its lifetime only data committed before the transaction has been started. */
|
|
51
|
+
exports.ISOLATION_REPEATABLE_READ = const_1.default.ISOLATION_REPEATABLE_READ;
|
|
52
|
+
/**
|
|
53
|
+
* This is the strictest isolation level, which enforces transaction serialization.
|
|
54
|
+
* Data accessed in the context of a serializable transaction cannot be accessed by any other transaction.
|
|
55
|
+
*/
|
|
56
|
+
exports.ISOLATION_SERIALIZABLE = const_1.default.ISOLATION_SERIALIZABLE;
|
|
57
|
+
exports.ISOLATION_READ_COMMITTED_READ_ONLY = const_1.default.ISOLATION_READ_COMMITTED_READ_ONLY;
|
|
58
|
+
exports.escape = utils_1.escape;
|
|
59
|
+
function attach(options, callback) {
|
|
60
|
+
var host = options.host || const_1.default.DEFAULT_HOST;
|
|
61
|
+
var port = options.port || const_1.default.DEFAULT_PORT;
|
|
31
62
|
var manager = options.manager || false;
|
|
32
|
-
var cnx =
|
|
33
|
-
|
|
63
|
+
var cnx = exports.connection = new connection_1.default(host, port, function (err) {
|
|
34
64
|
if (err) {
|
|
35
|
-
doError(err, callback);
|
|
65
|
+
(0, callback_1.doError)(err, callback);
|
|
36
66
|
return;
|
|
37
67
|
}
|
|
38
|
-
|
|
39
|
-
cnx.connect(options, function(err) {
|
|
68
|
+
cnx.connect(options, function (err) {
|
|
40
69
|
if (err) {
|
|
41
|
-
doError(err, callback);
|
|
42
|
-
}
|
|
70
|
+
(0, callback_1.doError)(err, callback);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
43
73
|
if (manager)
|
|
44
74
|
cnx.svcattach(options, callback);
|
|
45
75
|
else
|
|
46
76
|
cnx.attach(options, callback);
|
|
47
77
|
}
|
|
48
78
|
});
|
|
49
|
-
|
|
50
79
|
}, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
exports.
|
|
65
|
-
var host = options.host || Const.DEFAULT_HOST;
|
|
66
|
-
var port = options.port || Const.DEFAULT_PORT;
|
|
67
|
-
var cnx = this.connection = new Connection(host, port, function(err) {
|
|
68
|
-
|
|
80
|
+
}
|
|
81
|
+
function drop(options, callback) {
|
|
82
|
+
attach(options, function (err, db) {
|
|
83
|
+
if (err) {
|
|
84
|
+
callback({ error: err, message: "Drop error" });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
db.drop(callback);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function create(options, callback) {
|
|
91
|
+
var host = options.host || const_1.default.DEFAULT_HOST;
|
|
92
|
+
var port = options.port || const_1.default.DEFAULT_PORT;
|
|
93
|
+
var cnx = exports.connection = new connection_1.default(host, port, function (err) {
|
|
69
94
|
var self = cnx;
|
|
70
|
-
|
|
71
95
|
if (err) {
|
|
72
|
-
callback({ error: err, message: "Connect error" });
|
|
96
|
+
callback({ error: err, message: "Connect error" }, undefined);
|
|
73
97
|
return;
|
|
74
98
|
}
|
|
75
|
-
|
|
76
|
-
cnx.connect(options, function(err) {
|
|
99
|
+
cnx.connect(options, function (err) {
|
|
77
100
|
if (err) {
|
|
78
|
-
self.db
|
|
79
|
-
|
|
101
|
+
if (self.db)
|
|
102
|
+
self.db.emit('error', err);
|
|
103
|
+
(0, callback_1.doError)(err, callback);
|
|
80
104
|
return;
|
|
81
105
|
}
|
|
82
|
-
|
|
83
106
|
cnx.createDatabase(options, callback);
|
|
84
107
|
});
|
|
85
108
|
}, options);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
var port = options.port || Const.DEFAULT_PORT;
|
|
92
|
-
|
|
93
|
-
var cnx = this.connection = new Connection(host, port, function(err) {
|
|
94
|
-
|
|
109
|
+
}
|
|
110
|
+
function attachOrCreate(options, callback) {
|
|
111
|
+
var host = options.host || const_1.default.DEFAULT_HOST;
|
|
112
|
+
var port = options.port || const_1.default.DEFAULT_PORT;
|
|
113
|
+
var cnx = exports.connection = new connection_1.default(host, port, function (err) {
|
|
95
114
|
var self = cnx;
|
|
96
|
-
|
|
97
115
|
if (err) {
|
|
98
|
-
callback({ error: err, message: "Connect error" });
|
|
116
|
+
callback({ error: err, message: "Connect error" }, undefined);
|
|
99
117
|
return;
|
|
100
118
|
}
|
|
101
|
-
|
|
102
|
-
cnx.connect(options, function(err) {
|
|
103
|
-
|
|
119
|
+
cnx.connect(options, function (err) {
|
|
104
120
|
if (err) {
|
|
105
|
-
doError(err, callback);
|
|
121
|
+
(0, callback_1.doError)(err, callback);
|
|
106
122
|
return;
|
|
107
123
|
}
|
|
108
|
-
|
|
109
|
-
cnx.attach(options, function(err, ret) {
|
|
110
|
-
|
|
124
|
+
cnx.attach(options, function (err, ret) {
|
|
111
125
|
if (!err) {
|
|
112
126
|
if (self.db)
|
|
113
127
|
self.db.emit('connect', ret);
|
|
114
|
-
doCallback(ret, callback);
|
|
128
|
+
(0, callback_1.doCallback)(ret, callback);
|
|
115
129
|
return;
|
|
116
130
|
}
|
|
117
|
-
|
|
118
131
|
cnx.createDatabase(options, callback);
|
|
119
132
|
});
|
|
120
133
|
});
|
|
121
|
-
|
|
122
134
|
}, options);
|
|
123
|
-
}
|
|
124
|
-
|
|
135
|
+
}
|
|
125
136
|
// Pooling
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
137
|
+
function pool(max, options) {
|
|
138
|
+
return new pool_1.default(attach, max, Object.assign({}, options, { isPool: true }));
|
|
139
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FbStatusItem } from './callback';
|
|
2
|
+
export declare const msgNumber: (facility: number, code: number) => number;
|
|
3
|
+
export declare const getCode: (code: number) => number;
|
|
4
|
+
export declare const getFacility: (code: number) => number;
|
|
5
|
+
export declare const getClass: (code: number) => number;
|
|
6
|
+
export declare const lookupMessages: (status: FbStatusItem[], messageFile: string, callback: (text?: string) => void) => void;
|