@flowcore/pathways 0.2.1 → 0.2.2

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 +9 -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 +46 -3
  34. package/esm/pathways/logger.d.ts.map +1 -1
  35. package/esm/pathways/logger.js +45 -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 +46 -3
  83. package/script/pathways/logger.d.ts.map +1 -1
  84. package/script/pathways/logger.js +45 -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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.2](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.1...v0.2.2) (2025-03-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **deno.json:** :memo: Update library description to specify TypeScript ([014f1fc](https://github.com/flowcore-io/flowcore-pathways/commit/014f1fc88d5e5545dd92ff78fa0aae86a9aceebb))
9
+ * **mod:** :memo: Add module declaration comments to pathways and mod files ([275f41a](https://github.com/flowcore-io/flowcore-pathways/commit/275f41ac9d75b2f2509ddf78ddbd31fc8cd3914a))
10
+ * **types:** :memo: Add module declaration comments and improve JSDoc formatting ([21781f2](https://github.com/flowcore-io/flowcore-pathways/commit/21781f2ab8b8064935d831dfc9f2965f703af343))
11
+
3
12
  ## [0.2.1](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.0...v0.2.1) (2025-03-15)
4
13
 
5
14
 
@@ -1,11 +1,11 @@
1
1
  import type { FlowcoreEvent } from "../contracts/event.js";
2
2
  /**
3
3
  * Extends the FlowcoreEvent with legacy fields
4
- *
5
- * @typedef {Object} FlowcoreLegacyEvent
6
- * @property {string} [aggregator] - Optional aggregator information for legacy support
7
4
  */
8
5
  export type FlowcoreLegacyEvent = FlowcoreEvent & {
6
+ /**
7
+ * Optional aggregator information for legacy support
8
+ */
9
9
  aggregator?: string;
10
10
  };
11
11
  //# sourceMappingURL=flowcore.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowcore.type.d.ts","sourceRoot":"","sources":["../../src/common/flowcore.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA"}
1
+ {"version":3,"file":"flowcore.type.d.ts","sourceRoot":"","sources":["../../src/common/flowcore.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -2,6 +2,8 @@
2
2
  * Common types and utilities for Flowcore Pathways
3
3
  *
4
4
  * This module exports common types and utilities that are used across the Flowcore Pathways library.
5
+ *
6
+ * @module
5
7
  */
6
8
  export * from "./flowcore.type.js";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAC"}
@@ -2,5 +2,7 @@
2
2
  * Common types and utilities for Flowcore Pathways
3
3
  *
4
4
  * This module exports common types and utilities that are used across the Flowcore Pathways library.
5
+ *
6
+ * @module
5
7
  */
6
8
  export * from "./flowcore.type.js";
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This module re-exports components from the @flowcore/sdk-transformer-core package
5
5
  * to provide backwards compatibility with existing transformer implementations.
6
+ *
7
+ * @module
6
8
  */
7
9
  import transformerCore from "@flowcore/sdk-transformer-core";
8
10
  /**
@@ -11,6 +13,8 @@ import transformerCore from "@flowcore/sdk-transformer-core";
11
13
  export declare const WebhookBuilder: typeof transformerCore.WebhookBuilder;
12
14
  /**
13
15
  * Options for configuring webhook send operations
16
+ *
17
+ * These options control how webhook requests are sent, including timestamps and headers.
14
18
  */
15
19
  export type { WebhookSendOptions } from "@flowcore/sdk-transformer-core";
16
20
  //# sourceMappingURL=flowcore-transformer-core.sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowcore-transformer-core.sdk.d.ts","sourceRoot":"","sources":["../../src/compatibility/flowcore-transformer-core.sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,eAAe,MAAM,gCAAgC,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAQ,cAAc,uCAAoB,CAAA;AAEjD;;GAEG;AACH,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA"}
1
+ {"version":3,"file":"flowcore-transformer-core.sdk.d.ts","sourceRoot":"","sources":["../../src/compatibility/flowcore-transformer-core.sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,eAAe,MAAM,gCAAgC,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAQ,cAAc,uCAAoB,CAAA;AAEjD;;;;GAIG;AACH,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA"}
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This module re-exports components from the @flowcore/sdk-transformer-core package
5
5
  * to provide backwards compatibility with existing transformer implementations.
6
+ *
7
+ * @module
6
8
  */
7
9
  import transformerCore from "@flowcore/sdk-transformer-core";
8
10
  /**
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * Export all contract types and schemas for Flowcore events
3
+ *
4
+ * @module
3
5
  */
4
6
  export * from "./event.js";
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAC"}
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * Export all contract types and schemas for Flowcore events
3
+ *
4
+ * @module
3
5
  */
4
6
  export * from "./event.js";
package/esm/mod.d.ts CHANGED
@@ -6,6 +6,8 @@
6
6
  * - Event contracts and schemas
7
7
  * - Pathway definitions and builders
8
8
  * - Event routing functionality
9
+ *
10
+ * @module
9
11
  */
10
12
  export * from "./common/index.js";
11
13
  export * from "./contracts/index.js";
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
package/esm/mod.js CHANGED
@@ -6,6 +6,8 @@
6
6
  * - Event contracts and schemas
7
7
  * - Pathway definitions and builders
8
8
  * - Event routing functionality
9
+ *
10
+ * @module
9
11
  */
10
12
  export * from "./common/index.js";
11
13
  export * from "./contracts/index.js";
@@ -3,12 +3,46 @@ import type { WebhookSendOptions } from "@flowcore/sdk-transformer-core";
3
3
  import type { FlowcoreEvent } from "../contracts/event.js";
4
4
  import type { Logger } from "./logger.js";
5
5
  import type { EventMetadata, PathwayContract, PathwayKey, PathwayState, PathwayWriteOptions, WritablePathway } from "./types.js";
6
+ /**
7
+ * Defines the mode for auditing pathway operations
8
+ * - "user": Normal user-initiated operations
9
+ * - "system": System-initiated operations on behalf of a user
10
+ */
6
11
  export type AuditMode = "user" | "system";
12
+ /**
13
+ * Handler function for auditing pathway events
14
+ * @param path The pathway path being audited
15
+ * @param event The event data being processed
16
+ */
7
17
  export type AuditHandler = (path: string, event: FlowcoreEvent) => void;
18
+ /**
19
+ * Async function that resolves to the current user ID
20
+ * Used for audit functionality to track which user initiated an action
21
+ */
8
22
  export type UserIdResolver = () => Promise<string>;
23
+ /**
24
+ * Extended webhook send options with additional audit-specific options
25
+ */
9
26
  export interface AuditWebhookSendOptions extends WebhookSendOptions {
27
+ /**
28
+ * Custom HTTP headers to include with the webhook request
29
+ */
10
30
  headers?: Record<string, string>;
11
31
  }
32
+ /**
33
+ * Main builder class for creating and managing Flowcore pathways
34
+ *
35
+ * The PathwaysBuilder provides an interface for:
36
+ * - Registering pathways with type-safe schemas
37
+ * - Handling events sent to pathways
38
+ * - Writing data to pathways
39
+ * - Managing event processing and retries
40
+ * - Observing event lifecycle (before/after/error)
41
+ * - Audit logging of pathway operations
42
+ *
43
+ * @template TPathway Record type that maps pathway keys to their payload types
44
+ * @template TWritablePaths Union type of pathway keys that can be written to
45
+ */
12
46
  export declare class PathwaysBuilder<TPathway extends Record<string, unknown> = {}, TWritablePaths extends keyof TPathway = never> {
13
47
  private readonly pathways;
14
48
  private readonly handlers;
@@ -29,6 +63,16 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
29
63
  private auditHandler?;
30
64
  private userIdResolver?;
31
65
  private readonly logger;
66
+ /**
67
+ * Creates a new PathwaysBuilder instance
68
+ * @param options Configuration options for the PathwaysBuilder
69
+ * @param options.baseUrl The base URL for the Flowcore API
70
+ * @param options.tenant The tenant name
71
+ * @param options.dataCore The data core name
72
+ * @param options.apiKey The API key for authentication
73
+ * @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
74
+ * @param options.logger Optional logger instance
75
+ */
32
76
  constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, }: {
33
77
  baseUrl: string;
34
78
  tenant: string;
@@ -37,6 +81,11 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
37
81
  pathwayTimeoutMs?: number;
38
82
  logger?: Logger;
39
83
  });
84
+ /**
85
+ * Configures the PathwaysBuilder to use a custom pathway state implementation
86
+ * @param state The PathwayState implementation to use
87
+ * @returns The PathwaysBuilder instance with custom state configured
88
+ */
40
89
  withPathwayState(state: PathwayState): PathwaysBuilder<TPathway, TWritablePaths>;
41
90
  /**
42
91
  * Configures the PathwaysBuilder to use audit functionality
@@ -52,12 +101,39 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
52
101
  * @returns Promise that resolves when processing is complete
53
102
  */
54
103
  process(pathway: keyof TPathway, data: FlowcoreEvent): Promise<void>;
104
+ /**
105
+ * Registers a new pathway with the given contract
106
+ * @template F The flow type string
107
+ * @template E The event type string
108
+ * @template S The schema type extending TSchema
109
+ * @template W Boolean indicating if the pathway is writable (defaults to true)
110
+ * @param contract The pathway contract describing the pathway
111
+ * @returns The PathwaysBuilder instance with the new pathway registered
112
+ */
55
113
  register<F extends string, E extends string, S extends TSchema, W extends boolean = true>(contract: PathwayContract<F, E, S> & {
56
114
  writable?: W;
57
115
  maxRetries?: number;
58
116
  retryDelayMs?: number;
59
117
  }): PathwaysBuilder<TPathway & Record<PathwayKey<F, E>, Static<S>>, TWritablePaths | WritablePathway<PathwayKey<F, E>, W>>;
118
+ /**
119
+ * Gets a pathway instance by its path
120
+ *
121
+ * @template TPath The specific pathway key to retrieve
122
+ * @param path The pathway key to get
123
+ * @returns The pathway instance
124
+ */
60
125
  get<TPath extends keyof TPathway>(path: TPath): TPathway[TPath];
126
+ /**
127
+ * Sets a handler function for a pathway
128
+ *
129
+ * This handler will be called whenever an event is received for the specified pathway.
130
+ * Only one handler can be registered per pathway in a given PathwaysBuilder instance.
131
+ *
132
+ * @template TPath The specific pathway key to handle
133
+ * @param path The pathway key to handle
134
+ * @param handler The function that will process events for this pathway
135
+ * @throws Error if the pathway doesn't exist or already has a handler
136
+ */
61
137
  handle<TPath extends keyof TPathway>(path: TPath, handler: (event: FlowcoreEvent) => (Promise<void> | void)): void;
62
138
  /**
63
139
  * Subscribe to pathway events (before or after processing)
@@ -86,6 +162,17 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
86
162
  * @returns A promise that resolves to the event ID(s)
87
163
  */
88
164
  write<TPath extends TWritablePaths>(path: TPath, data: TPathway[TPath], metadata?: EventMetadata, options?: PathwayWriteOptions): Promise<string | string[]>;
165
+ /**
166
+ * Waits for a specific event to be processed
167
+ *
168
+ * This method polls the pathway state to check if an event has been processed,
169
+ * with a configurable timeout. It will throw an error if the timeout is exceeded.
170
+ *
171
+ * @private
172
+ * @param eventId The ID of the event to wait for
173
+ * @returns Promise that resolves when the event is processed
174
+ * @throws Error if the timeout is exceeded
175
+ */
89
176
  private waitForPathwayToBeProcessed;
90
177
  }
91
178
  //# sourceMappingURL=builder.d.ts.map
@@ -1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AAM,QAAQ,EAClC,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,GACpD,IAAI;IAcP;;;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;IA4F7B;;;;;;;;;;OAUG;YACW,2BAA2B;CA4C1C"}
@@ -3,10 +3,43 @@ import { Subject } from "rxjs";
3
3
  import { WebhookBuilder } from "../compatibility/flowcore-transformer-core.sdk.js";
4
4
  import { InternalPathwayState } from "./internal-pathway.state.js";
5
5
  import { NoopLogger } from "./logger.js";
6
+ /**
7
+ * Default timeout for pathway processing in milliseconds (10 seconds)
8
+ */
6
9
  const DEFAULT_PATHWAY_TIMEOUT_MS = 10000;
10
+ /**
11
+ * Default maximum number of retry attempts for failed pathway processing
12
+ */
7
13
  const DEFAULT_MAX_RETRIES = 3;
14
+ /**
15
+ * Default delay between retry attempts in milliseconds
16
+ */
8
17
  const DEFAULT_RETRY_DELAY_MS = 500;
18
+ /**
19
+ * Main builder class for creating and managing Flowcore pathways
20
+ *
21
+ * The PathwaysBuilder provides an interface for:
22
+ * - Registering pathways with type-safe schemas
23
+ * - Handling events sent to pathways
24
+ * - Writing data to pathways
25
+ * - Managing event processing and retries
26
+ * - Observing event lifecycle (before/after/error)
27
+ * - Audit logging of pathway operations
28
+ *
29
+ * @template TPathway Record type that maps pathway keys to their payload types
30
+ * @template TWritablePaths Union type of pathway keys that can be written to
31
+ */
9
32
  export class PathwaysBuilder {
33
+ /**
34
+ * Creates a new PathwaysBuilder instance
35
+ * @param options Configuration options for the PathwaysBuilder
36
+ * @param options.baseUrl The base URL for the Flowcore API
37
+ * @param options.tenant The tenant name
38
+ * @param options.dataCore The data core name
39
+ * @param options.apiKey The API key for authentication
40
+ * @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
41
+ * @param options.logger Optional logger instance
42
+ */
10
43
  constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, }) {
11
44
  Object.defineProperty(this, "pathways", {
12
45
  enumerable: true,
@@ -147,6 +180,11 @@ export class PathwaysBuilder {
147
180
  this.pathwayTimeoutMs = pathwayTimeoutMs;
148
181
  }
149
182
  }
183
+ /**
184
+ * Configures the PathwaysBuilder to use a custom pathway state implementation
185
+ * @param state The PathwayState implementation to use
186
+ * @returns The PathwaysBuilder instance with custom state configured
187
+ */
150
188
  withPathwayState(state) {
151
189
  this.logger.debug('Setting custom pathway state');
152
190
  this.pathwayState = state;
@@ -224,10 +262,9 @@ export class PathwaysBuilder {
224
262
  catch (error) {
225
263
  // Create error object if needed
226
264
  const errorObj = error instanceof Error ? error : new Error(String(error));
227
- this.logger.error(`Error processing pathway event`, {
265
+ this.logger.error(`Error processing pathway event`, errorObj, {
228
266
  pathway: pathwayStr,
229
267
  eventId: data.eventId,
230
- error: errorObj.message,
231
268
  retryCount,
232
269
  maxRetries
233
270
  });
@@ -277,6 +314,15 @@ export class PathwaysBuilder {
277
314
  await this.pathwayState.setProcessed(data.eventId);
278
315
  }
279
316
  }
317
+ /**
318
+ * Registers a new pathway with the given contract
319
+ * @template F The flow type string
320
+ * @template E The event type string
321
+ * @template S The schema type extending TSchema
322
+ * @template W Boolean indicating if the pathway is writable (defaults to true)
323
+ * @param contract The pathway contract describing the pathway
324
+ * @returns The PathwaysBuilder instance with the new pathway registered
325
+ */
280
326
  register(contract) {
281
327
  const path = `${contract.flowType}/${contract.eventType}`;
282
328
  const writable = contract.writable ?? true;
@@ -325,10 +371,28 @@ export class PathwaysBuilder {
325
371
  });
326
372
  return this;
327
373
  }
374
+ /**
375
+ * Gets a pathway instance by its path
376
+ *
377
+ * @template TPath The specific pathway key to retrieve
378
+ * @param path The pathway key to get
379
+ * @returns The pathway instance
380
+ */
328
381
  get(path) {
329
382
  this.logger.debug(`Getting pathway`, { pathway: String(path) });
330
383
  return this.pathways[path];
331
384
  }
385
+ /**
386
+ * Sets a handler function for a pathway
387
+ *
388
+ * This handler will be called whenever an event is received for the specified pathway.
389
+ * Only one handler can be registered per pathway in a given PathwaysBuilder instance.
390
+ *
391
+ * @template TPath The specific pathway key to handle
392
+ * @param path The pathway key to handle
393
+ * @param handler The function that will process events for this pathway
394
+ * @throws Error if the pathway doesn't exist or already has a handler
395
+ */
332
396
  handle(path, handler) {
333
397
  const pathStr = String(path);
334
398
  this.logger.debug(`Setting handler for pathway`, { pathway: pathStr });
@@ -433,12 +497,12 @@ export class PathwaysBuilder {
433
497
  }
434
498
  const schema = this.schemas[path];
435
499
  if (!Value.Check(schema, data)) {
436
- const error = `Invalid data for pathway ${pathStr}`;
437
- this.logger.error(error, {
500
+ const errorMessage = `Invalid data for pathway ${pathStr}`;
501
+ this.logger.error(errorMessage, new Error(errorMessage), {
438
502
  pathway: pathStr,
439
503
  schema: schema.toString()
440
504
  });
441
- throw new Error(error);
505
+ throw new Error(errorMessage);
442
506
  }
443
507
  // Create a copy of the metadata to avoid modifying the original
444
508
  const finalMetadata = metadata ? { ...metadata } : {};
@@ -490,6 +554,17 @@ export class PathwaysBuilder {
490
554
  }
491
555
  return eventIds;
492
556
  }
557
+ /**
558
+ * Waits for a specific event to be processed
559
+ *
560
+ * This method polls the pathway state to check if an event has been processed,
561
+ * with a configurable timeout. It will throw an error if the timeout is exceeded.
562
+ *
563
+ * @private
564
+ * @param eventId The ID of the event to wait for
565
+ * @returns Promise that resolves when the event is processed
566
+ * @throws Error if the timeout is exceeded
567
+ */
493
568
  async waitForPathwayToBeProcessed(eventId) {
494
569
  const startTime = Date.now();
495
570
  const timeoutMs = this.timeouts[eventId] ?? this.pathwayTimeoutMs;
@@ -502,14 +577,14 @@ export class PathwaysBuilder {
502
577
  attempts++;
503
578
  const elapsedTime = Date.now() - startTime;
504
579
  if (elapsedTime > timeoutMs) {
505
- const error = `Pathway processing timed out after ${timeoutMs}ms for event ${eventId}`;
506
- this.logger.error(error, {
580
+ const errorMessage = `Pathway processing timed out after ${timeoutMs}ms for event ${eventId}`;
581
+ this.logger.error(errorMessage, new Error(errorMessage), {
507
582
  eventId,
508
583
  timeoutMs,
509
584
  elapsedTime,
510
585
  attempts
511
586
  });
512
- throw new Error(error);
587
+ throw new Error(errorMessage);
513
588
  }
514
589
  if (attempts % 10 === 0) { // Log every 10 attempts (1 second)
515
590
  this.logger.debug(`Still waiting for event to be processed`, {
@@ -7,6 +7,8 @@
7
7
  * - Storage adapters (KV, Postgres)
8
8
  * - Logging
9
9
  * - Type definitions
10
+ *
11
+ * @module
10
12
  */
11
13
  export * from "./builder.js";
12
14
  export * from "./internal-pathway.state.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pathways/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pathways/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
@@ -7,6 +7,8 @@
7
7
  * - Storage adapters (KV, Postgres)
8
8
  * - Logging
9
9
  * - Type definitions
10
+ *
11
+ * @module
10
12
  */
11
13
  export * from "./builder.js";
12
14
  export * from "./internal-pathway.state.js";
@@ -2,8 +2,6 @@ import type { PathwayState } from "./types.js";
2
2
  /**
3
3
  * Internal implementation of PathwayState interface that uses KV storage
4
4
  * for tracking processed events to prevent duplicate processing
5
- *
6
- * @implements {PathwayState}
7
5
  */
8
6
  export declare class InternalPathwayState implements PathwayState {
9
7
  /**
@@ -20,21 +18,21 @@ export declare class InternalPathwayState implements PathwayState {
20
18
  * Gets or initializes the KV adapter
21
19
  *
22
20
  * @private
23
- * @returns {Promise<KvAdapter>} The KV adapter instance
21
+ * @returns The KV adapter instance
24
22
  */
25
23
  private getKv;
26
24
  /**
27
25
  * Checks if an event has already been processed
28
26
  *
29
- * @param {string} eventId - The ID of the event to check
30
- * @returns {Promise<boolean>} True if the event has been processed, false otherwise
27
+ * @param eventId The ID of the event to check
28
+ * @returns True if the event has been processed, false otherwise
31
29
  */
32
30
  isProcessed(eventId: string): Promise<boolean>;
33
31
  /**
34
32
  * Marks an event as processed
35
33
  *
36
- * @param {string} eventId - The ID of the event to mark as processed
37
- * @returns {Promise<void>}
34
+ * @param eventId The ID of the event to mark as processed
35
+ * @returns Promise that resolves when the operation completes
38
36
  */
39
37
  setProcessed(eventId: string): Promise<void>;
40
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"internal-pathway.state.d.ts","sourceRoot":"","sources":["../../src/pathways/internal-pathway.state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEvD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAA0B;IAEpC;;;;;OAKG;YACW,KAAK;IAOnB;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMpD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAInD"}
1
+ {"version":3,"file":"internal-pathway.state.d.ts","sourceRoot":"","sources":["../../src/pathways/internal-pathway.state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEvD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAA0B;IAEpC;;;;;OAKG;YACW,KAAK;IAOnB;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMpD;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAInD"}
@@ -2,8 +2,6 @@ import { createKvAdapter } from "./kv/kv-adapter.js";
2
2
  /**
3
3
  * Internal implementation of PathwayState interface that uses KV storage
4
4
  * for tracking processed events to prevent duplicate processing
5
- *
6
- * @implements {PathwayState}
7
5
  */
8
6
  export class InternalPathwayState {
9
7
  constructor() {
@@ -22,7 +20,7 @@ export class InternalPathwayState {
22
20
  * Gets or initializes the KV adapter
23
21
  *
24
22
  * @private
25
- * @returns {Promise<KvAdapter>} The KV adapter instance
23
+ * @returns The KV adapter instance
26
24
  */
27
25
  async getKv() {
28
26
  if (!this.kv) {
@@ -33,8 +31,8 @@ export class InternalPathwayState {
33
31
  /**
34
32
  * Checks if an event has already been processed
35
33
  *
36
- * @param {string} eventId - The ID of the event to check
37
- * @returns {Promise<boolean>} True if the event has been processed, false otherwise
34
+ * @param eventId The ID of the event to check
35
+ * @returns True if the event has been processed, false otherwise
38
36
  */
39
37
  async isProcessed(eventId) {
40
38
  const kv = await this.getKv();
@@ -44,8 +42,8 @@ export class InternalPathwayState {
44
42
  /**
45
43
  * Marks an event as processed
46
44
  *
47
- * @param {string} eventId - The ID of the event to mark as processed
48
- * @returns {Promise<void>}
45
+ * @param eventId The ID of the event to mark as processed
46
+ * @returns Promise that resolves when the operation completes
49
47
  */
50
48
  async setProcessed(eventId) {
51
49
  const kv = await this.getKv();
@@ -3,8 +3,6 @@ import type { KvAdapter } from "./kv-adapter.js";
3
3
  * KV adapter implementation for Bun runtime
4
4
  *
5
5
  * Uses Bun's SQLite-based key-value store for storage
6
- *
7
- * @implements {KvAdapter}
8
6
  */
9
7
  export declare class BunKvAdapter implements KvAdapter {
10
8
  /**
@@ -20,16 +18,16 @@ export declare class BunKvAdapter implements KvAdapter {
20
18
  * Retrieves a value from the Bun KV store
21
19
  *
22
20
  * @template T The expected type of the stored value
23
- * @param {string} key The key to retrieve
24
- * @returns {T | null} The stored value or null if not found
21
+ * @param key The key to retrieve
22
+ * @returns The stored value or null if not found
25
23
  */
26
24
  get<T>(key: string): T | null;
27
25
  /**
28
26
  * Stores a value in the Bun KV store with the specified TTL
29
27
  *
30
- * @param {string} key The key to store the value under
31
- * @param {unknown} value The value to store
32
- * @param {number} ttlMs Time-to-live in milliseconds
28
+ * @param key The key to store the value under
29
+ * @param value The value to store
30
+ * @param ttlMs Time-to-live in milliseconds
33
31
  */
34
32
  set(key: string, value: unknown, ttlMs: number): void;
35
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bun-kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/bun-kv-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAoB;IAEjC;;OAEG;;IAKH;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAK7B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAGtD"}
1
+ {"version":3,"file":"bun-kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/bun-kv-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAoB;IAEjC;;OAEG;;IAKH;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAK7B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAGtD"}
@@ -3,8 +3,6 @@ import { BunSqliteKeyValue } from "bun-sqlite-key-value";
3
3
  * KV adapter implementation for Bun runtime
4
4
  *
5
5
  * Uses Bun's SQLite-based key-value store for storage
6
- *
7
- * @implements {KvAdapter}
8
6
  */
9
7
  export class BunKvAdapter {
10
8
  /**
@@ -27,8 +25,8 @@ export class BunKvAdapter {
27
25
  * Retrieves a value from the Bun KV store
28
26
  *
29
27
  * @template T The expected type of the stored value
30
- * @param {string} key The key to retrieve
31
- * @returns {T | null} The stored value or null if not found
28
+ * @param key The key to retrieve
29
+ * @returns The stored value or null if not found
32
30
  */
33
31
  get(key) {
34
32
  const value = this.store.get(key);
@@ -37,9 +35,9 @@ export class BunKvAdapter {
37
35
  /**
38
36
  * Stores a value in the Bun KV store with the specified TTL
39
37
  *
40
- * @param {string} key The key to store the value under
41
- * @param {unknown} value The value to store
42
- * @param {number} ttlMs Time-to-live in milliseconds
38
+ * @param key The key to store the value under
39
+ * @param value The value to store
40
+ * @param ttlMs Time-to-live in milliseconds
43
41
  */
44
42
  set(key, value, ttlMs) {
45
43
  this.store.set(key, value, ttlMs);