@icure/api 8.8.0 → 8.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/icc-api/api/IccAccesslogApi.d.ts +48 -0
  2. package/icc-api/api/IccAccesslogApi.js +100 -0
  3. package/icc-api/api/IccAccesslogApi.js.map +1 -1
  4. package/icc-api/api/IccAgendaApi.d.ts +25 -0
  5. package/icc-api/api/IccAgendaApi.js +49 -0
  6. package/icc-api/api/IccAgendaApi.js.map +1 -1
  7. package/icc-api/api/IccCalendarItemApi.d.ts +25 -0
  8. package/icc-api/api/IccCalendarItemApi.js +49 -0
  9. package/icc-api/api/IccCalendarItemApi.js.map +1 -1
  10. package/icc-api/api/IccCalendarItemTypeApi.d.ts +25 -0
  11. package/icc-api/api/IccCalendarItemTypeApi.js +49 -0
  12. package/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
  13. package/icc-api/api/IccCodeApi.d.ts +25 -0
  14. package/icc-api/api/IccCodeApi.js +49 -0
  15. package/icc-api/api/IccCodeApi.js.map +1 -1
  16. package/icc-api/api/IccContactApi.d.ts +48 -0
  17. package/icc-api/api/IccContactApi.js +100 -0
  18. package/icc-api/api/IccContactApi.js.map +1 -1
  19. package/icc-api/api/IccDeviceApi.d.ts +48 -0
  20. package/icc-api/api/IccDeviceApi.js +100 -0
  21. package/icc-api/api/IccDeviceApi.js.map +1 -1
  22. package/icc-api/api/IccDocumentApi.d.ts +48 -0
  23. package/icc-api/api/IccDocumentApi.js +100 -0
  24. package/icc-api/api/IccDocumentApi.js.map +1 -1
  25. package/icc-api/api/IccFormApi.d.ts +48 -0
  26. package/icc-api/api/IccFormApi.js +101 -4
  27. package/icc-api/api/IccFormApi.js.map +1 -1
  28. package/icc-api/api/IccHcpartyApi.d.ts +48 -0
  29. package/icc-api/api/IccHcpartyApi.js +100 -0
  30. package/icc-api/api/IccHcpartyApi.js.map +1 -1
  31. package/icc-api/api/IccHelementApi.d.ts +48 -0
  32. package/icc-api/api/IccHelementApi.js +100 -0
  33. package/icc-api/api/IccHelementApi.js.map +1 -1
  34. package/icc-api/api/IccInsuranceApi.d.ts +50 -2
  35. package/icc-api/api/IccInsuranceApi.js +100 -0
  36. package/icc-api/api/IccInsuranceApi.js.map +1 -1
  37. package/icc-api/api/IccInvoiceApi.d.ts +48 -0
  38. package/icc-api/api/IccInvoiceApi.js +100 -0
  39. package/icc-api/api/IccInvoiceApi.js.map +1 -1
  40. package/icc-api/api/IccMessageApi.d.ts +48 -0
  41. package/icc-api/api/IccMessageApi.js +100 -0
  42. package/icc-api/api/IccMessageApi.js.map +1 -1
  43. package/icc-api/api/IccPatientApi.d.ts +48 -0
  44. package/icc-api/api/IccPatientApi.js +100 -0
  45. package/icc-api/api/IccPatientApi.js.map +1 -1
  46. package/icc-api/api/IccPlaceApi.d.ts +25 -0
  47. package/icc-api/api/IccPlaceApi.js +49 -0
  48. package/icc-api/api/IccPlaceApi.js.map +1 -1
  49. package/icc-api/api/IccReceiptApi.d.ts +25 -0
  50. package/icc-api/api/IccReceiptApi.js +49 -0
  51. package/icc-api/api/IccReceiptApi.js.map +1 -1
  52. package/icc-api/api/IccTopicApi.d.ts +48 -0
  53. package/icc-api/api/IccTopicApi.js +100 -0
  54. package/icc-api/api/IccTopicApi.js.map +1 -1
  55. package/icc-api/api/IccUserApi.d.ts +25 -0
  56. package/icc-api/api/IccUserApi.js +49 -0
  57. package/icc-api/api/IccUserApi.js.map +1 -1
  58. package/icc-api/model/ConflictResolutionRequest.d.ts +18 -0
  59. package/icc-api/model/ConflictResolutionRequest.js +17 -0
  60. package/icc-api/model/ConflictResolutionRequest.js.map +1 -0
  61. package/icc-api/model/ConflictResolutionResult.d.ts +22 -0
  62. package/icc-api/model/ConflictResolutionResult.js +24 -0
  63. package/icc-api/model/ConflictResolutionResult.js.map +1 -0
  64. package/icc-api/model/models.d.ts +2 -0
  65. package/icc-api/model/models.js +2 -0
  66. package/icc-api/model/models.js.map +1 -1
  67. package/icc-x-api/icc-accesslog-x-api.d.ts +31 -0
  68. package/icc-x-api/icc-accesslog-x-api.js +57 -0
  69. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  70. package/icc-x-api/icc-calendar-item-x-api.d.ts +15 -0
  71. package/icc-x-api/icc-calendar-item-x-api.js +28 -0
  72. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  73. package/icc-x-api/icc-contact-x-api.d.ts +31 -0
  74. package/icc-x-api/icc-contact-x-api.js +60 -1
  75. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  76. package/icc-x-api/icc-document-x-api.d.ts +31 -0
  77. package/icc-x-api/icc-document-x-api.js +64 -0
  78. package/icc-x-api/icc-document-x-api.js.map +1 -1
  79. package/icc-x-api/icc-form-x-api.d.ts +31 -0
  80. package/icc-x-api/icc-form-x-api.js +58 -0
  81. package/icc-x-api/icc-form-x-api.js.map +1 -1
  82. package/icc-x-api/icc-helement-x-api.d.ts +31 -0
  83. package/icc-x-api/icc-helement-x-api.js +57 -0
  84. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  85. package/icc-x-api/icc-invoice-x-api.d.ts +31 -0
  86. package/icc-x-api/icc-invoice-x-api.js +58 -0
  87. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  88. package/icc-x-api/icc-message-x-api.d.ts +31 -0
  89. package/icc-x-api/icc-message-x-api.js +64 -0
  90. package/icc-x-api/icc-message-x-api.js.map +1 -1
  91. package/icc-x-api/icc-patient-x-api.d.ts +31 -0
  92. package/icc-x-api/icc-patient-x-api.js +57 -0
  93. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  94. package/icc-x-api/icc-topic-x-api.d.ts +31 -0
  95. package/icc-x-api/icc-topic-x-api.js +58 -0
  96. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  97. package/package.json +1 -1
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.IccInvoiceXApi = void 0;
13
13
  const icc_api_1 = require("../icc-api");
14
14
  const models = require("../icc-api/model/models");
15
+ const collection_utils_1 = require("./utils/collection-utils");
15
16
  const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
16
17
  const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
17
18
  var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
