@icure/api 8.6.5 → 8.6.7

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.
Files changed (61) hide show
  1. package/icc-api/api/IccFormApi.d.ts +89 -0
  2. package/icc-api/api/IccFormApi.js +234 -0
  3. package/icc-api/api/IccFormApi.js.map +1 -1
  4. package/icc-x-api/icc-accesslog-x-api.d.ts +93 -0
  5. package/icc-x-api/icc-accesslog-x-api.js +93 -0
  6. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  7. package/icc-x-api/icc-calendar-item-x-api.d.ts +122 -0
  8. package/icc-x-api/icc-calendar-item-x-api.js +122 -0
  9. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  10. package/icc-x-api/icc-classification-x-api.d.ts +20 -0
  11. package/icc-x-api/icc-classification-x-api.js +20 -0
  12. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  13. package/icc-x-api/icc-code-x-api.d.ts +23 -0
  14. package/icc-x-api/icc-code-x-api.js +23 -0
  15. package/icc-x-api/icc-code-x-api.js.map +1 -1
  16. package/icc-x-api/icc-contact-x-api.d.ts +219 -1
  17. package/icc-x-api/icc-contact-x-api.js +219 -2
  18. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  19. package/icc-x-api/icc-data-owner-x-api.d.ts +14 -3
  20. package/icc-x-api/icc-data-owner-x-api.js +14 -3
  21. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  22. package/icc-x-api/icc-device-x-api.d.ts +8 -0
  23. package/icc-x-api/icc-device-x-api.js +8 -0
  24. package/icc-x-api/icc-device-x-api.js.map +1 -1
  25. package/icc-x-api/icc-doctemplate-x-api.d.ts +26 -0
  26. package/icc-x-api/icc-doctemplate-x-api.js +26 -0
  27. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  28. package/icc-x-api/icc-document-x-api.d.ts +114 -1
  29. package/icc-x-api/icc-document-x-api.js +127 -1
  30. package/icc-x-api/icc-document-x-api.js.map +1 -1
  31. package/icc-x-api/icc-form-x-api.d.ts +34 -4
  32. package/icc-x-api/icc-form-x-api.js +34 -4
  33. package/icc-x-api/icc-form-x-api.js.map +1 -1
  34. package/icc-x-api/icc-hcparty-x-api.d.ts +67 -0
  35. package/icc-x-api/icc-hcparty-x-api.js +67 -0
  36. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  37. package/icc-x-api/icc-helement-x-api.d.ts +141 -0
  38. package/icc-x-api/icc-helement-x-api.js +141 -0
  39. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  40. package/icc-x-api/icc-invoice-x-api.d.ts +54 -0
  41. package/icc-x-api/icc-invoice-x-api.js +54 -0
  42. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  43. package/icc-x-api/icc-message-x-api.d.ts +162 -0
  44. package/icc-x-api/icc-message-x-api.js +162 -0
  45. package/icc-x-api/icc-message-x-api.js.map +1 -1
  46. package/icc-x-api/icc-patient-x-api.d.ts +245 -0
  47. package/icc-x-api/icc-patient-x-api.js +245 -1
  48. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  49. package/icc-x-api/icc-receipt-x-api.d.ts +25 -0
  50. package/icc-x-api/icc-receipt-x-api.js +25 -0
  51. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  52. package/icc-x-api/icc-user-x-api.d.ts +25 -0
  53. package/icc-x-api/icc-user-x-api.js +25 -0
  54. package/icc-x-api/icc-user-x-api.js.map +1 -1
  55. package/package.json +1 -1
  56. package/test/icc-x-api/icc-form-x-api.js +316 -1
  57. package/test/icc-x-api/icc-form-x-api.js.map +1 -1
  58. package/test/utils/roles.js +5 -0
  59. package/test/utils/roles.js.map +1 -1
  60. package/test/utils/test_utils.js +1 -21
  61. package/test/utils/test_utils.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"icc-accesslog-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-accesslog-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AA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,EACxD,SAAS,CACV,CAAA;IACH,CAAC;CACF;AA7dD,4CA6dC","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 * as _ from 'lodash'\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!, _.uniq(extractedKeys))\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, _.uniq(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, _.uniq(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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 getEncryptionKeysOf(entity: AccessLog): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.AccessLog }, undefined)\n }\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,4BAA2B;AAE3B,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,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EACb,cAAuB,EACxC,WAAW,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,EACpC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QATtC,mBAAc,GAAd,cAAc,CAAS;QAUxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,eAAe,GAAG,IAAA,4BAAoB,EAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IACxE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACG,WAAW;6DACf,IAAiB,EACjB,O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CAA4B,CAAC,SAAS,EAAE,CAAC,CAAA;IACnI,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,MAAiB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,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 * as _ from 'lodash'\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!, _.uniq(extractedKeys))\n : this.findByHCPartyPatientSecretFKeys(hcpartyId!, _.uniq(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, _.uniq(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"]}
