@flowcore/pathways 0.3.0 → 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 CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## [0.3.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.4...v0.3.0) (2025-03-15)
4
11
 
5
12
 
@@ -1,8 +1,28 @@
1
1
  import type { PathwayState } from "../types.js";
2
2
  /**
3
- * Configuration options for PostgreSQL pathway state storage
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 PostgresPathwayStateConfig {
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,0BAA0B;IACzC,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;IACd,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IA0C3C,OAAO,CAAC,MAAM;IAzC1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAiB;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;IAgCxB;;;;;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"}
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;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;IAEZ,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,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,C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- this.postgres = await createPostgresAdapter({
76
- host: this.config.host,
77
- port: this.config.port,
78
- user: this.config.user,
79
- password: this.config.password,
80
- database: this.config.database,
81
- ssl: this.config.ssl,
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.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,8 +1,28 @@
1
1
  import type { PathwayState } from "../types.js";
2
2
  /**
3
- * Configuration options for PostgreSQL pathway state storage
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 PostgresPathwayStateConfig {
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,0BAA0B;IACzC,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;IACd,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IA0C3C,OAAO,CAAC,MAAM;IAzC1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAiB;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;IAgCxB;;;;;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"}
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;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;IAEZ,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB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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
- this.postgres = await (0, postgres_adapter_js_1.createPostgresAdapter)({
80
- host: this.config.host,
81
- port: this.config.port,
82
- user: this.config.user,
83
- password: this.config.password,
84
- database: this.config.database,
85
- ssl: this.config.ssl,
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} (