@flowcore/pathways 0.2.1 → 0.2.3

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/common/flowcore.type.d.ts +3 -3
  3. package/esm/common/flowcore.type.d.ts.map +1 -1
  4. package/esm/common/index.d.ts +2 -0
  5. package/esm/common/index.d.ts.map +1 -1
  6. package/esm/common/index.js +2 -0
  7. package/esm/compatibility/flowcore-transformer-core.sdk.d.ts +4 -0
  8. package/esm/compatibility/flowcore-transformer-core.sdk.d.ts.map +1 -1
  9. package/esm/compatibility/flowcore-transformer-core.sdk.js +2 -0
  10. package/esm/contracts/index.d.ts +2 -0
  11. package/esm/contracts/index.d.ts.map +1 -1
  12. package/esm/contracts/index.js +2 -0
  13. package/esm/mod.d.ts +2 -0
  14. package/esm/mod.d.ts.map +1 -1
  15. package/esm/mod.js +2 -0
  16. package/esm/pathways/builder.d.ts +87 -0
  17. package/esm/pathways/builder.d.ts.map +1 -1
  18. package/esm/pathways/builder.js +83 -8
  19. package/esm/pathways/index.d.ts +2 -0
  20. package/esm/pathways/index.d.ts.map +1 -1
  21. package/esm/pathways/index.js +2 -0
  22. package/esm/pathways/internal-pathway.state.d.ts +5 -7
  23. package/esm/pathways/internal-pathway.state.d.ts.map +1 -1
  24. package/esm/pathways/internal-pathway.state.js +5 -7
  25. package/esm/pathways/kv/bun-kv-adapter.d.ts +5 -7
  26. package/esm/pathways/kv/bun-kv-adapter.d.ts.map +1 -1
  27. package/esm/pathways/kv/bun-kv-adapter.js +5 -7
  28. package/esm/pathways/kv/kv-adapter.d.ts +7 -7
  29. package/esm/pathways/kv/kv-adapter.js +1 -1
  30. package/esm/pathways/kv/node-kv-adapter.d.ts +6 -8
  31. package/esm/pathways/kv/node-kv-adapter.d.ts.map +1 -1
  32. package/esm/pathways/kv/node-kv-adapter.js +6 -8
  33. package/esm/pathways/logger.d.ts +65 -12
  34. package/esm/pathways/logger.d.ts.map +1 -1
  35. package/esm/pathways/logger.js +48 -3
  36. package/esm/pathways/postgres/index.d.ts +2 -0
  37. package/esm/pathways/postgres/index.d.ts.map +1 -1
  38. package/esm/pathways/postgres/index.js +2 -0
  39. package/esm/pathways/postgres/postgres-adapter.d.ts +20 -29
  40. package/esm/pathways/postgres/postgres-adapter.d.ts.map +1 -1
  41. package/esm/pathways/postgres/postgres-adapter.js +12 -17
  42. package/esm/pathways/postgres/postgres-pathway-state.d.ts +2 -6
  43. package/esm/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
  44. package/esm/pathways/postgres/postgres-pathway-state.js +2 -4
  45. package/esm/pathways/types.d.ts +48 -3
  46. package/esm/pathways/types.d.ts.map +1 -1
  47. package/esm/router/index.d.ts +17 -11
  48. package/esm/router/index.d.ts.map +1 -1
  49. package/esm/router/index.js +21 -24
  50. package/package.json +2 -2
  51. package/script/common/flowcore.type.d.ts +3 -3
  52. package/script/common/flowcore.type.d.ts.map +1 -1
  53. package/script/common/index.d.ts +2 -0
  54. package/script/common/index.d.ts.map +1 -1
  55. package/script/common/index.js +2 -0
  56. package/script/compatibility/flowcore-transformer-core.sdk.d.ts +4 -0
  57. package/script/compatibility/flowcore-transformer-core.sdk.d.ts.map +1 -1
  58. package/script/compatibility/flowcore-transformer-core.sdk.js +2 -0
  59. package/script/contracts/index.d.ts +2 -0
  60. package/script/contracts/index.d.ts.map +1 -1
  61. package/script/contracts/index.js +2 -0
  62. package/script/mod.d.ts +2 -0
  63. package/script/mod.d.ts.map +1 -1
  64. package/script/mod.js +2 -0
  65. package/script/pathways/builder.d.ts +87 -0
  66. package/script/pathways/builder.d.ts.map +1 -1
  67. package/script/pathways/builder.js +83 -8
  68. package/script/pathways/index.d.ts +2 -0
  69. package/script/pathways/index.d.ts.map +1 -1
  70. package/script/pathways/index.js +2 -0
  71. package/script/pathways/internal-pathway.state.d.ts +5 -7
  72. package/script/pathways/internal-pathway.state.d.ts.map +1 -1
  73. package/script/pathways/internal-pathway.state.js +5 -7
  74. package/script/pathways/kv/bun-kv-adapter.d.ts +5 -7
  75. package/script/pathways/kv/bun-kv-adapter.d.ts.map +1 -1
  76. package/script/pathways/kv/bun-kv-adapter.js +5 -7
  77. package/script/pathways/kv/kv-adapter.d.ts +7 -7
  78. package/script/pathways/kv/kv-adapter.js +1 -1
  79. package/script/pathways/kv/node-kv-adapter.d.ts +6 -8
  80. package/script/pathways/kv/node-kv-adapter.d.ts.map +1 -1
  81. package/script/pathways/kv/node-kv-adapter.js +6 -8
  82. package/script/pathways/logger.d.ts +65 -12
  83. package/script/pathways/logger.d.ts.map +1 -1
  84. package/script/pathways/logger.js +48 -3
  85. package/script/pathways/postgres/index.d.ts +2 -0
  86. package/script/pathways/postgres/index.d.ts.map +1 -1
  87. package/script/pathways/postgres/index.js +2 -0
  88. package/script/pathways/postgres/postgres-adapter.d.ts +20 -29
  89. package/script/pathways/postgres/postgres-adapter.d.ts.map +1 -1
  90. package/script/pathways/postgres/postgres-adapter.js +12 -17
  91. package/script/pathways/postgres/postgres-pathway-state.d.ts +2 -6
  92. package/script/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
  93. package/script/pathways/postgres/postgres-pathway-state.js +2 -4
  94. package/script/pathways/types.d.ts +48 -3
  95. package/script/pathways/types.d.ts.map +1 -1
  96. package/script/router/index.d.ts +17 -11
  97. package/script/router/index.d.ts.map +1 -1
  98. package/script/router/index.js +21 -24
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This module exports components for using PostgreSQL as a storage backend
5
5
  * for pathway state and other persistent data.