@@ -24,6 +24,14 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
24
24
  constructor(host: string, headers: {
25
25
  [key: string]: string;
26
26
  }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, encryptedKeys?: Array<string>, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
27
+ /**
28
+ * Creates a new instance of calendar item with initialised encryption metadata (not in the database), without
29
+ * linking it to a patient. Use {@link newInstancePatient} to create a calendar item linked to a patient.
30
+ * @param user the current user.
31
+ * @param ci initialised data for the calendar item.
32
+ * @param options optional parameters for delegates and root delegation.
33
+ * @return a new instance of calendar item.
34
+ */
27
35
  newInstance(user: User, ci: any | CalendarItem, options?: {
28
36
  additionalDelegates?: {
29
37
  [dataOwnerId: string]: AccessLevelEnum;
@@ -70,30 +78,110 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
70
78
  * @deprecated use {@link findCalendarItemIdsByDataOwnerPatientStartTime} instead.
71
79
  */
72
80
  findByHCPartyPatientSecretFKeysArray(hcPartyId: string, secretFKeys: string[]): Promise<Array<models.CalendarItem> | any>;
81
+ /**
82
+ * @throws always. Use {@link createCalendarItemWithHcParty} instead.
83
+ */
73
84
  createCalendarItem(body?: CalendarItem): never;
85
+ /**
86
+ * Creates a calendar item after encrypting its content.
87
+ * @param user the current user, used for encryption.
88
+ * @param body the calendar item to create.
89
+ * @return the created and decrypted calendar item.
90
+ */
74
91
  createCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any>;
92
+ /**
93
+ * Retrieves a calendar item by id and decrypts it.
94
+ * @param user the current user, used for decryption.
95
+ * @param calendarItemId the id of the calendar item to retrieve.
96
+ * @return the decrypted calendar item.
97
+ */
75
98
  getCalendarItemWithUser(user: models.User, calendarItemId: string): Promise<CalendarItem | any>;
99
+ /**
100
+ * @throws always. Use {@link getCalendarItemWithUser} instead.
101
+ */
76
102
  getCalendarItem(calendarItemId: string): never;
77
103
  /**
78
104
  * @deprecated use {@link getCalendarItemsWithPaginationWithUser} instead.
79
105
  */
80
106
  getCalendarItemsWithUser(user: models.User): Promise<Array<CalendarItem> | any>;
107
+ /**
108
+ * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.
109
+ */
81
110
  getCalendarItems(): never;
111
+ /**
112
+ * Retrieves calendar items with pagination and decrypts them.
113
+ * @param user the current user, used for decryption.
114
+ * @param startDocumentId the pagination start document id.
115
+ * @param limit the maximum number of results to return.
116
+ * @return a paginated list of decrypted calendar items.
117
+ */
82
118
  getCalendarItemsWithPaginationWithUser(user: models.User, startDocumentId?: string, limit?: number): Promise<PaginatedListCalendarItem>;
119
+ /**
120
+ * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.
121
+ */
83
122
  getCalendarItemsWithPagination(startDocumentId?: string, limit?: number): never;
84
123
  /**
85
124
  * @deprecated use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.
86
125
  */
87
126
  findCalendarItemsByRecurrenceIdWithUser(user: models.User, recurrenceId: string): Promise<Array<CalendarItem> | any>;
127
+ /**
128
+ * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.
129
+ */
88
130
  findCalendarItemsByRecurrenceId(recurrenceId: string): never;
131
+ /**
132
+ * Finds calendar items by recurrence id with pagination and decrypts them.
133
+ * @param user the current user, used for decryption.
134
+ * @param recurrenceId the recurrence id to search for.
135
+ * @param startKey the pagination start key.
136
+ * @param startDocumentId the pagination start document id.
137
+ * @param limit the maximum number of results to return.
138
+ * @return a paginated list of decrypted calendar items matching the recurrence id.
139
+ */
89
140
  findCalendarItemsByRecurrenceIdWithPaginationWithUser(user: models.User, recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListCalendarItem>;
141
+ /**
142
+ * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.
143
+ */
90
144
  findCalendarItemsByRecurrenceIdWithPagination(recurrenceId: string, startKey?: string, startDocumentId?: string, limit?: number): never;
145
+ /**
146
+ * Retrieves multiple calendar items by their ids and decrypts them.
147
+ * @param user the current user, used for decryption.
148
+ * @param body the list of calendar item ids to retrieve.
149
+ * @return the decrypted calendar items.
150
+ */
91
151
  getCalendarItemsWithIdsWithUser(user: models.User, body?: models.ListOfIds): Promise<Array<CalendarItem> | any>;
152
+ /**
153
+ * @throws always. Use {@link getCalendarItemsWithIdsWithUser} instead.
154
+ */
92
155
  getCalendarItemsWithIds(body?: models.ListOfIds): never;
156
+ /**
157
+ * Retrieves calendar items for a given healthcare party within a date range and decrypts them.
158
+ * @param user the current user, used for decryption.
159
+ * @param startDate the start of the date range.
160
+ * @param endDate the end of the date range.
161
+ * @param hcPartyId the id of the healthcare party.
162
+ * @return the decrypted calendar items.
163
+ */
93
164
  getCalendarItemsByPeriodAndHcPartyIdWithUser(user: models.User, startDate: number, endDate: number, hcPartyId: string): Promise<Array<CalendarItem> | any>;
165
+ /**
166
+ * @throws always. Use {@link getCalendarItemsByPeriodAndHcPartyIdWithUser} instead.
167
+ */
94
168
  getCalendarItemsByPeriodAndHcPartyId(startDate?: number, endDate?: number, hcPartyId?: string): never;
169
+ /**
170
+ * Retrieves calendar items for a given agenda within a date range and decrypts them.
171
+ * @param user the current user, used for decryption.
172
+ * @param startDate the start of the date range.
173
+ * @param endDate the end of the date range.
174
+ * @param agendaId the id of the agenda.
175
+ * @return the decrypted calendar items.
176
+ */
95
177
  getCalendarsByPeriodAndAgendaIdWithUser(user: models.User, startDate: number, endDate: number, agendaId: string): Promise<Array<CalendarItem> | any>;
178
+ /**
179
+ * @throws always. Use {@link getCalendarsByPeriodAndAgendaIdWithUser} instead.
180
+ */
96
181
  getCalendarsByPeriodAndAgendaId(startDate?: number, endDate?: number, agendaId?: string): never;
182
+ /**
183
+ * @throws always. Use {@link modifyCalendarItemWithHcParty} instead.
184
+ */
97
185
  modifyCalendarItem(body?: CalendarItem): never;
98
186
  /**
99
187
  * Remove the following delegation objects from the
@@ -107,10 +195,28 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
107
195
  * @param calendarItem The Calendar Item object
108
196
  */
109
197
  resetCalendarDelegationObjects(calendarItem: models.CalendarItem): models.CalendarItem;
198
+ /**
199
+ * Modifies a calendar item after encrypting its content.
200
+ * @param user the current user, used for encryption/decryption.
201
+ * @param body the calendar item with updated fields.
202
+ * @return the modified and decrypted calendar item, or null if body was not provided.
203
+ */
110
204
  modifyCalendarItemWithHcParty(user: models.User, body?: models.CalendarItem): Promise<models.CalendarItem | any>;
111
205
  private modifyAs;
206
+ /**
207
+ * Encrypts the encrypted fields of a list of calendar items.
208
+ * @param user the current user, used to determine the data owner for encryption.
209
+ * @param calendarItems the calendar items to encrypt.
210
+ * @return the encrypted calendar items.
211
+ */
112
212
  encrypt(user: models.User, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>>;
113
213
  private encryptAs;
214
+ /**
215
+ * Decrypts a list of calendar items using the current data owner's keys.
216
+ * @param hcpId the id of the healthcare party performing the decryption.
217
+ * @param calendarItems the calendar items to decrypt.
218
+ * @return the decrypted calendar items.
219
+ */
114
220
  decrypt(hcpId: string, calendarItems: Array<models.CalendarItem>): Promise<Array<models.CalendarItem>>;
115
221
  /**
116
222
  * @param calendarItem a calendar item
@@ -188,12 +294,22 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
188
294
  sharePatientId?: ShareMetadataBehaviour;
189
295
  };
190
296
  }): Promise<ShareResult<models.CalendarItem>>;
297
+ /**
298
+ * Retrieves the data owners that have access to the given calendar item, along with their access levels.
299
+ * @param entity the calendar item.
300
+ * @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.
301
+ */
191
302
  getDataOwnersWithAccessTo(entity: CalendarItem): Promise<{
192
303
  permissionsByDataOwnerId: {
193
304
  [p: string]: AccessLevelEnum;
194
305
  };
195
306
  hasUnknownAnonymousDataOwners: boolean;
196
307
  }>;
308
+ /**
309
+ * Retrieves the encryption keys of the given calendar item.
310
+ * @param entity the calendar item.
311
+ * @return the encryption key ids.
312
+ */
197
313
  getEncryptionKeysOf(entity: CalendarItem): Promise<string[]>;
198
314
  /**
199
315
  * Adds a bidirectional link between a calendar item with a patient.
@@ -227,5 +343,11 @@ export declare class IccCalendarItemXApi extends IccCalendarItemApi implements E
227
343
  * @return the updated calendar item
228
344
  */
229
345
  addLinkFromPatient(calendarItem: CalendarItem, patient: models.Patient, sfkOption?: SecretIdUseOption): Promise<CalendarItem>;
346
+ /**
347
+ * Creates or updates de-anonymization metadata for the given calendar item, allowing the specified delegates to
348
+ * identify the data owners that have access to it.
349
+ * @param entity the calendar item.
350
+ * @param delegates the data owner ids for which to create de-anonymization metadata.
351
+ */
230
352
  createDelegationDeAnonymizationMetadata(entity: CalendarItem, delegates: string[]): Promise<void>;
231
353
  }
@@ -49,6 +49,14 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
49
49
  this.dataOwnerApi = dataOwnerApi;
50
50
  this.encryptedFields = (0, utils_1.parseEncryptedFields)(encryptedKeys, 'CalendarItem.');
51
51
  }
52
+ /**
53
+ * Creates a new instance of calendar item with initialised encryption metadata (not in the database), without
54
+ * linking it to a patient. Use {@link newInstancePatient} to create a calendar item linked to a patient.
55
+ * @param user the current user.
56
+ * @param ci initialised data for the calendar item.
57
+ * @param options optional parameters for delegates and root delegation.
58
+ * @return a new instance of calendar item.
59
+ */
52
60
  newInstance(user, ci, options = {}) {
53
61
  return this.newInstancePatient(user, null, ci, options);
54
62
  }
@@ -130,9 +138,18 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
130
138
  .findCalendarItemsByHCPartyPatientForeignKeysUsingPost(hcPartyId, secretFKeys)
131
139
  .then((calendarItems) => this.decrypt(hcPartyId, calendarItems));
132
140
  }
141
+ /**
142
+ * @throws always. Use {@link createCalendarItemWithHcParty} instead.
143
+ */
133
144
  createCalendarItem(body) {
134
145
  throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption');
135
146
  }
147
+ /**
148
+ * Creates a calendar item after encrypting its content.
149
+ * @param user the current user, used for encryption.
150
+ * @param body the calendar item to create.
151
+ * @return the created and decrypted calendar item.
152
+ */
136
153
  createCalendarItemWithHcParty(user, body) {
137
154
  const _super = Object.create(null, {
138
155
  createCalendarItem: { get: () => super.createCalendarItem }
@@ -146,12 +163,21 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
146
163
  : null;
147
164
  });
148
165
  }
166
+ /**
167
+ * Retrieves a calendar item by id and decrypts it.
168
+ * @param user the current user, used for decryption.
169
+ * @param calendarItemId the id of the calendar item to retrieve.
170
+ * @return the decrypted calendar item.
171
+ */
149
172
  getCalendarItemWithUser(user, calendarItemId) {
150
173
  return super
151
174
  .getCalendarItem(calendarItemId)
152
175
  .then((calendarItem) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [calendarItem]))
153
176
  .then((cis) => cis[0]);
154
177
  }
178
+ /**
179
+ * @throws always. Use {@link getCalendarItemWithUser} instead.
180
+ */
155
181
  getCalendarItem(calendarItemId) {
156
182
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
157
183
  }
@@ -166,9 +192,19 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
166
192
  return _super.getCalendarItems.call(this).then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems));
