@icure/api 8.3.5 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icc-api/api/IccAuthApi.d.ts +10 -1
- package/icc-api/api/IccAuthApi.js +20 -3
- package/icc-api/api/IccAuthApi.js.map +1 -1
- package/icc-api/api/IccClassificationApi.d.ts +1 -0
- package/icc-api/api/IccClassificationApi.js +12 -0
- package/icc-api/api/IccClassificationApi.js.map +1 -1
- package/icc-api/api/IccMessageApi.d.ts +0 -6
- package/icc-api/api/IccMessageApi.js +0 -15
- package/icc-api/api/IccMessageApi.js.map +1 -1
- package/icc-x-api/auth/SmartAuthProvider.d.ts +37 -13
- package/icc-x-api/auth/SmartAuthProvider.js +105 -29
- package/icc-x-api/auth/SmartAuthProvider.js.map +1 -1
- package/icc-x-api/icc-bekmehr-x-api.js +2 -1
- package/icc-x-api/icc-bekmehr-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.d.ts +51 -6
- package/icc-x-api/icc-document-x-api.js +231 -69
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-message-x-api.d.ts +45 -6
- package/icc-x-api/icc-message-x-api.js +202 -30
- package/icc-x-api/icc-message-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.d.ts +9 -1
- package/icc-x-api/icc-patient-x-api.js +92 -100
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +14 -14
- package/icc-x-api/index.js +5 -4
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-api/api/IccDocumentApi.js +27 -35
- package/test/icc-api/api/IccDocumentApi.js.map +1 -1
- package/test/icc-x-api/auth/group-switch-test.js +5 -5
- package/test/icc-x-api/auth/group-switch-test.js.map +1 -1
- package/test/icc-x-api/auth/jwt-provider-test.js +1 -1
- package/test/icc-x-api/auth/jwt-provider-test.js.map +1 -1
- package/test/icc-x-api/auth/smart-auth-provider-test.js +5 -5
- package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -1
- package/test/icc-x-api/icc-document-x-api.js +28 -4
- package/test/icc-x-api/icc-document-x-api.js.map +1 -1
- package/test/icc-x-api/icc-message-x-api.js +19 -293
- package/test/icc-x-api/icc-message-x-api.js.map +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js +1 -1
- package/test/icc-x-api/icc-user-x-api-test.js.map +1 -1
- package/test/utils/test_utils.d.ts +4 -2
- package/test/utils/test_utils.js +4 -3
- package/test/utils/test_utils.js.map +1 -1
|
@@ -156,11 +156,15 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
156
156
|
* the operation failed.
|
|
157
157
|
*/
|
|
158
158
|
tryShareWithMany(message, delegates) {
|
|
159
|
+
const _super = Object.create(null, {
|
|
160
|
+
bulkShareMessages: { get: () => super.bulkShareMessages }
|
|
161
|
+
});
|
|
159
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
163
|
// All entities should have an encryption key.
|
|
161
164
|
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(message, utils_1.EntityWithDelegationTypeName.Message);
|
|
162
|
-
const updatedEntity = entityWithEncryptionKey ? yield this.
|
|
163
|
-
return this.crypto.xapi
|
|
165
|
+
const updatedEntity = entityWithEncryptionKey ? yield this.modifyMessageWithUser(undefined, entityWithEncryptionKey) : message;
|
|
166
|
+
return this.crypto.xapi
|
|
167
|
+
.simpleShareOrUpdateEncryptedEntityMetadata({
|
|
164
168
|
entity: updatedEntity,
|
|
165
169
|
type: utils_1.EntityWithDelegationTypeName.Message,
|
|
166
170
|
}, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
@@ -171,7 +175,8 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
171
175
|
shareOwningEntityIds: options.sharePatientId,
|
|
172
176
|
shareSecretIds: options.shareSecretIds,
|
|
173
177
|
},
|
|
174
|
-
])), (x) =>
|
|
178
|
+
])), (x) => _super.bulkShareMessages.call(this, x))
|
|
179
|
+
.then((r) => r.mapSuccessAsync((m) => __awaiter(this, void 0, void 0, function* () { return (yield this.decrypt([m]))[0].entity; })));
|
|
175
180
|
});
|
|
176
181
|
}
|
|
177
182
|
/**
|
|
@@ -182,62 +187,229 @@ class IccMessageXApi extends icc_api_1.IccMessageApi {
|
|
|
182
187
|
decryptSecretIdsOf(message) {
|
|
183
188
|
return this.crypto.xapi.secretIdsOf({ entity: message, type: utils_1.EntityWithDelegationTypeName.Message }, undefined);
|
|
184
189
|
}
|
|
190
|
+
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
191
|
+
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.Message }, delegates);
|
|
192
|
+
}
|
|
185
193
|
getDataOwnersWithAccessTo(entity) {
|
|
186
194
|
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.Message });
|
|
187
195
|
}
|
|
188
196
|
getEncryptionKeysOf(entity) {
|
|
189
197
|
return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.Message }, undefined);
|
|
190
198
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
subscribeToMessageEvents(eventTypes_1, filter_1, eventFired_1) {
|
|
200
|
+
return __awaiter(this, arguments, void 0, function* (eventTypes, filter, eventFired, options = {}) {
|
|
201
|
+
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));
|
|
194
202
|
});
|
|
203
|
+
}
|
|
204
|
+
decryptPage(page) {
|
|
195
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
206
|
var _a;
|
|
197
|
-
|
|
198
|
-
const decryptedMessages = yield this.decrypt((_a = page.rows) !== null && _a !== void 0 ? _a : []);
|
|
199
|
-
if (decryptedMessages.some((m) => !m.decrypted))
|
|
200
|
-
throw new Error('Some messages could not be decrypted');
|
|
201
|
-
return Object.assign(Object.assign({}, page), { rows: decryptedMessages.map((m) => m.entity) });
|
|
207
|
+
return Object.assign(Object.assign({}, page), { rows: (yield this.decrypt((_a = page.rows) !== null && _a !== void 0 ? _a : [])).map((x) => x.entity) });
|
|
202
208
|
});
|
|
203
209
|
}
|
|
204
|
-
|
|
210
|
+
createMessageWithUser(user, body) {
|
|
205
211
|
const _super = Object.create(null, {
|
|
206
|
-
|
|
212
|
+
createMessage: { get: () => super.createMessage }
|
|
207
213
|
});
|
|
208
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
|
|
210
|
-
const createdMessage = yield _super.createMessageInTopic.call(this, encryptedMessage[0]);
|
|
211
|
-
return (yield this.decrypt([createdMessage]))[0].entity;
|
|
215
|
+
return (yield this.decrypt([yield _super.createMessage.call(this, (yield this.encrypt([body]))[0])]))[0].entity;
|
|
212
216
|
});
|
|
213
217
|
}
|
|
214
|
-
|
|
218
|
+
findMessagesWithUser(user, startKey, startDocumentId, limit) {
|
|
215
219
|
const _super = Object.create(null, {
|
|
216
|
-
|
|
220
|
+
findMessages: { get: () => super.findMessages }
|
|
221
|
+
});
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
return yield this.decryptPage(yield _super.findMessages.call(this, startKey, startDocumentId, limit));
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
findMessagesByFromAddressWithUser(user, fromAddress, startKey, startDocumentId, limit, hcpId) {
|
|
227
|
+
const _super = Object.create(null, {
|
|
228
|
+
findMessagesByFromAddress: { get: () => super.findMessagesByFromAddress }
|
|
217
229
|
});
|
|
218
230
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
-
return
|
|
231
|
+
return yield this.decryptPage(yield _super.findMessagesByFromAddress.call(this, fromAddress, startKey, startDocumentId, limit, hcpId));
|
|
220
232
|
});
|
|
221
233
|
}
|
|
222
|
-
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated
|
|
236
|
+
*/
|
|
237
|
+
findMessagesByHCPartyPatientForeignKeysUsingPostWithUser(user, body) {
|
|
238
|
+
const _super = Object.create(null, {
|
|
239
|
+
findMessagesByHCPartyPatientForeignKeysUsingPost: { get: () => super.findMessagesByHCPartyPatientForeignKeysUsingPost }
|
|
240
|
+
});
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
return (yield this.decrypt(yield _super.findMessagesByHCPartyPatientForeignKeysUsingPost.call(this, body))).map((x) => x.entity);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @deprecated
|
|
247
|
+
*/
|
|
248
|
+
findMessagesByHCPartyPatientForeignKeysWithUser(user, secretFKeys) {
|
|
249
|
+
const _super = Object.create(null, {
|
|
250
|
+
findMessagesByHCPartyPatientForeignKeys: { get: () => super.findMessagesByHCPartyPatientForeignKeys }
|
|
251
|
+
});
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
return (yield this.decrypt(yield _super.findMessagesByHCPartyPatientForeignKeys.call(this, secretFKeys))).map((x) => x.entity);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
findMessagesByToAddressWithUser(user, toAddress, startKey, startDocumentId, limit, reverse, hcpId) {
|
|
257
|
+
const _super = Object.create(null, {
|
|
258
|
+
findMessagesByToAddress: { get: () => super.findMessagesByToAddress }
|
|
259
|
+
});
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
return yield this.decryptPage(yield _super.findMessagesByToAddress.call(this, toAddress, startKey, startDocumentId, limit, reverse, hcpId));
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
findMessagesByTransportGuidWithUser(user, transportGuid, received, startKey, startDocumentId, limit, hcpId) {
|
|
265
|
+
const _super = Object.create(null, {
|
|
266
|
+
findMessagesByTransportGuid: { get: () => super.findMessagesByTransportGuid }
|
|
267
|
+
});
|
|
268
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
return yield this.decryptPage(yield _super.findMessagesByTransportGuid.call(this, transportGuid, received, startKey, startDocumentId, limit, hcpId));
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
findMessagesByTransportGuidSentDateWithUser(user, transportGuid, from, to, startKey, startDocumentId, limit, hcpId) {
|
|
273
|
+
const _super = Object.create(null, {
|
|
274
|
+
findMessagesByTransportGuidSentDate: { get: () => super.findMessagesByTransportGuidSentDate }
|
|
275
|
+
});
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
return yield this.decryptPage(yield _super.findMessagesByTransportGuidSentDate.call(this, transportGuid, from, to, startKey, startDocumentId, limit, hcpId));
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
getChildrenMessagesWithUser(user, messageId) {
|
|
281
|
+
const _super = Object.create(null, {
|
|
282
|
+
getChildrenMessages: { get: () => super.getChildrenMessages }
|
|
283
|
+
});
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
return (yield this.decrypt(yield _super.getChildrenMessages.call(this, messageId))).map((x) => x.entity);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
getChildrenMessagesOfListWithUser(user, body) {
|
|
289
|
+
const _super = Object.create(null, {
|
|
290
|
+
getChildrenMessagesOfList: { get: () => super.getChildrenMessagesOfList }
|
|
291
|
+
});
|
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
return (yield this.decrypt(yield _super.getChildrenMessagesOfList.call(this, body))).map((x) => x.entity);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
getMessageWithUser(user, messageId) {
|
|
223
297
|
const _super = Object.create(null, {
|
|
224
298
|
getMessage: { get: () => super.getMessage }
|
|
225
299
|
});
|
|
226
300
|
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
-
|
|
228
|
-
const decryptedMessage = yield this.decrypt([encryptedMessage]);
|
|
229
|
-
if (!decryptedMessage[0].decrypted)
|
|
230
|
-
throw new Error('Message could not be decrypted');
|
|
231
|
-
return decryptedMessage[0].entity;
|
|
301
|
+
return (yield this.decrypt([yield _super.getMessage.call(this, messageId)]))[0].entity;
|
|
232
302
|
});
|
|
233
303
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
304
|
+
getMessagesWithUser(user, messageIds) {
|
|
305
|
+
const _super = Object.create(null, {
|
|
306
|
+
getMessages: { get: () => super.getMessages }
|
|
307
|
+
});
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
return (yield this.decrypt(yield _super.getMessages.call(this, messageIds))).map((x) => x.entity);
|
|
237
310
|
});
|
|
238
311
|
}
|
|
239
|
-
|
|
240
|
-
|
|
312
|
+
listMessagesByInvoiceIdsWithUser(user, body) {
|
|
313
|
+
const _super = Object.create(null, {
|
|
314
|
+
listMessagesByInvoiceIds: { get: () => super.listMessagesByInvoiceIds }
|
|
315
|
+
});
|
|
316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
317
|
+
return (yield this.decrypt(yield _super.listMessagesByInvoiceIds.call(this, body))).map((x) => x.entity);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
listMessagesByTransportGuidsWithUser(user, hcpId, body) {
|
|
321
|
+
const _super = Object.create(null, {
|
|
322
|
+
listMessagesByTransportGuids: { get: () => super.listMessagesByTransportGuids }
|
|
323
|
+
});
|
|
324
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
return (yield this.decrypt(yield _super.listMessagesByTransportGuids.call(this, hcpId, body))).map((x) => x.entity);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
modifyMessageWithUser(user, body) {
|
|
329
|
+
const _super = Object.create(null, {
|
|
330
|
+
modifyMessage: { get: () => super.modifyMessage }
|
|
331
|
+
});
|
|
332
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
333
|
+
return (yield this.decrypt([yield _super.modifyMessage.call(this, (yield this.encrypt([body]))[0])]))[0].entity;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
setMessagesStatusBitsWithUser(user, status, body) {
|
|
337
|
+
const _super = Object.create(null, {
|
|
338
|
+
setMessagesStatusBits: { get: () => super.setMessagesStatusBits }
|
|
339
|
+
});
|
|
340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
+
return (yield this.decrypt(yield _super.setMessagesStatusBits.call(this, status, body))).map((x) => x.entity);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
filterMessagesByWithUser(user, body, startDocumentId, limit) {
|
|
345
|
+
const _super = Object.create(null, {
|
|
346
|
+
filterMessagesBy: { get: () => super.filterMessagesBy }
|
|
347
|
+
});
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
return yield this.decryptPage(yield _super.filterMessagesBy.call(this, body, startDocumentId, limit));
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
setMessagesReadStatusWithUser(user, body) {
|
|
353
|
+
const _super = Object.create(null, {
|
|
354
|
+
setMessagesReadStatus: { get: () => super.setMessagesReadStatus }
|
|
355
|
+
});
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
return (yield this.decrypt(yield _super.setMessagesReadStatus.call(this, body))).map((x) => x.entity);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
createMessage(body) {
|
|
361
|
+
throw new Error('Use withUser method');
|
|
362
|
+
}
|
|
363
|
+
findMessages(startKey, startDocumentId, limit) {
|
|
364
|
+
throw new Error('Use withUser method');
|
|
365
|
+
}
|
|
366
|
+
findMessagesByFromAddress(fromAddress, startKey, startDocumentId, limit, hcpId) {
|
|
367
|
+
throw new Error('Use withUser method');
|
|
368
|
+
}
|
|
369
|
+
findMessagesByHCPartyPatientForeignKeysUsingPost(body) {
|
|
370
|
+
throw new Error('Use withUser method');
|
|
371
|
+
}
|
|
372
|
+
findMessagesByHCPartyPatientForeignKeys(secretFKeys) {
|
|
373
|
+
throw new Error('Use withUser method');
|
|
374
|
+
}
|
|
375
|
+
findMessagesByToAddress(toAddress, startKey, startDocumentId, limit, reverse, hcpId) {
|
|
376
|
+
throw new Error('Use withUser method');
|
|
377
|
+
}
|
|
378
|
+
findMessagesByTransportGuid(transportGuid, received, startKey, startDocumentId, limit, hcpId) {
|
|
379
|
+
throw new Error('Use withUser method');
|
|
380
|
+
}
|
|
381
|
+
findMessagesByTransportGuidSentDate(transportGuid, from, to, startKey, startDocumentId, limit, hcpId) {
|
|
382
|
+
throw new Error('Use withUser method');
|
|
383
|
+
}
|
|
384
|
+
getChildrenMessages(messageId) {
|
|
385
|
+
throw new Error('Use withUser method');
|
|
386
|
+
}
|
|
387
|
+
getChildrenMessagesOfList(body) {
|
|
388
|
+
throw new Error('Use withUser method');
|
|
389
|
+
}
|
|
390
|
+
getMessage(messageId) {
|
|
391
|
+
throw new Error('Use withUser method');
|
|
392
|
+
}
|
|
393
|
+
getMessages(messageIds) {
|
|
394
|
+
throw new Error('Use withUser method');
|
|
395
|
+
}
|
|
396
|
+
listMessagesByInvoiceIds(body) {
|
|
397
|
+
throw new Error('Use withUser method');
|
|
398
|
+
}
|
|
399
|
+
listMessagesByTransportGuids(hcpId, body) {
|
|
400
|
+
throw new Error('Use withUser method');
|
|
401
|
+
}
|
|
402
|
+
modifyMessage(body) {
|
|
403
|
+
throw new Error('Use withUser method');
|
|
404
|
+
}
|
|
405
|
+
setMessagesStatusBits(status, body) {
|
|
406
|
+
throw new Error('Use withUser method');
|
|
407
|
+
}
|
|
408
|
+
filterMessagesBy(body, startDocumentId, limit) {
|
|
409
|
+
throw new Error('Use withUser method');
|
|
410
|
+
}
|
|
411
|
+
setMessagesReadStatus(body) {
|
|
412
|
+
throw new Error('Use withUser method');
|
|
241
413
|
}
|
|
242
414
|
}
|
|
243
415
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AAO,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;AAI9D,MAAa,cAAe,SAAQ,uBAAa;IAG/C,IAAI,OAAO;QACT,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,2BAA2B,CAAC,CAAC,EAAE,oCAA4B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,EAAE,eAAwB,EAAE,KAAc;QACjF,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;IAED,qBAAqB,CAAC,IAA+B;QACnD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;CACF;AA9eD,wCA8eC","sourcesContent":["import { IccAuthApi, IccMessageApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport * as models from '../icc-api/model/models'\nimport { DocIdentifier, ListOfIds, Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, User } from '../icc-api/model/models'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { FilterChainMessage } from '../icc-api/model/FilterChainMessage'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { AbstractFilter } from './filters/filters'\nimport { EncryptedFieldsManifest, EntityWithDelegationTypeName, parseEncryptedFields, subscribeToEntityEvents, SubscriptionOptions } from './utils'\nimport { Connection, ConnectionImpl } from '../icc-api/model/Connection'\nimport { SecretIdUseOption } from './crypto/SecretIdUseOption'\nimport { AbstractFilterMessage } from '../icc-api/model/AbstractFilterMessage'\nimport { BulkShareOrUpdateMetadataParams } from '../icc-api/model/requests/BulkShareOrUpdateMetadataParams'\n\nexport class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {\n private readonly encryptedFields: EncryptedFieldsManifest\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.Message))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly authApi: IccAuthApi,\n private readonly autofillAuthor: boolean,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n encryptedKeys: Array<string> = [],\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.encryptedFields = parseEncryptedFields(encryptedKeys, 'Message.')\n }\n\n // noinspection JSUnusedGlobalSymbols\n 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.modifyMessageWithUser(undefined, entityWithEncryptionKey) : message\n return this.crypto.xapi\n .simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.Message,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: options.sharePatientId,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => super.bulkShareMessages(x)\n )\n .then((r) => r.mapSuccessAsync(async (m) => (await this.decrypt([m]))[0].entity))\n }\n\n /**\n * @param message a message\n * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is\n * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.\n */\n decryptSecretIdsOf(message: models.Message): Promise<string[]> {\n return this.crypto.xapi.secretIdsOf({ entity: message, type: EntityWithDelegationTypeName.Message }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: EntityWithDelegationTypeName.Message }, delegates)\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 async subscribeToMessageEvents(\n eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[],\n filter: AbstractFilter<Message> | undefined,\n eventFired: (message: Message) => Promise<void>,\n options: SubscriptionOptions = {}\n ): Promise<Connection> {\n return await subscribeToEntityEvents(\n this.host,\n this.authApi,\n EntityWithDelegationTypeName.Message,\n eventTypes,\n filter,\n eventFired,\n options,\n async (encrypted) => (await this.decrypt([encrypted]))[0].entity\n ).then((rs) => new ConnectionImpl(rs))\n }\n\n private async decryptPage(page: PaginatedListMessage): Promise<PaginatedListMessage> {\n return {\n ...page,\n rows: (await this.decrypt(page.rows ?? [])).map((x) => x.entity),\n }\n }\n\n async createMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.createMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n async findMessagesWithUser(\n user: models.User | undefined,\n startKey?: string,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessages(startKey, startDocumentId, limit))\n }\n\n async findMessagesByFromAddressWithUser(\n user: models.User | undefined,\n fromAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByFromAddress(fromAddress, startKey, startDocumentId, limit, hcpId))\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysUsingPostWithUser(user: models.User | undefined, body?: Array<string>): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeysUsingPost(body))).map((x) => x.entity)\n }\n\n /**\n * @deprecated\n */\n async findMessagesByHCPartyPatientForeignKeysWithUser(user: models.User | undefined, secretFKeys: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.findMessagesByHCPartyPatientForeignKeys(secretFKeys))).map((x) => x.entity)\n }\n\n async findMessagesByToAddressWithUser(\n user: models.User | undefined,\n toAddress?: string,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n reverse?: boolean,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByToAddress(toAddress, startKey, startDocumentId, limit, reverse, hcpId))\n }\n\n async findMessagesByTransportGuidWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuid(transportGuid, received, startKey, startDocumentId, limit, hcpId))\n }\n\n async findMessagesByTransportGuidSentDateWithUser(\n user: models.User | undefined,\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.findMessagesByTransportGuidSentDate(transportGuid, from, to, startKey, startDocumentId, limit, hcpId))\n }\n\n async getChildrenMessagesWithUser(user: models.User | undefined, messageId: string): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessages(messageId))).map((x) => x.entity)\n }\n\n async getChildrenMessagesOfListWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.getChildrenMessagesOfList(body))).map((x) => x.entity)\n }\n\n async getMessageWithUser(user: models.User | undefined, messageId: string): Promise<Message> {\n return (await this.decrypt([await super.getMessage(messageId)]))[0].entity\n }\n\n async getMessagesWithUser(user: models.User | undefined, messageIds: ListOfIds): Promise<Message[]> {\n return (await this.decrypt(await super.getMessages(messageIds))).map((x) => x.entity)\n }\n\n async listMessagesByInvoiceIdsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByInvoiceIds(body))).map((x) => x.entity)\n }\n\n async listMessagesByTransportGuidsWithUser(user: models.User | undefined, hcpId: string, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.listMessagesByTransportGuids(hcpId, body))).map((x) => x.entity)\n }\n\n async modifyMessageWithUser(user: models.User | undefined, body: Message): Promise<Message> {\n return (await this.decrypt([await super.modifyMessage((await this.encrypt([body]))[0])]))[0].entity\n }\n\n async setMessagesStatusBitsWithUser(user: models.User | undefined, status: number, body?: ListOfIds): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesStatusBits(status, body))).map((x) => x.entity)\n }\n\n async filterMessagesByWithUser(\n user: models.User | undefined,\n body: FilterChainMessage,\n startDocumentId?: string,\n limit?: number\n ): Promise<PaginatedListMessage> {\n return await this.decryptPage(await super.filterMessagesBy(body, startDocumentId, limit))\n }\n\n async setMessagesReadStatusWithUser(user: models.User | undefined, body?: MessagesReadStatusUpdate): Promise<Array<Message>> {\n return (await this.decrypt(await super.setMessagesReadStatus(body))).map((x) => x.entity)\n }\n\n createMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n findMessages(startKey?: string, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByFromAddress(fromAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeysUsingPost(body?: Array<string>): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByHCPartyPatientForeignKeys(secretFKeys: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByToAddress(toAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, reverse?: boolean, hcpId?: string): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuid(\n transportGuid?: string,\n received?: boolean,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n findMessagesByTransportGuidSentDate(\n transportGuid?: string,\n from?: number,\n to?: number,\n startKey?: string,\n startDocumentId?: string,\n limit?: number,\n hcpId?: string\n ): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessages(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getChildrenMessagesOfList(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n getMessage(messageId: string): never {\n throw new Error('Use withUser method')\n }\n\n getMessages(messageIds: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByInvoiceIds(body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n listMessagesByTransportGuids(hcpId: string, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n modifyMessage(body?: Message): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesStatusBits(status: number, body?: ListOfIds): never {\n throw new Error('Use withUser method')\n }\n\n filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): never {\n throw new Error('Use withUser method')\n }\n\n setMessagesReadStatus(body?: MessagesReadStatusUpdate): never {\n throw new Error('Use withUser method')\n }\n}\n"]}
|
|
@@ -157,8 +157,16 @@ export declare class IccPatientXApi extends IccPatientApi implements EncryptedEn
|
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
159
|
} | null>;
|
|
160
|
-
export(user: models.User, patId: string, ownerId: string
|
|
160
|
+
export(user: models.User, patId: string, ownerId: string): Promise<{
|
|
161
161
|
id: string;
|
|
162
|
+
patient: Patient | null;
|
|
163
|
+
contacts: models.Contact[];
|
|
164
|
+
forms: models.Form[];
|
|
165
|
+
healthElements: models.HealthElement[];
|
|
166
|
+
invoices: models.Invoice[];
|
|
167
|
+
classifications: models.Classification[];
|
|
168
|
+
calItems: models.CalendarItem[];
|
|
169
|
+
documents: models.Document[];
|
|
162
170
|
}>;
|
|
163
171
|
checkInami(inami: string): boolean;
|
|
164
172
|
isValidSsin(ssin: string): boolean;
|