@@ -302,6 +303,63 @@ class IccInvoiceXApi extends icc_api_1.IccInvoiceApi {
302
303
  createDelegationDeAnonymizationMetadata(entity, delegates) {
303
304
  return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.Invoice }, delegates);
304
305
  }
306
+ /**
307
+ * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
308
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
309
+ * @param entityId the id of the invoice to retrieve the conflicts for.
310
+ * @return the decrypted conflicting revisions of the invoice.
311
+ */
312
+ getConflictsForEntityWithUser(user, entityId) {
313
+ return super.getConflictsForEntity(entityId).then((is) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), is));
314
+ }
315
+ /**
316
+ * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
317
+ * winner returned by the backend.
318
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
319
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
320
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
321
+ */
322
+ declareConflictWinnerWithUser(user, request) {
323
+ const _super = Object.create(null, {
324
+ declareConflictWinner: { get: () => super.declareConflictWinner }
325
+ });
326
+ return __awaiter(this, void 0, void 0, function* () {
327
+ const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
328
+ const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
329
+ if (result.document)
330
+ result.document = (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0];
331
+ return result;
332
+ });
333
+ }
334
+ /**
335
+ * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
336
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
337
+ * @param groupId the id of the group the invoice belongs to.
338
+ * @param entityId the id of the invoice to retrieve the conflicts for.
339
+ * @return the decrypted conflicting revisions of the invoice.
340
+ */
341
+ getConflictsForEntityInGroupWithUser(user, groupId, entityId) {
342
+ return super.getConflictsForEntityInGroup(groupId, entityId).then((is) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), is));
343
+ }
344
+ /**
345
+ * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
346
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
347
+ * @param groupId the id of the group the invoice belongs to.
348
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
349
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
350
+ */
351
+ declareConflictWinnerInGroupWithUser(user, groupId, request) {
352
+ const _super = Object.create(null, {
353
+ declareConflictWinnerInGroup: { get: () => super.declareConflictWinnerInGroup }
354
+ });
355
+ return __awaiter(this, void 0, void 0, function* () {
356
+ const encrypted = (yield this.encrypt(user, [(0, collection_utils_1.cloneDeep)(request.document)]))[0];
357
+ const result = yield _super.declareConflictWinnerInGroup.call(this, groupId, Object.assign(Object.assign({}, request), { document: encrypted }));
358
+ if (result.document)
359
+ result.document = (yield this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0];
360
+ return result;
361
+ });
362
+ }
305
363
  }
306
364
  exports.IccInvoiceXApi = IccInvoiceXApi;
307
365
  //# sourceMappingURL=icc-invoice-x-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icc-invoice-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-invoice-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCA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AO,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,iBAAiB,CAAC,CAAC,CAAC,CACjC;iBACA,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACvF,CAAC;KAAA;IAED;;;;OAIG;IACH,yBAAyB,CACvB,MAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,CAAC,CAAA;IACjI,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,MAAsB;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IAC7G,CAAC;IAED;;;;;OAKG;IACH,uCAAuC,CAAC,MAAsB,EAAE,SAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IACpJ,CAAC;CACF;AAhXD,wCAgXC","sourcesContent":["import { IccEntityrefApi, IccInvoiceApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { Invoice } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\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 IccInvoiceXApi extends IccInvoiceApi implements EncryptedEntityXApi<models.Invoice> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Invoice))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly entityrefApi: IccEntityrefApi,\n private readonly 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 }\n\n /**\n * Creates a new instance of invoice with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this invoice refers to.\n * @param inv initialised data for the invoice. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of invoice.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n inv: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Invoice> {\n const invoice = new models.Invoice({\n ...(inv ?? {}),\n _type: 'org.taktik.icure.entities.Invoice',\n id: inv?.id ?? this.crypto.primitives.randomUuid(),\n groupId: inv?.groupId ?? this.crypto.primitives.randomUuid(),\n created: inv?.created ?? new Date().getTime(),\n modified: inv?.modified ?? new Date().getTime(),\n responsible: inv?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: inv?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: inv?.codes ?? [],\n tags: inv?.tags ?? [],\n invoicingCodes: inv?.invoicingCodes ?? [],\n })\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.financialInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Invoice(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n invoice,\n EntityWithDelegationTypeName.Invoice,\n patient.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates an invoice. If a prefix is provided, an auto-incrementing invoice reference is generated using the\n * entity reference API. If the invoice has an internshipNihii, the reference is adjusted accordingly.\n * @param invoice the invoice to create.\n * @param prefix optional prefix for generating an auto-incrementing invoice reference.\n * @return the created invoice.\n */\n createInvoice(invoice: Invoice, prefix?: string): Promise<Invoice> {\n if (!prefix) {\n return super.createInvoice(invoice)\n }\n if (!invoice.id) {\n invoice.id = this.crypto.primitives.randomUuid()\n }\n return this.getNextInvoiceReference(prefix, this.entityrefApi)\n .then((reference) => this.createInvoiceReference(reference, invoice.id!, prefix, this.entityrefApi))\n .then((entityReference) => {\n if (!entityReference.id) {\n throw new Error('Cannot create invoice')\n }\n\n if (invoice.internshipNihii) {\n invoice.invoiceReference = entityReference.id.substring(prefix.length).replace('0', '1')\n } else {\n invoice.invoiceReference = entityReference.id.substring(prefix.length)\n }\n return super.createInvoice(invoice)\n })\n }\n\n /**\n * Gets the next available invoice reference number for the given prefix.\n * @param prefix the prefix to look up the latest reference for.\n * @param entityrefApi the entity reference API to query.\n * @return the next sequence number (1-based).\n */\n getNextInvoiceReference(prefix: string, entityrefApi: IccEntityrefApi): Promise<number> {\n return entityrefApi.getLatest(prefix).then((entRef: models.EntityReference) => {\n if (!entRef || !entRef.id || !entRef.id!.startsWith(prefix)) return 1\n const sequenceNumber = entRef.id!.split(':').pop() || 0\n return Number(sequenceNumber) + 1\n })\n }\n\n /**\n * Creates an entity reference for an invoice with the given reference number. If the reference already exists\n * (conflict), retries with the next available number.\n * @param nextReference the reference number to use.\n * @param docId the document id to link to this reference.\n * @param prefix the prefix for the reference id.\n * @param entityrefApi the entity reference API to use.\n * @return the created entity reference.\n */\n createInvoiceReference(nextReference: number, docId: string, prefix: string, entityrefApi: IccEntityrefApi): Promise<models.EntityReference> {\n return entityrefApi\n .createEntityReference(\n new models.EntityReference({\n id: prefix + nextReference.toString().padStart(6, '0'),\n docId,\n })\n )\n .catch((err) => {\n console.log(err)\n return this.createInvoiceReference(nextReference + 1, docId, prefix, entityrefApi)\n })\n }\n\n /**\n * 1. Check whether there is a delegation with 'hcpartyId' or not.\n * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.\n * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key\n * 3.1. KeyPair should be fetch from cache (in jwk)\n * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto\n * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient\n * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4)\n * 6. Do the REST call to get all invoices with (allSecretForeignKeysDelimitedByComa, hcpartyId)\n *\n * After these painful steps, you have the invoices for the patient.\n *\n * @deprecated use {@link findIdsBy} instead\n * @param hcpartyId\n * @param patient (Promise)\n * @param usingPost\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false): Promise<Array<models.Invoice>> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n let invoices: Array<Invoice> = usingPost\n ? await this.findInvoicesByHCPartyPatientForeignKeysUsingPost(hcpartyId!, [...new Set(extractedKeys)])\n : await this.findInvoicesByHCPartyPatientForeignKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n return await this.decrypt(hcpartyId, invoices)\n }\n\n /**\n * Same as {@link findBy} but it will only return the ids of the invoices. It can also filter the invoices where Invoice.invoiceDate is between\n * startDate and endDate in ascending or descending order by that field (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return this.findInvoiceIdsByDataOwnerPatientInvoiceDate(hcpartyId!, [...new Set(extractedKeys)], startDate, endDate, descending)\n }\n\n /**\n * Encrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields.\n * @param user the current user.\n * @param invoices the invoices to encrypt.\n * @return the invoices unchanged.\n */\n encrypt(user: models.User, invoices: Array<models.Invoice>) {\n return Promise.resolve(invoices)\n }\n\n /**\n * Decrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields.\n * @param hcpartyId the id of the healthcare party.\n * @param invoices the invoices to decrypt.\n * @return the invoices unchanged.\n */\n decrypt(hcpartyId: string, invoices: Array<models.Invoice>): Promise<Array<models.Invoice>> {\n return Promise.resolve(invoices)\n }\n\n /**\n * @param invoice a invoice\n * @return the id of the patient that the invoice 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(invoice: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: invoice, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given invoice\n */\n async hasWriteAccess(invoice: models.Invoice): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: invoice, type: EntityWithDelegationTypeName.Invoice })\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice 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 invoice.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice> {\n return this.shareWithMany(invoice, { [delegateId]: options })\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice> {\n return (await this.tryShareWithMany(invoice, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(invoice, EntityWithDelegationTypeName.Invoice)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyInvoice(entityWithEncryptionKey) : invoice\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Invoice,\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.bulkShareInvoices(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given invoice, along with their access levels.\n * @param entity the invoice.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Invoice\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Invoice })\n }\n\n /**\n * Retrieves the encryption keys of the given invoice.\n * @param entity the invoice.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given invoice, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the invoice.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Invoice, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Invoice }, delegates)\n }\n}\n"]}