167
193
  });
168
194
  }
195
+ /**
196
+ * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.
197
+ */
169
198
  getCalendarItems() {
170
199
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
171
200
  }
201
+ /**
202
+ * Retrieves calendar items with pagination and decrypts them.
203
+ * @param user the current user, used for decryption.
204
+ * @param startDocumentId the pagination start document id.
205
+ * @param limit the maximum number of results to return.
206
+ * @return a paginated list of decrypted calendar items.
207
+ */
172
208
  getCalendarItemsWithPaginationWithUser(user, startDocumentId, limit) {
173
209
  const _super = Object.create(null, {
174
210
  getCalendarItemsWithPagination: { get: () => super.getCalendarItemsWithPagination }
@@ -183,6 +219,9 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
183
219
  });
184
220
  });
185
221
  }
222
+ /**
223
+ * @throws always. Use {@link getCalendarItemsWithPaginationWithUser} instead.
224
+ */
186
225
  getCalendarItemsWithPagination(startDocumentId, limit) {
187
226
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
188
227
  }
@@ -198,9 +237,21 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
198
237
  .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems));
199
238
  });
200
239
  }
240
+ /**
241
+ * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.
242
+ */
201
243
  findCalendarItemsByRecurrenceId(recurrenceId) {
202
244
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
203
245
  }
