@flowcore/pathways 0.2.4 → 0.4.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 +14 -0
- package/esm/pathways/postgres/postgres-adapter.d.ts +27 -3
- package/esm/pathways/postgres/postgres-adapter.d.ts.map +1 -1
- package/esm/pathways/postgres/postgres-adapter.js +11 -4
- package/esm/pathways/postgres/postgres-pathway-state.d.ts +30 -2
- package/esm/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
- package/esm/pathways/postgres/postgres-pathway-state.js +19 -8
- package/package.json +1 -1
- package/script/pathways/postgres/postgres-adapter.d.ts +27 -3
- package/script/pathways/postgres/postgres-adapter.d.ts.map +1 -1
- package/script/pathways/postgres/postgres-adapter.js +11 -4
- package/script/pathways/postgres/postgres-pathway-state.d.ts +30 -2
- package/script/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
- package/script/pathways/postgres/postgres-pathway-state.js +19 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.3.0...v0.4.0) (2025-03-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **postgres:** :sparkles: Add support for connection string and individual parameters in PostgreSQL configuration ([881fba2](https://github.com/flowcore-io/flowcore-pathways/commit/881fba26485349a3d4253cdb112928b9a9c31996))
|
|
9
|
+
|
|
10
|
+
## [0.3.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.4...v0.3.0) (2025-03-15)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **postgres:** :sparkles: Enhance PostgreSQL configuration with connection string support ([9b51155](https://github.com/flowcore-io/flowcore-pathways/commit/9b51155eaa8f11c5ca3e8f6422d2b4268c4f27ea))
|
|
16
|
+
|
|
3
17
|
## [0.2.4](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.3...v0.2.4) (2025-03-15)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configuration
|
|
2
|
+
* Configuration for PostgreSQL connection using a connection string
|
|
3
|
+
*/
|
|
4
|
+
export interface PostgresConnectionStringConfig {
|
|
5
|
+
/** Complete PostgreSQL connection string (e.g., postgres://user:password@host:port/database?sslmode=require) */
|
|
6
|
+
connectionString: string;
|
|
7
|
+
/** These properties are not used when a connection string is provided */
|
|
8
|
+
host?: never;
|
|
9
|
+
port?: never;
|
|
10
|
+
user?: never;
|
|
11
|
+
password?: never;
|
|
12
|
+
database?: never;
|
|
13
|
+
ssl?: never;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for PostgreSQL connection using individual parameters
|
|
3
17
|
*/
|
|
4
|
-
export interface
|
|
18
|
+
export interface PostgresParametersConfig {
|
|
19
|
+
/** Not used when individual parameters are provided */
|
|
20
|
+
connectionString?: never;
|
|
5
21
|
/** PostgreSQL server hostname */
|
|
6
22
|
host: string;
|
|
7
23
|
/** PostgreSQL server port */
|
|
@@ -15,6 +31,14 @@ export interface PostgresConfig {
|
|
|
15
31
|
/** Whether to use SSL for the connection */
|
|
16
32
|
ssl?: boolean;
|
|
17
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration options for PostgreSQL connection
|
|
36
|
+
*
|
|
37
|
+
* Can provide either:
|
|
38
|
+
* 1. A complete connection string, or
|
|
39
|
+
* 2. Individual connection parameters (host, port, user, etc.)
|
|
40
|
+
*/
|
|
41
|
+
export type PostgresConfig = PostgresConnectionStringConfig | PostgresParametersConfig;
|
|
18
42
|
/**
|
|
19
43
|
* Interface for PostgreSQL database operations
|
|
20
44
|
*
|
|
@@ -96,7 +120,7 @@ export declare class PostgresJsAdapter implements PostgresAdapter {
|
|
|
96
120
|
/**
|
|
97
121
|
* Creates and initializes a PostgreSQL adapter
|
|
98
122
|
*
|
|
99
|
-
* @param config The PostgreSQL connection configuration
|
|
123
|
+
* @param config The PostgreSQL connection configuration (either connectionString or individual parameters)
|
|
100
124
|
* @returns An initialized PostgreSQL adapter
|
|
101
125
|
*/
|
|
102
126
|
export declare function createPostgresAdapter(config: PostgresConfig): Promise<PostgresAdapter>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAC;IAEzB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAEzB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,8BAA8B,G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{
|
|
|
37
37
|
value: void 0
|
|
38
38
|
});
|
|
39
39
|
this.config = config;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.connectionString
|
|
40
|
+
if ('connectionString' in config && config.connectionString) {
|
|
41
|
+
// Use the provided connection string directly
|
|
42
|
+
this.connectionString = config.connectionString;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Build connection string from individual parameters
|
|
46
|
+
this.connectionString = `postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.database}`;
|
|
47
|
+
if (config.ssl) {
|
|
48
|
+
this.connectionString += "?sslmode=require";
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
@@ -98,7 +105,7 @@ export class PostgresJsAdapter {
|
|
|
98
105
|
/**
|
|
99
106
|
* Creates and initializes a PostgreSQL adapter
|
|
100
107
|
*
|
|
101
|
-
* @param config The PostgreSQL connection configuration
|
|
108
|
+
* @param config The PostgreSQL connection configuration (either connectionString or individual parameters)
|
|
102
109
|
* @returns An initialized PostgreSQL adapter
|
|
103
110
|
*/
|
|
104
111
|
export async function createPostgresAdapter(config) {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import type { PathwayState } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Configuration
|
|
3
|
+
* Configuration for PostgreSQL pathway state storage using a connection string
|
|
4
|
+
*/
|
|
5
|
+
export interface PostgresPathwayStateConnectionStringConfig {
|
|
6
|
+
/** Complete PostgreSQL connection string (e.g., postgres://user:password@host:port/database?sslmode=require) */
|
|
7
|
+
connectionString: string;
|
|
8
|
+
/** These properties are not used when a connection string is provided */
|
|
9
|
+
host?: never;
|
|
10
|
+
port?: never;
|
|
11
|
+
user?: never;
|
|
12
|
+
password?: never;
|
|
13
|
+
database?: never;
|
|
14
|
+
ssl?: never;
|
|
15
|
+
/** Table name for storing pathway state (default: "pathway_state") */
|
|
16
|
+
tableName?: string;
|
|
17
|
+
/** Time-to-live in milliseconds for processed events (default: 5 minutes) */
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for PostgreSQL pathway state storage using individual parameters
|
|
4
22
|
*/
|
|
5
|
-
export interface
|
|
23
|
+
export interface PostgresPathwayStateParametersConfig {
|
|
24
|
+
/** Not used when individual parameters are provided */
|
|
25
|
+
connectionString?: never;
|
|
6
26
|
/** PostgreSQL server hostname */
|
|
7
27
|
host: string;
|
|
8
28
|
/** PostgreSQL server port */
|
|
@@ -20,6 +40,14 @@ export interface PostgresPathwayStateConfig {
|
|
|
20
40
|
/** Time-to-live in milliseconds for processed events (default: 5 minutes) */
|
|
21
41
|
ttlMs?: number;
|
|
22
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration options for PostgreSQL pathway state storage
|
|
45
|
+
*
|
|
46
|
+
* Can provide either:
|
|
47
|
+
* 1. A complete connection string, or
|
|
48
|
+
* 2. Individual connection parameters (host, port, user, etc.)
|
|
49
|
+
*/
|
|
50
|
+
export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringConfig | PostgresPathwayStateParametersConfig;
|
|
23
51
|
/**
|
|
24
52
|
* Implementation of PathwayState that uses PostgreSQL for storage
|
|
25
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-pathway-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-pathway-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,0CAA0C;IACzD,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAC;IAE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AAC,KAAK,CAAS;IAEtB;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;OAIG;gBACiB,MAAM,EAAE,0BAA0B;IAMtD;;;;;OAKG;YACW,UAAU;IA0CxB;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAcpD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelD;;;;;OAKG;YACW,cAAc;IAQ5B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B,GAAG,oBAAoB,CAGnG"}
|
|
@@ -72,14 +72,25 @@ export class PostgresPathwayState {
|
|
|
72
72
|
if (this.initialized) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
// Create adapter using either connection string or individual parameters
|
|
76
|
+
if ('connectionString' in this.config && this.config.connectionString) {
|
|
77
|
+
// Use connection string if provided
|
|
78
|
+
this.postgres = await createPostgresAdapter({
|
|
79
|
+
connectionString: this.config.connectionString
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// We know this must be the parameters config due to the type union
|
|
84
|
+
// TypeScript just needs help with narrowing the type
|
|
85
|
+
this.postgres = await createPostgresAdapter({
|
|
86
|
+
host: this.config.host,
|
|
87
|
+
port: this.config.port,
|
|
88
|
+
user: this.config.user,
|
|
89
|
+
password: this.config.password,
|
|
90
|
+
database: this.config.database,
|
|
91
|
+
ssl: this.config.ssl,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
83
94
|
// Create table if it doesn't exist
|
|
84
95
|
await this.postgres.execute(`
|
|
85
96
|
CREATE TABLE IF NOT EXISTS ${this.tableName} (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowcore/pathways",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A TypeScript Library for creating Flowcore Pathways, simplifying the integration with the flowcore platform",
|
|
5
5
|
"homepage": "https://github.com/flowcore-io/flowcore-sdk#readme",
|
|
6
6
|
"repository": {
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Configuration
|
|
2
|
+
* Configuration for PostgreSQL connection using a connection string
|
|
3
|
+
*/
|
|
4
|
+
export interface PostgresConnectionStringConfig {
|
|
5
|
+
/** Complete PostgreSQL connection string (e.g., postgres://user:password@host:port/database?sslmode=require) */
|
|
6
|
+
connectionString: string;
|
|
7
|
+
/** These properties are not used when a connection string is provided */
|
|
8
|
+
host?: never;
|
|
9
|
+
port?: never;
|
|
10
|
+
user?: never;
|
|
11
|
+
password?: never;
|
|
12
|
+
database?: never;
|
|
13
|
+
ssl?: never;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for PostgreSQL connection using individual parameters
|
|
3
17
|
*/
|
|
4
|
-
export interface
|
|
18
|
+
export interface PostgresParametersConfig {
|
|
19
|
+
/** Not used when individual parameters are provided */
|
|
20
|
+
connectionString?: never;
|
|
5
21
|
/** PostgreSQL server hostname */
|
|
6
22
|
host: string;
|
|
7
23
|
/** PostgreSQL server port */
|
|
@@ -15,6 +31,14 @@ export interface PostgresConfig {
|
|
|
15
31
|
/** Whether to use SSL for the connection */
|
|
16
32
|
ssl?: boolean;
|
|
17
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration options for PostgreSQL connection
|
|
36
|
+
*
|
|
37
|
+
* Can provide either:
|
|
38
|
+
* 1. A complete connection string, or
|
|
39
|
+
* 2. Individual connection parameters (host, port, user, etc.)
|
|
40
|
+
*/
|
|
41
|
+
export type PostgresConfig = PostgresConnectionStringConfig | PostgresParametersConfig;
|
|
18
42
|
/**
|
|
19
43
|
* Interface for PostgreSQL database operations
|
|
20
44
|
*
|
|
@@ -96,7 +120,7 @@ export declare class PostgresJsAdapter implements PostgresAdapter {
|
|
|
96
120
|
/**
|
|
97
121
|
* Creates and initializes a PostgreSQL adapter
|
|
98
122
|
*
|
|
99
|
-
* @param config The PostgreSQL connection configuration
|
|
123
|
+
* @param config The PostgreSQL connection configuration (either connectionString or individual parameters)
|
|
100
124
|
* @returns An initialized PostgreSQL adapter
|
|
101
125
|
*/
|
|
102
126
|
export declare function createPostgresAdapter(config: PostgresConfig): Promise<PostgresAdapter>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAC;IAEzB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,KAAK,CAAC;IAEzB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,QAA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AO,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAI5F"}
|
|
@@ -64,9 +64,16 @@ class PostgresJsAdapter {
|
|
|
64
64
|
value: void 0
|
|
65
65
|
});
|
|
66
66
|
this.config = config;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.connectionString
|
|
67
|
+
if ('connectionString' in config && config.connectionString) {
|
|
68
|
+
// Use the provided connection string directly
|
|
69
|
+
this.connectionString = config.connectionString;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Build connection string from individual parameters
|
|
73
|
+
this.connectionString = `postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.database}`;
|
|
74
|
+
if (config.ssl) {
|
|
75
|
+
this.connectionString += "?sslmode=require";
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
@@ -126,7 +133,7 @@ exports.PostgresJsAdapter = PostgresJsAdapter;
|
|
|
126
133
|
/**
|
|
127
134
|
* Creates and initializes a PostgreSQL adapter
|
|
128
135
|
*
|
|
129
|
-
* @param config The PostgreSQL connection configuration
|
|
136
|
+
* @param config The PostgreSQL connection configuration (either connectionString or individual parameters)
|
|
130
137
|
* @returns An initialized PostgreSQL adapter
|
|
131
138
|
*/
|
|
132
139
|
async function createPostgresAdapter(config) {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import type { PathwayState } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Configuration
|
|
3
|
+
* Configuration for PostgreSQL pathway state storage using a connection string
|
|
4
|
+
*/
|
|
5
|
+
export interface PostgresPathwayStateConnectionStringConfig {
|
|
6
|
+
/** Complete PostgreSQL connection string (e.g., postgres://user:password@host:port/database?sslmode=require) */
|
|
7
|
+
connectionString: string;
|
|
8
|
+
/** These properties are not used when a connection string is provided */
|
|
9
|
+
host?: never;
|
|
10
|
+
port?: never;
|
|
11
|
+
user?: never;
|
|
12
|
+
password?: never;
|
|
13
|
+
database?: never;
|
|
14
|
+
ssl?: never;
|
|
15
|
+
/** Table name for storing pathway state (default: "pathway_state") */
|
|
16
|
+
tableName?: string;
|
|
17
|
+
/** Time-to-live in milliseconds for processed events (default: 5 minutes) */
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for PostgreSQL pathway state storage using individual parameters
|
|
4
22
|
*/
|
|
5
|
-
export interface
|
|
23
|
+
export interface PostgresPathwayStateParametersConfig {
|
|
24
|
+
/** Not used when individual parameters are provided */
|
|
25
|
+
connectionString?: never;
|
|
6
26
|
/** PostgreSQL server hostname */
|
|
7
27
|
host: string;
|
|
8
28
|
/** PostgreSQL server port */
|
|
@@ -20,6 +40,14 @@ export interface PostgresPathwayStateConfig {
|
|
|
20
40
|
/** Time-to-live in milliseconds for processed events (default: 5 minutes) */
|
|
21
41
|
ttlMs?: number;
|
|
22
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration options for PostgreSQL pathway state storage
|
|
45
|
+
*
|
|
46
|
+
* Can provide either:
|
|
47
|
+
* 1. A complete connection string, or
|
|
48
|
+
* 2. Individual connection parameters (host, port, user, etc.)
|
|
49
|
+
*/
|
|
50
|
+
export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringConfig | PostgresPathwayStateParametersConfig;
|
|
23
51
|
/**
|
|
24
52
|
* Implementation of PathwayState that uses PostgreSQL for storage
|
|
25
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-pathway-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources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;IAEvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAmB;IAE7D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAkB;IAElC;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAS;IAE1B;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAS;IAEtB;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;OAIG;gBACiB,MAAM,EAAE,0BAA0B;IAMtD;;;;;OAKG;YACW,UAAU;IA0CxB;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAcpD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelD;;;;;OAKG;YACW,cAAc;IAQ5B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B,GAAG,oBAAoB,CAGnG"}
|
|
@@ -76,14 +76,25 @@ class PostgresPathwayState {
|
|
|
76
76
|
if (this.initialized) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
// Create adapter using either connection string or individual parameters
|
|
80
|
+
if ('connectionString' in this.config && this.config.connectionString) {
|
|
81
|
+
// Use connection string if provided
|
|
82
|
+
this.postgres = await (0, postgres_adapter_js_1.createPostgresAdapter)({
|
|
83
|
+
connectionString: this.config.connectionString
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// We know this must be the parameters config due to the type union
|
|
88
|
+
// TypeScript just needs help with narrowing the type
|
|
89
|
+
this.postgres = await (0, postgres_adapter_js_1.createPostgresAdapter)({
|
|
90
|
+
host: this.config.host,
|
|
91
|
+
port: this.config.port,
|
|
92
|
+
user: this.config.user,
|
|
93
|
+
password: this.config.password,
|
|
94
|
+
database: this.config.database,
|
|
95
|
+
ssl: this.config.ssl,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
87
98
|
// Create table if it doesn't exist
|
|
88
99
|
await this.postgres.execute(`
|
|
89
100
|
CREATE TABLE IF NOT EXISTS ${this.tableName} (
|