@icure/api 8.0.8 → 8.0.10

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 (270) hide show
  1. package/icc-api/model/models.d.ts +1 -0
  2. package/icc-api/model/models.js +1 -0
  3. package/icc-api/model/models.js.map +1 -1
  4. package/icc-x-api/crypto/BaseExchangeDataManager.js +1 -1
  5. package/icc-x-api/crypto/BaseExchangeDataManager.js.map +1 -1
  6. package/icc-x-api/crypto/BaseExchangeKeysManager.js +7 -3
  7. package/icc-x-api/crypto/BaseExchangeKeysManager.js.map +1 -1
  8. package/icc-x-api/crypto/ExchangeDataManager.js +3 -2
  9. package/icc-x-api/crypto/ExchangeDataManager.js.map +1 -1
  10. package/icc-x-api/crypto/KeyRecovery.js +6 -5
  11. package/icc-x-api/crypto/KeyRecovery.js.map +1 -1
  12. package/icc-x-api/crypto/RSA.d.ts +4 -1
  13. package/icc-x-api/crypto/RSA.js +6 -1
  14. package/icc-x-api/crypto/RSA.js.map +1 -1
  15. package/icc-x-api/crypto/SecureDelegationsManager.js +2 -1
  16. package/icc-x-api/crypto/SecureDelegationsManager.js.map +1 -1
  17. package/icc-x-api/crypto/ShamirKeysManager.js +8 -9
  18. package/icc-x-api/crypto/ShamirKeysManager.js.map +1 -1
  19. package/icc-x-api/crypto/TransferKeysManager.js +4 -3
  20. package/icc-x-api/crypto/TransferKeysManager.js.map +1 -1
  21. package/icc-x-api/crypto/UserEncryptionKeysManager.js +4 -4
  22. package/icc-x-api/crypto/UserEncryptionKeysManager.js.map +1 -1
  23. package/icc-x-api/crypto/UserSignatureKeysManager.js +9 -5
  24. package/icc-x-api/crypto/UserSignatureKeysManager.js.map +1 -1
  25. package/icc-x-api/crypto/utils.d.ts +13 -4
  26. package/icc-x-api/crypto/utils.js +27 -9
  27. package/icc-x-api/crypto/utils.js.map +1 -1
  28. package/icc-x-api/icc-accesslog-x-api.js +16 -14
  29. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  30. package/icc-x-api/icc-calendar-item-x-api.d.ts +2 -2
  31. package/icc-x-api/icc-calendar-item-x-api.js +17 -17
  32. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  33. package/icc-x-api/icc-classification-x-api.js +12 -11
  34. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  35. package/icc-x-api/icc-contact-x-api.d.ts +2 -2
  36. package/icc-x-api/icc-contact-x-api.js +23 -20
  37. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  38. package/icc-x-api/icc-data-owner-x-api.js +1 -1
  39. package/icc-x-api/icc-data-owner-x-api.js.map +1 -1
  40. package/icc-x-api/icc-document-x-api.js +17 -16
  41. package/icc-x-api/icc-document-x-api.js.map +1 -1
  42. package/icc-x-api/icc-form-x-api.js +13 -12
  43. package/icc-x-api/icc-form-x-api.js.map +1 -1
  44. package/icc-x-api/icc-helement-x-api.js +18 -16
  45. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  46. package/icc-x-api/icc-icure-maintenance-x-api.js +4 -3
  47. package/icc-x-api/icc-icure-maintenance-x-api.js.map +1 -1
  48. package/icc-x-api/icc-invoice-x-api.js +12 -11
  49. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  50. package/icc-x-api/icc-maintenance-task-x-api.js +11 -11
  51. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  52. package/icc-x-api/icc-message-x-api.js +14 -14
  53. package/icc-x-api/icc-message-x-api.js.map +1 -1
  54. package/icc-x-api/icc-patient-x-api.js +28 -27
  55. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  56. package/icc-x-api/icc-receipt-x-api.js +11 -10
  57. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  58. package/icc-x-api/icc-recovery-x-api.js +3 -2
  59. package/icc-x-api/icc-recovery-x-api.js.map +1 -1
  60. package/icc-x-api/icc-time-table-x-api.js +9 -8
  61. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  62. package/icc-x-api/icc-topic-x-api.js +13 -13
  63. package/icc-x-api/icc-topic-x-api.js.map +1 -1
  64. package/icc-x-api/storage/IcureStorageFacade.js +4 -1
  65. package/icc-x-api/storage/IcureStorageFacade.js.map +1 -1
  66. package/icc-x-api/utils/EntityWithDelegationTypeName.d.ts +17 -1
  67. package/icc-x-api/utils/EntityWithDelegationTypeName.js +33 -15
  68. package/icc-x-api/utils/EntityWithDelegationTypeName.js.map +1 -1
  69. package/package.json +1 -1
  70. package/test/icc-api/api/IccAnonymousAccessApi.d.ts +1 -0
  71. package/test/icc-api/api/IccAnonymousAccessApi.js +58 -0
  72. package/test/icc-api/api/IccAnonymousAccessApi.js.map +1 -0
  73. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  74. package/test/icc-api/api/IccDocumentApi.js +208 -0
  75. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  76. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  77. package/test/icc-api/api/IccGroupApi.js +50 -0
  78. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  79. package/test/icc-api/api/IccRecoveryDataApi.d.ts +1 -0
  80. package/test/icc-api/api/IccRecoveryDataApi.js +95 -0
  81. package/test/icc-api/api/IccRecoveryDataApi.js.map +1 -0
  82. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  83. package/test/icc-api/api/IccRoleApi.js +34 -0
  84. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  85. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  86. package/test/icc-api/api/IccUserApi.js +96 -0
  87. package/test/icc-api/api/IccUserApi.js.map +1 -0
  88. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  89. package/test/icc-api/e2e/IccCalendarItemApi.js +46 -0
  90. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  91. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  92. package/test/icc-api/model/modelHelpersTest.js +45 -0
  93. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  94. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  95. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  96. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  97. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  98. package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
  99. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  100. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  101. package/test/icc-x-api/auth/smart-auth-provider-test.js +224 -0
  102. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  103. package/test/icc-x-api/autofix-anonymity-test.d.ts +1 -0
  104. package/test/icc-x-api/autofix-anonymity-test.js +108 -0
  105. package/test/icc-x-api/autofix-anonymity-test.js.map +1 -0
  106. package/test/icc-x-api/confidential-entities-test.d.ts +1 -0
  107. package/test/icc-x-api/confidential-entities-test.js +110 -0
  108. package/test/icc-x-api/confidential-entities-test.js.map +1 -0
  109. package/test/icc-x-api/crud/comprehensive-crud-test.d.ts +1 -0
  110. package/test/icc-x-api/crud/comprehensive-crud-test.js +276 -0
  111. package/test/icc-x-api/crud/comprehensive-crud-test.js.map +1 -0
  112. package/test/icc-x-api/crud/entities-crud-test-interface.d.ts +16 -0
  113. package/test/icc-x-api/crud/entities-crud-test-interface.js +422 -0
  114. package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -0
  115. package/test/icc-x-api/crypto/anonymous-delegations-test.d.ts +1 -0
  116. package/test/icc-x-api/crypto/anonymous-delegations-test.js +588 -0
  117. package/test/icc-x-api/crypto/anonymous-delegations-test.js.map +1 -0
  118. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  119. package/test/icc-x-api/crypto/concurrency.js +35 -0
  120. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  121. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  122. package/test/icc-x-api/crypto/crypto-utils.js +80 -0
  123. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  124. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  125. package/test/icc-x-api/crypto/cryptoTest.js +302 -0
  126. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  127. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  128. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +166 -0
  129. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  130. package/test/icc-x-api/crypto/exchange-data-manager-test.d.ts +1 -0
  131. package/test/icc-x-api/crypto/exchange-data-manager-test.js +690 -0
  132. package/test/icc-x-api/crypto/exchange-data-manager-test.js.map +1 -0
  133. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  134. package/test/icc-x-api/crypto/full-crypto-test.js +457 -0
  135. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  136. package/test/icc-x-api/crypto/secure-delegations-manager-test.d.ts +1 -0
  137. package/test/icc-x-api/crypto/secure-delegations-manager-test.js +266 -0
  138. package/test/icc-x-api/crypto/secure-delegations-manager-test.js.map +1 -0
  139. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.d.ts +1 -0
  140. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js +393 -0
  141. package/test/icc-x-api/crypto/secure-delegations-metadata-decryptor-test.js.map +1 -0
  142. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.d.ts +1 -0
  143. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js +213 -0
  144. package/test/icc-x-api/crypto/security-metadata-decryptor-chain-test.js.map +1 -0
  145. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  146. package/test/icc-x-api/crypto/shamir.js +166 -0
  147. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  148. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  149. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +71 -0
  150. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  151. package/test/icc-x-api/crypto/signature-keys-manager-test.d.ts +1 -0
  152. package/test/icc-x-api/crypto/signature-keys-manager-test.js +44 -0
  153. package/test/icc-x-api/crypto/signature-keys-manager-test.js.map +1 -0
  154. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.d.ts +1 -0
  155. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js +246 -0
  156. package/test/icc-x-api/crypto/user-encryption-keys-manager-test.js.map +1 -0
  157. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  158. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  159. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  160. package/test/icc-x-api/filters/filters.d.ts +1 -0
  161. package/test/icc-x-api/filters/filters.js +49 -0
  162. package/test/icc-x-api/filters/filters.js.map +1 -0
  163. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  164. package/test/icc-x-api/icc-accesslog-x-api.js +106 -0
  165. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  166. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  167. package/test/icc-x-api/icc-auth-api.js +47 -0
  168. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  169. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  170. package/test/icc-x-api/icc-calendar-item-x-api.js +150 -0
  171. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  172. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  173. package/test/icc-x-api/icc-contact-x-api.js +279 -0
  174. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  175. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  176. package/test/icc-x-api/icc-form-x-api.js +98 -0
  177. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  178. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  179. package/test/icc-x-api/icc-helement-x-api-test.js +153 -0
  180. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  181. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  182. package/test/icc-x-api/icc-invoice-x-api.js +99 -0
  183. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  184. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  185. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +221 -0
  186. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  187. package/test/icc-x-api/icc-message-x-api.d.ts +1 -0
  188. package/test/icc-x-api/icc-message-x-api.js +328 -0
  189. package/test/icc-x-api/icc-message-x-api.js.map +1 -0
  190. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  191. package/test/icc-x-api/icc-patient-x-api-test.js +158 -0
  192. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  193. package/test/icc-x-api/icc-recovery-x-api.d.ts +1 -0
  194. package/test/icc-x-api/icc-recovery-x-api.js +170 -0
  195. package/test/icc-x-api/icc-recovery-x-api.js.map +1 -0
  196. package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
  197. package/test/icc-x-api/icc-time-table-x-api.js +100 -0
  198. package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
  199. package/test/icc-x-api/icc-topic-x-api.d.ts +1 -0
  200. package/test/icc-x-api/icc-topic-x-api.js +269 -0
  201. package/test/icc-x-api/icc-topic-x-api.js.map +1 -0
  202. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  203. package/test/icc-x-api/icc-user-x-api-test.js +99 -0
  204. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  205. package/test/icc-x-api/patient-user.d.ts +2 -0
  206. package/test/icc-x-api/patient-user.js +104 -0
  207. package/test/icc-x-api/patient-user.js.map +1 -0
  208. package/test/icc-x-api/storage/storage.d.ts +1 -0
  209. package/test/icc-x-api/storage/storage.js +48 -0
  210. package/test/icc-x-api/storage/storage.js.map +1 -0
  211. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  212. package/test/icc-x-api/test-api-no-parent.js +79 -0
  213. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  214. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  215. package/test/icc-x-api/test-legacy-data-support.js +376 -0
  216. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  217. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  218. package/test/icc-x-api/utils/graph-test.js +54 -0
  219. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  220. package/test/icc-x-api/utils/lru-temporised-async-cache-test.d.ts +1 -0
  221. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js +364 -0
  222. package/test/icc-x-api/utils/lru-temporised-async-cache-test.js.map +1 -0
  223. package/test/support/CSM-185.d.ts +1 -0
  224. package/test/support/CSM-185.js +124 -0
  225. package/test/support/CSM-185.js.map +1 -0
  226. package/test/support/CSM-243.d.ts +1 -0
  227. package/test/support/CSM-243.js +120 -0
  228. package/test/support/CSM-243.js.map +1 -0
  229. package/test/support/CSM-87.d.ts +0 -0
  230. package/test/support/CSM-87.js +21 -0
  231. package/test/support/CSM-87.js.map +1 -0
  232. package/test/support/CSM-93.d.ts +1 -0
  233. package/test/support/CSM-93.js +112 -0
  234. package/test/support/CSM-93.js.map +1 -0
  235. package/test/utils/FakeDataOwnerApi.d.ts +32 -0
  236. package/test/utils/FakeDataOwnerApi.js +136 -0
  237. package/test/utils/FakeDataOwnerApi.js.map +1 -0
  238. package/test/utils/FakeEncryptionKeysManager.d.ts +35 -0
  239. package/test/utils/FakeEncryptionKeysManager.js +87 -0
  240. package/test/utils/FakeEncryptionKeysManager.js.map +1 -0
  241. package/test/utils/FakeExchangeDataApi.d.ts +30 -0
  242. package/test/utils/FakeExchangeDataApi.js +74 -0
  243. package/test/utils/FakeExchangeDataApi.js.map +1 -0
  244. package/test/utils/FakeExchangeDataManager.d.ts +40 -0
  245. package/test/utils/FakeExchangeDataManager.js +89 -0
  246. package/test/utils/FakeExchangeDataManager.js.map +1 -0
  247. package/test/utils/FakeExchangeDataMapManager.d.ts +12 -0
  248. package/test/utils/FakeExchangeDataMapManager.js +38 -0
  249. package/test/utils/FakeExchangeDataMapManager.js.map +1 -0
  250. package/test/utils/FakeGenericApi.d.ts +16 -0
  251. package/test/utils/FakeGenericApi.js +65 -0
  252. package/test/utils/FakeGenericApi.js.map +1 -0
  253. package/test/utils/FakeSignatureKeysManager.d.ts +16 -0
  254. package/test/utils/FakeSignatureKeysManager.js +54 -0
  255. package/test/utils/FakeSignatureKeysManager.js.map +1 -0
  256. package/test/utils/TestApi.d.ts +3 -0
  257. package/test/utils/TestApi.js +30 -0
  258. package/test/utils/TestApi.js.map +1 -0
  259. package/test/utils/TestCollectionUtils.d.ts +1 -0
  260. package/test/utils/TestCollectionUtils.js +109 -0
  261. package/test/utils/TestCollectionUtils.js.map +1 -0
  262. package/test/utils/TestCryptoStrategies.d.ts +42 -0
  263. package/test/utils/TestCryptoStrategies.js +80 -0
  264. package/test/utils/TestCryptoStrategies.js.map +1 -0
  265. package/test/utils/TestStorage.d.ts +23 -0
  266. package/test/utils/TestStorage.js +61 -0
  267. package/test/utils/TestStorage.js.map +1 -0
  268. package/test/utils/test_utils.d.ts +76 -0
  269. package/test/utils/test_utils.js +419 -0
  270. package/test/utils/test_utils.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAMzD,MAAa,qBAAsB,SAAQ,8BAAoB;IAI7D,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CA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AAC,0CAA0C,CAChE,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,gBAAgB,EAAE,EACjD,IAAI,EACJ,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;gBACvD,UAAU;gBACV;oBACE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;oBAClD,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;oBAC/C,oBAAoB,EAAE,OAAO,CAAC,cAAc;oBAC5C,cAAc,EAAE,SAAS;iBAC1B;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CACxC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAA6B;QAE7B,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAA;IAC7G,CAAC;IAED,mBAAmB,CAAC,MAA6B;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,SAAS,CAAC,CAAA;IACzF,CAAC;IAED,uCAAuC,CAAC,MAA6B,EAAE,SAAmB;QACxF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,SAAS,CAAC,CAAA;IAChI,CAAC;CACF;AAtND,sDAsNC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { AccessLog } from '../icc-api/model/models'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Classification'))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n preferredSfk?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(moment().format('YYYYMMDDHHmmss')),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk = options?.preferredSfk ?? (await this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: 'Patient' }))\n if (!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.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(classification, 'Classification', patient?.id, sfk, true, false, extraDelegations)\n .then((x) => x.updatedEntity)\n )\n }\n\n async findBy(hcpartyId: string, patient: models.Patient) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: 'Patient' }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: 'Classification' }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: 'Classification' })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the classification.\n * @param classification the classification to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(classification, 'Classification')\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n { entity: updatedEntity, type: 'Classification' },\n true,\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: undefined,\n },\n ])\n ),\n (x) => this.bulkShareClassifications(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Classification' })\n }\n\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Classification' }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Classification' }, delegates)\n }\n}\n"]}