246
+ /**
247
+ * Finds calendar items by recurrence id with pagination and decrypts them.
248
+ * @param user the current user, used for decryption.
249
+ * @param recurrenceId the recurrence id to search for.
250
+ * @param startKey the pagination start key.
251
+ * @param startDocumentId the pagination start document id.
252
+ * @param limit the maximum number of results to return.
253
+ * @return a paginated list of decrypted calendar items matching the recurrence id.
254
+ */
204
255
  findCalendarItemsByRecurrenceIdWithPaginationWithUser(user, recurrenceId, startKey, startDocumentId, limit) {
205
256
  const _super = Object.create(null, {
206
257
  findCalendarItemsByRecurrenceIdWithPagination: { get: () => super.findCalendarItemsByRecurrenceIdWithPagination }
@@ -215,31 +266,68 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
215
266
  });
216
267
  });
217
268
  }
269
+ /**
270
+ * @throws always. Use {@link findCalendarItemsByRecurrenceIdWithPaginationWithUser} instead.
271
+ */
218
272
  findCalendarItemsByRecurrenceIdWithPagination(recurrenceId, startKey, startDocumentId, limit) {
219
273
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
220
274
  }
275
+ /**
276
+ * Retrieves multiple calendar items by their ids and decrypts them.
277
+ * @param user the current user, used for decryption.
278
+ * @param body the list of calendar item ids to retrieve.
279
+ * @return the decrypted calendar items.
280
+ */
221
281
  getCalendarItemsWithIdsWithUser(user, body) {
222
282
  return super.getCalendarItemsWithIds(body).then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems));
