@flowcore/pathways 0.2.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 (113) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +420 -0
  3. package/esm/common/flowcore.type.d.ts +11 -0
  4. package/esm/common/flowcore.type.d.ts.map +1 -0
  5. package/esm/common/flowcore.type.js +1 -0
  6. package/esm/common/index.d.ts +7 -0
  7. package/esm/common/index.d.ts.map +1 -0
  8. package/esm/common/index.js +6 -0
  9. package/esm/compatibility/flowcore-transformer-core.sdk.d.ts +16 -0
  10. package/esm/compatibility/flowcore-transformer-core.sdk.d.ts.map +1 -0
  11. package/esm/compatibility/flowcore-transformer-core.sdk.js +11 -0
  12. package/esm/contracts/event.d.ts +20 -0
  13. package/esm/contracts/event.d.ts.map +1 -0
  14. package/esm/contracts/event.js +15 -0
  15. package/esm/contracts/index.d.ts +5 -0
  16. package/esm/contracts/index.d.ts.map +1 -0
  17. package/esm/contracts/index.js +4 -0
  18. package/esm/mod.d.ts +14 -0
  19. package/esm/mod.d.ts.map +1 -0
  20. package/esm/mod.js +13 -0
  21. package/esm/package.json +3 -0
  22. package/esm/pathways/builder.d.ts +91 -0
  23. package/esm/pathways/builder.d.ts.map +1 -0
  24. package/esm/pathways/builder.js +530 -0
  25. package/esm/pathways/index.d.ts +17 -0
  26. package/esm/pathways/index.d.ts.map +1 -0
  27. package/esm/pathways/index.js +16 -0
  28. package/esm/pathways/internal-pathway.state.d.ts +41 -0
  29. package/esm/pathways/internal-pathway.state.d.ts.map +1 -0
  30. package/esm/pathways/internal-pathway.state.js +64 -0
  31. package/esm/pathways/kv/bun-kv-adapter.d.ts +36 -0
  32. package/esm/pathways/kv/bun-kv-adapter.d.ts.map +1 -0
  33. package/esm/pathways/kv/bun-kv-adapter.js +47 -0
  34. package/esm/pathways/kv/kv-adapter.d.ts +34 -0
  35. package/esm/pathways/kv/kv-adapter.d.ts.map +1 -0
  36. package/esm/pathways/kv/kv-adapter.js +19 -0
  37. package/esm/pathways/kv/node-kv-adapter.d.ts +33 -0
  38. package/esm/pathways/kv/node-kv-adapter.d.ts.map +1 -0
  39. package/esm/pathways/kv/node-kv-adapter.js +44 -0
  40. package/esm/pathways/logger.d.ts +48 -0
  41. package/esm/pathways/logger.d.ts.map +1 -0
  42. package/esm/pathways/logger.js +26 -0
  43. package/esm/pathways/postgres/index.d.ts +9 -0
  44. package/esm/pathways/postgres/index.d.ts.map +1 -0
  45. package/esm/pathways/postgres/index.js +8 -0
  46. package/esm/pathways/postgres/postgres-adapter.d.ts +112 -0
  47. package/esm/pathways/postgres/postgres-adapter.d.ts.map +1 -0
  48. package/esm/pathways/postgres/postgres-adapter.js +113 -0
  49. package/esm/pathways/postgres/postgres-pathway-state.d.ts +113 -0
  50. package/esm/pathways/postgres/postgres-pathway-state.d.ts.map +1 -0
  51. package/esm/pathways/postgres/postgres-pathway-state.js +188 -0
  52. package/esm/pathways/types.d.ts +87 -0
  53. package/esm/pathways/types.d.ts.map +1 -0
  54. package/esm/pathways/types.js +1 -0
  55. package/esm/router/index.d.ts +35 -0
  56. package/esm/router/index.d.ts.map +1 -0
  57. package/esm/router/index.js +96 -0
  58. package/package.json +38 -0
  59. package/script/common/flowcore.type.d.ts +11 -0
  60. package/script/common/flowcore.type.d.ts.map +1 -0
  61. package/script/common/flowcore.type.js +2 -0
  62. package/script/common/index.d.ts +7 -0
  63. package/script/common/index.d.ts.map +1 -0
  64. package/script/common/index.js +22 -0
  65. package/script/compatibility/flowcore-transformer-core.sdk.d.ts +16 -0
  66. package/script/compatibility/flowcore-transformer-core.sdk.d.ts.map +1 -0
  67. package/script/compatibility/flowcore-transformer-core.sdk.js +17 -0
  68. package/script/contracts/event.d.ts +20 -0
  69. package/script/contracts/event.d.ts.map +1 -0
  70. package/script/contracts/event.js +18 -0
  71. package/script/contracts/index.d.ts +5 -0
  72. package/script/contracts/index.d.ts.map +1 -0
  73. package/script/contracts/index.js +20 -0
  74. package/script/mod.d.ts +14 -0
  75. package/script/mod.d.ts.map +1 -0
  76. package/script/mod.js +29 -0
  77. package/script/package.json +3 -0
  78. package/script/pathways/builder.d.ts +91 -0
  79. package/script/pathways/builder.d.ts.map +1 -0
  80. package/script/pathways/builder.js +534 -0
  81. package/script/pathways/index.d.ts +17 -0
  82. package/script/pathways/index.d.ts.map +1 -0
  83. package/script/pathways/index.js +32 -0
  84. package/script/pathways/internal-pathway.state.d.ts +41 -0
  85. package/script/pathways/internal-pathway.state.d.ts.map +1 -0
  86. package/script/pathways/internal-pathway.state.js +68 -0
  87. package/script/pathways/kv/bun-kv-adapter.d.ts +36 -0
  88. package/script/pathways/kv/bun-kv-adapter.d.ts.map +1 -0
  89. package/script/pathways/kv/bun-kv-adapter.js +51 -0
  90. package/script/pathways/kv/kv-adapter.d.ts +34 -0
  91. package/script/pathways/kv/kv-adapter.d.ts.map +1 -0
  92. package/script/pathways/kv/kv-adapter.js +45 -0
  93. package/script/pathways/kv/node-kv-adapter.d.ts +33 -0
  94. package/script/pathways/kv/node-kv-adapter.d.ts.map +1 -0
  95. package/script/pathways/kv/node-kv-adapter.js +51 -0
  96. package/script/pathways/logger.d.ts +48 -0
  97. package/script/pathways/logger.d.ts.map +1 -0
  98. package/script/pathways/logger.js +31 -0
  99. package/script/pathways/postgres/index.d.ts +9 -0
  100. package/script/pathways/postgres/index.d.ts.map +1 -0
  101. package/script/pathways/postgres/index.js +24 -0
  102. package/script/pathways/postgres/postgres-adapter.d.ts +112 -0
  103. package/script/pathways/postgres/postgres-adapter.d.ts.map +1 -0
  104. package/script/pathways/postgres/postgres-adapter.js +141 -0
  105. package/script/pathways/postgres/postgres-pathway-state.d.ts +113 -0
  106. package/script/pathways/postgres/postgres-pathway-state.d.ts.map +1 -0
  107. package/script/pathways/postgres/postgres-pathway-state.js +193 -0
  108. package/script/pathways/types.d.ts +87 -0
  109. package/script/pathways/types.d.ts.map +1 -0
  110. package/script/pathways/types.js +2 -0
  111. package/script/router/index.d.ts +35 -0
  112. package/script/router/index.d.ts.map +1 -0
  113. package/script/router/index.js +100 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ ## [0.2.1](https://github.com/flowcore-io/flowcore-pathways/compare/v0.2.0...v0.2.1) (2025-03-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **dependencies:** :art: Update package versions in deno.lock and import statements ([e47298e](https://github.com/flowcore-io/flowcore-pathways/commit/e47298e565743ebc7381d7d9683ddc7f33b98bf0))
