@flowcore/pathways 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -58
- package/README.md +128 -124
- package/esm/common/index.d.ts.map +1 -1
- package/esm/contracts/index.d.ts.map +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/pathways/builder.d.ts +56 -4
- package/esm/pathways/builder.d.ts.map +1 -1
- package/esm/pathways/builder.js +59 -4
- package/esm/pathways/index.d.ts.map +1 -1
- package/esm/pathways/internal-pathway.state.d.ts.map +1 -1
- package/esm/pathways/kv/bun-kv-adapter.d.ts.map +1 -1
- package/esm/pathways/kv/kv-adapter.d.ts +2 -2
- package/esm/pathways/kv/kv-adapter.d.ts.map +1 -1
- package/esm/pathways/kv/node-kv-adapter.d.ts.map +1 -1
- package/esm/pathways/kv/node-kv-adapter.js +1 -1
- package/esm/pathways/logger.js +7 -7
- package/esm/pathways/postgres/index.d.ts.map +1 -1
- package/esm/pathways/postgres/postgres-adapter.d.ts.map +1 -1
- package/esm/pathways/postgres/postgres-adapter.js +3 -2
- package/esm/pathways/session-pathway.d.ts.map +1 -1
- package/esm/pathways/session-pathway.js +3 -3
- package/esm/router/index.d.ts.map +1 -1
- package/esm/router/index.js +4 -4
- package/package.json +1 -1
- package/script/common/index.d.ts.map +1 -1
- package/script/contracts/index.d.ts.map +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/pathways/builder.d.ts +56 -4
- package/script/pathways/builder.d.ts.map +1 -1
- package/script/pathways/builder.js +61 -5
- package/script/pathways/index.d.ts.map +1 -1
- package/script/pathways/internal-pathway.state.d.ts.map +1 -1
- package/script/pathways/kv/bun-kv-adapter.d.ts.map +1 -1
- package/script/pathways/kv/kv-adapter.d.ts +2 -2
- package/script/pathways/kv/kv-adapter.d.ts.map +1 -1
- package/script/pathways/kv/node-kv-adapter.d.ts.map +1 -1
- package/script/pathways/kv/node-kv-adapter.js +1 -1
- package/script/pathways/logger.js +7 -7
- package/script/pathways/postgres/index.d.ts.map +1 -1
- package/script/pathways/postgres/postgres-adapter.d.ts.map +1 -1
- package/script/pathways/postgres/postgres-adapter.js +3 -2
- package/script/pathways/session-pathway.d.ts.map +1 -1
- package/script/pathways/session-pathway.js +3 -3
- package/script/router/index.d.ts.map +1 -1
- package/script/router/index.js +4 -4
|
@@ -14,7 +14,7 @@ class ConsoleLogger {
|
|
|
14
14
|
* @param context Optional context data to include
|
|
15
15
|
*/
|
|
16
16
|
debug(message, context) {
|
|
17
|
-
console.debug(message, context ? JSON.stringify(context) :
|
|
17
|
+
console.debug(message, context ? JSON.stringify(context) : "");
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Log informational messages to the console
|
|
@@ -22,7 +22,7 @@ class ConsoleLogger {
|
|
|
22
22
|
* @param context Optional context data to include
|
|
23
23
|
*/
|
|
24
24
|
info(message, context) {
|
|
25
|
-
console.info(message, context ? JSON.stringify(context) :
|
|
25
|
+
console.info(message, context ? JSON.stringify(context) : "");
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Log warning messages to the console
|
|
@@ -30,7 +30,7 @@ class ConsoleLogger {
|
|
|
30
30
|
* @param context Optional context data to include
|
|
31
31
|
*/
|
|
32
32
|
warn(message, context) {
|
|
33
|
-
console.warn(message, context ? JSON.stringify(context) :
|
|
33
|
+
console.warn(message, context ? JSON.stringify(context) : "");
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Log error messages to the console
|
|
@@ -43,19 +43,19 @@ class ConsoleLogger {
|
|
|
43
43
|
* @param context Optional context data (only for signature 1)
|
|
44
44
|
*/
|
|
45
45
|
error(messageOrError, errorOrContext, context) {
|
|
46
|
-
if (typeof messageOrError ===
|
|
46
|
+
if (typeof messageOrError === "string") {
|
|
47
47
|
if (errorOrContext instanceof Error) {
|
|
48
48
|
// Signature 1: error(message: string, error: Error, context?: LoggerMeta)
|
|
49
|
-
console.error(messageOrError, errorOrContext, context ? JSON.stringify(context) :
|
|
49
|
+
console.error(messageOrError, errorOrContext, context ? JSON.stringify(context) : "");
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
// Signature 1 (no error) or Signature 2: error(message: string, context?: LoggerMeta)
|
|
53
|
-
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) :
|
|
53
|
+
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) : "");
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
57
|
// Signature 2: error(error: Error, context?: LoggerMeta)
|
|
58
|
-
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) :
|
|
58
|
+
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) : "");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAA;IAExB,yEAAyE;IACzE,IAAI,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AA8B;IACzC,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,yDAAyD;IACzD,OAAO,CAAC,gBAAgB,CAAQ;IAEhC;;;;OAIG;gBACS,MAAM,EAAE,cAAc;IAgBlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW9B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;;;;OAMG;IACG,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAO/D;;;;;OAKG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAI5F"}
|
|
@@ -64,13 +64,14 @@ class PostgresJsAdapter {
|
|
|
64
64
|
value: void 0
|
|
65
65
|
});
|
|
66
66
|
this.config = config;
|
|
67
|
-
if (
|
|
67
|
+
if ("connectionString" in config && config.connectionString) {
|
|
68
68
|
// Use the provided connection string directly
|
|
69
69
|
this.connectionString = config.connectionString;
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
72
|
// Build connection string from individual parameters
|
|
73
|
-
this.connectionString =
|
|
73
|
+
this.connectionString =
|
|
74
|
+
`postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.database}`;
|
|
74
75
|
if (config.ssl) {
|
|
75
76
|
this.connectionString += "?sslmode=require";
|
|
76
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-pathway.d.ts","sourceRoot":"","sources":["../../src/pathways/session-pathway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"session-pathway.d.ts","sourceRoot":"","sources":["../../src/pathways/session-pathway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAqBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,qBAAqB,CAEhC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAC7C,cAAc,SAAS,MAAM,QAAQ,GAAG,KAAK;IAE7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA2C;IAC3E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC;;;;;OAKG;gBAED,eAAe,EAAE,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,EAC1D,SAAS,CAAC,EAAE,MAAM;IAMpB;;;;OAIG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAKhD;;;;;;;;OAQG;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;CAU9B"}
|
|
@@ -7,14 +7,14 @@ exports.SessionPathwayBuilder = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
function generateUUID() {
|
|
9
9
|
// Check for Deno or browser crypto.randomUUID support
|
|
10
|
-
if (typeof crypto !==
|
|
10
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
11
11
|
return crypto.randomUUID();
|
|
12
12
|
}
|
|
13
13
|
// Fallback to manual UUID generation (compatible with all platforms)
|
|
14
14
|
// Implementation based on RFC4122 version 4
|
|
15
|
-
return
|
|
15
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
16
16
|
const r = Math.random() * 16 | 0;
|
|
17
|
-
const v = c ===
|
|
17
|
+
const v = c === "x" ? r : (r & 0x3 | 0x8);
|
|
18
18
|
return v.toString(16);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,aAAa;IAatB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,OAAO,CAAC,QAAQ,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,qBAAa,aAAa;IAatB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAE/B;;;;;;;OAOG;gBAGgB,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAC9C,SAAS,EAAE,MAAM,EAClC,MAAM,CAAC,EAAE,MAAM;IAajB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACG,YAAY,CAChB,KAAK,EAAE,mBAAmB,EAC1B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAkDlD"}
|
package/script/router/index.js
CHANGED
|
@@ -145,7 +145,7 @@ class PathwayRouter {
|
|
|
145
145
|
};
|
|
146
146
|
const pathwayKey = `${compatibleEvent.flowType}/${compatibleEvent.eventType}`;
|
|
147
147
|
this.logger.debug(`Processing event for pathway: ${pathwayKey}`, {
|
|
148
|
-
eventId: compatibleEvent.eventId
|
|
148
|
+
eventId: compatibleEvent.eventId,
|
|
149
149
|
});
|
|
150
150
|
const pathway = this.pathways.get(pathwayKey);
|
|
151
151
|
if (!pathway) {
|
|
@@ -156,19 +156,19 @@ class PathwayRouter {
|
|
|
156
156
|
try {
|
|
157
157
|
this.logger.debug(`Delegating event processing to pathway handler`, {
|
|
158
158
|
pathwayKey,
|
|
159
|
-
eventId: compatibleEvent.eventId
|
|
159
|
+
eventId: compatibleEvent.eventId,
|
|
160
160
|
});
|
|
161
161
|
await this.pathways.process(pathwayKey, compatibleEvent);
|
|
162
162
|
this.logger.debug(`Event successfully processed through pathway`, {
|
|
163
163
|
pathwayKey,
|
|
164
|
-
eventId: compatibleEvent.eventId
|
|
164
|
+
eventId: compatibleEvent.eventId,
|
|
165
165
|
});
|
|
166
166
|
return { success: true, message: `Event processed through pathway ${pathwayKey}` };
|
|
167
167
|
}
|
|
168
168
|
catch (error) {
|
|
169
169
|
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
170
170
|
this.logger.error(`Error processing pathway ${pathwayKey}`, errorObj, {
|
|
171
|
-
eventId: compatibleEvent.eventId
|
|
171
|
+
eventId: compatibleEvent.eventId,
|
|
172
172
|
});
|
|
173
173
|
// Rethrow the error with additional context
|
|
174
174
|
throw new Error(`Failed to process event in pathway ${pathwayKey}: ${errorObj.message}`);
|