@icure/api 7.1.30 → 7.1.31
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.
|
@@ -14,5 +14,6 @@ export declare class IccUserXApi extends IccUserApi {
|
|
|
14
14
|
}, authenticationProvider: AuthenticationProvider | undefined, authApi: IccAuthApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
15
15
|
getCurrentUser(bypassCache?: boolean): Promise<User>;
|
|
16
16
|
modifyUser(body?: User): Promise<User>;
|
|
17
|
+
modifyUserInGroup(groupId: string, body?: User): Promise<User>;
|
|
17
18
|
subscribeToUserEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<User> | undefined, eventFired: (user: User) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
|
|
18
19
|
}
|
|
@@ -64,6 +64,38 @@ class IccUserXApi extends icc_api_1.IccUserApi {
|
|
|
64
64
|
return _super.modifyUser.call(this, body);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
modifyUserInGroup(groupId, body) {
|
|
68
|
+
const _super = Object.create(null, {
|
|
69
|
+
modifyUserInGroup: { get: () => super.modifyUserInGroup },
|
|
70
|
+
getCurrentUser: { get: () => super.getCurrentUser }
|
|
71
|
+
});
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
//If we do not load the current user, we cannot know if the modification is on the current user
|
|
74
|
+
yield this.getCurrentUser();
|
|
75
|
+
if (this.cachedCurrentUser && (yield this.cachedCurrentUser).id === (body === null || body === void 0 ? void 0 : body.id) && (yield this.cachedCurrentUser).groupId === groupId) {
|
|
76
|
+
try {
|
|
77
|
+
const modifiedUser = yield _super.modifyUserInGroup.call(this, groupId, body).catch((e) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
//It is
|
|
79
|
+
if (e.statusCode === 409) {
|
|
80
|
+
let userInDb = yield _super.getCurrentUser.call(this);
|
|
81
|
+
if ((0, collection_utils_1.objectEquals)((yield this.cachedCurrentUser), userInDb, ['authenticationTokens', 'rev'])) {
|
|
82
|
+
return yield _super.modifyUserInGroup.call(this, groupId, Object.assign(Object.assign({}, body), { rev: userInDb.rev, authenticationTokens: userInDb.authenticationTokens }));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw e;
|
|
86
|
+
}));
|
|
87
|
+
this.cachedCurrentUser = Promise.resolve(modifiedUser);
|
|
88
|
+
return modifiedUser;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
this.cachedCurrentUser = undefined;
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
return _super.modifyUserInGroup.call(this, groupId, body);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
67
99
|
subscribeToUserEvents(eventTypes, filter, eventFired, options = {}) {
|
|
68
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
101
|
const rs = yield (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, 'User', eventTypes, filter, eventFired, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-user-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-user-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAuC;AACvC,0EAAgG;AAGhG,4DAAwE;AACxE,mCAAsE;AAEtE,+DAAsD;AAEtD,MAAa,WAAY,SAAQ,oBAAU;IAKzC,YACE,IAAY,EACZ,OAAkC,EAClC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,OAAmB,EACnB,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA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IAAI,EAAC;QACtD,CAAC;KAAA;IAEK,qBAAqB,CACzB,UAA8C,EAC9C,MAAwC,EACxC,UAAyC,EACzC,UAA+B,EAAE;;YAEjC,MAAM,EAAE,GAAG,MAAM,IAAA,+BAAuB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;YAClH,OAAO,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAA;QAC/B,CAAC;KAAA;CACF;AAnFD,kCAmFC","sourcesContent":["import { IccUserApi } from '../icc-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { AbstractFilter } from './filters/filters'\nimport { User } from '../icc-api/model/User'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { subscribeToEntityEvents , SubscriptionOptions} from './utils'\nimport { IccAuthApi } from '../icc-api'\nimport {objectEquals} from \"./utils/collection-utils\";\n\nexport class IccUserXApi extends IccUserApi {\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n authApi: IccAuthApi\n private cachedCurrentUser: Promise<User> | undefined\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n authApi: IccAuthApi,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.fetchImpl = fetchImpl\n this.authApi = authApi\n }\n\n getCurrentUser(bypassCache: boolean = false): Promise<User> {\n if (bypassCache) return (this.cachedCurrentUser = super.getCurrentUser())\n else return this.cachedCurrentUser ?? (this.cachedCurrentUser = super.getCurrentUser())\n }\n\n async modifyUser(body?: User): Promise<User> {\n //If we do not load the current user, we cannot know if the modification is on the current user\n await this.getCurrentUser()\n if (this.cachedCurrentUser && (await this.cachedCurrentUser).id === body?.id) {\n try {\n const modifiedUser = await super.modifyUser(body).catch(async (e) => {\n //It is\n if (e.statusCode === 409) {\n let userInDb = await super.getCurrentUser();\n if (objectEquals((await this.cachedCurrentUser)!, userInDb, ['authenticationTokens', 'rev'])) {\n return await super.modifyUser({...body, rev: userInDb.rev, authenticationTokens: userInDb.authenticationTokens})\n }\n }\n throw e\n })\n this.cachedCurrentUser = Promise.resolve(modifiedUser)\n return modifiedUser\n } catch (e) {\n this.cachedCurrentUser = undefined\n throw e\n }\n } else return super.modifyUser(body)\n }\n\n async modifyUserInGroup(groupId: string, body?: User): Promise<User> {\n //If we do not load the current user, we cannot know if the modification is on the current user\n await this.getCurrentUser()\n if (this.cachedCurrentUser && (await this.cachedCurrentUser).id === body?.id && (await this.cachedCurrentUser).groupId === groupId) {\n try {\n const modifiedUser = await super.modifyUserInGroup(groupId, body).catch(async (e) => {\n //It is\n if (e.statusCode === 409) {\n let userInDb = await super.getCurrentUser();\n if (objectEquals((await this.cachedCurrentUser)!, userInDb, ['authenticationTokens', 'rev'])) {\n return await super.modifyUserInGroup(groupId, {...body, rev: userInDb.rev, authenticationTokens: userInDb.authenticationTokens})\n }\n }\n throw e\n })\n this.cachedCurrentUser = Promise.resolve(modifiedUser)\n return modifiedUser\n } catch (e) {\n this.cachedCurrentUser = undefined\n throw e\n }\n } else return super.modifyUserInGroup(groupId, body)\n }\n\n async subscribeToUserEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<User> | undefined,\n eventFired: (user: User) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n const rs = await subscribeToEntityEvents(this.host, this.authApi, 'User', eventTypes, filter, eventFired, options)\n return new ConnectionImpl(rs)\n }\n}\n"]}
|