@icure/api 8.2.3 → 8.2.5

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 (337) hide show
  1. package/icc-api/api/IccAuthApi.js +1 -1
  2. package/icc-api/api/IccAuthApi.js.map +1 -1
  3. package/icc-api/api/IccDocumentApi.js.map +1 -1
  4. package/icc-api/api/IccFormApi.js.map +1 -1
  5. package/icc-api/api/IccReceiptApi.js.map +1 -1
  6. package/icc-api/api/IccRestApiPath.js +1 -2
  7. package/icc-api/api/IccRestApiPath.js.map +1 -1
  8. package/icc-api/api/XHR.js +10 -8
  9. package/icc-api/api/XHR.js.map +1 -1
  10. package/icc-api/model/Address.js +1 -1
  11. package/icc-api/model/Address.js.map +1 -1
  12. package/icc-api/model/Amp.js +1 -1
  13. package/icc-api/model/Amp.js.map +1 -1
  14. package/icc-api/model/AmpComponent.js +1 -1
  15. package/icc-api/model/AmpComponent.js.map +1 -1
  16. package/icc-api/model/Ampp.js +1 -1
  17. package/icc-api/model/Ampp.js.map +1 -1
  18. package/icc-api/model/AmppComponent.js +1 -1
  19. package/icc-api/model/AmppComponent.js.map +1 -1
  20. package/icc-api/model/CareTeamMember.js +1 -1
  21. package/icc-api/model/CareTeamMember.js.map +1 -1
  22. package/icc-api/model/CareTeamMembership.js +1 -1
  23. package/icc-api/model/CareTeamMembership.js.map +1 -1
  24. package/icc-api/model/Code.js +1 -1
  25. package/icc-api/model/Code.js.map +1 -1
  26. package/icc-api/model/Contact.js.map +1 -1
  27. package/icc-api/model/Content.js.map +1 -1
  28. package/icc-api/model/DataOwnerTypeEnum.js +1 -1
  29. package/icc-api/model/DataOwnerTypeEnum.js.map +1 -1
  30. package/icc-api/model/DataOwnerWithType.js +1 -1
  31. package/icc-api/model/DataOwnerWithType.js.map +1 -1
  32. package/icc-api/model/DatabaseSynchronization.js +1 -1
  33. package/icc-api/model/DatabaseSynchronization.js.map +1 -1
  34. package/icc-api/model/Dmpp.js +1 -1
  35. package/icc-api/model/Dmpp.js.map +1 -1
  36. package/icc-api/model/Document.js +1 -1
  37. package/icc-api/model/Document.js.map +1 -1
  38. package/icc-api/model/DocumentTemplate.d.ts +1 -1
  39. package/icc-api/model/DocumentTemplate.js +1 -1
  40. package/icc-api/model/DocumentTemplate.js.map +1 -1
  41. package/icc-api/model/Editor.js +1 -1
  42. package/icc-api/model/Editor.js.map +1 -1
  43. package/icc-api/model/EfactInvoice.js +1 -1
  44. package/icc-api/model/EfactInvoice.js.map +1 -1
  45. package/icc-api/model/EmailOrSmsMessage.js +1 -1
  46. package/icc-api/model/EmailOrSmsMessage.js.map +1 -1
  47. package/icc-api/model/FlatRateTarification.js +1 -1
  48. package/icc-api/model/FlatRateTarification.js.map +1 -1
  49. package/icc-api/model/Formula.js +1 -1
  50. package/icc-api/model/Formula.js.map +1 -1
  51. package/icc-api/model/FrontEndMigration.js +1 -1
  52. package/icc-api/model/FrontEndMigration.js.map +1 -1
  53. package/icc-api/model/HealthElement.js +1 -1
  54. package/icc-api/model/HealthElement.js.map +1 -1
  55. package/icc-api/model/HealthcareParty.js +1 -1
  56. package/icc-api/model/HealthcareParty.js.map +1 -1
  57. package/icc-api/model/HealthcarePartyHistoryStatus.js +1 -1
  58. package/icc-api/model/HealthcarePartyHistoryStatus.js.map +1 -1
  59. package/icc-api/model/Ingredient.js +1 -1
  60. package/icc-api/model/Ingredient.js.map +1 -1
  61. package/icc-api/model/Invoice.js +1 -1
  62. package/icc-api/model/Invoice.js.map +1 -1
  63. package/icc-api/model/InvoiceItem.js +1 -1
  64. package/icc-api/model/InvoiceItem.js.map +1 -1
  65. package/icc-api/model/InvoicingCode.js +1 -1
  66. package/icc-api/model/InvoicingCode.js.map +1 -1
  67. package/icc-api/model/MaintenanceTask.js +1 -1
  68. package/icc-api/model/MaintenanceTask.js.map +1 -1
  69. package/icc-api/model/Measure.js.map +1 -1
  70. package/icc-api/model/MedicalHouseContract.js +1 -1
  71. package/icc-api/model/MedicalHouseContract.js.map +1 -1
  72. package/icc-api/model/ModelHelper.js +9 -10
  73. package/icc-api/model/ModelHelper.js.map +1 -1
  74. package/icc-api/model/Partnership.js +1 -1
  75. package/icc-api/model/Partnership.js.map +1 -1
  76. package/icc-api/model/Patient.js +1 -1
  77. package/icc-api/model/Patient.js.map +1 -1
  78. package/icc-api/model/PatientByHcPartyGenderEducationProfession.js +1 -1
  79. package/icc-api/model/PatientByHcPartyGenderEducationProfession.js.map +1 -1
  80. package/icc-api/model/PatientHealthCareParty.js +1 -1
  81. package/icc-api/model/PatientHealthCareParty.js.map +1 -1
  82. package/icc-api/model/Payment.js +1 -1
  83. package/icc-api/model/Payment.js.map +1 -1
  84. package/icc-api/model/PermissionCriterion.js +1 -1
  85. package/icc-api/model/PermissionCriterion.js.map +1 -1
  86. package/icc-api/model/PermissionItem.js +1 -1
  87. package/icc-api/model/PermissionItem.js.map +1 -1
  88. package/icc-api/model/PersonName.js +1 -1
  89. package/icc-api/model/PersonName.js.map +1 -1
  90. package/icc-api/model/PropertyTypeStub.js +1 -1
  91. package/icc-api/model/PropertyTypeStub.js.map +1 -1
  92. package/icc-api/model/Reimbursement.js +1 -1
  93. package/icc-api/model/Reimbursement.js.map +1 -1
  94. package/icc-api/model/RoleSourceEnum.js +1 -1
  95. package/icc-api/model/RoleSourceEnum.js.map +1 -1
  96. package/icc-api/model/SecureDelegation.js +1 -1
  97. package/icc-api/model/SecureDelegation.js.map +1 -1
  98. package/icc-api/model/Service.js.map +1 -1
  99. package/icc-api/model/StandardSubstance.js +1 -1
  100. package/icc-api/model/StandardSubstance.js.map +1 -1
  101. package/icc-api/model/SumehrValidity.js +1 -1
  102. package/icc-api/model/SumehrValidity.js.map +1 -1
  103. package/icc-api/model/Tarification.js +1 -1
  104. package/icc-api/model/Tarification.js.map +1 -1
  105. package/icc-api/model/Telecom.js +1 -1
  106. package/icc-api/model/Telecom.js.map +1 -1
  107. package/icc-api/model/Topic.js +1 -1
  108. package/icc-api/model/Topic.js.map +1 -1
  109. package/icc-api/model/TypedValueObject.js +1 -1
  110. package/icc-api/model/TypedValueObject.js.map +1 -1
  111. package/icc-api/model/User.js +1 -1
  112. package/icc-api/model/User.js.map +1 -1
  113. package/icc-api/model/UserTypeEnum.js +1 -1
  114. package/icc-api/model/UserTypeEnum.js.map +1 -1
  115. package/icc-api/model/VirtualIngredient.js +1 -1
  116. package/icc-api/model/VirtualIngredient.js.map +1 -1
  117. package/icc-api/model/internal/RecoveryData.js +1 -1
  118. package/icc-api/model/internal/RecoveryData.js.map +1 -1
  119. package/icc-api/model/requests/EntityBulkShareResult.js.map +1 -1
  120. package/icc-api/model/requests/EntityShareOrMetadataUpdateRequest.js.map +1 -1
  121. package/icc-api/model/requests/EntityShareRequest.js +1 -1
  122. package/icc-api/model/requests/EntityShareRequest.js.map +1 -1
  123. package/icc-api/model/requests/EntitySharedMetadataUpdateRequest.js +1 -1
  124. package/icc-api/model/requests/EntitySharedMetadataUpdateRequest.js.map +1 -1
  125. package/icc-x-api/auth/AuthenticationProvider.js.map +1 -1
  126. package/icc-x-api/auth/BasicAuthService.js.map +1 -1
  127. package/icc-x-api/auth/EnsembleAuthService.js.map +1 -1
  128. package/icc-x-api/auth/JwtAuthService.js.map +1 -1
  129. package/icc-x-api/auth/JwtBridgedAuthService.d.ts +1 -1
  130. package/icc-x-api/auth/JwtBridgedAuthService.js +1 -1
  131. package/icc-x-api/auth/JwtBridgedAuthService.js.map +1 -1
  132. package/icc-x-api/auth/JwtUtils.js +3 -4
  133. package/icc-x-api/auth/JwtUtils.js.map +1 -1
  134. package/icc-x-api/auth/NoAuthService.js.map +1 -1
  135. package/icc-x-api/auth/SmartAuthProvider.d.ts +1 -1
  136. package/icc-x-api/auth/SmartAuthProvider.js +1 -1
  137. package/icc-x-api/auth/SmartAuthProvider.js.map +1 -1
  138. package/icc-x-api/crypto/AES.js.map +1 -1
  139. package/icc-x-api/crypto/AccessControlKeysHeadersProvider.js.map +1 -1
  140. package/icc-x-api/crypto/AccessControlSecretUtils.js.map +1 -1
  141. package/icc-x-api/crypto/BaseExchangeDataManager.js +10 -10
  142. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  143. package/icc-x-api/crypto/BaseExchangeKeysManager.js +4 -4
  144. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
  145. package/icc-x-api/crypto/CryptoStrategies.d.ts +5 -7
  146. package/icc-x-api/crypto/CryptoStrategies.js.map +1 -1
  147. package/icc-x-api/crypto/DelegationsDeAnonymization.js +1 -1
  148. package/icc-x-api/crypto/DelegationsDeAnonymization.js.map +1 -1
  149. package/icc-x-api/crypto/ExchangeDataManager.js +7 -8
  150. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  151. package/icc-x-api/crypto/ExchangeDataMapManager.js.map +1 -1
  152. package/icc-x-api/crypto/ExchangeKeysManager.js +1 -1
  153. package/icc-x-api/crypto/ExchangeKeysManager.js.map +1 -1
  154. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js +11 -10
  155. package/icc-x-api/crypto/ExtendedApisUtilsImpl.js.map +1 -1
  156. package/icc-x-api/crypto/HMACUtils.js.map +1 -1
  157. package/icc-x-api/crypto/KeyRecovery.js +5 -5
  158. package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
  159. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js +3 -3
  160. package/icc-x-api/crypto/NativeCryptoPrimitivesBridge.js.map +1 -1
  161. package/icc-x-api/crypto/RSA.js +4 -4
  162. package/icc-x-api/crypto/RSA.js.map +1 -1
  163. package/icc-x-api/crypto/RecoveryDataEncryption.js +1 -1
  164. package/icc-x-api/crypto/RecoveryDataEncryption.js.map +1 -1
  165. package/icc-x-api/crypto/SecretIdUseOption.js +1 -1
  166. package/icc-x-api/crypto/SecretIdUseOption.js.map +1 -1
  167. package/icc-x-api/crypto/SecureDelegationsEncryption.js +4 -4
  168. package/icc-x-api/crypto/SecureDelegationsEncryption.js.map +1 -1
  169. package/icc-x-api/crypto/SecureDelegationsManager.js +1 -1
  170. package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
  171. package/icc-x-api/crypto/SecurityMetadataDecryptor.d.ts +1 -1
  172. package/icc-x-api/crypto/SecurityMetadataDecryptor.js +9 -9
  173. package/icc-x-api/crypto/SecurityMetadataDecryptor.js.map +1 -1
  174. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
  175. package/icc-x-api/crypto/ShareMetadataBehaviour.js +1 -1
  176. package/icc-x-api/crypto/ShareMetadataBehaviour.js.map +1 -1
  177. package/icc-x-api/crypto/TransferKeysManager.js +1 -1
  178. package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
  179. package/icc-x-api/crypto/UserEncryptionKeysManager.js +2 -2
  180. package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
  181. package/icc-x-api/crypto/shamir.d.ts +2 -2
  182. package/icc-x-api/crypto/shamir.js +4 -4
  183. package/icc-x-api/crypto/shamir.js.map +1 -1
  184. package/icc-x-api/crypto/utils.js +14 -15
  185. package/icc-x-api/crypto/utils.js.map +1 -1
  186. package/icc-x-api/icc-accesslog-x-api.js +10 -10
  187. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  188. package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
  189. package/icc-x-api/icc-calendar-item-x-api.js +7 -7
  190. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  191. package/icc-x-api/icc-classification-x-api.js +5 -5
  192. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  193. package/icc-x-api/icc-code-x-api.js.map +1 -1
  194. package/icc-x-api/icc-contact-x-api.js +12 -12
  195. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  196. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  197. package/icc-x-api/icc-device-x-api.js +2 -2
  198. package/icc-x-api/icc-device-x-api.js.map +1 -1
  199. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  200. package/icc-x-api/icc-document-x-api.js +15 -15
  201. package/icc-x-api/icc-document-x-api.js.map +1 -1
  202. package/icc-x-api/icc-form-x-api.js +7 -7
  203. package/icc-x-api/icc-form-x-api.js.map +1 -1
  204. package/icc-x-api/icc-hcparty-x-api.js +4 -4
  205. package/icc-x-api/icc-hcparty-x-api.js.map +1 -1
  206. package/icc-x-api/icc-helement-x-api.js +10 -10
  207. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  208. package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
  209. package/icc-x-api/icc-invoice-x-api.js +7 -7
  210. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  211. package/icc-x-api/icc-maintenance-task-x-api.js +7 -7
  212. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  213. package/icc-x-api/icc-message-x-api.js +8 -8
  214. package/icc-x-api/icc-message-x-api.js.map +1 -1
  215. package/icc-x-api/icc-patient-x-api.js +11 -11
  216. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  217. package/icc-x-api/icc-receipt-x-api.js +10 -10
  218. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  219. package/icc-x-api/icc-recovery-x-api.js +4 -4
  220. package/icc-x-api/icc-recovery-x-api.js.map +1 -1
  221. package/icc-x-api/icc-time-table-x-api.js +5 -5
  222. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  223. package/icc-x-api/icc-topic-x-api.js +9 -9
  224. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  225. package/icc-x-api/icc-user-x-api.js +4 -4
  226. package/icc-x-api/icc-user-x-api.js.map +1 -1
  227. package/icc-x-api/index.js +22 -22
  228. package/icc-x-api/index.js.map +1 -1
  229. package/icc-x-api/maintenance/KeyPairUpdateRequest.js +2 -2
  230. package/icc-x-api/maintenance/KeyPairUpdateRequest.js.map +1 -1
  231. package/icc-x-api/storage/IcureStorageFacade.js +1 -1
  232. package/icc-x-api/storage/IcureStorageFacade.js.map +1 -1
  233. package/icc-x-api/storage/LocalStorageImpl.js +1 -1
  234. package/icc-x-api/storage/LocalStorageImpl.js.map +1 -1
  235. package/icc-x-api/utils/EntityWithDelegationTypeName.js +4 -4
  236. package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -1
  237. package/icc-x-api/utils/asn1-packer.js +2 -3
  238. package/icc-x-api/utils/asn1-packer.js.map +1 -1
  239. package/icc-x-api/utils/asn1-parser.js +1 -2
  240. package/icc-x-api/utils/asn1-parser.js.map +1 -1
  241. package/icc-x-api/utils/binary-utils.js +11 -11
  242. package/icc-x-api/utils/binary-utils.js.map +1 -1
  243. package/icc-x-api/utils/code-util.js +1 -2
  244. package/icc-x-api/utils/code-util.js.map +1 -1
  245. package/icc-x-api/utils/collection-utils.js +5 -6
  246. package/icc-x-api/utils/collection-utils.js.map +1 -1
  247. package/icc-x-api/utils/crypto-utils.d.ts +1 -1
  248. package/icc-x-api/utils/crypto-utils.js +17 -18
  249. package/icc-x-api/utils/crypto-utils.js.map +1 -1
  250. package/icc-x-api/utils/formatting-util.js +21 -21
  251. package/icc-x-api/utils/formatting-util.js.map +1 -1
  252. package/icc-x-api/utils/functional-util.js +3 -4
  253. package/icc-x-api/utils/functional-util.js.map +1 -1
  254. package/icc-x-api/utils/graph-utils.js +3 -4
  255. package/icc-x-api/utils/graph-utils.js.map +1 -1
  256. package/icc-x-api/utils/hcp-util.js +4 -4
  257. package/icc-x-api/utils/hcp-util.js.map +1 -1
  258. package/icc-x-api/utils/insurability-util.js +6 -7
  259. package/icc-x-api/utils/insurability-util.js.map +1 -1
  260. package/icc-x-api/utils/lru-temporised-async-cache.js.map +1 -1
  261. package/icc-x-api/utils/net-utils.js +3 -4
  262. package/icc-x-api/utils/net-utils.js.map +1 -1
  263. package/icc-x-api/utils/person-util.js +3 -4
  264. package/icc-x-api/utils/person-util.js.map +1 -1
  265. package/icc-x-api/utils/proxy-utils.js.map +1 -1
  266. package/icc-x-api/utils/simple-lru-cache.js.map +1 -1
  267. package/icc-x-api/utils/uuid-encoder.js +2 -2
  268. package/icc-x-api/utils/uuid-encoder.js.map +1 -1
  269. package/icc-x-api/utils/websocket.d.ts +0 -1
  270. package/icc-x-api/utils/websocket.js +3 -3
  271. package/icc-x-api/utils/websocket.js.map +1 -1
  272. package/package.json +3 -3
  273. package/test/icc-api/api/IccAgendaApi.js.map +1 -1
  274. package/test/icc-api/api/IccCalendarItemApi.js.map +1 -1
  275. package/test/icc-api/api/IccCalendarItemTypeApi.js +2 -2
  276. package/test/icc-api/api/IccCalendarItemTypeApi.js.map +1 -1
  277. package/test/icc-api/api/IccDocumentApi.js.map +1 -1
  278. package/test/icc-api/api/IccKeywordApi.js.map +1 -1
  279. package/test/icc-api/api/IccMedicalLocationApi.js.map +1 -1
  280. package/test/icc-api/api/IccPlaceApi.js.map +1 -1
  281. package/test/icc-api/api/IccUserApi.js +6 -6
  282. package/test/icc-x-api/auth/group-switch-test.js.map +1 -1
  283. package/test/icc-x-api/auth/jwt-concurrency-test.js +1 -2
  284. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -1
  285. package/test/icc-x-api/auth/jwt-provider-test.js.map +1 -1
  286. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -1
  287. package/test/icc-x-api/autofix-anonymity-test.js.map +1 -1
  288. package/test/icc-x-api/confidential-entities-test.js +1 -1
  289. package/test/icc-x-api/confidential-entities-test.js.map +1 -1
  290. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -1
  291. package/test/icc-x-api/crud/entities-crud-test-interface.js +24 -24
  292. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -1
  293. package/test/icc-x-api/crypto/anonymous-delegations-test.js +2 -2
  294. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -1
  295. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -1
  296. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -1
  297. package/test/icc-x-api/crypto/exchange-data-manager-test.js +4 -4
  298. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -1
  299. package/test/icc-x-api/crypto/full-crypto-test.js +5 -5
  300. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -1
  301. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js +7 -7
  302. package/test/icc-x-api/crypto/legacy-metadata-migration-test.js.map +1 -1
  303. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +2 -2
  304. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -1
  305. package/test/icc-x-api/crypto/shamir.js.map +1 -1
  306. package/test/icc-x-api/crypto/soft-deleted-data-owners.js +3 -3
  307. package/test/icc-x-api/crypto/soft-deleted-data-owners.js.map +1 -1
  308. package/test/icc-x-api/entity-with-attachments-api-test.js +2 -2
  309. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -1
  310. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +4 -4
  311. package/test/icc-x-api/icc-message-x-api.js +1 -1
  312. package/test/icc-x-api/icc-message-x-api.js.map +1 -1
  313. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -1
  314. package/test/icc-x-api/icc-recovery-x-api.js.map +1 -1
  315. package/test/icc-x-api/icc-topic-x-api.js.map +1 -1
  316. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -1
  317. package/test/icc-x-api/patient-user.js.map +1 -1
  318. package/test/icc-x-api/test-legacy-data-support.js.map +1 -1
  319. package/test/icc-x-api/utils/graph-test.js.map +1 -1
  320. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +1 -1
  321. package/test/support/CSM-243.js +2 -2
  322. package/test/support/CSM-243.js.map +1 -1
  323. package/test/support/CSM-93.js +1 -1
  324. package/test/support/CSM-93.js.map +1 -1
  325. package/test/utils/FakeDataOwnerApi.js.map +1 -1
  326. package/test/utils/FakeEncryptionKeysManager.js +2 -2
  327. package/test/utils/FakeEncryptionKeysManager.js.map +1 -1
  328. package/test/utils/FakeExchangeDataApi.js.map +1 -1
  329. package/test/utils/FakeExchangeDataManager.js.map +1 -1
  330. package/test/utils/FakeGenericApi.js.map +1 -1
  331. package/test/utils/TestApi.js +2 -2
  332. package/test/utils/TestApi.js.map +1 -1
  333. package/test/utils/TestCryptoStrategies.js.map +1 -1
  334. package/test/utils/TestStorage.js +2 -2
  335. package/test/utils/TestStorage.js.map +1 -1
  336. package/test/utils/test_utils.js +22 -22
  337. package/test/utils/test_utils.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"icc-invoice-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-invoice-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA2D;AAG3D,4BAA2B;AAC3B,kDAAiD;AAGjD,0EAAgG;AAChG,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAOzD,mCAAsD;AACtD,kEAA8D;AAE9D,MAAa,cAAe,SAAQ,uBAAa;IAC/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,YAA6B,EAC7B,YAA8B,EAC9B,cAAuB,EACxC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAXtC,WAAM,GAAN,MAAM,CAAe;QACrB,iBAAY,GAAZ,YAAY,CAAiB;QAC7B,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,mBAAc,GA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icc-crypto-x-api'\n\nimport * as _ from 'lodash'\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 * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the invoice. 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 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 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 ...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 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 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 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!, _.uniq(extractedKeys))\n : await this.findInvoicesByHCPartyPatientForeignKeys(hcpartyId!, _.uniq(extractedKeys).join(','))\n return await this.decrypt(hcpartyId, invoices)\n }\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!, _.uniq(extractedKeys), startDate, endDate, descending)\n }\n\n encrypt(user: models.User, invoices: Array<models.Invoice>) {\n return Promise.resolve(invoices)\n }\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 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 getEncryptionKeysOf(entity: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\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":";;;;;;;;;;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AAC,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,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,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,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;AAvTD,wCAuTC","sourcesContent":["import { IccEntityrefApi, IccInvoiceApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as _ from 'lodash'\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 * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the invoice. 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 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 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 ...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 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 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 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!, _.uniq(extractedKeys))\n : await this.findInvoicesByHCPartyPatientForeignKeys(hcpartyId!, _.uniq(extractedKeys).join(','))\n return await this.decrypt(hcpartyId, invoices)\n }\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!, _.uniq(extractedKeys), startDate, endDate, descending)\n }\n\n encrypt(user: models.User, invoices: Array<models.Invoice>) {\n return Promise.resolve(invoices)\n }\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 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 getEncryptionKeysOf(entity: models.Invoice): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Invoice }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Invoice, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Invoice }, delegates)\n }\n}\n"]}