9
+
10
+ ## [0.2.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.1.0...v0.2.0) (2025-03-15)
11
+
12
+
13
+ ### Features
14
+
15
+ * :sparkles: Add support for file-based pathways and multi-event writes ([e9d9bcc](https://github.com/flowcore-io/flowcore-pathways/commit/e9d9bcc8d4f6ff8959f99760c736671ba422e4a5))
16
+ * :sparkles: Allow non-async pathway handlers in PathwaysBuilder ([4313e63](https://github.com/flowcore-io/flowcore-pathways/commit/4313e635c04a6bd9a395f9df782482a0c18d0f37))
17
+ * :sparkles: Enhance PathwaysBuilder with improved type safety and writable pathway support ([a2c1c36](https://github.com/flowcore-io/flowcore-pathways/commit/a2c1c36aa5537be2aeec9b8e7bb744ed9a1243a8))
18
+ * :sparkles: Initialize core Flowcore Pathways library with essential components ([dfa32f1](https://github.com/flowcore-io/flowcore-pathways/commit/dfa32f1601b1c6851d87fb749fd9688b13fe398e))
19
+ * Add pathway state management with key-value storage support ([c717a2e](https://github.com/flowcore-io/flowcore-pathways/commit/c717a2e3757445cfb52b580c0ca67c746a16a622))
20
+ * **pathways:** :sparkles: Add audit functionality to PathwaysBuilder ([bdc68fe](https://github.com/flowcore-io/flowcore-pathways/commit/bdc68fe36d49c8b1827d63ee686f15afd76769bb))
21
+ * **pathways:** :sparkles: Implement error handling and retry mechanism in PathwaysBuilder ([5300036](https://github.com/flowcore-io/flowcore-pathways/commit/5300036370ce573a06dac65fc5b0fdf1ee9f3ffd))
22
+ * **pathways:** :sparkles: Introduce logging functionality in PathwaysBuilder ([9cef56a](https://github.com/flowcore-io/flowcore-pathways/commit/9cef56a8111336d2cfd26e72edbc01784cc0ef1a))
23
+ * **postgres:** :sparkles: Integrate PostgreSQL support for pathway state management ([710ab3f](https://github.com/flowcore-io/flowcore-pathways/commit/710ab3f24e4865f5259f773a73cbae12fe3f8795))
24
+ * **router:** :sparkles: Add secret key validation for PathwayRouter ([3a6a70a](https://github.com/flowcore-io/flowcore-pathways/commit/3a6a70a194ac8589ea6cc56cae741f2902befcf0))
25
+ * **tests:** :sparkles: Add comprehensive tests for pathways and router functionality ([ae032fd](https://github.com/flowcore-io/flowcore-pathways/commit/ae032fdec6c2f9c58c95dd1153c951d0d9915b2c))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **deno.json:** :art: Update test commands to remove unstable flag ([7fb6dd2](https://github.com/flowcore-io/flowcore-pathways/commit/7fb6dd22e4cf7f778725fb53a84b0f3ab222fa0a))
31
+ * **deno.lock:** :wrench: Fixed the npm building by updating the imports to be consisten ([5700b20](https://github.com/flowcore-io/flowcore-pathways/commit/5700b20ee2b93dca88ce3d4cc3d826ffe6db2cc4))
32
+ * **readme:** :fire: Remove Example Projects section from README ([bd27270](https://github.com/flowcore-io/flowcore-pathways/commit/bd27270ae0f80c46074def5ef3a08410677ebb68))
33
+ * **readme:** :memo: Update library description and installation instructions in README ([cbd3d33](https://github.com/flowcore-io/flowcore-pathways/commit/cbd3d330a8e6809c9cbb1bc8582598d3cd1992d5))
34
+ * **readme:** :memo: Update README with detailed usage examples and core concepts ([5e26e9b](https://github.com/flowcore-io/flowcore-pathways/commit/5e26e9b8f2b06c56e0c65dbce09d6c7e2fe36edd))
35
+ * **router:** :bug: Improve error handling in PathwayRouter processing ([56a00eb](https://github.com/flowcore-io/flowcore-pathways/commit/56a00eb9c9d8b056b40398eb40c213fd876e4226))
36
+ * **router:** :bug: Update processEvent method to include return type ([af5b821](https://github.com/flowcore-io/flowcore-pathways/commit/af5b821187404d72c1566f2ebdb9c7fbcbb0bb3b))
package/README.md ADDED
@@ -0,0 +1,420 @@
1
+ # Flowcore Pathways
2
+
3
+ A TypeScript Library for creating Flowcore Pathways, simplifying the integration with the Flowcore platform. Flowcore Pathways helps you build event-driven applications with type-safe pathways for processing and producing events.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Getting Started](#getting-started)
9
+ - [Core Concepts](#core-concepts)
10
+ - [Usage](#usage)
11
+ - [Creating a Pathways Builder](#creating-a-pathways-builder)
12
+ - [Registering Pathways](#registering-pathways)
13
+ - [Handling Events](#handling-events)
14
+ - [Writing Events](#writing-events)
15
+ - [Error Handling](#error-handling)
16
+ - [Event Observability](#event-observability)
17
+ - [Setting up a Router](#setting-up-a-router)
18
+ - [HTTP Server Integration](#http-server-integration)
19
+ - [Persistence Options](#persistence-options)
20
+ - [Advanced Usage](#advanced-usage)
21
+ - [Auditing](#auditing)
22
+ - [Custom Loggers](#custom-loggers)
23
+ - [Retry Mechanisms](#retry-mechanisms)
24
+ - [API Reference](#api-reference)
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Bun
30
+ bunx jsr add @flowcore/pathways
31
+
32
+ # Deno
33
+ deno add jsr:@flowcore/pathways
34
+
35
+ # npm / yarn
36
+ npx jsr add @flowcore/pathways
37
+ ```
38
+
39
+ or using npm:
40
+
41
+ ```bash
42
+ npm install @flowcore/pathways
43
+ ```
44
+
45
+ or using yarn:
46
+
47
+ ```bash
48
+ yarn add @flowcore/pathways
49
+ ```
50
+
51
+ ## Getting Started
52
+
53
+ Here's a basic example to get you started with Flowcore Pathways:
54
+
55
+ ```typescript
56
+ import { Type } from "@sinclair/typebox";
57
+ import { PathwaysBuilder } from "@flowcore/pathways";
58
+
59
+ // Define your event schema
60
+ const userSchema = Type.Object({
61
+ id: Type.String(),
62
+ name: Type.String(),
63
+ email: Type.String()
64
+ });
65
+
66
+ // Create a pathways builder
67
+ const pathways = new PathwaysBuilder({
68
+ baseUrl: "https://api.flowcore.io",
69
+ tenant: "your-tenant",
70
+ dataCore: "your-data-core",
71
+ apiKey: "your-api-key"
72
+ });
73
+
74
+ // Register a pathway
75
+ pathways
76
+ .register({
77
+ flowType: "user",
78
+ eventType: "created",
79
+ schema: userSchema
80
+ })
81
+ .handle("user/created", async (event) => {
82
+ console.log(`Processing user created event: ${event.eventId}`);
83
+ console.log(`User data:`, event.payload);
84
+
85
+ // Process the event...
86
+
87
+ // You can write to another pathway if needed
88
+ await pathways.write("notifications/sent", {
89
+ userId: event.payload.id,
90
+ message: `Welcome ${event.payload.name}!`,
91
+ channel: "email"
92
+ });
93
+ });
94
+ ```
95
+
96
+ ## Core Concepts
97
+
98
+ Flowcore Pathways is built around these core concepts:
99
+
100
+ - **PathwaysBuilder**: The main entry point for creating and managing pathways
101
+ - **Pathways**: Define event flows with schemas for type safety
102
+ - **Handlers**: Process incoming events
103
+ - **Writers**: Send events to pathways
104
+ - **Router**: Direct incoming events to the appropriate pathway
105
+ - **Persistence**: Store pathway state for reliable processing
106
+
107
+ ## Usage
108
+
109
+ ### Creating a Pathways Builder
110
+
111
+ The `PathwaysBuilder` is the main configuration point for your pathways:
112
+
113
+ ```typescript
114
+ import { PathwaysBuilder } from "@flowcore/pathways";
115
+
116
+ const pathways = new PathwaysBuilder({
117
+ baseUrl: "https://api.flowcore.io",
118
+ tenant: "your-tenant",
119
+ dataCore: "your-data-core",
120
+ apiKey: "your-api-key",
121
+ pathwayTimeoutMs: 10000, // Optional, default is 10000 (10s)
122
+ logger: customLogger // Optional, defaults to NoopLogger
123
+ });
124
+ ```
125
+
126
+ ### Registering Pathways
127
+
128
+ Register pathways with their schemas for type-safe event handling:
129
+
130
+ ```typescript
131
+ import { Type } from "@sinclair/typebox";
132
+
133
+ // Define your event schema
134
+ const orderSchema = Type.Object({
135
+ orderId: Type.String(),
136
+ userId: Type.String(),
137
+ total: Type.Number(),
138
+ items: Type.Array(
139
+ Type.Object({
140
+ id: Type.String(),
141
+ quantity: Type.Number()
142
+ })
143
+ )
144
+ });
145
+
146
+ // Register pathway
147
+ pathways.register({
148
+ flowType: "order",
149
+ eventType: "placed",
150
+ schema: orderSchema,
151
+ writable: true, // Optional, default is true
152
+ maxRetries: 3, // Optional, default is 3
153
+ retryDelayMs: 500 // Optional, default is 500
154
+ });
155
+ ```
156
+
157
+ ### Handling Events
158
+
159
+ Set up handlers to process events for specific pathways:
160
+
161
+ ```typescript
162
+ const pathwayKey = "order/placed";
163
+
164
+ pathways.handle(pathwayKey, async (event) => {
165
+ console.log(`Processing order ${event.payload.orderId}`);
166
+
167
+ // Access typed payload data
168
+ const { userId, total, items } = event.payload;
169
+
170
+ // Your business logic here
171
+ await updateInventory(items);
172
+ await notifyUser(userId, total);
173
+ });
174
+ ```
175
+
176
+ ### Writing Events
177
+
178
+ Send events to pathways:
179
+
180
+ ```typescript
181
+ // Basic write
182
+ const eventId = await pathways.write("order/placed", {
183
+ orderId: "ord-123",
184
+ userId: "user-456",
185
+ total: 99.99,
186
+ items: [
187
+ { id: "item-1", quantity: 2 }
188
+ ]
189
+ });
190
+
191
+ // Write with metadata
192
+ const eventId2 = await pathways.write(
193
+ "order/placed",
194
+ orderData,
195
+ {
196
+ correlationId: "corr-789",
197
+ source: "checkout-service"
198
+ }
199
+ );
200
+
201
+ // Fire-and-forget mode (doesn't wait for processing)
202
+ const eventId3 = await pathways.write(
203
+ "order/placed",
204
+ orderData,
205
+ undefined,
206
+ { fireAndForget: true }
207
+ );
208
+ ```
209
+
210
+ ### Error Handling
211
+
212
+ Handle errors in pathway processing:
213
+
214
+ ```typescript
215
+ // Error handler for a specific pathway
216
+ pathways.onError("order/placed", (error, event) => {
217
+ console.error(`Error processing order ${event.payload.orderId}:`, error);
218
+ reportToMonitoring(error, event);
219
+ });
220
+
221
+ // Global error handler for all pathways
222
+ pathways.onAnyError((error, event, pathway) => {
223
+ console.error(`Error in pathway ${pathway}:`, error);
224
+ reportToMonitoring(error, event, pathway);
225
+ });
226
+ ```
227
+
228
+ ### Event Observability
229
+
230
+ Subscribe to events for observability at different stages:
231
+
232
+ ```typescript
233
+ // Before processing
234
+ pathways.subscribe("order/placed", (event) => {
235
+ console.log(`About to process order ${event.payload.orderId}`);
236
+ }, "before");
237
+
238
+ // After processing
239
+ pathways.subscribe("order/placed", (event) => {
240
+ console.log(`Finished processing order ${event.payload.orderId}`);
241
+ }, "after");
242
+
243
+ // At both stages
244
+ pathways.subscribe("order/placed", (event) => {
245
+ console.log(`Event ${event.eventId} at ${new Date().toISOString()}`);
246
+ }, "all");
247
+ ```
248
+
249
+ ### Setting up a Router
250
+
251
+ The `PathwayRouter` routes incoming events to the appropriate pathway:
252
+
253
+ ```typescript
254
+ import { PathwayRouter } from "@flowcore/pathways";
255
+
256
+ // Create a router with a secret key for validation
257
+ const WEBHOOK_SECRET = "your-webhook-secret";
258
+ const router = new PathwayRouter(pathways, WEBHOOK_SECRET);
259
+
260
+ // Process an incoming event from a webhook
261
+ async function handleWebhook(req: Request) {
262
+ const event = await req.json();
263
+ const secret = req.headers.get("X-Webhook-Secret");
264
+
265
+ try {
266
+ // This validates the secret and routes to the right pathway
267
+ await router.processEvent(event, secret);
268
+ return new Response("Event processed", { status: 200 });
269
+ } catch (error) {
270
+ console.error("Error processing event:", error);
271
+ return new Response("Error processing event", { status: 500 });
272
+ }
273
+ }
274
+ ```
275
+
276
+ ### HTTP Server Integration
277
+
278
+ Integrate with Deno's HTTP server:
279
+
280
+ ```typescript
281
+ import { serve } from "https://deno.land/std/http/server.ts";
282
+
283
+ serve(async (req: Request) => {
284
+ const url = new URL(req.url);
285
+
286
+ if (req.method === "POST" && url.pathname === "/webhook") {
287
+ return handleWebhook(req);
288
+ }
289
+
290
+ return new Response("Not found", { status: 404 });
291
+ }, { port: 3000 });
292
+ ```
293
+
294
+ ### Persistence Options
295
+
296
+ Flowcore Pathways supports different persistence options to track processed events and ensure exactly-once processing.
297
+
298
+ #### Default In-Memory KV Store (Development)
299
+
300
+ By default, Flowcore Pathways uses an internal in-memory KV store for persistence:
301
+
302
+ ```typescript
303
+ // The default persistence is used automatically, no explicit setup required
304
+ const pathways = new PathwaysBuilder({
305
+ baseUrl: "https://api.flowcore.io",
306
+ tenant: "your-tenant",
307
+ dataCore: "your-data-core",
308
+ apiKey: "your-api-key"
309
+ });
310
+ ```
311
+
312
+ The internal store uses the appropriate KV adapter for your environment (Bun, Node, or Deno), but note that this state is not persistent across application restarts and should be used primarily for development.
313
+
314
+ #### PostgreSQL Persistence (Production)
315
+
316
+ For production environments, you can use PostgreSQL for reliable and scalable persistence:
317
+
318
+ ```typescript
319
+ import { PostgresPathwayState, createPostgresPathwayState } from "@flowcore/pathways";
320
+
321
+ // Create a PostgreSQL state handler
322
+ const postgresState = createPostgresPathwayState({
323
+ host: "localhost",
324
+ port: 5432,
325
+ user: "postgres",
326
+ password: "postgres",
327
+ database: "pathway_db",
328
+ tableName: "pathway_state", // Optional, defaults to "pathway_state"
329
+ ttlMs: 300000, // Optional, defaults to 5 minutes (300000ms)
330
+ ssl: false // Optional, defaults to false
331
+ });
332
+
333
+ // Use PostgreSQL for pathway state
334
+ pathways.withPathwayState(postgresState);
335
+ ```
336
+
337
+ The PostgreSQL implementation:
338
+
339
+ - Automatically creates the necessary table if it doesn't exist
340
+ - Includes TTL-based automatic cleanup of processed events
341
+ - Creates appropriate indexes for performance
342
+
343
+ ## Advanced Usage
344
+
345
+ ### Auditing
346
+
347
+ Enable auditing to track events:
348
+
349
+ ```typescript
350
+ // Set up auditing
351
+ pathways.withAudit(
352
+ // Audit handler
353
+ (path, event) => {
354
+ console.log(`Audit: ${path} event ${event.eventId}`);
355
+ logToAuditSystem(path, event);
356
+ },
357
+ // User ID resolver
358
+ async () => {
359
+ // Get the current user ID from context
360
+ return getCurrentUserId();
361
+ }
362
+ );
363
+ ```
364
+
365
+ ### Custom Loggers
366
+
367
+ Create a custom logger:
368
+
369
+ ```typescript
370
+ import { Logger } from "@flowcore/pathways";
371
+
372
+ class MyCustomLogger implements Logger {
373
+ debug(message: string, context?: Record<string, unknown>): void {
374
+ console.debug(`[DEBUG] ${message}`, context);
375
+ }
376
+
377
+ info(message: string, context?: Record<string, unknown>): void {
378
+ console.info(`[INFO] ${message}`, context);
379
+ }
380
+
381
+ warn(message: string, context?: Record<string, unknown>): void {
382
+ console.warn(`[WARN] ${message}`, context);
383
+ }
384
+
385
+ error(message: string, error?: Error, context?: Record<string, unknown>): void {
386
+ console.error(`[ERROR] ${message}`, error, context);
387
+ }
388
+ }
389
+
390
+ // Use custom logger
391
+ const pathways = new PathwaysBuilder({
392
+ // ...other config
393
+ logger: new MyCustomLogger()
394
+ });
395
+ ```
396
+
397
+ ### Retry Mechanisms
398
+
399
+ Configure retry behavior for pathways:
400
+
401
+ ```typescript
402
+ // Global timeout for pathway processing
403
+ const pathways = new PathwaysBuilder({
404
+ // ...other config
405
+ pathwayTimeoutMs: 15000 // 15 seconds
406
+ });
407
+
408
+ // Per-pathway retry configuration
409
+ pathways.register({
410
+ flowType: "payment",
411
+ eventType: "process",
412
+ schema: paymentSchema,
413
+ maxRetries: 5, // Retry up to 5 times
414
+ retryDelayMs: 1000 // 1 second between retries
415
+ });
416
+ ```
417
+
418
+ ## API Reference
419
+
420
+ For a complete API reference, please see the [API documentation](https://jsr.io/@flowcore/pathways).
@@ -0,0 +1,11 @@
1
+ import type { FlowcoreEvent } from "../contracts/event.js";
2
+ /**
3
+ * Extends the FlowcoreEvent with legacy fields
4
+ *
5
+ * @typedef {Object} FlowcoreLegacyEvent
6
+ * @property {string} [aggregator] - Optional aggregator information for legacy support
7
+ */
8
+ export type FlowcoreLegacyEvent = FlowcoreEvent & {
9
+ aggregator?: string;
10
+ };
11
+ //# sourceMappingURL=flowcore.type.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Common types and utilities for Flowcore Pathways
3
+ *
4
+ * This module exports common types and utilities that are used across the Flowcore Pathways library.
5
+ */
6
+ export * from "./flowcore.type.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Common types and utilities for Flowcore Pathways
3
+ *
4
+ * This module exports common types and utilities that are used across the Flowcore Pathways library.
5
+ */
6
+ export * from "./flowcore.type.js";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Compatibility layer for the Flowcore Transformer Core SDK
3
+ *
4
+ * This module re-exports components from the @flowcore/sdk-transformer-core package
5
+ * to provide backwards compatibility with existing transformer implementations.
6
+ */
7
+ import transformerCore from "@flowcore/sdk-transformer-core";
8
+ /**
9
+ * WebhookBuilder from the transformer core SDK for sending webhook events
10
+ */
11
+ export declare const WebhookBuilder: typeof transformerCore.WebhookBuilder;
12
+ /**
13
+ * Options for configuring webhook send operations
14
+ */
15
+ export type { WebhookSendOptions } from "@flowcore/sdk-transformer-core";
16
+ //# sourceMappingURL=flowcore-transformer-core.sdk.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Compatibility layer for the Flowcore Transformer Core SDK
3
+ *
4
+ * This module re-exports components from the @flowcore/sdk-transformer-core package
5
+ * to provide backwards compatibility with existing transformer implementations.
6
+ */
7
+ import transformerCore from "@flowcore/sdk-transformer-core";
8
+ /**
9
+ * WebhookBuilder from the transformer core SDK for sending webhook events
10
+ */
11
+ export const { WebhookBuilder } = transformerCore;
@@ -0,0 +1,20 @@
1
+ import { type Static, type TObject, type TRecord, type TString, type TUnknown } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for an event
4
+ */
5
+ export declare const FlowcoreEventSchema: TObject<{
6
+ eventId: TString;
7
+ timeBucket: TString;
8
+ tenant: TString;
9
+ dataCoreId: TString;
10
+ flowType: TString;
11
+ eventType: TString;
12
+ metadata: TRecord<TString, TUnknown>;
13
+ payload: TRecord<TString, TUnknown>;
14
+ validTime: TString;
15
+ }>;
16
+ /**
17
+ * The type for an event
18
+ */
19
+ export type FlowcoreEvent = Static<typeof FlowcoreEventSchema>;
20
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/contracts/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAQ,MAAM,mBAAmB,CAAA;AAE9G;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACpC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACnC,SAAS,EAAE,OAAO,CAAA;CACnB,CAUC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for an event
4
+ */
5
+ export const FlowcoreEventSchema = Type.Object({
6
+ eventId: Type.String(),
7
+ timeBucket: Type.String(),
8
+ tenant: Type.String(),
9
+ dataCoreId: Type.String(),
10
+ flowType: Type.String(),
11
+ eventType: Type.String(),
12
+ metadata: Type.Record(Type.String(), Type.Unknown()),
13
+ payload: Type.Record(Type.String(), Type.Unknown()),
14
+ validTime: Type.String(),
15
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Export all contract types and schemas for Flowcore events
3
+ */
4
+ export * from "./event.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Export all contract types and schemas for Flowcore events
3
+ */
4
+ export * from "./event.js";
package/esm/mod.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Main export module for Flowcore Pathways
3
+ *
4
+ * This module re-exports all the components needed to work with Flowcore Pathways:
5
+ * - Common types and utilities
6
+ * - Event contracts and schemas
7
+ * - Pathway definitions and builders
8
+ * - Event routing functionality
9
+ */
10
+ export * from "./common/index.js";
11
+ export * from "./contracts/index.js";
12
+ export * from "./pathways/index.js";
13
+ export * from "./router/index.js";
14
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +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"}
package/esm/mod.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Main export module for Flowcore Pathways
3
+ *
4
+ * This module re-exports all the components needed to work with Flowcore Pathways:
5
+ * - Common types and utilities
6
+ * - Event contracts and schemas
7
+ * - Pathway definitions and builders
8
+ * - Event routing functionality
9
+ */
10
+ export * from "./common/index.js";
11
+ export * from "./contracts/index.js";
12
+ export * from "./pathways/index.js";
13
+ export * from "./router/index.js";
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }