@icure/api 8.8.0 → 8.8.1
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/icc-api/api/IccAccesslogApi.d.ts +48 -0
- package/icc-api/api/IccAccesslogApi.js +100 -0
- package/icc-api/api/IccAccesslogApi.js.map +1 -1
- package/icc-api/api/IccAgendaApi.d.ts +25 -0
- package/icc-api/api/IccAgendaApi.js +49 -0
- package/icc-api/api/IccAgendaApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemApi.d.ts +25 -0
- package/icc-api/api/IccCalendarItemApi.js +49 -0
- package/icc-api/api/IccCalendarItemApi.js.map +1 -1
- package/icc-api/api/IccCalendarItemTypeApi.d.ts +25 -0
- package/icc-api/api/IccCalendarItemTypeApi.js +49 -0
- package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
- package/icc-api/api/IccCodeApi.d.ts +25 -0
- package/icc-api/api/IccCodeApi.js +49 -0
- package/icc-api/api/IccCodeApi.js.map +1 -1
- package/icc-api/api/IccContactApi.d.ts +48 -0
- package/icc-api/api/IccContactApi.js +100 -0
- package/icc-api/api/IccContactApi.js.map +1 -1
- package/icc-api/api/IccDeviceApi.d.ts +48 -0
- package/icc-api/api/IccDeviceApi.js +100 -0
- package/icc-api/api/IccDeviceApi.js.map +1 -1
- package/icc-api/api/IccDocumentApi.d.ts +48 -0
- package/icc-api/api/IccDocumentApi.js +100 -0
- package/icc-api/api/IccDocumentApi.js.map +1 -1
- package/icc-api/api/IccFormApi.d.ts +48 -0
- package/icc-api/api/IccFormApi.js +101 -4
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/api/IccHcpartyApi.d.ts +48 -0
- package/icc-api/api/IccHcpartyApi.js +100 -0
- package/icc-api/api/IccHcpartyApi.js.map +1 -1
- package/icc-api/api/IccHelementApi.d.ts +48 -0
- package/icc-api/api/IccHelementApi.js +100 -0
- package/icc-api/api/IccHelementApi.js.map +1 -1
- package/icc-api/api/IccInsuranceApi.d.ts +50 -2
- package/icc-api/api/IccInsuranceApi.js +100 -0
- package/icc-api/api/IccInsuranceApi.js.map +1 -1
- package/icc-api/api/IccInvoiceApi.d.ts +48 -0
- package/icc-api/api/IccInvoiceApi.js +100 -0
- package/icc-api/api/IccInvoiceApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +48 -0
- package/icc-api/api/IccMessageApi.js +100 -0
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-api/api/IccPatientApi.d.ts +48 -0
- package/icc-api/api/IccPatientApi.js +100 -0
- package/icc-api/api/IccPatientApi.js.map +1 -1
- package/icc-api/api/IccPlaceApi.d.ts +25 -0
- package/icc-api/api/IccPlaceApi.js +49 -0
- package/icc-api/api/IccPlaceApi.js.map +1 -1
- package/icc-api/api/IccReceiptApi.d.ts +25 -0
- package/icc-api/api/IccReceiptApi.js +49 -0
- package/icc-api/api/IccReceiptApi.js.map +1 -1
- package/icc-api/api/IccTopicApi.d.ts +48 -0
- package/icc-api/api/IccTopicApi.js +100 -0
- package/icc-api/api/IccTopicApi.js.map +1 -1
- package/icc-api/api/IccUserApi.d.ts +25 -0
- package/icc-api/api/IccUserApi.js +49 -0
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/model/ConflictResolutionRequest.d.ts +18 -0
- package/icc-api/model/ConflictResolutionRequest.js +17 -0
- package/icc-api/model/ConflictResolutionRequest.js.map +1 -0
- package/icc-api/model/ConflictResolutionResult.d.ts +22 -0
- package/icc-api/model/ConflictResolutionResult.js +24 -0
- package/icc-api/model/ConflictResolutionResult.js.map +1 -0
- package/icc-api/model/models.d.ts +2 -0
- package/icc-api/model/models.js +2 -0
- package/icc-api/model/models.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +31 -0
- package/icc-x-api/icc-accesslog-x-api.js +57 -0
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +15 -0
- package/icc-x-api/icc-calendar-item-x-api.js +28 -0
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +31 -0
- package/icc-x-api/icc-contact-x-api.js +60 -1
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +31 -0
- package/icc-x-api/icc-document-x-api.js +64 -0
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +31 -0
- package/icc-x-api/icc-form-x-api.js +58 -0
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +31 -0
- package/icc-x-api/icc-helement-x-api.js +57 -0
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +31 -0
- package/icc-x-api/icc-invoice-x-api.js +58 -0
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +31 -0
- package/icc-x-api/icc-message-x-api.js +64 -0
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +31 -0
- package/icc-x-api/icc-patient-x-api.js +57 -0
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.d.ts +31 -0
- package/icc-x-api/icc-topic-x-api.js +58 -0
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -201,4 +201,35 @@ export declare class IccTopicXApi extends IccTopicApi implements EncryptedEntity
|
|
|
201
201
|
}, topicId: string): Promise<Topic>;
|
|
202
202
|
subscribeToTopicEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<Topic> | undefined, eventFired: (message: Topic) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
|
|
203
203
|
createDelegationDeAnonymizationMetadata(entity: Topic, delegates: string[]): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
|
|
206
|
+
* @param user the current user.
|
|
207
|
+
* @param entityId the id of the topic to retrieve the conflicts for.
|
|
208
|
+
* @return the decrypted conflicting revisions of the topic.
|
|
209
|
+
*/
|
|
210
|
+
getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Topic>>;
|
|
211
|
+
/**
|
|
212
|
+
* Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
|
|
213
|
+
* winner returned by the backend.
|
|
214
|
+
* @param user the current user.
|
|
215
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
216
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
217
|
+
*/
|
|
218
|
+
declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest<models.Topic>): Promise<models.ConflictResolutionResult<models.Topic>>;
|
|
219
|
+
/**
|
|
220
|
+
* Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
|
|
221
|
+
* @param user the current user.
|
|
222
|
+
* @param groupId the id of the group the topic belongs to.
|
|
223
|
+
* @param entityId the id of the topic to retrieve the conflicts for.
|
|
224
|
+
* @return the decrypted conflicting revisions of the topic.
|
|
225
|
+
*/
|
|
226
|
+
getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Topic>>;
|
|
227
|
+
/**
|
|
228
|
+
* Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
|
|
229
|
+
* @param user the current user.
|
|
230
|
+
* @param groupId the id of the group the topic belongs to.
|
|
231
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
232
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
233
|
+
*/
|
|
234
|
+
declareConflictWinnerInGroupWithUser(user: models.User, groupId: string, request: models.ConflictResolutionRequest<models.Topic>): Promise<models.ConflictResolutionResult<models.Topic>>;
|
|
204
235
|
}
|
|
@@ -20,6 +20,7 @@ var RequestedPermissionEnum = EntityShareRequest_1.EntityShareRequest.RequestedP
|
|
|
20
20
|
const utils_1 = require("./utils");
|
|
21
21
|
const Connection_1 = require("../icc-api/model/Connection");
|
|
22
22
|
const SecretIdUseOption_1 = require("./crypto/SecretIdUseOption");
|
|
23
|
+
const collection_utils_1 = require("./utils/collection-utils");
|
|
23
24
|
// noinspection JSUnusedGlobalSymbols
|
|
24
25
|
class IccTopicXApi extends icc_api_1.IccTopicApi {
|
|
25
26
|
constructor(host, headers, crypto, dataOwnerApi, authApi, autofillAuthor, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), encryptedKeys = ['description'], fetchImpl = typeof window !== 'undefined'
|
|
@@ -304,6 +305,63 @@ class IccTopicXApi extends icc_api_1.IccTopicApi {
|
|
|
304
305
|
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
305
306
|
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.Topic }, delegates);
|
|
306
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
|
|
310
|
+
* @param user the current user.
|
|
311
|
+
* @param entityId the id of the topic to retrieve the conflicts for.
|
|
312
|
+
* @return the decrypted conflicting revisions of the topic.
|
|
313
|
+
*/
|
|
314
|
+
getConflictsForEntityWithUser(user, entityId) {
|
|
315
|
+
return super.getConflictsForEntity(entityId).then((ts) => this.decrypt(ts));
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
|
|
319
|
+
* winner returned by the backend.
|
|
320
|
+
* @param user the current user.
|
|
321
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
322
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
323
|
+
*/
|
|
324
|
+
declareConflictWinnerWithUser(user, request) {
|
|
325
|
+
const _super = Object.create(null, {
|
|
326
|
+
declareConflictWinner: { get: () => super.declareConflictWinner }
|
|
327
|
+
});
|
|
328
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
329
|
+
const encrypted = (yield this.encrypt([(0, collection_utils_1.cloneDeep)(request.document)]))[0];
|
|
330
|
+
const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
|
|
331
|
+
if (result.document)
|
|
332
|
+
result.document = (yield this.decrypt([result.document]))[0];
|
|
333
|
+
return result;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
|
|
338
|
+
* @param user the current user.
|
|
339
|
+
* @param groupId the id of the group the topic belongs to.
|
|
340
|
+
* @param entityId the id of the topic to retrieve the conflicts for.
|
|
341
|
+
* @return the decrypted conflicting revisions of the topic.
|
|
342
|
+
*/
|
|
343
|
+
getConflictsForEntityInGroupWithUser(user, groupId, entityId) {
|
|
344
|
+
return super.getConflictsForEntityInGroup(groupId, entityId).then((ts) => this.decrypt(ts));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
|
|
348
|
+
* @param user the current user.
|
|
349
|
+
* @param groupId the id of the group the topic belongs to.
|
|
350
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
351
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
352
|
+
*/
|
|
353
|
+
declareConflictWinnerInGroupWithUser(user, groupId, request) {
|
|
354
|
+
const _super = Object.create(null, {
|
|
355
|
+
declareConflictWinnerInGroup: { get: () => super.declareConflictWinnerInGroup }
|
|
356
|
+
});
|
|
357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
+
const encrypted = (yield this.encrypt([(0, collection_utils_1.cloneDeep)(request.document)]))[0];
|
|
359
|
+
const result = yield _super.declareConflictWinnerInGroup.call(this, groupId, Object.assign(Object.assign({}, request), { document: encrypted }));
|
|
360
|
+
if (result.document)
|
|
361
|
+
result.document = (yield this.decrypt([result.document]))[0];
|
|
362
|
+
return result;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
307
365
|
}
|
|
308
366
|
exports.IccTopicXApi = IccTopicXApi;
|
|
309
367
|
//# sourceMappingURL=icc-topic-x-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-topic-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-topic-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAoD;AAGpD,kDAAiD;AAGjD,0EAAgG;AAChG,wEAAoE;AAGpE,qFAAiF;AAKjF,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAC3E,mCAAmJ;AAEnJ,4DAAwE;AACxE,kEAA8D;AAE9D,qCAAqC;AACrC,MAAa,YAAa,SAAQ,qBAAW;IAG3C,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC9B,OAAmB,EACnB,cAAuB,EACxC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,gBAA+B,CAAC,aAAa,CAAC,EAC9C,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;QAZtC,WAAM,GAAN,MAAM,CAAe;QACrB,iBAAY,G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C,CAAC,MAAa,EAAE,SAAmB;QACxE,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAA;IAClJ,CAAC;CACF;AA/WD,oCA+WC","sourcesContent":["import { IccAuthApi, IccTopicApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { ListOfIds, MaintenanceTask, TimingInfo, Topic, TopicRole } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainTopic } from '../icc-api/model/FilterChainTopic'\nimport { PaginatedListTopic } from '../icc-api/model/PaginatedListTopic'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccTopicXApi extends IccTopicApi implements EncryptedEntityXApi<models.Topic> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = ['description'],\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\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Topic.')\n }\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Topic))\n }\n\n /**\n * Creates a new instance of topic with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this topic refers to.\n * @param c initialised data for the topic. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of topic.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient | null,\n c: Topic = {}, // TODO: Why this isn't Topic?\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n if (!patient && options.sfkOption) throw new Error('preferredSfk can only be specified if patient is specified.')\n\n const topic = {\n ...(c ?? {}),\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n _type: 'org.taktik.icure.entities.Topic',\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n }\n\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true ? {} : Object.fromEntries((user.autoDelegations?.all ?? []).map((d) => [d, AccessLevelEnum.WRITE]))),\n ...(options?.additionalDelegates ?? {}),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\n\n return new models.Topic(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n topic,\n EntityWithDelegationTypeName.Topic,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n async decrypt(topics: Array<models.Topic>) {\n return (await this.crypto.xapi.tryDecryptEntities(topics, EntityWithDelegationTypeName.Topic, (x) => new models.Topic(x))).map(\n ({ entity }) => entity\n )\n }\n\n async encrypt(topics: Array<models.Topic>): Promise<Array<models.Topic>> {\n return this.crypto.xapi.tryEncryptEntities(\n topics,\n EntityWithDelegationTypeName.Topic,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Topic(x)\n )\n }\n\n /**\n * Create and share a new topic with other participants.\n * @param body the topic to create.\n * @return the created topic.\n */\n override async createTopic(body: Topic): Promise<Topic> {\n const encryptedTopics = await this.encrypt([body])\n const createdTopic = await super.createTopic(encryptedTopics[0])\n const decryptedTopics = await this.decrypt([createdTopic])\n return decryptedTopics[0]\n }\n\n /**\n * @param topic a topic\n * @return the id of the patient that the topic refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(topic: models.Topic): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: topic, type: EntityWithDelegationTypeName.Topic }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given topic\n */\n async hasWriteAccess(topic: models.Topic): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: topic, type: EntityWithDelegationTypeName.Topic })\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the topic.\n * @param topic the topic to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n topic: models.Topic,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Topic> {\n return this.shareWithMany(topic, { [delegateId]: options })\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param topic the topic to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * topic does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n topic: models.Topic,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Topic> {\n return (await this.tryShareWithMany(topic, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param topic the topic to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * topic does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n topic: models.Topic,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Topic>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(topic, EntityWithDelegationTypeName.Topic)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyTopic(entityWithEncryptionKey) : topic\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Topic,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareTopics(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt([e]).then((es) => es[0])))\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Topic\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Topic })\n }\n\n getEncryptionKeysOf(entity: models.Topic): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Topic }, undefined)\n }\n\n /**\n * Filter and decrypt topics by the given filter.\n * @param body the filter to apply.\n * @param startDocumentId the document id to start from (inclusive).\n * @param limit the maximum number of topics to return in the page.\n * @param collectTiming add timing information to the response\n * @return a paginated list of topics.\n */\n override async filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming?: false): Promise<PaginatedListTopic>\n override async filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming?: true): Promise<PaginatedListTopic & TimingInfo>\n override async filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming: boolean = false): Promise<PaginatedListTopic> {\n const page = await super.filterTopicsBy(body, startDocumentId, limit, collectTiming as any)\n const decryptedTopics = await this.decrypt(page.rows ?? [])\n return {\n ...page,\n rows: decryptedTopics,\n }\n }\n\n /**\n * Obtain the topic with the given id and decrypt it.\n * @param id the id of the topic to retrieve.\n * @return the decrypted topic.\n */\n override async getTopic(id: string): Promise<Topic> {\n const topic = await super.getTopic(id)\n const decryptedTopics = await this.decrypt([topic])\n return decryptedTopics[0]\n }\n\n /**\n * Obtain the topics with the given ids and decrypt them.\n * @param body the ids of the topics to retrieve.\n * @return the decrypted topics.\n */\n override async getTopics(body: ListOfIds): Promise<Array<Topic>> {\n const topics = await super.getTopics(body)\n return await this.decrypt(topics)\n }\n\n /**\n * Update and encrypt the given topic.\n * @param body the topic to update.\n * @return the updated decrypted topic.\n */\n override async modifyTopic(body: Topic): Promise<Topic> {\n const encryptedTopics = await this.encrypt([body])\n const modifiedTopic = await super.modifyTopic(encryptedTopics[0])\n const decryptedTopics = await this.decrypt([modifiedTopic])\n return decryptedTopics[0]\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant.\n * @param topicId Id of the topic to which the participant should be added.\n */\n override async addParticipant(body: { dataOwnerId: string; topicRole: TopicRole }, topicId: string): Promise<Topic> {\n throw new Error('Cannot add participant to topic without sharing it first. You should use addParticipantWithTopic instead.')\n }\n\n /**\n * This method is similar to {@link addParticipant} but it also shares the topic with the data owner before adding the participant.\n * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant.\n * @param topic the topic to share and to which the participant should be added.\n * @return the updated topic.\n */\n async addParticipantWithTopic(body: { dataOwnerId: string; topicRole: TopicRole }, topic: Topic): Promise<Topic> {\n const updatedTopic = await this.shareWith(body.dataOwnerId, topic, {\n requestedPermissions: RequestedPermissionEnum.FULL_WRITE,\n })\n\n return (await this.decrypt([await super.addParticipant(body, updatedTopic.id!)]))[0]\n }\n\n /**\n * Remove the participant with the given data owner id from the topic with the given id.\n * @param body data owner id of the participant to remove.\n * @param topicId Id of the topic from which the participant should be removed.\n * @return the updated decrypted topic.\n */\n async removeParticipant(body: { dataOwnerId: string }, topicId: string): Promise<Topic> {\n const updatedTopic = await super.removeParticipant(body, topicId)\n return (await this.decrypt([updatedTopic]))[0]\n }\n\n async subscribeToTopicEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Topic> | undefined,\n eventFired: (message: Topic) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Topic,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n createDelegationDeAnonymizationMetadata(entity: Topic, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Topic }, delegates)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-topic-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-topic-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAoD;AAGpD,kDAAiD;AAGjD,0EAAgG;AAChG,wEAAoE;AAGpE,qFAAiF;AAKjF,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAC3E,mCAAmJ;AAEnJ,4DAAwE;AACxE,kEAA8D;AAC9D,+DAAoD;AAEpD,qCAAqC;AACrC,M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M,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACjF,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;IAED;;;;;;OAMG;IACH,oCAAoC,CAAC,IAAiB,EAAE,OAAe,EAAE,QAAgB;QACvF,OAAO,KAAK,CAAC,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7F,CAAC;IAED;;;;;;OAMG;IACG,oCAAoC,CACxC,IAAiB,EACjB,OAAe,EACf,OAAuD;;;;;YAEvD,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,IAAA,4BAAS,EAAC,OAAO,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACzE,MAAM,MAAM,GAAG,MAAM,OAAM,4BAA4B,YAAC,OAAO,kCAAO,OAAO,KAAE,QAAQ,EAAE,SAAS,IAAG,CAAA;YACrG,IAAI,MAAM,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YACjF,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AAjbD,oCAibC","sourcesContent":["import { IccAuthApi, IccTopicApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { ListOfIds, MaintenanceTask, TimingInfo, Topic, TopicRole } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainTopic } from '../icc-api/model/FilterChainTopic'\nimport { PaginatedListTopic } from '../icc-api/model/PaginatedListTopic'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport { cloneDeep } from './utils/collection-utils'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccTopicXApi extends IccTopicApi implements EncryptedEntityXApi<models.Topic> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = ['description'],\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\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Topic.')\n }\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Topic))\n }\n\n /**\n * Creates a new instance of topic with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this topic refers to.\n * @param c initialised data for the topic. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of topic.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient | null,\n c: Topic = {}, // TODO: Why this isn't Topic?\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n if (!patient && options.sfkOption) throw new Error('preferredSfk can only be specified if patient is specified.')\n\n const topic = {\n ...(c ?? {}),\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n _type: 'org.taktik.icure.entities.Topic',\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n }\n\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true ? {} : Object.fromEntries((user.autoDelegations?.all ?? []).map((d) => [d, AccessLevelEnum.WRITE]))),\n ...(options?.additionalDelegates ?? {}),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\n\n return new models.Topic(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n topic,\n EntityWithDelegationTypeName.Topic,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n async decrypt(topics: Array<models.Topic>) {\n return (await this.crypto.xapi.tryDecryptEntities(topics, EntityWithDelegationTypeName.Topic, (x) => new models.Topic(x))).map(\n ({ entity }) => entity\n )\n }\n\n async encrypt(topics: Array<models.Topic>): Promise<Array<models.Topic>> {\n return this.crypto.xapi.tryEncryptEntities(\n topics,\n EntityWithDelegationTypeName.Topic,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Topic(x)\n )\n }\n\n /**\n * Create and share a new topic with other participants.\n * @param body the topic to create.\n * @return the created topic.\n */\n override async createTopic(body: Topic): Promise<Topic> {\n const encryptedTopics = await this.encrypt([body])\n const createdTopic = await super.createTopic(encryptedTopics[0])\n const decryptedTopics = await this.decrypt([createdTopic])\n return decryptedTopics[0]\n }\n\n /**\n * @param topic a topic\n * @return the id of the patient that the topic refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(topic: models.Topic): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: topic, type: EntityWithDelegationTypeName.Topic }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given topic\n */\n async hasWriteAccess(topic: models.Topic): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: topic, type: EntityWithDelegationTypeName.Topic })\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the topic.\n * @param topic the topic to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n topic: models.Topic,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Topic> {\n return this.shareWithMany(topic, { [delegateId]: options })\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param topic the topic to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * topic does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n topic: models.Topic,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Topic> {\n return (await this.tryShareWithMany(topic, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing topic with other data owners, allowing them to access the non-encrypted data of the topic and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param topic the topic to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * topic does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this topic refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n topic: models.Topic,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Topic>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(topic, EntityWithDelegationTypeName.Topic)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyTopic(entityWithEncryptionKey) : topic\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Topic,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareTopics(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt([e]).then((es) => es[0])))\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Topic\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Topic })\n }\n\n getEncryptionKeysOf(entity: models.Topic): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Topic }, undefined)\n }\n\n /**\n * Filter and decrypt topics by the given filter.\n * @param body the filter to apply.\n * @param startDocumentId the document id to start from (inclusive).\n * @param limit the maximum number of topics to return in the page.\n * @param collectTiming add timing information to the response\n * @return a paginated list of topics.\n */\n override async filterTopicsBy(body: FilterChainTopic, startDocumentId?: string, limit?: number, collectTiming?: false): Promise<PaginatedListTopic>\n override async filterTopicsBy(\n body: FilterChainTopic,\n startDocumentId?: string,\n limit?: number,\n collectTiming?: true\n ): Promise<PaginatedListTopic & TimingInfo>\n override async filterTopicsBy(\n body: FilterChainTopic,\n startDocumentId?: string,\n limit?: number,\n collectTiming: boolean = false\n ): Promise<PaginatedListTopic> {\n const page = await super.filterTopicsBy(body, startDocumentId, limit, collectTiming as any)\n const decryptedTopics = await this.decrypt(page.rows ?? [])\n return {\n ...page,\n rows: decryptedTopics,\n }\n }\n\n /**\n * Obtain the topic with the given id and decrypt it.\n * @param id the id of the topic to retrieve.\n * @return the decrypted topic.\n */\n override async getTopic(id: string): Promise<Topic> {\n const topic = await super.getTopic(id)\n const decryptedTopics = await this.decrypt([topic])\n return decryptedTopics[0]\n }\n\n /**\n * Obtain the topics with the given ids and decrypt them.\n * @param body the ids of the topics to retrieve.\n * @return the decrypted topics.\n */\n override async getTopics(body: ListOfIds): Promise<Array<Topic>> {\n const topics = await super.getTopics(body)\n return await this.decrypt(topics)\n }\n\n /**\n * Update and encrypt the given topic.\n * @param body the topic to update.\n * @return the updated decrypted topic.\n */\n override async modifyTopic(body: Topic): Promise<Topic> {\n const encryptedTopics = await this.encrypt([body])\n const modifiedTopic = await super.modifyTopic(encryptedTopics[0])\n const decryptedTopics = await this.decrypt([modifiedTopic])\n return decryptedTopics[0]\n }\n\n /**\n * @internal this method is for internal use only and may be changed without notice\n * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant.\n * @param topicId Id of the topic to which the participant should be added.\n */\n override async addParticipant(body: { dataOwnerId: string; topicRole: TopicRole }, topicId: string): Promise<Topic> {\n throw new Error('Cannot add participant to topic without sharing it first. You should use addParticipantWithTopic instead.')\n }\n\n /**\n * This method is similar to {@link addParticipant} but it also shares the topic with the data owner before adding the participant.\n * @param body data owner id of the data owner to which the participant should be added and the topic role of the participant.\n * @param topic the topic to share and to which the participant should be added.\n * @return the updated topic.\n */\n async addParticipantWithTopic(body: { dataOwnerId: string; topicRole: TopicRole }, topic: Topic): Promise<Topic> {\n const updatedTopic = await this.shareWith(body.dataOwnerId, topic, {\n requestedPermissions: RequestedPermissionEnum.FULL_WRITE,\n })\n\n return (await this.decrypt([await super.addParticipant(body, updatedTopic.id!)]))[0]\n }\n\n /**\n * Remove the participant with the given data owner id from the topic with the given id.\n * @param body data owner id of the participant to remove.\n * @param topicId Id of the topic from which the participant should be removed.\n * @return the updated decrypted topic.\n */\n async removeParticipant(body: { dataOwnerId: string }, topicId: string): Promise<Topic> {\n const updatedTopic = await super.removeParticipant(body, topicId)\n return (await this.decrypt([updatedTopic]))[0]\n }\n\n async subscribeToTopicEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Topic> | undefined,\n eventFired: (message: Topic) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Topic,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n createDelegationDeAnonymizationMetadata(entity: Topic, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Topic }, delegates)\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user.\n * @param entityId the id of the topic to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the topic.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Topic>> {\n return super.getConflictsForEntity(entityId).then((ts) => this.decrypt(ts))\n }\n\n /**\n * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved\n * winner returned by the backend.\n * @param user the current user.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerWithUser(\n user: models.User,\n request: models.ConflictResolutionRequest<models.Topic>\n ): Promise<models.ConflictResolutionResult<models.Topic>> {\n const encrypted = (await this.encrypt([cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt([result.document]))[0]\n return result\n }\n\n /**\n * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.\n * @param user the current user.\n * @param groupId the id of the group the topic belongs to.\n * @param entityId the id of the topic to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the topic.\n */\n getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Topic>> {\n return super.getConflictsForEntityInGroup(groupId, entityId).then((ts) => this.decrypt(ts))\n }\n\n /**\n * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.\n * @param user the current user.\n * @param groupId the id of the group the topic belongs to.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerInGroupWithUser(\n user: models.User,\n groupId: string,\n request: models.ConflictResolutionRequest<models.Topic>\n ): Promise<models.ConflictResolutionResult<models.Topic>> {\n const encrypted = (await this.encrypt([cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinnerInGroup(groupId, { ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt([result.document]))[0]\n return result\n }\n}\n"]}
|