@icure/api 8.3.6 → 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.
@@ -8,31 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var _a;
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  require("isomorphic-fetch");
14
13
  const test_utils_1 = require("../utils/test_utils");
15
14
  const mocha_1 = require("mocha");
16
- const icc_x_api_1 = require("../../icc-x-api");
17
- const Patient_1 = require("../../icc-api/model/Patient");
18
15
  const crypto_1 = require("crypto");
19
16
  const types_1 = require("@icure/test-setup/types");
20
- const Topic_1 = require("../../icc-api/model/Topic");
21
- const SecureDelegation_1 = require("../../icc-api/model/SecureDelegation");
22
- const XHR_1 = require("../../icc-api/api/XHR");
23
- const Message_1 = require("../../icc-api/model/Message");
24
- var initApi = test_utils_1.TestUtils.initApi;
25
- const FilterChainMessage_1 = require("../../icc-api/model/FilterChainMessage");
26
- const MessageByHcPartyFilter_1 = require("../../icc-x-api/filters/MessageByHcPartyFilter");
27
- const MessageByHcPartyTransportGuidFilter_1 = require("../../icc-x-api/filters/MessageByHcPartyTransportGuidFilter");
28
- const LatestMessageByHcPartyTransportGuidFilter_1 = require("../../icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter");
29
17
  const chai_1 = require("chai");
30
18
  const chaiAsPromised = require("chai-as-promised");
31
19
  const icc_api_1 = require("../../icc-api");
32
20
  (0, chai_1.use)(chaiAsPromised);
33
21
  (0, test_utils_1.setLocalStorage)(fetch);
34
22
  let env;
