@m2k-5f/pgtx 2.4.1 → 2.5.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 +157 -36
- package/dist/connection.d.ts +33 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +95 -14
- package/dist/pool.d.ts +73 -3
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +119 -8
- package/dist/protocol/connection-response-reader.d.ts +5 -2
- package/dist/protocol/connection-response-reader.d.ts.map +1 -1
- package/dist/protocol/connection-response-reader.js +6 -23
- package/dist/protocol/socket-authorization.d.ts +1 -0
- package/dist/protocol/socket-authorization.d.ts.map +1 -1
- package/dist/protocol/socket-authorization.js +80 -83
- package/dist/protocol/socket-connector.d.ts +1 -1
- package/dist/protocol/socket-connector.d.ts.map +1 -1
- package/dist/protocol/socket-connector.js +2 -1
- package/dist/query.d.ts +21 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +42 -4
- package/dist/transaction.d.ts +2 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +4 -2
- package/package.json +54 -55
package/dist/query.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Future } from "fluent-future";
|
|
1
2
|
import { QueryText, StatementName } from "./connection";
|
|
2
3
|
import { ColumnDescription, ValueOF } from "./types";
|
|
4
|
+
import { PostgresError } from "./error";
|
|
3
5
|
export declare const QueryState: {
|
|
4
6
|
readonly Parsing: 0;
|
|
5
7
|
readonly Describing: 1;
|
|
@@ -14,14 +16,31 @@ export declare class Query<T> {
|
|
|
14
16
|
state: State;
|
|
15
17
|
statementName: StatementName;
|
|
16
18
|
columns?: ColumnDescription[] | undefined;
|
|
17
|
-
|
|
19
|
+
future: Future<T[], PostgresError>;
|
|
18
20
|
private _resolve;
|
|
19
21
|
private _reject;
|
|
20
22
|
private _rows;
|
|
23
|
+
private _timer?;
|
|
21
24
|
constructor(text: QueryText, args: (string | null)[], state: State, statementName: StatementName, columns?: ColumnDescription[] | undefined);
|
|
25
|
+
startTimeout(timeout: number): void;
|
|
22
26
|
setState(state: State): void;
|
|
23
27
|
push(value: T): void;
|
|
24
|
-
reject(cause:
|
|
28
|
+
reject(cause: PostgresError): void;
|
|
29
|
+
resolve(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare class StreamQuery<T> {
|
|
32
|
+
text: QueryText;
|
|
33
|
+
args: (string | null)[];
|
|
34
|
+
state: State;
|
|
35
|
+
statementName: StatementName;
|
|
36
|
+
private _controller;
|
|
37
|
+
columns?: ColumnDescription[] | undefined;
|
|
38
|
+
private _timer?;
|
|
39
|
+
constructor(text: QueryText, args: (string | null)[], state: State, statementName: StatementName, _controller: ReadableStreamDefaultController<T>, columns?: ColumnDescription[] | undefined);
|
|
40
|
+
setState(state: State): void;
|
|
41
|
+
startTimeout(timeout: number): void;
|
|
42
|
+
push(value: T): void;
|
|
43
|
+
reject(cause: PostgresError): void;
|
|
25
44
|
resolve(): void;
|
|
26
45
|
}
|
|
27
46
|
//# sourceMappingURL=query.d.ts.map
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,eAAO,MAAM,UAAU;;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AAC,CAAC,CAAC,EAChD,OAAO,CAAC,EAAE,iBAAiB,EAAE,YAAA;IAGxC,QAAQ,CAAC,KAAK,EAAE,KAAK;IAIrB,YAAY,CAAC,OAAO,EAAE,MAAM;IAM5B,IAAI,CAAC,KAAK,EAAE,CAAC;IAIb,MAAM,CAAC,KAAK,EAAE,aAAa;IAK3B,OAAO;CAIV"}
|
package/dist/query.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Future } from "fluent-future";
|
|
2
|
+
import { PostgresError } from "./error";
|
|
1
3
|
export const QueryState = {
|
|
2
4
|
Parsing: 0,
|
|
3
5
|
Describing: 1,
|
|
@@ -13,10 +15,15 @@ export class Query {
|
|
|
13
15
|
this.statementName = statementName;
|
|
14
16
|
this.columns = columns;
|
|
15
17
|
this._rows = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const { future, reject, resolve } = Future.withResolvers();
|
|
19
|
+
this.future = future;
|
|
20
|
+
this._resolve = resolve;
|
|
21
|
+
this._reject = reject;
|
|
22
|
+
}
|
|
23
|
+
startTimeout(timeout) {
|
|
24
|
+
this._timer = setTimeout(() => {
|
|
25
|
+
this.reject(new PostgresError('Query timeout', '57014'));
|
|
26
|
+
}, timeout);
|
|
20
27
|
}
|
|
21
28
|
setState(state) {
|
|
22
29
|
this.state = state;
|
|
@@ -25,9 +32,40 @@ export class Query {
|
|
|
25
32
|
this._rows.push(value);
|
|
26
33
|
}
|
|
27
34
|
reject(cause) {
|
|
35
|
+
clearTimeout(this._timer);
|
|
28
36
|
this._reject(cause);
|
|
29
37
|
}
|
|
30
38
|
resolve() {
|
|
39
|
+
clearTimeout(this._timer);
|
|
31
40
|
this._resolve(this._rows);
|
|
32
41
|
}
|
|
33
42
|
}
|
|
43
|
+
export class StreamQuery {
|
|
44
|
+
constructor(text, args, state, statementName, _controller, columns) {
|
|
45
|
+
this.text = text;
|
|
46
|
+
this.args = args;
|
|
47
|
+
this.state = state;
|
|
48
|
+
this.statementName = statementName;
|
|
49
|
+
this._controller = _controller;
|
|
50
|
+
this.columns = columns;
|
|
51
|
+
}
|
|
52
|
+
setState(state) {
|
|
53
|
+
this.state = state;
|
|
54
|
+
}
|
|
55
|
+
startTimeout(timeout) {
|
|
56
|
+
this._timer = setTimeout(() => {
|
|
57
|
+
this.reject(new PostgresError('Query timeout', '57014'));
|
|
58
|
+
}, timeout);
|
|
59
|
+
}
|
|
60
|
+
push(value) {
|
|
61
|
+
this._controller.enqueue(value);
|
|
62
|
+
}
|
|
63
|
+
reject(cause) {
|
|
64
|
+
clearTimeout(this._timer);
|
|
65
|
+
this._controller.error(cause);
|
|
66
|
+
}
|
|
67
|
+
resolve() {
|
|
68
|
+
clearTimeout(this._timer);
|
|
69
|
+
this._controller.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/transaction.d.ts
CHANGED
|
@@ -17,11 +17,11 @@ export declare class Transaction {
|
|
|
17
17
|
/**
|
|
18
18
|
* Commits the current transaction.
|
|
19
19
|
*/
|
|
20
|
-
commit(): Future<
|
|
20
|
+
commit(): Future<void, any>;
|
|
21
21
|
/**
|
|
22
22
|
* Rolls back the current transaction.
|
|
23
23
|
*/
|
|
24
|
-
rollback(): Future<
|
|
24
|
+
rollback(): Future<void, any>;
|
|
25
25
|
/**
|
|
26
26
|
* Executes a query within the current transaction.
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAG7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACI,MAAM
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAG7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACI,MAAM;IAQb;;OAEG;IACI,QAAQ;IAQf;;OAEG;IACI,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAK3F;;;;;;;;;OASG;IACI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;CAWjG"}
|
package/dist/transaction.js
CHANGED
|
@@ -26,7 +26,8 @@ export class Transaction {
|
|
|
26
26
|
commit() {
|
|
27
27
|
this.checkActive();
|
|
28
28
|
return this.conn.query `COMMIT`
|
|
29
|
-
.tap(() => this.isFinished = true)
|
|
29
|
+
.tap(() => { this.isFinished = true; })
|
|
30
|
+
.map(() => { });
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Rolls back the current transaction.
|
|
@@ -34,7 +35,8 @@ export class Transaction {
|
|
|
34
35
|
rollback() {
|
|
35
36
|
this.checkActive();
|
|
36
37
|
return this.conn.query `ROLLBACK`
|
|
37
|
-
.tap(() => this.isFinished = true)
|
|
38
|
+
.tap(() => { this.isFinished = true; })
|
|
39
|
+
.map(() => { });
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Executes a query within the current transaction.
|
package/package.json
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@m2k-5f/pgtx",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Blazing-fast PostgreSQL driver with pipeline support.",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist",
|
|
8
|
-
"README.md"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"prepublishOnly": "npm run build",
|
|
13
|
-
"testGitHub": "node --import tsx --test $(find tests -name '*.test.ts')",
|
|
14
|
-
"test": "node --import tsx --test ./tests/*.test.ts",
|
|
15
|
-
"benchmark": "npx tsx benchmark.ts"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git://github.com/M2K-5F/pgtx.git"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"sql",
|
|
23
|
-
"postgres",
|
|
24
|
-
"driver",
|
|
25
|
-
"pipeline",
|
|
26
|
-
"query-builder",
|
|
27
|
-
"typescript",
|
|
28
|
-
"transactions",
|
|
29
|
-
"prepared-statements"
|
|
30
|
-
],
|
|
31
|
-
"author": "M2K-5F",
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"homepage": "https://github.com/M2K-5F/pgtx",
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/M2K-5F/pgtx/issues"
|
|
36
|
-
},
|
|
37
|
-
"exports": {
|
|
38
|
-
".": {
|
|
39
|
-
"import": "./dist/index.js",
|
|
40
|
-
"require": "./dist/index.js",
|
|
41
|
-
"types": "./dist/index.d.ts"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@types/node": "^26.
|
|
46
|
-
"mitata": "^1.0.34",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@m2k-5f/pgtx",
|
|
3
|
+
"version": "2.5.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Blazing-fast PostgreSQL driver with pipeline support.",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"testGitHub": "node --import tsx --test $(find tests -name '*.test.ts')",
|
|
14
|
+
"test": "node --import tsx --test ./tests/*.test.ts",
|
|
15
|
+
"benchmark": "npx tsx benchmark.ts"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git://github.com/M2K-5F/pgtx.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"sql",
|
|
23
|
+
"postgres",
|
|
24
|
+
"driver",
|
|
25
|
+
"pipeline",
|
|
26
|
+
"query-builder",
|
|
27
|
+
"typescript",
|
|
28
|
+
"transactions",
|
|
29
|
+
"prepared-statements"
|
|
30
|
+
],
|
|
31
|
+
"author": "M2K-5F",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"homepage": "https://github.com/M2K-5F/pgtx",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/M2K-5F/pgtx/issues"
|
|
36
|
+
},
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"import": "./dist/index.js",
|
|
40
|
+
"require": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^26.2.0",
|
|
46
|
+
"mitata": "^1.0.34",
|
|
47
|
+
"postgres": "^3.4.9",
|
|
48
|
+
"tsx": "^4.23.11",
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"fluent-future": "^1.4.1"
|
|
53
|
+
}
|
|
54
|
+
}
|