@memberjunction/postgresql-dataprovider 0.0.1 → 5.6.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 +218 -28
- package/dist/PostgreSQLDataProvider.d.ts +138 -0
- package/dist/PostgreSQLDataProvider.d.ts.map +1 -0
- package/dist/PostgreSQLDataProvider.js +626 -0
- package/dist/PostgreSQLDataProvider.js.map +1 -0
- package/dist/PostgreSQLTransactionGroup.d.ts +26 -0
- package/dist/PostgreSQLTransactionGroup.d.ts.map +1 -0
- package/dist/PostgreSQLTransactionGroup.js +117 -0
- package/dist/PostgreSQLTransactionGroup.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/pgConnectionManager.d.ts +78 -0
- package/dist/pgConnectionManager.d.ts.map +1 -0
- package/dist/pgConnectionManager.js +101 -0
- package/dist/pgConnectionManager.js.map +1 -0
- package/dist/queryParameterProcessor.d.ts +24 -0
- package/dist/queryParameterProcessor.d.ts.map +1 -0
- package/dist/queryParameterProcessor.js +54 -0
- package/dist/queryParameterProcessor.js.map +1 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -7
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TransactionGroupBase, TransactionResult } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL implementation of the TransactionGroupBase.
|
|
4
|
+
* Uses a dedicated pg.PoolClient with BEGIN/COMMIT/ROLLBACK
|
|
5
|
+
* to wrap all transaction items in a single database transaction.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PostgreSQLTransactionGroup extends TransactionGroupBase {
|
|
8
|
+
protected HandleSubmit(): Promise<TransactionResult[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Executes transaction items sequentially when there are variable dependencies between them.
|
|
11
|
+
*/
|
|
12
|
+
private executeWithVariables;
|
|
13
|
+
/**
|
|
14
|
+
* Executes transaction items sequentially (no variable dependencies).
|
|
15
|
+
*/
|
|
16
|
+
private executeWithoutVariables;
|
|
17
|
+
/**
|
|
18
|
+
* Executes a single transaction item against the given client connection.
|
|
19
|
+
*/
|
|
20
|
+
private executeItem;
|
|
21
|
+
/**
|
|
22
|
+
* Safely attempts a rollback, suppressing errors from already-rolled-back transactions.
|
|
23
|
+
*/
|
|
24
|
+
private safeRollback;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=PostgreSQLTransactionGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLTransactionGroup.d.ts","sourceRoot":"","sources":["../src/PostgreSQLTransactionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,oBAAoB,EAAmB,iBAAiB,EAAY,MAAM,sBAAsB,CAAC;AAKpH;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,oBAAoB;cAChD,YAAY,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAmC5D;;OAEG;YACW,oBAAoB;IAmClC;;OAEG;YACW,uBAAuB;IAoBrC;;OAEG;YACW,WAAW;IAWzB;;OAEG;YACW,YAAY;CAS7B"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Metadata, TransactionGroupBase, TransactionResult, LogError } from '@memberjunction/core';
|
|
2
|
+
import { PGQueryParameterProcessor } from './queryParameterProcessor.js';
|
|
3
|
+
/**
|
|
4
|
+
* PostgreSQL implementation of the TransactionGroupBase.
|
|
5
|
+
* Uses a dedicated pg.PoolClient with BEGIN/COMMIT/ROLLBACK
|
|
6
|
+
* to wrap all transaction items in a single database transaction.
|
|
7
|
+
*/
|
|
8
|
+
export class PostgreSQLTransactionGroup extends TransactionGroupBase {
|
|
9
|
+
async HandleSubmit() {
|
|
10
|
+
const returnResults = [];
|
|
11
|
+
const items = this.PendingTransactions;
|
|
12
|
+
const pgProvider = Metadata.Provider;
|
|
13
|
+
if (items.length === 0) {
|
|
14
|
+
return returnResults;
|
|
15
|
+
}
|
|
16
|
+
const pool = items[0].ExtraData.dataSource;
|
|
17
|
+
const client = await pool.connect();
|
|
18
|
+
try {
|
|
19
|
+
await client.query('BEGIN');
|
|
20
|
+
if (this.Variables.length > 0) {
|
|
21
|
+
await this.executeWithVariables(items, client, pgProvider, returnResults);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
await this.executeWithoutVariables(items, client, returnResults);
|
|
25
|
+
}
|
|
26
|
+
await client.query('COMMIT');
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
await this.safeRollback(client);
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Transaction failed: ${String(error)}. All changes have been rolled back.`);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
client.release();
|
|
37
|
+
}
|
|
38
|
+
return returnResults;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Executes transaction items sequentially when there are variable dependencies between them.
|
|
42
|
+
*/
|
|
43
|
+
async executeWithVariables(items, client, pgProvider, returnResults) {
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
let result;
|
|
46
|
+
let bSuccess = false;
|
|
47
|
+
try {
|
|
48
|
+
const numValueSet = this.SetEntityValuesFromVariables(item.BaseEntity);
|
|
49
|
+
if (numValueSet > 0 && item.OperationType !== 'Delete') {
|
|
50
|
+
// Values changed — regenerate the SQL instruction
|
|
51
|
+
const bCreate = item.OperationType === 'Create';
|
|
52
|
+
const newSqlResult = await pgProvider.GetSaveSQL(item.BaseEntity, bCreate, item.BaseEntity.ContextCurrentUser);
|
|
53
|
+
item.Instruction = newSqlResult.fullSQL;
|
|
54
|
+
if (newSqlResult.parameters) {
|
|
55
|
+
item.ExtraData.parameters = newSqlResult.parameters;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
result = await this.executeItem(client, item);
|
|
59
|
+
if (result && result.length > 0) {
|
|
60
|
+
this.SetVariableValuesFromEntity(item.BaseEntity, result[0]);
|
|
61
|
+
}
|
|
62
|
+
bSuccess = (result != null && result.length > 0);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
returnResults.push(new TransactionResult(item, e, false));
|
|
66
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
67
|
+
throw new Error(`Transaction rolled back due to operation failure: ${errorMessage}`);
|
|
68
|
+
}
|
|
69
|
+
returnResults.push(new TransactionResult(item, result && result.length > 0 ? result[0] : result, bSuccess));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Executes transaction items sequentially (no variable dependencies).
|
|
74
|
+
*/
|
|
75
|
+
async executeWithoutVariables(items, client, returnResults) {
|
|
76
|
+
for (const item of items) {
|
|
77
|
+
let result;
|
|
78
|
+
let bSuccess = false;
|
|
79
|
+
try {
|
|
80
|
+
result = await this.executeItem(client, item);
|
|
81
|
+
bSuccess = (result != null && result.length > 0);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
returnResults.push(new TransactionResult(item, e, false));
|
|
85
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
86
|
+
throw new Error(`Transaction rolled back due to operation failure: ${errorMessage}`);
|
|
87
|
+
}
|
|
88
|
+
returnResults.push(new TransactionResult(item, result && result.length > 0 ? result[0] : result, bSuccess));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Executes a single transaction item against the given client connection.
|
|
93
|
+
*/
|
|
94
|
+
async executeItem(client, item) {
|
|
95
|
+
// The parameters come from GenerateSaveSQL/GenerateDeleteSQL as an array of values
|
|
96
|
+
// for $1, $2, ... placeholders. They may be stored in ExtraData.parameters (set during
|
|
97
|
+
// transaction creation) or in Vars (set by AddTransaction in the base class).
|
|
98
|
+
const rawParams = item.ExtraData?.parameters ?? item.Vars;
|
|
99
|
+
const params = PGQueryParameterProcessor.ProcessParameters(rawParams);
|
|
100
|
+
const queryResult = await client.query(item.Instruction, params);
|
|
101
|
+
return queryResult.rows;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Safely attempts a rollback, suppressing errors from already-rolled-back transactions.
|
|
105
|
+
*/
|
|
106
|
+
async safeRollback(client) {
|
|
107
|
+
try {
|
|
108
|
+
// PostgreSQL automatically aborts the transaction on error,
|
|
109
|
+
// but we still issue ROLLBACK to return the client to a clean state.
|
|
110
|
+
await client.query('ROLLBACK');
|
|
111
|
+
}
|
|
112
|
+
catch (rollbackError) {
|
|
113
|
+
LogError(`Failed to rollback: ${rollbackError}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=PostgreSQLTransactionGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLTransactionGroup.js","sourceRoot":"","sources":["../src/PostgreSQLTransactionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAmB,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGpH,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,oBAAoB;IACtD,KAAK,CAAC,YAAY;QACxB,MAAM,aAAa,GAAwB,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAkC,CAAC;QAE/D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,aAAa,CAAC;QACzB,CAAC;QAED,MAAM,IAAI,GAAY,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM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AC,SAAS,CAAC,CAAC;QAEtE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACjE,OAAO,WAAW,CAAC,IAAiC,CAAC;IACzD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,YAAY,CAAC,MAAqB;QAC5C,IAAI,CAAC;YACD,4DAA4D;YAC5D,qEAAqE;YACrE,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,aAAa,EAAE,CAAC;YACrB,QAAQ,CAAC,uBAAuB,aAAa,EAAE,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { PostgreSQLDataProvider } from './PostgreSQLDataProvider.js';
|
|
2
|
+
export { PGConnectionManager, PGConnectionConfig } from './pgConnectionManager.js';
|
|
3
|
+
export { PGQueryParameterProcessor } from './queryParameterProcessor.js';
|
|
4
|
+
export { PostgreSQLProviderConfigData, PostgreSQLProviderConfigOptions } from './types.js';
|
|
5
|
+
export { PostgreSQLTransactionGroup } from './PostgreSQLTransactionGroup.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { PostgreSQLDataProvider } from './PostgreSQLDataProvider.js';
|
|
2
|
+
export { PGConnectionManager } from './pgConnectionManager.js';
|
|
3
|
+
export { PGQueryParameterProcessor } from './queryParameterProcessor.js';
|
|
4
|
+
export { PostgreSQLProviderConfigData } from './types.js';
|
|
5
|
+
export { PostgreSQLTransactionGroup } from './PostgreSQLTransactionGroup.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAsB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAmC,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for establishing a PostgreSQL connection pool.
|
|
4
|
+
*/
|
|
5
|
+
export interface PGConnectionConfig {
|
|
6
|
+
/** PostgreSQL host */
|
|
7
|
+
Host: string;
|
|
8
|
+
/** PostgreSQL port (default: 5432) */
|
|
9
|
+
Port?: number;
|
|
10
|
+
/** Database name */
|
|
11
|
+
Database: string;
|
|
12
|
+
/** Username */
|
|
13
|
+
User: string;
|
|
14
|
+
/** Password */
|
|
15
|
+
Password: string;
|
|
16
|
+
/** SSL configuration */
|
|
17
|
+
SSL?: boolean | pg.ConnectionConfig['ssl'];
|
|
18
|
+
/** Maximum number of connections in the pool (default: 20) */
|
|
19
|
+
MaxConnections?: number;
|
|
20
|
+
/** Minimum number of connections in the pool (default: 2) */
|
|
21
|
+
MinConnections?: number;
|
|
22
|
+
/** Idle timeout in milliseconds (default: 30000) */
|
|
23
|
+
IdleTimeoutMillis?: number;
|
|
24
|
+
/** Connection timeout in milliseconds (default: 30000) */
|
|
25
|
+
ConnectionTimeoutMillis?: number;
|
|
26
|
+
/** MemberJunction schema name (default: __mj) */
|
|
27
|
+
MJCoreSchemaName?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Manages the PostgreSQL connection pool lifecycle.
|
|
31
|
+
* Provides a clean API for acquiring and releasing connections.
|
|
32
|
+
*/
|
|
33
|
+
export declare class PGConnectionManager {
|
|
34
|
+
private _pool;
|
|
35
|
+
private _config;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the active connection pool. Throws if not initialized.
|
|
38
|
+
*/
|
|
39
|
+
get Pool(): pg.Pool;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the pool is currently initialized and connected.
|
|
42
|
+
*/
|
|
43
|
+
get IsConnected(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the current configuration.
|
|
46
|
+
*/
|
|
47
|
+
get Config(): PGConnectionConfig | null;
|
|
48
|
+
/**
|
|
49
|
+
* Whether this manager owns its pool (created it) vs sharing an external one.
|
|
50
|
+
* Shared pools are NOT closed when Close() is called.
|
|
51
|
+
*/
|
|
52
|
+
private _ownsPool;
|
|
53
|
+
/**
|
|
54
|
+
* Initializes the connection pool with the given configuration.
|
|
55
|
+
*/
|
|
56
|
+
Initialize(config: PGConnectionConfig): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Sets an existing pool for this manager to use without creating a new one.
|
|
59
|
+
* The manager will NOT close a shared pool when Close() is called.
|
|
60
|
+
* This is used for per-request providers that share the primary pool.
|
|
61
|
+
*/
|
|
62
|
+
InitializeWithExistingPool(pool: pg.Pool, config: PGConnectionConfig): void;
|
|
63
|
+
/**
|
|
64
|
+
* Acquires a client from the pool for manual connection management.
|
|
65
|
+
*/
|
|
66
|
+
AcquireClient(): Promise<pg.PoolClient>;
|
|
67
|
+
/**
|
|
68
|
+
* Executes a query using the pool directly (auto-acquires and releases).
|
|
69
|
+
*/
|
|
70
|
+
Query<T extends pg.QueryResultRow = Record<string, unknown>>(text: string, values?: unknown[]): Promise<pg.QueryResult<T>>;
|
|
71
|
+
/**
|
|
72
|
+
* Closes the connection pool and releases all connections.
|
|
73
|
+
* If the pool was shared via InitializeWithExistingPool(), this is a no-op
|
|
74
|
+
* since the pool lifecycle is managed by the original owner.
|
|
75
|
+
*/
|
|
76
|
+
Close(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=pgConnectionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgConnectionManager.d.ts","sourceRoot":"","sources":["../src/pgConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,IAAI,EAAE,MAAM,CAAC;IACb,eAAe;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,GAAG,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC3C,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,OAAO,CAAmC;IAElD;;OAEG;IACH,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,CAKlB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,kBAAkB,GAAG,IAAI,CAEtC;IAED;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAiB;IAElC;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B3D;;;;OAIG;IACH,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAM3E;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC;IAI7C;;OAEG;IACG,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,EAAE,GACnB,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAI7B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
/**
|
|
3
|
+
* Manages the PostgreSQL connection pool lifecycle.
|
|
4
|
+
* Provides a clean API for acquiring and releasing connections.
|
|
5
|
+
*/
|
|
6
|
+
export class PGConnectionManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this._pool = null;
|
|
9
|
+
this._config = null;
|
|
10
|
+
/**
|
|
11
|
+
* Whether this manager owns its pool (created it) vs sharing an external one.
|
|
12
|
+
* Shared pools are NOT closed when Close() is called.
|
|
13
|
+
*/
|
|
14
|
+
this._ownsPool = true;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the active connection pool. Throws if not initialized.
|
|
18
|
+
*/
|
|
19
|
+
get Pool() {
|
|
20
|
+
if (!this._pool) {
|
|
21
|
+
throw new Error('PostgreSQL connection pool is not initialized. Call Initialize() first.');
|
|
22
|
+
}
|
|
23
|
+
return this._pool;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether the pool is currently initialized and connected.
|
|
27
|
+
*/
|
|
28
|
+
get IsConnected() {
|
|
29
|
+
return this._pool != null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the current configuration.
|
|
33
|
+
*/
|
|
34
|
+
get Config() {
|
|
35
|
+
return this._config;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Initializes the connection pool with the given configuration.
|
|
39
|
+
*/
|
|
40
|
+
async Initialize(config) {
|
|
41
|
+
if (this._pool && this._ownsPool) {
|
|
42
|
+
await this.Close();
|
|
43
|
+
}
|
|
44
|
+
this._config = config;
|
|
45
|
+
this._ownsPool = true;
|
|
46
|
+
this._pool = new pg.Pool({
|
|
47
|
+
host: config.Host,
|
|
48
|
+
port: config.Port ?? 5432,
|
|
49
|
+
database: config.Database,
|
|
50
|
+
user: config.User,
|
|
51
|
+
password: config.Password,
|
|
52
|
+
ssl: config.SSL ?? false,
|
|
53
|
+
max: config.MaxConnections ?? 20,
|
|
54
|
+
min: config.MinConnections ?? 2,
|
|
55
|
+
idleTimeoutMillis: config.IdleTimeoutMillis ?? 30000,
|
|
56
|
+
connectionTimeoutMillis: config.ConnectionTimeoutMillis ?? 30000,
|
|
57
|
+
});
|
|
58
|
+
// Verify connectivity
|
|
59
|
+
const client = await this._pool.connect();
|
|
60
|
+
try {
|
|
61
|
+
await client.query('SELECT 1');
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
client.release();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Sets an existing pool for this manager to use without creating a new one.
|
|
69
|
+
* The manager will NOT close a shared pool when Close() is called.
|
|
70
|
+
* This is used for per-request providers that share the primary pool.
|
|
71
|
+
*/
|
|
72
|
+
InitializeWithExistingPool(pool, config) {
|
|
73
|
+
this._pool = pool;
|
|
74
|
+
this._config = config;
|
|
75
|
+
this._ownsPool = false;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Acquires a client from the pool for manual connection management.
|
|
79
|
+
*/
|
|
80
|
+
async AcquireClient() {
|
|
81
|
+
return this.Pool.connect();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Executes a query using the pool directly (auto-acquires and releases).
|
|
85
|
+
*/
|
|
86
|
+
async Query(text, values) {
|
|
87
|
+
return this.Pool.query(text, values);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Closes the connection pool and releases all connections.
|
|
91
|
+
* If the pool was shared via InitializeWithExistingPool(), this is a no-op
|
|
92
|
+
* since the pool lifecycle is managed by the original owner.
|
|
93
|
+
*/
|
|
94
|
+
async Close() {
|
|
95
|
+
if (this._pool && this._ownsPool) {
|
|
96
|
+
await this._pool.end();
|
|
97
|
+
}
|
|
98
|
+
this._pool = null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=pgConnectionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgConnectionManager.js","sourceRoot":"","sources":["../src/pgConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AA8BpB;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACY,UAAK,GAAmB,IAAI,CAAC;QAC7B,YAAO,GAA8B,IAAI,CAAC;QA0BlD;;;WAGG;QACK,cAAS,GAAY,IAAI,CAAC;IAyEtC,CAAC;IArGG;;OAEG;IACH,IAAI,IAAI;QACJ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;QAC/F,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IA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AA0B;QAChE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CACP,IAAY,EACZ,MAAkB;QAElB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACP,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL-specific query parameter processing.
|
|
3
|
+
* Handles type conversion differences between SQL Server and PostgreSQL.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PGQueryParameterProcessor {
|
|
6
|
+
/**
|
|
7
|
+
* Processes a parameter value for PostgreSQL.
|
|
8
|
+
* Key differences from SQL Server:
|
|
9
|
+
* - Booleans: true/false instead of 1/0
|
|
10
|
+
* - Dates: ISO 8601 strings work natively
|
|
11
|
+
* - UUIDs: passed as-is (pg driver handles them)
|
|
12
|
+
*/
|
|
13
|
+
static ProcessParameterValue(value: unknown): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Converts an array of parameters for PostgreSQL execution.
|
|
16
|
+
* PostgreSQL uses $1, $2, ... positional parameters.
|
|
17
|
+
*/
|
|
18
|
+
static ProcessParameters(params: unknown[] | undefined): unknown[];
|
|
19
|
+
/**
|
|
20
|
+
* Converts a SQL Server BIT value (1/0) to PostgreSQL BOOLEAN.
|
|
21
|
+
*/
|
|
22
|
+
static BitToBoolean(value: unknown): boolean | null;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=queryParameterProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryParameterProcessor.d.ts","sourceRoot":"","sources":["../src/queryParameterProcessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,yBAAyB;IAClC;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAUrD;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE;IAKlE;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;CAUtD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL-specific query parameter processing.
|
|
3
|
+
* Handles type conversion differences between SQL Server and PostgreSQL.
|
|
4
|
+
*/
|
|
5
|
+
export class PGQueryParameterProcessor {
|
|
6
|
+
/**
|
|
7
|
+
* Processes a parameter value for PostgreSQL.
|
|
8
|
+
* Key differences from SQL Server:
|
|
9
|
+
* - Booleans: true/false instead of 1/0
|
|
10
|
+
* - Dates: ISO 8601 strings work natively
|
|
11
|
+
* - UUIDs: passed as-is (pg driver handles them)
|
|
12
|
+
*/
|
|
13
|
+
static ProcessParameterValue(value) {
|
|
14
|
+
if (value == null)
|
|
15
|
+
return null;
|
|
16
|
+
if (typeof value === 'boolean')
|
|
17
|
+
return value; // PG natively supports boolean
|
|
18
|
+
if (value instanceof Date)
|
|
19
|
+
return value.toISOString();
|
|
20
|
+
if (typeof value === 'number')
|
|
21
|
+
return value;
|
|
22
|
+
if (typeof value === 'string')
|
|
23
|
+
return value;
|
|
24
|
+
if (Buffer.isBuffer(value))
|
|
25
|
+
return value; // BYTEA
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts an array of parameters for PostgreSQL execution.
|
|
30
|
+
* PostgreSQL uses $1, $2, ... positional parameters.
|
|
31
|
+
*/
|
|
32
|
+
static ProcessParameters(params) {
|
|
33
|
+
if (!params)
|
|
34
|
+
return [];
|
|
35
|
+
return params.map(p => PGQueryParameterProcessor.ProcessParameterValue(p));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts a SQL Server BIT value (1/0) to PostgreSQL BOOLEAN.
|
|
39
|
+
*/
|
|
40
|
+
static BitToBoolean(value) {
|
|
41
|
+
if (value == null)
|
|
42
|
+
return null;
|
|
43
|
+
if (typeof value === 'boolean')
|
|
44
|
+
return value;
|
|
45
|
+
if (typeof value === 'number')
|
|
46
|
+
return value !== 0;
|
|
47
|
+
if (typeof value === 'string') {
|
|
48
|
+
const lower = value.toLowerCase();
|
|
49
|
+
return lower === 'true' || lower === '1' || lower === 'yes';
|
|
50
|
+
}
|
|
51
|
+
return Boolean(value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=queryParameterProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryParameterProcessor.js","sourceRoot":"","sources":["../src/queryParameterProcessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAClC;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAc;QACvC,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,CAAC,+BAA+B;QAC7E,IAAI,KAAK,YAAY,IAAI;YAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;QACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,QAAQ;QAClD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAA6B;QAClD,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,KAAc;QAC9B,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,KAAK,CAAC,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YAClC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,CAAC;QAChE,CAAC;QACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACJ"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PGConnectionConfig } from './pgConnectionManager.js';
|
|
2
|
+
import { ProviderConfigDataBase } from '@memberjunction/core';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options specific to the PostgreSQL provider.
|
|
5
|
+
*/
|
|
6
|
+
export interface PostgreSQLProviderConfigOptions {
|
|
7
|
+
/** The PostgreSQL connection configuration */
|
|
8
|
+
ConnectionConfig: PGConnectionConfig;
|
|
9
|
+
/** Interval in seconds for checking metadata refresh (0 = disabled) */
|
|
10
|
+
CheckRefreshIntervalSeconds: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Configuration data for the PostgreSQL data provider.
|
|
14
|
+
* Wraps the PGConnectionConfig and adds MJ-specific options.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PostgreSQLProviderConfigData extends ProviderConfigDataBase<PostgreSQLProviderConfigOptions> {
|
|
17
|
+
get ConnectionConfig(): PGConnectionConfig;
|
|
18
|
+
get CheckRefreshIntervalSeconds(): number;
|
|
19
|
+
constructor(connectionConfig: PGConnectionConfig, MJCoreSchemaName?: string, checkRefreshIntervalSeconds?: number, includeSchemas?: string[], excludeSchemas?: string[], ignoreExistingMetadata?: boolean);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC5C,8CAA8C;IAC9C,gBAAgB,EAAE,kBAAkB,CAAC;IACrC,uEAAuE;IACvE,2BAA2B,EAAE,MAAM,CAAC;CACvC;AAED;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,sBAAsB,CAAC,+BAA+B,CAAC;IACrG,IAAI,gBAAgB,IAAI,kBAAkB,CAEzC;IAED,IAAI,2BAA2B,IAAI,MAAM,CAExC;gBAGG,gBAAgB,EAAE,kBAAkB,EACpC,gBAAgB,CAAC,EAAE,MAAM,EACzB,2BAA2B,GAAE,MAAU,EACvC,cAAc,CAAC,EAAE,MAAM,EAAE,EACzB,cAAc,CAAC,EAAE,MAAM,EAAE,EACzB,sBAAsB,GAAE,OAAc;CAa7C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProviderConfigDataBase } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration data for the PostgreSQL data provider.
|
|
4
|
+
* Wraps the PGConnectionConfig and adds MJ-specific options.
|
|
5
|
+
*/
|
|
6
|
+
export class PostgreSQLProviderConfigData extends ProviderConfigDataBase {
|
|
7
|
+
get ConnectionConfig() {
|
|
8
|
+
return this.Data.ConnectionConfig;
|
|
9
|
+
}
|
|
10
|
+
get CheckRefreshIntervalSeconds() {
|
|
11
|
+
return this.Data.CheckRefreshIntervalSeconds;
|
|
12
|
+
}
|
|
13
|
+
constructor(connectionConfig, MJCoreSchemaName, checkRefreshIntervalSeconds = 0, includeSchemas, excludeSchemas, ignoreExistingMetadata = true) {
|
|
14
|
+
super({
|
|
15
|
+
ConnectionConfig: connectionConfig,
|
|
16
|
+
CheckRefreshIntervalSeconds: checkRefreshIntervalSeconds,
|
|
17
|
+
}, MJCoreSchemaName, includeSchemas, excludeSchemas, ignoreExistingMetadata);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAY9D;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,sBAAuD;IACrG,IAAI,gBAAgB;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACtC,CAAC;IAED,IAAI,2BAA2B;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACjD,CAAC;IAED,YACI,gBAAoC,EACpC,gBAAyB,EACzB,8BAAsC,CAAC,EACvC,cAAyB,EACzB,cAAyB,EACzB,yBAAkC,IAAI;QAEtC,KAAK,CACD;YACI,gBAAgB,EAAE,gBAAgB;YAClC,2BAA2B,EAAE,2BAA2B;SAC3D,EACD,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,sBAAsB,CACzB,CAAC;IACN,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/postgresql-dataprovider",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.6.0",
|
|
5
|
+
"description": "MemberJunction: PostgreSQL Data Provider",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "ts-node-dev src/index.ts",
|
|
13
|
+
"build": "tsc && tsc-alias -f",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"test:coverage": "vitest run --coverage"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@memberjunction/core": "5.6.0",
|
|
24
|
+
"@memberjunction/generic-database-provider": "5.6.0",
|
|
25
|
+
"@memberjunction/global": "5.6.0",
|
|
26
|
+
"@memberjunction/query-processor": "5.6.0",
|
|
27
|
+
"@memberjunction/sql-dialect": "5.6.0",
|
|
28
|
+
"pg": "^8.13.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/pg": "^8.11.11",
|
|
32
|
+
"ts-node-dev": "^2.0.0",
|
|
33
|
+
"typescript": "^5.9.3",
|
|
34
|
+
"vitest": "^4.0.18"
|
|
35
|
+
}
|
|
10
36
|
}
|