6
+ *
7
+ * @module
6
8
  */
7
9
  export * from "./postgres-adapter.js";
8
10
  export * from "./postgres-pathway-state.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
@@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  *
20
20
  * This module exports components for using PostgreSQL as a storage backend
21
21
  * for pathway state and other persistent data.
22
+ *
23
+ * @module
22
24
  */
23
25
  __exportStar(require("./postgres-adapter.js"), exports);
24
26
  __exportStar(require("./postgres-pathway-state.js"), exports);
@@ -1,7 +1,5 @@
1
1
  /**
2
2
  * Configuration options for PostgreSQL connection
3
- *
4
- * @interface PostgresConfig
5
3
  */
6
4
  export interface PostgresConfig {
7
5
  /** PostgreSQL server hostname */
@@ -21,40 +19,36 @@ export interface PostgresConfig {
21
19
  * Interface for PostgreSQL database operations
22
20
  *
23
21
  * Provides methods for connecting, querying, and executing SQL statements
24
- *
25
- * @interface PostgresAdapter
26
22
  */
27
23
  export interface PostgresAdapter {
28
24
  /**
29
25
  * Establishes a connection to the PostgreSQL database
30
- * @returns {Promise<void>}
26
+ * @returns Promise that resolves when the connection is established
31
27
  */
32
28
  connect(): Promise<void>;
33
29
  /**
34
30
  * Closes the connection to the PostgreSQL database
35
- * @returns {Promise<void>}
31
+ * @returns Promise that resolves when the connection is closed
36
32
  */
37
33
  disconnect(): Promise<void>;
38
34
  /**
39
35
  * Executes a SQL query and returns the results
40
36
  * @template T The expected result type
41
- * @param {string} sql The SQL query to execute
42
- * @param {unknown[]} [params] Optional parameters for the query
43
- * @returns {Promise<T>} The query results
37
+ * @param sql The SQL query to execute
38
+ * @param params Optional parameters for the query
39
+ * @returns Promise that resolves to the query results
44
40
  */
45
41
  query<T>(sql: string, params?: unknown[]): Promise<T>;
46
42
  /**
47
43
  * Executes a SQL statement without returning results
48
- * @param {string} sql The SQL statement to execute
49
- * @param {unknown[]} [params] Optional parameters for the statement
50
- * @returns {Promise<void>}
44
+ * @param sql The SQL statement to execute
45
+ * @param params Optional parameters for the statement
46
+ * @returns Promise that resolves when the statement has been executed
51
47
  */
52
48
  execute(sql: string, params?: unknown[]): Promise<void>;
53
49
  }
54
50
  /**
55
51
  * Implementation of PostgresAdapter using the postgres.js library
56
- *
57
- * @implements {PostgresAdapter}
58
52
  */
59
53
  export declare class PostgresJsAdapter implements PostgresAdapter {
60
54
  /** The postgres.js client factory function */
@@ -68,45 +62,42 @@ export declare class PostgresJsAdapter implements PostgresAdapter {
68
62
  /**
69
63
  * Creates a new PostgresJsAdapter instance
70
64
  *
71
- * @param {PostgresConfig} config The PostgreSQL connection configuration
65
+ * @param config The PostgreSQL connection configuration
72
66
  */
73
67
  constructor(config: PostgresConfig);
74
68
  /**
75
69
  * Establishes a connection to the PostgreSQL database
76
70
  *
77
- * @returns {Promise<void>}
78
- * @throws {Error} If connection fails
71
+ * @returns Promise that resolves when connection is established
72
+ * @throws Error if connection fails
79
73
  */
80
74
  connect(): Promise<void>;
81
75
  /**
82
76
  * Closes the connection to the PostgreSQL database
83
- *
84
- * @returns {Promise<void>}
77
+ * @returns Promise that resolves when the connection is closed
85
78
  */
86
79
  disconnect(): Promise<void>;
87
80
  /**
88
81
  * Executes a SQL query and returns the results
89
- *
90
82
  * @template T The expected result type
91
- * @param {string} sql The SQL query to execute
92
- * @param {unknown[]} [params=[]] Optional parameters for the query
93
- * @returns {Promise<T>} The query results
83
+ * @param sql The SQL query to execute
84
+ * @param params Optional parameters for the query
85
+ * @returns Promise that resolves to the query results
94
86
  */
95
87
  query<T>(sql: string, params?: unknown[]): Promise<T>;
96
88
  /**
97
89
  * Executes a SQL statement without returning results
98
- *
99
- * @param {string} sql The SQL statement to execute
100
- * @param {unknown[]} [params=[]] Optional parameters for the statement
101
- * @returns {Promise<void>}
90
+ * @param sql The SQL statement to execute
91
+ * @param params Optional parameters for the statement
92
+ * @returns Promise that resolves when the statement has been executed
102
93
  */
103
94
  execute(sql: string, params?: unknown[]): Promise<void>;
104
95
  }
105
96
  /**
106
97
  * Creates and initializes a PostgreSQL adapter
107
98
  *
108
- * @param {PostgresConfig} config The PostgreSQL connection configuration
109
- * @returns {Promise<PostgresAdapter>} An initialized PostgreSQL adapter
99
+ * @param config The PostgreSQL connection configuration
100
+ * @returns An initialized PostgreSQL adapter
110
101
  */
111
102
  export declare function createPostgresAdapter(config: PostgresConfig): Promise<PostgresAdapter>;
112
103
  //# sourceMappingURL=postgres-adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,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,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAoBD;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAA+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;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAoBD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAA+D;IAC/E,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAA+B;IAC1C,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAiB;IAC/B,yDAAyD;IACzD,OAAO,CAAC,gBAAgB,CAAS;IAEjC;;;;OAIG;gBACS,MAAM,EAAE,cAAc;IAQlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW9B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;;;;OAMG;IACG,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAO/D;;;;;OAKG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAI5F"}
@@ -27,14 +27,12 @@ exports.PostgresJsAdapter = void 0;
27
27
  exports.createPostgresAdapter = createPostgresAdapter;
28
28
  /**
29
29
  * Implementation of PostgresAdapter using the postgres.js library
30
- *
31
- * @implements {PostgresAdapter}
32
30
  */
33
31
  class PostgresJsAdapter {
34
32
  /**
35
33
  * Creates a new PostgresJsAdapter instance
36
34
  *
37
- * @param {PostgresConfig} config The PostgreSQL connection configuration
35
+ * @param config The PostgreSQL connection configuration
38
36
  */
39
37
  constructor(config) {
40
38
  /** The postgres.js client factory function */
@@ -74,8 +72,8 @@ class PostgresJsAdapter {
74
72
  /**
75
73
  * Establishes a connection to the PostgreSQL database
76
74
  *
77
- * @returns {Promise<void>}
78
- * @throws {Error} If connection fails
75
+ * @returns Promise that resolves when connection is established
76
+ * @throws Error if connection fails
79
77
  */
80
78
  async connect() {
81
79
  try {
@@ -90,8 +88,7 @@ class PostgresJsAdapter {
90
88
  }
91
89
  /**
92
90
  * Closes the connection to the PostgreSQL database
93
- *
94
- * @returns {Promise<void>}
91
+ * @returns Promise that resolves when the connection is closed
95
92
  */
96
93
  async disconnect() {
97
94
  if (this.sql) {
@@ -101,11 +98,10 @@ class PostgresJsAdapter {
101
98
  }
102
99
  /**
103
100
  * Executes a SQL query and returns the results
104
- *
105
101
  * @template T The expected result type
106
- * @param {string} sql The SQL query to execute
107
- * @param {unknown[]} [params=[]] Optional parameters for the query
108
- * @returns {Promise<T>} The query results
102
+ * @param sql The SQL query to execute
103
+ * @param params Optional parameters for the query
104
+ * @returns Promise that resolves to the query results
109
105
  */
110
106
  async query(sql, params = []) {
111
107
  if (!this.sql) {
@@ -115,10 +111,9 @@ class PostgresJsAdapter {
115
111
  }
116
112
  /**
117
113
  * Executes a SQL statement without returning results
118
- *
119
- * @param {string} sql The SQL statement to execute
120
- * @param {unknown[]} [params=[]] Optional parameters for the statement
121
- * @returns {Promise<void>}
114
+ * @param sql The SQL statement to execute
115
+ * @param params Optional parameters for the statement
116
+ * @returns Promise that resolves when the statement has been executed
122
117
  */
123
118
  async execute(sql, params = []) {
124
119
  if (!this.sql) {
@@ -131,8 +126,8 @@ exports.PostgresJsAdapter = PostgresJsAdapter;
131
126
  /**
132
127
  * Creates and initializes a PostgreSQL adapter
133
128
  *
134
- * @param {PostgresConfig} config The PostgreSQL connection configuration
135
- * @returns {Promise<PostgresAdapter>} An initialized PostgreSQL adapter
129
+ * @param config The PostgreSQL connection configuration
130
+ * @returns An initialized PostgreSQL adapter
136
131
  */
137
132
  async function createPostgresAdapter(config) {
138
133
  const adapter = new PostgresJsAdapter(config);
@@ -1,8 +1,6 @@
1
1
  import type { PathwayState } from "../types.js";
2
2
  /**
3
3
  * Configuration options for PostgreSQL pathway state storage
4
- *
5
- * @interface PostgresPathwayStateConfig
6
4
  */
7
5
  export interface PostgresPathwayStateConfig {
8
6
  /** PostgreSQL server hostname */
@@ -27,8 +25,6 @@ export interface PostgresPathwayStateConfig {
27
25
  *
28
26
  * This class provides persistent storage of pathway state using a PostgreSQL database,
29
27
  * which allows for state to be shared across multiple instances of the application.
30
- *
31
- * @implements {PathwayState}
32
28
  */
33
29
  export declare class PostgresPathwayState implements PathwayState {
34
30
  private config;
@@ -106,8 +102,8 @@ export declare class PostgresPathwayState implements PathwayState {
106
102
  /**
107
103
  * Creates a new PostgreSQL pathway state instance
108
104
  *
109
- * @param {PostgresPathwayStateConfig} config The PostgreSQL configuration
110
- * @returns {PostgresPathwayState} A new PostgresPathwayState instance
105
+ * @param config The PostgreSQL configuration
106
+ * @returns A new PostgresPathwayState instance
111
107
  */
112
108
  export declare function createPostgresPathwayState(config: PostgresPathwayStateConfig): PostgresPathwayState;
113
109
  //# sourceMappingURL=postgres-pathway-state.d.ts.map
@@ -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;;;;GAIG;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;;;;;;;GAOG;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,0BAA0B;IACzC,iCAAiC;IACjC,IAAI,EAA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8
  *
9
9
  * This class provides persistent storage of pathway state using a PostgreSQL database,
10
10
  * which allows for state to be shared across multiple instances of the application.
11
- *
12
- * @implements {PathwayState}
13
11
  */
14
12
  class PostgresPathwayState {
15
13
  /**
@@ -184,8 +182,8 @@ Object.defineProperty(PostgresPathwayState, "DEFAULT_TABLE_NAME", {
184
182
  /**
185
183
  * Creates a new PostgreSQL pathway state instance
186
184
  *
187
- * @param {PostgresPathwayStateConfig} config The PostgreSQL configuration
188
- * @returns {PostgresPathwayState} A new PostgresPathwayState instance
185
+ * @param config The PostgreSQL configuration
186
+ * @returns A new PostgresPathwayState instance
189
187
  */
190
188
  function createPostgresPathwayState(config) {
191
189
  const state = new PostgresPathwayState(config);
@@ -2,19 +2,29 @@ import type { TSchema } from "@sinclair/typebox";
2
2
  import type { WebhookFileData, WebhookSendOptions } from "@flowcore/sdk-transformer-core";
3
3
  /**
4
4
  * Helper type to create a custom type error for non-writable pathways
5
+ * @template T The string type to create an error for
5
6
  */
6
7
  type NonWritablePathwayError<T extends string> = T & {
7
8
  readonly __nonWritablePathwayError: "This pathway is not writable. To make it writable, remove 'writable: false' from the pathway contract.";
8
9
  };
9
10
  /**
10
11
  * Contract for defining a pathway
11
- * @template F - The flow type
12
- * @template E - The event type
13
- * @template T - The schema type
12
+ * @template F The flow type
13
+ * @template E The event type
14
+ * @template T The schema type
14
15
  */
15
16
  export interface PathwayContract<F extends string, E extends string, T extends TSchema> {
17
+ /**
18
+ * The flow type for this pathway
19
+ */
16
20
  flowType: F;
21
+ /**
22
+ * The event type for this pathway
23
+ */
17
24
  eventType: E;
25
+ /**
26
+ * The schema that defines the structure of events for this pathway
27
+ */
18
28
  schema: T;
19
29
  /**
20
30
  * Whether the pathway is writable. Use `false as const` to make the pathway non-writable at compile time.
@@ -63,24 +73,59 @@ export interface PathwayContract<F extends string, E extends string, T extends T
63
73
  */
64
74
  isFilePathway?: boolean;
65
75
  }
76
+ /**
77
+ * Creates a string key from flow type and event type in the format `flowType/eventType`
78
+ * @template F The flow type
79
+ * @template E The event type
80
+ */
66
81
  export type PathwayKey<F extends string, E extends string> = `${F}/${E}`;
82
+ /**
83
+ * Interface for event metadata, extending Record<string, unknown>
84
+ */
67
85
  export interface EventMetadata extends Record<string, unknown> {
68
86
  }
87
+ /**
88
+ * Function type for sending an event to a webhook
89
+ * @template EventPayload The type of the event payload
90
+ */
69
91
  export type SendWebhook<EventPayload> = (payload: EventPayload, metadata?: EventMetadata, options?: WebhookSendOptions) => Promise<string>;
92
+ /**
93
+ * Function type for sending a file to a webhook
94
+ */
70
95
  export type SendFilehook = (payload: WebhookFileData, metadata?: EventMetadata, options?: WebhookSendOptions) => Promise<string[]>;
71
96
  /**
72
97
  * Helper type to create a better error message for non-writable pathways
98
+ * @template T The string type for the pathway
99
+ * @template IsWritable Boolean indicating if the pathway is writable
73
100
  */
74
101
  export type WritablePathway<T extends string, IsWritable extends boolean> = IsWritable extends false ? NonWritablePathwayError<T> : T;
102
+ /**
103
+ * Interface for managing pathway processing state
104
+ */
75
105
  export type PathwayState = {
106
+ /**
107
+ * Checks if an event has been processed
108
+ * @param eventId The ID of the event to check
109
+ * @returns Boolean indicating if the event has been processed
110
+ */
76
111
  isProcessed: (eventId: string) => (boolean | Promise<boolean>);
112
+ /**
113
+ * Marks an event as processed
114
+ * @param eventId The ID of the event to mark as processed
115
+ */
77
116
  setProcessed: (eventId: string) => (void | Promise<void>);
78
117
  };
79
118
  /**
80
119
  * Options for pathway writes, extending WebhookSendOptions
81
120
  */
82
121
  export type PathwayWriteOptions = WebhookSendOptions & {
122
+ /**
123
+ * If true, doesn't wait for confirmation of event delivery
124
+ */
83
125
  fireAndForget?: boolean;
126
+ /**
127
+ * Additional HTTP headers to include with the request
128
+ */
84
129
  headers?: Record<string, string>;
85
130
  };
86
131
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pathways/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA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OAAO,EAAE,MAAM,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;CAC1D,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC,CAAA"}
@@ -1,10 +1,16 @@
1
+ /**
2
+ * Router module for Flowcore Pathways
3
+ *
4
+ * This module provides routing functionality to direct incoming events
5
+ * to the appropriate pathway handlers based on flow type and event type.
6
+ *
7
+ * @module
8
+ */
1
9
  import type { FlowcoreLegacyEvent } from "../common/flowcore.type.js";
2
10
  import type { PathwaysBuilder } from "../pathways/index.js";
3
11
  import type { Logger } from "../pathways/logger.js";
4
12
  /**
5
13
  * Router class that handles directing events to the appropriate pathway handlers
6
- *
7
- * @class PathwayRouter
8
14
  */
9
15
  export declare class PathwayRouter {
10
16
  private readonly pathways;
@@ -13,19 +19,19 @@ export declare class PathwayRouter {
13
19
  /**
14
20
  * Creates a new instance of PathwayRouter
15
21
  *
16
- * @param {PathwaysBuilder<Record<string, any>>} pathways - The pathways builder instance that contains all registered pathways
17
- * @param {string} secretKey - Secret key used for authentication when processing events
18
- * @param {Logger} [logger] - Optional logger instance (defaults to NoopLogger if not provided)
19
- * @throws {Error} Will throw an error if secretKey is empty or not provided
22
+ * @param pathways The pathways builder instance that contains all registered pathways
23
+ * @param secretKey Secret key used for authentication when processing events
24
+ * @param logger Optional logger instance (defaults to NoopLogger if not provided)
25
+ * @throws Error if secretKey is empty or not provided
20
26
  */
21
27
  constructor(pathways: PathwaysBuilder<Record<string, any>>, secretKey: string, logger?: Logger);
22
28
  /**
23
- * Processes an incoming event by routing it to the appropriate pathway
29
+ * Process an incoming event by routing it to the appropriate pathway handler
24
30
  *
25
- * @param {FlowcoreLegacyEvent} event - The event to process
26
- * @param {string} providedSecret - The secret key provided for authentication
27
- * @returns {Promise<{ success: boolean; message: string }>} Result of the event processing
28
- * @throws {Error} Will throw an error if authentication fails, pathway is not found, or processing fails
31
+ * @param event The event to process
32
+ * @param providedSecret The secret key provided for authentication
33
+ * @returns Result of the event processing with success status and message
34
+ * @throws Error if authentication fails, pathway is not found, or processing fails
29
35
  */
30
36
  processEvent(event: FlowcoreLegacyEvent, providedSecret: string): Promise<{
31
37
  success: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;;;GAIG;AACH,qBAAa,aAAa;IAatB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;;;OAOG;gBAGgB,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC9C,SAAS,EAAE,MAAM,EAClC,MAAM,CAAC,EAAE,MAAM;IAYjB;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAoDvH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;GAEG;AACH,qBAAa,aAAa;IAatB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;;;OAOG;gBAGgB,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC9C,SAAS,EAAE,MAAM,EAClC,MAAM,CAAC,EAAE,MAAM;IAajB;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAkDvH"}
@@ -4,17 +4,15 @@ exports.PathwayRouter = void 0;
4
4
  const logger_js_1 = require("../pathways/logger.js");
5
5
  /**
6
6
  * Router class that handles directing events to the appropriate pathway handlers
7
- *
8
- * @class PathwayRouter
9
7
  */
10
8
  class PathwayRouter {
11
9
  /**
12
10
  * Creates a new instance of PathwayRouter
13
11
  *
14
- * @param {PathwaysBuilder<Record<string, any>>} pathways - The pathways builder instance that contains all registered pathways
15
- * @param {string} secretKey - Secret key used for authentication when processing events
16
- * @param {Logger} [logger] - Optional logger instance (defaults to NoopLogger if not provided)
17
- * @throws {Error} Will throw an error if secretKey is empty or not provided
12
+ * @param pathways The pathways builder instance that contains all registered pathways
13
+ * @param secretKey Secret key used for authentication when processing events
14
+ * @param logger Optional logger instance (defaults to NoopLogger if not provided)
15
+ * @throws Error if secretKey is empty or not provided
18
16
  */
19
17
  constructor(
20
18
  // deno-lint-ignore no-explicit-any
@@ -39,24 +37,26 @@ class PathwayRouter {
39
37
  });
40
38
  this.logger = logger ?? new logger_js_1.NoopLogger();
41
39
  if (!secretKey || secretKey.trim() === "") {
42
- this.logger.error("Secret key is required for PathwayRouter");
43
- throw new Error("Secret key is required for PathwayRouter");
40
+ const errorMsg = "Secret key is required for PathwayRouter";
41
+ this.logger.error(errorMsg, new Error(errorMsg));
42
+ throw new Error(errorMsg);
44
43
  }
45
44
  this.logger.debug("PathwayRouter initialized");
46
45
  }
47
46
  /**
48
- * Processes an incoming event by routing it to the appropriate pathway
47
+ * Process an incoming event by routing it to the appropriate pathway handler
49
48
  *
50
- * @param {FlowcoreLegacyEvent} event - The event to process
51
- * @param {string} providedSecret - The secret key provided for authentication
52
- * @returns {Promise<{ success: boolean; message: string }>} Result of the event processing
53
- * @throws {Error} Will throw an error if authentication fails, pathway is not found, or processing fails
49
+ * @param event The event to process
50
+ * @param providedSecret The secret key provided for authentication
51
+ * @returns Result of the event processing with success status and message
52
+ * @throws Error if authentication fails, pathway is not found, or processing fails
54
53
  */
55
54
  async processEvent(event, providedSecret) {
56
55
  // Validate secret key
57
56
  if (!providedSecret || providedSecret !== this.secretKey) {
58
- this.logger.error("Invalid secret key provided");
59
- throw new Error("Invalid secret key");
57
+ const errorMsg = "Invalid secret key";
58
+ this.logger.error(errorMsg, new Error(errorMsg));
59
+ throw new Error(errorMsg);
60
60
  }
61
61
  const compatibleEvent = {
62
62
  ...event,
@@ -68,9 +68,9 @@ class PathwayRouter {
68
68
  });
69
69
  const pathway = this.pathways.get(pathwayKey);
70
70
  if (!pathway) {
71
- const error = `Pathway ${pathwayKey} not found`;
72
- this.logger.error(error);
73
- throw new Error(error);
71
+ const errorMsg = `Pathway ${pathwayKey} not found`;
72
+ this.logger.error(errorMsg, new Error(errorMsg));
73
+ throw new Error(errorMsg);
74
74
  }
75
75
  try {
76
76
  this.logger.debug(`Delegating event processing to pathway handler`, {
@@ -85,15 +85,12 @@ class PathwayRouter {
85
85
  return { success: true, message: `Event processed through pathway ${pathwayKey}` };
86
86
  }
87
87
  catch (error) {
88
- const errorMessage = error instanceof Error
89
- ? error.message
90
- : String(error);
91
- this.logger.error(`Error processing pathway ${pathwayKey}`, {
92
- error: errorMessage,
88
+ const errorObj = error instanceof Error ? error : new Error(String(error));
89
+ this.logger.error(`Error processing pathway ${pathwayKey}`, errorObj, {
93
90
  eventId: compatibleEvent.eventId
94
91
  });
95
92
  // Rethrow the error with additional context
96
- throw new Error(`Failed to process event in pathway ${pathwayKey}: ${errorMessage}`);
93
+ throw new Error(`Failed to process event in pathway ${pathwayKey}: ${errorObj.message}`);
97
94
  }
98
95
  }
99
96
  }