223
283
  }
284
+ /**
285
+ * @throws always. Use {@link getCalendarItemsWithIdsWithUser} instead.
286
+ */
224
287
  getCalendarItemsWithIds(body) {
225
288
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
226
289
  }
290
+ /**
291
+ * Retrieves calendar items for a given healthcare party within a date range and decrypts them.
292
+ * @param user the current user, used for decryption.
293
+ * @param startDate the start of the date range.
294
+ * @param endDate the end of the date range.
295
+ * @param hcPartyId the id of the healthcare party.
296
+ * @return the decrypted calendar items.
297
+ */
227
298
  getCalendarItemsByPeriodAndHcPartyIdWithUser(user, startDate, endDate, hcPartyId) {
228
299
  return super
229
300
  .getCalendarItemsByPeriodAndHcPartyId(startDate, endDate, hcPartyId)
230
301
  .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems));
231
302
  }
303
+ /**
304
+ * @throws always. Use {@link getCalendarItemsByPeriodAndHcPartyIdWithUser} instead.
305
+ */
232
306
  getCalendarItemsByPeriodAndHcPartyId(startDate, endDate, hcPartyId) {
233
307
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
234
308
  }
309
+ /**
310
+ * Retrieves calendar items for a given agenda within a date range and decrypts them.
311
+ * @param user the current user, used for decryption.
312
+ * @param startDate the start of the date range.
313
+ * @param endDate the end of the date range.
314
+ * @param agendaId the id of the agenda.
315
+ * @return the decrypted calendar items.
316
+ */
235
317
  getCalendarsByPeriodAndAgendaIdWithUser(user, startDate, endDate, agendaId) {
236
318
  return super
237
319
  .getCalendarsByPeriodAndAgendaId(startDate, endDate, agendaId)
238
320
  .then((calendarItems) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems));