1
+ {"version":3,"file":"icc-classification-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-classification-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAiD;AAGjD,kDAAiD;AAEjD,4BAA2B;AAC3B,iCAAgC;AAEhC,0EAAgG;AAChG,wEAAoE;AAIpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAKzD,mCAAsD;AAEtD,MAAa,qBAAsB,SA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,CAAA;IACH,CAAC;CACF;AAtOD,sDAsOC","sourcesContent":["import { IccClassificationApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\n\nimport * as _ from 'lodash'\nimport * as moment from 'moment'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { AccessLog } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName } from './utils'\n\nexport class IccClassificationXApi extends IccClassificationApi implements EncryptedEntityXApi<models.Classification> {\n crypto: IccCryptoXApi\n dataOwnerApi: IccDataOwnerXApi\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Classification))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of classification with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param patient the patient this classification refers to.\n * @param c initialised data for the classification. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the classification. The default value will be a\n * secret id of patient known by the topmost parent in the current data owner hierarchy.\n * @return a new instance of classification.\n */\n async newInstance(\n user: models.User,\n patient: models.Patient,\n c: any = {},\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n preferredSfk?: string\n } = {}\n ): Promise<models.Classification> {\n const classification = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.Classification',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n responsible: c?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: c?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: c?.codes ?? [],\n tags: c?.tags ?? [],\n healthElementId: c?.healthElementId ?? this.crypto.primitives.randomUuid(),\n openingDate: c?.openingDate ?? parseInt(moment().format('YYYYMMDDHHmmss')),\n }\n\n const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user)\n if (ownerId !== (await this.dataOwnerApi.getCurrentDataOwnerId())) throw new Error('Can only initialise entities as current data owner.')\n const sfk =\n options?.preferredSfk ??\n (await this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: EntityWithDelegationTypeName.Patient }))\n if (!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.Classification(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n classification,\n EntityWithDelegationTypeName.Classification,\n patient?.id,\n sfk,\n true,\n false,\n extraDelegations\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n async findBy(hcpartyId: string, patient: models.Patient) {\n const extractedKeys = await this.crypto.xapi.secretIdsOf({ entity: patient, type: EntityWithDelegationTypeName.Patient }, hcpartyId)\n const topmostParentId = (await this.dataOwnerApi.getCurrentDataOwnerHierarchyIds())[0]\n return extractedKeys && extractedKeys.length > 0\n ? this.findClassificationsByHCPartyPatientForeignKeys(topmostParentId, _.uniq(extractedKeys).join(','))\n : Promise.resolve([])\n }\n\n /**\n * @param classification a classification\n * @return the id of the patient that the classification refers to, retrieved from the encrypted metadata. Normally there should only be one element\n * in the returned array, but in case of entity merges there could be multiple values.\n */\n async decryptPatientIdOf(classification: models.Classification): Promise<string[]> {\n return this.crypto.xapi.owningEntityIdsOf({ entity: classification, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given classification\n */\n async hasWriteAccess(classification: models.Classification): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: classification, type: EntityWithDelegationTypeName.Classification })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the classification.\n * @param classification the classification to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n classification: models.Classification,\n options: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.Classification> {\n return this.shareWithMany(classification, { [delegateId]: options })\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.Classification> {\n return (await this.tryShareWithMany(classification, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing classification with other data owners, allowing them to access the non-encrypted data of the classification and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param classification the classification to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * classification does not have encrypted content.\n * - sharePatientId: specifies if the id of the patient that this classification refers to should be shared with the delegate (defaults to\n * {@link ShareMetadataBehaviour.IF_AVAILABLE}).\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n classification: models.Classification,\n delegates: {\n [delegateId: string]: {\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n sharePatientId?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.Classification>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(\n classification,\n EntityWithDelegationTypeName.Classification\n )\n const updatedEntity = entityWithEncryptionKey ? await this.modifyClassification(entityWithEncryptionKey) : classification\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n { entity: updatedEntity, type: EntityWithDelegationTypeName.Classification },\n true,\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: undefined,\n },\n ])\n ),\n (x) => this.bulkShareClassifications(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.Classification\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.Classification })\n }\n\n getEncryptionKeysOf(entity: models.Classification): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.Classification }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.Classification, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.Classification },\n delegates\n )\n }\n}\n"]}
@@ -7,16 +7,16 @@ import { IccDataOwnerXApi } from './icc-data-owner-x-api';
7
7
  import { SubscriptionOptions } from './utils';