@@ -51,9 +51,9 @@ class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi_1.IccMaintenanceTaskA
51
51
  * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
52
52
  * @return a new instance of maintenance task.
53
53
  */
54
- newInstance(user, m, options = {}) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h;
56
- return __awaiter(this, void 0, void 0, function* () {
54
+ newInstance(user_1, m_1) {
55
+ return __awaiter(this, arguments, void 0, function* (user, m, options = {}) {
56
+ var _a, _b, _c, _d, _e, _f, _g, _h;
57
57
  const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user);
58
58
  const maintenanceTask = Object.assign(Object.assign({}, (m !== null && m !== void 0 ? m : {})), { _type: 'org.taktik.icure.entities.MaintenanceTask', id: (_a = m === null || m === void 0 ? void 0 : m.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = m === null || m === void 0 ? void 0 : m.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = m === null || m === void 0 ? void 0 : m.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = m === null || m === void 0 ? void 0 : m.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? dataOwnerId : undefined), author: (_e = m === null || m === void 0 ? void 0 : m.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined) });
59
59
  const extraDelegations = Object.assign(Object.assign({}, Object.fromEntries(((_g = (_f = user.autoDelegations) === null || _f === void 0 ? void 0 : _f.all) !== null && _g !== void 0 ? _g : []).map((d) => [d, AccessLevelEnum.WRITE]))), ((_h = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _h !== void 0 ? _h : {}));
@@ -151,8 +151,8 @@ class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi_1.IccMaintenanceTaskA
151
151
  * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
152
152
  * @return the updated entity
153
153
  */
154
- shareWith(delegateId, maintenanceTask, options = {}) {
155
- return __awaiter(this, void 0, void 0, function* () {
154
+ shareWith(delegateId_1, maintenanceTask_1) {
155
+ return __awaiter(this, arguments, void 0, function* (delegateId, maintenanceTask, options = {}) {
156
156
  return this.shareWithMany(maintenanceTask, { [delegateId]: options });
157
157
  });
158
158
  }
@@ -214,8 +214,8 @@ class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi_1.IccMaintenanceTaskA
214
214
  getEncryptionKeysOf(entity) {
215
215
  return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.MaintenanceTask }, undefined);
216
216
  }
217
- subscribeToMaintenanceTaskEvents(eventTypes, filter, eventFired, options = {}) {
218
- return __awaiter(this, void 0, void 0, function* () {
217
+ subscribeToMaintenanceTaskEvents(eventTypes_1, filter_1, eventFired_1) {
218
+ return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
219
219
  const currentUser = yield this.userApi.getCurrentUser();
220
220
  return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, utils_1.EntityWithDelegationTypeName.MaintenanceTask, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(currentUser, [encrypted]))[0]; })).then((rs) => new Connection_1.ConnectionImpl(rs));
221
221
  });
@@ -1 +1 @@
1
- {"version":3,"file":"icc-maintenance-task-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-maintenance-task-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gFAA4E;AAE5E,kDAAiD;AACjD,4BAA2B;AAE3B,oDAAmF;AAEnF,0EAAgG;AAChG,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,4EAAwE;AAKxE,mCAAmJ;AAInJ,4DAAwE;AAGxE,MAAa,sBAAuB,SAAQ,6CAAqB;IAG/D,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9B,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,eAAe,CAAC,CAClH,CAAA;IACH,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,UAA0B,EAC1B,YAA8B,EAC9B,OAAoB,EACpB,OAAmB,EACnB,cAAuB,EACxC,gBAA+B,EAAE,EACjC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,C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,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,eAAe,EAAE,EAC9D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAnUD,wDAmUC","sourcesContent":["import { IccMaintenanceTaskApi } from '../icc-api/api/IccMaintenanceTaskApi'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport * as _ from 'lodash'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { DocIdentifier, ListOfIds, MaintenanceTask } 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 { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { IccAuthApi } from '../icc-api'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { IccUserXApi } from './icc-user-x-api'\n\nexport class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi implements EncryptedEntityXApi<models.MaintenanceTask> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) =>\n this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.MaintenanceTask)\n )\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly hcPartyApi: IccHcpartyXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly userApi: IccUserXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = [],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'MaintenanceTask.')\n }\n\n /**\n * Creates a new instance of maintenance task with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param m initialised data for the maintenance task. 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 * - 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 maintenance task.\n */\n async newInstance(\n user: models.User,\n m: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const maintenanceTask = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.MaintenanceTask',\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 ? dataOwnerId : undefined),\n author: m?.author ?? (this.autofillAuthor ? user.id : undefined),\n }\n\n const extraDelegations = {\n ...Object.fromEntries((user.autoDelegations?.all ?? []).map((d) => [d, AccessLevelEnum.WRITE])),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.MaintenanceTask(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n maintenanceTask,\n EntityWithDelegationTypeName.MaintenanceTask,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n createMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n createMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | null> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((tasks) => super.createMaintenanceTask(tasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((tasks) => tasks[0])\n : Promise.resolve(null)\n }\n\n filterMaintenanceTasksBy(startDocumentId?: string, limit?: number, body?: models.FilterChainMaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTask(_maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<DocIdentifier> | never {\n return super.deleteMaintenanceTask(maintenanceTaskId)\n }\n\n deleteMaintenanceTasks(_maintenanceTaskIds: ListOfIds): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTasksWithUser(user: models.User, maintenanceTaskIds: ListOfIds): Promise<Array<DocIdentifier>> | never {\n return super.deleteMaintenanceTasks(maintenanceTaskIds)\n }\n\n filterMaintenanceTasksByWithUser(\n user: models.User,\n startDocumentId?: string,\n limit?: number,\n body?: models.FilterChainMaintenanceTask\n ): Promise<models.PaginatedListMaintenanceTask> {\n return super\n .filterMaintenanceTasksBy(startDocumentId, limit, body)\n .then((pl) => this.decrypt(user, pl.rows!).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n getMaintenanceTask(maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n getMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<models.MaintenanceTask | any> {\n return super\n .getMaintenanceTask(maintenanceTaskId)\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n }\n\n modifyMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n modifyMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body ? this.modifyMaintenanceTaskAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : Promise.resolve(null)\n }\n\n private modifyMaintenanceTaskAs(dataOwner: string, body: models.MaintenanceTask): Promise<models.MaintenanceTask> {\n return this.encryptAs(dataOwner, [_.cloneDeep(body)])\n .then((encTasks) => super.modifyMaintenanceTask(encTasks[0]))\n .then((mt) => this.decryptAs(dataOwner, [mt]))\n .then((mts) => mts[0])\n }\n\n encrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(dataOwnerId, maintenanceTasks)\n }\n\n private encryptAs(dataOwner: string, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n return this.crypto.xapi.tryEncryptEntities(\n maintenanceTasks,\n EntityWithDelegationTypeName.MaintenanceTask,\n this.encryptedFields,\n true,\n false,\n (x) => new models.MaintenanceTask(x)\n )\n }\n\n decrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.decryptAs(dataOwnerId, maintenanceTasks)\n }\n\n private async decryptAs(dataOwner: string, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n return (\n await this.crypto.xapi.tryDecryptEntities(maintenanceTasks, EntityWithDelegationTypeName.MaintenanceTask, (x) => new MaintenanceTask(x))\n ).map(({ entity }) => entity)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given maintenance task\n */\n async hasWriteAccess(maintenanceTask: models.MaintenanceTask): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: maintenanceTask, type: EntityWithDelegationTypeName.MaintenanceTask })\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task 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 maintenance task.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\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 maintenanceTask: models.MaintenanceTask,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.MaintenanceTask> {\n return this.shareWithMany(maintenanceTask, { [delegateId]: options })\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity.\n */\n async shareWithMany(\n maintenanceTask: models.MaintenanceTask,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.MaintenanceTask> {\n return (await this.tryShareWithMany(maintenanceTask, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\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 maintenanceTask: models.MaintenanceTask,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.MaintenanceTask>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n maintenanceTask,\n EntityWithDelegationTypeName.MaintenanceTask\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyMaintenanceTaskAs(self, entityWithEncryptionKey) : maintenanceTask\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.MaintenanceTask,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareMaintenanceTask(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decryptAs(self, [e]).then((es) => es[0])))\n }\n\n getDataOwnersWithAccessTo(\n entity: models.MaintenanceTask\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.MaintenanceTask })\n }\n\n getEncryptionKeysOf(entity: models.MaintenanceTask): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.MaintenanceTask }, undefined)\n }\n\n async subscribeToMaintenanceTaskEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<MaintenanceTask>,\n eventFired: (dataSample: MaintenanceTask) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n const currentUser = await this.userApi.getCurrentUser()\n\n return subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.MaintenanceTask,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt(currentUser, [encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n createDelegationDeAnonymizationMetadata(entity: MaintenanceTask, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.MaintenanceTask },\n delegates\n )\n }\n}\n"]}
1
+ {"version":3,"file":"icc-maintenance-task-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-maintenance-task-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gFAA4E;AAE5E,kDAAiD;AACjD,4BAA2B;AAE3B,oDAAmF;AAEnF,0EAAgG;AAChG,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AACzD,4EAAwE;AAKxE,mCAAmJ;AAInJ,4DAAwE;AAGxE,MAAa,sBAAuB,SAAQ,6CAAqB;IAG/D,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9B,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B,CAAC,eAAe,CAAC,CAClH,CAAA;IACH,CAAC;IAED,YACE,IAAY,EACZ,OAAkC,EACjB,MAAqB,EACrB,UAA0B,EAC1B,YAA8B,EAC9B,OAAoB,EACpB,OAAmB,EACnB,cAAuB,EACxC,gBAA+B,EAAE,EACjC,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAdtC,WAAM,GAAN,MAAM,CAAe;QACrB,eAAU,GAAV,UAAU,CAAgB;QAC1B,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,YAA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IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,eAAe,EAAE,CAAC,CAAA;IACzI,CAAC;IAED,mBAAmB,CAAC,MAA8B;QAChD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,eAAe,EAAE,EAAE,SAAS,CAAC,CAAA;IACrH,CAAC;IAEK,gCAAgC;6DACpC,UAA8C,EAC9C,MAAuC,EACvC,UAA0D,EAC1D,UAA+B,EAAE;YAEjC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;YAEvD,OAAO,IAAA,+BAAuB,EAC5B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,EACZ,oCAA4B,CAAC,eAAe,EAC5C,UAAU,EACV,MAAM,EACN,UAAU,EACV,OAAO,EACP,CAAO,SAAS,EAAE,EAAE,gDAAC,OAAA,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,GAAA,CACvE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;KAAA;IAED,uCAAuC,CAAC,MAAuB,EAAE,SAAmB;QAClF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,eAAe,EAAE,EAC9D,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAnUD,wDAmUC","sourcesContent":["import { IccMaintenanceTaskApi } from '../icc-api/api/IccMaintenanceTaskApi'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport * as models from '../icc-api/model/models'\nimport * as _ from 'lodash'\nimport { IccHcpartyXApi } from './icc-hcparty-x-api'\nimport { DocIdentifier, ListOfIds, MaintenanceTask } 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 { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { IccAuthApi } from '../icc-api'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { AbstractFilter } from './filters/filters'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { IccUserXApi } from './icc-user-x-api'\n\nexport class IccMaintenanceTaskXApi extends IccMaintenanceTaskApi implements EncryptedEntityXApi<models.MaintenanceTask> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) =>\n this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.MaintenanceTask)\n )\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly hcPartyApi: IccHcpartyXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly userApi: IccUserXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n encryptedKeys: Array<string> = [],\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'MaintenanceTask.')\n }\n\n /**\n * Creates a new instance of maintenance task with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param m initialised data for the maintenance task. 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 * - 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 maintenance task.\n */\n async newInstance(\n user: models.User,\n m: any,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n alternateRootDelegation?: string\n } = {}\n ) {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n const maintenanceTask = {\n ...(m ?? {}),\n _type: 'org.taktik.icure.entities.MaintenanceTask',\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 ? dataOwnerId : undefined),\n author: m?.author ?? (this.autofillAuthor ? user.id : undefined),\n }\n\n const extraDelegations = {\n ...Object.fromEntries((user.autoDelegations?.all ?? []).map((d) => [d, AccessLevelEnum.WRITE])),\n ...(options?.additionalDelegates ?? {}),\n }\n return new models.MaintenanceTask(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n maintenanceTask,\n EntityWithDelegationTypeName.MaintenanceTask,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n createMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n createMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | null> {\n return body\n ? this.encrypt(user, [_.cloneDeep(body)])\n .then((tasks) => super.createMaintenanceTask(tasks[0]))\n .then((mt) => this.decrypt(user, [mt]))\n .then((tasks) => tasks[0])\n : Promise.resolve(null)\n }\n\n filterMaintenanceTasksBy(startDocumentId?: string, limit?: number, body?: models.FilterChainMaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTask(_maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<DocIdentifier> | never {\n return super.deleteMaintenanceTask(maintenanceTaskId)\n }\n\n deleteMaintenanceTasks(_maintenanceTaskIds: ListOfIds): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n deleteMaintenanceTasksWithUser(user: models.User, maintenanceTaskIds: ListOfIds): Promise<Array<DocIdentifier>> | never {\n return super.deleteMaintenanceTasks(maintenanceTaskIds)\n }\n\n filterMaintenanceTasksByWithUser(\n user: models.User,\n startDocumentId?: string,\n limit?: number,\n body?: models.FilterChainMaintenanceTask\n ): Promise<models.PaginatedListMaintenanceTask> {\n return super\n .filterMaintenanceTasksBy(startDocumentId, limit, body)\n .then((pl) => this.decrypt(user, pl.rows!).then((dr) => Object.assign(pl, { rows: dr })))\n }\n\n getMaintenanceTask(maintenanceTaskId: string): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n getMaintenanceTaskWithUser(user: models.User, maintenanceTaskId: string): Promise<models.MaintenanceTask | any> {\n return super\n .getMaintenanceTask(maintenanceTaskId)\n .then((mt) => this.decrypt(user, [mt]))\n .then((mts) => mts[0])\n }\n\n modifyMaintenanceTask(body?: models.MaintenanceTask): never {\n throw new Error('Cannot call a method that returns maintenance tasks without providing a user for de/encryption')\n }\n\n modifyMaintenanceTaskWithUser(user: models.User, body?: models.MaintenanceTask): Promise<models.MaintenanceTask | any> {\n return body ? this.modifyMaintenanceTaskAs(this.dataOwnerApi.getDataOwnerIdOf(user), body) : Promise.resolve(null)\n }\n\n private modifyMaintenanceTaskAs(dataOwner: string, body: models.MaintenanceTask): Promise<models.MaintenanceTask> {\n return this.encryptAs(dataOwner, [_.cloneDeep(body)])\n .then((encTasks) => super.modifyMaintenanceTask(encTasks[0]))\n .then((mt) => this.decryptAs(dataOwner, [mt]))\n .then((mts) => mts[0])\n }\n\n encrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.encryptAs(dataOwnerId, maintenanceTasks)\n }\n\n private encryptAs(dataOwner: string, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n return this.crypto.xapi.tryEncryptEntities(\n maintenanceTasks,\n EntityWithDelegationTypeName.MaintenanceTask,\n this.encryptedFields,\n true,\n false,\n (x) => new models.MaintenanceTask(x)\n )\n }\n\n decrypt(user: models.User, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n const dataOwnerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n return this.decryptAs(dataOwnerId, maintenanceTasks)\n }\n\n private async decryptAs(dataOwner: string, maintenanceTasks: Array<models.MaintenanceTask>): Promise<Array<models.MaintenanceTask>> {\n return (\n await this.crypto.xapi.tryDecryptEntities(maintenanceTasks, EntityWithDelegationTypeName.MaintenanceTask, (x) => new MaintenanceTask(x))\n ).map(({ entity }) => entity)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given maintenance task\n */\n async hasWriteAccess(maintenanceTask: models.MaintenanceTask): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: maintenanceTask, type: EntityWithDelegationTypeName.MaintenanceTask })\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task 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 maintenance task.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\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 maintenanceTask: models.MaintenanceTask,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.MaintenanceTask> {\n return this.shareWithMany(maintenanceTask, { [delegateId]: options })\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity.\n */\n async shareWithMany(\n maintenanceTask: models.MaintenanceTask,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.MaintenanceTask> {\n return (await this.tryShareWithMany(maintenanceTask, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing maintenance task with other data owners, allowing them to access the non-encrypted data of the maintenance task and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param maintenanceTask the maintenance task 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 * maintenance task does not have encrypted content.\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 maintenanceTask: models.MaintenanceTask,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.MaintenanceTask>> {\n const self = await this.dataOwnerApi.getCurrentDataOwnerId()\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n maintenanceTask,\n EntityWithDelegationTypeName.MaintenanceTask\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyMaintenanceTaskAs(self, entityWithEncryptionKey) : maintenanceTask\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.MaintenanceTask,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareMaintenanceTask(x)\n )\n .then((r) => r.mapSuccessAsync((e) => this.decryptAs(self, [e]).then((es) => es[0])))\n }\n\n getDataOwnersWithAccessTo(\n entity: models.MaintenanceTask\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.MaintenanceTask })\n }\n\n getEncryptionKeysOf(entity: models.MaintenanceTask): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.MaintenanceTask }, undefined)\n }\n\n async subscribeToMaintenanceTaskEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<MaintenanceTask>,\n eventFired: (dataSample: MaintenanceTask) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n const currentUser = await this.userApi.getCurrentUser()\n\n return subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.MaintenanceTask,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt(currentUser, [encrypted]))[0]\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n createDelegationDeAnonymizationMetadata(entity: MaintenanceTask, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.MaintenanceTask },\n delegates\n )\n }\n}\n"]}
@@ -54,9 +54,9 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
54
54
  * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
55
55
  * @return a new instance of message.
56
56
  */
57
- newInstanceWithPatient(user, patient, m = {}, options = {}) {
58
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
59
- return __awaiter(this, void 0, void 0, function* () {
57
+ newInstanceWithPatient(user_1, patient_1) {
58
+ return __awaiter(this, arguments, void 0, function* (user, patient, m = {}, options = {}) {
59
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
60
60
  const message = Object.assign(Object.assign({}, (m !== null && m !== void 0 ? m : {})), { _type: 'org.taktik.icure.entities.Message', id: (_a = m === null || m === void 0 ? void 0 : m.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = m === null || m === void 0 ? void 0 : m.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = m === null || m === void 0 ? void 0 : m.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = m === null || m === void 0 ? void 0 : m.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = m === null || m === void 0 ? void 0 : m.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = m === null || m === void 0 ? void 0 : m.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = m === null || m === void 0 ? void 0 : m.tags) !== null && _g !== void 0 ? _g : [] });
61
61
  const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
62
62
  if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
@@ -114,8 +114,8 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
114
114
  * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
115
115
  * @return the updated entity
116
116
  */
117
- shareWith(delegateId, message, shareSecretIds, options = {}) {
118
- return __awaiter(this, void 0, void 0, function* () {
117
+ shareWith(delegateId_1, message_1, shareSecretIds_1) {
118
+ return __awaiter(this, arguments, void 0, function* (delegateId, message, shareSecretIds, options = {}) {
119
119
  return this.shareWithMany(message, { [delegateId]: Object.assign(Object.assign({}, options), { shareSecretIds }) });
120
120
  });
121
121
  }
@@ -192,8 +192,8 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
192
192
  const _super = Object.create(null, {
193
193
  filterMessagesBy: { get: () => super.filterMessagesBy }
194
194
  });
195
- var _a;
196
195
  return __awaiter(this, void 0, void 0, function* () {
196
+ var _a;
197
197
  const page = yield _super.filterMessagesBy.call(this, body, startDocumentId, limit);
198
198
  const decryptedMessages = yield this.decrypt((_a = page.rows) !== null && _a !== void 0 ? _a : []);
199
199
  if (decryptedMessages.some((m) => !m.decrypted))
@@ -231,8 +231,8 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
231
231
  return decryptedMessage[0].entity;
232
232
  });
233
233
  }
234
- subscribeToMessageEvents(eventTypes, filter, eventFired, options = {}) {
235
- return __awaiter(this, void 0, void 0, function* () {
234
+ subscribeToMessageEvents(eventTypes_1, filter_1, eventFired_1) {
235
+ return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
236
236
  return yield (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, utils_1.EntityWithDelegationTypeName.Message, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt([encrypted]))[0].entity; })).then((rs) => new Connection_1.ConnectionImpl(rs));
237
237
  });
238
238
  }
@@ -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;AAE9D,MAAa,cAAe,SAAQ,uBAAa;IAG/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAA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,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAA;YAC/D,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;YACrF,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QACnC,CAAC;KAAA;IAEK,wBAAwB,CAC5B,UAA8C,EAC9C,MAA2C,EAC3C,UAA+C,EAC/C,UAA+B,EAAE;;YAEjC,OAAO,MAAM,IAAA,+BAAuB,EAClC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,OAAO,EACZ,oCAA4B,CAAC,OAAO,EACpC,UAAU,EACV,MAAM,EACN,UAAU,EACV,OAAO,EACP,CAAO,SAAS,EAAE,EAAE,gDAAC,OAAA,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA,GAAA,CACjE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;KAAA;IAED,uCAAuC,CAAC,MAAe,EAAE,SAAmB;QAC1E,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;AAjTD,wCAiTC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, 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'\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 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 async decrypt(messages: Array<models.Message>) {\n return await this.crypto.xapi.tryDecryptEntities(messages, EntityWithDelegationTypeName.Message, (x) => new models.Message(x))\n }\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.modifyMessage(entityWithEncryptionKey) : message\n return this.crypto.xapi.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) => this.bulkShareMessages(x)\n )\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 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 getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n override async filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): Promise<PaginatedListMessage> {\n const page = await super.filterMessagesBy(body, startDocumentId, limit)\n const decryptedMessages = await this.decrypt(page.rows ?? [])\n if (decryptedMessages.some((m) => !m.decrypted)) throw new Error('Some messages could not be decrypted')\n return {\n ...page,\n rows: decryptedMessages.map((m) => m.entity),\n }\n }\n\n async encryptAndCreateMessageInTopic(body: Message): Promise<Message> {\n const encryptedMessage = await this.encrypt([body])\n const createdMessage = await super.createMessageInTopic(encryptedMessage[0])\n return (await this.decrypt([createdMessage]))[0].entity\n }\n\n async setMessagesReadStatus(body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((m) => m.entity)\n }\n\n async getAndDecryptMessage(messageId: string): Promise<Message> {\n const encryptedMessage = await super.getMessage(messageId)\n const decryptedMessage = await this.decrypt([encryptedMessage])\n if (!decryptedMessage[0].decrypted) throw new Error('Message could not be decrypted')\n return decryptedMessage[0].entity\n }\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 createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Message }, delegates)\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;AAGjD,0EAAgG;AAChG,wEAAoE;AAOpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAGzD,mCAAmJ;AACnJ,4DAAwE;AACxE,kEAA8D;AAE9D,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,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QAZtC,W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A,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA,GAAA,CACjE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,2BAAc,CAAC,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;KAAA;IAED,uCAAuC,CAAC,MAAe,EAAE,SAAmB;QAC1E,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;AAjTD,wCAiTC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, 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'\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 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 async decrypt(messages: Array<models.Message>) {\n return await this.crypto.xapi.tryDecryptEntities(messages, EntityWithDelegationTypeName.Message, (x) => new models.Message(x))\n }\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.modifyMessage(entityWithEncryptionKey) : message\n return this.crypto.xapi.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) => this.bulkShareMessages(x)\n )\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 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 getEncryptionKeysOf(entity: models.Message): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n override async filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): Promise<PaginatedListMessage> {\n const page = await super.filterMessagesBy(body, startDocumentId, limit)\n const decryptedMessages = await this.decrypt(page.rows ?? [])\n if (decryptedMessages.some((m) => !m.decrypted)) throw new Error('Some messages could not be decrypted')\n return {\n ...page,\n rows: decryptedMessages.map((m) => m.entity),\n }\n }\n\n async encryptAndCreateMessageInTopic(body: Message): Promise<Message> {\n const encryptedMessage = await this.encrypt([body])\n const createdMessage = await super.createMessageInTopic(encryptedMessage[0])\n return (await this.decrypt([createdMessage]))[0].entity\n }\n\n async setMessagesReadStatus(body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((m) => m.entity)\n }\n\n async getAndDecryptMessage(messageId: string): Promise<Message> {\n const encryptedMessage = await super.getMessage(messageId)\n const decryptedMessage = await this.decrypt([encryptedMessage])\n if (!decryptedMessage[0].decrypted) throw new Error('Message could not be decrypted')\n return decryptedMessage[0].entity\n }\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 createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Message }, delegates)\n }\n}\n"]}
@@ -64,9 +64,9 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
64
64
  * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
65
65
  * @return a new instance of patient.
66
66
  */
67
- newInstance(user, p = {}, options = {}) {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
69
- return __awaiter(this, void 0, void 0, function* () {
67
+ newInstance(user_1) {
68
+ return __awaiter(this, arguments, void 0, function* (user, p = {}, options = {}) {
69
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
70
70
  const patient = Object.assign(Object.assign({}, (p !== null && p !== void 0 ? p : {})), { _type: 'org.taktik.icure.entities.Patient', id: (_a = p === null || p === void 0 ? void 0 : p.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = p === null || p === void 0 ? void 0 : p.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = p === null || p === void 0 ? void 0 : p.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = p === null || p === void 0 ? void 0 : p.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = p === null || p === void 0 ? void 0 : p.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = p === null || p === void 0 ? void 0 : p.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = p === null || p === void 0 ? void 0 : p.tags) !== null && _g !== void 0 ? _g : [] });
71
71
  const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
72
72
  if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
@@ -341,13 +341,13 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
341
341
  /**
342
342
  * @deprecated replace with {@link shareAllDataOfPatient}
343
343
  */
344
- share(user, patId, ownerId, delegateIds, delegationTags, usingPost = false) {
345
- return __awaiter(this, void 0, void 0, function* () {
344
+ share(user_1, patId_1, ownerId_1, delegateIds_1, delegationTags_1) {
345
+ return __awaiter(this, arguments, void 0, function* (user, patId, ownerId, delegateIds, delegationTags, usingPost = false) {
346
346
  return this.shareAllDataOfPatient(user, patId, ownerId, delegateIds, delegationTags, usingPost);
347
347
  });
348
348
  }
349
- shareAllDataOfPatient(user, patId, ownerId, delegateIds, delegationTags, usingPost = false) {
350
- return __awaiter(this, void 0, void 0, function* () {
349
+ shareAllDataOfPatient(user_1, patId_1, ownerId_1, delegateIds_1, delegationTags_1) {
350
+ return __awaiter(this, arguments, void 0, function* (user, patId, ownerId, delegateIds, delegationTags, usingPost = false) {
351
351
  const allTags = _.uniq(_.flatMap(Object.values(delegationTags)));
352
352
  const status = {
353
353
  contacts: {
@@ -711,8 +711,8 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
711
711
  * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
712
712
  * @return the updated entity
713
713
  */
714
- shareWith(delegateId, patient, shareSecretIds, options = {}) {
715
- return __awaiter(this, void 0, void 0, function* () {
714
+ shareWith(delegateId_1, patient_1, shareSecretIds_1) {
715
+ return __awaiter(this, arguments, void 0, function* (delegateId, patient, shareSecretIds, options = {}) {
716
716
  return this.shareWithMany(patient, { [delegateId]: Object.assign(Object.assign({}, options), { shareSecretIds: shareSecretIds }) });
717
717
  });
718
718
  }
@@ -849,8 +849,8 @@ class IccPatientXApi extends icc_api_1.IccPatientApi {
849
849
  return (yield this.tryDecryptOrReturnOriginal([merged]))[0].entity;
850
850
  });
851
851
  }
852
- subscribeToPatientEvents(eventTypes, filter, eventFired, options = {}) {
853
- return __awaiter(this, void 0, void 0, function* () {
852
+ subscribeToPatientEvents(eventTypes_1, filter_1, eventFired_1) {
853
+ return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
854
854
  const currentUser = yield this.userApi.getCurrentUser();
855
855
  return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, EntityWithDelegationTypeName_1.EntityWithDelegationTypeName.Patient, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(currentUser, [encrypted]))[0]; })).then((rs) => new Connection_1.ConnectionImpl(rs));
856
856
  });