35
- (_a = (0, test_utils_1.describeNoLite)('icc-message-x-api Topic-based tests', () => {
23
+ (0, mocha_1.describe)('icc-message-x-api', () => {
36
24
  (0, mocha_1.before)(function () {
37
25
  return __awaiter(this, void 0, void 0, function* () {
38
26
  this.timeout(600000);
@@ -40,289 +28,27 @@ let env;
40
28
  env = yield initializer.execute((0, types_1.getEnvVariables)());
41
29
  });
42
30
  });
43
- function createMessage(messageApi, hcpUser, patient, topic) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- var _a, _b;
46
- return messageApi.encryptAndCreateMessageInTopic(yield messageApi.newInstanceWithPatient(hcpUser, patient, new Message_1.Message({
47
- id: (0, crypto_1.randomUUID)(),
48
- subject: 'Message Subject',
49
- sent: new Date().getTime(),
50
- transportGuid: topic.id,
51
- readStatus: Object.fromEntries(Object.keys((_a = topic.activeParticipants) !== null && _a !== void 0 ? _a : {})
52
- .filter((p) => p != hcpUser.healthcarePartyId)
53
- .map((hcpId) => [hcpId, { read: false }])),
54
- fromHealthcarePartyId: hcpUser.healthcarePartyId,
55
- }), {
56
- additionalDelegates: Object.fromEntries(Object.keys((_b = topic.activeParticipants) !== null && _b !== void 0 ? _b : {})
57
- .filter((hcpId) => hcpId != hcpUser.healthcarePartyId)
58
- .map((hcpId) => [hcpId, SecureDelegation_1.SecureDelegation.AccessLevelEnum.READ])),
59
- }));
60
- });
61
- }
62
- function createTopic(topicApi, hcpUser, patient, ...additionalUser) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- return topicApi.createTopic(yield topicApi.newInstance(hcpUser, patient, new Topic_1.Topic({
65
- id: (0, crypto_1.randomUUID)(),
66
- description: 'Topic description',
67
- activeParticipants: Object.assign(Object.assign({}, Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId, u.role]))), { [hcpUser.healthcarePartyId]: Topic_1.TopicRole.OWNER }),
68
- }), {
69
- additionalDelegates: Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId, SecureDelegation_1.SecureDelegation.AccessLevelEnum.WRITE])),
70
- }));
71
- });
72
- }
73
- function createPatient(patientApiForHcp, hcpUser) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
76
- id: (0, crypto_1.randomUUID)(),
77
- firstName: 'John',
78
- lastName: 'Snow',
79
- note: 'Winter is coming',
80
- })));
81
- });
82
- }
83
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a participant can read it', () => __awaiter(void 0, void 0, void 0, function* () {
84
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
85
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
86
- const hcpUser = yield userApiForHcp.getCurrentUser();
87
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
88
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
89
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
90
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
91
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
92
- const message2 = yield messageApiForHcp2.getAndDecryptMessage(createdMessage.id);
93
- (0, chai_1.expect)(message).to.deep.equal(createdMessage);
94
- (0, chai_1.expect)(message).to.deep.equal(message2);
95
- }));
96
- (0, mocha_1.it)('An HCP should be able to publish an encrypted message on a topic', () => __awaiter(void 0, void 0, void 0, function* () {
97
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username, {
31
+ (0, mocha_1.it)('Should be encrypted', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ const hcp = yield (0, test_utils_1.createNewHcpApi)(env, {
98
33
  encryptedFieldsConfig: {
99
34
  message: ['subject'],
100
35
  },
101
36
  });
102
- const baseMessageApi = new icc_api_1.IccMessageApi(env.iCureUrl, messageApiForHcp._headers, messageApiForHcp.authenticationProvider, messageApiForHcp.fetchImpl);
103
- const hcpUser = yield userApiForHcp.getCurrentUser();
104
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
105
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient);
106
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
107
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
108
- (0, chai_1.expect)(message).to.deep.equal(createdMessage);
109
- (0, chai_1.expect)(message.subject).to.not.be.undefined;
110
- const notDecryptedMessage = yield baseMessageApi.getMessage(createdMessage.id);
111
- (0, chai_1.expect)(notDecryptedMessage).to.not.deep.equal(createdMessage);
112
- (0, chai_1.expect)(notDecryptedMessage.subject).to.be.undefined;
113
- }));
114
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a non-participant cannot read it', () => __awaiter(void 0, void 0, void 0, function* () {
115
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
116
- const { userApi: userApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
117
- const { messageApi: messageApiForHcp3 } = yield initApi(env, test_utils_1.hcp3Username);
118
- const hcpUser = yield userApiForHcp.getCurrentUser();
119
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
120
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
121
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
122
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
123
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
124
- (0, chai_1.expect)(message).to.not.be.null;
125
- yield messageApiForHcp3.getAndDecryptMessage(createdMessage.id).then(() => chai_1.expect.fail('Should not be able to read the message'), (e) => {
126
- (0, chai_1.expect)(e).to.be.instanceOf(XHR_1.XHR.XHRError);
127
- (0, chai_1.expect)(e.statusCode).to.equal(403);
128
- });
129
- }));
130
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyFilter', () => __awaiter(void 0, void 0, void 0, function* () {
131
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
132
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
133
- const hcpUser = yield userApiForHcp.getCurrentUser();
134
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
135
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
136
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
137
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
138
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
139
- const filterChain = (hcpId) => new FilterChainMessage_1.FilterChainMessage({
140
- filter: new MessageByHcPartyFilter_1.MessageByHcPartyFilter({
141
- hcpId: hcpId,
142
- }),
143
- });
144
- const filterResultForHcp = yield messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId));
145
- (0, chai_1.expect)(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1);
146
- (0, chai_1.expect)(filterResultForHcp.rows.find((m) => m.id === message.id)).to.deep.equal(message);
147
- const filterResultForHcp2 = yield messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId));
148
- (0, chai_1.expect)(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1);
149
- (0, chai_1.expect)(filterResultForHcp2.rows.find((m) => m.id === message.id)).to.deep.equal(message);
150
- })).timeout(60000);
151
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyFilter', () => __awaiter(void 0, void 0, void 0, function* () {
152
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
153
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
154
- const { messageApi: messageApiForHcp3, userApi: userApiForHcp3 } = yield initApi(env, test_utils_1.hcp3Username);
155
- const hcpUser = yield userApiForHcp.getCurrentUser();
156
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
157
- const hcpUser3 = yield userApiForHcp3.getCurrentUser();
158
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
159
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
160
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
161
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
162
- const filterChain = (hcpId) => new FilterChainMessage_1.FilterChainMessage({
163
- filter: new MessageByHcPartyFilter_1.MessageByHcPartyFilter({
164
- hcpId: hcpId,
165
- }),
166
- });
167
- const filterResultForHcp = yield messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId));
168
- (0, chai_1.expect)(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1);
169
- (0, chai_1.expect)(filterResultForHcp.rows.find((m) => m.id === message.id)).to.deep.equal(message);
170
- const filterResultForHcp2 = yield messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId));
171
- (0, chai_1.expect)(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1);
172
- (0, chai_1.expect)(filterResultForHcp2.rows.find((m) => m.id === message.id)).to.deep.equal(message);
173
- const filterResultForHcp3 = yield messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId));
174
- (0, chai_1.expect)(filterResultForHcp3.rows.find((m) => m.id === message.id)).to.be.undefined;
37
+ const subject = 'Hello';
38
+ const transportGuid = (0, crypto_1.randomUUID)();
39
+ const created = yield hcp.api.messageApi.createMessageWithUser(undefined, yield hcp.api.messageApi.newInstance(hcp.user, {
40
+ id: (0, crypto_1.randomUUID)(),
41
+ subject,
42
+ transportGuid,
43
+ }));
44
+ (0, chai_1.expect)(created.subject).to.eq(subject);
45
+ (0, chai_1.expect)(created.transportGuid).to.eq(transportGuid);
46
+ const retrieved = yield hcp.api.messageApi.getMessageWithUser(undefined, created.id);
47
+ (0, chai_1.expect)(retrieved.subject).to.eq(subject);
48
+ (0, chai_1.expect)(retrieved.transportGuid).to.eq(transportGuid);
49
+ const encrypted = yield new icc_api_1.IccMessageApi(env.iCureUrl, {}, hcp.api.authApi.authenticationProvider, fetch).getMessage(created.id);
50
+ (0, chai_1.expect)(encrypted.subject).to.be.undefined;
51
+ (0, chai_1.expect)(encrypted.transportGuid).to.eq(transportGuid);
175
52
  }));