8
8
  import { AuthenticationProvider } from './auth/AuthenticationProvider';
9
9
  import { SecureDelegation } from '../icc-api/model/SecureDelegation';
10
- import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
11
10
  import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
12
11
  import { ShareResult } from './utils/ShareResult';
13
12
  import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
14
- import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
15
13
  import { XHR } from '../icc-api/api/XHR';
16
14
  import { IccUserXApi } from './icc-user-x-api';
17
15
  import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
18
16
  import { AbstractFilter } from './filters/filters';
19
17
  import { Connection } from '../icc-api/model/Connection';
18
+ import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
19
+ import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
20
20
  export declare class IccContactXApi extends IccContactApi implements EncryptedEntityXApi<models.Contact> {
21
21
  private readonly crypto;
22
22
  private readonly dataOwnerApi;
@@ -21,11 +21,11 @@ const ServiceByIdsFilter_1 = require("./filters/ServiceByIdsFilter");
21
21
  const utils_1 = require("./utils");
22
22
  const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
23
23
  const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
24
- var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
25
24
  const Connection_1 = require("../icc-api/model/Connection");
25
+ var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
26
26
  class IccContactXApi extends icc_api_1.IccContactApi {
27
27
  get headers() {
28
- return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, 'Contact'));
28
+ return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, utils_1.EntityWithDelegationTypeName.Contact));
29
29
  }