1
+ {"version":3,"file":"icc-invoice-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-invoice-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA2D;AAG3D,kDAAiD;AAEjD,+DAAoD;AAEpD,0EAAgG;AAChG,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAOzD,mCAAsD;AACtD,kEAA8D;AAE9D,MAAa,cAAe,S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CAAA;YACrG,IAAI,MAAM,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3H,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AAxaD,wCAwaC","sourcesContent":["import { IccEntityrefApi, IccInvoiceApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { Invoice } from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\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 IccInvoiceXApi extends IccInvoiceApi implements EncryptedEntityXApi<models.Invoice> {\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Invoice))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly entityrefApi: IccEntityrefApi,\n private readonly 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 }\n\n /**\n * Creates a new instance of invoice with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this invoice refers to.\n * @param inv initialised data for the invoice. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - sfkOption: specifies which sfk of the owning entity to use.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of invoice.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n inv: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ): Promise<models.Invoice> {\n const invoice = new models.Invoice({\n ...(inv ?? {}),\n _type: 'org.taktik.icure.entities.Invoice',\n id: inv?.id ?? this.crypto.primitives.randomUuid(),\n groupId: inv?.groupId ?? this.crypto.primitives.randomUuid(),\n created: inv?.created ?? new Date().getTime(),\n modified: inv?.modified ?? new Date().getTime(),\n responsible: inv?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: inv?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: inv?.codes ?? [],\n tags: inv?.tags ?? [],\n invoicingCodes: inv?.invoicingCodes ?? [],\n })\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? {}\n : Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.financialInformation ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.Invoice(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n invoice,\n EntityWithDelegationTypeName.Invoice,\n patient.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Creates an invoice. If a prefix is provided, an auto-incrementing invoice reference is generated using the\n * entity reference API. If the invoice has an internshipNihii, the reference is adjusted accordingly.\n * @param invoice the invoice to create.\n * @param prefix optional prefix for generating an auto-incrementing invoice reference.\n * @return the created invoice.\n */\n createInvoice(invoice: Invoice, prefix?: string): Promise<Invoice> {\n if (!prefix) {\n return super.createInvoice(invoice)\n }\n if (!invoice.id) {\n invoice.id = this.crypto.primitives.randomUuid()\n }\n return this.getNextInvoiceReference(prefix, this.entityrefApi)\n .then((reference) => this.createInvoiceReference(reference, invoice.id!, prefix, this.entityrefApi))\n .then((entityReference) => {\n if (!entityReference.id) {\n throw new Error('Cannot create invoice')\n }\n\n if (invoice.internshipNihii) {\n invoice.invoiceReference = entityReference.id.substring(prefix.length).replace('0', '1')\n } else {\n invoice.invoiceReference = entityReference.id.substring(prefix.length)\n }\n return super.createInvoice(invoice)\n })\n }\n\n /**\n * Gets the next available invoice reference number for the given prefix.\n * @param prefix the prefix to look up the latest reference for.\n * @param entityrefApi the entity reference API to query.\n * @return the next sequence number (1-based).\n */\n getNextInvoiceReference(prefix: string, entityrefApi: IccEntityrefApi): Promise<number> {\n return entityrefApi.getLatest(prefix).then((entRef: models.EntityReference) => {\n if (!entRef || !entRef.id || !entRef.id!.startsWith(prefix)) return 1\n const sequenceNumber = entRef.id!.split(':').pop() || 0\n return Number(sequenceNumber) + 1\n })\n }\n\n /**\n * Creates an entity reference for an invoice with the given reference number. If the reference already exists\n * (conflict), retries with the next available number.\n * @param nextReference the reference number to use.\n * @param docId the document id to link to this reference.\n * @param prefix the prefix for the reference id.\n * @param entityrefApi the entity reference API to use.\n * @return the created entity reference.\n */\n createInvoiceReference(nextReference: number, docId: string, prefix: string, entityrefApi: IccEntityrefApi): Promise<models.EntityReference> {\n return entityrefApi\n .createEntityReference(\n new models.EntityReference({\n id: prefix + nextReference.toString().padStart(6, '0'),\n docId,\n })\n )\n .catch((err) => {\n console.log(err)\n return this.createInvoiceReference(nextReference + 1, docId, prefix, entityrefApi)\n })\n }\n\n /**\n * 1. Check whether there is a delegation with 'hcpartyId' or not.\n * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.\n * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key\n * 3.1. KeyPair should be fetch from cache (in jwk)\n * 3.2. if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto\n * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient\n * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4)\n * 6. Do the REST call to get all invoices with (allSecretForeignKeysDelimitedByComa, hcpartyId)\n *\n * After these painful steps, you have the invoices for the patient.\n *\n * @deprecated use {@link findIdsBy} instead\n * @param hcpartyId\n * @param patient (Promise)\n * @param usingPost\n */\n async findBy(hcpartyId: string, patient: models.Patient, usingPost: boolean = false): Promise<Array<models.Invoice>> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n let invoices: Array<Invoice> = usingPost\n ? await this.findInvoicesByHCPartyPatientForeignKeysUsingPost(hcpartyId!, [...new Set(extractedKeys)])\n : await this.findInvoicesByHCPartyPatientForeignKeys(hcpartyId!, [...new Set(extractedKeys)].join(','))\n return await this.decrypt(hcpartyId, invoices)\n }\n\n /**\n * Same as {@link findBy} but it will only return the ids of the invoices. It can also filter the invoices where Invoice.invoiceDate is between\n * startDate and endDate in ascending or descending order by that field (default: ascending).\n */\n async findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]> {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return this.findInvoiceIdsByDataOwnerPatientInvoiceDate(hcpartyId!, [...new Set(extractedKeys)], startDate, endDate, descending)\n }\n\n /**\n * Encrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields.\n * @param user the current user.\n * @param invoices the invoices to encrypt.\n * @return the invoices unchanged.\n */\n encrypt(user: models.User, invoices: Array<models.Invoice>) {\n return Promise.resolve(invoices)\n }\n\n /**\n * Decrypts a list of invoices. Currently a no-op as invoices do not have encrypted fields.\n * @param hcpartyId the id of the healthcare party.\n * @param invoices the invoices to decrypt.\n * @return the invoices unchanged.\n */\n decrypt(hcpartyId: string, invoices: Array<models.Invoice>): Promise<Array<models.Invoice>> {\n return Promise.resolve(invoices)\n }\n\n /**\n * @param invoice a invoice\n * @return the id of the patient that the invoice 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(invoice: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: invoice, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given invoice\n */\n async hasWriteAccess(invoice: models.Invoice): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: invoice, type: EntityWithDelegationTypeName.Invoice })\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice 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 invoice.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice> {\n return this.shareWithMany(invoice, { [delegateId]: options })\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice> {\n return (await this.tryShareWithMany(invoice, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing invoice with other data owners, allowing them to access the non-encrypted data of the invoice and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param invoice the invoice 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 * invoice does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this invoice 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 invoice: models.Invoice,\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.Invoice>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(invoice, EntityWithDelegationTypeName.Invoice)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyInvoice(entityWithEncryptionKey) : invoice\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Invoice,\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.bulkShareInvoices(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decrypt(self, [e]).then((es) => es[0])))\n }\n\n /**\n * Retrieves the data owners that have access to the given invoice, along with their access levels.\n * @param entity the invoice.\n * @return an object containing a map of data owner ids to their access levels, and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Invoice\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Invoice })\n }\n\n /**\n * Retrieves the encryption keys of the given invoice.\n * @param entity the invoice.\n * @return the encryption key ids.\n */\n getEncryptionKeysOf(entity: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the given invoice, allowing the specified delegates to\n * identify the data owners that have access to it.\n * @param entity the invoice.\n * @param delegates the data owner ids for which to create de-anonymization metadata.\n */\n createDelegationDeAnonymizationMetadata(entity: models.Invoice, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Invoice }, delegates)\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param entityId the id of the invoice to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the invoice.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Invoice>> {\n return super.getConflictsForEntity(entityId).then((is) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), is))\n }\n\n /**\n * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved\n * winner returned by the backend.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerWithUser(\n user: models.User,\n request: models.ConflictResolutionRequest<models.Invoice>\n ): Promise<models.ConflictResolutionResult<models.Invoice>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0]\n return result\n }\n\n /**\n * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param groupId the id of the group the invoice belongs to.\n * @param entityId the id of the invoice to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the invoice.\n */\n getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Invoice>> {\n return super.getConflictsForEntityInGroup(groupId, entityId).then((is) => this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), is))\n }\n\n /**\n * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param groupId the id of the group the invoice belongs to.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerInGroupWithUser(\n user: models.User,\n groupId: string,\n request: models.ConflictResolutionRequest<models.Invoice>\n ): Promise<models.ConflictResolutionResult<models.Invoice>> {\n const encrypted = (await this.encrypt(user, [cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinnerInGroup(groupId, { ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt(this.dataOwnerApi.getDataOwnerIdOf(user), [result.document]))[0]\n return result\n }\n}\n"]}
@@ -356,4 +356,35 @@ export declare class IccMessageXApi extends IccMessageApi implements EncryptedEn
356
356
  setMessagesStatusBits(status: number, body?: ListOfIds): never;