176
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyTransportGuidFilter', () => __awaiter(void 0, void 0, void 0, function* () {
177
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
178
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
179
- const hcpUser = yield userApiForHcp.getCurrentUser();
180
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
181
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
182
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
183
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
184
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
185
- const filterChain = (hcpId, transportGuid) => new FilterChainMessage_1.FilterChainMessage({
186
- filter: new MessageByHcPartyTransportGuidFilter_1.MessageByHcPartyTransportGuidFilter({
187
- healthcarePartyId: hcpId,
188
- transportGuid: transportGuid,
189
- }),
190
- });
191
- const filterResultForHcp = yield messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId, message.transportGuid));
192
- (0, chai_1.expect)(filterResultForHcp.rows).to.have.length(1);
193
- (0, chai_1.expect)(filterResultForHcp.rows.find((m) => m.id === message.id)).to.deep.equal(message);
194
- const filterResultForHcp2 = yield messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId, message.transportGuid));
195
- (0, chai_1.expect)(filterResultForHcp2.rows).to.have.length(1);
196
- (0, chai_1.expect)(filterResultForHcp2.rows.find((m) => m.id === message.id)).to.deep.equal(message);
197
- }));
198
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyTransportGuidFilter', () => __awaiter(void 0, void 0, void 0, function* () {
199
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
200
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
201
- const { userApi: userApiForHcp3, messageApi: messageApiForHcp3 } = yield initApi(env, test_utils_1.hcp3Username);
202
- const hcpUser = yield userApiForHcp.getCurrentUser();
203
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
204
- const hcpUser3 = yield userApiForHcp3.getCurrentUser();
205
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
206
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
207
- const createdMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
208
- const message = yield messageApiForHcp.getAndDecryptMessage(createdMessage.id);
209
- const filterChain = (hcpId, transportGuid) => new FilterChainMessage_1.FilterChainMessage({
210
- filter: new MessageByHcPartyTransportGuidFilter_1.MessageByHcPartyTransportGuidFilter({
211
- healthcarePartyId: hcpId,
212
- transportGuid: transportGuid,
213
- }),
214
- });
215
- const filterResultForHcp = yield messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId, message.transportGuid));
216
- (0, chai_1.expect)(filterResultForHcp.rows).to.have.length(1);
217
- (0, chai_1.expect)(filterResultForHcp.rows.find((m) => m.id === message.id)).to.deep.equal(message);
218
- const filterResultForHcp2 = yield messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId, message.transportGuid));
219
- (0, chai_1.expect)(filterResultForHcp2.rows).to.have.length(1);
220
- (0, chai_1.expect)(filterResultForHcp2.rows.find((m) => m.id === message.id)).to.deep.equal(message);
221
- const filterResultForHcp3 = yield messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId, message.transportGuid));
222
- (0, chai_1.expect)(filterResultForHcp3.rows.find((m) => m.id === message.id)).to.be.undefined;
223
- }));
224
- (0, mocha_1.it)('An HCP should be able to publish a message on a topic and a participant should be able to query it through LatestMessageByHcPartyTransportGuidFilter', () => __awaiter(void 0, void 0, void 0, function* () {
225
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
226
- const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = yield initApi(env, test_utils_1.hcp2Username);
227
- const hcpUser = yield userApiForHcp.getCurrentUser();
228
- const hcpUser2 = yield userApiForHcp2.getCurrentUser();
229
- const samplePatient = yield createPatient(patientApiForHcp, hcpUser);
230
- const createdTopic = yield createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: Topic_1.TopicRole.PARTICIPANT });
231
- let latestMessage = null;
232
- for (let i = 0; i < 5; i++) {
233
- // Creating 5 messages
234
- latestMessage = yield createMessage(messageApiForHcp, hcpUser, null, createdTopic);
235
- }
236
- const filterChain = (hcpId, transportGuid) => new FilterChainMessage_1.FilterChainMessage({
237
- filter: new LatestMessageByHcPartyTransportGuidFilter_1.LatestMessageByHcPartyTransportGuidFilter({
238
- healthcarePartyId: hcpId,
239
- transportGuid: transportGuid,
240
- }),
241
- });
242
- const filterResultForHcp2 = yield messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId, latestMessage.transportGuid));
243
- (0, chai_1.expect)(filterResultForHcp2.rows).to.have.length(1); // Only one message should be returned
244
- (0, chai_1.expect)(filterResultForHcp2.rows[0]).to.deep.equal(latestMessage); // It should be the latest message
245
- }));
246
- function doXOnYAndSubscribe(connectionPromise, x, statusListener, eventReceivedPromiseReject, eventReceivedPromise) {
247
- return __awaiter(this, void 0, void 0, function* () {
248
- const connection = (yield connectionPromise)
249
- .onClosed(() => __awaiter(this, void 0, void 0, function* () {
250
- statusListener('CLOSED');
251
- yield (0, icc_x_api_1.sleep)(3000);
252
- }))
253
- .onConnected(() => __awaiter(this, void 0, void 0, function* () {
254
- statusListener('CONNECTED');
255
- yield (0, icc_x_api_1.sleep)(2000);
256
- yield x();
257
- }));
258
- const timeout = setTimeout(eventReceivedPromiseReject, 20000);
259
- yield eventReceivedPromise.then(() => clearTimeout(timeout)).catch(() => { });
260
- connection.close();
261
- yield (0, icc_x_api_1.sleep)(3000);
262
- });
263
- }
264
- const subscribeAndCreateMessage = (options, eventTypes) => __awaiter(void 0, void 0, void 0, function* () {
265
- const { userApi: userApiForHcp, topicApi: topicApiForHcp, patientApi: patientApiForHcp, messageApi: messageApiForHcp, } = yield initApi(env, test_utils_1.hcp2Username);
266
- const loggedUser = yield userApiForHcp.getCurrentUser();
267
- const connectionPromise = (options, eventListener) => __awaiter(void 0, void 0, void 0, function* () {
268
- return messageApiForHcp.subscribeToMessageEvents(eventTypes, new MessageByHcPartyFilter_1.MessageByHcPartyFilter({
269
- hcpId: loggedUser.healthcarePartyId,
270
- }), eventListener, options);
271
- });
272
- const events = [];
273
- const statuses = [];
274
- let eventReceivedPromiseResolve;
275
- let eventReceivedPromiseReject;
276
- const eventReceivedPromise = new Promise((res, rej) => {
277
- eventReceivedPromiseResolve = res;
278
- eventReceivedPromiseReject = rej;
279
- });
280
- yield doXOnYAndSubscribe(connectionPromise(options, (healthcareElement) => __awaiter(void 0, void 0, void 0, function* () {
281
- events.push(healthcareElement);
282
- eventReceivedPromiseResolve();
283
- })), () => __awaiter(void 0, void 0, void 0, function* () {
284
- var _a;
285
- const user = yield userApiForHcp.getCurrentUser();
286
- const patient = yield patientApiForHcp.createPatientWithUser(user, yield patientApiForHcp.newInstance(user, new Patient_1.Patient({
287
- firstName: 'John',
288
- lastName: 'Snow',
289
- note: 'Winter is coming',
290
- })));
291
- const topic = yield topicApiForHcp.createTopic(yield topicApiForHcp.newInstance(loggedUser, patient, new Topic_1.Topic({
292
- description: 'Topic description',
293
- activeParticipants: {
294
- [loggedUser.healthcarePartyId]: Topic_1.TopicRole.OWNER,
295
- },
296
- })));
297
- const createdMessage = yield messageApiForHcp.encryptAndCreateMessageInTopic(yield messageApiForHcp.newInstanceWithPatient(loggedUser, null, new Message_1.Message({
298
- id: (0, crypto_1.randomUUID)(),
299
- subject: 'Message Subject',
300
- sent: new Date().getTime(),
301
- transportGuid: topic.id,
302
- readStatus: Object.fromEntries(Object.keys((_a = topic.activeParticipants) !== null && _a !== void 0 ? _a : {})
303
- .filter((hcpId) => hcpId != loggedUser.healthcarePartyId)
304
- .map((hcpId) => [hcpId, { read: false }])),
305
- fromHealthcarePartyId: loggedUser.healthcarePartyId,
306
- }), {
307
- additionalDelegates: {},
308
- }));
309
- }), (status) => {
310
- statuses.push(status);
311
- }, eventReceivedPromiseReject, eventReceivedPromise);
312
- events === null || events === void 0 ? void 0 : events.forEach((event) => console.log(`Event : ${event}`));
313
- statuses === null || statuses === void 0 ? void 0 : statuses.forEach((status) => console.log(`Status : ${status}`));
314
- (0, chai_1.expect)(statuses).to.have.length(2);
315
- (0, chai_1.expect)(events).to.have.length(1);
316
- (0, chai_1.expect)(events.every((event) => event instanceof Message_1.Message)).to.be.true;
317
- });
318
- (0, mocha_1.it)('CREATE Message without options', () => __awaiter(void 0, void 0, void 0, function* () {
319
- yield subscribeAndCreateMessage({}, ['CREATE']);
320
- })).timeout(60000);
321
- (0, mocha_1.it)('CREATE Message with options', () => __awaiter(void 0, void 0, void 0, function* () {
322
- yield subscribeAndCreateMessage({
323
- connectionRetryIntervalMs: 10000,
324
- connectionMaxRetry: 5,
325
- }, ['CREATE']);
326
- })).timeout(60000);
327
- })) === null || _a === void 0 ? void 0 : _a.timeout(60000);
53
+ });
328
54
  //# sourceMappingURL=icc-message-x-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAqJ;AACrJ,iCAA4C;AAC5C,+CAA4F;AAC5F,yDAAqD;AAErD,mCAAmC;AACnC,mDAAmE;AAEnE,qDAA4D;AAC5D,2EAAuE;AACvE,+CAA2C;AAC3C,yDAAqD;AACrD,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAElC,+EAA2E;AAC3E,2FAAuF;AACvF,qHAAiH;AACjH,iIAA6H;AAE7H,+BAA6C;AAC7C,mDAAkD;AAClD,2CAA6C;AAE7C,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AACvB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,MAAA,IAAA,2BAAc,EAAC,qCAAqC,EAAE,GAAG,EAAE;IACzD,IAAA,cAAM,EAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;QACpD,CAAC;KAAA,CAAC,CAAA;IAEF,SAAe,aAAa,CAAC,UAA0B,EAAE,OAAa,EAAE,OAAuB,EAAE,KAAY;;;YAC3G,OAAO,UAAU,CAAC,8BAA8B,CAC9C,MAAM,UAAU,CAAC,sBAAsB,CACrC,OAAO,EACP,OAAO,EACP,IAAI,iBAAO,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AAC,6BAA6B,EAAE,GAAS,EAAE;QAC3C,MAAM,yBAAyB,CAC7B;YACE,yBAAyB,EAAE,KAAM;YACjC,kBAAkB,EAAE,CAAC;SACtB,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IACH,CAAC,CAAA,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC,CAAC,0CAAE,OAAO,CAAC,KAAM,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { describeNoLite, getEnvironmentInitializer, hcp1Username, hcp2Username, hcp3Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before, it, describe } from 'mocha'\nimport { IccMessageXApi, IccPatientXApi, sleep, SubscriptionOptions } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { IccTopicXApi } from '../../icc-x-api/icc-topic-x-api'\nimport { Topic, TopicRole } from '../../icc-api/model/Topic'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { Message } from '../../icc-api/model/Message'\nimport initApi = TestUtils.initApi\nimport XHRError = XHR.XHRError\nimport { FilterChainMessage } from '../../icc-api/model/FilterChainMessage'\nimport { MessageByHcPartyFilter } from '../../icc-x-api/filters/MessageByHcPartyFilter'\nimport { MessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/MessageByHcPartyTransportGuidFilter'\nimport { LatestMessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter'\nimport { Connection } from '../../icc-api/model/Connection'\nimport { expect, use as chaiUse } from 'chai'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { IccMessageApi } from '../../icc-api'\n\nchaiUse(chaiAsPromised)\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribeNoLite('icc-message-x-api Topic-based tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n async function createMessage(messageApi: IccMessageXApi, hcpUser: User, patient: Patient | null, topic: Topic) {\n return messageApi.encryptAndCreateMessageInTopic(\n await messageApi.newInstanceWithPatient(\n hcpUser,\n patient,\n new Message({\n id: randomUUID(),\n subject: 'Message Subject',\n sent: new Date().getTime(),\n transportGuid: topic.id,\n readStatus: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((p) => p != hcpUser.healthcarePartyId)\n .map((hcpId) => [hcpId, { read: false }])\n ),\n fromHealthcarePartyId: hcpUser.healthcarePartyId,\n }),\n {\n additionalDelegates: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((hcpId) => hcpId != hcpUser.healthcarePartyId)\n .map((hcpId) => [hcpId, SecureDelegation.AccessLevelEnum.READ])\n ),\n }\n )\n )\n }\n\n async function createTopic(topicApi: IccTopicXApi, hcpUser: User, patient: Patient, ...additionalUser: { user: User; role: TopicRole }[]) {\n return topicApi.createTopic(\n await topicApi.newInstance(\n hcpUser,\n patient,\n new Topic({\n id: randomUUID(),\n description: 'Topic description',\n activeParticipants: {\n ...Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId!, u.role])),\n [hcpUser.healthcarePartyId!]: TopicRole.OWNER,\n },\n }),\n {\n additionalDelegates: Object.fromEntries(additionalUser.map((u) => [u.user.healthcarePartyId!, SecureDelegation.AccessLevelEnum.WRITE])),\n }\n )\n )\n }\n\n async function createPatient(patientApiForHcp: IccPatientXApi, hcpUser: User) {\n return patientApiForHcp.createPatientWithUser(\n hcpUser,\n await patientApiForHcp.newInstance(\n hcpUser,\n new Patient({\n id: randomUUID(),\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n }\n\n it('An HCP should be able to publish a message on a topic and a participant can read it', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n const message2 = await messageApiForHcp2.getAndDecryptMessage(createdMessage.id!)\n\n expect(message).to.deep.equal(createdMessage)\n expect(message).to.deep.equal(message2)\n })\n\n it('An HCP should be able to publish an encrypted message on a topic', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username, {\n encryptedFieldsConfig: {\n message: ['subject'],\n },\n })\n\n const baseMessageApi = new IccMessageApi(\n env!.iCureUrl,\n messageApiForHcp._headers,\n messageApiForHcp.authenticationProvider,\n messageApiForHcp.fetchImpl\n )\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient)\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n expect(message).to.deep.equal(createdMessage)\n expect(message.subject).to.not.be.undefined\n\n const notDecryptedMessage = await baseMessageApi.getMessage(createdMessage.id!)\n expect(notDecryptedMessage).to.not.deep.equal(createdMessage)\n expect(notDecryptedMessage.subject).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a non-participant cannot read it', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { messageApi: messageApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n expect(message).to.not.be.null\n\n await messageApiForHcp3.getAndDecryptMessage(createdMessage.id!).then(\n () => expect.fail('Should not be able to read the message'),\n (e) => {\n expect(e).to.be.instanceOf(XHR.XHRError)\n expect((e as XHRError).statusCode).to.equal(403)\n }\n )\n })\n\n it('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyFilter({\n hcpId: hcpId,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!))\n expect(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!))\n expect(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n }).timeout(60_000)\n\n it('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { messageApi: messageApiForHcp3, userApi: userApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n const hcpUser3 = await userApiForHcp3.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyFilter({\n hcpId: hcpId,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!))\n expect(filterResultForHcp.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!))\n expect(filterResultForHcp2.rows).to.have.length.greaterThanOrEqual(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp3 = await messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId!))\n expect(filterResultForHcp3.rows!.find((m) => m.id === message.id)).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a participant could query it through MessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp.rows).to.have.length(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n })\n\n it('An HCP should be able to publish a message on a topic and a non-participant should not be able to query it through MessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const { userApi: userApiForHcp3, messageApi: messageApiForHcp3 } = await initApi(env!, hcp3Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n const hcpUser3 = await userApiForHcp3.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n const createdMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n\n const message = await messageApiForHcp.getAndDecryptMessage(createdMessage.id!)\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new MessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp = await messageApiForHcp.filterMessagesBy(filterChain(hcpUser.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp.rows).to.have.length(1)\n expect(filterResultForHcp.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1)\n expect(filterResultForHcp2.rows!.find((m) => m.id === message.id)).to.deep.equal(message)\n\n const filterResultForHcp3 = await messageApiForHcp3.filterMessagesBy(filterChain(hcpUser3.healthcarePartyId!, message.transportGuid!))\n expect(filterResultForHcp3.rows!.find((m) => m.id === message.id)).to.be.undefined\n })\n\n it('An HCP should be able to publish a message on a topic and a participant should be able to query it through LatestMessageByHcPartyTransportGuidFilter', async () => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp1Username)\n\n const { userApi: userApiForHcp2, messageApi: messageApiForHcp2 } = await initApi(env!, hcp2Username)\n\n const hcpUser = await userApiForHcp.getCurrentUser()\n const hcpUser2 = await userApiForHcp2.getCurrentUser()\n\n const samplePatient = await createPatient(patientApiForHcp, hcpUser)\n const createdTopic = await createTopic(topicApiForHcp, hcpUser, samplePatient, { user: hcpUser2, role: TopicRole.PARTICIPANT })\n\n let latestMessage: Message | null = null\n for (let i = 0; i < 5; i++) {\n // Creating 5 messages\n latestMessage = await createMessage(messageApiForHcp, hcpUser, null, createdTopic)\n }\n\n const filterChain = (hcpId: string, transportGuid: string) =>\n new FilterChainMessage({\n filter: new LatestMessageByHcPartyTransportGuidFilter({\n healthcarePartyId: hcpId,\n transportGuid: transportGuid,\n }),\n })\n\n const filterResultForHcp2 = await messageApiForHcp2.filterMessagesBy(filterChain(hcpUser2.healthcarePartyId!, latestMessage!.transportGuid!))\n expect(filterResultForHcp2.rows).to.have.length(1) // Only one message should be returned\n expect(filterResultForHcp2.rows![0]).to.deep.equal(latestMessage) // It should be the latest message\n })\n\n async function doXOnYAndSubscribe<Y>(\n connectionPromise: Promise<Connection>,\n x: () => Promise<Y>,\n statusListener: (status: string) => void,\n eventReceivedPromiseReject: (reason?: any) => void,\n eventReceivedPromise: Promise<void>\n ) {\n const connection = (await connectionPromise)\n .onClosed(async () => {\n statusListener('CLOSED')\n await sleep(3_000)\n })\n .onConnected(async () => {\n statusListener('CONNECTED')\n await sleep(2_000)\n await x()\n })\n\n const timeout = setTimeout(eventReceivedPromiseReject, 20_000)\n await eventReceivedPromise.then(() => clearTimeout(timeout)).catch(() => {})\n\n connection.close()\n\n await sleep(3_000)\n }\n\n const subscribeAndCreateMessage = async (options: SubscriptionOptions, eventTypes: ('CREATE' | 'DELETE' | 'UPDATE')[]) => {\n const {\n userApi: userApiForHcp,\n topicApi: topicApiForHcp,\n patientApi: patientApiForHcp,\n messageApi: messageApiForHcp,\n } = await initApi(env!, hcp2Username)\n\n const loggedUser = await userApiForHcp.getCurrentUser()\n const connectionPromise = async (options: {}, eventListener: (healthcareElement: Message) => Promise<void>) =>\n messageApiForHcp.subscribeToMessageEvents(\n eventTypes,\n new MessageByHcPartyFilter({\n hcpId: loggedUser!.healthcarePartyId!,\n }),\n eventListener,\n options\n )\n\n const events: Message[] = []\n const statuses: string[] = []\n\n let eventReceivedPromiseResolve!: (value: void | PromiseLike<void>) => void\n let eventReceivedPromiseReject!: (reason?: any) => void\n const eventReceivedPromise = new Promise<void>((res, rej) => {\n eventReceivedPromiseResolve = res\n eventReceivedPromiseReject = rej\n })\n\n await doXOnYAndSubscribe(\n connectionPromise(options, async (healthcareElement) => {\n events.push(healthcareElement)\n eventReceivedPromiseResolve()\n }),\n async () => {\n const user = await userApiForHcp.getCurrentUser()\n\n const patient = await patientApiForHcp.createPatientWithUser(\n user,\n await patientApiForHcp.newInstance(\n user,\n new Patient({\n firstName: 'John',\n lastName: 'Snow',\n note: 'Winter is coming',\n })\n )\n )\n\n const topic = await topicApiForHcp.createTopic(\n await topicApiForHcp.newInstance(\n loggedUser,\n patient,\n new Topic({\n description: 'Topic description',\n activeParticipants: {\n [loggedUser.healthcarePartyId!]: TopicRole.OWNER,\n },\n })\n )\n )\n\n const createdMessage = await messageApiForHcp.encryptAndCreateMessageInTopic(\n await messageApiForHcp.newInstanceWithPatient(\n loggedUser,\n null,\n new Message({\n id: randomUUID(),\n subject: 'Message Subject',\n sent: new Date().getTime(),\n transportGuid: topic.id,\n readStatus: Object.fromEntries(\n Object.keys(topic.activeParticipants ?? {})\n .filter((hcpId) => hcpId != loggedUser.healthcarePartyId)\n .map((hcpId) => [hcpId, { read: false }])\n ),\n fromHealthcarePartyId: loggedUser.healthcarePartyId,\n }),\n {\n additionalDelegates: {},\n }\n )\n )\n },\n (status) => {\n statuses.push(status)\n },\n eventReceivedPromiseReject,\n eventReceivedPromise\n )\n\n events?.forEach((event) => console.log(`Event : ${event}`))\n statuses?.forEach((status) => console.log(`Status : ${status}`))\n\n expect(statuses).to.have.length(2)\n expect(events).to.have.length(1)\n expect(events.every((event) => event instanceof Message)).to.be.true\n }\n\n it('CREATE Message without options', async () => {\n await subscribeAndCreateMessage({}, ['CREATE'])\n }).timeout(60000)\n\n it('CREATE Message with options', async () => {\n await subscribeAndCreateMessage(\n {\n connectionRetryIntervalMs: 10_000,\n connectionMaxRetry: 5,\n },\n ['CREATE']\n )\n }).timeout(60000)\n})?.timeout(60_000)\n"]}
