postgrejs 2.22.9 → 2.23.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/CHANGELOG.md +18 -1
- package/{esm/connection → connection}/bind-param.js +2 -0
- package/{esm/connection → connection}/connection.js +4 -2
- package/{esm/connection → connection}/cursor.js +8 -3
- package/{esm/connection → connection}/intl-connection.js +6 -3
- package/{esm/connection → connection}/pool.js +4 -1
- package/{esm/connection → connection}/portal.js +3 -1
- package/{esm/connection → connection}/prepared-statement.js +6 -3
- package/{esm/constants.js → constants.js} +1 -1
- package/{types/data-type-map.d.ts → data-type-map.d.ts} +2 -2
- package/{esm/data-type-map.js → data-type-map.js} +2 -2
- package/{esm/data-types → data-types}/int2-vector-type.js +1 -0
- package/{types/data-types → data-types}/timestamptz-type.d.ts +1 -1
- package/{esm/data-types → data-types}/timestamptz-type.js +1 -0
- package/package.json +12 -31
- package/{esm/protocol → protocol}/backend.js +1 -0
- package/{esm/protocol → protocol}/buffer-reader.js +2 -1
- package/{esm/protocol → protocol}/database-error.js +17 -0
- package/{esm/protocol → protocol}/frontend.js +2 -0
- package/{types/protocol → protocol}/pg-socket.d.ts +1 -1
- package/{esm/protocol → protocol}/pg-socket.js +9 -3
- package/{esm/protocol → protocol}/smart-buffer.js +9 -5
- package/{esm/util → util}/bigint-methods.js +1 -0
- package/cjs/connection/bind-param.js +0 -10
- package/cjs/connection/connection.js +0 -295
- package/cjs/connection/cursor.js +0 -91
- package/cjs/connection/intl-connection.js +0 -258
- package/cjs/connection/pool.js +0 -236
- package/cjs/connection/portal.js +0 -157
- package/cjs/connection/prepared-statement.js +0 -226
- package/cjs/constants.js +0 -249
- package/cjs/data-type-map.js +0 -131
- package/cjs/data-types/bool-type.js +0 -33
- package/cjs/data-types/box-type.js +0 -52
- package/cjs/data-types/bytea-type.js +0 -28
- package/cjs/data-types/char-type.js +0 -27
- package/cjs/data-types/circle-type.js +0 -51
- package/cjs/data-types/date-type.js +0 -75
- package/cjs/data-types/float4-type.js +0 -25
- package/cjs/data-types/float8-type.js +0 -25
- package/cjs/data-types/int2-type.js +0 -26
- package/cjs/data-types/int2-vector-type.js +0 -42
- package/cjs/data-types/int4-type.js +0 -28
- package/cjs/data-types/int8-type.js +0 -36
- package/cjs/data-types/json-type.js +0 -40
- package/cjs/data-types/jsonb-type.js +0 -44
- package/cjs/data-types/lseg-type.js +0 -55
- package/cjs/data-types/numeric-type.js +0 -125
- package/cjs/data-types/oid-type.js +0 -32
- package/cjs/data-types/point-type.js +0 -42
- package/cjs/data-types/time-type.js +0 -66
- package/cjs/data-types/timestamp-type.js +0 -89
- package/cjs/data-types/timestamptz-type.js +0 -76
- package/cjs/data-types/uuid-type.js +0 -39
- package/cjs/data-types/varchar-type.js +0 -27
- package/cjs/index.js +0 -28
- package/cjs/interfaces/command-result.js +0 -2
- package/cjs/interfaces/data-mapping-options.js +0 -2
- package/cjs/interfaces/data-type.js +0 -2
- package/cjs/interfaces/database-connection-params.js +0 -2
- package/cjs/interfaces/field-info.js +0 -2
- package/cjs/interfaces/query-options.js +0 -2
- package/cjs/interfaces/query-result.js +0 -2
- package/cjs/interfaces/script-execute-options.js +0 -2
- package/cjs/interfaces/script-result.js +0 -2
- package/cjs/interfaces/statement-prepare-options.js +0 -2
- package/cjs/package.json +0 -3
- package/cjs/protocol/backend.js +0 -262
- package/cjs/protocol/buffer-reader.js +0 -78
- package/cjs/protocol/database-error.js +0 -17
- package/cjs/protocol/frontend.js +0 -255
- package/cjs/protocol/pg-socket.js +0 -367
- package/cjs/protocol/protocol.js +0 -71
- package/cjs/protocol/sasl.js +0 -108
- package/cjs/protocol/smart-buffer.js +0 -178
- package/cjs/safe-event-emitter.js +0 -17
- package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
- package/cjs/types.js +0 -2
- package/cjs/util/array-calculatedim.js +0 -18
- package/cjs/util/bigint-methods.js +0 -44
- package/cjs/util/config-from-env.js +0 -29
- package/cjs/util/connection-config.js +0 -61
- package/cjs/util/convert-row-to-object.js +0 -12
- package/cjs/util/decode-binaryarray.js +0 -38
- package/cjs/util/encode-binaryarray.js +0 -44
- package/cjs/util/escape-literal.js +0 -26
- package/cjs/util/fast-parseint.js +0 -31
- package/cjs/util/get-parsers.js +0 -41
- package/cjs/util/parse-array.js +0 -60
- package/cjs/util/parse-datetime.js +0 -37
- package/cjs/util/parse-row.js +0 -11
- package/cjs/util/parse-time.js +0 -30
- package/cjs/util/stringify-arrayliteral.js +0 -37
- package/cjs/util/stringify-for-sql.js +0 -29
- package/cjs/util/wrap-row-description.js +0 -34
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -25
- /package/{types/connection → connection}/bind-param.d.ts +0 -0
- /package/{types/connection → connection}/connection.d.ts +0 -0
- /package/{types/connection → connection}/cursor.d.ts +0 -0
- /package/{types/connection → connection}/intl-connection.d.ts +0 -0
- /package/{types/connection → connection}/pool.d.ts +0 -0
- /package/{types/connection → connection}/portal.d.ts +0 -0
- /package/{types/connection → connection}/prepared-statement.d.ts +0 -0
- /package/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/{types/data-types → data-types}/bool-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bool-type.js +0 -0
- /package/{types/data-types → data-types}/box-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/box-type.js +0 -0
- /package/{types/data-types → data-types}/bytea-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bytea-type.js +0 -0
- /package/{types/data-types → data-types}/char-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/char-type.js +0 -0
- /package/{types/data-types → data-types}/circle-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/circle-type.js +0 -0
- /package/{types/data-types → data-types}/date-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/date-type.js +0 -0
- /package/{types/data-types → data-types}/float4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float4-type.js +0 -0
- /package/{types/data-types → data-types}/float8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float8-type.js +0 -0
- /package/{types/data-types → data-types}/int2-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int2-type.js +0 -0
- /package/{types/data-types → data-types}/int2-vector-type.d.ts +0 -0
- /package/{types/data-types → data-types}/int4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int4-type.js +0 -0
- /package/{types/data-types → data-types}/int8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int8-type.js +0 -0
- /package/{types/data-types → data-types}/json-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/json-type.js +0 -0
- /package/{types/data-types → data-types}/jsonb-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/jsonb-type.js +0 -0
- /package/{types/data-types → data-types}/lseg-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/lseg-type.js +0 -0
- /package/{types/data-types → data-types}/numeric-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/numeric-type.js +0 -0
- /package/{types/data-types → data-types}/oid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/oid-type.js +0 -0
- /package/{types/data-types → data-types}/point-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/point-type.js +0 -0
- /package/{types/data-types → data-types}/time-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/time-type.js +0 -0
- /package/{types/data-types → data-types}/timestamp-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/timestamp-type.js +0 -0
- /package/{types/data-types → data-types}/uuid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/uuid-type.js +0 -0
- /package/{types/data-types → data-types}/varchar-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/varchar-type.js +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/interfaces → interfaces}/command-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/command-result.js +0 -0
- /package/{types/interfaces → interfaces}/data-mapping-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-mapping-options.js +0 -0
- /package/{types/interfaces → interfaces}/data-type.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-type.js +0 -0
- /package/{types/interfaces → interfaces}/database-connection-params.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/database-connection-params.js +0 -0
- /package/{types/interfaces → interfaces}/field-info.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/field-info.js +0 -0
- /package/{types/interfaces → interfaces}/query-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-options.js +0 -0
- /package/{types/interfaces → interfaces}/query-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-result.js +0 -0
- /package/{types/interfaces → interfaces}/script-execute-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-execute-options.js +0 -0
- /package/{types/interfaces → interfaces}/script-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-result.js +0 -0
- /package/{types/interfaces → interfaces}/statement-prepare-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/statement-prepare-options.js +0 -0
- /package/{types/protocol → protocol}/backend.d.ts +0 -0
- /package/{types/protocol → protocol}/buffer-reader.d.ts +0 -0
- /package/{types/protocol → protocol}/database-error.d.ts +0 -0
- /package/{types/protocol → protocol}/frontend.d.ts +0 -0
- /package/{types/protocol → protocol}/protocol.d.ts +0 -0
- /package/{esm/protocol → protocol}/protocol.js +0 -0
- /package/{types/protocol → protocol}/sasl.d.ts +0 -0
- /package/{esm/protocol → protocol}/sasl.js +0 -0
- /package/{types/protocol → protocol}/smart-buffer.d.ts +0 -0
- /package/{types/safe-event-emitter.d.ts → safe-event-emitter.d.ts} +0 -0
- /package/{esm/safe-event-emitter.js → safe-event-emitter.js} +0 -0
- /package/{types/types.d.ts → types.d.ts} +0 -0
- /package/{esm/types.js → types.js} +0 -0
- /package/{types/util → util}/array-calculatedim.d.ts +0 -0
- /package/{esm/util → util}/array-calculatedim.js +0 -0
- /package/{types/util → util}/bigint-methods.d.ts +0 -0
- /package/{types/util → util}/config-from-env.d.ts +0 -0
- /package/{esm/util → util}/config-from-env.js +0 -0
- /package/{types/util → util}/connection-config.d.ts +0 -0
- /package/{esm/util → util}/connection-config.js +0 -0
- /package/{types/util → util}/convert-row-to-object.d.ts +0 -0
- /package/{esm/util → util}/convert-row-to-object.js +0 -0
- /package/{types/util → util}/decode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/decode-binaryarray.js +0 -0
- /package/{types/util → util}/encode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/encode-binaryarray.js +0 -0
- /package/{types/util → util}/escape-literal.d.ts +0 -0
- /package/{esm/util → util}/escape-literal.js +0 -0
- /package/{types/util → util}/fast-parseint.d.ts +0 -0
- /package/{esm/util → util}/fast-parseint.js +0 -0
- /package/{types/util → util}/get-parsers.d.ts +0 -0
- /package/{esm/util → util}/get-parsers.js +0 -0
- /package/{types/util → util}/parse-array.d.ts +0 -0
- /package/{esm/util → util}/parse-array.js +0 -0
- /package/{types/util → util}/parse-datetime.d.ts +0 -0
- /package/{esm/util → util}/parse-datetime.js +0 -0
- /package/{types/util → util}/parse-row.d.ts +0 -0
- /package/{esm/util → util}/parse-row.js +0 -0
- /package/{types/util → util}/parse-time.d.ts +0 -0
- /package/{esm/util → util}/parse-time.js +0 -0
- /package/{types/util → util}/stringify-arrayliteral.d.ts +0 -0
- /package/{esm/util → util}/stringify-arrayliteral.js +0 -0
- /package/{types/util → util}/stringify-for-sql.d.ts +0 -0
- /package/{esm/util → util}/stringify-for-sql.js +0 -0
- /package/{types/util → util}/wrap-row-description.d.ts +0 -0
- /package/{esm/util → util}/wrap-row-description.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v2.
|
|
3
|
+
### [v2.23.1](https://github.com/panates/postgrejs/compare/v2.23.0...v2.23.1) -
|
|
4
|
+
|
|
5
|
+
#### 💬 General Changes
|
|
6
|
+
|
|
7
|
+
- dev: Updated dependencies and switched to `import type` for cleaner type imports @Eray Hanoğlu
|
|
8
|
+
- dev: Minor lint issue @Eray Hanoğlu
|
|
9
|
+
- dev: Updated action/chechout version @Eray Hanoğlu
|
|
10
|
+
- dev: Minor lint issue @Eray Hanoğlu
|
|
11
|
+
- dev: Set min node test version to 20 @Eray Hanoğlu
|
|
12
|
+
|
|
13
|
+
### [v2.23.0](https://github.com/panates/postgrejs/compare/v2.22.9...v2.23.0) - 3 April 2026
|
|
14
|
+
|
|
15
|
+
#### 🛠 Refactoring and Updates
|
|
16
|
+
|
|
17
|
+
- dev: Updated deps to support latest TypeScript and NodeJS. @Eray Hanoğlu
|
|
18
|
+
- dev: Updated deps to support latest TypeScript and NodeJS. @Eray Hanoğlu
|
|
19
|
+
|
|
20
|
+
### [v2.22.9](https://github.com/panates/postgrejs/compare/v2.22.8...v2.22.9) - 4 December 2025
|
|
4
21
|
|
|
5
22
|
### [v2.22.8](https://github.com/panates/postgrejs/compare/v2.22.7...v2.22.8) - 27 October 2025
|
|
6
23
|
|
|
@@ -5,10 +5,12 @@ import { BindParam } from './bind-param.js';
|
|
|
5
5
|
import { IntlConnection } from './intl-connection.js';
|
|
6
6
|
import { PreparedStatement } from './prepared-statement.js';
|
|
7
7
|
export class Connection extends SafeEventEmitter {
|
|
8
|
+
_pool;
|
|
9
|
+
_intlCon;
|
|
10
|
+
_notificationListeners = new SafeEventEmitter();
|
|
11
|
+
_closing = false;
|
|
8
12
|
constructor(arg0, arg1) {
|
|
9
13
|
super();
|
|
10
|
-
this._notificationListeners = new SafeEventEmitter();
|
|
11
|
-
this._closing = false;
|
|
12
14
|
if (arg0 &&
|
|
13
15
|
typeof arg0 === 'object' &&
|
|
14
16
|
typeof arg0.acquire === 'function') {
|
|
@@ -4,11 +4,16 @@ import { SafeEventEmitter } from '../safe-event-emitter.js';
|
|
|
4
4
|
import { convertRowToObject } from '../util/convert-row-to-object.js';
|
|
5
5
|
import { parseRow } from '../util/parse-row.js';
|
|
6
6
|
export class Cursor extends SafeEventEmitter {
|
|
7
|
+
_statement;
|
|
8
|
+
_portal;
|
|
9
|
+
_parsers;
|
|
10
|
+
_queryOptions;
|
|
11
|
+
_taskQueue = new TaskQueue({ concurrency: 1 });
|
|
12
|
+
_rows = new DoublyLinked();
|
|
13
|
+
_closed = false;
|
|
14
|
+
fields;
|
|
7
15
|
constructor(statement, portal, fields, parsers, queryOptions) {
|
|
8
16
|
super();
|
|
9
|
-
this._taskQueue = new TaskQueue({ concurrency: 1 });
|
|
10
|
-
this._rows = new DoublyLinked();
|
|
11
|
-
this._closed = false;
|
|
12
17
|
this._statement = statement;
|
|
13
18
|
this._portal = portal;
|
|
14
19
|
this._parsers = parsers;
|
|
@@ -13,11 +13,14 @@ import { parseRow } from '../util/parse-row.js';
|
|
|
13
13
|
import { wrapRowDescription } from '../util/wrap-row-description.js';
|
|
14
14
|
const DataFormat = Protocol.DataFormat;
|
|
15
15
|
export class IntlConnection extends SafeEventEmitter {
|
|
16
|
+
_refCount = 0;
|
|
17
|
+
_config;
|
|
18
|
+
_onErrorSavePoint;
|
|
19
|
+
transactionStatus = 'I';
|
|
20
|
+
socket;
|
|
21
|
+
statementQueue = new TaskQueue({ concurrency: 1 });
|
|
16
22
|
constructor(config) {
|
|
17
23
|
super();
|
|
18
|
-
this._refCount = 0;
|
|
19
|
-
this.transactionStatus = 'I';
|
|
20
|
-
this.statementQueue = new TaskQueue({ concurrency: 1 });
|
|
21
24
|
this._config = Object.freeze(getConnectionConfig(config));
|
|
22
25
|
this.socket = new PgSocket(this._config);
|
|
23
26
|
this.socket.on('error', err => this._onError(err));
|
|
@@ -6,9 +6,12 @@ import { getConnectionConfig } from '../util/connection-config.js';
|
|
|
6
6
|
import { Connection } from './connection.js';
|
|
7
7
|
import { getIntlConnection, IntlConnection } from './intl-connection.js';
|
|
8
8
|
export class Pool extends SafeEventEmitter {
|
|
9
|
+
_pool;
|
|
10
|
+
_notificationListeners = new SafeEventEmitter();
|
|
11
|
+
_notificationConnection;
|
|
12
|
+
config;
|
|
9
13
|
constructor(config) {
|
|
10
14
|
super();
|
|
11
|
-
this._notificationListeners = new SafeEventEmitter();
|
|
12
15
|
const cfg = getConnectionConfig(config);
|
|
13
16
|
this.config = Object.freeze(cfg);
|
|
14
17
|
const poolOptions = {};
|
|
@@ -3,8 +3,10 @@ import { GlobalTypeMap } from '../data-type-map.js';
|
|
|
3
3
|
import { Protocol } from '../protocol/protocol.js';
|
|
4
4
|
import { getIntlConnection } from './intl-connection.js';
|
|
5
5
|
export class Portal {
|
|
6
|
+
_statement;
|
|
7
|
+
_name;
|
|
8
|
+
_columnFormat = DEFAULT_COLUMN_FORMAT;
|
|
6
9
|
constructor(statement, name) {
|
|
7
|
-
this._columnFormat = DEFAULT_COLUMN_FORMAT;
|
|
8
10
|
this._statement = statement;
|
|
9
11
|
this._name = name;
|
|
10
12
|
}
|
|
@@ -13,11 +13,14 @@ import { Portal } from './portal.js';
|
|
|
13
13
|
let statementCounter = 0;
|
|
14
14
|
let portalCounter = 0;
|
|
15
15
|
export class PreparedStatement extends SafeEventEmitter {
|
|
16
|
+
_connection;
|
|
17
|
+
_sql = '';
|
|
18
|
+
_name = '';
|
|
19
|
+
_paramTypes;
|
|
20
|
+
_onErrorSavePoint;
|
|
21
|
+
_refCount = 0;
|
|
16
22
|
constructor(connection, sql, paramTypes) {
|
|
17
23
|
super();
|
|
18
|
-
this._sql = '';
|
|
19
|
-
this._name = '';
|
|
20
|
-
this._refCount = 0;
|
|
21
24
|
this._connection = connection;
|
|
22
25
|
this._name = 'S_' + ++statementCounter;
|
|
23
26
|
this._sql = sql;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Protocol } from './protocol/protocol.js';
|
|
2
2
|
var DataFormat = Protocol.DataFormat;
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
Symbol.asyncDispose
|
|
4
|
+
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
|
|
5
5
|
export { DataFormat };
|
|
6
6
|
export const DEFAULT_COLUMN_FORMAT = DataFormat.binary;
|
|
7
7
|
export var ConnectionState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataType } from './interfaces/data-type.js';
|
|
2
|
-
import { OID } from './types.js';
|
|
1
|
+
import type { DataType } from './interfaces/data-type.js';
|
|
2
|
+
import type { OID } from './types.js';
|
|
3
3
|
export declare class DataTypeMap {
|
|
4
4
|
private _itemsByOID;
|
|
5
5
|
private _items;
|
|
@@ -23,9 +23,9 @@ import { ArrayTimestamptzType, TimestamptzType, } from './data-types/timestamptz
|
|
|
23
23
|
import { ArrayUuidType, UuidType } from './data-types/uuid-type.js';
|
|
24
24
|
import { ArrayVarcharType, VarcharType } from './data-types/varchar-type.js';
|
|
25
25
|
export class DataTypeMap {
|
|
26
|
+
_itemsByOID = {};
|
|
27
|
+
_items = [];
|
|
26
28
|
constructor(other) {
|
|
27
|
-
this._itemsByOID = {};
|
|
28
|
-
this._items = [];
|
|
29
29
|
if (other instanceof DataTypeMap)
|
|
30
30
|
Object.assign(this._items, other._items);
|
|
31
31
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
+
import { SmartBuffer } from '../protocol/smart-buffer.js';
|
|
2
3
|
import { decodeBinaryArray } from '../util/decode-binaryarray.js';
|
|
3
4
|
import { encodeBinaryArray } from '../util/encode-binaryarray.js';
|
|
4
5
|
import { fastParseInt } from '../util/fast-parseint.js';
|
package/package.json
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postgrejs",
|
|
3
3
|
"description": "Professional PostgreSQL client NodeJS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.23.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.
|
|
8
|
+
"@jsopen/objects": "^2.2.3",
|
|
9
9
|
"doublylinked": "^2.5.6",
|
|
10
10
|
"lightning-pool": "^4.12.0",
|
|
11
11
|
"postgres-bytea": "^3.0.0",
|
|
12
|
-
"power-tasks": "^1.
|
|
12
|
+
"power-tasks": "^1.14.2",
|
|
13
13
|
"putil-promisify": "^1.10.1",
|
|
14
|
-
"putil-varhelpers": "^1.
|
|
14
|
+
"putil-varhelpers": "^1.7.0",
|
|
15
15
|
"tslib": "^2.8.1"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
|
+
"module": "./index.js",
|
|
19
|
+
"types": "./index.d.ts",
|
|
18
20
|
"exports": {
|
|
19
21
|
".": {
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"default": "./esm/index.js"
|
|
23
|
-
},
|
|
24
|
-
"require": {
|
|
25
|
-
"types": "./types/index.d.cts",
|
|
26
|
-
"default": "./cjs/index.js"
|
|
27
|
-
},
|
|
28
|
-
"default": "./esm/index.js"
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"default": "./index.js"
|
|
29
24
|
},
|
|
30
25
|
"./package.json": "./package.json"
|
|
31
26
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20.0"
|
|
29
|
+
},
|
|
35
30
|
"homepage": "https://postgrejs.panates.com/",
|
|
36
31
|
"contributors": [
|
|
37
32
|
"Eray Hanoglu <e.hanoglu@panates.com>"
|
|
@@ -40,17 +35,6 @@
|
|
|
40
35
|
"type": "git",
|
|
41
36
|
"url": "https://github.com/panates/postgrejs.git"
|
|
42
37
|
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=16.0"
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"cjs/",
|
|
48
|
-
"esm/",
|
|
49
|
-
"types/",
|
|
50
|
-
"LICENSE",
|
|
51
|
-
"README.md",
|
|
52
|
-
"CHANGELOG.md"
|
|
53
|
-
],
|
|
54
38
|
"keywords": [
|
|
55
39
|
"postgresql",
|
|
56
40
|
"postgres",
|
|
@@ -62,10 +46,7 @@
|
|
|
62
46
|
"client",
|
|
63
47
|
"backend",
|
|
64
48
|
"rdbms",
|
|
65
|
-
"sql"
|
|
66
|
-
"typescript",
|
|
67
|
-
"ts",
|
|
68
|
-
"esm"
|
|
49
|
+
"sql"
|
|
69
50
|
],
|
|
70
51
|
"publishConfig": {
|
|
71
52
|
"access": "public"
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
import { Protocol } from './protocol.js';
|
|
1
2
|
export class DatabaseError extends Error {
|
|
3
|
+
severity;
|
|
4
|
+
code;
|
|
5
|
+
detail;
|
|
6
|
+
hint;
|
|
7
|
+
position;
|
|
8
|
+
internalPosition;
|
|
9
|
+
internalQuery;
|
|
10
|
+
where;
|
|
11
|
+
schema;
|
|
12
|
+
table;
|
|
13
|
+
column;
|
|
14
|
+
dataType;
|
|
15
|
+
constraint;
|
|
16
|
+
lineNr;
|
|
17
|
+
colNr;
|
|
18
|
+
line;
|
|
2
19
|
constructor(msg) {
|
|
3
20
|
super(msg.message);
|
|
4
21
|
Object.assign(this, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_COLUMN_FORMAT } from '../constants.js';
|
|
2
|
+
import { DataTypeMap } from '../data-type-map.js';
|
|
2
3
|
import { encodeBinaryArray } from '../util/encode-binaryarray.js';
|
|
3
4
|
import { stringifyArrayLiteral } from '../util/stringify-arrayliteral.js';
|
|
4
5
|
import { Protocol } from './protocol.js';
|
|
@@ -26,6 +27,7 @@ const StaticSyncBuffer = Buffer.from([
|
|
|
26
27
|
0x04,
|
|
27
28
|
]);
|
|
28
29
|
export class Frontend {
|
|
30
|
+
_io;
|
|
29
31
|
constructor(options) {
|
|
30
32
|
this._io = new SmartBuffer(options?.buffer);
|
|
31
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectionState } from '../constants.js';
|
|
2
2
|
import type { ConnectionConfiguration } from '../interfaces/database-connection-params.js';
|
|
3
3
|
import { SafeEventEmitter } from '../safe-event-emitter.js';
|
|
4
|
-
import { Callback, Maybe } from '../types.js';
|
|
4
|
+
import type { Callback, Maybe } from '../types.js';
|
|
5
5
|
import { Frontend } from './frontend.js';
|
|
6
6
|
import { Protocol } from './protocol.js';
|
|
7
7
|
export type CaptureCallback = (code: Protocol.BackendMessageCode, msg: any, done: (err: Maybe<Error>, result?: any) => void) => void | Promise<void>;
|
|
@@ -13,12 +13,18 @@ import { SASL } from './sasl.js';
|
|
|
13
13
|
const DEFAULT_PORT_NUMBER = 5432;
|
|
14
14
|
const COMMAND_RESULT_PATTERN = /^([^\d]+)(?: (\d+)(?: (\d+))?)?$/;
|
|
15
15
|
export class PgSocket extends SafeEventEmitter {
|
|
16
|
+
options;
|
|
17
|
+
_state = ConnectionState.CLOSED;
|
|
18
|
+
_socket;
|
|
19
|
+
_backend = new Backend();
|
|
20
|
+
_frontend;
|
|
21
|
+
_sessionParameters = {};
|
|
22
|
+
_saslSession;
|
|
23
|
+
_processID;
|
|
24
|
+
_secretKey;
|
|
16
25
|
constructor(options) {
|
|
17
26
|
super();
|
|
18
27
|
this.options = options;
|
|
19
|
-
this._state = ConnectionState.CLOSED;
|
|
20
|
-
this._backend = new Backend();
|
|
21
|
-
this._sessionParameters = {};
|
|
22
28
|
this._frontend = new Frontend({ buffer: options.buffer });
|
|
23
29
|
this.setMaxListeners(99);
|
|
24
30
|
}
|
|
@@ -2,11 +2,17 @@ import * as os from 'os';
|
|
|
2
2
|
import { writeBigUInt64BE } from '../util/bigint-methods.js';
|
|
3
3
|
import { BufferReader } from './buffer-reader.js';
|
|
4
4
|
export class SmartBuffer extends BufferReader {
|
|
5
|
+
static DEFAULT_PAGE_SIZE = 4096;
|
|
6
|
+
static DEFAULT_MAX_SIZE = Math.min(Math.floor(os.totalmem() / 2), 1024 * 1024 * 1024 * 2);
|
|
7
|
+
_houseKeepInterval;
|
|
8
|
+
_houseKeepTimer;
|
|
9
|
+
_lastHouseKeep = 0;
|
|
10
|
+
_stMaxPages = 1;
|
|
11
|
+
_length = 0;
|
|
12
|
+
pageSize;
|
|
13
|
+
maxSize;
|
|
5
14
|
constructor(cfg) {
|
|
6
15
|
super(Buffer.allocUnsafe(cfg?.pageSize || SmartBuffer.DEFAULT_PAGE_SIZE));
|
|
7
|
-
this._lastHouseKeep = 0;
|
|
8
|
-
this._stMaxPages = 1;
|
|
9
|
-
this._length = 0;
|
|
10
16
|
this._houseKeepInterval = cfg?.houseKeepInterval || 5000;
|
|
11
17
|
this.pageSize = this.buffer.length;
|
|
12
18
|
this.maxSize = cfg?.maxLength || SmartBuffer.DEFAULT_MAX_SIZE;
|
|
@@ -169,5 +175,3 @@ export class SmartBuffer extends BufferReader {
|
|
|
169
175
|
this._stMaxPages = this.length ? Math.ceil(this.length / this.pageSize) : 1;
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
|
-
SmartBuffer.DEFAULT_PAGE_SIZE = 4096;
|
|
173
|
-
SmartBuffer.DEFAULT_MAX_SIZE = Math.min(Math.floor(os.totalmem() / 2), 1024 * 1024 * 1024 * 2);
|