postgrejs 2.22.7 → 2.23.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/CHANGELOG.md +20 -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/{esm/data-type-map.js → data-type-map.js} +2 -2
- package/package.json +13 -32
- package/{esm/protocol → protocol}/backend.js +1 -0
- package/{esm/protocol → protocol}/buffer-reader.js +2 -1
- package/{esm/protocol → protocol}/database-error.js +16 -0
- package/{esm/protocol → protocol}/frontend.js +1 -0
- package/{esm/protocol → protocol}/pg-socket.js +9 -3
- package/{types/protocol → protocol}/smart-buffer.d.ts +1 -0
- package/{esm/protocol → protocol}/smart-buffer.js +29 -19
- 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 -172
- 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-type-map.d.ts → data-type-map.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/{esm/data-types → data-types}/int2-vector-type.js +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}/timestamptz-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/timestamptz-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}/pg-socket.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/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,25 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v2.
|
|
3
|
+
### [v2.23.0](https://github.com/panates/postgrejs/compare/v2.22.9...v2.23.0) -
|
|
4
|
+
|
|
5
|
+
#### 🛠 Refactoring and Updates
|
|
6
|
+
|
|
7
|
+
- dev: Updated deps to support latest TypeScript and NodeJS. @Eray Hanoğlu
|
|
8
|
+
- dev: Updated deps to support latest TypeScript and NodeJS. @Eray Hanoğlu
|
|
9
|
+
|
|
10
|
+
### [v2.22.9](https://github.com/panates/postgrejs/compare/v2.22.8...v2.22.9) - 4 December 2025
|
|
11
|
+
|
|
12
|
+
### [v2.22.8](https://github.com/panates/postgrejs/compare/v2.22.7...v2.22.8) - 27 October 2025
|
|
13
|
+
|
|
14
|
+
#### 🪲 Fixes
|
|
15
|
+
|
|
16
|
+
- fix: SmartBuffer grows when offset isn't at last @Eray Hanoğlu
|
|
17
|
+
|
|
18
|
+
#### 💬 General Changes
|
|
19
|
+
|
|
20
|
+
- dev: npm Trusted publishing update @Eray Hanoğlu
|
|
21
|
+
|
|
22
|
+
### [v2.22.7](https://github.com/panates/postgrejs/compare/v2.22.6...v2.22.7) - 21 October 2025
|
|
4
23
|
|
|
5
24
|
#### 💬 General Changes
|
|
6
25
|
|
|
@@ -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;
|
|
@@ -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
|
}
|
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.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.0
|
|
8
|
+
"@jsopen/objects": "^2.2.0",
|
|
9
9
|
"doublylinked": "^2.5.6",
|
|
10
|
-
"lightning-pool": "^4.
|
|
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,20 @@
|
|
|
1
1
|
export class DatabaseError extends Error {
|
|
2
|
+
severity;
|
|
3
|
+
code;
|
|
4
|
+
detail;
|
|
5
|
+
hint;
|
|
6
|
+
position;
|
|
7
|
+
internalPosition;
|
|
8
|
+
internalQuery;
|
|
9
|
+
where;
|
|
10
|
+
schema;
|
|
11
|
+
table;
|
|
12
|
+
column;
|
|
13
|
+
dataType;
|
|
14
|
+
constraint;
|
|
15
|
+
lineNr;
|
|
16
|
+
colNr;
|
|
17
|
+
line;
|
|
2
18
|
constructor(msg) {
|
|
3
19
|
super(msg.message);
|
|
4
20
|
Object.assign(this, {
|
|
@@ -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;
|
|
@@ -57,14 +63,14 @@ export class SmartBuffer extends BufferReader {
|
|
|
57
63
|
return this;
|
|
58
64
|
}
|
|
59
65
|
fill(value = 0, len = 1) {
|
|
60
|
-
this.
|
|
66
|
+
this.ensureSize(len);
|
|
61
67
|
this.buffer.fill(value, this.offset, this.offset + len);
|
|
62
68
|
this.offset += len;
|
|
63
69
|
return this;
|
|
64
70
|
}
|
|
65
71
|
writeCString(str, encoding) {
|
|
66
72
|
const len = str ? Buffer.byteLength(str, encoding) : 0;
|
|
67
|
-
this.
|
|
73
|
+
this.ensureSize(len + 1);
|
|
68
74
|
if (str) {
|
|
69
75
|
this.buffer.write(str, this.offset, encoding);
|
|
70
76
|
this.offset += len;
|
|
@@ -74,7 +80,7 @@ export class SmartBuffer extends BufferReader {
|
|
|
74
80
|
}
|
|
75
81
|
writeLString(str, encoding) {
|
|
76
82
|
const len = str ? Buffer.byteLength(str, encoding) : 0;
|
|
77
|
-
this.
|
|
83
|
+
this.ensureSize(len + 4);
|
|
78
84
|
this.writeInt32BE(str == null ? -1 : len);
|
|
79
85
|
if (str) {
|
|
80
86
|
if (encoding)
|
|
@@ -87,50 +93,50 @@ export class SmartBuffer extends BufferReader {
|
|
|
87
93
|
writeString(str, encoding) {
|
|
88
94
|
if (str) {
|
|
89
95
|
const len = Buffer.byteLength(str, encoding);
|
|
90
|
-
this.
|
|
96
|
+
this.ensureSize(len);
|
|
91
97
|
this.offset += this.buffer.write(str, this.offset, encoding);
|
|
92
98
|
}
|
|
93
99
|
return this;
|
|
94
100
|
}
|
|
95
101
|
writeInt8(n) {
|
|
96
|
-
this.
|
|
102
|
+
this.ensureSize(1);
|
|
97
103
|
this.buffer.writeInt8(n, this.offset);
|
|
98
104
|
this.offset++;
|
|
99
105
|
return this;
|
|
100
106
|
}
|
|
101
107
|
writeUInt8(n) {
|
|
102
|
-
this.
|
|
108
|
+
this.ensureSize(1);
|
|
103
109
|
this.buffer.writeUInt8(n, this.offset);
|
|
104
110
|
this.offset++;
|
|
105
111
|
return this;
|
|
106
112
|
}
|
|
107
113
|
writeUInt16BE(n) {
|
|
108
|
-
this.
|
|
114
|
+
this.ensureSize(2);
|
|
109
115
|
this.buffer.writeUInt16BE(n, this.offset);
|
|
110
116
|
this.offset += 2;
|
|
111
117
|
return this;
|
|
112
118
|
}
|
|
113
119
|
writeUInt32BE(n) {
|
|
114
|
-
this.
|
|
120
|
+
this.ensureSize(4);
|
|
115
121
|
this.buffer.writeUInt32BE(n, this.offset);
|
|
116
122
|
this.offset += 4;
|
|
117
123
|
return this;
|
|
118
124
|
}
|
|
119
125
|
writeInt16BE(n) {
|
|
120
|
-
this.
|
|
126
|
+
this.ensureSize(2);
|
|
121
127
|
this.buffer.writeInt16BE(n, this.offset);
|
|
122
128
|
this.offset += 2;
|
|
123
129
|
return this;
|
|
124
130
|
}
|
|
125
131
|
writeInt32BE(n) {
|
|
126
|
-
this.
|
|
132
|
+
this.ensureSize(4);
|
|
127
133
|
this.buffer.writeInt32BE(n, this.offset);
|
|
128
134
|
this.offset += 4;
|
|
129
135
|
return this;
|
|
130
136
|
}
|
|
131
137
|
writeBigInt64BE(n) {
|
|
132
138
|
n = typeof n === 'bigint' ? n : BigInt(n);
|
|
133
|
-
this.
|
|
139
|
+
this.ensureSize(8);
|
|
134
140
|
if (typeof this.buffer.writeBigInt64BE === 'function')
|
|
135
141
|
this.buffer.writeBigInt64BE(n, this.offset);
|
|
136
142
|
else
|
|
@@ -139,23 +145,29 @@ export class SmartBuffer extends BufferReader {
|
|
|
139
145
|
return this;
|
|
140
146
|
}
|
|
141
147
|
writeFloatBE(n) {
|
|
142
|
-
this.
|
|
148
|
+
this.ensureSize(4);
|
|
143
149
|
this.buffer.writeFloatBE(n, this.offset);
|
|
144
150
|
this.offset += 4;
|
|
145
151
|
return this;
|
|
146
152
|
}
|
|
147
153
|
writeDoubleBE(n) {
|
|
148
|
-
this.
|
|
154
|
+
this.ensureSize(8);
|
|
149
155
|
this.buffer.writeDoubleBE(n, this.offset);
|
|
150
156
|
this.offset += 8;
|
|
151
157
|
return this;
|
|
152
158
|
}
|
|
153
159
|
writeBuffer(buffer) {
|
|
154
|
-
this.
|
|
160
|
+
this.ensureSize(buffer.length);
|
|
155
161
|
buffer.copy(this.buffer, this.offset, 0, buffer.length);
|
|
156
162
|
this.offset += buffer.length;
|
|
157
163
|
return this;
|
|
158
164
|
}
|
|
165
|
+
ensureSize(len) {
|
|
166
|
+
const n = this.offset + len - this.length;
|
|
167
|
+
if (n > 0)
|
|
168
|
+
this.growSize(n);
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
159
171
|
_houseKeep() {
|
|
160
172
|
const needSize = this._stMaxPages * this.pageSize;
|
|
161
173
|
if (this.buffer.length > needSize)
|
|
@@ -163,5 +175,3 @@ export class SmartBuffer extends BufferReader {
|
|
|
163
175
|
this._stMaxPages = this.length ? Math.ceil(this.length / this.pageSize) : 1;
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
|
-
SmartBuffer.DEFAULT_PAGE_SIZE = 4096;
|
|
167
|
-
SmartBuffer.DEFAULT_MAX_SIZE = Math.min(Math.floor(os.totalmem() / 2), 1024 * 1024 * 1024 * 2);
|