30
30
  constructor(host, headers, crypto, dataOwnerApi, userApi, authApi, autofillAuthor, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
31
31
  ? window.fetch
@@ -81,14 +81,14 @@ class IccContactXApi extends icc_api_1.IccContactApi {
81
81
  if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
82
82
  throw new Error('Can only initialise entities as current data owner.');
83
83
  const sfk = (_m = options.preferredSfk) !== null && _m !== void 0 ? _m : ((options === null || options === void 0 ? void 0 : options.confidential)
84
- ? yield this.crypto.confidential.getConfidentialSecretId({ entity: patient, type: 'Patient' })
85
- : yield this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: 'Patient' }));
84
+ ? yield this.crypto.confidential.getConfidentialSecretId({ entity: patient, type: utils_1.EntityWithDelegationTypeName.Patient })
85
+ : yield this.crypto.confidential.getAnySecretIdSharedWithParents({ entity: patient, type: utils_1.EntityWithDelegationTypeName.Patient }));
86
86
  if (!sfk)
87
87
  throw new Error(`Couldn't find any sfk of parent patient ${patient.id} for confidential=${(_o = options.confidential) !== null && _o !== void 0 ? _o : false}`);
88
88
  const extraDelegations = Object.assign(Object.assign({}, (options.confidential
89
89
  ? {}
90
90
  : Object.fromEntries([...((_q = (_p = user.autoDelegations) === null || _p === void 0 ? void 0 : _p.all) !== null && _q !== void 0 ? _q : []), ...((_s = (_r = user.autoDelegations) === null || _r === void 0 ? void 0 : _r.medicalInformation) !== null && _s !== void 0 ? _s : [])].map((d) => [d, AccessLevelEnum.WRITE])))), ((_t = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _t !== void 0 ? _t : {}));
91
- const initialisationInfo = yield this.crypto.xapi.entityWithInitialisedEncryptedMetadata(contact, 'Contact', patient.id, sfk, true, false, extraDelegations);
91
+ const initialisationInfo = yield this.crypto.xapi.entityWithInitialisedEncryptedMetadata(contact, utils_1.EntityWithDelegationTypeName.Contact, patient.id, sfk, true, false, extraDelegations);
92
92
  return new models.Contact(initialisationInfo.updatedEntity);
93
93
  });