357
357
  filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): never;
358
358
  setMessagesReadStatus(body?: MessagesReadStatusUpdate): never;
359
+ /**
360
+ * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
361
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
362
+ * @param entityId the id of the message to retrieve the conflicts for.
363
+ * @return the decrypted conflicting revisions of the message.
364
+ */
365
+ getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Message>>;
366
+ /**
367
+ * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
368
+ * winner returned by the backend.
369
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
370
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
371
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
372
+ */
373
+ declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest<models.Message>): Promise<models.ConflictResolutionResult<models.Message>>;
374
+ /**
375
+ * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
376
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
377
+ * @param groupId the id of the group the message belongs to.
378
+ * @param entityId the id of the message to retrieve the conflicts for.
379
+ * @return the decrypted conflicting revisions of the message.
380
+ */
381
+ getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Message>>;
382
+ /**
383
+ * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
384
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
385
+ * @param groupId the id of the group the message belongs to.
386
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
387
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
388
+ */
389
+ declareConflictWinnerInGroupWithUser(user: models.User, groupId: string, request: models.ConflictResolutionRequest<models.Message>): Promise<models.ConflictResolutionResult<models.Message>>;
359
390
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.IccMessageXApi = void 0;
13
13
  const icc_api_1 = require("../icc-api");
14
14
  const models = require("../icc-api/model/models");
15
+ const collection_utils_1 = require("./utils/collection-utils");
15
16
  const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
16
17
  const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
17
18
  var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
@@ -565,6 +566,69 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
565
566
  setMessagesReadStatus(body) {
566
567
  throw new Error('Use withUser method');
567
568
  }
