@icure/api 8.1.8 → 8.2.0
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/model/RouteOfAdministration.d.ts +0 -1
- package/icc-api/model/RouteOfAdministration.js.map +1 -1
- package/icc-api/model/Vmp.d.ts +0 -2
- package/icc-api/model/Vmp.js.map +1 -1
- package/icc-api/model/VmpGroup.d.ts +0 -2
- package/icc-api/model/VmpGroup.js.map +1 -1
- package/icc-api/model/internal/ExchangeData.d.ts +1 -1
- package/icc-api/model/internal/ExchangeData.js +1 -7
- package/icc-api/model/internal/ExchangeData.js.map +1 -1
- package/icc-x-api/crypto/BaseExchangeDataManager.d.ts +19 -9
- package/icc-x-api/crypto/BaseExchangeDataManager.js +27 -6
- package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +2 -1
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/DelegationsDeAnonymization.js +1 -1
- package/icc-x-api/crypto/DelegationsDeAnonymization.js.map +1 -1
- package/icc-x-api/crypto/ExchangeDataManager.d.ts +25 -2
- package/icc-x-api/crypto/ExchangeDataManager.js +98 -5
- package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtils.d.ts +3 -1
- package/icc-x-api/crypto/ExtendedApisUtils.js.map +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.d.ts +1 -1
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +3 -3
- package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
- package/icc-x-api/crypto/SecureDelegationsManager.d.ts +3 -1
- package/icc-x-api/crypto/SecureDelegationsManager.js +10 -6
- package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.js +1 -1
- package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +4 -0
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/crypto/utils.js +1 -1
- package/icc-x-api/crypto/utils.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +6 -0
- package/icc-x-api/icc-accesslog-x-api.js +6 -2
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +4 -0
- package/icc-x-api/icc-calendar-item-x-api.js +3 -1
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +3 -0
- package/icc-x-api/icc-classification-x-api.js +3 -1
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +3 -0
- package/icc-x-api/icc-contact-x-api.js +3 -1
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-crypto-x-api.d.ts +29 -0
- package/icc-x-api/icc-crypto-x-api.js +36 -0
- package/icc-x-api/icc-crypto-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +3 -0
- package/icc-x-api/icc-document-x-api.js +3 -1
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +3 -0
- package/icc-x-api/icc-form-x-api.js +3 -1
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +3 -0
- package/icc-x-api/icc-helement-x-api.js +3 -1
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +3 -0
- package/icc-x-api/icc-invoice-x-api.js +3 -1
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.d.ts +3 -0
- package/icc-x-api/icc-maintenance-task-x-api.js +3 -1
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +3 -0
- package/icc-x-api/icc-message-x-api.js +3 -1
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +3 -0
- package/icc-x-api/icc-patient-x-api.js +6 -2
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +3 -0
- package/icc-x-api/icc-receipt-x-api.js +3 -1
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-recovery-x-api.js +8 -1
- package/icc-x-api/icc-recovery-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +3 -0
- package/icc-x-api/icc-time-table-x-api.js +3 -1
- package/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.d.ts +3 -0
- package/icc-x-api/icc-topic-x-api.js +3 -1
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +16 -0
- package/icc-x-api/index.js +7 -1
- package/icc-x-api/index.js.map +1 -1
- package/icc-x-api/utils/websocket.d.ts +1 -0
- package/package.json +1 -1
- package/test/icc-x-api/autofix-anonymity-test.js +18 -4
- package/test/icc-x-api/autofix-anonymity-test.js.map +1 -1
- package/test/icc-x-api/crypto/exchange-data-manager-test.js +34 -32
- package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -1
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js +2 -2
- package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -1
- package/test/icc-x-api/icc-hcparty-x-api-test.js +2 -14
- package/test/icc-x-api/icc-hcparty-x-api-test.js.map +1 -1
- package/test/icc-x-api/keyless-api.d.ts +1 -0
- package/test/icc-x-api/keyless-api.js +125 -0
- package/test/icc-x-api/keyless-api.js.map +1 -0
- package/test/utils/FakeExchangeDataManager.d.ts +8 -0
- package/test/utils/FakeExchangeDataManager.js +3 -0
- package/test/utils/FakeExchangeDataManager.js.map +1 -1
- package/test/utils/KeylessCryptoStrategies.d.ts +23 -0
- package/test/utils/KeylessCryptoStrategies.js +26 -0
- package/test/utils/KeylessCryptoStrategies.js.map +1 -0
- package/test/utils/test_utils.d.ts +7 -0
- package/test/utils/test_utils.js +30 -1
- package/test/utils/test_utils.js.map +1 -1
|
@@ -32,6 +32,8 @@ export declare class IccClassificationXApi extends IccClassificationApi implemen
|
|
|
32
32
|
* auto-delegations, in such case the access level specified here will be used.
|
|
33
33
|
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
34
34
|
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
35
|
+
* - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
|
|
36
|
+
* and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
|
|
35
37
|
* @return a new instance of classification.
|
|
36
38
|
*/
|
|
37
39
|
newInstance(user: models.User, patient: models.Patient, c?: any, options?: {
|
|
@@ -39,6 +41,7 @@ export declare class IccClassificationXApi extends IccClassificationApi implemen
|
|
|
39
41
|
[dataOwnerId: string]: AccessLevelEnum;
|
|
40
42
|
};
|
|
41
43
|
sfkOption?: SecretIdUseOption;
|
|
44
|
+
alternateRootDelegation?: string;
|
|
42
45
|
}): Promise<models.Classification>;
|
|
43
46
|
/**
|
|
44
47
|
* @deprecated use {@link findIdsBy} instead.
|
|
@@ -45,6 +45,8 @@ class IccClassificationXApi extends icc_api_1.IccClassificationApi {
|
|
|
45
45
|
* auto-delegations, in such case the access level specified here will be used.
|
|
46
46
|
* - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a
|
|
47
47
|
* secret id of patient known by the topmost parent in the current data owner hierarchy.
|
|
48
|
+
* - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
|
|
49
|
+
* and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
|
|
48
50
|
* @return a new instance of classification.
|
|
49
51
|
*/
|
|
50
52
|
newInstance(user, patient, c = {}, options = {}) {
|
|
@@ -57,7 +59,7 @@ class IccClassificationXApi extends icc_api_1.IccClassificationApi {
|
|
|
57
59
|
const sfk = yield this.crypto.xapi.resolveSecretIdUseOptions({ entity: patient, type: utils_1.EntityWithDelegationTypeName.Patient }, (_k = options.sfkOption) !== null && _k !== void 0 ? _k : SecretIdUseOption_1.SecretIdUseOption.UseAnySharedWithParent);
|
|
58
60
|
const extraDelegations = Object.assign(Object.assign({}, Object.fromEntries([...((_m = (_l = user.autoDelegations) === null || _l === void 0 ? void 0 : _l.all) !== null && _m !== void 0 ? _m : []), ...((_p = (_o = user.autoDelegations) === null || _o === void 0 ? void 0 : _o.medicalInformation) !== null && _p !== void 0 ? _p : [])].map((d) => [d, AccessLevelEnum.WRITE]))), ((_q = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _q !== void 0 ? _q : {}));
|
|
59
61
|
return new models.Classification(yield this.crypto.xapi
|
|
60
|
-
.entityWithInitialisedEncryptedMetadata(classification, utils_1.EntityWithDelegationTypeName.Classification, patient === null || patient === void 0 ? void 0 : patient.id, sfk, true, extraDelegations)
|
|
62
|
+
.entityWithInitialisedEncryptedMetadata(classification, utils_1.EntityWithDelegationTypeName.Classification, patient === null || patient === void 0 ? void 0 : patient.id, sfk, true, extraDelegations, options.alternateRootDelegation)
|
|
61
63
|
.then((x) => x.updatedEntity));
|
|
62
64
|
});
|
|
63
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;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AC,CACxC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAA6B;QAE7B,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,CAAC,CAAA;IACxI,CAAC;IAED,mBAAmB,CAAC,MAA6B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAA;IACpH,CAAC;IAED,uCAAuC,CAAC,MAA6B,EAAE,SAAmB;QACxF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAC7D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAjPD,sDAiPC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { EntityWithDelegationTypeName } from './utils'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\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.Classification))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\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 }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. 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 classification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(moment().format('YYYYMMDDHHmmss')),\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 ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(classification, EntityWithDelegationTypeName.Classification, patient?.id, sfk, true, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @deprecated use {@link findIdsBy} instead.\n */\n async findBy(hcpartyId: string, patient: models.Patient) {\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 ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean) {\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 ? this.findClassificationIdsByDataOwnerPatientCreated(topmostParentId, _.uniq(extractedKeys), startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification 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(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification 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 classification.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\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.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification 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 classification: models.Classification,\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.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\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.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n classification,\n EntityWithDelegationTypeName.Classification\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Classification,\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.bulkShareClassifications(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Classification })\n }\n\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.Classification },\n delegates\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;AACtD,kEAA8D;AAE9D,MAAa,qBAAsB,SAAQ,8BAAoB;IAI7D,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,cAAc,CAAC,CAAC,CAAA;IACpJ,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,YAA8B,EACb,cAAuB,EACxC,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;QARtC,mBAAc,GAAd,cAAc,CAAS;QASxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACG,WAAW,CACf,IAAiB,EACjB,OAAuB,EACvB,IAAS,EAAE,EACX,UAII,EAAE;;;YAEN,MAAM,cAAc,mCACf,CAAC,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAC,KACZ,KAAK,EAAE,0C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,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;gBACvD,UAAU;gBACV;oBACE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;oBAClD,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;oBAC/C,oBAAoB,EAAE,OAAO,CAAC,cAAc;oBAC5C,cAAc,EAAE,OAAO,CAAC,cAAc;iBACvC;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CACxC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAA6B;QAE7B,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,CAAC,CAAA;IACxI,CAAC;IAED,mBAAmB,CAAC,MAA6B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAA;IACpH,CAAC;IAED,uCAAuC,CAAC,MAA6B,EAAE,SAAmB;QACxF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,cAAc,EAAE,EAC7D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AA5PD,sDA4PC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { EntityWithDelegationTypeName } from './utils'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\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.Classification))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\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 }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. 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 classification. 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 classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(moment().format('YYYYMMDDHHmmss')),\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 ...Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.medicalInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n ),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n classification,\n EntityWithDelegationTypeName.Classification,\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) {\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 ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean) {\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 ? this.findClassificationIdsByDataOwnerPatientCreated(topmostParentId, _.uniq(extractedKeys), startDate, endDate, descending)\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification 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(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification 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 classification.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\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.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification 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 classification: models.Classification,\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.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification 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 * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\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.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n classification,\n EntityWithDelegationTypeName.Classification\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Classification,\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.bulkShareClassifications(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Classification })\n }\n\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.Classification },\n delegates\n )\n }\n}\n"]}
|
|
@@ -47,6 +47,8 @@ export declare class IccContactXApi extends IccContactApi implements EncryptedEn
|
|
|
47
47
|
* the data owner did not share with any of his parents.
|
|
48
48
|
* - confidential: if true, the entity will be created as confidential. Confidential entities are not shared with auto-delegations, and the default
|
|
49
49
|
* foreign key used is any key that is not shared with any of the data owner parents. By default entities are created as non-confidential.
|
|
50
|
+
* - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
|
|
51
|
+
* and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
|
|
50
52
|
* @return a new instance of contact.
|
|
51
53
|
*/
|
|
52
54
|
newInstance(user: models.User, patient: models.Patient, c: any, options?: {
|
|
@@ -55,6 +57,7 @@ export declare class IccContactXApi extends IccContactApi implements EncryptedEn
|
|
|
55
57
|
};
|
|
56
58
|
sfkOption?: SecretIdUseOption;
|
|
57
59
|
ignoreAutoDelegations?: boolean;
|
|
60
|
+
alternateRootDelegation?: string;
|
|
58
61
|
}): Promise<models.Contact>;
|
|
59
62
|
/**
|
|
60
63
|
* 1. Check whether there is a delegation with 'hcpartyId' or not.
|
|
@@ -72,6 +72,8 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
72
72
|
* the data owner did not share with any of his parents.
|
|
73
73
|
* - confidential: if true, the entity will be created as confidential. Confidential entities are not shared with auto-delegations, and the default
|
|
74
74
|
* foreign key used is any key that is not shared with any of the data owner parents. By default entities are created as non-confidential.
|
|
75
|
+
* - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
|
|
76
|
+
* and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
|
|
75
77
|
* @return a new instance of contact.
|
|
76
78
|
*/
|
|
77
79
|
newInstance(user, patient, c, options = {}) {
|
|
@@ -85,7 +87,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
|
|
|
85
87
|
const extraDelegations = Object.assign(Object.assign({}, (options.ignoreAutoDelegations
|
|
86
88
|
? {}
|
|
87
89
|
: Object.fromEntries([...((_p = (_o = user.autoDelegations) === null || _o === void 0 ? void 0 : _o.all) !== null && _p !== void 0 ? _p : []), ...((_r = (_q = user.autoDelegations) === null || _q === void 0 ? void 0 : _q.medicalInformation) !== null && _r !== void 0 ? _r : [])].map((d) => [d, AccessLevelEnum.WRITE])))), ((_s = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _s !== void 0 ? _s : {}));
|
|
88
|
-
const initialisationInfo = yield this.crypto.xapi.entityWithInitialisedEncryptedMetadata(contact, utils_1.EntityWithDelegationTypeName.Contact, patient.id, sfk, true, extraDelegations);
|
|
90
|
+
const initialisationInfo = yield this.crypto.xapi.entityWithInitialisedEncryptedMetadata(contact, utils_1.EntityWithDelegationTypeName.Contact, patient.id, sfk, true, extraDelegations, options.alternateRootDelegation);
|
|
89
91
|
return new models.Contact(initialisationInfo.updatedEntity);
|
|
90
92
|
});
|
|
91
93
|
}
|