@credo-ts/tenants 0.5.0-alpha.153 → 0.5.0-alpha.155
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.
|
@@ -10,7 +10,7 @@ export declare class TenantAgentContextProvider implements AgentContextProvider
|
|
|
10
10
|
private logger;
|
|
11
11
|
private tenantSessionCoordinator;
|
|
12
12
|
constructor(tenantRecordService: TenantRecordService, rootAgentContext: AgentContext, eventEmitter: EventEmitter, tenantSessionCoordinator: TenantSessionCoordinator, logger: Logger);
|
|
13
|
-
getAgentContextForContextCorrelationId(
|
|
13
|
+
getAgentContextForContextCorrelationId(contextCorrelationId: string): Promise<AgentContext>;
|
|
14
14
|
getContextForInboundMessage(inboundMessage: unknown, options?: {
|
|
15
15
|
contextCorrelationId?: string;
|
|
16
16
|
}): Promise<AgentContext>;
|
|
@@ -27,9 +27,13 @@ let TenantAgentContextProvider = class TenantAgentContextProvider {
|
|
|
27
27
|
// Start listener for newly created routing keys, so we can register a mapping for each new key for the tenant
|
|
28
28
|
this.listenForRoutingKeyCreatedEvents();
|
|
29
29
|
}
|
|
30
|
-
async getAgentContextForContextCorrelationId(
|
|
30
|
+
async getAgentContextForContextCorrelationId(contextCorrelationId) {
|
|
31
|
+
// It could be that the root agent context is requested, in that case we return the root agent context
|
|
32
|
+
if (contextCorrelationId === this.rootAgentContext.contextCorrelationId) {
|
|
33
|
+
return this.rootAgentContext;
|
|
34
|
+
}
|
|
31
35
|
// TODO: maybe we can look at not having to retrieve the tenant record if there's already a context available.
|
|
32
|
-
const tenantRecord = await this.tenantRecordService.getTenantById(this.rootAgentContext,
|
|
36
|
+
const tenantRecord = await this.tenantRecordService.getTenantById(this.rootAgentContext, contextCorrelationId);
|
|
33
37
|
const shouldUpdate = !(0, core_1.isStorageUpToDate)(tenantRecord.storageVersion);
|
|
34
38
|
// If the tenant storage is not up to date, and autoUpdate is disabled we throw an error
|
|
35
39
|
if (shouldUpdate && !this.rootAgentContext.config.autoUpdateStorageOnStartup) {
|
|
@@ -41,7 +45,7 @@ let TenantAgentContextProvider = class TenantAgentContextProvider {
|
|
|
41
45
|
const agentContext = await this.tenantSessionCoordinator.getContextForSession(tenantRecord, {
|
|
42
46
|
runInMutex: shouldUpdate ? (agentContext) => this._updateTenantStorage(tenantRecord, agentContext) : undefined,
|
|
43
47
|
});
|
|
44
|
-
this.logger.debug(`Created tenant agent context for tenant '${
|
|
48
|
+
this.logger.debug(`Created tenant agent context for tenant '${contextCorrelationId}'`);
|
|
45
49
|
return agentContext;
|
|
46
50
|
}
|
|
47
51
|
async getContextForInboundMessage(inboundMessage, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantAgentContextProvider.js","sourceRoot":"","sources":["../../src/context/TenantAgentContextProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,yCAgBuB;AAEvB,gDAA4C;AAC5C,0CAAiD;AAEjD,yEAAqE;AAG9D,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAOrC,YACE,mBAAwC,EACxC,gBAA8B,EAC9B,YAA0B,EAC1B,wBAAkD,EACjB,MAAc;QAE/C,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAA;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,8GAA8G;QAC9G,IAAI,CAAC,gCAAgC,EAAE,CAAA;IACzC,CAAC;IAEM,KAAK,CAAC,sCAAsC,CAAC,
|
|
1
|
+
{"version":3,"file":"TenantAgentContextProvider.js","sourceRoot":"","sources":["../../src/context/TenantAgentContextProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,yCAgBuB;AAEvB,gDAA4C;AAC5C,0CAAiD;AAEjD,yEAAqE;AAG9D,IAAM,0BAA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
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@credo-ts/tenants",
|
|
3
3
|
"main": "build/index",
|
|
4
4
|
"types": "build/index",
|
|
5
|
-
"version": "0.5.0-alpha.
|
|
5
|
+
"version": "0.5.0-alpha.155+f4c386a6",
|
|
6
6
|
"files": [
|
|
7
7
|
"build"
|
|
8
8
|
],
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"test": "jest"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@credo-ts/core": "0.5.0-alpha.
|
|
27
|
+
"@credo-ts/core": "0.5.0-alpha.155+f4c386a6",
|
|
28
28
|
"async-mutex": "^0.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@credo-ts/node": "0.5.0-alpha.
|
|
31
|
+
"@credo-ts/node": "0.5.0-alpha.155+f4c386a6",
|
|
32
32
|
"reflect-metadata": "^0.1.13",
|
|
33
33
|
"rimraf": "^4.4.0",
|
|
34
34
|
"typescript": "~4.9.5"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f4c386a6ccf8adb829cad30b81d524e6ffddb029"
|
|
37
37
|
}
|