1
+ {"version":3,"file":"icc-message-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-message-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAS4B;AAC5B,iCAA4C;AAI5C,mCAAmC;AACnC,mDAAmE;AAanE,+BAA6C;AAC7C,mDAAkD;AAClD,2CAA6C;AAI7C,IAAA,UAAO,EAAC,cAAc,CAAC,CAAA;AACvB,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,IAAA,gBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAA,cAAM,EAAC;;YACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpB,MAAM,WAAW,GAAG,MAAM,IAAA,sCAAyB,GAAE,CAAA;YACrD,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,IAAA,uBAAe,GAAE,CAAC,CAAA;QACpD,CAAC;KAAA,CAAC,CAAA;IAEF,IAAA,UAAE,EAAC,qBAAqB,EAAE,GAAS,EAAE;QACnC,MAAM,GAAG,GAAG,MAAM,IAAA,4BAAe,EAAC,GAAG,EAAE;YACrC,qBAAqB,EAAE;gBACrB,OAAO,EAAE,CAAC,SAAS,CAAC;aACrB;SACF,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,OAAO,CAAA;QACvB,MAAM,aAAa,GAAG,IAAA,mBAAU,GAAE,CAAA;QAClC,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,GAAG,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,\n hcp2Username,\n hcp3Username,\n setLocalStorage,\n TestUtils,\n} from '../utils/test_utils'\nimport { before, it, describe } from 'mocha'\nimport { IccMessageXApi, IccPatientXApi, sleep, SubscriptionOptions } from '../../icc-x-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\nimport { IccTopicXApi } from '../../icc-x-api/icc-topic-x-api'\nimport { Topic, TopicRole } from '../../icc-api/model/Topic'\nimport { SecureDelegation } from '../../icc-api/model/SecureDelegation'\nimport { XHR } from '../../icc-api/api/XHR'\nimport { Message } from '../../icc-api/model/Message'\nimport initApi = TestUtils.initApi\nimport XHRError = XHR.XHRError\nimport { FilterChainMessage } from '../../icc-api/model/FilterChainMessage'\nimport { MessageByHcPartyFilter } from '../../icc-x-api/filters/MessageByHcPartyFilter'\nimport { MessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/MessageByHcPartyTransportGuidFilter'\nimport { LatestMessageByHcPartyTransportGuidFilter } from '../../icc-x-api/filters/LatestMessageByHcPartyTransportGuidFilter'\nimport { Connection } from '../../icc-api/model/Connection'\nimport { expect, use as chaiUse } from 'chai'\nimport * as chaiAsPromised from 'chai-as-promised'\nimport { IccMessageApi } from '../../icc-api'\nimport undefinedError = Mocha.utils.undefinedError\nimport { create } from 'lodash'\n\nchaiUse(chaiAsPromised)\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-message-x-api', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('Should be encrypted', async () => {\n const hcp = await createNewHcpApi(env, {\n encryptedFieldsConfig: {\n message: ['subject'],\n },\n })\n const subject = 'Hello'\n const transportGuid = randomUUID()\n const created = await hcp.api.messageApi.createMessageWithUser(\n undefined,\n await hcp.api.messageApi.newInstance(hcp.user, {\n id: randomUUID(),\n subject,\n transportGuid,\n })\n )\n expect(created.subject).to.eq(subject)\n expect(created.transportGuid).to.eq(transportGuid)\n const retrieved = await hcp.api.messageApi.getMessageWithUser(undefined, created.id!)\n expect(retrieved.subject).to.eq(subject)\n expect(retrieved.transportGuid).to.eq(transportGuid)\n const encrypted = await new IccMessageApi(env.iCureUrl, {}, hcp.api.authApi.authenticationProvider, fetch).getMessage(created.id!)\n expect(encrypted.subject).to.be.undefined\n expect(encrypted.transportGuid).to.eq(transportGuid)\n })\n})\n"]}
@@ -1,4 +1,4 @@
1
- import { IcureApi, IcureApiOptions } from '../../icc-x-api';
1
+ import { EncryptedFieldsConfig, IcureApi, IcureApiOptions } from '../../icc-x-api';
2
2
  import { IcureApi as TestSetupApi } from '@icure/apiV7';