94
94
  }
@@ -110,7 +110,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
110
110
  */
111
111
  findBy(hcpartyId, patient, usingPost = false) {
112
112
  return __awaiter(this, void 0, void 0, function* () {
113
- return yield this.crypto.xapi.secretIdsForHcpHierarchyOf({ entity: patient, type: 'Patient' }).then((keysHierarchy) => keysHierarchy && keysHierarchy.length > 0
113
+ return yield this.crypto.xapi.secretIdsForHcpHierarchyOf({ entity: patient, type: utils_1.EntityWithDelegationTypeName.Patient }).then((keysHierarchy) => keysHierarchy && keysHierarchy.length > 0
114
114
  ? Promise.all(keysHierarchy
115
115
  .reduce((acc, level) => {
116
116
  return acc.concat([
@@ -132,7 +132,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
132
132
  const perHcpId = {};
133
133
  for (const patient of patients) {
134
134
  ;
135
- (yield this.crypto.xapi.secretIdsForHcpHierarchyOf({ entity: patient, type: 'Patient' }))
135
+ (yield this.crypto.xapi.secretIdsForHcpHierarchyOf({ entity: patient, type: utils_1.EntityWithDelegationTypeName.Patient }))
136
136
  .reduce((acc, level) => {
137
137
  return acc.concat([
138
138
  {
@@ -320,20 +320,23 @@ class IccContactXApi extends icc_api_1.IccContactApi {
320
320
  return Promise.all(ctcs.map((ctc) => __awaiter(this, void 0, void 0, function* () {
321
321
  let initialisedCtc = ctc;
322
322
  if (!bypassEncryption) {
323
- const contactWithKeys = yield this.crypto.xapi.ensureEncryptionKeysInitialised(ctc, 'Contact');
323
+ const contactWithKeys = yield this.crypto.xapi.ensureEncryptionKeysInitialised(ctc, utils_1.EntityWithDelegationTypeName.Contact);
324
324
  if (contactWithKeys) {
325
325
  initialisedCtc = contactWithKeys;
326
326
  }
327
327
  }
328
- const encryptionKey = yield this.crypto.xapi.decryptAndImportAnyEncryptionKey({ entity: initialisedCtc, type: 'Contact' });
328
+ const encryptionKey = yield this.crypto.xapi.decryptAndImportAnyEncryptionKey({
329
+ entity: initialisedCtc,
330
+ type: utils_1.EntityWithDelegationTypeName.Contact,
331
+ });
329
332
  return new models_1.Contact(yield (0, utils_1.encryptObject)(Object.assign(Object.assign({}, initialisedCtc), { services: initialisedCtc.services ? yield this.encryptServices(encryptionKey.key, encryptionKey.raw, initialisedCtc.services) : [] }), (obj) => {
330
333
  return this.crypto.primitives.AES.encrypt(encryptionKey.key, (0, binary_utils_1.utf8_2ua)(JSON.stringify(obj)), encryptionKey.raw);
331
- }, this.contactEncryptedFields, 'contact'));
334
+ }, this.contactEncryptedFields, utils_1.EntityWithDelegationTypeName.Contact));
332
335
  })));
333
336
  }
334
337
  decrypt(hcpartyId, ctcs) {
335
338
  return Promise.all(ctcs.map((ctc) => __awaiter(this, void 0, void 0, function* () {
336
- const keys = yield this.crypto.xapi.decryptAndImportAllDecryptionKeys({ entity: ctc, type: 'Contact' });
339
+ const keys = yield this.crypto.xapi.decryptAndImportAllDecryptionKeys({ entity: ctc, type: utils_1.EntityWithDelegationTypeName.Contact });
337
340
  if (!keys || !keys.length) {
338
341
  console.log('Cannot decrypt contact', ctc.id);
339
342
  return ctc;
@@ -349,7 +352,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
349
352
  return Promise.all(svcs.map((svc) => __awaiter(this, void 0, void 0, function* () {
350
353
  let currentKeys = keys !== null && keys !== void 0 ? keys : (svc.contactId ? contactKeysCache[svc.contactId] : undefined);
351
354
  if (!currentKeys) {
352
- const decryptedKeys = yield this.crypto.xapi.decryptAndImportAllDecryptionKeys({ entity: svc, type: 'Contact' });
355
+ const decryptedKeys = yield this.crypto.xapi.decryptAndImportAllDecryptionKeys({ entity: svc, type: utils_1.EntityWithDelegationTypeName.Contact });
353
356
  if (svc.contactId) {
354
357
  contactKeysCache[svc.contactId] = decryptedKeys;
355
358
  }
@@ -726,7 +729,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
726
729
  */
727
730
  decryptPatientIdOf(contact) {
728
731
  return __awaiter(this, void 0, void 0, function* () {
729
- return this.crypto.xapi.owningEntityIdsOf({ entity: contact, type: 'Contact' }, undefined);
732
+ return this.crypto.xapi.owningEntityIdsOf({ entity: contact, type: utils_1.EntityWithDelegationTypeName.Contact }, undefined);
730
733
  });
731
734
  }
732
735
  /**
@@ -734,7 +737,7 @@ class IccContactXApi extends icc_api_1.IccContactApi {
734
737
  */
735
738
  hasWriteAccess(contact) {
736
739
  return __awaiter(this, void 0, void 0, function* () {
737
- return this.crypto.xapi.hasWriteAccess({ entity: contact, type: 'Contact' });
740
+ return this.crypto.xapi.hasWriteAccess({ entity: contact, type: utils_1.EntityWithDelegationTypeName.Contact });
738
741
  });
739
742
  }
740
743
  /**
@@ -792,10 +795,10 @@ class IccContactXApi extends icc_api_1.IccContactApi {
792
795
  return __awaiter(this, void 0, void 0, function* () {
793
796
  const self = yield this.dataOwnerApi.getCurrentDataOwnerId();
794
797
  // All entities should have an encryption key.
795
- const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(contact, 'Contact');
798
+ const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(contact, utils_1.EntityWithDelegationTypeName.Contact);
796
799
  const updatedEntity = entityWithEncryptionKey ? yield this.modifyContactAs(self, entityWithEncryptionKey) : contact;
797
800
  return this.crypto.xapi
798
- .simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: 'Contact' }, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
801
+ .simpleShareOrUpdateEncryptedEntityMetadata({ entity: updatedEntity, type: utils_1.EntityWithDelegationTypeName.Contact }, true, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
799
802
  delegateId,
800
803
  {
801
804
  requestedPermissions: options.requestedPermissions,
@@ -808,10 +811,10 @@ class IccContactXApi extends icc_api_1.IccContactApi {
808
811
  });
809
812
  }
810
813
  getDataOwnersWithAccessTo(entity) {
811
- return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: 'Contact' });
814
+ return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.Contact });
812
815
  }
813
816
  getEncryptionKeysOf(entity) {
814
- return this.crypto.xapi.encryptionKeysOf({ entity, type: 'Contact' }, undefined);
817
+ return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.Contact }, undefined);
815
818
  }
816
819
  subscribeToServiceEvents(eventTypes, filter, eventFired, options = {}) {
817
820
  return __awaiter(this, void 0, void 0, function* () {
@@ -822,11 +825,11 @@ class IccContactXApi extends icc_api_1.IccContactApi {
822
825
  subscribeToContactEvents(eventTypes, filter, eventFired, options = {}) {
823
826
  return __awaiter(this, void 0, void 0, function* () {
824
827
  const currentUser = yield this.userApi.getCurrentUser();
825
- return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, 'Contact', eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(currentUser.healthcarePartyId, [encrypted]))[0]; })).then((ws) => new Connection_1.ConnectionImpl(ws));
828
+ return (0, utils_1.subscribeToEntityEvents)(this.host, this.authApi, utils_1.EntityWithDelegationTypeName.Contact, eventTypes, filter, eventFired, options, (encrypted) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt(currentUser.healthcarePartyId, [encrypted]))[0]; })).then((ws) => new Connection_1.ConnectionImpl(ws));
826
829
  });
827
830
  }
828
831
  createDelegationDeAnonymizationMetadata(entity, delegates) {
829
- return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: 'Contact' }, delegates);
832
+ return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.Contact }, delegates);
830
833
  }
831
834
  }
832
835
  exports.IccContactXApi = IccContactXApi;