node-firebird 2.8.1 → 2.10.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.
- package/README.md +268 -7
- package/lib/index.d.ts +17 -9
- package/lib/index.js +42 -3
- package/lib/named-params.d.ts +42 -0
- package/lib/named-params.js +133 -0
- package/lib/pool.js +1 -1
- package/lib/srp.d.ts +3 -3
- package/lib/types.d.ts +185 -25
- package/lib/uri.d.ts +57 -0
- package/lib/uri.js +193 -0
- package/lib/wire/connection.d.ts +92 -59
- package/lib/wire/connection.js +286 -55
- package/lib/wire/const.d.ts +9 -1
- package/lib/wire/const.js +21 -9
- package/lib/wire/database.d.ts +51 -26
- package/lib/wire/database.js +26 -8
- package/lib/wire/eventConnection.js +5 -3
- package/lib/wire/query-stream.d.ts +18 -0
- package/lib/wire/query-stream.js +73 -0
- package/lib/wire/serialize.d.ts +18 -2
- package/lib/wire/serialize.js +7 -0
- package/lib/wire/service.d.ts +42 -0
- package/lib/wire/service.js +145 -0
- package/lib/wire/socket.d.ts +3 -1
- package/lib/wire/socket.js +5 -2
- package/lib/wire/statement.d.ts +40 -20
- package/lib/wire/statement.js +26 -6
- package/lib/wire/transaction.d.ts +32 -18
- package/lib/wire/transaction.js +50 -8
- package/lib/wire/wire-types.d.ts +116 -0
- package/lib/wire/wire-types.js +10 -0
- package/lib/wire/xsqlvar.d.ts +18 -18
- package/package.json +1 -1
- package/src/index.ts +54 -15
- package/src/messages.ts +1 -1
- package/src/named-params.ts +145 -0
- package/src/pool.ts +1 -1
- package/src/srp.ts +6 -6
- package/src/types.ts +183 -25
- package/src/unix-crypt.ts +9 -9
- package/src/uri.ts +204 -0
- package/src/wire/connection.ts +481 -234
- package/src/wire/const.ts +21 -9
- package/src/wire/database.ts +75 -43
- package/src/wire/eventConnection.ts +8 -5
- package/src/wire/query-stream.ts +80 -0
- package/src/wire/serialize.ts +29 -0
- package/src/wire/service.ts +188 -6
- package/src/wire/socket.ts +17 -8
- package/src/wire/statement.ts +68 -31
- package/src/wire/transaction.ts +85 -33
- package/src/wire/wire-types.ts +127 -0
- package/src/wire/xsqlvar.ts +9 -7
package/lib/wire/statement.d.ts
CHANGED
|
@@ -3,34 +3,54 @@
|
|
|
3
3
|
* Statement
|
|
4
4
|
*
|
|
5
5
|
***************************************/
|
|
6
|
+
import { type Callback, type SimpleCallback } from '../callback';
|
|
7
|
+
import type Connection from './connection';
|
|
8
|
+
import type Transaction from './transaction';
|
|
9
|
+
import type { SQLVarBase } from './xsqlvar';
|
|
10
|
+
import type { QueryOptions, QueryParams } from '../types';
|
|
6
11
|
declare class Statement {
|
|
7
|
-
connection:
|
|
12
|
+
connection: Connection;
|
|
8
13
|
query: string;
|
|
9
14
|
type: number;
|
|
10
|
-
output:
|
|
11
|
-
input:
|
|
12
|
-
options
|
|
15
|
+
output: SQLVarBase[];
|
|
16
|
+
input: SQLVarBase[];
|
|
17
|
+
/** per-execute query options (asObject/asStream/timeout/...) */
|
|
18
|
+
options: (QueryOptions & {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}) | undefined;
|
|
13
21
|
handle: number;
|
|
14
22
|
plan: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder names in positional order when this statement was
|
|
25
|
+
* prepared from SQL with named placeholders (namedPlaceholders on),
|
|
26
|
+
* null/undefined otherwise. Set by Transaction.newStatement.
|
|
27
|
+
*/
|
|
28
|
+
namedParams?: string[] | null;
|
|
29
|
+
/** set when an execute/fetch on this statement errored — the statement
|
|
30
|
+
* is dropped on release instead of going back into the cache */
|
|
31
|
+
_failed?: boolean;
|
|
32
|
+
/** rows fetched so far by the current cursor (decodeResponse) */
|
|
33
|
+
nbrowsfetched?: number;
|
|
34
|
+
constructor(connection: Connection);
|
|
35
|
+
close(callback?: SimpleCallback): void;
|
|
36
|
+
drop(callback?: SimpleCallback): void;
|
|
37
|
+
release(callback?: SimpleCallback): void;
|
|
38
|
+
execute(transaction: Transaction, params?: any, callback?: any, options?: any): void;
|
|
39
|
+
fetch(transaction: Transaction, count: number | string, callback: Callback): void;
|
|
40
|
+
fetchScroll(transaction: Transaction, direction: string | number, offset?: any, count?: any, callback?: any): void;
|
|
41
|
+
fetchAll(transaction: Transaction, callback: Callback): void;
|
|
24
42
|
/**
|
|
25
43
|
* Execute this statement once per row via the Firebird 4 batch API
|
|
26
|
-
* (protocol 16+). `rows` is an array of parameter arrays
|
|
44
|
+
* (protocol 16+). `rows` is an array of parameter arrays — or, when the
|
|
45
|
+
* statement was prepared with named placeholders, of values-by-name
|
|
46
|
+
* objects (the two forms can be mixed).
|
|
27
47
|
*/
|
|
28
|
-
executeBatch(transaction:
|
|
29
|
-
executeAsync(transaction:
|
|
30
|
-
executeBatchAsync(transaction:
|
|
31
|
-
fetchAsync(transaction:
|
|
32
|
-
fetchScrollAsync(transaction:
|
|
33
|
-
fetchAllAsync(transaction:
|
|
48
|
+
executeBatch(transaction: Transaction, rows: QueryParams[], callback?: any, options?: any): void;
|
|
49
|
+
executeAsync(transaction: Transaction, params?: any, options?: any): Promise<any>;
|
|
50
|
+
executeBatchAsync(transaction: Transaction, rows: QueryParams[], options?: any): Promise<any>;
|
|
51
|
+
fetchAsync(transaction: Transaction, count: number | string): Promise<any>;
|
|
52
|
+
fetchScrollAsync(transaction: Transaction, direction: string | number, offset?: any, count?: any): Promise<any>;
|
|
53
|
+
fetchAllAsync(transaction: Transaction): Promise<any>;
|
|
34
54
|
closeAsync(): Promise<void>;
|
|
35
55
|
dropAsync(): Promise<void>;
|
|
36
56
|
releaseAsync(): Promise<void>;
|
package/lib/wire/statement.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
***************************************/
|
|
7
7
|
const callback_1 = require("../callback");
|
|
8
|
+
const named_params_1 = require("../named-params");
|
|
8
9
|
class Statement {
|
|
9
10
|
constructor(connection) {
|
|
10
11
|
this.connection = connection;
|
|
@@ -16,11 +17,7 @@ class Statement {
|
|
|
16
17
|
this.connection.dropStatement(this, callback);
|
|
17
18
|
}
|
|
18
19
|
release(callback) {
|
|
19
|
-
|
|
20
|
-
if (cache_query)
|
|
21
|
-
this.connection.closeStatement(this, callback);
|
|
22
|
-
else
|
|
23
|
-
this.connection.dropStatement(this, callback);
|
|
20
|
+
this.connection.releaseStatement(this, callback);
|
|
24
21
|
}
|
|
25
22
|
execute(transaction, params, callback, options) {
|
|
26
23
|
if (params instanceof Function) {
|
|
@@ -28,6 +25,15 @@ class Statement {
|
|
|
28
25
|
callback = params;
|
|
29
26
|
params = undefined;
|
|
30
27
|
}
|
|
28
|
+
if (this.namedParams && (0, named_params_1.isNamedParamsObject)(params)) {
|
|
29
|
+
try {
|
|
30
|
+
params = (0, named_params_1.bindNamedParams)(this.namedParams, params);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
(0, callback_1.doError)(err, callback);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
31
37
|
this.options = options;
|
|
32
38
|
this.connection.executeStatement(transaction, this, params, callback, options);
|
|
33
39
|
}
|
|
@@ -51,9 +57,23 @@ class Statement {
|
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* Execute this statement once per row via the Firebird 4 batch API
|
|
54
|
-
* (protocol 16+). `rows` is an array of parameter arrays
|
|
60
|
+
* (protocol 16+). `rows` is an array of parameter arrays — or, when the
|
|
61
|
+
* statement was prepared with named placeholders, of values-by-name
|
|
62
|
+
* objects (the two forms can be mixed).
|
|
55
63
|
*/
|
|
56
64
|
executeBatch(transaction, rows, callback, options) {
|
|
65
|
+
var names = this.namedParams;
|
|
66
|
+
if (names && Array.isArray(rows)) {
|
|
67
|
+
try {
|
|
68
|
+
rows = rows.map(function (row) {
|
|
69
|
+
return (0, named_params_1.isNamedParamsObject)(row) ? (0, named_params_1.bindNamedParams)(names, row) : row;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
(0, callback_1.doError)(err, callback);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
57
77
|
this.connection.executeBatch(transaction, this, rows, callback, options);
|
|
58
78
|
}
|
|
59
79
|
/* Promise / async-await API — wrappers over the callback methods above. */
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import { type Callback, type SimpleCallback } from '../callback';
|
|
2
|
+
import type Connection from './connection';
|
|
3
|
+
import type Database from './database';
|
|
4
|
+
import type Statement from './statement';
|
|
5
|
+
import type { BatchCb, StatementCb, InternalQueryOptions } from './wire-types';
|
|
6
|
+
import type { BatchOptions, BatchResult, QueryOptions, QueryParams, QueryStreamOptions, SequentialCallback } from '../types';
|
|
1
7
|
declare class Transaction {
|
|
2
|
-
connection:
|
|
3
|
-
db:
|
|
8
|
+
connection: Connection;
|
|
9
|
+
db: Database;
|
|
4
10
|
handle: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
constructor(connection: Connection);
|
|
12
|
+
/** Per-call options.namedPlaceholders overrides the connection option. */
|
|
13
|
+
private namedPlaceholdersEnabled;
|
|
14
|
+
newStatement(query: string, callback: StatementCb, options?: InternalQueryOptions): void;
|
|
15
|
+
execute(query: string, params?: QueryParams | Callback, callback?: any, options?: InternalQueryOptions): void;
|
|
16
|
+
sequentially(query: string, params?: any, on?: any, callback?: any, options?: InternalQueryOptions | boolean): this;
|
|
17
|
+
/**
|
|
18
|
+
* Run `query` inside this transaction and return an object-mode
|
|
19
|
+
* Readable emitting one row per chunk, with real backpressure (see
|
|
20
|
+
* Database.queryStream). The transaction is NOT committed when the
|
|
21
|
+
* stream ends — commit or roll back yourself.
|
|
22
|
+
*/
|
|
23
|
+
queryStream(query: string, params?: QueryParams, options?: QueryStreamOptions): import("node:stream").Readable;
|
|
24
|
+
query(query: string, params?: QueryParams | Callback, callback?: any, options?: InternalQueryOptions): void;
|
|
11
25
|
/**
|
|
12
26
|
* Execute `query` once per row in `rows` using the Firebird 4 batch API
|
|
13
27
|
* (protocol 16+, single network flush). The callback receives a
|
|
@@ -17,16 +31,16 @@ declare class Transaction {
|
|
|
17
31
|
* commit or roll back yourself (or use db.executeBatch for
|
|
18
32
|
* all-or-nothing semantics).
|
|
19
33
|
*/
|
|
20
|
-
executeBatch(query: string, rows:
|
|
21
|
-
executeBatchAsync(query: string, rows:
|
|
22
|
-
commit(callback?:
|
|
23
|
-
rollback(callback?:
|
|
24
|
-
commitRetaining(callback?:
|
|
25
|
-
rollbackRetaining(callback?:
|
|
26
|
-
queryAsync(query: string, params?:
|
|
27
|
-
executeAsync(query: string, params?:
|
|
28
|
-
sequentiallyAsync(query: string, params?: any, on?:
|
|
29
|
-
newStatementAsync(query: string): Promise<
|
|
34
|
+
executeBatch(query: string, rows: QueryParams[], callback?: BatchCb, options?: BatchOptions & QueryOptions): void;
|
|
35
|
+
executeBatchAsync(query: string, rows: QueryParams[], options?: BatchOptions & QueryOptions): Promise<BatchResult>;
|
|
36
|
+
commit(callback?: SimpleCallback): void;
|
|
37
|
+
rollback(callback?: SimpleCallback): void;
|
|
38
|
+
commitRetaining(callback?: SimpleCallback): void;
|
|
39
|
+
rollbackRetaining(callback?: SimpleCallback): void;
|
|
40
|
+
queryAsync(query: string, params?: QueryParams, options?: InternalQueryOptions): Promise<any[]>;
|
|
41
|
+
executeAsync(query: string, params?: QueryParams, options?: InternalQueryOptions): Promise<any[]>;
|
|
42
|
+
sequentiallyAsync(query: string, params?: any, on?: SequentialCallback, options?: InternalQueryOptions | boolean): Promise<void>;
|
|
43
|
+
newStatementAsync(query: string): Promise<Statement>;
|
|
30
44
|
commitAsync(): Promise<void>;
|
|
31
45
|
rollbackAsync(): Promise<void>;
|
|
32
46
|
commitRetainingAsync(): Promise<void>;
|
package/lib/wire/transaction.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const callback_1 = require("../callback");
|
|
6
|
+
const named_params_1 = require("../named-params");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
7
8
|
const const_1 = __importDefault(require("./const"));
|
|
9
|
+
const query_stream_1 = __importDefault(require("./query-stream"));
|
|
8
10
|
/***************************************
|
|
9
11
|
*
|
|
10
12
|
* Transaction
|
|
@@ -45,15 +47,40 @@ class Transaction {
|
|
|
45
47
|
this.connection = connection;
|
|
46
48
|
this.db = connection.db;
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
/** Per-call options.namedPlaceholders overrides the connection option. */
|
|
51
|
+
namedPlaceholdersEnabled(options) {
|
|
52
|
+
if (options && options.namedPlaceholders !== undefined)
|
|
53
|
+
return !!options.namedPlaceholders;
|
|
54
|
+
return !!(this.connection.options && this.connection.options.namedPlaceholders);
|
|
55
|
+
}
|
|
56
|
+
newStatement(query, callback, options) {
|
|
49
57
|
var cnx = this.connection;
|
|
50
58
|
var self = this;
|
|
51
|
-
|
|
59
|
+
// the public strict callback shape and the internal optional-args
|
|
60
|
+
// shape only differ in optionality; treat it as the internal one
|
|
61
|
+
var cb = callback;
|
|
62
|
+
// With namedPlaceholders on, prepare the positional rewrite and
|
|
63
|
+
// remember the name order on the statement so statement.execute can
|
|
64
|
+
// accept a values-by-name object. The rewritten SQL is the cache key.
|
|
65
|
+
var names = null;
|
|
66
|
+
if (this.namedPlaceholdersEnabled(options)) {
|
|
67
|
+
var parsed = (0, named_params_1.parseNamedPlaceholders)(query);
|
|
68
|
+
if (parsed.names) {
|
|
69
|
+
query = parsed.sql;
|
|
70
|
+
names = parsed.names;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var deliver = function (err, statement) {
|
|
74
|
+
if (statement)
|
|
75
|
+
statement.namedParams = names;
|
|
76
|
+
cb(err, statement);
|
|
77
|
+
};
|
|
78
|
+
var query_cache = cnx.takeCachedStatement(query);
|
|
52
79
|
if (query_cache) {
|
|
53
|
-
|
|
80
|
+
deliver(null, query_cache);
|
|
54
81
|
}
|
|
55
82
|
else {
|
|
56
|
-
cnx.prepare(self, query, false,
|
|
83
|
+
cnx.prepare(self, query, false, deliver);
|
|
57
84
|
}
|
|
58
85
|
}
|
|
59
86
|
execute(query, params, callback, options) {
|
|
@@ -72,11 +99,15 @@ class Transaction {
|
|
|
72
99
|
}
|
|
73
100
|
var self = this;
|
|
74
101
|
this.newStatement(query, function (err, statement) {
|
|
75
|
-
if (err) {
|
|
102
|
+
if (err || !statement) {
|
|
76
103
|
(0, callback_1.doError)(err, callback);
|
|
77
104
|
return;
|
|
78
105
|
}
|
|
79
106
|
function dropError(err) {
|
|
107
|
+
// do not put a statement that just failed back into the cache
|
|
108
|
+
// (statement is guaranteed by the guard above; hoisting keeps
|
|
109
|
+
// the narrowing from reaching this function declaration)
|
|
110
|
+
statement._failed = true;
|
|
80
111
|
statement.release();
|
|
81
112
|
(0, callback_1.doCallback)(err, callback);
|
|
82
113
|
}
|
|
@@ -124,7 +155,7 @@ class Transaction {
|
|
|
124
155
|
break;
|
|
125
156
|
}
|
|
126
157
|
}, options);
|
|
127
|
-
});
|
|
158
|
+
}, options);
|
|
128
159
|
}
|
|
129
160
|
sequentially(query, params, on, callback, options = {}) {
|
|
130
161
|
if (params instanceof Function) {
|
|
@@ -186,6 +217,15 @@ class Transaction {
|
|
|
186
217
|
self.execute(query, params, callback, options);
|
|
187
218
|
return self;
|
|
188
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Run `query` inside this transaction and return an object-mode
|
|
222
|
+
* Readable emitting one row per chunk, with real backpressure (see
|
|
223
|
+
* Database.queryStream). The transaction is NOT committed when the
|
|
224
|
+
* stream ends — commit or roll back yourself.
|
|
225
|
+
*/
|
|
226
|
+
queryStream(query, params, options) {
|
|
227
|
+
return (0, query_stream_1.default)(this, query, params, options);
|
|
228
|
+
}
|
|
189
229
|
query(query, params, callback, options = {}) {
|
|
190
230
|
if (params instanceof Function) {
|
|
191
231
|
callback = params;
|
|
@@ -212,16 +252,18 @@ class Transaction {
|
|
|
212
252
|
executeBatch(query, rows, callback, options) {
|
|
213
253
|
var self = this;
|
|
214
254
|
this.newStatement(query, function (err, statement) {
|
|
215
|
-
if (err) {
|
|
255
|
+
if (err || !statement) {
|
|
216
256
|
(0, callback_1.doError)(err, callback);
|
|
217
257
|
return;
|
|
218
258
|
}
|
|
219
259
|
statement.executeBatch(self, rows, function (err, result) {
|
|
260
|
+
if (err)
|
|
261
|
+
statement._failed = true;
|
|
220
262
|
statement.release();
|
|
221
263
|
if (callback)
|
|
222
264
|
callback(err, result);
|
|
223
265
|
}, options);
|
|
224
|
-
});
|
|
266
|
+
}, options);
|
|
225
267
|
}
|
|
226
268
|
executeBatchAsync(query, rows, options) {
|
|
227
269
|
var self = this;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/***************************************
|
|
2
|
+
*
|
|
3
|
+
* Internal wire-protocol types (type-only module)
|
|
4
|
+
*
|
|
5
|
+
* Shared vocabulary for the wire core (connection/statement/transaction/
|
|
6
|
+
* database). Nothing here exists at runtime.
|
|
7
|
+
*
|
|
8
|
+
***************************************/
|
|
9
|
+
import type { Callback, FbStatusItem } from '../callback';
|
|
10
|
+
import type Statement from './statement';
|
|
11
|
+
import type { BatchResult, Options, QueryOptions, Statement as PublicStatement } from '../types';
|
|
12
|
+
/**
|
|
13
|
+
* One entry of the connection's response queue (`connection._queue`).
|
|
14
|
+
* The function itself is the user/driver callback; the extra properties
|
|
15
|
+
* steer decodeResponse:
|
|
16
|
+
*
|
|
17
|
+
* - `response` — pre-allocated object the op_response decode fills in
|
|
18
|
+
* (a Statement, Transaction, or plain response object).
|
|
19
|
+
* - `statement` — statement whose `output` describes the rows of an
|
|
20
|
+
* op_fetch_response / op_sql_response.
|
|
21
|
+
* - `lazy_count`— number of chained lazy op_responses this entry consumes
|
|
22
|
+
* (ptype_lazy_send batches e.g. allocate+prepare).
|
|
23
|
+
*
|
|
24
|
+
* Deferred ops (op_free_statement, op_close_blob, ...) push `undefined`
|
|
25
|
+
* placeholders so every server response still pairs with one entry.
|
|
26
|
+
*/
|
|
27
|
+
export interface QueueCallback {
|
|
28
|
+
(err?: any, obj?: any): void;
|
|
29
|
+
response?: any;
|
|
30
|
+
statement?: Statement;
|
|
31
|
+
lazy_count?: number;
|
|
32
|
+
}
|
|
33
|
+
/** A queue entry: a callback, or a placeholder for a deferred op. */
|
|
34
|
+
export type QueueEntry = QueueCallback | undefined;
|
|
35
|
+
/** XDR quad — 64-bit value as two 32-bit halves (blob ids, object ids). */
|
|
36
|
+
export interface Quad {
|
|
37
|
+
high: number;
|
|
38
|
+
low: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decoded op_response packet (see parseOpResponse): object handle, object
|
|
42
|
+
* id, optional info buffer and, on failure, the status vector. Statement /
|
|
43
|
+
* Transaction responses are these fields merged onto the pre-allocated
|
|
44
|
+
* object from QueueCallback.response.
|
|
45
|
+
*/
|
|
46
|
+
export interface WireResponse {
|
|
47
|
+
handle?: number;
|
|
48
|
+
oid?: Quad;
|
|
49
|
+
buffer?: Buffer;
|
|
50
|
+
status?: FbStatusItem[];
|
|
51
|
+
/** isc_arg_warning entries — attached to a SUCCESSFUL response */
|
|
52
|
+
warnings?: FbStatusItem[];
|
|
53
|
+
sqlcode?: number;
|
|
54
|
+
message?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Result of decoding op_fetch_response / op_sql_response row data. */
|
|
57
|
+
export interface FetchResult {
|
|
58
|
+
data: any[];
|
|
59
|
+
/** true when the cursor is exhausted (fetch status 100 / singleton). */
|
|
60
|
+
fetched: boolean;
|
|
61
|
+
/** pending blobAsText fetches to resolve before delivering rows. */
|
|
62
|
+
arrBlob?: any[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Protocol negotiation result decoded from op_accept / op_cond_accept /
|
|
66
|
+
* op_accept_data, plus the auth/crypt state accumulated during the
|
|
67
|
+
* handshake (op_cont_auth rounds, wire-crypt keys).
|
|
68
|
+
*/
|
|
69
|
+
export interface AcceptPacket {
|
|
70
|
+
protocolVersion: number;
|
|
71
|
+
protocolArchitecture: number;
|
|
72
|
+
protocolMinimumType: number;
|
|
73
|
+
compress: boolean;
|
|
74
|
+
pluginName: string;
|
|
75
|
+
authData: any;
|
|
76
|
+
sessionKey?: any;
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Query options as the wire core sees them: the public QueryOptions plus
|
|
81
|
+
* the internal row-delivery flags set by the Database/Transaction helpers
|
|
82
|
+
* (query / sequentially / queryStream).
|
|
83
|
+
*/
|
|
84
|
+
export type InternalQueryOptions = QueryOptions & {
|
|
85
|
+
/** deliver rows as objects keyed by column alias */
|
|
86
|
+
asObject?: boolean;
|
|
87
|
+
/** deliver rows one by one (row events / `on` delegate) instead of accumulating */
|
|
88
|
+
asStream?: boolean;
|
|
89
|
+
/** per-row delegate installed by sequentially() */
|
|
90
|
+
on?: (row: any, index: number, meta: any[], next: (err?: any) => void) => void;
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* newStatement callback: the internal optional-args shape, or the public
|
|
95
|
+
* strict shape (non-optional statement) declared in types.ts.
|
|
96
|
+
*/
|
|
97
|
+
export type StatementCb = Callback<Statement> | ((err: Error | null, statement: PublicStatement) => void);
|
|
98
|
+
/**
|
|
99
|
+
* executeBatch callback: the internal optional-args shape, or the public
|
|
100
|
+
* strict shape (non-optional result) declared in types.ts.
|
|
101
|
+
*/
|
|
102
|
+
export type BatchCb = Callback<BatchResult> | ((err: any, result: BatchResult) => void);
|
|
103
|
+
/**
|
|
104
|
+
* Connection options as the wire core sees them: the public Options plus
|
|
105
|
+
* internal flags set by the driver itself.
|
|
106
|
+
*/
|
|
107
|
+
export type InternalOptions = Options & {
|
|
108
|
+
/** set by the pool so detach() returns the connection instead */
|
|
109
|
+
isPool?: boolean;
|
|
110
|
+
/** override path of the firebird.msg error-message file */
|
|
111
|
+
messageFile?: string;
|
|
112
|
+
/** legacy statement-cache flags (mapped onto statementCacheSize) */
|
|
113
|
+
cacheQuery?: boolean;
|
|
114
|
+
maxCachedQuery?: number;
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/***************************************
|
|
3
|
+
*
|
|
4
|
+
* Internal wire-protocol types (type-only module)
|
|
5
|
+
*
|
|
6
|
+
* Shared vocabulary for the wire core (connection/statement/transaction/
|
|
7
|
+
* database). Nothing here exists at runtime.
|
|
8
|
+
*
|
|
9
|
+
***************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/wire/xsqlvar.d.ts
CHANGED
|
@@ -22,20 +22,20 @@ export declare abstract class SQLVarBase {
|
|
|
22
22
|
abstract calcBlr(blr: BlrWriter): void;
|
|
23
23
|
}
|
|
24
24
|
export declare class SQLVarText extends SQLVarBase {
|
|
25
|
-
decode(data: XdrReader, lowerV13: boolean, options?: any):
|
|
25
|
+
decode(data: XdrReader, lowerV13: boolean, options?: any): string | Buffer<ArrayBufferLike> | null | undefined;
|
|
26
26
|
calcBlr(blr: BlrWriter): void;
|
|
27
27
|
}
|
|
28
28
|
export declare class SQLVarNull extends SQLVarText {
|
|
29
29
|
}
|
|
30
30
|
export declare class SQLVarString extends SQLVarBase {
|
|
31
|
-
decode(data: XdrReader, lowerV13: boolean, options?: any):
|
|
31
|
+
decode(data: XdrReader, lowerV13: boolean, options?: any): string | Buffer<ArrayBufferLike> | null | undefined;
|
|
32
32
|
calcBlr(blr: BlrWriter): void;
|
|
33
33
|
}
|
|
34
34
|
export declare class SQLVarQuad extends SQLVarBase {
|
|
35
35
|
decode(data: XdrReader, lowerV13: boolean): {
|
|
36
36
|
low: number;
|
|
37
37
|
high: number;
|
|
38
|
-
};
|
|
38
|
+
} | null;
|
|
39
39
|
calcBlr(blr: BlrWriter): void;
|
|
40
40
|
}
|
|
41
41
|
export declare class SQLVarBlob extends SQLVarQuad {
|
|
@@ -45,66 +45,66 @@ export declare class SQLVarArray extends SQLVarQuad {
|
|
|
45
45
|
calcBlr(blr: BlrWriter): void;
|
|
46
46
|
}
|
|
47
47
|
export declare class SQLVarInt extends SQLVarBase {
|
|
48
|
-
decode(data: XdrReader, lowerV13: boolean): number;
|
|
48
|
+
decode(data: XdrReader, lowerV13: boolean): number | null;
|
|
49
49
|
calcBlr(blr: BlrWriter): void;
|
|
50
50
|
}
|
|
51
51
|
export declare class SQLVarShort extends SQLVarInt {
|
|
52
52
|
calcBlr(blr: BlrWriter): void;
|
|
53
53
|
}
|
|
54
54
|
export declare class SQLVarInt64 extends SQLVarBase {
|
|
55
|
-
decode(data: XdrReader, lowerV13: boolean): number;
|
|
55
|
+
decode(data: XdrReader, lowerV13: boolean): number | null;
|
|
56
56
|
calcBlr(blr: BlrWriter): void;
|
|
57
57
|
}
|
|
58
58
|
export declare class SQLVarInt128 extends SQLVarBase {
|
|
59
|
-
decode(data: XdrReader, lowerV13: boolean): string | number;
|
|
59
|
+
decode(data: XdrReader, lowerV13: boolean): string | number | null;
|
|
60
60
|
calcBlr(blr: BlrWriter): void;
|
|
61
61
|
}
|
|
62
62
|
export declare class SQLVarDecFloat16 extends SQLVarBase {
|
|
63
|
-
decode(data: XdrReader, lowerV13: boolean): string | number;
|
|
63
|
+
decode(data: XdrReader, lowerV13: boolean): string | number | null;
|
|
64
64
|
calcBlr(blr: BlrWriter): void;
|
|
65
65
|
}
|
|
66
66
|
export declare class SQLVarDecFloat34 extends SQLVarBase {
|
|
67
|
-
decode(data: XdrReader, lowerV13: boolean): string | number;
|
|
67
|
+
decode(data: XdrReader, lowerV13: boolean): string | number | null;
|
|
68
68
|
calcBlr(blr: BlrWriter): void;
|
|
69
69
|
}
|
|
70
70
|
export declare class SQLVarFloat extends SQLVarBase {
|
|
71
|
-
decode(data: XdrReader, lowerV13: boolean): number;
|
|
71
|
+
decode(data: XdrReader, lowerV13: boolean): number | null;
|
|
72
72
|
calcBlr(blr: BlrWriter): void;
|
|
73
73
|
}
|
|
74
74
|
export declare class SQLVarDouble extends SQLVarBase {
|
|
75
|
-
decode(data: XdrReader, lowerV13: boolean): number;
|
|
75
|
+
decode(data: XdrReader, lowerV13: boolean): number | null;
|
|
76
76
|
calcBlr(blr: BlrWriter): void;
|
|
77
77
|
}
|
|
78
78
|
export declare class SQLVarDate extends SQLVarBase {
|
|
79
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
79
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
80
80
|
calcBlr(blr: BlrWriter): void;
|
|
81
81
|
}
|
|
82
82
|
export declare class SQLVarTime extends SQLVarBase {
|
|
83
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
83
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
84
84
|
calcBlr(blr: BlrWriter): void;
|
|
85
85
|
}
|
|
86
86
|
export declare class SQLVarTimeStamp extends SQLVarBase {
|
|
87
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
87
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
88
88
|
calcBlr(blr: BlrWriter): void;
|
|
89
89
|
}
|
|
90
90
|
export declare class SQLVarTimeTz extends SQLVarBase {
|
|
91
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
91
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
92
92
|
calcBlr(blr: BlrWriter): void;
|
|
93
93
|
}
|
|
94
94
|
export declare class SQLVarTimeTzEx extends SQLVarTimeTz {
|
|
95
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
95
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
96
96
|
calcBlr(blr: BlrWriter): void;
|
|
97
97
|
}
|
|
98
98
|
export declare class SQLVarTimeStampTz extends SQLVarBase {
|
|
99
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
99
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
100
100
|
calcBlr(blr: BlrWriter): void;
|
|
101
101
|
}
|
|
102
102
|
export declare class SQLVarTimeStampTzEx extends SQLVarTimeStampTz {
|
|
103
|
-
decode(data: XdrReader, lowerV13: boolean): Date;
|
|
103
|
+
decode(data: XdrReader, lowerV13: boolean): Date | null;
|
|
104
104
|
calcBlr(blr: BlrWriter): void;
|
|
105
105
|
}
|
|
106
106
|
export declare class SQLVarBoolean extends SQLVarBase {
|
|
107
|
-
decode(data: XdrReader, lowerV13: boolean): boolean;
|
|
107
|
+
decode(data: XdrReader, lowerV13: boolean): boolean | null;
|
|
108
108
|
calcBlr(blr: BlrWriter): void;
|
|
109
109
|
}
|
|
110
110
|
export declare class SQLParamInt {
|