569
+ /**
570
+ * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
571
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
572
+ * @param entityId the id of the message to retrieve the conflicts for.
573
+ * @return the decrypted conflicting revisions of the message.
574
+ */
575
+ getConflictsForEntityWithUser(user, entityId) {
576
+ return super
577
+ .getConflictsForEntity(entityId)
578
+ .then((ms) => this.decrypt(ms))
579
+ .then((res) => res.map(({ entity }) => entity));
580
+ }
581
+ /**
582
+ * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
583
+ * winner returned by the backend.
584
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
585
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
586
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
587
+ */
588
+ declareConflictWinnerWithUser(user, request) {
589
+ const _super = Object.create(null, {
590
+ declareConflictWinner: { get: () => super.declareConflictWinner }
591
+ });
592
+ return __awaiter(this, void 0, void 0, function* () {
593
+ const encrypted = (yield this.encrypt([(0, collection_utils_1.cloneDeep)(request.document)]))[0];
594
+ const result = yield _super.declareConflictWinner.call(this, Object.assign(Object.assign({}, request), { document: encrypted }));
595
+ if (result.document)
596
+ result.document = (yield this.decrypt([result.document]))[0].entity;
597
+ return result;
598
+ });
599
+ }
600
+ /**
601
+ * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
602
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
603
+ * @param groupId the id of the group the message belongs to.
604
+ * @param entityId the id of the message to retrieve the conflicts for.
605
+ * @return the decrypted conflicting revisions of the message.
606
+ */
607
+ getConflictsForEntityInGroupWithUser(user, groupId, entityId) {
608
+ return super
609
+ .getConflictsForEntityInGroup(groupId, entityId)
610
+ .then((ms) => this.decrypt(ms))
611
+ .then((res) => res.map(({ entity }) => entity));
612
+ }
613
+ /**
614
+ * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
615
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
616
+ * @param groupId the id of the group the message belongs to.
617
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
618
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
619
+ */
620
+ declareConflictWinnerInGroupWithUser(user, groupId, request) {
621
+ const _super = Object.create(null, {
622
+ declareConflictWinnerInGroup: { get: () => super.declareConflictWinnerInGroup }
623
+ });
624
+ return __awaiter(this, void 0, void 0, function* () {
625
+ const encrypted = (yield this.encrypt([(0, collection_utils_1.cloneDeep)(request.document)]))[0];
626
+ const result = yield _super.declareConflictWinnerInGroup.call(this, groupId, Object.assign(Object.assign({}, request), { document: encrypted }));
627
+ if (result.document)
628
+ result.document = (yield this.decrypt([result.document]))[0].entity;
629
+ return result;
630
+ });
631
+ }
568
632
  }
569
633
  exports.IccMessageXApi = IccMessageXApi;