239
321
  }
322
+ /**
323
+ * @throws always. Use {@link getCalendarsByPeriodAndAgendaIdWithUser} instead.
324
+ */
240
325
  getCalendarsByPeriodAndAgendaId(startDate, endDate, agendaId) {
241
326
  throw new Error('Cannot call a method that must en/decrypt a calendar item without providing a user for de/encryption');
242
327
  }
328
+ /**
329
+ * @throws always. Use {@link modifyCalendarItemWithHcParty} instead.
330
+ */
243
331
  modifyCalendarItem(body) {
244
332
  throw new Error('Cannot call a method that must encrypt a calendar item without providing a user for de/encryption');
245
333
  }
@@ -258,6 +346,12 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
258
346
  const { cryptedForeignKeys, secretForeignKeys } = calendarItem, resetCalendarItem = __rest(calendarItem, ["cryptedForeignKeys", "secretForeignKeys"]);
259
347
  return resetCalendarItem;
260
348
  }
349
+ /**
350
+ * Modifies a calendar item after encrypting its content.
351
+ * @param user the current user, used for encryption/decryption.
352
+ * @param body the calendar item with updated fields.
353
+ * @return the modified and decrypted calendar item, or null if body was not provided.
354
+ */
261
355
  modifyCalendarItemWithHcParty(user, body) {
262
356
  return __awaiter(this, void 0, void 0, function* () {
263
357
  return body ? this.modifyAs(this.dataOwnerApi.getDataOwnerIdOf(user), _.cloneDeep(body)) : null;
@@ -269,12 +363,24 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
269
363
  .then((ci) => this.decrypt(dataOwner, [ci]))
270
364
  .then((cis) => cis[0]);
271
365
  }
366
+ /**
367
+ * Encrypts the encrypted fields of a list of calendar items.
368
+ * @param user the current user, used to determine the data owner for encryption.
369
+ * @param calendarItems the calendar items to encrypt.
370
+ * @return the encrypted calendar items.
371
+ */
272
372
  encrypt(user, calendarItems) {
273
373
  return this.encryptAs(this.dataOwnerApi.getDataOwnerIdOf(user), calendarItems);
274
374
  }
275
375
  encryptAs(dataOwner, calendarItems) {
276
376
  return this.crypto.xapi.tryEncryptEntities(calendarItems, utils_1.EntityWithDelegationTypeName.CalendarItem, this.encryptedFields, false, false, (json) => new models_1.CalendarItem(json));
277
377
  }
378
+ /**
379
+ * Decrypts a list of calendar items using the current data owner's keys.
380
+ * @param hcpId the id of the healthcare party performing the decryption.
381
+ * @param calendarItems the calendar items to decrypt.
382
+ * @return the decrypted calendar items.
383
+ */
278
384
  decrypt(hcpId, calendarItems) {
279
385
  return __awaiter(this, void 0, void 0, function* () {
280
386
  return (yield this.crypto.xapi.tryDecryptEntities(calendarItems, utils_1.EntityWithDelegationTypeName.CalendarItem, (json) => new models_1.CalendarItem(json))).map(({ entity }) => entity);
@@ -374,9 +480,19 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
374
480
  .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])));
375
481
  });
376
482
  }
483
+ /**
484
+ * Retrieves the data owners that have access to the given calendar item, along with their access levels.
485
+ * @param entity the calendar item.
486
+ * @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.
487
+ */
377
488
  getDataOwnersWithAccessTo(entity) {
378
489
  return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.CalendarItem });
379
490
  }
491
+ /**
492
+ * Retrieves the encryption keys of the given calendar item.
493
+ * @param entity the calendar item.
494
+ * @return the encryption key ids.
495
+ */
380
496
  getEncryptionKeysOf(entity) {
381
497
  return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.CalendarItem }, undefined);
382
498
  }
@@ -464,6 +580,12 @@ class IccCalendarItemXApi extends icc_api_1.IccCalendarItemApi {
464
580
  }
465
581
  });
466
582
  }
583
+ /**
584
+ * Creates or updates de-anonymization metadata for the given calendar item, allowing the specified delegates to
585
+ * identify the data owners that have access to it.
586
+ * @param entity the calendar item.
587
+ * @param delegates the data owner ids for which to create de-anonymization metadata.
588
+ */
467
589
  createDelegationDeAnonymizationMetadata(entity, delegates) {
468
590
  return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.CalendarItem }, delegates);
469
591
  }