@flowcore/pathways 0.11.0 → 0.13.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 +102 -58
- package/README.md +133 -126
- 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 +66 -5
- package/esm/pathways/builder.d.ts.map +1 -1
- package/esm/pathways/builder.js +67 -8
- 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 +66 -5
- package/script/pathways/builder.d.ts.map +1 -1
- package/script/pathways/builder.js +69 -9
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pathways/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEnE,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pathways/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEnE,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EAInB,eAAe,EAChB,MAAM,YAAY,CAAA;AAsBnB;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;AAEvE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B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QAAQ,EAAE,cAAc,CAAC;IAQ5C;;;;;;;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;IA8HvB,UAAU,CAAC,KAAK,SAAS,cAAc,EAC3C,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,EACvB,QAAQ,CAAC,EAAE,aAAa,EACxB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;IAwH7B;;;;;;;;;;OAUG;YACW,2BAA2B;CA4C1C"}
|
package/esm/pathways/builder.js
CHANGED
|
@@ -20,6 +20,60 @@ const DEFAULT_RETRY_DELAY_MS = 500;
|
|
|
20
20
|
* Default TTL for session-specific user resolvers in milliseconds (10seconds)
|
|
21
21
|
*/
|
|
22
22
|
const DEFAULT_SESSION_USER_RESOLVER_TTL_MS = 10 * 1000;
|
|
23
|
+
/**
|
|
24
|
+
* SessionUserResolver implementation that uses a Map to store UserIdResolver functions
|
|
25
|
+
* with a TTL (time to live).
|
|
26
|
+
*/
|
|
27
|
+
export class SessionUser {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new SessionUser instance
|
|
30
|
+
*/
|
|
31
|
+
constructor() {
|
|
32
|
+
/**
|
|
33
|
+
* The underlying Map that stores UserIdResolver functions and their timeouts
|
|
34
|
+
* Using unknown for timeout to support both Node.js and Deno timer types
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(this, "store", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
this.store = new Map();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a UserIdResolver from the session user resolver store
|
|
46
|
+
* @param key The key to retrieve the UserIdResolver for
|
|
47
|
+
* @returns The UserIdResolver or undefined if it doesn't exist
|
|
48
|
+
*/
|
|
49
|
+
get(key) {
|
|
50
|
+
const entry = this.store.get(key);
|
|
51
|
+
if (!entry) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return entry.value;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Stores a UserIdResolver in the session user resolver store
|
|
58
|
+
* @param key The key to store the UserIdResolver under
|
|
59
|
+
* @param value The UserIdResolver to store
|
|
60
|
+
* @param ttlMs The time to live for the UserIdResolver in milliseconds
|
|
61
|
+
* @default 5 minutes
|
|
62
|
+
*/
|
|
63
|
+
set(key, value, ttlMs = 1000 * 60 * 5) {
|
|
64
|
+
// Clear any existing timeout for this key
|
|
65
|
+
const existingEntry = this.store.get(key);
|
|
66
|
+
if (existingEntry) {
|
|
67
|
+
clearTimeout(existingEntry.timeout);
|
|
68
|
+
}
|
|
69
|
+
// Set up new timeout
|
|
70
|
+
const timeout = setTimeout(() => {
|
|
71
|
+
this.store.delete(key);
|
|
72
|
+
}, ttlMs);
|
|
73
|
+
// Store the new value and its timeout
|
|
74
|
+
this.store.set(key, { value, timeout });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
23
77
|
/**
|
|
24
78
|
* Main builder class for creating and managing Flowcore pathways
|
|
25
79
|
*
|
|
@@ -44,9 +98,10 @@ export class PathwaysBuilder {
|
|
|
44
98
|
* @param options.apiKey The API key for authentication
|
|
45
99
|
* @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
|
|
46
100
|
* @param options.logger Optional logger instance
|
|
47
|
-
* @param options.
|
|
101
|
+
* @param options.enableSessionUserResolvers Whether to enable session user resolvers
|
|
102
|
+
* @param options.overrideSessionUserResolvers Optional SessionUserResolver instance to override the default
|
|
48
103
|
*/
|
|
49
|
-
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger,
|
|
104
|
+
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, enableSessionUserResolvers, overrideSessionUserResolvers, }) {
|
|
50
105
|
Object.defineProperty(this, "pathways", {
|
|
51
106
|
enumerable: true,
|
|
52
107
|
configurable: true,
|
|
@@ -208,8 +263,8 @@ export class PathwaysBuilder {
|
|
|
208
263
|
this.tenant = tenant;
|
|
209
264
|
this.dataCore = dataCore;
|
|
210
265
|
this.apiKey = apiKey;
|
|
211
|
-
if (
|
|
212
|
-
this.sessionUserResolvers =
|
|
266
|
+
if (enableSessionUserResolvers) {
|
|
267
|
+
this.sessionUserResolvers = overrideSessionUserResolvers ?? new SessionUser();
|
|
213
268
|
}
|
|
214
269
|
this.logger.debug("Initializing PathwaysBuilder", {
|
|
215
270
|
baseUrl,
|
|
@@ -680,12 +735,14 @@ export class PathwaysBuilder {
|
|
|
680
735
|
// Add appropriate audit metadata based on mode
|
|
681
736
|
if (auditMode === "system") {
|
|
682
737
|
finalMetadata["audit/user-id"] = "system";
|
|
683
|
-
finalMetadata["audit/on-behalf-of"] = userId;
|
|
738
|
+
finalMetadata["audit/on-behalf-of"] = userId.entityId;
|
|
684
739
|
finalMetadata["audit/mode"] = "system";
|
|
740
|
+
finalMetadata["audit/entity-type"] = userId.entityType;
|
|
685
741
|
}
|
|
686
742
|
else {
|
|
687
|
-
finalMetadata["audit/user-id"] = userId;
|
|
743
|
+
finalMetadata["audit/user-id"] = userId.entityId;
|
|
688
744
|
finalMetadata["audit/mode"] = "user"; // Always set mode for user
|
|
745
|
+
finalMetadata["audit/entity-type"] = userId.entityType;
|
|
689
746
|
}
|
|
690
747
|
}
|
|
691
748
|
let eventIds = [];
|
|
@@ -785,12 +842,14 @@ export class PathwaysBuilder {
|
|
|
785
842
|
// Add appropriate audit metadata based on mode
|
|
786
843
|
if (auditMode === "system") {
|
|
787
844
|
finalMetadata["audit/user-id"] = "system";
|
|
788
|
-
finalMetadata["audit/on-behalf-of"] = userId;
|
|
845
|
+
finalMetadata["audit/on-behalf-of"] = userId.entityId;
|
|
789
846
|
finalMetadata["audit/mode"] = "system";
|
|
847
|
+
finalMetadata["audit/entity-type"] = userId.entityType;
|
|
790
848
|
}
|
|
791
849
|
else {
|
|
792
|
-
finalMetadata["audit/user-id"] = userId;
|
|
850
|
+
finalMetadata["audit/user-id"] = userId.entityId;
|
|
793
851
|
finalMetadata["audit/mode"] = "user"; // Always set mode for user
|
|
852
|
+
finalMetadata["audit/entity-type"] = userId.entityType;
|
|
794
853
|
}
|
|
795
854
|
}
|
|
796
855
|
let eventIds = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pathways/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pathways/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA"}
|
|
@@ -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,
|
|
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,CAAA;AAE9C;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAEtD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAyB;IAEnC;;;;;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 +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,
|
|
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,CAAA;AAEhD;;;;GAIG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAmB;IAEhC;;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"}
|
|
@@ -39,7 +39,7 @@ export interface KvAdapter {
|
|
|
39
39
|
* @param key The key to retrieve
|
|
40
40
|
* @returns The stored value or null if not found
|
|
41
41
|
*/
|
|
42
|
-
get<T>(key: string):
|
|
42
|
+
get<T>(key: string): Promise<T | null> | T | null;
|
|
43
43
|
/**
|
|
44
44
|
* Stores a value in storage with the specified key and TTL
|
|
45
45
|
*
|
|
@@ -48,7 +48,7 @@ export interface KvAdapter {
|
|
|
48
48
|
* @param ttlMs Time-to-live in milliseconds
|
|
49
49
|
* @returns Promise or void when the operation completes
|
|
50
50
|
*/
|
|
51
|
-
set(key: string, value: unknown, ttlMs: number):
|
|
51
|
+
set(key: string, value: unknown, ttlMs: number): Promise<void> | void;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Creates an appropriate KV adapter based on the runtime environment
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAEjD;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAU1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/node-kv-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"node-kv-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/kv/node-kv-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD;;;;GAIG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAkB;IAErC;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAK5C;;;;;;;OAOG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrE"}
|
package/esm/pathways/logger.js
CHANGED
|
@@ -11,7 +11,7 @@ export class ConsoleLogger {
|
|
|
11
11
|
* @param context Optional context data to include
|
|
12
12
|
*/
|
|
13
13
|
debug(message, context) {
|
|
14
|
-
console.debug(message, context ? JSON.stringify(context) :
|
|
14
|
+
console.debug(message, context ? JSON.stringify(context) : "");
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Log informational messages to the console
|
|
@@ -19,7 +19,7 @@ export class ConsoleLogger {
|
|
|
19
19
|
* @param context Optional context data to include
|
|
20
20
|
*/
|
|
21
21
|
info(message, context) {
|
|
22
|
-
console.info(message, context ? JSON.stringify(context) :
|
|
22
|
+
console.info(message, context ? JSON.stringify(context) : "");
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Log warning messages to the console
|
|
@@ -27,7 +27,7 @@ export class ConsoleLogger {
|
|
|
27
27
|
* @param context Optional context data to include
|
|
28
28
|
*/
|
|
29
29
|
warn(message, context) {
|
|
30
|
-
console.warn(message, context ? JSON.stringify(context) :
|
|
30
|
+
console.warn(message, context ? JSON.stringify(context) : "");
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Log error messages to the console
|
|
@@ -40,19 +40,19 @@ export class ConsoleLogger {
|
|
|
40
40
|
* @param context Optional context data (only for signature 1)
|
|
41
41
|
*/
|
|
42
42
|
error(messageOrError, errorOrContext, context) {
|
|
43
|
-
if (typeof messageOrError ===
|
|
43
|
+
if (typeof messageOrError === "string") {
|
|
44
44
|
if (errorOrContext instanceof Error) {
|
|
45
45
|
// Signature 1: error(message: string, error: Error, context?: LoggerMeta)
|
|
46
|
-
console.error(messageOrError, errorOrContext, context ? JSON.stringify(context) :
|
|
46
|
+
console.error(messageOrError, errorOrContext, context ? JSON.stringify(context) : "");
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
// Signature 1 (no error) or Signature 2: error(message: string, context?: LoggerMeta)
|
|
50
|
-
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) :
|
|
50
|
+
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) : "");
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
54
|
// Signature 2: error(error: Error, context?: LoggerMeta)
|
|
55
|
-
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) :
|
|
55
|
+
console.error(messageOrError, errorOrContext ? JSON.stringify(errorOrContext) : "");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -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,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,GAAG,CAAC,EAAE,KAAK,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,KAAK,CAAA;IAExB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,8BAA8B,GAAG,wBAAwB,CAAA;AAEtF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAExB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3B;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAErD;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAoBD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAA8D;IAC9E,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAA8B;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"}
|
|
@@ -37,13 +37,14 @@ export class PostgresJsAdapter {
|
|
|
37
37
|
value: void 0
|
|
38
38
|
});
|
|
39
39
|
this.config = config;
|
|
40
|
-
if (
|
|
40
|
+
if ("connectionString" in config && config.connectionString) {
|
|
41
41
|
// Use the provided connection string directly
|
|
42
42
|
this.connectionString = config.connectionString;
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
// Build connection string from individual parameters
|
|
46
|
-
this.connectionString =
|
|
46
|
+
this.connectionString =
|
|
47
|
+
`postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.database}`;
|
|
47
48
|
if (config.ssl) {
|
|
48
49
|
this.connectionString += "?sslmode=require";
|
|
49
50
|
}
|
|
@@ -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"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
function generateUUID() {
|
|
6
6
|
// Check for Deno or browser crypto.randomUUID support
|
|
7
|
-
if (typeof crypto !==
|
|
7
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
8
8
|
return crypto.randomUUID();
|
|
9
9
|
}
|
|
10
10
|
// Fallback to manual UUID generation (compatible with all platforms)
|
|
11
11
|
// Implementation based on RFC4122 version 4
|
|
12
|
-
return
|
|
12
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
13
13
|
const r = Math.random() * 16 | 0;
|
|
14
|
-
const v = c ===
|
|
14
|
+
const v = c === "x" ? r : (r & 0x3 | 0x8);
|
|
15
15
|
return v.toString(16);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -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/esm/router/index.js
CHANGED
|
@@ -142,7 +142,7 @@ export class PathwayRouter {
|
|
|
142
142
|
};
|
|
143
143
|
const pathwayKey = `${compatibleEvent.flowType}/${compatibleEvent.eventType}`;
|
|
144
144
|
this.logger.debug(`Processing event for pathway: ${pathwayKey}`, {
|
|
145
|
-
eventId: compatibleEvent.eventId
|
|
145
|
+
eventId: compatibleEvent.eventId,
|
|
146
146
|
});
|
|
147
147
|
const pathway = this.pathways.get(pathwayKey);
|
|
148
148
|
if (!pathway) {
|
|
@@ -153,19 +153,19 @@ export class PathwayRouter {
|
|
|
153
153
|
try {
|
|
154
154
|
this.logger.debug(`Delegating event processing to pathway handler`, {
|
|
155
155
|
pathwayKey,
|
|
156
|
-
eventId: compatibleEvent.eventId
|
|
156
|
+
eventId: compatibleEvent.eventId,
|
|
157
157
|
});
|
|
158
158
|
await this.pathways.process(pathwayKey, compatibleEvent);
|
|
159
159
|
this.logger.debug(`Event successfully processed through pathway`, {
|
|
160
160
|
pathwayKey,
|
|
161
|
-
eventId: compatibleEvent.eventId
|
|
161
|
+
eventId: compatibleEvent.eventId,
|
|
162
162
|
});
|
|
163
163
|
return { success: true, message: `Event processed through pathway ${pathwayKey}` };
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
166
|
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
167
167
|
this.logger.error(`Error processing pathway ${pathwayKey}`, errorObj, {
|
|
168
|
-
eventId: compatibleEvent.eventId
|
|
168
|
+
eventId: compatibleEvent.eventId,
|
|
169
169
|
});
|
|
170
170
|
// Rethrow the error with additional context
|
|
171
171
|
throw new Error(`Failed to process event in pathway ${pathwayKey}: ${errorObj.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowcore/pathways",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A TypeScript Library for creating Flowcore Pathways, simplifying the integration with the flowcore platform",
|
|
5
5
|
"homepage": "https://github.com/flowcore-io/flowcore-pathways#readme",
|
|
6
6
|
"repository": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,YAAY,CAAA"}
|
package/script/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,mBAAmB,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Static, type 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";
|
|
5
4
|
import type { Logger } from "./logger.js";
|
|
6
5
|
import type { EventMetadata, PathwayContract, PathwayKey, PathwayState, PathwayWriteOptions, WritablePathway } from "./types.js";
|
|
7
6
|
/**
|
|
@@ -16,11 +15,20 @@ export type AuditMode = "user" | "system";
|
|
|
16
15
|
* @param event The event data being processed
|
|
17
16
|
*/
|
|
18
17
|
export type AuditHandler = (path: string, event: FlowcoreEvent) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Represents an entity that can be used for audit purposes
|
|
20
|
+
* @property entityId The unique identifier for the entity
|
|
21
|
+
* @property entityType The type of entity (e.g., "user" or "key")
|
|
22
|
+
*/
|
|
23
|
+
export type UserResolverEntity = {
|
|
24
|
+
entityId: string;
|
|
25
|
+
entityType: "user" | "key";
|
|
26
|
+
};
|
|
19
27
|
/**
|
|
20
28
|
* Async function that resolves to the current user ID
|
|
21
29
|
* Used for audit functionality to track which user initiated an action
|
|
22
30
|
*/
|
|
23
|
-
export type UserIdResolver = () => Promise<
|
|
31
|
+
export type UserIdResolver = () => Promise<UserResolverEntity>;
|
|
24
32
|
/**
|
|
25
33
|
* Extended webhook send options with additional audit-specific options
|
|
26
34
|
*/
|
|
@@ -30,6 +38,57 @@ export interface AuditWebhookSendOptions extends WebhookSendOptions {
|
|
|
30
38
|
*/
|
|
31
39
|
headers?: Record<string, string>;
|
|
32
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* SessionUserResolver is a key-value store for storing and retrieving UserIdResolver functions
|
|
43
|
+
* with a TTL (time to live).
|
|
44
|
+
*
|
|
45
|
+
* This allows for session-specific user resolvers to be stored and reused across different
|
|
46
|
+
* sessions or operations.
|
|
47
|
+
*/
|
|
48
|
+
export interface SessionUserResolver {
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves a UserIdResolver from the session user resolver store
|
|
51
|
+
* @param key The key to retrieve the UserIdResolver for
|
|
52
|
+
* @returns The UserIdResolver or undefined if it doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
get(key: string): Promise<UserIdResolver | undefined> | UserIdResolver | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Stores a UserIdResolver in the session user resolver store
|
|
57
|
+
* @param key The key to store the UserIdResolver under
|
|
58
|
+
* @param value The UserIdResolver to store
|
|
59
|
+
* @param ttlMs The time to live for the UserIdResolver in milliseconds
|
|
60
|
+
*/
|
|
61
|
+
set(key: string, value: UserIdResolver, ttlMs: number): Promise<void> | void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* SessionUserResolver implementation that uses a Map to store UserIdResolver functions
|
|
65
|
+
* with a TTL (time to live).
|
|
66
|
+
*/
|
|
67
|
+
export declare class SessionUser implements SessionUserResolver {
|
|
68
|
+
/**
|
|
69
|
+
* The underlying Map that stores UserIdResolver functions and their timeouts
|
|
70
|
+
* Using unknown for timeout to support both Node.js and Deno timer types
|
|
71
|
+
*/
|
|
72
|
+
private store;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new SessionUser instance
|
|
75
|
+
*/
|
|
76
|
+
constructor();
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves a UserIdResolver from the session user resolver store
|
|
79
|
+
* @param key The key to retrieve the UserIdResolver for
|
|
80
|
+
* @returns The UserIdResolver or undefined if it doesn't exist
|
|
81
|
+
*/
|
|
82
|
+
get(key: string): UserIdResolver | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Stores a UserIdResolver in the session user resolver store
|
|
85
|
+
* @param key The key to store the UserIdResolver under
|
|
86
|
+
* @param value The UserIdResolver to store
|
|
87
|
+
* @param ttlMs The time to live for the UserIdResolver in milliseconds
|
|
88
|
+
* @default 5 minutes
|
|
89
|
+
*/
|
|
90
|
+
set(key: string, value: UserIdResolver, ttlMs?: number): void;
|
|
91
|
+
}
|
|
33
92
|
/**
|
|
34
93
|
* Main builder class for creating and managing Flowcore pathways
|
|
35
94
|
*
|
|
@@ -79,16 +138,18 @@ export declare class PathwaysBuilder<TPathway extends Record<string, unknown> =
|
|
|
79
138
|
* @param options.apiKey The API key for authentication
|
|
80
139
|
* @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
|
|
81
140
|
* @param options.logger Optional logger instance
|
|
82
|
-
* @param options.
|
|
141
|
+
* @param options.enableSessionUserResolvers Whether to enable session user resolvers
|
|
142
|
+
* @param options.overrideSessionUserResolvers Optional SessionUserResolver instance to override the default
|
|
83
143
|
*/
|
|
84
|
-
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger,
|
|
144
|
+
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, enableSessionUserResolvers, overrideSessionUserResolvers, }: {
|
|
85
145
|
baseUrl: string;
|
|
86
146
|
tenant: string;
|
|
87
147
|
dataCore: string;
|
|
88
148
|
apiKey: string;
|
|
89
149
|
pathwayTimeoutMs?: number;
|
|
90
150
|
logger?: Logger;
|
|
91
|
-
|
|
151
|
+
enableSessionUserResolvers?: boolean;
|
|
152
|
+
overrideSessionUserResolvers?: SessionUserResolver;
|
|
92
153
|
});
|
|
93
154
|
/**
|
|
94
155
|
* Configures the PathwaysBuilder to use a custom pathway state implementation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pathways/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEnE,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pathways/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEnE,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EAInB,eAAe,EAChB,MAAM,YAAY,CAAA;AAsBnB;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;AAEvE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,GAAG,KAAK,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,kBAAkB,C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