570
634
  //# sourceMappingURL=icc-message-x-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AAGtD,kDAAiD;AAGjD,0EAAgG;AAChG,wEAAoE;AAOpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAGzD,mCAAmJ;AACnJ,4DAAwE;AACxE,kEAA8D;AAI9D,MAAa,cAAe,SAAQ,uBAAa;IAG/C,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,OAAO,CAAC,CAAC,CAAA;IAC7I,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,YAA8B,EAC9B,OAAmB,EACnB,cAAuB,EACxC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,gBAA+B,EAAE,EACjC,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,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,qBAAqB,CAAC,CAAA;IACxC,CAAC;IAED,gBAAgB,CAAC,IAAwB,EAAE,eAAwB,EAAE,KAAc;QACjF,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;IAED,qBAAqB,CAAC,IAA+B;QACnD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;CACF;AAhqBD,wCAgqBC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { DocIdentifier, ListOfIds, Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, TimingInfo, User } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainMessage } from '../icc-api/model/FilterChainMessage'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { AbstractFilter } from './filters/filters'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport { AbstractFilterMessage } from '../icc-api/model/AbstractFilterMessage'\nimport { BulkShareOrUpdateMetadataParams } from '../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\nexport class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Message))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = [],\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.encryptedFields = parseEncryptedFields(encryptedKeys, 'Message.')\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param m initialised data for the message. 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 * @return a new instance of message.\n */\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this message refers to.\n * @param m initialised data for the message. 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 message. 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 message.\n */\n async newInstanceWithPatient(\n user: User,\n patient: Patient | null,\n m: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n alternateRootDelegation?: string\n } = {}\n ) {\n const message = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.Message',\n id: m?.id ?? this.crypto.primitives.randomUuid(),\n created: m?.created ?? new Date().getTime(),\n modified: m?.modified ?? new Date().getTime(),\n responsible: m?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: m?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: m?.codes ?? [],\n tags: m?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\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.Message(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n message,\n EntityWithDelegationTypeName.Message,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Decrypts the encrypted content of messages.\n * @param messages the messages to decrypt.\n * @return the decrypted messages with their encryption status.\n */\n async decrypt(messages: Array<models.Message>) {\n return await this.crypto.xapi.tryDecryptEntities(messages, EntityWithDelegationTypeName.Message, (x) => new models.Message(x))\n }\n\n /**\n * Encrypts the content of messages.\n * @param messages the messages to encrypt.\n * @return the encrypted messages.\n */\n encrypt(messages: Array<models.Message>): Promise<Array<models.Message>> {\n return this.crypto.xapi.tryEncryptEntities(\n messages,\n EntityWithDelegationTypeName.Message,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Message(x)\n )\n }\n\n /**\n * @param message a message\n * @return the id of the patient that the message 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(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: message, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given message\n */\n async hasWriteAccess(message: models.Message): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: message, type: EntityWithDelegationTypeName.Message })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message 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 message.\n * @param message the message to share.\n * @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\n shareSecretIds: string[],\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Message> {\n return this.shareWithMany(message, { [delegateId]: { ...options, shareSecretIds } })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message 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 the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\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.Message> {\n return (await this.tryShareWithMany(message, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message 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 the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\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.Message>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(message, EntityWithDelegationTypeName.Message)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyMessageWithUser(undefined, entityWithEncryptionKey) : message\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Message,\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) => super.bulkShareMessages(x)\n )\n .then((r) => r.mapSuccessAsync(async (m) => (await this.decrypt([m]))[0].entity))\n }\n\n /**\n * @param message a message\n * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is\n * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: message, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the message, allowing resolution of anonymous delegations.\n * @param entity the message.\n * @param delegates the data owner ids of the delegates.\n */\n createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Message }, delegates)\n }\n\n /**\n * Retrieves the data owners that have access to the message.\n * @param entity the message.\n * @return the data owners with their access levels and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Message\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Message })\n }\n\n /**\n * Retrieves the encryption keys of the message.\n * @param entity the message.\n * @return the encryption keys.\n */\n getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * Subscribes to message events (create, update, delete).\n * @param eventTypes the types of events to subscribe to.\n * @param filter optional filter to apply to the events.\n * @param eventFired callback function to be called when an event is fired.\n * @param options optional subscription options.\n * @return a connection that can be used to close the subscription.\n */\n async subscribeToMessageEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Message> | undefined,\n eventFired: (message: Message) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Message,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0].entity\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n private async decryptPage(page: PaginatedListMessage): Promise<PaginatedListMessage> {\n return {\n ...page,\n rows: (await this.decrypt(page.rows ?? [])).map((x) => x.entity),\n }\n }\n\n /**\n * Creates a message.\n * @param user the current user (unused, for compatibility).\n * @param body the message to create.\n * @return the created message.\n */\n async createMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.createMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n /**\n * Finds messages with pagination.\n * @param user the current user (unused, for compatibility).\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @return a paginated list of messages.\n */\n async findMessagesWithUser(\n user: models.User | undefined,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessages(startKey, startDocumentId, limit))\n }\n\n /**\n * Finds messages by sender address with pagination.\n * @param user the current user (unused, for compatibility).\n * @param fromAddress the sender address to filter by.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByFromAddressWithUser(\n user: models.User | undefined,\n fromAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByFromAddress(fromAddress, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysUsingPostWithUser(user: models.User | undefined, body?: Array<string>): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeysUsingPost(body))).map((x) => x.entity)\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysWithUser(user: models.User | undefined, secretFKeys: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeys(secretFKeys))).map((x) => x.entity)\n }\n\n /**\n * Finds messages by recipient address with pagination.\n * @param user the current user (unused, for compatibility).\n * @param toAddress the recipient address to filter by.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param reverse optional flag to reverse the sort order.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByToAddressWithUser(\n user: models.User | undefined,\n toAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n reverse?: boolean,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByToAddress(toAddress, startKey, startDocumentId, limit, reverse, hcpId))\n }\n\n /**\n * Finds messages by transport GUID with pagination.\n * @param user the current user (unused, for compatibility).\n * @param transportGuid the transport GUID to filter by.\n * @param received optional flag to filter by received status.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByTransportGuidWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuid(transportGuid, received, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * Finds messages by transport GUID and sent date range with pagination.\n * @param user the current user (unused, for compatibility).\n * @param transportGuid the transport GUID to filter by.\n * @param from optional start timestamp for the date range.\n * @param to optional end timestamp for the date range.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByTransportGuidSentDateWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuidSentDate(transportGuid, from, to, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * Retrieves the children messages of a message.\n * @param user the current user (unused, for compatibility).\n * @param messageId the id of the parent message.\n * @return the children messages.\n */\n async getChildrenMessagesWithUser(user: models.User | undefined, messageId: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessages(messageId))).map((x) => x.entity)\n }\n\n /**\n * Retrieves the children messages of a list of parent messages.\n * @param user the current user (unused, for compatibility).\n * @param body the list of parent message ids.\n * @return the children messages.\n */\n async getChildrenMessagesOfListWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessagesOfList(body))).map((x) => x.entity)\n }\n\n /**\n * Retrieves a message by its id.\n * @param user the current user (unused, for compatibility).\n * @param messageId the id of the message.\n * @return the message.\n */\n async getMessageWithUser(user: models.User | undefined, messageId: string): Promise<Message> {\n return (await this.decrypt([await super.getMessage(messageId)]))[0].entity\n }\n\n /**\n * Retrieves multiple messages by their ids.\n * @param user the current user (unused, for compatibility).\n * @param messageIds the list of message ids.\n * @return the messages.\n */\n async getMessagesWithUser(user: models.User | undefined, messageIds: ListOfIds): Promise<Message[]> {\n return (await this.decrypt(await super.getMessages(messageIds))).map((x) => x.entity)\n }\n\n /**\n * Lists messages by invoice ids.\n * @param user the current user (unused, for compatibility).\n * @param body the list of invoice ids.\n * @return the messages associated with the invoices.\n */\n async listMessagesByInvoiceIdsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByInvoiceIds(body))).map((x) => x.entity)\n }\n\n /**\n * Lists messages by transport GUIDs.\n * @param user the current user (unused, for compatibility).\n * @param hcpId the healthcare party id.\n * @param body the list of transport GUIDs.\n * @return the messages associated with the transport GUIDs.\n */\n async listMessagesByTransportGuidsWithUser(user: models.User | undefined, hcpId: string, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByTransportGuids(hcpId, body))).map((x) => x.entity)\n }\n\n /**\n * Modifies a message.\n * @param user the current user (unused, for compatibility).\n * @param body the message to modify.\n * @return the modified message.\n */\n async modifyMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.modifyMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n /**\n * Sets the status bits of multiple messages.\n * @param user the current user (unused, for compatibility).\n * @param status the status bits to set.\n * @param body the list of message ids.\n * @return the updated messages.\n */\n async setMessagesStatusBitsWithUser(user: models.User | undefined, status: number, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesStatusBits(status, body))).map((x) => x.entity)\n }\n\n /**\n * Filters messages using a filter chain with pagination.\n * @param user the current user (unused, for compatibility).\n * @param body the filter chain to apply.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param collectTiming add timing information to the response\n * @return a paginated list of filtered messages.\n */\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming?: false\n ): Promise<PaginatedListMessage>\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming?: true\n ): Promise<PaginatedListMessage & TimingInfo>\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming: boolean = false\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.filterMessagesBy(body, startDocumentId, limit, collectTiming as any))\n }\n\n /**\n * Sets the read status of multiple messages.\n * @param user the current user (unused, for compatibility).\n * @param body the read status update information.\n * @return the updated messages.\n */\n async setMessagesReadStatusWithUser(user: models.User | undefined, body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((x) => x.entity)\n }\n\n createMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n findMessages(startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByFromAddress(fromAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeysUsingPost(body?: Array<string>): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeys(secretFKeys: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByToAddress(toAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, reverse?: boolean, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuid(\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuidSentDate(\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessages(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessagesOfList(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n getMessage(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getMessages(messageIds: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByInvoiceIds(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByTransportGuids(hcpId: string, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n modifyMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesStatusBits(status: number, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesReadStatus(body?: MessagesReadStatusUpdate): never {\n throw new Error('Use withUser method')\n }\n}\n"]}
