@topconsultnpm/sdk-ts 6.19.0-dev1.5 → 6.19.0-dev1.6
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.
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { PublicClientApplication } from "@azure/msal-browser";
|
|
11
11
|
import { ArchiveEngine, AreaEngine, BasketEngine, BasketTypeEngine, DataListEngine, DcmtTypeEngine, DiskEngine, DossierEngine, FavoritesEngine, HomePageEngine, RelationEngine, JobEngine, LicenseEngine, NotificationEngine, OrchPlatformEngine, PreviewEngine, ProcessEngine, RecentEngine, SavedQueryEngine, SearchEngine, SignCertEngine, TSAEngine, TaskEngine, TreeEngine, UploadFileEngine, UserEngine, WorkflowEngine, WorkingGroupEngine, DeleteEngine, UpdateEngineByID, ArchiveEngineByID, DcmtPlatformEngine, ADMEngine, NumeratorEngine, ReportEngine, SignServerEngine, LDAPEngine, GroupEngine, SAPEngine, PermissionEngine, ViewEngine, DossierTypeEngine } from "./Engine";
|
|
12
|
-
import { DataListCacheService, DcmtTypeListCacheService, RelationCacheService, SavedQueryCacheService, SignCertCacheService, TreeCacheService, TSACacheService, UserListCacheService, WorkingGroupCacheService } from "./helper/SDK_CacheServices";
|
|
12
|
+
import { DataListCacheService, DcmtTypeListCacheService, DossierCacheService, LayoutCacheService, RelationCacheService, SavedQueryCacheService, SignCertCacheService, TreeCacheService, TSACacheService, UserListCacheService, WorkingGroupCacheService } from "./helper/SDK_CacheServices";
|
|
13
13
|
import { AuthenticationModes } from "./openAPIs/TopMediaServiceClient";
|
|
14
14
|
import { SDK_Globals } from "./helper/SDK_Globals";
|
|
15
15
|
export class TopMediaSession {
|
|
@@ -160,6 +160,14 @@ export class TopMediaSession {
|
|
|
160
160
|
UserListCacheService.RemoveAll(this);
|
|
161
161
|
}
|
|
162
162
|
catch (_m) { }
|
|
163
|
+
try {
|
|
164
|
+
LayoutCacheService.RemoveAll(this);
|
|
165
|
+
}
|
|
166
|
+
catch (_o) { }
|
|
167
|
+
try {
|
|
168
|
+
DossierCacheService.RemoveAll(this);
|
|
169
|
+
}
|
|
170
|
+
catch (_p) { }
|
|
163
171
|
SDK_Globals.license = undefined;
|
|
164
172
|
SDK_Globals.currentWorkflowApproveData = [];
|
|
165
173
|
if (!useGlobals)
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { AccessLevelsEx, DataColumnTypes, DataListDescriptor, DataListViewModes, DcmtTypeDescriptor, DossierDescriptor, MetadataDataDomains, MetadataDataTypes, MetadataDescriptor, ObjectClasses, RelationDescriptor, SavedQueryDescriptor, SignCertDescriptor, TSADescriptor, TreeContext, TreeDescriptor, UserDescriptor, UserLevels, WFDescriptor, WorkingGroupDescriptor } from "../openAPIs/TopMediaServiceClient";
|
|
10
|
+
import { AccessLevelsEx, DataColumnTypes, DataListDescriptor, DataListViewModes, DcmtTypeDescriptor, DossierDescriptor, LayoutDescriptor, MetadataDataDomains, MetadataDataTypes, MetadataDescriptor, ObjectClasses, RelationDescriptor, SavedQueryDescriptor, SignCertDescriptor, TSADescriptor, TreeContext, TreeDescriptor, UserDescriptor, UserLevels, WFDescriptor, WorkingGroupDescriptor } from "../openAPIs/TopMediaServiceClient";
|
|
11
11
|
import { Mutex } from 'async-mutex';
|
|
12
12
|
import { SDK_Globals } from "./SDK_Globals";
|
|
13
13
|
export class DataListCacheService {
|
|
@@ -959,3 +959,91 @@ export class UserListCacheService {
|
|
|
959
959
|
}
|
|
960
960
|
UserListCacheService._mutex = new Mutex();
|
|
961
961
|
UserListCacheService._cache = new Map();
|
|
962
|
+
export class LayoutCacheService {
|
|
963
|
+
static getCacheKey(TID, layoutMode) {
|
|
964
|
+
return `${TID}_${layoutMode}`;
|
|
965
|
+
}
|
|
966
|
+
static getAccessToken(tmSession) {
|
|
967
|
+
var _a, _b;
|
|
968
|
+
return (_b = (_a = (tmSession !== null && tmSession !== void 0 ? tmSession : SDK_Globals.tmSession)) === null || _a === void 0 ? void 0 : _a.SessionDescr) === null || _b === void 0 ? void 0 : _b.accessToken;
|
|
969
|
+
}
|
|
970
|
+
static GetAsync(TID_1, layoutMode_1, tmSession_1) {
|
|
971
|
+
return __awaiter(this, arguments, void 0, function* (TID, layoutMode, tmSession, deepCopy = false, refreshCache = false) {
|
|
972
|
+
if (!TID)
|
|
973
|
+
return undefined;
|
|
974
|
+
return yield this.withLock(() => __awaiter(this, void 0, void 0, function* () {
|
|
975
|
+
const tms = tmSession !== null && tmSession !== void 0 ? tmSession : SDK_Globals.tmSession;
|
|
976
|
+
if (!tms)
|
|
977
|
+
throw new Error("No valid session available for DcmtTypeEngine.");
|
|
978
|
+
const accessToken = this.getAccessToken(tmSession);
|
|
979
|
+
const cacheKey = this.getCacheKey(TID, layoutMode);
|
|
980
|
+
if (refreshCache) {
|
|
981
|
+
this.Remove(TID, layoutMode, tmSession);
|
|
982
|
+
}
|
|
983
|
+
let layoutMap = this._cache.get(accessToken);
|
|
984
|
+
if (!layoutMap) {
|
|
985
|
+
layoutMap = new Map();
|
|
986
|
+
this._cache.set(accessToken, layoutMap);
|
|
987
|
+
}
|
|
988
|
+
let layout = layoutMap.get(cacheKey);
|
|
989
|
+
if (!layout) {
|
|
990
|
+
layout = yield tms.NewDcmtTypeEngine().LayoutRetrieveAsync(TID, layoutMode);
|
|
991
|
+
if (layout) {
|
|
992
|
+
layoutMap.set(cacheKey, layout);
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
console.warn(`LayoutRetrieveAsync(${TID}, ${layoutMode}) returned undefined for accessToken: ${accessToken}`);
|
|
996
|
+
return undefined;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return deepCopy ? this.cloneItem(layout) : layout;
|
|
1000
|
+
}));
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
static Remove(TID, layoutMode, tmSession) {
|
|
1004
|
+
if (!TID)
|
|
1005
|
+
return;
|
|
1006
|
+
const accessToken = this.getAccessToken(tmSession);
|
|
1007
|
+
const layoutMap = this._cache.get(accessToken);
|
|
1008
|
+
if (layoutMap) {
|
|
1009
|
+
const cacheKey = this.getCacheKey(TID, layoutMode);
|
|
1010
|
+
layoutMap.delete(cacheKey);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
static RemoveAllForTID(TID, tmSession) {
|
|
1014
|
+
if (!TID)
|
|
1015
|
+
return;
|
|
1016
|
+
const accessToken = this.getAccessToken(tmSession);
|
|
1017
|
+
const layoutMap = this._cache.get(accessToken);
|
|
1018
|
+
if (layoutMap) {
|
|
1019
|
+
const keysToDelete = [];
|
|
1020
|
+
layoutMap.forEach((_, key) => {
|
|
1021
|
+
if (key.startsWith(`${TID}_`)) {
|
|
1022
|
+
keysToDelete.push(key);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
keysToDelete.forEach(key => layoutMap.delete(key));
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
static RemoveAll(tmSession) {
|
|
1029
|
+
const accessToken = this.getAccessToken(tmSession);
|
|
1030
|
+
this._cache.delete(accessToken);
|
|
1031
|
+
}
|
|
1032
|
+
static CacheCount(tmSession) {
|
|
1033
|
+
var _a, _b;
|
|
1034
|
+
const accessToken = this.getAccessToken(tmSession);
|
|
1035
|
+
return (_b = (_a = this._cache.get(accessToken)) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 0;
|
|
1036
|
+
}
|
|
1037
|
+
static withLock(callback) {
|
|
1038
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1039
|
+
return yield this._mutex.runExclusive(callback);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
static cloneItem(item) {
|
|
1043
|
+
const cloned = new LayoutDescriptor();
|
|
1044
|
+
cloned.init(Object.assign({}, item));
|
|
1045
|
+
return cloned;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
LayoutCacheService._mutex = new Mutex();
|
|
1049
|
+
LayoutCacheService._cache = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITopMediaSession } from "../TopMediaSession";
|
|
2
|
-
import { DataListDescriptor, DcmtTypeDescriptor, DossierDescriptor, QueryDescriptor, RelationDescriptor, SavedQueryDescriptor, SearchResultDescriptor, SignCertDescriptor, TSADescriptor, TreeDescriptor, UserDescriptor, WFDescriptor, WorkingGroupDescriptor } from "../openAPIs/TopMediaServiceClient";
|
|
2
|
+
import { DataListDescriptor, DcmtTypeDescriptor, DossierDescriptor, LayoutDescriptor, LayoutModes, QueryDescriptor, RelationDescriptor, SavedQueryDescriptor, SearchResultDescriptor, SignCertDescriptor, TSADescriptor, TreeDescriptor, UserDescriptor, WFDescriptor, WorkingGroupDescriptor } from "../openAPIs/TopMediaServiceClient";
|
|
3
3
|
export declare class DataListCacheService {
|
|
4
4
|
private static readonly _mutex;
|
|
5
5
|
private static readonly _cacheAll;
|
|
@@ -121,3 +121,16 @@ export declare class UserListCacheService {
|
|
|
121
121
|
static GetAsync(userId: number | undefined, tmSession?: ITopMediaSession | undefined, deepCopy?: boolean): Promise<UserDescriptor | undefined>;
|
|
122
122
|
static RemoveAll(tmSession?: ITopMediaSession | undefined): void;
|
|
123
123
|
}
|
|
124
|
+
export declare class LayoutCacheService {
|
|
125
|
+
private static readonly _mutex;
|
|
126
|
+
private static readonly _cache;
|
|
127
|
+
private static getCacheKey;
|
|
128
|
+
private static getAccessToken;
|
|
129
|
+
static GetAsync(TID: number | undefined, layoutMode: LayoutModes, tmSession?: ITopMediaSession, deepCopy?: boolean, refreshCache?: boolean): Promise<LayoutDescriptor | undefined>;
|
|
130
|
+
static Remove(TID: number | undefined, layoutMode: LayoutModes, tmSession?: ITopMediaSession): void;
|
|
131
|
+
static RemoveAllForTID(TID: number | undefined, tmSession?: ITopMediaSession): void;
|
|
132
|
+
static RemoveAll(tmSession?: ITopMediaSession): void;
|
|
133
|
+
static CacheCount(tmSession?: ITopMediaSession): number;
|
|
134
|
+
private static withLock;
|
|
135
|
+
private static cloneItem;
|
|
136
|
+
}
|