@icure/api 8.8.0 → 8.8.2
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/icc-x-api/utils/formatting-util.d.ts +10 -4
- package/icc-x-api/utils/formatting-util.js +47 -6
- package/icc-x-api/utils/formatting-util.js.map +1 -1
- package/package.json +1 -1
|
@@ -428,6 +428,63 @@ class IccAccesslogXApi extends icc_api_1.IccAccesslogApi {
|
|
|
428
428
|
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
429
429
|
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.AccessLog }, delegates);
|
|
430
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
|
|
433
|
+
* @param user the current user, used to determine the data owner that will decrypt the entities.
|
|
434
|
+
* @param entityId the id of the access log to retrieve the conflicts for.
|
|
435
|
+
* @return the decrypted conflicting revisions of the access log.
|
|
436
|
+
*/
|
|
437
|
+
getConflictsForEntityWithUser(user, entityId) {
|
|
438
|
+
return super.getConflictsForEntity(entityId).then((als) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), als));
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
|
|
442
|
+
* winner returned by the backend.
|
|
443
|
+
* @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
|
|
444
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
445
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
446
|
+
*/
|
|
447
|
+
declareConflictWinnerWithUser(user, request) {
|
|
448
|
+
const _super = Object.create(null, {
|
|
449
|
+
declareConflictWinner: { get: () => super.declareConflictWinner }
|
|
450
|
+
});
|
|
451
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
+
const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
|
|
453
|
+
const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
|
|
454
|
+
if (result.document)
|
|
455
|
+
result.document = (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0];
|
|
456
|
+
return result;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
|
|
461
|
+
* @param user the current user, used to determine the data owner that will decrypt the entities.
|
|
462
|
+
* @param groupId the id of the group the access log belongs to.
|
|
463
|
+
* @param entityId the id of the access log to retrieve the conflicts for.
|
|
464
|
+
* @return the decrypted conflicting revisions of the access log.
|
|
465
|
+
*/
|
|
466
|
+
getConflictsForEntityInGroupWithUser(user, groupId, entityId) {
|
|
467
|
+
return super.getConflictsForEntityInGroup(groupId, entityId).then((als) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), als));
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
|
|
471
|
+
* @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
|
|
472
|
+
* @param groupId the id of the group the access log belongs to.
|
|
473
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
474
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
475
|
+
*/
|
|
476
|
+
declareConflictWinnerInGroupWithUser(user, groupId, request) {
|
|
477
|
+
const _super = Object.create(null, {
|
|
478
|
+
declareConflictWinnerInGroup: { get: () => super.declareConflictWinnerInGroup }
|
|
479
|
+
});
|
|
480
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
481
|
+
const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
|
|
482
|
+
const result = yield _super.declareConflictWinnerInGroup.call(this, groupId, Object.assign(Object.assign({}, request), { document: encrypted }));
|
|
483
|
+
if (result.document)
|
|
484
|
+
result.document = (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0];
|
|
485
|
+
return result;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
431
488
|
}
|
|
432
489
|
exports.IccAccesslogXApi = IccAccesslogXApi;
|
|
433
490
|
//# sourceMappingURL=icc-accesslog-x-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-accesslog-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-accesslog-x-api.ts"],"names":[],"mappings":";;;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,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAA;IAC/G,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAAiB,EAAE,SAAmB;QAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,SAAS,EAAE,EACxD,SAAS,CACV,CAAA;IACH,CAAC;CACF;AA1jBD,4CA0jBC","sourcesContent":["import { IccAccesslogApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AccessLog, ListOfIds, PaginatedListAccessLog } from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\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 { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { ShareResult } from './utils/ShareResult'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields } from './utils'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\nexport class IccAccesslogXApi extends IccAccesslogApi implements EncryptedEntityXApi<models.AccessLog> {\n private readonly encryptedFields: EncryptedFieldsManifest\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.AccessLog))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n cryptedKeys = ['detail', 'objectId'],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n this.encryptedFields = parseEncryptedFields(cryptedKeys, 'AccessLog.')\n }\n\n /**\n * Creates a new instance of access log with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this access log refers to.\n * @param h initialised data for the access log. 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 access log.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n h: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const accessLog = {\n ...(h ?? {}),\n _type: 'org.taktik.icure.entities.AccessLog',\n id: h?.id ?? this.crypto.primitives.randomUuid(),\n created: h?.created ?? new Date().getTime(),\n modified: h?.modified ?? new Date().getTime(),\n date: h?.date ?? new Date().getTime(),\n responsible: h?.responsible ?? (this.autofillAuthor ? dataOwnerId : undefined),\n author: h?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: h?.codes ?? [],\n tags: h?.tags ?? [],\n user: h?.user ?? user.id,\n accessType: h?.accessType ?? 'USER_ACCESS',\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 = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((x) => [x, AccessLevelEnum.WRITE])\n )),\n ...(options.additionalDelegates ?? {}),\n }\n return new AccessLog(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n accessLog,\n EntityWithDelegationTypeName.AccessLog,\n patient.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates a new instance of access log with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param h initialised data for the access log. 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 * - 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 access log.\n */\n async newInstanceNoPatient(\n user: models.User,\n h: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const accessLog = {\n ...(h ?? {}),\n _type: 'org.taktik.icure.entities.AccessLog',\n id: h?.id ?? this.crypto.primitives.randomUuid(),\n created: h?.created ?? new Date().getTime(),\n modified: h?.modified ?? new Date().getTime(),\n date: h?.date ?? new Date().getTime(),\n responsible: h?.responsible ?? (this.autofillAuthor ? dataOwnerId : undefined),\n author: h?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: h?.codes ?? [],\n tags: h?.tags ?? [],\n user: h?.user ?? user.id,\n accessType: h?.accessType ?? 'USER_LOGIN',\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 extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((x) => [x, AccessLevelEnum.WRITE])\n )),\n ...(options.additionalDelegates ?? {}),\n }\n return new AccessLog(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n accessLog,\n EntityWithDelegationTypeName.AccessLog,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * 1. Check whether there is a delegation with 'hcpartyId' or not.\n * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.\n * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key\n * 3.1. KeyPair should be fetch from cache (in jwk)\n * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto\n * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient\n * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4)\n * 6. Do the REST call to get all access logs with (allSecretForeignKeysDelimitedByComma, hcpartyId)\n *\n * After these painful steps, you have the access logs of the patient.\n *\n * @deprecated use {@link findIdsBy} instead\n * @param hcpartyId\n * @param patient (Promise)\n * @param usingPost\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false): Promise<models.AccessLog[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? usingPost\n ? this.findByHCPartyPatientSecretFKeysArray(hcpartyId!, [...new Set(extractedKeys)])\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as `findBy` but it will only return the ids of the access logs. It can also filter the access logs where AccessLog.date is between\n * startDate and endDate in ascending or descending order by that field. (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n return extractedKeys && extractedKeys.length > 0\n ? this.findAccessLogIdsByDataOwnerPatientDate(hcpartyId, [...new Set(extractedKeys)], startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead\n */\n async findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<AccessLog[]> {\n const accessLogs = await super.findAccessLogsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys)\n return await this.decrypt(hcPartyId, accessLogs)\n }\n\n /**\n * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead\n */\n findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<AccessLog> | any> {\n return super.findAccessLogsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys).then((accesslogs) => this.decrypt(hcPartyId, accesslogs))\n }\n\n /**\n * Decrypts a list of access logs using the current data owner's keys.\n * @param hcpId the id of the healthcare party performing the decryption.\n * @param accessLogs the access logs to decrypt.\n * @return the decrypted access logs.\n */\n async decrypt(hcpId: string, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n return (await this.crypto.xapi.tryDecryptEntities(accessLogs, EntityWithDelegationTypeName.AccessLog, (json) => new AccessLog(json))).map(\n ({ entity }) => entity\n )\n }\n\n /**\n * Encrypts the encrypted fields of a list of access logs.\n * @param user the current user, used to determine the data owner for encryption.\n * @param accessLogs the access logs to encrypt.\n * @return the encrypted access logs.\n */\n encrypt(user: models.User, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n const owner = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(owner, accessLogs)\n }\n\n private async encryptAs(dataOwner: string, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n return this.crypto.xapi.tryEncryptEntities(\n accessLogs,\n EntityWithDelegationTypeName.AccessLog,\n this.encryptedFields,\n false,\n false,\n (json) => new AccessLog(json)\n )\n }\n\n /**\n * @throws always. Use {@link createAccessLogWithUser} instead.\n */\n createAccessLog(body?: models.AccessLog): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Creates an access log after encrypting its content.\n * @param user the current user, used for encryption.\n * @param body the access log to create.\n * @return the created and decrypted access log.\n */\n createAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | any> {\n return body\n ? this.encrypt(user, [cloneDeep(body)])\n .then((als) => super.createAccessLog(als[0]))\n .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [accessLog]))\n .then((als) => als[0])\n : Promise.resolve()\n }\n\n /**\n * @throws always. Use {@link getAccessLogWithUser} instead.\n */\n getAccessLog(accessLogId: string): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Retrieves an access log by id and decrypts it.\n * @param user the current user, used for decryption.\n * @param accessLogId the id of the access log to retrieve.\n * @return the decrypted access log.\n */\n getAccessLogWithUser(user: models.User, accessLogId: string): Promise<models.AccessLog | any> {\n return super\n .getAccessLog(accessLogId)\n .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [accessLog]))\n .then((als) => als[0])\n }\n\n /**\n * @throws always. Use {@link getAccessLogsWithUser} instead.\n */\n async getAccessLogs(ids: ListOfIds): Promise<AccessLog[]> {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Retrieves multiple access logs by their ids and decrypts them.\n * @param user the current user, used for decryption.\n * @param ids the list of access log ids to retrieve.\n * @return the decrypted access logs.\n */\n getAccessLogsWithUser(user: models.User, ids: ListOfIds): Promise<AccessLog[]> {\n return super.getAccessLogs(ids).then((accessLogs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLogs))\n }\n\n /**\n * @throws always. Use {@link listAccessLogsWithUser} instead.\n */\n listAccessLogs(fromEpoch?: number, toEpoch?: number, startKey?: number, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Lists access logs within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param fromEpoch the start of the date range (epoch in ms).\n * @param toEpoch the end of the date range (epoch in ms).\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @param descending if true, results are returned in descending order.\n * @return a paginated list of decrypted access logs.\n */\n listAccessLogsWithUser(\n user: models.User,\n fromEpoch?: number,\n toEpoch?: number,\n startKey?: number,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): Promise<PaginatedListAccessLog> {\n return super\n .listAccessLogs(fromEpoch, toEpoch, startKey, startDocumentId, limit, descending)\n .then((accessLog) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLog.rows!).then((dr) => Object.assign(accessLog, { rows: dr }))\n )\n }\n\n /**\n * @throws always. Use {@link modifyAccessLogWithUser} instead.\n */\n modifyAccessLog(body?: models.AccessLog): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Modifies an access log after encrypting its content.\n * @param user the current user, used for encryption/decryption.\n * @param body the access log with updated fields.\n * @return the modified and decrypted access log, or null if body was not provided.\n */\n async modifyAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | null> {\n return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, cloneDeep(body)) : null\n }\n\n private async modifyAs(owner: string, body: models.AccessLog): Promise<models.AccessLog> {\n return this.encryptAs(owner, [cloneDeep(body)])\n .then((als) => super.modifyAccessLog(als[0]))\n .then((accessLog) => this.decrypt(owner, [accessLog]))\n .then((als) => als[0])\n }\n\n /**\n * @throws always. Use {@link findByUserAfterDateWithUser} instead.\n */\n findByUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Finds access logs by user id after a given date and decrypts them.\n * @param user the current user, used for decryption.\n * @param userId the id of the user whose access logs to find.\n * @param accessType optional access type filter.\n * @param startDate optional start date filter (epoch in ms).\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @param descending if true, results are returned in descending order.\n * @return a paginated list of decrypted access logs.\n */\n findByUserAfterDateWithUser(\n user: models.User,\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): Promise<models.AccessLog | any> {\n return super\n .findByUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit, descending)\n .then((accessLog) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLog.rows!).then((dr) => Object.assign(accessLog, { rows: dr }))\n )\n }\n\n /**\n * @param accessLog an access log\n * @return the id of the patient that the access log refers to, retrieved from the encrypted metadata (not from the decrypted entity body). Normally\n * there should only be one element in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(accessLog: AccessLog): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: accessLog, type: EntityWithDelegationTypeName.AccessLog }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given access log\n */\n async hasWriteAccess(accessLog: AccessLog): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: accessLog, type: EntityWithDelegationTypeName.AccessLog })\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * 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 access log.\n * @param accessLog the access log 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 access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\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<AccessLog> {\n return this.shareWithMany(accessLog, { [delegateId]: options })\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * encrypted content, with read-only or read-write permissions.\n * @param accessLog the access log 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}).\n * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\n delegates: {\n [delegateId: string]: {\n shareSecretId?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<AccessLog> {\n return (await this.tryShareWithMany(accessLog, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * encrypted content, with read-only or read-write permissions.\n * @param accessLog the access log 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}).\n * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\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<AccessLog>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(accessLog, EntityWithDelegationTypeName.AccessLog)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyAs(self, entityWithEncryptionKey) : accessLog\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.AccessLog,\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.bulkShareAccessLogs(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given access log, along with their access levels.\n * @param entity the access log.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: AccessLog\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.AccessLog })\n }\n\n /**\n * Retrieves the encryption keys of the given access log.\n * @param entity the access log.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: AccessLog): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.AccessLog }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given access log, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the access log.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: AccessLog, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.AccessLog },\n delegates\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-accesslog-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-accesslog-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAG5C,oDAAsF;AACtF,+DAAoD;AAEpD,0EAAgG;AAChG,wEAAoE;AAKpE,mCAAqG;AAErG,kEAA8D;AAC9D,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAGzD,MAAa,gBAAiB,SAAQ,yBAAe;IAKnD,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,SAAS,CAAC,CAAC,CAAA;IAC/I,CAAC;IAED,YACE,IA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AC,OAAO,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/E,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,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3H,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AAlnBD,4CAknBC","sourcesContent":["import { IccAccesslogApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AccessLog, ListOfIds, PaginatedListAccessLog } from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\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 { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { ShareResult } from './utils/ShareResult'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields } from './utils'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\n\nexport class IccAccesslogXApi extends IccAccesslogApi implements EncryptedEntityXApi<models.AccessLog> {\n private readonly encryptedFields: EncryptedFieldsManifest\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.AccessLog))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n cryptedKeys = ['detail', 'objectId'],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n this.encryptedFields = parseEncryptedFields(cryptedKeys, 'AccessLog.')\n }\n\n /**\n * Creates a new instance of access log with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this access log refers to.\n * @param h initialised data for the access log. 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 access log.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n h: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const accessLog = {\n ...(h ?? {}),\n _type: 'org.taktik.icure.entities.AccessLog',\n id: h?.id ?? this.crypto.primitives.randomUuid(),\n created: h?.created ?? new Date().getTime(),\n modified: h?.modified ?? new Date().getTime(),\n date: h?.date ?? new Date().getTime(),\n responsible: h?.responsible ?? (this.autofillAuthor ? dataOwnerId : undefined),\n author: h?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: h?.codes ?? [],\n tags: h?.tags ?? [],\n user: h?.user ?? user.id,\n accessType: h?.accessType ?? 'USER_ACCESS',\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 = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((x) => [x, AccessLevelEnum.WRITE])\n )),\n ...(options.additionalDelegates ?? {}),\n }\n return new AccessLog(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n accessLog,\n EntityWithDelegationTypeName.AccessLog,\n patient.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates a new instance of access log with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param h initialised data for the access log. 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 * - 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 access log.\n */\n async newInstanceNoPatient(\n user: models.User,\n h: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const accessLog = {\n ...(h ?? {}),\n _type: 'org.taktik.icure.entities.AccessLog',\n id: h?.id ?? this.crypto.primitives.randomUuid(),\n created: h?.created ?? new Date().getTime(),\n modified: h?.modified ?? new Date().getTime(),\n date: h?.date ?? new Date().getTime(),\n responsible: h?.responsible ?? (this.autofillAuthor ? dataOwnerId : undefined),\n author: h?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: h?.codes ?? [],\n tags: h?.tags ?? [],\n user: h?.user ?? user.id,\n accessType: h?.accessType ?? 'USER_LOGIN',\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 extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((x) => [x, AccessLevelEnum.WRITE])\n )),\n ...(options.additionalDelegates ?? {}),\n }\n return new AccessLog(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n accessLog,\n EntityWithDelegationTypeName.AccessLog,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * 1. Check whether there is a delegation with 'hcpartyId' or not.\n * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.\n * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key\n * 3.1. KeyPair should be fetch from cache (in jwk)\n * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto\n * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient\n * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4)\n * 6. Do the REST call to get all access logs with (allSecretForeignKeysDelimitedByComma, hcpartyId)\n *\n * After these painful steps, you have the access logs of the patient.\n *\n * @deprecated use {@link findIdsBy} instead\n * @param hcpartyId\n * @param patient (Promise)\n * @param usingPost\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false): Promise<models.AccessLog[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? usingPost\n ? this.findByHCPartyPatientSecretFKeysArray(hcpartyId!, [...new Set(extractedKeys)])\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as `findBy` but it will only return the ids of the access logs. It can also filter the access logs where AccessLog.date is between\n * startDate and endDate in ascending or descending order by that field. (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n return extractedKeys && extractedKeys.length > 0\n ? this.findAccessLogIdsByDataOwnerPatientDate(hcpartyId, [...new Set(extractedKeys)], startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead\n */\n async findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<AccessLog[]> {\n const accessLogs = await super.findAccessLogsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys)\n return await this.decrypt(hcPartyId, accessLogs)\n }\n\n /**\n * @deprecated use {@link findAccessLogIdsByDataOwnerPatientDate} instead\n */\n findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<AccessLog> | any> {\n return super.findAccessLogsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys).then((accesslogs) => this.decrypt(hcPartyId, accesslogs))\n }\n\n /**\n * Decrypts a list of access logs using the current data owner's keys.\n * @param hcpId the id of the healthcare party performing the decryption.\n * @param accessLogs the access logs to decrypt.\n * @return the decrypted access logs.\n */\n async decrypt(hcpId: string, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n return (await this.crypto.xapi.tryDecryptEntities(accessLogs, EntityWithDelegationTypeName.AccessLog, (json) => new AccessLog(json))).map(\n ({ entity }) => entity\n )\n }\n\n /**\n * Encrypts the encrypted fields of a list of access logs.\n * @param user the current user, used to determine the data owner for encryption.\n * @param accessLogs the access logs to encrypt.\n * @return the encrypted access logs.\n */\n encrypt(user: models.User, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n const owner = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(owner, accessLogs)\n }\n\n private async encryptAs(dataOwner: string, accessLogs: Array<models.AccessLog>): Promise<Array<models.AccessLog>> {\n return this.crypto.xapi.tryEncryptEntities(\n accessLogs,\n EntityWithDelegationTypeName.AccessLog,\n this.encryptedFields,\n false,\n false,\n (json) => new AccessLog(json)\n )\n }\n\n /**\n * @throws always. Use {@link createAccessLogWithUser} instead.\n */\n createAccessLog(body?: models.AccessLog): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Creates an access log after encrypting its content.\n * @param user the current user, used for encryption.\n * @param body the access log to create.\n * @return the created and decrypted access log.\n */\n createAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | any> {\n return body\n ? this.encrypt(user, [cloneDeep(body)])\n .then((als) => super.createAccessLog(als[0]))\n .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [accessLog]))\n .then((als) => als[0])\n : Promise.resolve()\n }\n\n /**\n * @throws always. Use {@link getAccessLogWithUser} instead.\n */\n getAccessLog(accessLogId: string): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Retrieves an access log by id and decrypts it.\n * @param user the current user, used for decryption.\n * @param accessLogId the id of the access log to retrieve.\n * @return the decrypted access log.\n */\n getAccessLogWithUser(user: models.User, accessLogId: string): Promise<models.AccessLog | any> {\n return super\n .getAccessLog(accessLogId)\n .then((accessLog) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [accessLog]))\n .then((als) => als[0])\n }\n\n /**\n * @throws always. Use {@link getAccessLogsWithUser} instead.\n */\n async getAccessLogs(ids: ListOfIds): Promise<AccessLog[]> {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Retrieves multiple access logs by their ids and decrypts them.\n * @param user the current user, used for decryption.\n * @param ids the list of access log ids to retrieve.\n * @return the decrypted access logs.\n */\n getAccessLogsWithUser(user: models.User, ids: ListOfIds): Promise<AccessLog[]> {\n return super.getAccessLogs(ids).then((accessLogs) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLogs))\n }\n\n /**\n * @throws always. Use {@link listAccessLogsWithUser} instead.\n */\n listAccessLogs(fromEpoch?: number, toEpoch?: number, startKey?: number, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Lists access logs within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param fromEpoch the start of the date range (epoch in ms).\n * @param toEpoch the end of the date range (epoch in ms).\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @param descending if true, results are returned in descending order.\n * @return a paginated list of decrypted access logs.\n */\n listAccessLogsWithUser(\n user: models.User,\n fromEpoch?: number,\n toEpoch?: number,\n startKey?: number,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): Promise<PaginatedListAccessLog> {\n return super\n .listAccessLogs(fromEpoch, toEpoch, startKey, startDocumentId, limit, descending)\n .then((accessLog) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLog.rows!).then((dr) => Object.assign(accessLog, { rows: dr }))\n )\n }\n\n /**\n * @throws always. Use {@link modifyAccessLogWithUser} instead.\n */\n modifyAccessLog(body?: models.AccessLog): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Modifies an access log after encrypting its content.\n * @param user the current user, used for encryption/decryption.\n * @param body the access log with updated fields.\n * @return the modified and decrypted access log, or null if body was not provided.\n */\n async modifyAccessLogWithUser(user: models.User, body?: models.AccessLog): Promise<models.AccessLog | null> {\n return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, cloneDeep(body)) : null\n }\n\n private async modifyAs(owner: string, body: models.AccessLog): Promise<models.AccessLog> {\n return this.encryptAs(owner, [cloneDeep(body)])\n .then((als) => super.modifyAccessLog(als[0]))\n .then((accessLog) => this.decrypt(owner, [accessLog]))\n .then((als) => als[0])\n }\n\n /**\n * @throws always. Use {@link findByUserAfterDateWithUser} instead.\n */\n findByUserAfterDate(\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): never {\n throw new Error('Cannot call a method that returns access logs without providing a user for de/encryption')\n }\n\n /**\n * Finds access logs by user id after a given date and decrypts them.\n * @param user the current user, used for decryption.\n * @param userId the id of the user whose access logs to find.\n * @param accessType optional access type filter.\n * @param startDate optional start date filter (epoch in ms).\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @param descending if true, results are returned in descending order.\n * @return a paginated list of decrypted access logs.\n */\n findByUserAfterDateWithUser(\n user: models.User,\n userId: string,\n accessType?: string,\n startDate?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n descending?: boolean\n ): Promise<models.AccessLog | any> {\n return super\n .findByUserAfterDate(userId, accessType, startDate, startKey, startDocumentId, limit, descending)\n .then((accessLog) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, accessLog.rows!).then((dr) => Object.assign(accessLog, { rows: dr }))\n )\n }\n\n /**\n * @param accessLog an access log\n * @return the id of the patient that the access log refers to, retrieved from the encrypted metadata (not from the decrypted entity body). Normally\n * there should only be one element in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(accessLog: AccessLog): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: accessLog, type: EntityWithDelegationTypeName.AccessLog }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given access log\n */\n async hasWriteAccess(accessLog: AccessLog): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: accessLog, type: EntityWithDelegationTypeName.AccessLog })\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * 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 access log.\n * @param accessLog the access log 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 access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\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<AccessLog> {\n return this.shareWithMany(accessLog, { [delegateId]: options })\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * encrypted content, with read-only or read-write permissions.\n * @param accessLog the access log 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}).\n * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\n delegates: {\n [delegateId: string]: {\n shareSecretId?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<AccessLog> {\n return (await this.tryShareWithMany(accessLog, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing access log with other data owners, allowing them to access the non-encrypted data of the access log and optionally also the\n * encrypted content, with read-only or read-write permissions.\n * @param accessLog the access log 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}).\n * - sharePatientId: specifies if the id of the patient that this access log refers to should be shared with the delegate. Normally this would\n * be the same as objectId, but it is encrypted separately from it allowing you to give access to the patient id without giving access to the other\n * encrypted data of the access log (defaults to {@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 accessLog: AccessLog,\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<AccessLog>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(accessLog, EntityWithDelegationTypeName.AccessLog)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyAs(self, entityWithEncryptionKey) : accessLog\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.AccessLog,\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.bulkShareAccessLogs(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given access log, along with their access levels.\n * @param entity the access log.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: AccessLog\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.AccessLog })\n }\n\n /**\n * Retrieves the encryption keys of the given access log.\n * @param entity the access log.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: AccessLog): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.AccessLog }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given access log, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the access log.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: AccessLog, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.AccessLog },\n delegates\n )\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param entityId the id of the access log to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the access log.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.AccessLog>> {\n return super.getConflictsForEntity(entityId).then((als) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), als))\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, used to determine the data owner that will encrypt/decrypt the entity.\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.AccessLog>\n ): Promise<models.ConflictResolutionResult<models.AccessLog>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [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, used to determine the data owner that will decrypt the entities.\n * @param groupId the id of the group the access log belongs to.\n * @param entityId the id of the access log to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the access log.\n */\n getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.AccessLog>> {\n return super.getConflictsForEntityInGroup(groupId, entityId).then((als) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), als))\n }\n\n /**\n * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param groupId the id of the group the access log 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.AccessLog>\n ): Promise<models.ConflictResolutionResult<models.AccessLog>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinnerInGroup(groupId, { ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0]\n return result\n }\n}\n"]}
|
|
@@ -350,4 +350,19 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
|
|
|
350
350
|
* @param delegates the data owner ids for which to create de-anonymization metadata.
|
|
351
351
|
*/
|
|
352
352
|
createDelegationDeAnonymizationMetadata(entity: CalendarItem, delegates: string[]): Promise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
|
|
355
|
+
* @param user the current user, used to determine the data owner that will decrypt the entities.
|
|
356
|
+
* @param entityId the id of the calendar item to retrieve the conflicts for.
|
|
357
|
+
* @return the decrypted conflicting revisions of the calendar item.
|
|
358
|
+
*/
|
|
359
|
+
getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.CalendarItem>>;
|
|
360
|
+
/**
|
|
361
|
+
* Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
|
|
362
|
+
* winner returned by the backend.
|
|
363
|
+
* @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
|
|
364
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
365
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
366
|
+
*/
|
|
367
|
+
declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest<models.CalendarItem>): Promise<models.ConflictResolutionResult<models.CalendarItem>>;
|
|
353
368
|
}
|
|
@@ -589,6 +589,34 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
|
|
|
589
589
|
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
590
590
|
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.CalendarItem }, delegates);
|
|
591
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
|
|
594
|
+
* @param user the current user, used to determine the data owner that will decrypt the entities.
|
|
595
|
+
* @param entityId the id of the calendar item to retrieve the conflicts for.
|
|
596
|
+
* @return the decrypted conflicting revisions of the calendar item.
|
|
597
|
+
*/
|
|
598
|
+
getConflictsForEntityWithUser(user, entityId) {
|
|
599
|
+
return super.getConflictsForEntity(entityId).then((cis) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), cis));
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
|
|
603
|
+
* winner returned by the backend.
|
|
604
|
+
* @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
|
|
605
|
+
* @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
|
|
606
|
+
* @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
|
|
607
|
+
*/
|
|
608
|
+
declareConflictWinnerWithUser(user, request) {
|
|
609
|
+
const _super = Object.create(null, {
|
|
610
|
+
declareConflictWinner: { get: () => super.declareConflictWinner }
|
|
611
|
+
});
|
|
612
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
613
|
+
const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
|
|
614
|
+
const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
|
|
615
|
+
if (result.document)
|
|
616
|
+
result.document = (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0];
|
|
617
|
+
return result;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
592
620
|
}
|
|
593
621
|
exports.IccCalendarItemXApi = IccCalendarItemXApi;
|
|
594
622
|
//# sourceMappingURL=icc-calendar-item-x-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-calendar-item-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-calendar-item-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA2C;AAG3C,+DAAoD;AACpD,oDAA4D;AAE5D,wCAA+C;AAE/C,0EA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AAoB,EAAE,SAAmB;QAC/E,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,YAAY,EAAE,EAC3D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAxqBD,kDAwqBC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as models from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\nimport { CalendarItem, User } from '../icc-api/model/models'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccCalendarItemApi } from '../icc-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields } from './utils'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { PaginatedListCalendarItem } from '../icc-api/model/PaginatedListCalendarItem'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccCalendarItemXApi extends IccCalendarItemApi implements EncryptedEntityXApi<models.CalendarItem> {\n i18n: any = i18n\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.CalendarItem))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = ['details', 'title', 'patientId'],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'CalendarItem.')\n }\n\n /**\n * Creates a new instance of calendar item with initialised encryption metadata (not in the database), without\n * linking it to a patient. Use {@link newInstancePatient} to create a calendar item linked to a patient.\n * @param user the current user.\n * @param ci initialised data for the calendar item.\n * @param options optional parameters for delegates and root delegation.\n * @return a new instance of calendar item.\n */\n newInstance(\n user: User,\n ci: any | CalendarItem,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n alternateRootDelegation?: string\n } = {}\n ) {\n return this.newInstancePatient(user, null, ci, options)\n }\n\n /**\n * Creates a new instance of calendar item with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this calendar item refers to.\n * @param ci initialised data for the calendar item. 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 * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classcalendar itemification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\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 calendar item.\n */\n async newInstancePatient(\n user: models.User,\n patient: models.Patient | null,\n ci: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.CalendarItem> {\n const calendarItem = {\n ...(ci ?? {}),\n _type: 'org.taktik.icure.entities.CalendarItem',\n id: ci?.id ?? this.crypto.primitives.randomUuid(),\n created: ci?.created ?? new Date().getTime(),\n modified: ci?.modified ?? new Date().getTime(),\n responsible: ci?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: ci?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: ci?.codes ?? [],\n tags: ci?.tags ?? [],\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 =\n patient != undefined\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n const extraDelegations = {\n ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n return new CalendarItem(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n calendarItem,\n EntityWithDelegationTypeName.CalendarItem,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @deprecated use {@link findIdsBy} instead.\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? usingPost\n ? this.findByHCPartyPatientSecretFKeysArray(hcpartyId!, [...new Set(extractedKeys)])\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as `findBy` but it will only return the ids of the calendar items. It can also filter the access logs where CalendarItem.date is between\n * startDate and endDate in ascending or descending order by that field. (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n return extractedKeys && extractedKeys.length > 0\n ? this.findCalendarItemIdsByDataOwnerPatientStartTime(hcpartyId, [...new Set(extractedKeys)], startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead.\n */\n async findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<Array<models.CalendarItem>> {\n const calendarItems = await super.findCalendarItemsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys)\n return await this.decrypt(hcPartyId, calendarItems)\n }\n\n /**\n * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead.\n */\n findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<models.CalendarItem> | any> {\n return super\n .findCalendarItemsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys)\n .then((calendarItems) => this.decrypt(hcPartyId, calendarItems))\n }\n\n /**\n * @throws always. Use {@link createCalendarItemWithHcParty} instead.\n */\n createCalendarItem(body?: CalendarItem): never {\n throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Creates a calendar item after encrypting its content.\n * @param user the current user, used for encryption.\n * @param body the calendar item to create.\n * @return the created and decrypted calendar item.\n */\n async createCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any> {\n return body\n ? this.encrypt(user, [cloneDeep(body)])\n .then((items) => super.createCalendarItem(items[0]))\n .then((ci) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [ci]))\n .then((cis) => cis[0])\n : null\n }\n\n /**\n * Retrieves a calendar item by id and decrypts it.\n * @param user the current user, used for decryption.\n * @param calendarItemId the id of the calendar item to retrieve.\n * @return the decrypted calendar item.\n */\n getCalendarItemWithUser(user: models.User, calendarItemId: string): Promise<CalendarItem | any> {\n return super\n .getCalendarItem(calendarItemId)\n .then((calendarItem) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [calendarItem]))\n .then((cis) => cis[0])\n }\n\n /**\n * @throws always. Use {@link getCalendarItemWithUser} instead.\n */\n getCalendarItem(calendarItemId: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @deprecated use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n async getCalendarItemsWithUser(user: models.User): Promise<Array<CalendarItem> | any> {\n return super.getCalendarItems().then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n getCalendarItems(): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items with pagination and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @return a paginated list of decrypted calendar items.\n */\n async getCalendarItemsWithPaginationWithUser(user: models.User, startDocumentId?: string, limit?: number): Promise<PaginatedListCalendarItem> {\n return super.getCalendarItemsWithPagination(startDocumentId, limit).then((calendarItems) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems.rows ?? []).then(\n (decryptedItems) =>\n new PaginatedListCalendarItem({\n rows: decryptedItems,\n nextKeyPair: calendarItems.nextKeyPair,\n })\n )\n )\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n getCalendarItemsWithPagination(startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @deprecated use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n async findCalendarItemsByRecurrenceIdWithUser(user: models.User, recurrenceId: string): Promise<Array<CalendarItem> | any> {\n return super\n .findCalendarItemsByRecurrenceId(recurrenceId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n findCalendarItemsByRecurrenceId(recurrenceId: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Finds calendar items by recurrence id with pagination and decrypts them.\n * @param user the current user, used for decryption.\n * @param recurrenceId the recurrence id to search for.\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @return a paginated list of decrypted calendar items matching the recurrence id.\n */\n async findCalendarItemsByRecurrenceIdWithPaginationWithUser(\n user: models.User,\n recurrenceId: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListCalendarItem> {\n return super.findCalendarItemsByRecurrenceIdWithPagination(recurrenceId, startKey, startDocumentId, limit).then((calendarItems) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems.rows ?? []).then(\n (decryptedItems) =>\n new PaginatedListCalendarItem({\n rows: decryptedItems,\n nextKeyPair: calendarItems.nextKeyPair,\n })\n )\n )\n }\n\n /**\n * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n findCalendarItemsByRecurrenceIdWithPagination(recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves multiple calendar items by their ids and decrypts them.\n * @param user the current user, used for decryption.\n * @param body the list of calendar item ids to retrieve.\n * @return the decrypted calendar items.\n */\n getCalendarItemsWithIdsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<CalendarItem> | any> {\n return super.getCalendarItemsWithIds(body).then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithIdsWithUser} instead.\n */\n getCalendarItemsWithIds(body?: models.ListOfIds): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items for a given healthcare party within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDate the start of the date range.\n * @param endDate the end of the date range.\n * @param hcPartyId the id of the healthcare party.\n * @return the decrypted calendar items.\n */\n getCalendarItemsByPeriodAndHcPartyIdWithUser(\n user: models.User,\n startDate: number,\n endDate: number,\n hcPartyId: string\n ): Promise<Array<CalendarItem> | any> {\n return super\n .getCalendarItemsByPeriodAndHcPartyId(startDate, endDate, hcPartyId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsByPeriodAndHcPartyIdWithUser} instead.\n */\n getCalendarItemsByPeriodAndHcPartyId(startDate?: number, endDate?: number, hcPartyId?: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items for a given agenda within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDate the start of the date range.\n * @param endDate the end of the date range.\n * @param agendaId the id of the agenda.\n * @return the decrypted calendar items.\n */\n getCalendarsByPeriodAndAgendaIdWithUser(\n user: models.User,\n startDate: number,\n endDate: number,\n agendaId: string\n ): Promise<Array<CalendarItem> | any> {\n return super\n .getCalendarsByPeriodAndAgendaId(startDate, endDate, agendaId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarsByPeriodAndAgendaIdWithUser} instead.\n */\n getCalendarsByPeriodAndAgendaId(startDate?: number, endDate?: number, agendaId?: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @throws always. Use {@link modifyCalendarItemWithHcParty} instead.\n */\n modifyCalendarItem(body?: CalendarItem): never {\n throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Remove the following delegation objects from the\n * CalendarItem instance: cryptedForeignKeys, secretForeignKeys.\n *\n * The delegations & encryptionKeys objects are not removed because\n * in the case the CalendarItem is saved in the DB & then encrypted,\n * if later we remove the patient from it, it'd reset the delegations\n * and encryptionKeys thus impossibilitating further access.\n *\n * @param calendarItem The Calendar Item object\n */\n resetCalendarDelegationObjects(calendarItem: models.CalendarItem): models.CalendarItem {\n const { cryptedForeignKeys, secretForeignKeys, ...resetCalendarItem } = calendarItem\n return resetCalendarItem\n }\n\n /**\n * Modifies a calendar item after encrypting its content.\n * @param user the current user, used for encryption/decryption.\n * @param body the calendar item with updated fields.\n * @return the modified and decrypted calendar item, or null if body was not provided.\n */\n async modifyCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any> {\n return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, cloneDeep(body)) : null\n }\n\n private modifyAs(dataOwner: string, body: models.CalendarItem): Promise<models.CalendarItem> {\n return this.encryptAs(dataOwner, [cloneDeep(body)])\n .then((items) => super.modifyCalendarItem(items[0]))\n .then((ci) => this.decrypt(dataOwner, [ci]))\n .then((cis) => cis[0])\n }\n\n /**\n * Encrypts the encrypted fields of a list of calendar items.\n * @param user the current user, used to determine the data owner for encryption.\n * @param calendarItems the calendar items to encrypt.\n * @return the encrypted calendar items.\n */\n encrypt(user: models.User, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems)\n }\n\n private encryptAs(dataOwner: string, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return this.crypto.xapi.tryEncryptEntities(\n calendarItems,\n EntityWithDelegationTypeName.CalendarItem,\n this.encryptedFields,\n false,\n false,\n (json) => new CalendarItem(json)\n )\n }\n\n /**\n * Decrypts a list of calendar items using the current data owner's keys.\n * @param hcpId the id of the healthcare party performing the decryption.\n * @param calendarItems the calendar items to decrypt.\n * @return the decrypted calendar items.\n */\n async decrypt(hcpId: string, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return (\n await this.crypto.xapi.tryDecryptEntities(calendarItems, EntityWithDelegationTypeName.CalendarItem, (json) => new CalendarItem(json))\n ).map(({ entity }) => entity)\n }\n\n /**\n * @param calendarItem a calendar item\n * @return the id of the patient that the calendar item 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(calendarItem: models.CalendarItem): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: calendarItem, type: EntityWithDelegationTypeName.CalendarItem }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given calendar item\n */\n async hasWriteAccess(calendarItem: models.CalendarItem): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: calendarItem, type: EntityWithDelegationTypeName.CalendarItem })\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item 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 calendar item.\n * @param calendarItem item the calendar item 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}). Note that by default a\n * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 shareWith(\n delegateId: string,\n calendarItem: models.CalendarItem,\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.CalendarItem> {\n return this.shareWithMany(calendarItem, { [delegateId]: options })\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param calendarItem item the calendar item 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 * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 calendarItem: models.CalendarItem,\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.CalendarItem> {\n return (await this.tryShareWithMany(calendarItem, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param calendarItem item the calendar item 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 * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 tryShareWithMany(\n calendarItem: models.CalendarItem,\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.CalendarItem>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(calendarItem, EntityWithDelegationTypeName.CalendarItem)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyAs(self, entityWithEncryptionKey) : calendarItem\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.CalendarItem,\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.bulkShareCalendarItems(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given calendar item, along with their access levels.\n * @param entity the calendar item.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: CalendarItem\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.CalendarItem })\n }\n\n /**\n * Retrieves the encryption keys of the given calendar item.\n * @param entity the calendar item.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: CalendarItem): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.CalendarItem }, undefined)\n }\n\n /**\n * Adds a bidirectional link between a calendar item with a patient.\n * Note that this operation is not reversible: it is not possible to change the patient linked to a calendar\n * item.\n * @param calendarItem a calendar item\n * @param patient the patient which will be linked to the calendar item.\n * @param shareLinkWithDelegates data owners other than the current data owner which will also be able to decrypt the id of the newly linked\n * patient. If any of these data owners do not already have access to the calendar item, they will be granted read access (no write).\n * @param sfkOption specify how to create the link from the patient\n * @return the updated calendar item\n */\n async linkWithPatient(\n calendarItem: models.CalendarItem,\n patient: models.Patient,\n shareLinkWithDelegates: string[],\n sfkOption?: SecretIdUseOption\n ): Promise<models.CalendarItem> {\n if (this.hasLinkFromPatient(calendarItem)) throw new Error(`Calendar item ${calendarItem.id} is already linked to a patient`)\n const delegates = [...new Set([await this.dataOwnerApi.getCurrentDataOwnerId(), ...shareLinkWithDelegates])]\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const individualShareData = {\n shareSecretIds: [] as string[],\n shareEncryptionKeys: [] as string[],\n shareOwningEntityIds: [patient.id!],\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n }\n const shared = await this.crypto.xapi.bulkShareOrUpdateEncryptedEntityMetadata(\n EntityWithDelegationTypeName.CalendarItem,\n [\n {\n entity: calendarItem,\n dataForDelegates: Object.fromEntries(delegates.map((d) => [d, individualShareData])),\n },\n ],\n (x) => this.bulkShareCalendarItems(x)\n )\n if (!shared.updatedEntities.length || shared.updatedEntities[0].id !== calendarItem.id) {\n const errorsForEntity = shared.updateErrors.filter((e) => e.entityId === calendarItem.id)\n if (!errorsForEntity.length || !errorsForEntity.find((x) => x.code === 409)) {\n throw new Error(`Unexpected error while linking calendar item ${calendarItem.id}`)\n } else {\n throw new Error(`Outdated calendar item revision ${calendarItem.id}-${calendarItem.rev}`)\n }\n }\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n const sharedDecrypted = (await this.decrypt(self, [shared.updatedEntities[0]]))[0]\n if (sfk.length > 0) {\n return await this.modifyAs(self, { ...sharedDecrypted, secretForeignKeys: sfk })\n } else {\n return sharedDecrypted\n }\n }\n\n /**\n * Checks if a calendar item has an (encrypted) link from a patient.\n * Calendar item where this method returns false won't be findable when searching for them by patient.\n * If this method returns false there may still be a link to the patient; you can check for it by using the method\n * {@link decryptPatientIdOf}.\n *\n * Note: this method only checks the presence of a link, it doesn't verify that it is valid (for example, this method\n * doesn't check if the link from the patient matches the link to the patient).\n */\n hasLinkFromPatient(calendarItem: CalendarItem): boolean {\n return (calendarItem.secretForeignKeys ?? []).length > 0\n }\n\n /**\n * Adds a link to a calendar item allowing it to be found from the patient.\n * This method only adds a partial link; if the calendar item is not already linked to the patient you should\n * instead use the {@link linkWithPatient}\n * @param calendarItem the calendar item to update.\n * @param patient the patient to link with the calendar item.\n * @param sfkOption customize how to create the link.\n * @return the updated calendar item\n */\n async addLinkFromPatient(calendarItem: CalendarItem, patient: models.Patient, sfkOption?: SecretIdUseOption): Promise<CalendarItem> {\n if (this.hasLinkFromPatient(calendarItem)) throw new Error(`Calendar item ${calendarItem.id} is already linked to a patient`)\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n if (sfk.length > 0) {\n return await this.modifyAs(self, { ...calendarItem, secretForeignKeys: sfk })\n } else {\n return calendarItem\n }\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given calendar item, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the calendar item.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: CalendarItem, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.CalendarItem },\n delegates\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-calendar-item-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-calendar-item-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA2C;AAG3C,+DAAoD;AACpD,oDAA4D;AAE5D,wCAA+C;AAE/C,0EAAgG;AAGhG,qFAAiF;AACjF,wEAAoE;AAEpE,mCAAqG;AAErG,IAAO,uBAAuB,GAAG,uCAAkB,CAAC,uBAAuB,CAAA;AAC3E,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,0FAAsF;AACtF,kEAA8D;AAE9D,MAAa,mBAAoB,SAAQ,4BAAkB;IAMzD,IAAI,OAAO;QACT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KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IACzH,CAAC;IAED;;;;;;OAMG;IACG,6BAA6B,CACjC,IAAiB,EACjB,OAA8D;;;;;YAE9D,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAA,4BAAS,EAAC,OAAO,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/E,MAAM,MAAM,GAAG,MAAM,OAAM,qBAAqB,4CAAM,OAAO,KAAE,QAAQ,EAAE,SAAS,IAAG,CAAA;YACrF,IAAI,MAAM,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3H,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AAnsBD,kDAmsBC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as models from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\nimport { CalendarItem, User } from '../icc-api/model/models'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccCalendarItemApi } from '../icc-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields } from './utils'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { PaginatedListCalendarItem } from '../icc-api/model/PaginatedListCalendarItem'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccCalendarItemXApi extends IccCalendarItemApi implements EncryptedEntityXApi<models.CalendarItem> {\n i18n: any = i18n\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.CalendarItem))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = ['details', 'title', 'patientId'],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\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.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'CalendarItem.')\n }\n\n /**\n * Creates a new instance of calendar item with initialised encryption metadata (not in the database), without\n * linking it to a patient. Use {@link newInstancePatient} to create a calendar item linked to a patient.\n * @param user the current user.\n * @param ci initialised data for the calendar item.\n * @param options optional parameters for delegates and root delegation.\n * @return a new instance of calendar item.\n */\n newInstance(\n user: User,\n ci: any | CalendarItem,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n alternateRootDelegation?: string\n } = {}\n ) {\n return this.newInstancePatient(user, null, ci, options)\n }\n\n /**\n * Creates a new instance of calendar item with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this calendar item refers to.\n * @param ci initialised data for the calendar item. 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 * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classcalendar itemification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\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 calendar item.\n */\n async newInstancePatient(\n user: models.User,\n patient: models.Patient | null,\n ci: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.CalendarItem> {\n const calendarItem = {\n ...(ci ?? {}),\n _type: 'org.taktik.icure.entities.CalendarItem',\n id: ci?.id ?? this.crypto.primitives.randomUuid(),\n created: ci?.created ?? new Date().getTime(),\n modified: ci?.modified ?? new Date().getTime(),\n responsible: ci?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: ci?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: ci?.codes ?? [],\n tags: ci?.tags ?? [],\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 =\n patient != undefined\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n const extraDelegations = {\n ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n return new CalendarItem(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n calendarItem,\n EntityWithDelegationTypeName.CalendarItem,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @deprecated use {@link findIdsBy} instead.\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? usingPost\n ? this.findByHCPartyPatientSecretFKeysArray(hcpartyId!, [...new Set(extractedKeys)])\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n : Promise.resolve([])\n }\n\n /**\n * Same as `findBy` but it will only return the ids of the calendar items. It can also filter the access logs where CalendarItem.date is between\n * startDate and endDate in ascending or descending order by that field. (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n return extractedKeys && extractedKeys.length > 0\n ? this.findCalendarItemIdsByDataOwnerPatientStartTime(hcpartyId, [...new Set(extractedKeys)], startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead.\n */\n async findByHCPartyPatientSecretFKeys(hcPartyId: string, secretFKeys: string): Promise<Array<models.CalendarItem>> {\n const calendarItems = await super.findCalendarItemsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys)\n return await this.decrypt(hcPartyId, calendarItems)\n }\n\n /**\n * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead.\n */\n findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<models.CalendarItem> | any> {\n return super\n .findCalendarItemsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys)\n .then((calendarItems) => this.decrypt(hcPartyId, calendarItems))\n }\n\n /**\n * @throws always. Use {@link createCalendarItemWithHcParty} instead.\n */\n createCalendarItem(body?: CalendarItem): never {\n throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Creates a calendar item after encrypting its content.\n * @param user the current user, used for encryption.\n * @param body the calendar item to create.\n * @return the created and decrypted calendar item.\n */\n async createCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any> {\n return body\n ? this.encrypt(user, [cloneDeep(body)])\n .then((items) => super.createCalendarItem(items[0]))\n .then((ci) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [ci]))\n .then((cis) => cis[0])\n : null\n }\n\n /**\n * Retrieves a calendar item by id and decrypts it.\n * @param user the current user, used for decryption.\n * @param calendarItemId the id of the calendar item to retrieve.\n * @return the decrypted calendar item.\n */\n getCalendarItemWithUser(user: models.User, calendarItemId: string): Promise<CalendarItem | any> {\n return super\n .getCalendarItem(calendarItemId)\n .then((calendarItem) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, [calendarItem]))\n .then((cis) => cis[0])\n }\n\n /**\n * @throws always. Use {@link getCalendarItemWithUser} instead.\n */\n getCalendarItem(calendarItemId: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @deprecated use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n async getCalendarItemsWithUser(user: models.User): Promise<Array<CalendarItem> | any> {\n return super.getCalendarItems().then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n getCalendarItems(): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items with pagination and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @return a paginated list of decrypted calendar items.\n */\n async getCalendarItemsWithPaginationWithUser(user: models.User, startDocumentId?: string, limit?: number): Promise<PaginatedListCalendarItem> {\n return super.getCalendarItemsWithPagination(startDocumentId, limit).then((calendarItems) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems.rows ?? []).then(\n (decryptedItems) =>\n new PaginatedListCalendarItem({\n rows: decryptedItems,\n nextKeyPair: calendarItems.nextKeyPair,\n })\n )\n )\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.\n */\n getCalendarItemsWithPagination(startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @deprecated use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n async findCalendarItemsByRecurrenceIdWithUser(user: models.User, recurrenceId: string): Promise<Array<CalendarItem> | any> {\n return super\n .findCalendarItemsByRecurrenceId(recurrenceId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n findCalendarItemsByRecurrenceId(recurrenceId: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Finds calendar items by recurrence id with pagination and decrypts them.\n * @param user the current user, used for decryption.\n * @param recurrenceId the recurrence id to search for.\n * @param startKey the pagination start key.\n * @param startDocumentId the pagination start document id.\n * @param limit the maximum number of results to return.\n * @return a paginated list of decrypted calendar items matching the recurrence id.\n */\n async findCalendarItemsByRecurrenceIdWithPaginationWithUser(\n user: models.User,\n recurrenceId: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListCalendarItem> {\n return super.findCalendarItemsByRecurrenceIdWithPagination(recurrenceId, startKey, startDocumentId, limit).then((calendarItems) =>\n this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems.rows ?? []).then(\n (decryptedItems) =>\n new PaginatedListCalendarItem({\n rows: decryptedItems,\n nextKeyPair: calendarItems.nextKeyPair,\n })\n )\n )\n }\n\n /**\n * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.\n */\n findCalendarItemsByRecurrenceIdWithPagination(recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves multiple calendar items by their ids and decrypts them.\n * @param user the current user, used for decryption.\n * @param body the list of calendar item ids to retrieve.\n * @return the decrypted calendar items.\n */\n getCalendarItemsWithIdsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<CalendarItem> | any> {\n return super.getCalendarItemsWithIds(body).then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsWithIdsWithUser} instead.\n */\n getCalendarItemsWithIds(body?: models.ListOfIds): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items for a given healthcare party within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDate the start of the date range.\n * @param endDate the end of the date range.\n * @param hcPartyId the id of the healthcare party.\n * @return the decrypted calendar items.\n */\n getCalendarItemsByPeriodAndHcPartyIdWithUser(\n user: models.User,\n startDate: number,\n endDate: number,\n hcPartyId: string\n ): Promise<Array<CalendarItem> | any> {\n return super\n .getCalendarItemsByPeriodAndHcPartyId(startDate, endDate, hcPartyId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarItemsByPeriodAndHcPartyIdWithUser} instead.\n */\n getCalendarItemsByPeriodAndHcPartyId(startDate?: number, endDate?: number, hcPartyId?: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Retrieves calendar items for a given agenda within a date range and decrypts them.\n * @param user the current user, used for decryption.\n * @param startDate the start of the date range.\n * @param endDate the end of the date range.\n * @param agendaId the id of the agenda.\n * @return the decrypted calendar items.\n */\n getCalendarsByPeriodAndAgendaIdWithUser(\n user: models.User,\n startDate: number,\n endDate: number,\n agendaId: string\n ): Promise<Array<CalendarItem> | any> {\n return super\n .getCalendarsByPeriodAndAgendaId(startDate, endDate, agendaId)\n .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems))\n }\n\n /**\n * @throws always. Use {@link getCalendarsByPeriodAndAgendaIdWithUser} instead.\n */\n getCalendarsByPeriodAndAgendaId(startDate?: number, endDate?: number, agendaId?: string): never {\n throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * @throws always. Use {@link modifyCalendarItemWithHcParty} instead.\n */\n modifyCalendarItem(body?: CalendarItem): never {\n throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption')\n }\n\n /**\n * Remove the following delegation objects from the\n * CalendarItem instance: cryptedForeignKeys, secretForeignKeys.\n *\n * The delegations & encryptionKeys objects are not removed because\n * in the case the CalendarItem is saved in the DB & then encrypted,\n * if later we remove the patient from it, it'd reset the delegations\n * and encryptionKeys thus impossibilitating further access.\n *\n * @param calendarItem The Calendar Item object\n */\n resetCalendarDelegationObjects(calendarItem: models.CalendarItem): models.CalendarItem {\n const { cryptedForeignKeys, secretForeignKeys, ...resetCalendarItem } = calendarItem\n return resetCalendarItem\n }\n\n /**\n * Modifies a calendar item after encrypting its content.\n * @param user the current user, used for encryption/decryption.\n * @param body the calendar item with updated fields.\n * @return the modified and decrypted calendar item, or null if body was not provided.\n */\n async modifyCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any> {\n return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, cloneDeep(body)) : null\n }\n\n private modifyAs(dataOwner: string, body: models.CalendarItem): Promise<models.CalendarItem> {\n return this.encryptAs(dataOwner, [cloneDeep(body)])\n .then((items) => super.modifyCalendarItem(items[0]))\n .then((ci) => this.decrypt(dataOwner, [ci]))\n .then((cis) => cis[0])\n }\n\n /**\n * Encrypts the encrypted fields of a list of calendar items.\n * @param user the current user, used to determine the data owner for encryption.\n * @param calendarItems the calendar items to encrypt.\n * @return the encrypted calendar items.\n */\n encrypt(user: models.User, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user)!, calendarItems)\n }\n\n private encryptAs(dataOwner: string, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return this.crypto.xapi.tryEncryptEntities(\n calendarItems,\n EntityWithDelegationTypeName.CalendarItem,\n this.encryptedFields,\n false,\n false,\n (json) => new CalendarItem(json)\n )\n }\n\n /**\n * Decrypts a list of calendar items using the current data owner's keys.\n * @param hcpId the id of the healthcare party performing the decryption.\n * @param calendarItems the calendar items to decrypt.\n * @return the decrypted calendar items.\n */\n async decrypt(hcpId: string, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>> {\n return (\n await this.crypto.xapi.tryDecryptEntities(calendarItems, EntityWithDelegationTypeName.CalendarItem, (json) => new CalendarItem(json))\n ).map(({ entity }) => entity)\n }\n\n /**\n * @param calendarItem a calendar item\n * @return the id of the patient that the calendar item 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(calendarItem: models.CalendarItem): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: calendarItem, type: EntityWithDelegationTypeName.CalendarItem }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given calendar item\n */\n async hasWriteAccess(calendarItem: models.CalendarItem): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: calendarItem, type: EntityWithDelegationTypeName.CalendarItem })\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item 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 calendar item.\n * @param calendarItem item the calendar item 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}). Note that by default a\n * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 shareWith(\n delegateId: string,\n calendarItem: models.CalendarItem,\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.CalendarItem> {\n return this.shareWithMany(calendarItem, { [delegateId]: options })\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param calendarItem item the calendar item 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 * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 calendarItem: models.CalendarItem,\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.CalendarItem> {\n return (await this.tryShareWithMany(calendarItem, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing calendar item with other data owners, allowing them to access the non-encrypted data of the calendar item and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param calendarItem item the calendar item 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 * calendar item does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this calendar item 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 tryShareWithMany(\n calendarItem: models.CalendarItem,\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.CalendarItem>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(calendarItem, EntityWithDelegationTypeName.CalendarItem)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyAs(self, entityWithEncryptionKey) : calendarItem\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.CalendarItem,\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.bulkShareCalendarItems(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given calendar item, along with their access levels.\n * @param entity the calendar item.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: CalendarItem\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.CalendarItem })\n }\n\n /**\n * Retrieves the encryption keys of the given calendar item.\n * @param entity the calendar item.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: CalendarItem): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.CalendarItem }, undefined)\n }\n\n /**\n * Adds a bidirectional link between a calendar item with a patient.\n * Note that this operation is not reversible: it is not possible to change the patient linked to a calendar\n * item.\n * @param calendarItem a calendar item\n * @param patient the patient which will be linked to the calendar item.\n * @param shareLinkWithDelegates data owners other than the current data owner which will also be able to decrypt the id of the newly linked\n * patient. If any of these data owners do not already have access to the calendar item, they will be granted read access (no write).\n * @param sfkOption specify how to create the link from the patient\n * @return the updated calendar item\n */\n async linkWithPatient(\n calendarItem: models.CalendarItem,\n patient: models.Patient,\n shareLinkWithDelegates: string[],\n sfkOption?: SecretIdUseOption\n ): Promise<models.CalendarItem> {\n if (this.hasLinkFromPatient(calendarItem)) throw new Error(`Calendar item ${calendarItem.id} is already linked to a patient`)\n const delegates = [...new Set([await this.dataOwnerApi.getCurrentDataOwnerId(), ...shareLinkWithDelegates])]\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const individualShareData = {\n shareSecretIds: [] as string[],\n shareEncryptionKeys: [] as string[],\n shareOwningEntityIds: [patient.id!],\n requestedPermissions: RequestedPermissionEnum.FULL_READ,\n }\n const shared = await this.crypto.xapi.bulkShareOrUpdateEncryptedEntityMetadata(\n EntityWithDelegationTypeName.CalendarItem,\n [\n {\n entity: calendarItem,\n dataForDelegates: Object.fromEntries(delegates.map((d) => [d, individualShareData])),\n },\n ],\n (x) => this.bulkShareCalendarItems(x)\n )\n if (!shared.updatedEntities.length || shared.updatedEntities[0].id !== calendarItem.id) {\n const errorsForEntity = shared.updateErrors.filter((e) => e.entityId === calendarItem.id)\n if (!errorsForEntity.length || !errorsForEntity.find((x) => x.code === 409)) {\n throw new Error(`Unexpected error while linking calendar item ${calendarItem.id}`)\n } else {\n throw new Error(`Outdated calendar item revision ${calendarItem.id}-${calendarItem.rev}`)\n }\n }\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n const sharedDecrypted = (await this.decrypt(self, [shared.updatedEntities[0]]))[0]\n if (sfk.length > 0) {\n return await this.modifyAs(self, { ...sharedDecrypted, secretForeignKeys: sfk })\n } else {\n return sharedDecrypted\n }\n }\n\n /**\n * Checks if a calendar item has an (encrypted) link from a patient.\n * Calendar item where this method returns false won't be findable when searching for them by patient.\n * If this method returns false there may still be a link to the patient; you can check for it by using the method\n * {@link decryptPatientIdOf}.\n *\n * Note: this method only checks the presence of a link, it doesn't verify that it is valid (for example, this method\n * doesn't check if the link from the patient matches the link to the patient).\n */\n hasLinkFromPatient(calendarItem: CalendarItem): boolean {\n return (calendarItem.secretForeignKeys ?? []).length > 0\n }\n\n /**\n * Adds a link to a calendar item allowing it to be found from the patient.\n * This method only adds a partial link; if the calendar item is not already linked to the patient you should\n * instead use the {@link linkWithPatient}\n * @param calendarItem the calendar item to update.\n * @param patient the patient to link with the calendar item.\n * @param sfkOption customize how to create the link.\n * @return the updated calendar item\n */\n async addLinkFromPatient(calendarItem: CalendarItem, patient: models.Patient, sfkOption?: SecretIdUseOption): Promise<CalendarItem> {\n if (this.hasLinkFromPatient(calendarItem)) throw new Error(`Calendar item ${calendarItem.id} is already linked to a patient`)\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n if (sfk.length > 0) {\n return await this.modifyAs(self, { ...calendarItem, secretForeignKeys: sfk })\n } else {\n return calendarItem\n }\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given calendar item, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the calendar item.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: CalendarItem, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.CalendarItem },\n delegates\n )\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param entityId the id of the calendar item to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the calendar item.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.CalendarItem>> {\n return super.getConflictsForEntity(entityId).then((cis) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), cis))\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, used to determine the data owner that will encrypt/decrypt the entity.\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.CalendarItem>\n ): Promise<models.ConflictResolutionResult<models.CalendarItem>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0]\n return result\n }\n}\n"]}
|