3
3
  import { User } from '../../icc-api/model/User';
4
4
  import { TestVars, UserDetails } from '@icure/test-setup/types';
@@ -19,7 +19,9 @@ export declare namespace TestUtils {
19
19
  function initMasterApi(envVars: TestVars, options?: IcureApiOptions): Promise<IcureApi>;
20
20
  }
21
21
  export declare function getApiAndAddPrivateKeysForUser(iCureUrl: string, details: UserDetails, options?: IcureApiOptions): Promise<IcureApi>;
22
- export declare function createNewHcpApi(env: TestVars): Promise<{
22
+ export declare function createNewHcpApi(env: TestVars, options?: {
23
+ encryptedFieldsConfig?: EncryptedFieldsConfig;
24
+ }): Promise<{
23
25
  api: IcureApi;
24
26
  credentials: UserDetails;
25
27
  user: User;
@@ -150,8 +150,8 @@ function createHealthcarePartyUser(api, userLogin, userToken, publicKey, private
150
150
  };
151
151
  });
152
152
  }
153
- function createNewHcpApi(env) {
154
- return __awaiter(this, void 0, void 0, function* () {
153
+ function createNewHcpApi(env_1) {
154
+ return __awaiter(this, arguments, void 0, function* (env, options = {}) {
155
155
  const initialisationApi = yield testSetupMasterApi(env);
156
156
  const primitives = new icc_x_api_1.WebCryptoPrimitives(crypto_1.webcrypto);
157
157
  const credentials = yield createHealthcarePartyUser(initialisationApi, `user-${primitives.randomUuid()}@icure.com`, primitives.randomUuid());
@@ -165,6 +165,7 @@ function createNewHcpApi(env) {
165
165
  storage: storage.storage,
166
166
  keyStorage: storage.keyStorage,
167
167
  entryKeysFactory: storage.keyFactory,
168
+ encryptedFieldsConfig: options.encryptedFieldsConfig,
168
169
  });
169
170
  return { api, credentials, user: yield api.userApi.getCurrentUser() };
170
171
  });