@flowcore/pathways 0.10.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 +98 -55
- 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 +63 -9
- package/esm/pathways/builder.d.ts.map +1 -1
- package/esm/pathways/builder.js +203 -41
- 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/pathways/types.d.ts +7 -2
- package/esm/pathways/types.d.ts.map +1 -1
- 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 +63 -9
- package/script/pathways/builder.d.ts.map +1 -1
- package/script/pathways/builder.js +205 -42
- 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/pathways/types.d.ts +7 -2
- package/script/pathways/types.d.ts.map +1 -1
- 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,KAAK,
|
|
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;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE;;OAEG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,MAAM,GAAG,MAAM,EAAE,CAAC;IA4HvB,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;IAsH7B;;;;;;;;;;OAUG;YACW,2BAA2B;CA4C1C"}
|
package/esm/pathways/builder.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
1
2
|
import { Value } from "@sinclair/typebox/value";
|
|
2
3
|
import { Subject } from "rxjs";
|
|
3
4
|
import { WebhookBuilder } from "../compatibility/flowcore-transformer-core.sdk.js";
|
|
@@ -19,6 +20,60 @@ const DEFAULT_RETRY_DELAY_MS = 500;
|
|
|
19
20
|
* Default TTL for session-specific user resolvers in milliseconds (10seconds)
|
|
20
21
|
*/
|
|
21
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
|
+
}
|
|
22
77
|
/**
|
|
23
78
|
* Main builder class for creating and managing Flowcore pathways
|
|
24
79
|
*
|
|
@@ -43,9 +98,10 @@ export class PathwaysBuilder {
|
|
|
43
98
|
* @param options.apiKey The API key for authentication
|
|
44
99
|
* @param options.pathwayTimeoutMs Optional timeout for pathway processing in milliseconds
|
|
45
100
|
* @param options.logger Optional logger instance
|
|
46
|
-
* @param options.
|
|
101
|
+
* @param options.enableSessionUserResolvers Whether to enable session user resolvers
|
|
102
|
+
* @param options.overrideSessionUserResolvers Optional SessionUserResolver instance to override the default
|
|
47
103
|
*/
|
|
48
|
-
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger,
|
|
104
|
+
constructor({ baseUrl, tenant, dataCore, apiKey, pathwayTimeoutMs, logger, enableSessionUserResolvers, overrideSessionUserResolvers, }) {
|
|
49
105
|
Object.defineProperty(this, "pathways", {
|
|
50
106
|
enumerable: true,
|
|
51
107
|
configurable: true,
|
|
@@ -88,6 +144,12 @@ export class PathwaysBuilder {
|
|
|
88
144
|
writable: true,
|
|
89
145
|
value: {}
|
|
90
146
|
});
|
|
147
|
+
Object.defineProperty(this, "batchWriters", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
configurable: true,
|
|
150
|
+
writable: true,
|
|
151
|
+
value: {}
|
|
152
|
+
});
|
|
91
153
|
Object.defineProperty(this, "schemas", {
|
|
92
154
|
enumerable: true,
|
|
93
155
|
configurable: true,
|
|
@@ -201,14 +263,14 @@ export class PathwaysBuilder {
|
|
|
201
263
|
this.tenant = tenant;
|
|
202
264
|
this.dataCore = dataCore;
|
|
203
265
|
this.apiKey = apiKey;
|
|
204
|
-
if (
|
|
205
|
-
this.sessionUserResolvers =
|
|
266
|
+
if (enableSessionUserResolvers) {
|
|
267
|
+
this.sessionUserResolvers = overrideSessionUserResolvers ?? new SessionUser();
|
|
206
268
|
}
|
|
207
|
-
this.logger.debug(
|
|
269
|
+
this.logger.debug("Initializing PathwaysBuilder", {
|
|
208
270
|
baseUrl,
|
|
209
271
|
tenant,
|
|
210
272
|
dataCore,
|
|
211
|
-
pathwayTimeoutMs
|
|
273
|
+
pathwayTimeoutMs,
|
|
212
274
|
});
|
|
213
275
|
this.webhookBuilderFactory = new WebhookBuilder({
|
|
214
276
|
baseUrl,
|
|
@@ -231,7 +293,7 @@ export class PathwaysBuilder {
|
|
|
231
293
|
* @returns The PathwaysBuilder instance with custom state configured
|
|
232
294
|
*/
|
|
233
295
|
withPathwayState(state) {
|
|
234
|
-
this.logger.debug(
|
|
296
|
+
this.logger.debug("Setting custom pathway state");
|
|
235
297
|
this.pathwayState = state;
|
|
236
298
|
return this;
|
|
237
299
|
}
|
|
@@ -241,7 +303,7 @@ export class PathwaysBuilder {
|
|
|
241
303
|
* @returns The PathwaysBuilder instance with audit configured
|
|
242
304
|
*/
|
|
243
305
|
withAudit(handler) {
|
|
244
|
-
this.logger.debug(
|
|
306
|
+
this.logger.debug("Configuring audit functionality");
|
|
245
307
|
this.auditHandler = handler;
|
|
246
308
|
return this;
|
|
247
309
|
}
|
|
@@ -251,7 +313,7 @@ export class PathwaysBuilder {
|
|
|
251
313
|
* @returns The PathwaysBuilder instance with custom user ID resolver configured
|
|
252
314
|
*/
|
|
253
315
|
withUserResolver(resolver) {
|
|
254
|
-
this.logger.debug(
|
|
316
|
+
this.logger.debug("Configuring user resolver");
|
|
255
317
|
this.userIdResolver = resolver;
|
|
256
318
|
return this;
|
|
257
319
|
}
|
|
@@ -290,9 +352,9 @@ export class PathwaysBuilder {
|
|
|
290
352
|
*/
|
|
291
353
|
withSessionUserResolver(sessionId, resolver) {
|
|
292
354
|
if (!this.sessionUserResolvers) {
|
|
293
|
-
throw new Error(
|
|
355
|
+
throw new Error("Session user resolvers not configured");
|
|
294
356
|
}
|
|
295
|
-
this.logger.debug(
|
|
357
|
+
this.logger.debug("Configuring session-specific user resolver", { sessionId });
|
|
296
358
|
this.sessionUserResolvers.set(sessionId, resolver, DEFAULT_SESSION_USER_RESOLVER_TTL_MS);
|
|
297
359
|
return this;
|
|
298
360
|
}
|
|
@@ -318,7 +380,7 @@ export class PathwaysBuilder {
|
|
|
318
380
|
const pathwayStr = String(pathway);
|
|
319
381
|
this.logger.debug(`Processing pathway event`, {
|
|
320
382
|
pathway: pathwayStr,
|
|
321
|
-
eventId: data.eventId
|
|
383
|
+
eventId: data.eventId,
|
|
322
384
|
});
|
|
323
385
|
if (!this.pathways[pathway]) {
|
|
324
386
|
const error = `Pathway ${pathwayStr} not found`;
|
|
@@ -345,7 +407,7 @@ export class PathwaysBuilder {
|
|
|
345
407
|
if (this.auditHandler) {
|
|
346
408
|
this.logger.debug(`Calling audit handler for pathway`, {
|
|
347
409
|
pathway: pathwayStr,
|
|
348
|
-
eventId: data.eventId
|
|
410
|
+
eventId: data.eventId,
|
|
349
411
|
});
|
|
350
412
|
this.auditHandler(pathwayStr, data);
|
|
351
413
|
}
|
|
@@ -355,7 +417,7 @@ export class PathwaysBuilder {
|
|
|
355
417
|
const retryDelayMs = this.retryDelays[pathway] ?? DEFAULT_RETRY_DELAY_MS;
|
|
356
418
|
this.logger.debug(`Emitting 'before' event`, {
|
|
357
419
|
pathway: pathwayStr,
|
|
358
|
-
eventId: data.eventId
|
|
420
|
+
eventId: data.eventId,
|
|
359
421
|
});
|
|
360
422
|
this.beforeObservable[pathway].next(data);
|
|
361
423
|
while (true) {
|
|
@@ -363,7 +425,7 @@ export class PathwaysBuilder {
|
|
|
363
425
|
this.logger.debug(`Executing handler for pathway`, {
|
|
364
426
|
pathway: pathwayStr,
|
|
365
427
|
eventId: data.eventId,
|
|
366
|
-
attempt: retryCount + 1
|
|
428
|
+
attempt: retryCount + 1,
|
|
367
429
|
});
|
|
368
430
|
// Execute the handler
|
|
369
431
|
const handle = this.handlers[pathway](data);
|
|
@@ -371,13 +433,13 @@ export class PathwaysBuilder {
|
|
|
371
433
|
// If successful, emit success event and mark as processed
|
|
372
434
|
this.logger.debug(`Handler executed successfully, emitting 'after' event`, {
|
|
373
435
|
pathway: pathwayStr,
|
|
374
|
-
eventId: data.eventId
|
|
436
|
+
eventId: data.eventId,
|
|
375
437
|
});
|
|
376
438
|
this.afterObservers[pathway].next(data);
|
|
377
439
|
await this.pathwayState.setProcessed(data.eventId);
|
|
378
440
|
this.logger.info(`Successfully processed pathway event`, {
|
|
379
441
|
pathway: pathwayStr,
|
|
380
|
-
eventId: data.eventId
|
|
442
|
+
eventId: data.eventId,
|
|
381
443
|
});
|
|
382
444
|
return;
|
|
383
445
|
}
|
|
@@ -388,7 +450,7 @@ export class PathwaysBuilder {
|
|
|
388
450
|
pathway: pathwayStr,
|
|
389
451
|
eventId: data.eventId,
|
|
390
452
|
retryCount,
|
|
391
|
-
maxRetries
|
|
453
|
+
maxRetries,
|
|
392
454
|
});
|
|
393
455
|
// Emit error event with both error and event data
|
|
394
456
|
this.errorObservers[pathway].next({ event: data, error: errorObj });
|
|
@@ -396,7 +458,7 @@ export class PathwaysBuilder {
|
|
|
396
458
|
this.globalErrorSubject.next({
|
|
397
459
|
pathway: pathwayStr,
|
|
398
460
|
event: data,
|
|
399
|
-
error: errorObj
|
|
461
|
+
error: errorObj,
|
|
400
462
|
});
|
|
401
463
|
// Check if we should retry
|
|
402
464
|
if (retryCount < maxRetries) {
|
|
@@ -407,10 +469,10 @@ export class PathwaysBuilder {
|
|
|
407
469
|
eventId: data.eventId,
|
|
408
470
|
attempt: retryCount,
|
|
409
471
|
maxRetries,
|
|
410
|
-
nextDelay
|
|
472
|
+
nextDelay,
|
|
411
473
|
});
|
|
412
474
|
// Wait for delay before retrying
|
|
413
|
-
await new Promise(resolve => setTimeout(resolve, nextDelay));
|
|
475
|
+
await new Promise((resolve) => setTimeout(resolve, nextDelay));
|
|
414
476
|
continue;
|
|
415
477
|
}
|
|
416
478
|
// If we've exhausted retries, mark as processed to avoid hanging
|
|
@@ -418,7 +480,7 @@ export class PathwaysBuilder {
|
|
|
418
480
|
pathway: pathwayStr,
|
|
419
481
|
eventId: data.eventId,
|
|
420
482
|
retryCount,
|
|
421
|
-
maxRetries
|
|
483
|
+
maxRetries,
|
|
422
484
|
});
|
|
423
485
|
await this.pathwayState.setProcessed(data.eventId);
|
|
424
486
|
throw error;
|
|
@@ -429,7 +491,7 @@ export class PathwaysBuilder {
|
|
|
429
491
|
// No handler, just emit events and mark as processed
|
|
430
492
|
this.logger.debug(`No handler for pathway, emitting events and marking as processed`, {
|
|
431
493
|
pathway: pathwayStr,
|
|
432
|
-
eventId: data.eventId
|
|
494
|
+
eventId: data.eventId,
|
|
433
495
|
});
|
|
434
496
|
this.beforeObservable[pathway].next(data);
|
|
435
497
|
this.afterObservers[pathway].next(data);
|
|
@@ -456,9 +518,9 @@ export class PathwaysBuilder {
|
|
|
456
518
|
isFilePathway: contract.isFilePathway,
|
|
457
519
|
timeoutMs: contract.timeoutMs,
|
|
458
520
|
maxRetries: contract.maxRetries,
|
|
459
|
-
retryDelayMs: contract.retryDelayMs
|
|
460
|
-
})
|
|
461
|
-
|
|
521
|
+
retryDelayMs: contract.retryDelayMs,
|
|
522
|
+
}) // deno-lint-ignore no-explicit-any
|
|
523
|
+
;
|
|
462
524
|
this.pathways[path] = true;
|
|
463
525
|
this.beforeObservable[path] = new Subject();
|
|
464
526
|
this.afterObservers[path] = new Subject();
|
|
@@ -472,6 +534,8 @@ export class PathwaysBuilder {
|
|
|
472
534
|
else {
|
|
473
535
|
this.writers[path] = this.webhookBuilderFactory()
|
|
474
536
|
.buildWebhook(contract.flowType, contract.eventType).send;
|
|
537
|
+
this.batchWriters[path] = this.webhookBuilderFactory()
|
|
538
|
+
.buildWebhook(contract.flowType, contract.eventType).sendBatch;
|
|
475
539
|
}
|
|
476
540
|
}
|
|
477
541
|
if (contract.timeoutMs) {
|
|
@@ -489,7 +553,7 @@ export class PathwaysBuilder {
|
|
|
489
553
|
pathway: path,
|
|
490
554
|
flowType: contract.flowType,
|
|
491
555
|
eventType: contract.eventType,
|
|
492
|
-
writable
|
|
556
|
+
writable,
|
|
493
557
|
});
|
|
494
558
|
return this;
|
|
495
559
|
}
|
|
@@ -558,7 +622,7 @@ export class PathwaysBuilder {
|
|
|
558
622
|
}
|
|
559
623
|
this.logger.info(`Subscription to pathway events set up`, {
|
|
560
624
|
pathway: pathStr,
|
|
561
|
-
type
|
|
625
|
+
type,
|
|
562
626
|
});
|
|
563
627
|
return this;
|
|
564
628
|
}
|
|
@@ -607,8 +671,8 @@ export class PathwaysBuilder {
|
|
|
607
671
|
metadata,
|
|
608
672
|
options: {
|
|
609
673
|
fireAndForget: options?.fireAndForget,
|
|
610
|
-
sessionId: options?.sessionId
|
|
611
|
-
}
|
|
674
|
+
sessionId: options?.sessionId,
|
|
675
|
+
},
|
|
612
676
|
});
|
|
613
677
|
if (!this.pathways[path]) {
|
|
614
678
|
const error = `Pathway ${pathStr} not found`;
|
|
@@ -625,7 +689,7 @@ export class PathwaysBuilder {
|
|
|
625
689
|
const errorMessage = `Invalid data for pathway ${pathStr}`;
|
|
626
690
|
this.logger.error(errorMessage, new Error(errorMessage), {
|
|
627
691
|
pathway: pathStr,
|
|
628
|
-
schema: schema.toString()
|
|
692
|
+
schema: schema.toString(),
|
|
629
693
|
});
|
|
630
694
|
throw new Error(errorMessage);
|
|
631
695
|
}
|
|
@@ -641,13 +705,13 @@ export class PathwaysBuilder {
|
|
|
641
705
|
this.logger.debug(`Using session-specific user resolver`, {
|
|
642
706
|
pathway: pathStr,
|
|
643
707
|
sessionId: options.sessionId,
|
|
644
|
-
userId
|
|
708
|
+
userId,
|
|
645
709
|
});
|
|
646
710
|
}
|
|
647
711
|
catch (error) {
|
|
648
712
|
this.logger.error(`Error resolving session user ID`, error instanceof Error ? error : new Error(String(error)), {
|
|
649
713
|
pathway: pathStr,
|
|
650
|
-
sessionId: options.sessionId
|
|
714
|
+
sessionId: options.sessionId,
|
|
651
715
|
});
|
|
652
716
|
}
|
|
653
717
|
}
|
|
@@ -665,7 +729,7 @@ export class PathwaysBuilder {
|
|
|
665
729
|
this.logger.debug(`Adding audit metadata`, {
|
|
666
730
|
pathway: pathStr,
|
|
667
731
|
auditMode,
|
|
668
|
-
userId
|
|
732
|
+
userId,
|
|
669
733
|
});
|
|
670
734
|
if (userId) {
|
|
671
735
|
// Add appropriate audit metadata based on mode
|
|
@@ -692,15 +756,113 @@ export class PathwaysBuilder {
|
|
|
692
756
|
this.logger.info(`Successfully wrote to pathway`, {
|
|
693
757
|
pathway: pathStr,
|
|
694
758
|
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
695
|
-
fireAndForget: options?.fireAndForget
|
|
759
|
+
fireAndForget: options?.fireAndForget,
|
|
696
760
|
});
|
|
697
761
|
if (!options?.fireAndForget) {
|
|
698
762
|
this.logger.debug(`Waiting for pathway to be processed`, {
|
|
699
763
|
pathway: pathStr,
|
|
700
|
-
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds]
|
|
764
|
+
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
701
765
|
});
|
|
702
766
|
await Promise.all(Array.isArray(eventIds)
|
|
703
|
-
? eventIds.map(id => this.waitForPathwayToBeProcessed(id))
|
|
767
|
+
? eventIds.map((id) => this.waitForPathwayToBeProcessed(id))
|
|
768
|
+
: [this.waitForPathwayToBeProcessed(eventIds)]);
|
|
769
|
+
}
|
|
770
|
+
return eventIds;
|
|
771
|
+
}
|
|
772
|
+
async writeBatch(path, data, metadata, options) {
|
|
773
|
+
const pathStr = String(path);
|
|
774
|
+
this.logger.debug(`Writing batch to pathway`, {
|
|
775
|
+
pathway: pathStr,
|
|
776
|
+
metadata,
|
|
777
|
+
options: {
|
|
778
|
+
fireAndForget: options?.fireAndForget,
|
|
779
|
+
sessionId: options?.sessionId,
|
|
780
|
+
},
|
|
781
|
+
});
|
|
782
|
+
if (!this.pathways[path]) {
|
|
783
|
+
const error = `Pathway ${pathStr} not found`;
|
|
784
|
+
this.logger.error(error);
|
|
785
|
+
throw new Error(error);
|
|
786
|
+
}
|
|
787
|
+
if (!this.writable[path]) {
|
|
788
|
+
const error = `Pathway ${pathStr} is not writable`;
|
|
789
|
+
this.logger.error(error);
|
|
790
|
+
throw new Error(error);
|
|
791
|
+
}
|
|
792
|
+
const schema = this.schemas[path];
|
|
793
|
+
if (!Value.Check(Type.Array(schema), data)) {
|
|
794
|
+
const errorMessage = `Invalid batch data for pathway ${pathStr}`;
|
|
795
|
+
this.logger.error(errorMessage, new Error(errorMessage), {
|
|
796
|
+
pathway: pathStr,
|
|
797
|
+
schema: schema.toString(),
|
|
798
|
+
});
|
|
799
|
+
throw new Error(errorMessage);
|
|
800
|
+
}
|
|
801
|
+
// Create a copy of the metadata to avoid modifying the original
|
|
802
|
+
const finalMetadata = metadata ? { ...metadata } : {};
|
|
803
|
+
// Check for session-specific user resolver
|
|
804
|
+
let userId;
|
|
805
|
+
if (options?.sessionId) {
|
|
806
|
+
const sessionUserResolver = this.getSessionUserResolver(options.sessionId);
|
|
807
|
+
if (sessionUserResolver) {
|
|
808
|
+
try {
|
|
809
|
+
userId = await sessionUserResolver();
|
|
810
|
+
this.logger.debug(`Using session-specific user resolver`, {
|
|
811
|
+
pathway: pathStr,
|
|
812
|
+
sessionId: options.sessionId,
|
|
813
|
+
userId,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
catch (error) {
|
|
817
|
+
this.logger.error(`Error resolving session user ID`, error instanceof Error ? error : new Error(String(error)), {
|
|
818
|
+
pathway: pathStr,
|
|
819
|
+
sessionId: options.sessionId,
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
// Process audit metadata if audit is configured
|
|
825
|
+
if (this.userIdResolver) {
|
|
826
|
+
// Only use global resolver if we don't already have a user ID from a session resolver
|
|
827
|
+
if (!userId) {
|
|
828
|
+
this.logger.debug(`Resolving user ID for audit metadata`, { pathway: pathStr });
|
|
829
|
+
userId = await this.userIdResolver();
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
// Determine the audit mode: default is "user" unless explicitly specified as "system"
|
|
833
|
+
const auditMode = options?.auditMode ?? "user";
|
|
834
|
+
this.logger.debug(`Adding audit metadata`, {
|
|
835
|
+
pathway: pathStr,
|
|
836
|
+
auditMode,
|
|
837
|
+
userId,
|
|
838
|
+
});
|
|
839
|
+
if (userId) {
|
|
840
|
+
// Add appropriate audit metadata based on mode
|
|
841
|
+
if (auditMode === "system") {
|
|
842
|
+
finalMetadata["audit/user-id"] = "system";
|
|
843
|
+
finalMetadata["audit/on-behalf-of"] = userId;
|
|
844
|
+
finalMetadata["audit/mode"] = "system";
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
finalMetadata["audit/user-id"] = userId;
|
|
848
|
+
finalMetadata["audit/mode"] = "user"; // Always set mode for user
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
let eventIds = [];
|
|
852
|
+
this.logger.debug(`Writing batch webhook data to pathway`, { pathway: pathStr });
|
|
853
|
+
eventIds = await this.batchWriters[path](data, finalMetadata, options);
|
|
854
|
+
this.logger.info(`Successfully wrote to pathway`, {
|
|
855
|
+
pathway: pathStr,
|
|
856
|
+
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
857
|
+
fireAndForget: options?.fireAndForget,
|
|
858
|
+
});
|
|
859
|
+
if (!options?.fireAndForget) {
|
|
860
|
+
this.logger.debug(`Waiting for pathway to be processed`, {
|
|
861
|
+
pathway: pathStr,
|
|
862
|
+
eventIds: Array.isArray(eventIds) ? eventIds : [eventIds],
|
|
863
|
+
});
|
|
864
|
+
await Promise.all(Array.isArray(eventIds)
|
|
865
|
+
? eventIds.map((id) => this.waitForPathwayToBeProcessed(id))
|
|
704
866
|
: [this.waitForPathwayToBeProcessed(eventIds)]);
|
|
705
867
|
}
|
|
706
868
|
return eventIds;
|
|
@@ -721,7 +883,7 @@ export class PathwaysBuilder {
|
|
|
721
883
|
const timeoutMs = this.timeouts[eventId] ?? this.pathwayTimeoutMs;
|
|
722
884
|
this.logger.debug(`Waiting for event to be processed`, {
|
|
723
885
|
eventId,
|
|
724
|
-
timeoutMs
|
|
886
|
+
timeoutMs,
|
|
725
887
|
});
|
|
726
888
|
let attempts = 0;
|
|
727
889
|
while (!(await this.pathwayState.isProcessed(eventId))) {
|
|
@@ -733,7 +895,7 @@ export class PathwaysBuilder {
|
|
|
733
895
|
eventId,
|
|
734
896
|
timeoutMs,
|
|
735
897
|
elapsedTime,
|
|
736
|
-
attempts
|
|
898
|
+
attempts,
|
|
737
899
|
});
|
|
738
900
|
throw new Error(errorMessage);
|
|
739
901
|
}
|
|
@@ -742,7 +904,7 @@ export class PathwaysBuilder {
|
|
|
742
904
|
eventId,
|
|
743
905
|
elapsedTime,
|
|
744
906
|
attempts,
|
|
745
|
-
timeoutMs
|
|
907
|
+
timeoutMs,
|
|
746
908
|
});
|
|
747
909
|
}
|
|
748
910
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -750,7 +912,7 @@ export class PathwaysBuilder {
|
|
|
750
912
|
this.logger.debug(`Event has been processed`, {
|
|
751
913
|
eventId,
|
|
752
914
|
elapsedTime: Date.now() - startTime,
|
|
753
|
-
attempts
|
|
915
|
+
attempts,
|
|
754
916
|
});
|
|
755
917
|
}
|
|
756
918
|
}
|
|
@@ -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,E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AE,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"}
|