@icure/api 8.6.5 → 8.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccFormApi.d.ts +81 -0
- package/icc-api/api/IccFormApi.js +213 -0
- package/icc-api/api/IccFormApi.js.map +1 -1
- package/icc-api/model/CryptoActorStub.d.ts +0 -2
- package/icc-api/model/CryptoActorStub.js.map +1 -1
- package/icc-api/model/Device.d.ts +0 -1
- package/icc-api/model/Device.js.map +1 -1
- package/icc-api/model/HealthcareParty.d.ts +0 -1
- package/icc-api/model/HealthcareParty.js.map +1 -1
- package/icc-api/model/Patient.d.ts +0 -1
- package/icc-api/model/Patient.js.map +1 -1
- package/icc-x-api/crypto/CryptoStrategies.d.ts +1 -2
- package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
- package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -2
- package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.d.ts +93 -0
- package/icc-x-api/icc-accesslog-x-api.js +93 -0
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-calendar-item-x-api.d.ts +122 -0
- package/icc-x-api/icc-calendar-item-x-api.js +122 -0
- package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.d.ts +20 -0
- package/icc-x-api/icc-classification-x-api.js +20 -0
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-code-x-api.d.ts +23 -0
- package/icc-x-api/icc-code-x-api.js +23 -0
- package/icc-x-api/icc-code-x-api.js.map +1 -1
- package/icc-x-api/icc-contact-x-api.d.ts +219 -1
- package/icc-x-api/icc-contact-x-api.js +219 -2
- package/icc-x-api/icc-contact-x-api.js.map +1 -1
- package/icc-x-api/icc-data-owner-x-api.d.ts +14 -3
- package/icc-x-api/icc-data-owner-x-api.js +14 -3
- package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
- package/icc-x-api/icc-device-x-api.d.ts +8 -0
- package/icc-x-api/icc-device-x-api.js +8 -0
- package/icc-x-api/icc-device-x-api.js.map +1 -1
- package/icc-x-api/icc-doctemplate-x-api.d.ts +26 -0
- package/icc-x-api/icc-doctemplate-x-api.js +26 -0
- package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +114 -1
- package/icc-x-api/icc-document-x-api.js +127 -1
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.d.ts +34 -4
- package/icc-x-api/icc-form-x-api.js +34 -4
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-hcparty-x-api.d.ts +67 -0
- package/icc-x-api/icc-hcparty-x-api.js +67 -0
- package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
- package/icc-x-api/icc-helement-x-api.d.ts +141 -0
- package/icc-x-api/icc-helement-x-api.js +141 -0
- package/icc-x-api/icc-helement-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.d.ts +54 -0
- package/icc-x-api/icc-invoice-x-api.js +54 -0
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +162 -0
- package/icc-x-api/icc-message-x-api.js +162 -0
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +245 -0
- package/icc-x-api/icc-patient-x-api.js +245 -1
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.d.ts +25 -0
- package/icc-x-api/icc-receipt-x-api.js +25 -0
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-user-x-api.d.ts +25 -0
- package/icc-x-api/icc-user-x-api.js +25 -0
- package/icc-x-api/icc-user-x-api.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/icc-form-x-api.js +265 -1
- package/test/icc-x-api/icc-form-x-api.js.map +1 -1
- package/test/utils/roles.js +5 -0
- package/test/utils/roles.js.map +1 -1
- package/test/utils/test_utils.js +1 -21
- package/test/utils/test_utils.js.map +1 -1
- package/test/support/CSM-729.d.ts +0 -1
- package/test/support/CSM-729.js +0 -225
- package/test/support/CSM-729.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-data-owner-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-data-owner-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,0CAAiH;AAGjH,sEAA2F;AAE3F,0EAAgG;AAChG,oEAAgE;AAMhE,MAAa,gBAAiB,SAAQ,iCAAe;IAInD,IAAY,eAAe;QACzB,IAAI,CAAC,IAAI,CAAC,4BAA4B;YAAE,OAAO,SAAS,CAAA;QACxD,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,4BAA4B,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACxF,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EAClC,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;IACzD,CAAC;IAED;;;;OAIG;IACH,0BAA0B,CAAC,SAA0B;QACnD,OAAO,IAAA,+BAAuB,EAAC,SAAS,CAAC,CAAA;IAC3C,CAAC;IAED;;;;OAIG;IACH,4BAA4B,CAAC,SAA0B;QACrD,OAAO,IAAA,iCAAyB,EAAC,SAAS,CAAC,CAAA;IAC7C,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,SAA0B;QAC3C,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,C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GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAG,CAAC,CAAA;YACnE,OAAO,GAAG,CAAA;QACZ,CAAC;KAAA;CACF;AAvLD,4CAuLC","sourcesContent":["import { User } from '../icc-api/model/User'\nimport { IccDeviceApi, IccPatientApi, IccUserApi } from '../icc-api'\nimport { HealthcareParty } from '../icc-api/model/HealthcareParty'\nimport { Patient } from '../icc-api/model/Patient'\nimport { Device } from '../icc-api/model/Device'\nimport { fingerprintV1, fingerprintV2, hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from './crypto/utils'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { XHR } from '../icc-api/api/XHR'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../icc-api/model/CryptoActorStub'\nimport { DataOwnerTypeEnum } from '../icc-api/model/DataOwnerTypeEnum'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { IccDataownerApi } from '../icc-api/api/IccDataownerApi'\nimport { DataOwnerWithType } from '../icc-api/model/DataOwnerWithType'\n\nexport type DataOwnerOrStub = DataOwner | CryptoActorStub\nexport type DataOwner = HealthcareParty | Patient | Device\n\nexport class IccDataOwnerXApi extends IccDataownerApi {\n private currentDataOwnerType: DataOwnerTypeEnum | undefined\n private currentDataOwnerHierarchyIds: string[] | undefined\n\n private get selfDataOwnerId(): string | undefined {\n if (!this.currentDataOwnerHierarchyIds) return undefined\n return this.currentDataOwnerHierarchyIds[this.currentDataOwnerHierarchyIds.length - 1]\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\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 }\n\n /**\n * Gets the public keys of a data owner to be used for encryption with RSA-OAEP+SHA-1, in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysWithSha1Of(dataOwner: DataOwnerOrStub): Set<string> {\n return hexPublicKeysWithSha1Of(dataOwner)\n }\n\n /**\n * Gets the public keys of a data owner to be used for encryption with RSA-OAEP+SHA-256, in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysWithSha256Of(dataOwner: DataOwnerOrStub): Set<string> {\n return hexPublicKeysWithSha256Of(dataOwner)\n }\n\n /**\n * Gets all public keys of a data owner to be used for encryption, in hex format. Note that this may include keys that should be used for different\n * encryption algorithms.\n */\n getHexPublicKeysOf(dataOwner: DataOwnerOrStub): Set<string> {\n return new Set([...this.getHexPublicKeysWithSha1Of(dataOwner), ...this.getHexPublicKeysWithSha256Of(dataOwner)])\n }\n\n async getCurrentDataOwnerStub(): Promise<CryptoActorStubWithType> {\n return CryptoActorStubWithType.fromDataOwner(await this.getCurrentDataOwner())\n }\n\n /**\n * If the logged user is a data owner get the current data owner. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerId(): Promise<string> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n return this.currentDataOwnerHierarchyIds![this.currentDataOwnerHierarchyIds!.length - 1]\n }\n\n /**\n * If the logged user is a data owner get its parent hierarchy. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * The resulting array starts with the topmost parent (the only ancestor without a parent) and ends with the data owner itself.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerHierarchyIds(): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return [...this.currentDataOwnerHierarchyIds!]\n }\n\n /**\n * Get the hierarchy for the current data owner starting from the specified parent.\n * @throws an array starting at the topmost parent and ending at the provided parent id. If the provided id is not part of the hierarchy throws an\n * error.\n */\n async getCurrentDataOwnerHierarchyIdsFrom(parentId: string): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n const res = []\n for (const dataOwnerId of this.currentDataOwnerHierarchyIds!) {\n res.push(dataOwnerId)\n if (dataOwnerId === parentId) return res\n }\n throw new Error(`${parentId} is not part of the data owner hierarchy for the current user`)\n }\n\n /**\n * If the logged user is a data owner get the current data owner and all of his parents.\n * @throws if the current user is not a data owner.\n * @return the current data owner hierarchy, starting from the topmost parent to the current data owner.\n */\n async getCurrentDataOwnerHierarchy(): Promise<DataOwnerWithType[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n return await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n } else return Promise.all(this.currentDataOwnerHierarchyIds!.map((id) => this.getDataOwner(id)))\n }\n\n /**\n * If the logged user is a data owner get the type of the current data owner. This information is cached.\n * @throws if the current user is not a data owner\n */\n async getCurrentDataOwnerType(): Promise<DataOwnerTypeEnum> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return this.currentDataOwnerType!\n }\n\n /**\n * Get the id of the data owner entity for a user.\n * @param user a user that is also a data owner.\n * @return the id of the data owner corresponding to the provided user.\n * @throws if the user is not a data owner.\n */\n getDataOwnerIdOf(user: User): string {\n const dataOwnerId = user.healthcarePartyId ?? user.patientId ?? user.deviceId\n if (dataOwnerId == undefined) {\n throw Error(`User ${user.id} is not a data owner`)\n }\n return dataOwnerId\n }\n\n /**\n * Get a data owner. Note that this does not decrpyt patient data owners.\n * @param ownerId id of the data owner to retrieve (patient, medical device, hcp, ...)\n * @return the data owner with the provided id\n * @throws if you have no access to the data owner. Use {@link getCryptoActorStub}.\n */\n async getDataOwner(ownerId: string): Promise<DataOwnerWithType> {\n return super.getDataOwner(ownerId).then((dowt) => {\n if (dowt.dataOwner.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.dataOwner)\n return dowt\n })\n }\n\n /**\n * Get a crypto actor stub for a data owner.\n * @param ownerId id of the data owner for which you want to retrieve the stub (patient, medical device, hcp, ...)\n * @return the crypto actor stub of the data owner with the provided id\n */\n async getCryptoActorStub(ownerId: string): Promise<CryptoActorStubWithType> {\n return super.getCryptoActorStub(ownerId).then((dowt) => {\n if (dowt.stub.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.stub)\n return dowt\n })\n }\n\n /**\n * Clears the cache of current data owner id and parent hierarchy ids. The hierarchy of a data owner should not normally change over time, so this\n * method should be rarely needed.\n */\n clearCurrentDataOwnerIdsCache() {\n this.currentDataOwnerHierarchyIds = undefined\n }\n\n private checkDataOwnerIntegrity(dataOwner: DataOwnerOrStub) {\n const keys = new Set([...this.getHexPublicKeysWithSha1Of(dataOwner), ...this.getHexPublicKeysWithSha256Of(dataOwner)])\n if (new Set(Array.from(keys).map((x) => fingerprintV2(x))).size != keys.size)\n throw new Error(\n `Different public keys for ${dataOwner.id} have the same fingerprint; this should not happen in normal circumstances. Please report this error to iCure.`\n )\n }\n\n private async forceLoadCurrentDataOwnerHierarchyAndCacheIds(): Promise<DataOwnerWithType[]> {\n let curr = await this.getCurrentDataOwner()\n this.checkDataOwnerIntegrity(curr.dataOwner)\n this.currentDataOwnerType = curr.type\n let res = [curr]\n while ((curr.dataOwner as HealthcareParty).parentId) {\n curr = await this.getDataOwner((curr.dataOwner as HealthcareParty).parentId!)\n res = [curr, ...res]\n }\n this.currentDataOwnerHierarchyIds = res.map((x) => x.dataOwner.id!)\n return res\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icc-data-owner-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-data-owner-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,0CAAiH;AAGjH,sEAA2F;AAE3F,0EAAgG;AAChG,oEAAgE;AAMhE;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,iCAAe;IAInD,IAAY,eAAe;QACz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C,CAAA;QACtH,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;YAC1E,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,CAAC,EAAE,gHAAgH,CAC1J,CAAA;IACL,CAAC;IAEa,6CAA6C;;YACzD,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAA;YAC3C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC5C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAA;YACrC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;YAChB,OAAQ,IAAI,CAAC,SAA6B,CAAC,QAAQ,EAAE,CAAC;gBACpD,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAE,IAAI,CAAC,SAA6B,CAAC,QAAS,CAAC,CAAA;gBAC7E,GAAG,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAA;YACtB,CAAC;YACD,IAAI,CAAC,4BAA4B,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAG,CAAC,CAAA;YACnE,OAAO,GAAG,CAAA;QACZ,CAAC;KAAA;CACF;AA9LD,4CA8LC","sourcesContent":["import { User } from '../icc-api/model/User'\nimport { IccDeviceApi, IccPatientApi, IccUserApi } from '../icc-api'\nimport { HealthcareParty } from '../icc-api/model/HealthcareParty'\nimport { Patient } from '../icc-api/model/Patient'\nimport { Device } from '../icc-api/model/Device'\nimport { fingerprintV1, fingerprintV2, hexPublicKeysWithSha1Of, hexPublicKeysWithSha256Of } from './crypto/utils'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { XHR } from '../icc-api/api/XHR'\nimport { CryptoActorStub, CryptoActorStubWithType } from '../icc-api/model/CryptoActorStub'\nimport { DataOwnerTypeEnum } from '../icc-api/model/DataOwnerTypeEnum'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { IccDataownerApi } from '../icc-api/api/IccDataownerApi'\nimport { DataOwnerWithType } from '../icc-api/model/DataOwnerWithType'\n\nexport type DataOwnerOrStub = DataOwner | CryptoActorStub\nexport type DataOwner = HealthcareParty | Patient | Device\n\n/**\n * Extended API for managing data owners (healthcare parties, patients, and devices).\n * Provides methods to retrieve data owner information, manage hierarchies, and handle cryptographic keys.\n */\nexport class IccDataOwnerXApi extends IccDataownerApi {\n private currentDataOwnerType: DataOwnerTypeEnum | undefined\n private currentDataOwnerHierarchyIds: string[] | undefined\n\n private get selfDataOwnerId(): string | undefined {\n if (!this.currentDataOwnerHierarchyIds) return undefined\n return this.currentDataOwnerHierarchyIds[this.currentDataOwnerHierarchyIds.length - 1]\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\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 }\n\n /**\n * Gets the public keys of a data owner to be used for encryption with RSA-OAEP+SHA-1, in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysWithSha1Of(dataOwner: DataOwnerOrStub): Set<string> {\n return hexPublicKeysWithSha1Of(dataOwner)\n }\n\n /**\n * Gets the public keys of a data owner to be used for encryption with RSA-OAEP+SHA-256, in hex format.\n * @param dataOwner a data owner.\n * @return the public keys for the data owner in hex format.\n */\n getHexPublicKeysWithSha256Of(dataOwner: DataOwnerOrStub): Set<string> {\n return hexPublicKeysWithSha256Of(dataOwner)\n }\n\n /**\n * Gets all public keys of a data owner to be used for encryption, in hex format. Note that this may include keys that should be used for different\n * encryption algorithms.\n */\n getHexPublicKeysOf(dataOwner: DataOwnerOrStub): Set<string> {\n return new Set([...this.getHexPublicKeysWithSha1Of(dataOwner), ...this.getHexPublicKeysWithSha256Of(dataOwner)])\n }\n\n /**\n * Gets the crypto actor stub for the current data owner. This is a lightweight representation containing only\n * cryptographic information without full data owner details.\n * @return the crypto actor stub of the current data owner.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerStub(): Promise<CryptoActorStubWithType> {\n return CryptoActorStubWithType.fromDataOwner(await this.getCurrentDataOwner())\n }\n\n /**\n * If the logged user is a data owner get the current data owner. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerId(): Promise<string> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n return this.currentDataOwnerHierarchyIds![this.currentDataOwnerHierarchyIds!.length - 1]\n }\n\n /**\n * If the logged user is a data owner get its parent hierarchy. This information is cached without expiration, and will only be updated in case\n * of forced refresh.\n * The resulting array starts with the topmost parent (the only ancestor without a parent) and ends with the data owner itself.\n * @throws if the current user is not a data owner.\n */\n async getCurrentDataOwnerHierarchyIds(): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return [...this.currentDataOwnerHierarchyIds!]\n }\n\n /**\n * Get the hierarchy for the current data owner starting from the specified parent.\n * @param parentId the id of a parent in the current data owner hierarchy.\n * @return an array starting at the topmost parent and ending at the provided parent id.\n * @throws if the provided id is not part of the data owner hierarchy.\n */\n async getCurrentDataOwnerHierarchyIdsFrom(parentId: string): Promise<string[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.getCurrentDataOwnerHierarchyIds()\n }\n const res = []\n for (const dataOwnerId of this.currentDataOwnerHierarchyIds!) {\n res.push(dataOwnerId)\n if (dataOwnerId === parentId) return res\n }\n throw new Error(`${parentId} is not part of the data owner hierarchy for the current user`)\n }\n\n /**\n * If the logged user is a data owner get the current data owner and all of his parents.\n * @throws if the current user is not a data owner.\n * @return the current data owner hierarchy, starting from the topmost parent to the current data owner.\n */\n async getCurrentDataOwnerHierarchy(): Promise<DataOwnerWithType[]> {\n if (!this.currentDataOwnerHierarchyIds) {\n return await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n } else return Promise.all(this.currentDataOwnerHierarchyIds!.map((id) => this.getDataOwner(id)))\n }\n\n /**\n * If the logged user is a data owner get the type of the current data owner. This information is cached.\n * @throws if the current user is not a data owner\n */\n async getCurrentDataOwnerType(): Promise<DataOwnerTypeEnum> {\n if (!this.currentDataOwnerHierarchyIds) {\n await this.forceLoadCurrentDataOwnerHierarchyAndCacheIds()\n }\n return this.currentDataOwnerType!\n }\n\n /**\n * Get the id of the data owner entity for a user.\n * @param user a user that is also a data owner.\n * @return the id of the data owner corresponding to the provided user.\n * @throws if the user is not a data owner.\n */\n getDataOwnerIdOf(user: User): string {\n const dataOwnerId = user.healthcarePartyId ?? user.patientId ?? user.deviceId\n if (dataOwnerId == undefined) {\n throw Error(`User ${user.id} is not a data owner`)\n }\n return dataOwnerId\n }\n\n /**\n * Get a data owner. Note that this does not decrypt patient data owners.\n * @param ownerId id of the data owner to retrieve (patient, medical device, hcp, ...)\n * @return the data owner with the provided id\n * @throws if you have no access to the data owner. Use {@link getCryptoActorStub}.\n */\n async getDataOwner(ownerId: string): Promise<DataOwnerWithType> {\n return super.getDataOwner(ownerId).then((dowt) => {\n if (dowt.dataOwner.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.dataOwner)\n return dowt\n })\n }\n\n /**\n * Get a crypto actor stub for a data owner.\n * @param ownerId id of the data owner for which you want to retrieve the stub (patient, medical device, hcp, ...)\n * @return the crypto actor stub of the data owner with the provided id\n */\n async getCryptoActorStub(ownerId: string): Promise<CryptoActorStubWithType> {\n return super.getCryptoActorStub(ownerId).then((dowt) => {\n if (dowt.stub.id === this.selfDataOwnerId) this.checkDataOwnerIntegrity(dowt.stub)\n return dowt\n })\n }\n\n /**\n * Clears the cache of current data owner id and parent hierarchy ids. The hierarchy of a data owner should not normally change over time, so this\n * method should be rarely needed.\n */\n clearCurrentDataOwnerIdsCache() {\n this.currentDataOwnerHierarchyIds = undefined\n }\n\n private checkDataOwnerIntegrity(dataOwner: DataOwnerOrStub) {\n const keys = new Set([...this.getHexPublicKeysWithSha1Of(dataOwner), ...this.getHexPublicKeysWithSha256Of(dataOwner)])\n if (new Set(Array.from(keys).map((x) => fingerprintV2(x))).size != keys.size)\n throw new Error(\n `Different public keys for ${dataOwner.id} have the same fingerprint; this should not happen in normal circumstances. Please report this error to iCure.`\n )\n }\n\n private async forceLoadCurrentDataOwnerHierarchyAndCacheIds(): Promise<DataOwnerWithType[]> {\n let curr = await this.getCurrentDataOwner()\n this.checkDataOwnerIntegrity(curr.dataOwner)\n this.currentDataOwnerType = curr.type\n let res = [curr]\n while ((curr.dataOwner as HealthcareParty).parentId) {\n curr = await this.getDataOwner((curr.dataOwner as HealthcareParty).parentId!)\n res = [curr, ...res]\n }\n this.currentDataOwnerHierarchyIds = res.map((x) => x.dataOwner.id!)\n return res\n }\n}\n"]}
|
|
@@ -11,5 +11,13 @@ export declare class IccDeviceXApi extends IccDeviceApi {
|
|
|
11
11
|
constructor(host: string, headers: {
|
|
12
12
|
[key: string]: string;
|
|
13
13
|
}, authenticationProvider: AuthenticationProvider | undefined, userApi: IccUserXApi, authApi: IccAuthApi, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
14
|
+
/**
|
|
15
|
+
* Subscribes to real-time device events using a WebSocket connection.
|
|
16
|
+
* @param eventTypes the types of events to listen for (e.g. 'CREATE', 'UPDATE', 'DELETE').
|
|
17
|
+
* @param filter an optional filter to restrict which device events trigger the callback.
|
|
18
|
+
* @param eventFired the callback function invoked when a matching device event is received.
|
|
19
|
+
* @param options optional subscription configuration such as connection parameters and retry behaviour.
|
|
20
|
+
* @return a connection object that can be used to manage the WebSocket subscription lifecycle.
|
|
21
|
+
*/
|
|
14
22
|
subscribeToDeviceEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<Device> | undefined, eventFired: (dataSample: Device) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
|
|
15
23
|
}
|
|
@@ -25,6 +25,14 @@ class IccDeviceXApi extends icc_api_1.IccDeviceApi {
|
|
|
25
25
|
this.userApi = userApi;
|
|
26
26
|
this.authApi = authApi;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Subscribes to real-time device events using a WebSocket connection.
|
|
30
|
+
* @param eventTypes the types of events to listen for (e.g. 'CREATE', 'UPDATE', 'DELETE').
|
|
31
|
+
* @param filter an optional filter to restrict which device events trigger the callback.
|
|
32
|
+
* @param eventFired the callback function invoked when a matching device event is received.
|
|
33
|
+
* @param options optional subscription configuration such as connection parameters and retry behaviour.
|
|
34
|
+
* @return a connection object that can be used to manage the WebSocket subscription lifecycle.
|
|
35
|
+
*/
|
|
28
36
|
subscribeToDeviceEvents(eventTypes_1, filter_1, eventFired_1) {
|
|
29
37
|
return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
|
|
30
38
|
return (0, websocket_1.subscribeToEntityEvents)(this.host, this.authApi, 'Device', eventTypes, filter, eventFired, options).then((rs) => new Connection_1.ConnectionImpl(rs));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-device-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-device-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAmD;AAEnD,0EAA8F;AAE9F,4DAAsE;AACtE,iDAA8E;AAG9E,qCAAqC;AACrC,MAAa,aAAc,SAAQ,sBAAY;IAI7C,YACE,IAAY,EACZ,OAAkC,EAClC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,OAAoB,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U,EACV,OAAO,CACR,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;KAAA;CACF;AA9CD,sCA8CC","sourcesContent":["import {IccAuthApi, IccDeviceApi} from '../icc-api'\nimport {Device} from '../icc-api/model/Device'\nimport {AuthenticationProvider, NoAuthenticationProvider} from './auth/AuthenticationProvider'\nimport {AbstractFilter} from \"./filters/filters\"\nimport {Connection, ConnectionImpl} from \"../icc-api/model/Connection\"\nimport {subscribeToEntityEvents, SubscriptionOptions} from \"./utils/websocket\"\nimport {IccUserXApi} from \"./icc-user-x-api\"\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccDeviceXApi extends IccDeviceApi {\n private readonly userApi: IccUserXApi\n private readonly authApi: IccAuthApi\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n userApi: IccUserXApi,\n authApi: IccAuthApi,\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n\n this.userApi = userApi\n this.authApi = authApi\n }\n\n /**\n * Subscribes to real-time device events using a WebSocket connection.\n * @param eventTypes the types of events to listen for (e.g. 'CREATE', 'UPDATE', 'DELETE').\n * @param filter an optional filter to restrict which device events trigger the callback.\n * @param eventFired the callback function invoked when a matching device event is received.\n * @param options optional subscription configuration such as connection parameters and retry behaviour.\n * @return a connection object that can be used to manage the WebSocket subscription lifecycle.\n */\n async subscribeToDeviceEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Device> | undefined,\n eventFired: (dataSample: Device) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return subscribeToEntityEvents(\n this.host,\n this.authApi,\n 'Device',\n eventTypes,\n filter,\n eventFired,\n options,\n ).then((rs) => new ConnectionImpl(rs))\n }\n}\n"]}
|
|
@@ -10,8 +10,34 @@ export declare class IccDoctemplateXApi extends IccDoctemplateApi {
|
|
|
10
10
|
constructor(host: string, headers: {
|
|
11
11
|
[key: string]: string;
|
|
12
12
|
}, crypto: IccCryptoXApi, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of document template with initialised metadata (not persisted in the database).
|
|
15
|
+
* @param user the current user, used to set the owner.
|
|
16
|
+
* @param template the template content as a string, which will be converted to an ArrayBuffer attachment.
|
|
17
|
+
* @param c optional initial data to merge into the document template. Metadata such as id, creation date, and guid
|
|
18
|
+
* will be automatically generated if not provided.
|
|
19
|
+
* @return a new DocumentTemplate instance with populated metadata fields.
|
|
20
|
+
*/
|
|
13
21
|
newInstance(user: models.User, template: string, c: any): Promise<DocumentTemplate>;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated not implemented. Always rejects with an error.
|
|
24
|
+
* @param ownerId the id of the owner.
|
|
25
|
+
* @return always rejects.
|
|
26
|
+
*/
|
|
14
27
|
findAllByOwnerId(ownerId: string): Promise<Array<models.DocumentTemplate>>;
|
|
28
|
+
/**
|
|
29
|
+
* Builds the URL for downloading a document template attachment.
|
|
30
|
+
* @param documentId the id of the document template.
|
|
31
|
+
* @param attachmentId the id of the attachment.
|
|
32
|
+
* @return the fully qualified URL to the attachment resource.
|
|
33
|
+
*/
|
|
15
34
|
getAttachmentUrl(documentId: string, attachmentId: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves the text content of a document template attachment. Decodes binary responses as UTF-8 text, and
|
|
37
|
+
* returns text/plain, text/html, or text/xml content directly. Returns false for unsupported content types.
|
|
38
|
+
* @param documentTemplateId the id of the document template.
|
|
39
|
+
* @param attachmentId the id of the attachment.
|
|
40
|
+
* @return the attachment text content as a string, or false if the content type is unsupported.
|
|
41
|
+
*/
|
|
16
42
|
getAttachmentText(documentTemplateId: string, attachmentId: string): Promise<any | boolean>;
|
|
17
43
|
}
|
|
@@ -17,6 +17,14 @@ class IccDoctemplateXApi extends icc_api_1.IccDoctemplateApi {
|
|
|
17
17
|
this.authenticationProvider = authenticationProvider;
|
|
18
18
|
this.fetchImpl = fetchImpl;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new instance of document template with initialised metadata (not persisted in the database).
|
|
22
|
+
* @param user the current user, used to set the owner.
|
|
23
|
+
* @param template the template content as a string, which will be converted to an ArrayBuffer attachment.
|
|
24
|
+
* @param c optional initial data to merge into the document template. Metadata such as id, creation date, and guid
|
|
25
|
+
* will be automatically generated if not provided.
|
|
26
|
+
* @return a new DocumentTemplate instance with populated metadata fields.
|
|
27
|
+
*/
|
|
20
28
|
newInstance(user, template, c) {
|
|
21
29
|
return new Promise((resolve, reject) => {
|
|
22
30
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -31,16 +39,34 @@ class IccDoctemplateXApi extends icc_api_1.IccDoctemplateApi {
|
|
|
31
39
|
return resolve(documentTemplate);
|
|
32
40
|
});
|
|
33
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated not implemented. Always rejects with an error.
|
|
44
|
+
* @param ownerId the id of the owner.
|
|
45
|
+
* @return always rejects.
|
|
46
|
+
*/
|
|
34
47
|
// noinspection JSUnusedLocalSymbols
|
|
35
48
|
findAllByOwnerId(ownerId) {
|
|
36
49
|
return new Promise(function (resolve, reject) {
|
|
37
50
|
reject(console.log('findByHCPartyPatientSecretFKeys not implemented in document API!'));
|
|
38
51
|
});
|
|
39
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Builds the URL for downloading a document template attachment.
|
|
55
|
+
* @param documentId the id of the document template.
|
|
56
|
+
* @param attachmentId the id of the attachment.
|
|
57
|
+
* @return the fully qualified URL to the attachment resource.
|
|
58
|
+
*/
|
|
40
59
|
// noinspection JSUnusedGlobalSymbols
|
|
41
60
|
getAttachmentUrl(documentId, attachmentId) {
|
|
42
61
|
return (this.host + '/doctemplate/{documentId}/attachment/{attachmentId}'.replace('{documentId}', documentId).replace('{attachmentId}', attachmentId));
|
|
43
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the text content of a document template attachment. Decodes binary responses as UTF-8 text, and
|
|
65
|
+
* returns text/plain, text/html, or text/xml content directly. Returns false for unsupported content types.
|
|
66
|
+
* @param documentTemplateId the id of the document template.
|
|
67
|
+
* @param attachmentId the id of the attachment.
|
|
68
|
+
* @return the attachment text content as a string, or false if the content type is unsupported.
|
|
69
|
+
*/
|
|
44
70
|
getAttachmentText(documentTemplateId, attachmentId) {
|
|
45
71
|
const _body = null;
|
|
46
72
|
const _url = this.host +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icc-doctemplate-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-doctemplate-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAM9C,uDAAgD;AAChD,4CAAwC;AACxC,0EAAgG;AAEhG,qCAAqC;AACrC,MAAa,kBAAmB,SAAQ,2BAAiB;IAKvD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,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;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;QACpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,WAAW,CAAC,IAAiB,EAAE,QAAgB,EAAE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AE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;aAC9H,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;gBAC3D,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;gBACpC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBACpC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;iBAAM,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBACzI,OAAO,GAAG,CAAC,IAAI,CAAA;YACjB,CAAC;iBAAM,CAAC;gBACN,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACF;AApHD,gDAoHC","sourcesContent":["import { IccDoctemplateApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport { extend } from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { DocumentTemplate } from '../icc-api/model/models'\nimport { string2ua } from './utils/binary-utils'\nimport { XHR } from '../icc-api/api/XHR'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccDoctemplateXApi extends IccDoctemplateApi {\n crypto: IccCryptoXApi\n authenticationProvider: AuthenticationProvider\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\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.authenticationProvider = authenticationProvider\n this.fetchImpl = fetchImpl\n }\n\n /**\n * Creates a new instance of document template with initialised metadata (not persisted in the database).\n * @param user the current user, used to set the owner.\n * @param template the template content as a string, which will be converted to an ArrayBuffer attachment.\n * @param c optional initial data to merge into the document template. Metadata such as id, creation date, and guid\n * will be automatically generated if not provided.\n * @return a new DocumentTemplate instance with populated metadata fields.\n */\n newInstance(user: models.User, template: string, c: any): Promise<DocumentTemplate> {\n return new Promise<DocumentTemplate>((resolve, reject) => {\n const documentTemplate: DocumentTemplate = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.DocumentTemplate',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n owner: c?.owner ?? user.id,\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n guid: c?.guid ?? this.crypto.primitives.randomUuid(),\n group: c?.group ?? null,\n specialty: c?.specialty ?? null,\n attachment: c?.attachment ?? string2ua(template),\n mainUti: c?.mainUti ?? 'public.plain-text',\n }\n if (documentTemplate.group && documentTemplate.group.guid == null) {\n documentTemplate.group.guid = this.crypto.primitives.randomUuid()\n }\n\n //sauver l doctemplate vide\n\n if (template) {\n //save attachement\n }\n\n return resolve(documentTemplate)\n })\n }\n\n /**\n * @deprecated not implemented. Always rejects with an error.\n * @param ownerId the id of the owner.\n * @return always rejects.\n */\n // noinspection JSUnusedLocalSymbols\n findAllByOwnerId(ownerId: string): Promise<Array<models.DocumentTemplate>> {\n return new Promise(function (resolve, reject) {\n reject(console.log('findByHCPartyPatientSecretFKeys not implemented in document API!'))\n })\n }\n\n /**\n * Builds the URL for downloading a document template attachment.\n * @param documentId the id of the document template.\n * @param attachmentId the id of the attachment.\n * @return the fully qualified URL to the attachment resource.\n */\n // noinspection JSUnusedGlobalSymbols\n getAttachmentUrl(documentId: string, attachmentId: string) {\n return (\n this.host + '/doctemplate/{documentId}/attachment/{attachmentId}'.replace('{documentId}', documentId).replace('{attachmentId}', attachmentId)\n )\n }\n\n /**\n * Retrieves the text content of a document template attachment. Decodes binary responses as UTF-8 text, and\n * returns text/plain, text/html, or text/xml content directly. Returns false for unsupported content types.\n * @param documentTemplateId the id of the document template.\n * @param attachmentId the id of the attachment.\n * @return the attachment text content as a string, or false if the content type is unsupported.\n */\n getAttachmentText(documentTemplateId: string, attachmentId: string): Promise<any | boolean> {\n const _body = null\n\n const _url =\n this.host +\n '/doctemplate/{documentTemplateId}/attachmentText/{attachmentId}'\n .replace('{documentTemplateId}', documentTemplateId + '')\n .replace('{attachmentId}', attachmentId + '') +\n '?ts=' +\n new Date().getTime()\n\n return XHR.sendCommand('GET', _url, this.headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => {\n if (doc.contentType.startsWith('application/octet-stream')) {\n const enc = new TextDecoder('utf-8')\n const arr = new Uint8Array(doc.body)\n return enc.decode(arr)\n } else if (doc.contentType.startsWith('text/plain') || doc.contentType.startsWith('text/html') || doc.contentType.startsWith('text/xml')) {\n return doc.body\n } else {\n return false\n }\n })\n .catch((err) => this.handleError(err))\n }\n}\n"]}
|
|
@@ -63,14 +63,24 @@ export declare class IccDocumentXApi extends IccDocumentApi implements Encrypted
|
|
|
63
63
|
alternateRootDelegation?: string;
|
|
64
64
|
}): Promise<models.Document>;
|
|
65
65
|
/**
|
|
66
|
-
* Same as {@link findByMessage} but it will only return the ids of the
|
|
66
|
+
* Same as {@link findByMessage} but it will only return the ids of the documents. It can also filter the documents where Document.created is between
|
|
67
67
|
* startDate and endDate in ascending or descending order by that field. (default: ascending).
|
|
68
68
|
*/
|
|
69
69
|
findIdsByMessage(hcpartyId: string, message: models.Message, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Decrypts an array of documents.
|
|
72
|
+
* @param documents the documents to decrypt.
|
|
73
|
+
* @return an array of objects containing the document and a flag indicating if it was successfully decrypted.
|
|
74
|
+
*/
|
|
70
75
|
decrypt(documents: Array<models.Document>): Promise<{
|
|
71
76
|
entity: models.Document;
|
|
72
77
|
decrypted: boolean;
|
|
73
78
|
}[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Encrypts an array of documents.
|
|
81
|
+
* @param documents the documents to encrypt.
|
|
82
|
+
* @return the encrypted documents.
|
|
83
|
+
*/
|
|
74
84
|
encrypt(documents: Array<models.Document>): Promise<Array<models.Document>>;
|
|
75
85
|
getAttachmentAs(documentId: string, attachmentId: string, returnType: "application/octet-stream", enckeys?: string, fileName?: string): Promise<ArrayBuffer>;
|
|
76
86
|
getAttachmentAs(documentId: string, attachmentId: string, returnType: "text/plain", enckeys?: string, fileName?: string): Promise<string>;
|
|
@@ -84,7 +94,18 @@ export declare class IccDocumentXApi extends IccDocumentApi implements Encrypted
|
|
|
84
94
|
getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: "application/json"): Promise<any | undefined>;
|
|
85
95
|
getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: 'application/octet-stream' | 'text/plain' | 'application/json'): Promise<any | undefined>;
|
|
86
96
|
private parserFor;
|
|
97
|
+
/**
|
|
98
|
+
* Converts a MIME type and file extension to a UTI (Uniform Type Identifier).
|
|
99
|
+
* @param mimeType the MIME type.
|
|
100
|
+
* @param extension the file extension.
|
|
101
|
+
* @return the corresponding UTI.
|
|
102
|
+
*/
|
|
87
103
|
uti(mimeType: string, extension: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Converts a UTI (Uniform Type Identifier) to a MIME type.
|
|
106
|
+
* @param uti the UTI.
|
|
107
|
+
* @return the corresponding MIME type.
|
|
108
|
+
*/
|
|
88
109
|
mimeType(uti: string): string;
|
|
89
110
|
/**
|
|
90
111
|
* Adds an attachment to a document, encrypting it on client side using the encryption keys of the provided document.
|
|
@@ -241,16 +262,43 @@ export declare class IccDocumentXApi extends IccDocumentApi implements Encrypted
|
|
|
241
262
|
shareMessageId?: ShareMetadataBehaviour;
|
|
242
263
|
};
|
|
243
264
|
}): Promise<ShareResult<models.Document>>;
|
|
265
|
+
/**
|
|
266
|
+
* Gets the data owners that have access to a document.
|
|
267
|
+
* @param entity the document.
|
|
268
|
+
* @return an object containing the permissions by data owner id and a flag indicating if there are unknown anonymous data owners.
|
|
269
|
+
*/
|
|
244
270
|
getDataOwnersWithAccessTo(entity: models.Document): Promise<{
|
|
245
271
|
permissionsByDataOwnerId: {
|
|
246
272
|
[p: string]: AccessLevelEnum;
|
|
247
273
|
};
|
|
248
274
|
hasUnknownAnonymousDataOwners: boolean;
|
|
249
275
|
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Gets the encryption keys of a document.
|
|
278
|
+
* @param entity the document.
|
|
279
|
+
* @return an array of encryption keys.
|
|
280
|
+
*/
|
|
250
281
|
getEncryptionKeysOf(entity: models.Document): Promise<string[]>;
|
|
282
|
+
/**
|
|
283
|
+
* Creates delegation de-anonymization metadata for a document.
|
|
284
|
+
* @param entity the document.
|
|
285
|
+
* @param delegates the data owner ids of the delegates.
|
|
286
|
+
*/
|
|
251
287
|
createDelegationDeAnonymizationMetadata(entity: models.Document, delegates: string[]): Promise<void>;
|
|
252
288
|
private decryptPage;
|
|
289
|
+
/**
|
|
290
|
+
* Creates a new document.
|
|
291
|
+
* @param user the user (not used).
|
|
292
|
+
* @param body the document to create.
|
|
293
|
+
* @return the created document.
|
|
294
|
+
*/
|
|
253
295
|
createDocumentWithUser(user: models.User | undefined, body: models.Document): Promise<models.Document>;
|
|
296
|
+
/**
|
|
297
|
+
* Deletes the main attachment of a document.
|
|
298
|
+
* @param user the user (not used).
|
|
299
|
+
* @param documentId the id of the document.
|
|
300
|
+
* @return the updated document.
|
|
301
|
+
*/
|
|
254
302
|
deleteAttachmentWithUser(user: models.User | undefined, documentId: string): Promise<models.Document>;
|
|
255
303
|
/**
|
|
256
304
|
* @deprecated
|
|
@@ -265,14 +313,79 @@ export declare class IccDocumentXApi extends IccDocumentApi implements Encrypted
|
|
|
265
313
|
*/
|
|
266
314
|
findDocumentsByHCPartyPatientForeignKeyWithUser(user: models.User | undefined, hcPartyId: string, secretFKey: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListDocument>;
|
|
267
315
|
findWithoutDelegationWithUser(user: models.User | undefined, limit?: number): Promise<Array<models.Document>>;
|
|
316
|
+
/**
|
|
317
|
+
* Gets a document by id.
|
|
318
|
+
* @param user the user (not used).
|
|
319
|
+
* @param documentId the id of the document.
|
|
320
|
+
* @return the document.
|
|
321
|
+
*/
|
|
268
322
|
getDocumentWithUser(user: models.User | undefined, documentId: string): Promise<models.Document>;
|
|
323
|
+
/**
|
|
324
|
+
* Gets a document by external UUID.
|
|
325
|
+
* @param user the user (not used).
|
|
326
|
+
* @param externalUuid the external UUID of the document.
|
|
327
|
+
* @return the document.
|
|
328
|
+
*/
|
|
269
329
|
getDocumentByExternalUuidWithUser(user: models.User | undefined, externalUuid: string): Promise<models.Document>;
|
|
330
|
+
/**
|
|
331
|
+
* Gets multiple documents by their ids.
|
|
332
|
+
* @param user the user (not used).
|
|
333
|
+
* @param body a list of document ids.
|
|
334
|
+
* @return the documents.
|
|
335
|
+
*/
|
|
270
336
|
getDocumentsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<models.Document>>;
|
|
337
|
+
/**
|
|
338
|
+
* Gets all documents with a specific external UUID.
|
|
339
|
+
* @param user the user (not used).
|
|
340
|
+
* @param externalUuid the external UUID.
|
|
341
|
+
* @return the documents.
|
|
342
|
+
*/
|
|
271
343
|
getDocumentsByExternalUuidWithUser(user: models.User | undefined, externalUuid: string): Promise<Array<models.Document>>;
|
|
344
|
+
/**
|
|
345
|
+
* Updates a document.
|
|
346
|
+
* @param user the user (not used).
|
|
347
|
+
* @param body the document to update.
|
|
348
|
+
* @return the updated document.
|
|
349
|
+
*/
|
|
272
350
|
modifyDocumentWithUser(user: models.User | undefined, body: models.Document): Promise<models.Document>;
|
|
351
|
+
/**
|
|
352
|
+
* Updates multiple documents.
|
|
353
|
+
* @param user the user (not used).
|
|
354
|
+
* @param body the documents to update.
|
|
355
|
+
* @return the updated documents.
|
|
356
|
+
*/
|
|
273
357
|
modifyDocumentsWithUser(user: models.User | undefined, body: Array<models.Document>): Promise<Array<models.Document>>;
|
|
358
|
+
/**
|
|
359
|
+
* Sets the main attachment of a document.
|
|
360
|
+
* @param user the user (not used).
|
|
361
|
+
* @param documentId the id of the document.
|
|
362
|
+
* @param documentRev the revision of the document.
|
|
363
|
+
* @param body the attachment data.
|
|
364
|
+
* @param utis an array of UTIs for the attachment.
|
|
365
|
+
* @param dataIsEncrypted whether the data is already encrypted.
|
|
366
|
+
* @return the updated document.
|
|
367
|
+
*/
|
|
274
368
|
setMainDocumentAttachmentWithUser(user: models.User | undefined, documentId: string, documentRev: string, body: Object, utis?: Array<string>, dataIsEncrypted?: boolean): Promise<models.Document>;
|
|
369
|
+
/**
|
|
370
|
+
* Sets a secondary attachment on a document.
|
|
371
|
+
* @param user the user (not used).
|
|
372
|
+
* @param documentId the id of the document.
|
|
373
|
+
* @param key the key for the secondary attachment.
|
|
374
|
+
* @param rev the revision of the document.
|
|
375
|
+
* @param attachment the attachment data.
|
|
376
|
+
* @param utis an array of UTIs for the attachment.
|
|
377
|
+
* @param dataIsEncrypted whether the data is already encrypted.
|
|
378
|
+
* @return the updated document.
|
|
379
|
+
*/
|
|
275
380
|
setSecondaryAttachmentWithUser(user: models.User | undefined, documentId: string, key: string, rev: string, attachment: Object, utis?: Array<string>, dataIsEncrypted?: boolean): Promise<models.Document>;
|
|
381
|
+
/**
|
|
382
|
+
* Deletes a secondary attachment from a document.
|
|
383
|
+
* @param user the user (not used).
|
|
384
|
+
* @param documentId the id of the document.
|
|
385
|
+
* @param key the key of the secondary attachment.
|
|
386
|
+
* @param rev the revision of the document.
|
|
387
|
+
* @return the updated document.
|
|
388
|
+
*/
|
|
276
389
|
deleteSecondaryAttachmentWithUser(user: models.User | undefined, documentId: string, key: string, rev: string): Promise<models.Document>;
|
|
277
390
|
createDocument(body?: models.Document): never;
|
|
278
391
|
deleteAttachment(documentId: string): never;
|