node-firebird 2.9.0 → 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 +166 -6
- package/lib/index.d.ts +5 -0
- package/lib/index.js +32 -1
- package/lib/pool.js +1 -1
- package/lib/srp.d.ts +3 -3
- package/lib/types.d.ts +143 -5
- package/lib/uri.js +2 -2
- package/lib/wire/connection.d.ts +92 -59
- package/lib/wire/connection.js +267 -53
- 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 +31 -19
- package/lib/wire/statement.js +1 -5
- package/lib/wire/transaction.d.ts +30 -18
- package/lib/wire/transaction.js +23 -4
- 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 +36 -4
- package/src/messages.ts +1 -1
- package/src/pool.ts +1 -1
- package/src/srp.ts +6 -6
- package/src/types.ts +140 -5
- package/src/unix-crypt.ts +9 -9
- package/src/uri.ts +2 -2
- package/src/wire/connection.ts +464 -232
- 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 +37 -29
- package/src/wire/transaction.ts +57 -32
- package/src/wire/wire-types.ts +127 -0
- package/src/wire/xsqlvar.ts +9 -7
|
@@ -0,0 +1,127 @@
|
|
|
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
|
+
|
|
10
|
+
import type { Callback, FbStatusItem } from '../callback';
|
|
11
|
+
import type Statement from './statement';
|
|
12
|
+
import type { BatchResult, Options, QueryOptions, Statement as PublicStatement } from '../types';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* One entry of the connection's response queue (`connection._queue`).
|
|
16
|
+
* The function itself is the user/driver callback; the extra properties
|
|
17
|
+
* steer decodeResponse:
|
|
18
|
+
*
|
|
19
|
+
* - `response` — pre-allocated object the op_response decode fills in
|
|
20
|
+
* (a Statement, Transaction, or plain response object).
|
|
21
|
+
* - `statement` — statement whose `output` describes the rows of an
|
|
22
|
+
* op_fetch_response / op_sql_response.
|
|
23
|
+
* - `lazy_count`— number of chained lazy op_responses this entry consumes
|
|
24
|
+
* (ptype_lazy_send batches e.g. allocate+prepare).
|
|
25
|
+
*
|
|
26
|
+
* Deferred ops (op_free_statement, op_close_blob, ...) push `undefined`
|
|
27
|
+
* placeholders so every server response still pairs with one entry.
|
|
28
|
+
*/
|
|
29
|
+
export interface QueueCallback {
|
|
30
|
+
(err?: any, obj?: any): void;
|
|
31
|
+
response?: any;
|
|
32
|
+
statement?: Statement;
|
|
33
|
+
lazy_count?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A queue entry: a callback, or a placeholder for a deferred op. */
|
|
37
|
+
export type QueueEntry = QueueCallback | undefined;
|
|
38
|
+
|
|
39
|
+
/** XDR quad — 64-bit value as two 32-bit halves (blob ids, object ids). */
|
|
40
|
+
export interface Quad {
|
|
41
|
+
high: number;
|
|
42
|
+
low: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Decoded op_response packet (see parseOpResponse): object handle, object
|
|
47
|
+
* id, optional info buffer and, on failure, the status vector. Statement /
|
|
48
|
+
* Transaction responses are these fields merged onto the pre-allocated
|
|
49
|
+
* object from QueueCallback.response.
|
|
50
|
+
*/
|
|
51
|
+
export interface WireResponse {
|
|
52
|
+
handle?: number;
|
|
53
|
+
oid?: Quad;
|
|
54
|
+
buffer?: Buffer;
|
|
55
|
+
status?: FbStatusItem[];
|
|
56
|
+
/** isc_arg_warning entries — attached to a SUCCESSFUL response */
|
|
57
|
+
warnings?: FbStatusItem[];
|
|
58
|
+
sqlcode?: number;
|
|
59
|
+
message?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Result of decoding op_fetch_response / op_sql_response row data. */
|
|
63
|
+
export interface FetchResult {
|
|
64
|
+
data: any[];
|
|
65
|
+
/** true when the cursor is exhausted (fetch status 100 / singleton). */
|
|
66
|
+
fetched: boolean;
|
|
67
|
+
/** pending blobAsText fetches to resolve before delivering rows. */
|
|
68
|
+
arrBlob?: any[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Protocol negotiation result decoded from op_accept / op_cond_accept /
|
|
73
|
+
* op_accept_data, plus the auth/crypt state accumulated during the
|
|
74
|
+
* handshake (op_cont_auth rounds, wire-crypt keys).
|
|
75
|
+
*/
|
|
76
|
+
export interface AcceptPacket {
|
|
77
|
+
protocolVersion: number;
|
|
78
|
+
protocolArchitecture: number;
|
|
79
|
+
protocolMinimumType: number;
|
|
80
|
+
compress: boolean;
|
|
81
|
+
pluginName: string;
|
|
82
|
+
authData: any;
|
|
83
|
+
sessionKey?: any;
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Query options as the wire core sees them: the public QueryOptions plus
|
|
89
|
+
* the internal row-delivery flags set by the Database/Transaction helpers
|
|
90
|
+
* (query / sequentially / queryStream).
|
|
91
|
+
*/
|
|
92
|
+
export type InternalQueryOptions = QueryOptions & {
|
|
93
|
+
/** deliver rows as objects keyed by column alias */
|
|
94
|
+
asObject?: boolean;
|
|
95
|
+
/** deliver rows one by one (row events / `on` delegate) instead of accumulating */
|
|
96
|
+
asStream?: boolean;
|
|
97
|
+
/** per-row delegate installed by sequentially() */
|
|
98
|
+
on?: (row: any, index: number, meta: any[], next: (err?: any) => void) => void;
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* newStatement callback: the internal optional-args shape, or the public
|
|
104
|
+
* strict shape (non-optional statement) declared in types.ts.
|
|
105
|
+
*/
|
|
106
|
+
export type StatementCb = Callback<Statement> | ((err: Error | null, statement: PublicStatement) => void);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* executeBatch callback: the internal optional-args shape, or the public
|
|
110
|
+
* strict shape (non-optional result) declared in types.ts.
|
|
111
|
+
*/
|
|
112
|
+
export type BatchCb = Callback<BatchResult> | ((err: any, result: BatchResult) => void);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Connection options as the wire core sees them: the public Options plus
|
|
116
|
+
* internal flags set by the driver itself.
|
|
117
|
+
*/
|
|
118
|
+
export type InternalOptions = Options & {
|
|
119
|
+
/** set by the pool so detach() returns the connection instead */
|
|
120
|
+
isPool?: boolean;
|
|
121
|
+
/** override path of the firebird.msg error-message file */
|
|
122
|
+
messageFile?: string;
|
|
123
|
+
/** legacy statement-cache flags (mapped onto statementCacheSize) */
|
|
124
|
+
cacheQuery?: boolean;
|
|
125
|
+
maxCachedQuery?: number;
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
};
|
package/src/wire/xsqlvar.ts
CHANGED
|
@@ -26,7 +26,7 @@ const
|
|
|
26
26
|
* Commonly used Firebird charsets not listed here fall back to the
|
|
27
27
|
* connection-level DEFAULT_ENCODING (typically 'utf8').
|
|
28
28
|
*/
|
|
29
|
-
const FirebirdToNodeEncoding = Object.freeze({
|
|
29
|
+
const FirebirdToNodeEncoding: Readonly<Record<string, string>> = Object.freeze({
|
|
30
30
|
UTF8: 'utf8',
|
|
31
31
|
UNICODE_FSS: 'utf8',
|
|
32
32
|
WIN1252: 'latin1',
|
|
@@ -36,7 +36,7 @@ const FirebirdToNodeEncoding = Object.freeze({
|
|
|
36
36
|
NONE: 'latin1', // unspecified charset – treat as binary-safe latin1
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
const FirebirdCharsetWidths = {
|
|
39
|
+
const FirebirdCharsetWidths: Record<string, number> = {
|
|
40
40
|
'UTF8': 4,
|
|
41
41
|
'UNICODE_FSS': 3,
|
|
42
42
|
'SJIS': 2,
|
|
@@ -71,11 +71,13 @@ function resolveTextEncoding(options?: any): BufferEncoding {
|
|
|
71
71
|
* describe response before decode()/calcBlr() are called.
|
|
72
72
|
*/
|
|
73
73
|
export abstract class SQLVarBase {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
// populated externally (see the doc comment above), hence the definite
|
|
75
|
+
// assignment assertions
|
|
76
|
+
type!: number;
|
|
77
|
+
subType!: number;
|
|
78
|
+
scale!: number;
|
|
79
|
+
length!: number;
|
|
80
|
+
nullable!: boolean;
|
|
79
81
|
field?: string;
|
|
80
82
|
relation?: string;
|
|
81
83
|
relationSchema?: string;
|