1
+ {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsD;AAGtD,kDAAiD;AAEjD,+DAAoD;AAEpD,0EAAgG;AAChG,wEAAoE;AAOpE,IAAO,eAAe,GAAG,mCAAgB,CAAC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,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YACxF,OAAO,MAAM,CAAA;QACf,CAAC;KAAA;CACF;AA9tBD,wCA8tBC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { DocIdentifier, ListOfIds, Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, TimingInfo, User } from '../icc-api/model/models'\nimport { cloneDeep } from './utils/collection-utils'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainMessage } from '../icc-api/model/FilterChainMessage'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { AbstractFilter } from './filters/filters'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport { AbstractFilterMessage } from '../icc-api/model/AbstractFilterMessage'\nimport { BulkShareOrUpdateMetadataParams } from '../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\nexport class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Message))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = [],\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.encryptedFields = parseEncryptedFields(encryptedKeys, 'Message.')\n }\n\n // noinspection JSUnusedGlobalSymbols\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param m initialised data for the message. 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 * @return a new instance of message.\n */\n newInstance(user: User, m: any) {\n return this.newInstanceWithPatient(user, null, m)\n }\n\n /**\n * Creates a new instance of message with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this message refers to.\n * @param m initialised data for the message. 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 message. 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 message.\n */\n async newInstanceWithPatient(\n user: User,\n patient: Patient | null,\n m: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n sfkOption?: SecretIdUseOption\n alternateRootDelegation?: string\n } = {}\n ) {\n const message = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.Message',\n id: m?.id ?? this.crypto.primitives.randomUuid(),\n created: m?.created ?? new Date().getTime(),\n modified: m?.modified ?? new Date().getTime(),\n responsible: m?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: m?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: m?.codes ?? [],\n tags: m?.tags ?? [],\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = patient\n ? await this.crypto.xapi.resolveSecretIdUseOptions(\n { entity: patient, type: EntityWithDelegationTypeName.Patient },\n options.sfkOption ?? SecretIdUseOption.UseAnySharedWithParent\n )\n : undefined\n if (patient && !sfk) throw new Error(`Couldn't find any sfk of parent patient ${patient.id}`)\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.Message(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n message,\n EntityWithDelegationTypeName.Message,\n patient?.id,\n sfk,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * Decrypts the encrypted content of messages.\n * @param messages the messages to decrypt.\n * @return the decrypted messages with their encryption status.\n */\n async decrypt(messages: Array<models.Message>) {\n return await this.crypto.xapi.tryDecryptEntities(messages, EntityWithDelegationTypeName.Message, (x) => new models.Message(x))\n }\n\n /**\n * Encrypts the content of messages.\n * @param messages the messages to encrypt.\n * @return the encrypted messages.\n */\n encrypt(messages: Array<models.Message>): Promise<Array<models.Message>> {\n return this.crypto.xapi.tryEncryptEntities(\n messages,\n EntityWithDelegationTypeName.Message,\n this.encryptedFields,\n true,\n false,\n (x) => new models.Message(x)\n )\n }\n\n /**\n * @param message a message\n * @return the id of the patient that the message 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(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: message, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given message\n */\n async hasWriteAccess(message: models.Message): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: message, type: EntityWithDelegationTypeName.Message })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message 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 message.\n * @param message the message to share.\n * @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id.\n * @param options optional parameters to customize the sharing behaviour:\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\n shareSecretIds: string[],\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Message> {\n return this.shareWithMany(message, { [delegateId]: { ...options, shareSecretIds } })\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message 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 the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\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.Message> {\n return (await this.tryShareWithMany(message, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param message the message 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 the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the\n * shared Message is the owning entity id. Mandatory.\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 * message does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this message 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 message: models.Message,\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.Message>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(message, EntityWithDelegationTypeName.Message)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyMessageWithUser(undefined, entityWithEncryptionKey) : message\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Message,\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) => super.bulkShareMessages(x)\n )\n .then((r) => r.mapSuccessAsync(async (m) => (await this.decrypt([m]))[0].entity))\n }\n\n /**\n * @param message a message\n * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is\n * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: message, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * Creates or updates de-anonymization metadata for the message, allowing resolution of anonymous delegations.\n * @param entity the message.\n * @param delegates the data owner ids of the delegates.\n */\n createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Message }, delegates)\n }\n\n /**\n * Retrieves the data owners that have access to the message.\n * @param entity the message.\n * @return the data owners with their access levels and a flag indicating if there are unknown anonymous data owners.\n */\n getDataOwnersWithAccessTo(\n entity: models.Message\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Message })\n }\n\n /**\n * Retrieves the encryption keys of the message.\n * @param entity the message.\n * @return the encryption keys.\n */\n getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n /**\n * Subscribes to message events (create, update, delete).\n * @param eventTypes the types of events to subscribe to.\n * @param filter optional filter to apply to the events.\n * @param eventFired callback function to be called when an event is fired.\n * @param options optional subscription options.\n * @return a connection that can be used to close the subscription.\n */\n async subscribeToMessageEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Message> | undefined,\n eventFired: (message: Message) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Message,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0].entity\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n private async decryptPage(page: PaginatedListMessage): Promise<PaginatedListMessage> {\n return {\n ...page,\n rows: (await this.decrypt(page.rows ?? [])).map((x) => x.entity),\n }\n }\n\n /**\n * Creates a message.\n * @param user the current user (unused, for compatibility).\n * @param body the message to create.\n * @return the created message.\n */\n async createMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.createMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n /**\n * Finds messages with pagination.\n * @param user the current user (unused, for compatibility).\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @return a paginated list of messages.\n */\n async findMessagesWithUser(\n user: models.User | undefined,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessages(startKey, startDocumentId, limit))\n }\n\n /**\n * Finds messages by sender address with pagination.\n * @param user the current user (unused, for compatibility).\n * @param fromAddress the sender address to filter by.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByFromAddressWithUser(\n user: models.User | undefined,\n fromAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByFromAddress(fromAddress, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysUsingPostWithUser(user: models.User | undefined, body?: Array<string>): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeysUsingPost(body))).map((x) => x.entity)\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysWithUser(user: models.User | undefined, secretFKeys: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeys(secretFKeys))).map((x) => x.entity)\n }\n\n /**\n * Finds messages by recipient address with pagination.\n * @param user the current user (unused, for compatibility).\n * @param toAddress the recipient address to filter by.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param reverse optional flag to reverse the sort order.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByToAddressWithUser(\n user: models.User | undefined,\n toAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n reverse?: boolean,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByToAddress(toAddress, startKey, startDocumentId, limit, reverse, hcpId))\n }\n\n /**\n * Finds messages by transport GUID with pagination.\n * @param user the current user (unused, for compatibility).\n * @param transportGuid the transport GUID to filter by.\n * @param received optional flag to filter by received status.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByTransportGuidWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuid(transportGuid, received, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * Finds messages by transport GUID and sent date range with pagination.\n * @param user the current user (unused, for compatibility).\n * @param transportGuid the transport GUID to filter by.\n * @param from optional start timestamp for the date range.\n * @param to optional end timestamp for the date range.\n * @param startKey optional start key for pagination.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param hcpId optional healthcare party id to filter by.\n * @return a paginated list of messages.\n */\n async findMessagesByTransportGuidSentDateWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuidSentDate(transportGuid, from, to, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * Retrieves the children messages of a message.\n * @param user the current user (unused, for compatibility).\n * @param messageId the id of the parent message.\n * @return the children messages.\n */\n async getChildrenMessagesWithUser(user: models.User | undefined, messageId: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessages(messageId))).map((x) => x.entity)\n }\n\n /**\n * Retrieves the children messages of a list of parent messages.\n * @param user the current user (unused, for compatibility).\n * @param body the list of parent message ids.\n * @return the children messages.\n */\n async getChildrenMessagesOfListWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessagesOfList(body))).map((x) => x.entity)\n }\n\n /**\n * Retrieves a message by its id.\n * @param user the current user (unused, for compatibility).\n * @param messageId the id of the message.\n * @return the message.\n */\n async getMessageWithUser(user: models.User | undefined, messageId: string): Promise<Message> {\n return (await this.decrypt([await super.getMessage(messageId)]))[0].entity\n }\n\n /**\n * Retrieves multiple messages by their ids.\n * @param user the current user (unused, for compatibility).\n * @param messageIds the list of message ids.\n * @return the messages.\n */\n async getMessagesWithUser(user: models.User | undefined, messageIds: ListOfIds): Promise<Message[]> {\n return (await this.decrypt(await super.getMessages(messageIds))).map((x) => x.entity)\n }\n\n /**\n * Lists messages by invoice ids.\n * @param user the current user (unused, for compatibility).\n * @param body the list of invoice ids.\n * @return the messages associated with the invoices.\n */\n async listMessagesByInvoiceIdsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByInvoiceIds(body))).map((x) => x.entity)\n }\n\n /**\n * Lists messages by transport GUIDs.\n * @param user the current user (unused, for compatibility).\n * @param hcpId the healthcare party id.\n * @param body the list of transport GUIDs.\n * @return the messages associated with the transport GUIDs.\n */\n async listMessagesByTransportGuidsWithUser(user: models.User | undefined, hcpId: string, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByTransportGuids(hcpId, body))).map((x) => x.entity)\n }\n\n /**\n * Modifies a message.\n * @param user the current user (unused, for compatibility).\n * @param body the message to modify.\n * @return the modified message.\n */\n async modifyMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.modifyMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n /**\n * Sets the status bits of multiple messages.\n * @param user the current user (unused, for compatibility).\n * @param status the status bits to set.\n * @param body the list of message ids.\n * @return the updated messages.\n */\n async setMessagesStatusBitsWithUser(user: models.User | undefined, status: number, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesStatusBits(status, body))).map((x) => x.entity)\n }\n\n /**\n * Filters messages using a filter chain with pagination.\n * @param user the current user (unused, for compatibility).\n * @param body the filter chain to apply.\n * @param startDocumentId optional start document id for pagination.\n * @param limit optional maximum number of results to return.\n * @param collectTiming add timing information to the response\n * @return a paginated list of filtered messages.\n */\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming?: false\n ): Promise<PaginatedListMessage>\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming?: true\n ): Promise<PaginatedListMessage & TimingInfo>\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number,\n collectTiming: boolean = false\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.filterMessagesBy(body, startDocumentId, limit, collectTiming as any))\n }\n\n /**\n * Sets the read status of multiple messages.\n * @param user the current user (unused, for compatibility).\n * @param body the read status update information.\n * @return the updated messages.\n */\n async setMessagesReadStatusWithUser(user: models.User | undefined, body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((x) => x.entity)\n }\n\n createMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n findMessages(startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByFromAddress(fromAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeysUsingPost(body?: Array<string>): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeys(secretFKeys: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByToAddress(toAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, reverse?: boolean, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuid(\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuidSentDate(\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessages(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessagesOfList(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n getMessage(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getMessages(messageIds: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByInvoiceIds(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByTransportGuids(hcpId: string, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n modifyMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesStatusBits(status: number, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesReadStatus(body?: MessagesReadStatusUpdate): never {\n throw new Error('Use withUser method')\n }\n\n /**\n * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param entityId the id of the message to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the message.\n */\n getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Message>> {\n return super\n .getConflictsForEntity(entityId)\n .then((ms) => this.decrypt(ms))\n .then((res) => res.map(({ entity }) => entity))\n }\n\n /**\n * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved\n * winner returned by the backend.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerWithUser(\n user: models.User,\n request: models.ConflictResolutionRequest<models.Message>\n ): Promise<models.ConflictResolutionResult<models.Message>> {\n const encrypted = (await this.encrypt([cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinner({ ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt([result.document]))[0].entity\n return result\n }\n\n /**\n * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will decrypt the entities.\n * @param groupId the id of the group the message belongs to.\n * @param entityId the id of the message to retrieve the conflicts for.\n * @return the decrypted conflicting revisions of the message.\n */\n getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Message>> {\n return super\n .getConflictsForEntityInGroup(groupId, entityId)\n .then((ms) => this.decrypt(ms))\n .then((res) => res.map(({ entity }) => entity))\n }\n\n /**\n * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.\n * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.\n * @param groupId the id of the group the message belongs to.\n * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.\n * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.\n */\n async declareConflictWinnerInGroupWithUser(\n user: models.User,\n groupId: string,\n request: models.ConflictResolutionRequest<models.Message>\n ): Promise<models.ConflictResolutionResult<models.Message>> {\n const encrypted = (await this.encrypt([cloneDeep(request.document!)]))[0]\n const result = await super.declareConflictWinnerInGroup(groupId, { ...request, document: encrypted })\n if (result.document) result.document = (await this.decrypt([result.document]))[0].entity\n return result\n }\n}\n"]}
@@ -567,4 +567,35 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
567
567
  * will be initialized in the standard way (automatically on the first time data is shared with the user).
568
568
  */
569
569
  forceInitialiseExchangeDataToNewlyInvitedPatient(patientId: string): Promise<boolean>;
570
+ /**
571
+ * Like {@link getConflictsForEntity} but additionally decrypts the conflicting revisions for the given user.
572
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
573
+ * @param entityId the id of the patient to retrieve the conflicts for.
574
+ * @return the decrypted conflicting revisions of the patient.
575
+ */
576
+ getConflictsForEntityWithUser(user: models.User, entityId: string): Promise<Array<models.Patient>>;
577
+ /**
578
+ * Like {@link declareConflictWinner} but encrypts the winning revision before sending it and decrypts the saved
579
+ * winner returned by the backend.
580
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
581
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
582
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
583
+ */
584
+ declareConflictWinnerWithUser(user: models.User, request: models.ConflictResolutionRequest<models.Patient>): Promise<models.ConflictResolutionResult<models.Patient>>;
585
+ /**
586
+ * Like {@link getConflictsForEntityWithUser} but targets the entity of the group with the given id.
587
+ * @param user the current user, used to determine the data owner that will decrypt the entities.
588
+ * @param groupId the id of the group the patient belongs to.
589
+ * @param entityId the id of the patient to retrieve the conflicts for.
590
+ * @return the decrypted conflicting revisions of the patient.
591
+ */
592
+ getConflictsForEntityInGroupWithUser(user: models.User, groupId: string, entityId: string): Promise<Array<models.Patient>>;
593
+ /**
594
+ * Like {@link declareConflictWinnerWithUser} but targets the entity of the group with the given id.
595
+ * @param user the current user, used to determine the data owner that will encrypt/decrypt the entity.
596
+ * @param groupId the id of the group the patient belongs to.
597
+ * @param request the {@link models.ConflictResolutionRequest} carrying the (decrypted) winning revision and the conflicts to purge.
598
+ * @return the {@link models.ConflictResolutionResult} with the decrypted saved winner and the conflicts that are still unresolved.
599
+ */
600
+ declareConflictWinnerInGroupWithUser(user: models.User, groupId: string, request: models.ConflictResolutionRequest<models.Patient>): Promise<models.ConflictResolutionResult<models.Patient>>;
570
601
  }