@flowcore/pathways 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +95 -0
  3. package/esm/pathways/builder.d.ts +31 -1
  4. package/esm/pathways/builder.d.ts.map +1 -1
  5. package/esm/pathways/builder.js +47 -5
  6. package/esm/pathways/kv/kv-adapter.d.ts +59 -2
  7. package/esm/pathways/kv/kv-adapter.d.ts.map +1 -1
  8. package/esm/pathways/kv/kv-adapter.js +31 -1
  9. package/esm/pathways/postgres/postgres-pathway-state.d.ts +131 -1
  10. package/esm/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
  11. package/esm/pathways/postgres/postgres-pathway-state.js +131 -1
  12. package/esm/pathways/session-pathway.d.ts +63 -1
  13. package/esm/pathways/session-pathway.d.ts.map +1 -1
  14. package/esm/pathways/session-pathway.js +65 -0
  15. package/esm/router/index.d.ts +83 -2
  16. package/esm/router/index.d.ts.map +1 -1
  17. package/esm/router/index.js +83 -2
  18. package/package.json +4 -5
  19. package/script/pathways/builder.d.ts +31 -1
  20. package/script/pathways/builder.d.ts.map +1 -1
  21. package/script/pathways/builder.js +47 -5
  22. package/script/pathways/kv/kv-adapter.d.ts +59 -2
  23. package/script/pathways/kv/kv-adapter.d.ts.map +1 -1
  24. package/script/pathways/kv/kv-adapter.js +31 -1
  25. package/script/pathways/postgres/postgres-pathway-state.d.ts +131 -1
  26. package/script/pathways/postgres/postgres-pathway-state.d.ts.map +1 -1
  27. package/script/pathways/postgres/postgres-pathway-state.js +131 -1
  28. package/script/pathways/session-pathway.d.ts +63 -1
  29. package/script/pathways/session-pathway.d.ts.map +1 -1
  30. package/script/pathways/session-pathway.js +65 -0
  31. package/script/router/index.d.ts +83 -2
  32. package/script/router/index.d.ts.map +1 -1
  33. package/script/router/index.js +83 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.1](https://github.com/flowcore-io/flowcore-pathways/compare/v0.9.0...v0.9.1) (2025-04-08)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * force bun-sqlite-key-value only as optional dependency ([c8a4ce5](https://github.com/flowcore-io/flowcore-pathways/commit/c8a4ce523def84e33c8986da04b758ab0b45ac17))
9
+
10
+ ## [0.9.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.8.0...v0.9.0) (2025-03-18)
11
+
12
+
13
+ ### Features
14
+
15
+ * **pathways:** :sparkles: Introduce Session Pathways for session management ([5ad1f1d](https://github.com/flowcore-io/flowcore-pathways/commit/5ad1f1d706dcfb4ba517c38a2748274d43762cb6))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **pathways:** :art: Change import of KvAdapter to type import ([732da2d](https://github.com/flowcore-io/flowcore-pathways/commit/732da2d191b87781b2be3adf9efa150e2eaab3ef))
21
+
3
22
  ## [0.8.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.7.0...v0.8.0) (2025-03-18)
4
23
 
5
24
 
package/README.md CHANGED
@@ -21,6 +21,7 @@ A TypeScript Library for creating Flowcore Pathways, simplifying the integration
21
21
  - [Auditing](#auditing)
22
22
  - [Custom Loggers](#custom-loggers)
23
23
  - [Retry Mechanisms](#retry-mechanisms)
24
+ - [Session Pathways](#session-pathways)
24
25
  - [API Reference](#api-reference)
25
26
 
26
27
  ## Installation
@@ -415,6 +416,100 @@ pathways.register({
415
416
  });
416
417
  ```
417
418
 
419
+ ### Session Pathways
420
+
421
+ The `SessionPathwayBuilder` provides a way to associate session IDs with pathway operations, making it easier to track and manage user sessions in your application.
422
+
423
+ #### Setting Up Session Support
424
+
425
+ To use session-specific functionality, first configure your `PathwaysBuilder` with session support:
426
+
427
+ ```typescript
428
+ import { PathwaysBuilder, createKvAdapter } from "@flowcore/pathways";
429
+
430
+ // Create a KV adapter for storing session information
431
+ const sessionStore = await createKvAdapter();
432
+
433
+ // Configure the builder with session support
434
+ const pathways = new PathwaysBuilder({
435
+ baseUrl: "https://api.flowcore.io",
436
+ tenant: "your-tenant",
437
+ dataCore: "your-data-core",
438
+ apiKey: "your-api-key",
439
+ sessionUserResolvers: sessionStore // Enable session-specific resolvers
440
+ });
441
+ ```
442
+
443
+ #### Creating Session Pathways
444
+
445
+ Create a session-specific pathway wrapper:
446
+
447
+ ```typescript
448
+ import { SessionPathwayBuilder } from "@flowcore/pathways";
449
+
450
+ // Create a session with an auto-generated session ID
451
+ const session = new SessionPathwayBuilder(pathways);
452
+ const sessionId = session.getSessionId(); // Get the auto-generated ID
453
+
454
+ // Or create a session with a specific session ID
455
+ const customSession = new SessionPathwayBuilder(pathways, "user-session-123");
456
+ ```
457
+
458
+ #### Session-Specific User Resolvers
459
+
460
+ You can register different user resolvers for different sessions, allowing you to associate users with specific sessions:
461
+
462
+ ```typescript
463
+ // Register a user resolver for a specific session
464
+ pathways.withSessionUserResolver("user-session-123", async () => {
465
+ // Return the user ID for this session
466
+ return "user-456";
467
+ });
468
+
469
+ // Alternative: Register directly through the session instance
470
+ session.withUserResolver(async () => {
471
+ return "user-789";
472
+ });
473
+ ```
474
+
475
+ #### Writing Events with Session Context
476
+
477
+ Events written through a session builder automatically include the session ID:
478
+
479
+ ```typescript
480
+ // Write an event with session context
481
+ await session.write("order/placed", {
482
+ orderId: "ord-123",
483
+ userId: "user-456",
484
+ total: 99.99,
485
+ items: [{ id: "item-1", quantity: 2 }]
486
+ });
487
+
488
+ // You can override the session ID for a specific write
489
+ await session.write(
490
+ "order/placed",
491
+ orderData,
492
+ {}, // No metadata
493
+ { sessionId: "different-session" }
494
+ );
495
+ ```
496
+
497
+ #### Session ID in Audit Events
498
+
499
+ When auditing is enabled, the session ID is included in the audit metadata:
500
+
501
+ ```typescript
502
+ // Enable auditing
503
+ pathways.withAudit((path, event) => {
504
+ console.log(`Audit: ${path} event ${event.eventId}`);
505
+ // The session ID will be included in event metadata
506
+ });
507
+
508
+ // Now when writing events through a session
509
+ await session.write("order/placed", orderData);
510
+ // The session ID is automatically included in the audit metadata
511
+ ```
512
+
418
513
  ## API Reference
419
514
 
420
515
  For a complete API reference, please see the [API documentation](https://jsr.io/@flowcore/pathways).
@@ -1,6 +1,7 @@
1
1
  import type { Static, TSchema } from "@sinclair/typebox";
2
2
  import type { WebhookSendOptions } from "@flowcore/sdk-transformer-core";
3
3
  import type { FlowcoreEvent } from "../contracts/event.js";
4
+ import type { KvAdapter } from "./kv/kv-adapter.js";
4
5
  import type { Logger } from "./logger.js";
5
6
  import type { EventMetadata, PathwayContract, PathwayKey, PathwayState, PathwayWriteOptions, WritablePathway } from "./types.js";
6
7
  /**
@@ -77,14 +78,16 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
77
78
  * @param options.apiKey The API key for authentication
78
79
  * @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
79
80
  * @param options.logger Optional logger instance
81
+ * @param options.sessionUserResolvers Optional KvAdapter instance for session-specific user resolvers
80
82
  */
81
- constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, }: {
83
+ constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, sessionUserResolvers, }: {
82
84
  baseUrl: string;
83
85
  tenant: string;
84
86
  dataCore: string;
85
87
  apiKey: string;
86
88
  pathwayTimeoutMs?: number;
87
89
  logger?: Logger;
90
+ sessionUserResolvers?: KvAdapter;
88
91
  });
89
92
  /**
90
93
  * Configures the PathwaysBuilder to use a custom pathway state implementation
@@ -106,9 +109,36 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
106
109
  withUserResolver(resolver: UserIdResolver): PathwaysBuilder<TPathway, TWritablePaths>;
107
110
  /**
108
111
  * Registers a user resolver for a specific session
112
+ *
113
+ * Session-specific user resolvers allow you to associate different user IDs with different
114
+ * sessions, which is useful in multi-user applications or when tracking user actions across
115
+ * different sessions.
116
+ *
117
+ * The resolver is stored in a key-value store with a TTL (time to live), and will be used
118
+ * to resolve the user ID when operations are performed with the given session ID. If the resolver
119
+ * expires, it will need to be registered again.
120
+ *
121
+ * This feature works in conjunction with the SessionPathwayBuilder to provide a complete
122
+ * session management solution.
123
+ *
109
124
  * @param sessionId The session ID to associate with this resolver
110
125
  * @param resolver The resolver function that resolves to the user ID for this session
111
126
  * @returns The PathwaysBuilder instance for chaining
127
+ *
128
+ * @throws Error if session user resolvers are not configured (sessionUserResolvers not provided in constructor)
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Register a resolver for a specific session
133
+ * pathwaysBuilder.withSessionUserResolver("session-123", async () => {
134
+ * return "user-456"; // Return the user ID for this session
135
+ * });
136
+ *
137
+ * // Use with SessionPathwayBuilder
138
+ * const session = new SessionPathwayBuilder(pathwaysBuilder, "session-123");
139
+ * await session.write("user/action", actionData);
140
+ * // The user ID will be automatically included in the metadata
141
+ * ```
112
142
  */
113
143
  withSessionUserResolver(sessionId: string, resolver: UserIdResolver): PathwaysBuilder<TPathway, TWritablePaths>;
114
144
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pathways/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,KAAK,EAAyD,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAG/H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAA6B,eAAe,EAAE,MAAM,YAAY,CAAA;AAiB3J;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EA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ClC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;KAAE,KAAK,IAAI,GACpG,IAAI;IAmBP;;;OAGG;IACH,UAAU,CACR,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GACrE,IAAI;IAMP;;;;;;;OAOG;IACG,KAAK,CAAC,KAAK,SAAS,cAAc,EACtC,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,EACrB,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;IAuH7B;;;;;;;;;;OAUG;YACW,2BAA2B;CA4C1C"}
@@ -15,6 +15,10 @@ const DEFAULT_MAX_RETRIES = 3;
15
15
  * Default delay between retry attempts in milliseconds
16
16
  */
17
17
  const DEFAULT_RETRY_DELAY_MS = 500;
18
+ /**
19
+ * Default TTL for session-specific user resolvers in milliseconds (10seconds)
20
+ */
21
+ const DEFAULT_SESSION_USER_RESOLVER_TTL_MS = 10 * 1000;
18
22
  /**
19
23
  * Main builder class for creating and managing Flowcore pathways
20
24
  *
@@ -39,8 +43,9 @@ export class PathwaysBuilder {
39
43
  * @param options.apiKey The API key for authentication
40
44
  * @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
41
45
  * @param options.logger Optional logger instance
46
+ * @param options.sessionUserResolvers Optional KvAdapter instance for session-specific user resolvers
42
47
  */
43
- constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, }) {
48
+ constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, sessionUserResolvers, }) {
44
49
  Object.defineProperty(this, "pathways", {
45
50
  enumerable: true,
46
51
  configurable: true,
@@ -155,7 +160,7 @@ export class PathwaysBuilder {
155
160
  enumerable: true,
156
161
  configurable: true,
157
162
  writable: true,
158
- value: new Map()
163
+ value: null
159
164
  });
160
165
  // Logger instance (but not using it yet due to TypeScript errors)
161
166
  Object.defineProperty(this, "logger", {
@@ -196,6 +201,9 @@ export class PathwaysBuilder {
196
201
  this.tenant = tenant;
197
202
  this.dataCore = dataCore;
198
203
  this.apiKey = apiKey;
204
+ if (sessionUserResolvers) {
205
+ this.sessionUserResolvers = sessionUserResolvers;
206
+ }
199
207
  this.logger.debug('Initializing PathwaysBuilder', {
200
208
  baseUrl,
201
209
  tenant,
@@ -249,13 +257,43 @@ export class PathwaysBuilder {
249
257
  }
250
258
  /**
251
259
  * Registers a user resolver for a specific session
260
+ *
261
+ * Session-specific user resolvers allow you to associate different user IDs with different
262
+ * sessions, which is useful in multi-user applications or when tracking user actions across
263
+ * different sessions.
264
+ *
265
+ * The resolver is stored in a key-value store with a TTL (time to live), and will be used
266
+ * to resolve the user ID when operations are performed with the given session ID. If the resolver
267
+ * expires, it will need to be registered again.
268
+ *
269
+ * This feature works in conjunction with the SessionPathwayBuilder to provide a complete
270
+ * session management solution.
271
+ *
252
272
  * @param sessionId The session ID to associate with this resolver
253
273
  * @param resolver The resolver function that resolves to the user ID for this session
254
274
  * @returns The PathwaysBuilder instance for chaining
275
+ *
276
+ * @throws Error if session user resolvers are not configured (sessionUserResolvers not provided in constructor)
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * // Register a resolver for a specific session
281
+ * pathwaysBuilder.withSessionUserResolver("session-123", async () => {
282
+ * return "user-456"; // Return the user ID for this session
283
+ * });
284
+ *
285
+ * // Use with SessionPathwayBuilder
286
+ * const session = new SessionPathwayBuilder(pathwaysBuilder, "session-123");
287
+ * await session.write("user/action", actionData);
288
+ * // The user ID will be automatically included in the metadata
289
+ * ```
255
290
  */
256
291
  withSessionUserResolver(sessionId, resolver) {
292
+ if (!this.sessionUserResolvers) {
293
+ throw new Error('Session user resolvers not configured');
294
+ }
257
295
  this.logger.debug('Configuring session-specific user resolver', { sessionId });
258
- this.sessionUserResolvers.set(sessionId, resolver);
296
+ this.sessionUserResolvers.set(sessionId, resolver, DEFAULT_SESSION_USER_RESOLVER_TTL_MS);
259
297
  return this;
260
298
  }
261
299
  /**
@@ -264,7 +302,11 @@ export class PathwaysBuilder {
264
302
  * @returns The resolver function for the session, or undefined if none exists
265
303
  */
266
304
  getSessionUserResolver(sessionId) {
267
- return this.sessionUserResolvers.get(sessionId);
305
+ if (!this.sessionUserResolvers) {
306
+ return undefined;
307
+ }
308
+ const resolver = this.sessionUserResolvers.get(sessionId);
309
+ return resolver;
268
310
  }
269
311
  /**
270
312
  * Process a pathway event with error handling and retries
@@ -588,7 +630,7 @@ export class PathwaysBuilder {
588
630
  // Check for session-specific user resolver
589
631
  let userId;
590
632
  if (options?.sessionId) {
591
- const sessionUserResolver = this.sessionUserResolvers.get(options.sessionId);
633
+ const sessionUserResolver = this.getSessionUserResolver(options.sessionId);
592
634
  if (sessionUserResolver) {
593
635
  try {
594
636
  userId = await sessionUserResolver();
@@ -2,7 +2,34 @@
2
2
  * Interface for key-value storage adapters
3
3
  *
4
4
  * Provides a common interface for different KV storage implementations
5
- * that can be used for storing pathway state.
5
+ * that can be used for storing pathway state and other application data.
6
+ *
7
+ * This interface abstracts away the details of specific storage backends,
8
+ * allowing the application to work with different storage providers
9
+ * without changing the core logic.
10
+ *
11
+ * The Flowcore Pathways library includes several implementations of this interface:
12
+ * - BunKvAdapter: Uses Bun's built-in KV store
13
+ * - NodeKvAdapter: Uses node-cache for in-memory storage
14
+ * - DenoKvAdapter: Uses Deno's KV store (when available)
15
+ *
16
+ * Custom implementations can be created for other storage backends
17
+ * by implementing this interface.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Create a KV adapter
22
+ * const store = await createKvAdapter();
23
+ *
24
+ * // Store a value with a TTL
25
+ * await store.set("session:123", { userId: "user-456" }, 3600000); // 1 hour TTL
26
+ *
27
+ * // Retrieve the value
28
+ * const session = await store.get<{ userId: string }>("session:123");
29
+ * if (session) {
30
+ * console.log("User ID:", session.userId);
31
+ * }
32
+ * ```
6
33
  */
7
34
  export interface KvAdapter {
8
35
  /**
@@ -26,9 +53,39 @@ export interface KvAdapter {
26
53
  /**
27
54
  * Creates an appropriate KV adapter based on the runtime environment
28
55
  *
29
- * Attempts to use Bun KV adapter if running in Bun, falls back to Node adapter otherwise
56
+ * This function automatically detects the current runtime environment and creates
57
+ * the most suitable KV adapter implementation:
58
+ *
59
+ * - In Bun: Returns a BunKvAdapter using Bun's built-in KV store
60
+ * - In Deno with KV access: Returns a DenoKvAdapter
61
+ * - Otherwise: Returns a NodeKvAdapter using an in-memory cache
62
+ *
63
+ * Using this factory function rather than directly instantiating a specific adapter
64
+ * implementation makes your code more portable across different JavaScript runtimes.
65
+ *
66
+ * The adapter is lazily initialized, so any necessary setup only happens when
67
+ * you first interact with the adapter.
30
68
  *
31
69
  * @returns A KV adapter instance for the current runtime
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // Create a runtime-specific KV adapter
74
+ * const kv = await createKvAdapter();
75
+ *
76
+ * // Use with PathwaysBuilder for session user resolvers
77
+ * const pathways = new PathwaysBuilder({
78
+ * baseUrl: "https://api.flowcore.io",
79
+ * tenant: "my-tenant",
80
+ * dataCore: "my-data-core",
81
+ * apiKey: "my-api-key",
82
+ * sessionUserResolvers: kv
83
+ * });
84
+ *
85
+ * // Use as a general-purpose key-value store
86
+ * await kv.set("cache:user:123", userData, 60 * 60 * 1000); // 1 hour TTL
87
+ * const cachedUser = await kv.get("cache:user:123");
88
+ * ```
32
89
  */
33
90
  export declare function createKvAdapter(): Promise<KvAdapter>;
34
91
  //# sourceMappingURL=kv-adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/kv-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;CACzE;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAU1D"}
1
+ {"version":3,"file":"kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/kv-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;CACzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAU1D"}
@@ -1,9 +1,39 @@
1
1
  /**
2
2
  * Creates an appropriate KV adapter based on the runtime environment
3
3
  *
4
- * Attempts to use Bun KV adapter if running in Bun, falls back to Node adapter otherwise
4
+ * This function automatically detects the current runtime environment and creates
5
+ * the most suitable KV adapter implementation:
6
+ *
7
+ * - In Bun: Returns a BunKvAdapter using Bun's built-in KV store
8
+ * - In Deno with KV access: Returns a DenoKvAdapter
9
+ * - Otherwise: Returns a NodeKvAdapter using an in-memory cache
10
+ *
11
+ * Using this factory function rather than directly instantiating a specific adapter
12
+ * implementation makes your code more portable across different JavaScript runtimes.
13
+ *
14
+ * The adapter is lazily initialized, so any necessary setup only happens when
15
+ * you first interact with the adapter.
5
16
  *
6
17
  * @returns A KV adapter instance for the current runtime
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // Create a runtime-specific KV adapter
22
+ * const kv = await createKvAdapter();
23
+ *
24
+ * // Use with PathwaysBuilder for session user resolvers
25
+ * const pathways = new PathwaysBuilder({
26
+ * baseUrl: "https://api.flowcore.io",
27
+ * tenant: "my-tenant",
28
+ * dataCore: "my-data-core",
29
+ * apiKey: "my-api-key",
30
+ * sessionUserResolvers: kv
31
+ * });
32
+ *
33
+ * // Use as a general-purpose key-value store
34
+ * await kv.set("cache:user:123", userData, 60 * 60 * 1000); // 1 hour TTL
35
+ * const cachedUser = await kv.get("cache:user:123");
36
+ * ```
7
37
  */
8
38
  export async function createKvAdapter() {
9
39
  try {
@@ -53,6 +53,47 @@ export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringCon
53
53
  *
54
54
  * This class provides persistent storage of pathway state using a PostgreSQL database,
55
55
  * which allows for state to be shared across multiple instances of the application.
56
+ *
57
+ * Key features:
58
+ * - Persistent storage of pathway processing state across application restarts
59
+ * - Automatic table and index creation
60
+ * - Configurable TTL (time-to-live) for processed events
61
+ * - Automatic cleanup of expired records
62
+ * - Support for horizontal scaling across multiple instances
63
+ * - Connection pooling for efficient database usage
64
+ *
65
+ * Use cases:
66
+ * - Production deployments that require durability and persistence
67
+ * - Distributed systems where multiple instances process events
68
+ * - Applications with high reliability requirements
69
+ * - Scenarios where in-memory state is insufficient
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * // Create PostgreSQL pathway state with connection string
74
+ * const postgresState = createPostgresPathwayState({
75
+ * connectionString: "postgres://user:password@localhost:5432/mydb",
76
+ * tableName: "event_processing_state", // Optional
77
+ * ttlMs: 24 * 60 * 60 * 1000 // 24 hours (optional)
78
+ * });
79
+ *
80
+ * // Or with individual parameters
81
+ * const postgresState = createPostgresPathwayState({
82
+ * host: "localhost",
83
+ * port: 5432,
84
+ * user: "postgres",
85
+ * password: "postgres",
86
+ * database: "mydb",
87
+ * ssl: false,
88
+ * tableName: "event_processing_state", // Optional
89
+ * ttlMs: 30 * 60 * 1000 // 30 minutes (optional)
90
+ * });
91
+ *
92
+ * // Use with PathwaysBuilder
93
+ * const pathways = new PathwaysBuilder({
94
+ * // ... other config
95
+ * }).withPathwayState(postgresState);
96
+ * ```
56
97
  */
57
98
  export declare class PostgresPathwayState implements PathwayState {
58
99
  private config;
@@ -102,15 +143,66 @@ export declare class PostgresPathwayState implements PathwayState {
102
143
  /**
103
144
  * Checks if an event has already been processed
104
145
  *
146
+ * This method checks the PostgreSQL database to determine if an event with the given ID
147
+ * has been marked as processed. If the event exists in the database and is marked as processed,
148
+ * the method returns true.
149
+ *
150
+ * Before performing the check, this method also triggers cleanup of expired event records
151
+ * to maintain database performance.
152
+ *
105
153
  * @param {string} eventId - The ID of the event to check
106
154
  * @returns {Promise<boolean>} True if the event has been processed, false otherwise
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * // Check if an event has been processed
159
+ * const processed = await postgresState.isProcessed("event-123");
160
+ * if (processed) {
161
+ * console.log("Event has already been processed, skipping");
162
+ * } else {
163
+ * console.log("Processing event for the first time");
164
+ * // Process the event
165
+ * await processEvent(event);
166
+ * // Mark as processed
167
+ * await postgresState.setProcessed("event-123");
168
+ * }
169
+ * ```
107
170
  */
108
171
  isProcessed(eventId: string): Promise<boolean>;
109
172
  /**
110
173
  * Marks an event as processed
111
174
  *
175
+ * This method inserts or updates a record in the PostgreSQL database to mark an event
176
+ * as processed. If the event already exists in the database, the record is updated;
177
+ * otherwise, a new record is created.
178
+ *
179
+ * Each processed event is stored with an expiration timestamp based on the configured TTL.
180
+ * After this time elapses, the record may be automatically removed during cleanup operations.
181
+ *
112
182
  * @param {string} eventId - The ID of the event to mark as processed
113
183
  * @returns {Promise<void>}
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Process an event and mark it as processed
188
+ * async function handleEvent(event) {
189
+ * // Check if already processed to implement idempotency
190
+ * if (await postgresState.isProcessed(event.id)) {
191
+ * return; // Skip already processed events
192
+ * }
193
+ *
194
+ * try {
195
+ * // Process the event
196
+ * await processEvent(event);
197
+ *
198
+ * // Mark as processed after successful processing
199
+ * await postgresState.setProcessed(event.id);
200
+ * } catch (error) {
201
+ * console.error("Failed to process event:", error);
202
+ * // Not marking as processed, so it can be retried
203
+ * }
204
+ * }
205
+ * ```
114
206
  */
115
207
  setProcessed(eventId: string): Promise<void>;
116
208
  /**
@@ -130,8 +222,46 @@ export declare class PostgresPathwayState implements PathwayState {
130
222
  /**
131
223
  * Creates a new PostgreSQL pathway state instance
132
224
  *
133
- * @param config The PostgreSQL configuration
225
+ * This is a factory function that simplifies the creation of PostgresPathwayState instances.
226
+ * It accepts either a connection string or individual connection parameters, along with
227
+ * optional configuration for table name and TTL.
228
+ *
229
+ * The PostgresPathwayState is lazily initialized, meaning the database connection and
230
+ * table creation only happen when the first operation is performed. This makes it safe
231
+ * to create instances early in the application lifecycle.
232
+ *
233
+ * @param config The PostgreSQL configuration (connection string or parameters)
134
234
  * @returns A new PostgresPathwayState instance
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // With connection string
239
+ * const state = createPostgresPathwayState({
240
+ * connectionString: "postgres://user:pass@localhost:5432/db?sslmode=require"
241
+ * });
242
+ *
243
+ * // With individual parameters
244
+ * const state = createPostgresPathwayState({
245
+ * host: "localhost",
246
+ * port: 5432,
247
+ * user: "postgres",
248
+ * password: "secret",
249
+ * database: "events_db",
250
+ * ssl: true
251
+ * });
252
+ *
253
+ * // With custom table name and TTL
254
+ * const state = createPostgresPathwayState({
255
+ * connectionString: "postgres://user:pass@localhost:5432/db",
256
+ * tableName: "my_custom_event_state",
257
+ * ttlMs: 7 * 24 * 60 * 60 * 1000 // 1 week
258
+ * });
259
+ *
260
+ * // Use with PathwaysBuilder
261
+ * const pathways = new PathwaysBuilder({
262
+ * // Other config
263
+ * }).withPathwayState(state);
264
+ * ```
135
265
  */
136
266
  export declare function createPostgresPathwayState(config: PostgresPathwayStateConfig): PostgresPathwayState;
137
267
  //# 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;;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,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;IAEd,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,0CAA0C,GAAG,oCAAoC,CAAC;AAE3H;;;;;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;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"}
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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