@icure/api 7.1.34 → 7.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/icc-api/api/IccAuthApi.d.ts +1 -0
  2. package/icc-api/api/IccAuthApi.js +1 -0
  3. package/icc-api/api/IccAuthApi.js.map +1 -1
  4. package/icc-x-api/index.d.ts +22 -29
  5. package/icc-x-api/index.js +60 -38
  6. package/icc-x-api/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/test/icc-api/api/IccDocumentApi.d.ts +1 -0
  9. package/test/icc-api/api/IccDocumentApi.js +200 -0
  10. package/test/icc-api/api/IccDocumentApi.js.map +1 -0
  11. package/test/icc-api/api/IccGroupApi.d.ts +1 -0
  12. package/test/icc-api/api/IccGroupApi.js +50 -0
  13. package/test/icc-api/api/IccGroupApi.js.map +1 -0
  14. package/test/icc-api/api/IccRoleApi.d.ts +1 -0
  15. package/test/icc-api/api/IccRoleApi.js +34 -0
  16. package/test/icc-api/api/IccRoleApi.js.map +1 -0
  17. package/test/icc-api/api/IccUserApi.d.ts +1 -0
  18. package/test/icc-api/api/IccUserApi.js +80 -0
  19. package/test/icc-api/api/IccUserApi.js.map +1 -0
  20. package/test/icc-api/e2e/IccCalendarItemApi.d.ts +1 -0
  21. package/test/icc-api/e2e/IccCalendarItemApi.js +45 -0
  22. package/test/icc-api/e2e/IccCalendarItemApi.js.map +1 -0
  23. package/test/icc-api/model/modelHelpersTest.d.ts +1 -0
  24. package/test/icc-api/model/modelHelpersTest.js +45 -0
  25. package/test/icc-api/model/modelHelpersTest.js.map +1 -0
  26. package/test/icc-x-api/auth/group-switch-test.d.ts +1 -0
  27. package/test/icc-x-api/auth/group-switch-test.js +81 -0
  28. package/test/icc-x-api/auth/group-switch-test.js.map +1 -0
  29. package/test/icc-x-api/auth/jwt-concurrency-test.d.ts +2 -0
  30. package/test/icc-x-api/auth/jwt-concurrency-test.js +113 -0
  31. package/test/icc-x-api/auth/jwt-concurrency-test.js.map +1 -0
  32. package/test/icc-x-api/auth/smart-auth-provider-test.d.ts +1 -0
  33. package/test/icc-x-api/auth/smart-auth-provider-test.js +222 -0
  34. package/test/icc-x-api/auth/smart-auth-provider-test.js.map +1 -0
  35. package/test/icc-x-api/crypto/KeyManager-test.d.ts +1 -0
  36. package/test/icc-x-api/crypto/KeyManager-test.js +225 -0
  37. package/test/icc-x-api/crypto/KeyManager-test.js.map +1 -0
  38. package/test/icc-x-api/crypto/concurrency.d.ts +1 -0
  39. package/test/icc-x-api/crypto/concurrency.js +35 -0
  40. package/test/icc-x-api/crypto/concurrency.js.map +1 -0
  41. package/test/icc-x-api/crypto/crypto-utils.d.ts +1 -0
  42. package/test/icc-x-api/crypto/crypto-utils.js +80 -0
  43. package/test/icc-x-api/crypto/crypto-utils.js.map +1 -0
  44. package/test/icc-x-api/crypto/cryptoTest.d.ts +2 -0
  45. package/test/icc-x-api/crypto/cryptoTest.js +275 -0
  46. package/test/icc-x-api/crypto/cryptoTest.js.map +1 -0
  47. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.d.ts +1 -0
  48. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js +132 -0
  49. package/test/icc-x-api/crypto/delegate-ci-to-patient-with-missing-keys-test.js.map +1 -0
  50. package/test/icc-x-api/crypto/full-crypto-test.d.ts +1 -0
  51. package/test/icc-x-api/crypto/full-crypto-test.js +458 -0
  52. package/test/icc-x-api/crypto/full-crypto-test.js.map +1 -0
  53. package/test/icc-x-api/crypto/shamir.d.ts +2 -0
  54. package/test/icc-x-api/crypto/shamir.js +156 -0
  55. package/test/icc-x-api/crypto/shamir.js.map +1 -0
  56. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.d.ts +1 -0
  57. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js +75 -0
  58. package/test/icc-x-api/crypto/share-to-newly-created-patient-from-hcp.js.map +1 -0
  59. package/test/icc-x-api/data-compatibility-test-7to6.d.ts +1 -0
  60. package/test/icc-x-api/data-compatibility-test-7to6.js +343 -0
  61. package/test/icc-x-api/data-compatibility-test-7to6.js.map +1 -0
  62. package/test/icc-x-api/entity-with-attachments-api-test.d.ts +1 -0
  63. package/test/icc-x-api/entity-with-attachments-api-test.js +142 -0
  64. package/test/icc-x-api/entity-with-attachments-api-test.js.map +1 -0
  65. package/test/icc-x-api/filters/filters.d.ts +1 -0
  66. package/test/icc-x-api/filters/filters.js +49 -0
  67. package/test/icc-x-api/filters/filters.js.map +1 -0
  68. package/test/icc-x-api/icc-accesslog-x-api.d.ts +1 -0
  69. package/test/icc-x-api/icc-accesslog-x-api.js +121 -0
  70. package/test/icc-x-api/icc-accesslog-x-api.js.map +1 -0
  71. package/test/icc-x-api/icc-auth-api.d.ts +1 -0
  72. package/test/icc-x-api/icc-auth-api.js +46 -0
  73. package/test/icc-x-api/icc-auth-api.js.map +1 -0
  74. package/test/icc-x-api/icc-calendar-item-x-api.d.ts +1 -0
  75. package/test/icc-x-api/icc-calendar-item-x-api.js +146 -0
  76. package/test/icc-x-api/icc-calendar-item-x-api.js.map +1 -0
  77. package/test/icc-x-api/icc-contact-x-api.d.ts +1 -0
  78. package/test/icc-x-api/icc-contact-x-api.js +311 -0
  79. package/test/icc-x-api/icc-contact-x-api.js.map +1 -0
  80. package/test/icc-x-api/icc-form-x-api.d.ts +1 -0
  81. package/test/icc-x-api/icc-form-x-api.js +331 -0
  82. package/test/icc-x-api/icc-form-x-api.js.map +1 -0
  83. package/test/icc-x-api/icc-helement-x-api-test.d.ts +1 -0
  84. package/test/icc-x-api/icc-helement-x-api-test.js +158 -0
  85. package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -0
  86. package/test/icc-x-api/icc-invoice-x-api.d.ts +1 -0
  87. package/test/icc-x-api/icc-invoice-x-api.js +115 -0
  88. package/test/icc-x-api/icc-invoice-x-api.js.map +1 -0
  89. package/test/icc-x-api/icc-maintenance-task-x-api-test.d.ts +1 -0
  90. package/test/icc-x-api/icc-maintenance-task-x-api-test.js +230 -0
  91. package/test/icc-x-api/icc-maintenance-task-x-api-test.js.map +1 -0
  92. package/test/icc-x-api/icc-patient-x-api-test.d.ts +1 -0
  93. package/test/icc-x-api/icc-patient-x-api-test.js +169 -0
  94. package/test/icc-x-api/icc-patient-x-api-test.js.map +1 -0
  95. package/test/icc-x-api/icc-time-table-x-api.d.ts +1 -0
  96. package/test/icc-x-api/icc-time-table-x-api.js +110 -0
  97. package/test/icc-x-api/icc-time-table-x-api.js.map +1 -0
  98. package/test/icc-x-api/icc-user-x-api-test.d.ts +1 -0
  99. package/test/icc-x-api/icc-user-x-api-test.js +108 -0
  100. package/test/icc-x-api/icc-user-x-api-test.js.map +1 -0
  101. package/test/icc-x-api/icureapi-group-test.d.ts +1 -0
  102. package/test/icc-x-api/icureapi-group-test.js +130 -0
  103. package/test/icc-x-api/icureapi-group-test.js.map +1 -0
  104. package/test/icc-x-api/patient-user.d.ts +2 -0
  105. package/test/icc-x-api/patient-user.js +117 -0
  106. package/test/icc-x-api/patient-user.js.map +1 -0
  107. package/test/icc-x-api/storage/storage.d.ts +1 -0
  108. package/test/icc-x-api/storage/storage.js +50 -0
  109. package/test/icc-x-api/storage/storage.js.map +1 -0
  110. package/test/icc-x-api/subscription-apis.d.ts +2 -0
  111. package/test/icc-x-api/subscription-apis.js +498 -0
  112. package/test/icc-x-api/subscription-apis.js.map +1 -0
  113. package/test/icc-x-api/test-api-no-parent.d.ts +1 -0
  114. package/test/icc-x-api/test-api-no-parent.js +79 -0
  115. package/test/icc-x-api/test-api-no-parent.js.map +1 -0
  116. package/test/icc-x-api/test-legacy-data-support.d.ts +1 -0
  117. package/test/icc-x-api/test-legacy-data-support.js +231 -0
  118. package/test/icc-x-api/test-legacy-data-support.js.map +1 -0
  119. package/test/icc-x-api/utils/crypto-utils-test.d.ts +1 -0
  120. package/test/icc-x-api/utils/crypto-utils-test.js +586 -0
  121. package/test/icc-x-api/utils/crypto-utils-test.js.map +1 -0
  122. package/test/icc-x-api/utils/graph-test.d.ts +1 -0
  123. package/test/icc-x-api/utils/graph-test.js +54 -0
  124. package/test/icc-x-api/utils/graph-test.js.map +1 -0
  125. package/test/support/CSM-185.d.ts +1 -0
  126. package/test/support/CSM-185.js +120 -0
  127. package/test/support/CSM-185.js.map +1 -0
  128. package/test/support/CSM-87.d.ts +0 -0
  129. package/test/support/CSM-87.js +21 -0
  130. package/test/support/CSM-87.js.map +1 -0
  131. package/test/support/CSM-93.d.ts +1 -0
  132. package/test/support/CSM-93.js +111 -0
  133. package/test/support/CSM-93.js.map +1 -0
  134. package/test/utils/TestApi.d.ts +3 -0
  135. package/test/utils/TestApi.js +27 -0
  136. package/test/utils/TestApi.js.map +1 -0
  137. package/test/utils/TestCollectionUtils.d.ts +1 -0
  138. package/test/utils/TestCollectionUtils.js +109 -0
  139. package/test/utils/TestCollectionUtils.js.map +1 -0
  140. package/test/utils/TestCryptoStrategies.d.ts +37 -0
  141. package/test/utils/TestCryptoStrategies.js +72 -0
  142. package/test/utils/TestCryptoStrategies.js.map +1 -0
  143. package/test/utils/TestStorage.d.ts +31 -0
  144. package/test/utils/TestStorage.js +88 -0
  145. package/test/utils/TestStorage.js.map +1 -0
  146. package/test/utils/test_utils.d.ts +60 -0
  147. package/test/utils/test_utils.js +313 -0
  148. package/test/utils/test_utils.js.map +1 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_1 = require("chai");
4
+ require("mocha");
5
+ const filters_1 = require("../../../icc-x-api/filters/filters");
6
+ describe('Composition', () => {
7
+ it('or should return an or combining other filters', () => {
8
+ const builder = filters_1.Filter.patient().forHcp('me').olderThan(65).or().youngerThan(18);
9
+ const filter = builder.build();
10
+ (0, chai_1.expect)(filter.$type).to.equal('UnionFilter');
11
+ });
12
+ it('and should work with or', () => {
13
+ const builder = filters_1.Filter.patient().forHcp('me').olderThan(65).or().youngerThan(18).and().searchByName('dup');
14
+ const filter = builder.build();
15
+ (0, chai_1.expect)(filter.$type).to.equal('IntersectionFilter');
16
+ (0, chai_1.expect)(filter.filters[0].$type).to.equal('UnionFilter');
17
+ });
18
+ it('precedence of operators can be managed for and/or', () => {
19
+ const builder = filters_1.Filter.patient()
20
+ .forHcp('me')
21
+ .olderThan(65)
22
+ .or((it) => it.youngerThan(18).and().searchByName('dup'));
23
+ const filter = builder.build();
24
+ (0, chai_1.expect)(filter.$type).to.equal('UnionFilter');
25
+ (0, chai_1.expect)(filter.filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter');
26
+ (0, chai_1.expect)(filter.filters[1].$type).to.equal('IntersectionFilter');
27
+ });
28
+ it('and should work with and', () => {
29
+ const builder = filters_1.Filter.patient().youngerThan(65).and().olderThan(18).and().searchByName('dup');
30
+ const filter = builder.build();
31
+ (0, chai_1.expect)(filter.$type).to.equal('IntersectionFilter');
32
+ (0, chai_1.expect)(filter.filters[0].$type).to.equal('IntersectionFilter');
33
+ });
34
+ it('should not crash miserably on incomplete or/and', () => {
35
+ const builder = filters_1.Filter.patient().youngerThan(65).and();
36
+ const filter = builder.build();
37
+ (0, chai_1.expect)(filter.$type).to.equal('IntersectionFilter');
38
+ (0, chai_1.expect)(filter.filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter');
39
+ (0, chai_1.expect)(filter.filters[1].$type).to.equal('PatientByHcPartyFilter');
40
+ });
41
+ it('should not crash miserably on combination of or/and', () => {
42
+ const builder = filters_1.Filter.patient().youngerThan(65).and().or().olderThan(75);
43
+ const filter = builder.build();
44
+ (0, chai_1.expect)(filter.$type).to.equal('IntersectionFilter');
45
+ (0, chai_1.expect)(filter.filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter');
46
+ (0, chai_1.expect)(filter.filters[1].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter');
47
+ });
48
+ });
49
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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ribe('Composition', () => {\n it('or should return an or combining other filters', () => {\n const builder = Filter.patient().forHcp('me').olderThan(65).or().youngerThan(18)\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('UnionFilter')\n })\n\n it('and should work with or', () => {\n const builder = Filter.patient().forHcp('me').olderThan(65).or().youngerThan(18).and().searchByName('dup')\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('IntersectionFilter')\n expect((filter as any).filters[0].$type).to.equal('UnionFilter')\n })\n\n it('precedence of operators can be managed for and/or', () => {\n const builder = Filter.patient()\n .forHcp('me')\n .olderThan(65)\n .or((it) => it.youngerThan(18).and().searchByName('dup'))\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('UnionFilter')\n expect((filter as any).filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter')\n expect((filter as any).filters[1].$type).to.equal('IntersectionFilter')\n })\n\n it('and should work with and', () => {\n const builder = Filter.patient().youngerThan(65).and().olderThan(18).and().searchByName('dup')\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('IntersectionFilter')\n expect((filter as any).filters[0].$type).to.equal('IntersectionFilter')\n })\n\n it('should not crash miserably on incomplete or/and', () => {\n const builder = Filter.patient().youngerThan(65).and()\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('IntersectionFilter')\n expect((filter as any).filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter')\n expect((filter as any).filters[1].$type).to.equal('PatientByHcPartyFilter')\n })\n\n it('should not crash miserably on combination of or/and', () => {\n const builder = Filter.patient().youngerThan(65).and().or().olderThan(75)\n const filter = builder.build()\n\n expect((filter as any).$type).to.equal('IntersectionFilter')\n expect((filter as any).filters[0].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter')\n expect((filter as any).filters[1].$type).to.equal('PatientByHcPartyDateOfBirthBetweenFilter')\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ require("isomorphic-fetch");
13
+ const test_utils_1 = require("../utils/test_utils");
14
+ const mocha_1 = require("mocha");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
17
+ const icc_api_1 = require("../../icc-api");
18
+ const Patient_1 = require("../../icc-api/model/Patient");
19
+ const crypto_1 = require("crypto");
20
+ const AccessLog_1 = require("../../icc-api/model/AccessLog");
21
+ const chai_1 = require("chai");
22
+ var initApi = test_utils_1.TestUtils.initApi;
23
+ const types_1 = require("@icure/test-setup/types");
24
+ (0, test_utils_1.setLocalStorage)(fetch);
25
+ let env;
26
+ describe('icc-x-accesslog-api Tests', () => {
27
+ (0, mocha_1.before)(function () {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ this.timeout(600000);
30
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
31
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
32
+ });
33
+ });
34
+ function createPatient(patientApiForHcp, hcpUser) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
37
+ id: (0, crypto_1.randomUUID)(),
38
+ firstName: 'John',
39
+ lastName: 'Snow',
40
+ note: 'Winter is coming',
41
+ })));
42
+ });
43
+ }
44
+ it('Test', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ // Given
46
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
47
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
48
+ const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
49
+ const userApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, authProvider, null, fetch);
50
+ const accessLogApi = new icc_api_1.IccAccesslogApi(env.iCureUrl, {}, authProvider, fetch);
51
+ const currentUser = yield userApi.getCurrentUser();
52
+ yield accessLogApi.findByUserAfterDate(currentUser.id);
53
+ }));
54
+ it('Test findBy', () => __awaiter(void 0, void 0, void 0, function* () {
55
+ // Given
56
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, cryptoApi: cryptoApiForHcp, dataOwnerApi: dateOwnerApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
57
+ const hcpUser = yield userApiForHcp.getCurrentUser();
58
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
59
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
60
+ const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
61
+ const accessLogXApi = new icc_x_api_1.IccAccesslogXApi(env.iCureUrl, {}, cryptoApiForHcp, dateOwnerApiForHcp, icc_x_api_1.EncryptedFieldsConfig.Defaults.accessLog, authProvider, fetch);
62
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
63
+ const accessLog = new AccessLog_1.AccessLog({
64
+ id: (0, crypto_1.randomUUID)(),
65
+ _type: 'org.taktik.icure.entities.AccessLog',
66
+ created: new Date().getTime(),
67
+ modified: new Date().getTime(),
68
+ date: +new Date(),
69
+ responsible: hcpUser.healthcarePartyId,
70
+ author: hcpUser.id,
71
+ codes: [],
72
+ tags: [],
73
+ user: hcpUser.id,
74
+ patient: patient.id,
75
+ accessType: 'USER_ACCESS',
76
+ });
77
+ const accessLogToCreate = yield accessLogXApi.newInstance(hcpUser, patient, accessLog);
78
+ const createdAccessLog = yield accessLogXApi.createAccessLogWithUser(hcpUser, accessLogToCreate);
79
+ const foundItems = yield accessLogXApi.findBy(hcpUser.healthcarePartyId, patient, false);
80
+ const foundItemsUsingPost = yield accessLogXApi.findBy(hcpUser.healthcarePartyId, patient, true);
81
+ (0, chai_1.assert)(foundItems.length == 1, 'Found items should be 1');
82
+ (0, chai_1.assert)(foundItems[0].id == createdAccessLog.id, 'Found item should be the same as the created one');
83
+ (0, chai_1.assert)(foundItemsUsingPost.length == 1, 'Found items using post should be 1');
84
+ (0, chai_1.assert)(foundItemsUsingPost[0].id == createdAccessLog.id, 'Found item using post should be the same as the created one');
85
+ }));
86
+ it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
87
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
88
+ const user1 = yield api1.userApi.getCurrentUser();
89
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
90
+ const user2 = yield api2.userApi.getCurrentUser();
91
+ const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
92
+ const encryptedField = 'Something encrypted';
93
+ const entity = yield api1.accessLogApi.createAccessLogWithUser(user1, yield api1.accessLogApi.newInstance(user1, samplePatient, { detail: encryptedField }));
94
+ (0, chai_1.expect)(entity.detail).to.be.equal(encryptedField);
95
+ yield api2.accessLogApi
96
+ .getAccessLogWithUser(user2, entity.id)
97
+ .then(() => {
98
+ throw new Error('Should not be able to get the entity');
99
+ })
100
+ .catch(() => {
101
+ /* expected */
102
+ });
103
+ yield api1.accessLogApi.shareWith(user2.healthcarePartyId, entity);
104
+ const retrieved = yield api2.accessLogApi.getAccessLogWithUser(user2, entity.id);
105
+ (0, chai_1.expect)(retrieved.detail).to.be.equal(encryptedField);
106
+ (0, chai_1.expect)((yield api2.accessLogApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
107
+ }));
108
+ it('newInstance should honor non-default values unless they are undefined', () => __awaiter(void 0, void 0, void 0, function* () {
109
+ const apis = yield initApi(env, test_utils_1.hcp1Username);
110
+ const user = yield apis.userApi.getCurrentUser();
111
+ const samplePatient = yield apis.patientApi.createPatientWithUser(user, yield apis.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' }));
112
+ const accessLogUndefinedId = yield apis.accessLogApi.newInstance(user, samplePatient, { id: undefined });
113
+ (0, chai_1.expect)(accessLogUndefinedId.id).to.not.be.undefined;
114
+ const customId = 'customId';
115
+ const accessLogCustomId = yield apis.accessLogApi.newInstance(user, samplePatient, { id: customId });
116
+ (0, chai_1.expect)(accessLogCustomId.id).to.equal(customId);
117
+ const accessLogUndefinedInit = yield apis.accessLogApi.newInstance(user, samplePatient, undefined);
118
+ (0, chai_1.expect)(accessLogUndefinedInit.id).to.not.be.undefined;
119
+ }));
120
+ });
121
+ //# sourceMappingURL=icc-accesslog-x-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icc-accesslog-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-accesslog-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAuH;AACvH,iCAA8B;AAC9B,+CAAsG;AACtG,wFAAyF;AACzF,2CAA+C;AAC/C,yDAAqD;AAErD,mCAAmC;AACnC,6DAAyD;AACzD,+BAAqC;AACrC,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AAEnE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,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,C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port { before } from 'mocha'\nimport { EncryptedFieldsConfig, IccAccesslogXApi, IccPatientXApi, IccUserXApi } from '../../icc-x-api'\nimport { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IccAccesslogApi } from '../../icc-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { AccessLog } from '../../icc-api/model/AccessLog'\nimport { assert, expect } from 'chai'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-x-accesslog-api 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 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('Test', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const userApi = new IccUserXApi(env.iCureUrl, {}, authProvider, null as any, fetch)\n const accessLogApi = new IccAccesslogApi(env.iCureUrl, {}, authProvider, fetch)\n\n const currentUser = await userApi.getCurrentUser()\n\n await accessLogApi.findByUserAfterDate(currentUser.id!)\n })\n\n it('Test findBy', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n cryptoApi: cryptoApiForHcp,\n dataOwnerApi: dateOwnerApiForHcp,\n } = await initApi(env!, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const accessLogXApi = new IccAccesslogXApi(\n env.iCureUrl,\n {},\n cryptoApiForHcp,\n dateOwnerApiForHcp,\n EncryptedFieldsConfig.Defaults.accessLog,\n authProvider,\n fetch\n )\n\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n\n const accessLog = new AccessLog({\n id: randomUUID(),\n _type: 'org.taktik.icure.entities.AccessLog',\n created: new Date().getTime(),\n modified: new Date().getTime(),\n date: +new Date(),\n responsible: hcpUser.healthcarePartyId!,\n author: hcpUser.id,\n codes: [],\n tags: [],\n user: hcpUser.id,\n patient: patient.id,\n accessType: 'USER_ACCESS',\n })\n\n const accessLogToCreate = await accessLogXApi.newInstance(hcpUser, patient, accessLog)\n const createdAccessLog = await accessLogXApi.createAccessLogWithUser(hcpUser, accessLogToCreate)\n\n const foundItems: AccessLog[] = await accessLogXApi.findBy(hcpUser.healthcarePartyId!, patient, false)\n const foundItemsUsingPost: AccessLog[] = await accessLogXApi.findBy(hcpUser.healthcarePartyId!, patient, true)\n\n assert(foundItems.length == 1, 'Found items should be 1')\n assert(foundItems[0].id == createdAccessLog.id, 'Found item should be the same as the created one')\n\n assert(foundItemsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundItemsUsingPost[0].id == createdAccessLog.id, 'Found item using post should be the same as the created one')\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const encryptedField = 'Something encrypted'\n const entity = await api1.accessLogApi.createAccessLogWithUser(\n user1,\n await api1.accessLogApi.newInstance(user1, samplePatient, { detail: encryptedField })\n )\n expect(entity.detail).to.be.equal(encryptedField)\n await api2.accessLogApi\n .getAccessLogWithUser(user2, entity.id)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.accessLogApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.accessLogApi.getAccessLogWithUser(user2, entity.id)\n expect(retrieved.detail).to.be.equal(encryptedField)\n expect((await api2.accessLogApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('newInstance should honor non-default values unless they are undefined', async () => {\n const apis = await initApi(env!, hcp1Username)\n const user = await apis.userApi.getCurrentUser()\n const samplePatient = await apis.patientApi.createPatientWithUser(\n user,\n await apis.patientApi.newInstance(user, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const accessLogUndefinedId = await apis.accessLogApi.newInstance(user, samplePatient, { id: undefined })\n expect(accessLogUndefinedId.id).to.not.be.undefined\n const customId = 'customId'\n const accessLogCustomId = await apis.accessLogApi.newInstance(user, samplePatient, { id: customId })\n expect(accessLogCustomId.id).to.equal(customId)\n const accessLogUndefinedInit = await apis.accessLogApi.newInstance(user, samplePatient, undefined)\n expect(accessLogUndefinedInit.id).to.not.be.undefined\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ require("isomorphic-fetch");
13
+ const test_utils_1 = require("../utils/test_utils");
14
+ const mocha_1 = require("mocha");
15
+ const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
16
+ const icc_api_1 = require("../../icc-api");
17
+ const node_compat_1 = require("../../node-compat");
18
+ const TestApi_1 = require("../utils/TestApi");
19
+ const types_1 = require("@icure/test-setup/types");
20
+ (0, test_utils_1.setLocalStorage)(fetch);
21
+ let env;
22
+ describe('icc-auth-api Tests', () => {
23
+ (0, mocha_1.before)(function () {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ this.timeout(600000);
26
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
27
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
28
+ });
29
+ });
30
+ it('Can login and then logout instating all the Apis', () => __awaiter(void 0, void 0, void 0, function* () {
31
+ // Given
32
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
33
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
34
+ const { authApi } = yield (0, TestApi_1.TestApi)(env.iCureUrl, username, password, node_compat_1.crypto);
35
+ yield authApi.logout();
36
+ }));
37
+ it('Can login and then logout instating only the AuthApi', () => __awaiter(void 0, void 0, void 0, function* () {
38
+ // Given
39
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
40
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
41
+ const authenticationProvider = new AuthenticationProvider_1.EnsembleAuthenticationProvider(new icc_api_1.IccAuthApi(env.iCureUrl, {}, new AuthenticationProvider_1.NoAuthenticationProvider(), fetch), username, password);
42
+ const authApi = new icc_api_1.IccAuthApi(env.iCureUrl, {}, authenticationProvider, fetch);
43
+ yield authApi.logout();
44
+ }));
45
+ });
46
+ //# sourceMappingURL=icc-auth-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icc-auth-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-auth-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAA8F;AAC9F,iCAA8B;AAC9B,wFAAsH;AACtH,2CAA0C;AAC1C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ED,MAAM,OAAO,GAAG,IAAI,oBAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAE/E,MAAM,OAAO,CAAC,MAAM,EAAE,CAAA;IACxB,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import 'isomorphic-fetch'\nimport { getEnvironmentInitializer, hcp1Username, setLocalStorage } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { EnsembleAuthenticationProvider, NoAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IccAuthApi } from '../../icc-api'\nimport { crypto } from '../../node-compat'\nimport { TestApi } from '../utils/TestApi'\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-auth-api Tests', () => {\n before(async function () {\n this.timeout(600000)\n const initializer = await getEnvironmentInitializer()\n env = await initializer.execute(getEnvVariables())\n })\n\n it('Can login and then logout instating all the Apis', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const { authApi } = await TestApi(env!.iCureUrl, username, password, crypto)\n\n await authApi.logout()\n })\n\n it('Can login and then logout instating only the AuthApi', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authenticationProvider = new EnsembleAuthenticationProvider(\n new IccAuthApi(env.iCureUrl, {}, new NoAuthenticationProvider(), fetch),\n username,\n password\n )\n\n const authApi = new IccAuthApi(env.iCureUrl, {}, authenticationProvider, fetch)\n\n await authApi.logout()\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ require("isomorphic-fetch");
13
+ const test_utils_1 = require("../utils/test_utils");
14
+ const mocha_1 = require("mocha");
15
+ const icc_x_api_1 = require("../../icc-x-api");
16
+ const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
17
+ const icc_api_1 = require("../../icc-api");
18
+ const Patient_1 = require("../../icc-api/model/Patient");
19
+ const crypto_1 = require("crypto");
20
+ const chai_1 = require("chai");
21
+ var initApi = test_utils_1.TestUtils.initApi;
22
+ const types_1 = require("@icure/test-setup/types");
23
+ (0, test_utils_1.setLocalStorage)(fetch);
24
+ let env;
25
+ describe('icc-calendar-item-x-api Tests', () => {
26
+ (0, mocha_1.before)(function () {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ this.timeout(600000);
29
+ const initializer = yield (0, test_utils_1.getEnvironmentInitializer)();
30
+ env = yield initializer.execute((0, types_1.getEnvVariables)());
31
+ });
32
+ });
33
+ function createPatient(patientApiForHcp, hcpUser) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ return patientApiForHcp.createPatientWithUser(hcpUser, yield patientApiForHcp.newInstance(hcpUser, new Patient_1.Patient({
36
+ id: (0, crypto_1.randomUUID)(),
37
+ firstName: 'John',
38
+ lastName: 'Snow',
39
+ note: 'Winter is coming',
40
+ })));
41
+ });
42
+ }
43
+ it('Test', () => __awaiter(void 0, void 0, void 0, function* () {
44
+ // Given
45
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
46
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
47
+ const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
48
+ const userApi = new icc_x_api_1.IccUserXApi(env.iCureUrl, {}, authProvider, null, fetch);
49
+ const calenderItemApi = new icc_api_1.IccCalendarItemApi(env.iCureUrl, {}, authProvider, fetch);
50
+ const currentUser = yield userApi.getCurrentUser();
51
+ }));
52
+ it('Test findBy', () => __awaiter(void 0, void 0, void 0, function* () {
53
+ // Given
54
+ const { userApi: userApiForHcp, dataOwnerApi: dataOwnerApiForHcp, patientApi: patientApiForHcp, cryptoApi: cryptoApiForHcp, dataOwnerApi: dateOwnerApiForHcp, } = yield initApi(env, test_utils_1.hcp1Username);
55
+ const hcpUser = yield userApiForHcp.getCurrentUser();
56
+ const username = env.dataOwnerDetails[test_utils_1.hcp1Username].user;
57
+ const password = env.dataOwnerDetails[test_utils_1.hcp1Username].password;
58
+ const authProvider = new AuthenticationProvider_1.BasicAuthenticationProvider(username, password);
59
+ const calendarItemXApi = new icc_x_api_1.IccCalendarItemXApi(env.iCureUrl, {}, cryptoApiForHcp, dateOwnerApiForHcp, undefined, authProvider, fetch);
60
+ const patient = (yield createPatient(patientApiForHcp, hcpUser));
61
+ const calendarItem = {
62
+ id: (0, crypto_1.randomUUID)(),
63
+ created: new Date().getTime(),
64
+ modified: new Date().getTime(),
65
+ startTime: 20230327131313,
66
+ endTime: 20230327141313,
67
+ responsible: hcpUser.healthcarePartyId,
68
+ author: hcpUser.id,
69
+ codes: [],
70
+ tags: [],
71
+ };
72
+ const calendarItemToCreate = yield calendarItemXApi.newInstancePatient(hcpUser, patient, calendarItem);
73
+ const createdCalendarItem = yield calendarItemXApi.createCalendarItemWithHcParty(hcpUser, calendarItemToCreate);
74
+ const foundItems = yield calendarItemXApi.findBy(hcpUser.healthcarePartyId, patient, false);
75
+ const foundItemsUsingPost = yield calendarItemXApi.findBy(hcpUser.healthcarePartyId, patient, true);
76
+ (0, chai_1.assert)(foundItems.length == 1, 'Found items should be 1');
77
+ (0, chai_1.assert)(foundItems[0].id == createdCalendarItem.id, 'Found item should be the same as created item');
78
+ (0, chai_1.assert)(foundItemsUsingPost.length == 1, 'Found items using post should be 1');
79
+ (0, chai_1.assert)(foundItemsUsingPost[0].id == createdCalendarItem.id, 'Found item using post should be the same as created item');
80
+ }));
81
+ it('Should be able to link a calendar item with an existing patient', () => __awaiter(void 0, void 0, void 0, function* () {
82
+ var _a, _b;
83
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
84
+ const user1 = yield api1.userApi.getCurrentUser();
85
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
86
+ const user2 = yield api2.userApi.getCurrentUser();
87
+ const patient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, {
88
+ firstName: 'Gigio',
89
+ lastName: 'Bagigio',
90
+ }, { additionalDelegates: { [user2.healthcarePartyId]: 'WRITE' } }));
91
+ const patientSecretIds = yield api2.patientApi.decryptNonConfidentialSecretIdsOf(patient);
92
+ (0, chai_1.expect)(patientSecretIds).to.have.length(1);
93
+ const itemTitle = 'An interesting title';
94
+ const calendarItem = yield api2.calendarItemApi.createCalendarItemWithHcParty(user2, yield api2.calendarItemApi.newInstance(user2, { title: itemTitle }, { additionalDelegates: { [user1.healthcarePartyId]: 'WRITE' } }));
95
+ (0, chai_1.expect)(calendarItem.title).to.equal(itemTitle);
96
+ (0, chai_1.expect)((yield api1.calendarItemApi.getCalendarItemWithUser(user1, calendarItem.id)).title).to.equal(itemTitle);
97
+ (0, chai_1.expect)(yield api1.calendarItemApi.decryptPatientIdOf(calendarItem)).to.have.length(0);
98
+ (0, chai_1.expect)((_a = calendarItem.secretForeignKeys) !== null && _a !== void 0 ? _a : []).to.have.length(0);
99
+ const linked = yield api1.calendarItemApi.linkToPatient(calendarItem, patient, [user2.healthcarePartyId]);
100
+ (0, chai_1.expect)(linked.title).to.equal(itemTitle);
101
+ (0, chai_1.expect)((_b = linked.secretForeignKeys) !== null && _b !== void 0 ? _b : []).to.have.length(1);
102
+ (0, chai_1.expect)(linked.secretForeignKeys[0]).to.equal(patientSecretIds[0]);
103
+ const decryptedPatientIdBy1 = yield api1.calendarItemApi.decryptPatientIdOf(linked);
104
+ (0, chai_1.expect)(decryptedPatientIdBy1).to.have.length(1);
105
+ (0, chai_1.expect)(decryptedPatientIdBy1[0]).to.equal(patient.id);
106
+ const retrievedBy2AfterLink = yield api2.calendarItemApi.getCalendarItemWithUser(user2, calendarItem.id);
107
+ (0, chai_1.expect)(retrievedBy2AfterLink.title).to.equal(itemTitle);
108
+ const decryptedPatientIdBy2 = yield api2.calendarItemApi.decryptPatientIdOf(retrievedBy2AfterLink);
109
+ (0, chai_1.expect)(decryptedPatientIdBy2).to.have.length(1);
110
+ (0, chai_1.expect)(decryptedPatientIdBy2[0]).to.equal(patient.id);
111
+ }));
112
+ it('Share with should work as expected', () => __awaiter(void 0, void 0, void 0, function* () {
113
+ const api1 = yield initApi(env, test_utils_1.hcp1Username);
114
+ const user1 = yield api1.userApi.getCurrentUser();
115
+ const api2 = yield initApi(env, test_utils_1.hcp2Username);
116
+ const user2 = yield api2.userApi.getCurrentUser();
117
+ const samplePatient = yield api1.patientApi.createPatientWithUser(user1, yield api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' }));
118
+ const encryptedField = 'Something encrypted';
119
+ const entity = yield api1.calendarItemApi.createCalendarItemWithHcParty(user1, yield api1.calendarItemApi.newInstancePatient(user1, samplePatient, { details: encryptedField }));
120
+ (0, chai_1.expect)(entity.details).to.be.equal(encryptedField);
121
+ yield api2.calendarItemApi
122
+ .getCalendarItemWithUser(user2, entity.id)
123
+ .then(() => {
124
+ throw new Error('Should not be able to get the entity');
125
+ })
126
+ .catch(() => {
127
+ /* expected */
128
+ });
129
+ yield api1.calendarItemApi.shareWith(user2.healthcarePartyId, entity);
130
+ const retrieved = yield api2.calendarItemApi.getCalendarItemWithUser(user2, entity.id);
131
+ (0, chai_1.expect)(retrieved.details).to.be.equal(encryptedField);
132
+ (0, chai_1.expect)((yield api2.calendarItemApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id);
133
+ }));
134
+ it('newInstance should honor non-default values unless they are undefined', () => __awaiter(void 0, void 0, void 0, function* () {
135
+ const apis = yield initApi(env, test_utils_1.hcp1Username);
136
+ const user = yield apis.userApi.getCurrentUser();
137
+ const calendarItemUndefinedId = yield apis.calendarItemApi.newInstance(user, { id: undefined });
138
+ (0, chai_1.expect)(calendarItemUndefinedId.id).to.not.be.undefined;
139
+ const customId = 'customId';
140
+ const calendarItemCustomId = yield apis.calendarItemApi.newInstance(user, { id: customId });
141
+ (0, chai_1.expect)(calendarItemCustomId.id).to.equal(customId);
142
+ const calendarItemUndefinedInit = yield apis.calendarItemApi.newInstance(user, undefined);
143
+ (0, chai_1.expect)(calendarItemUndefinedInit.id).to.not.be.undefined;
144
+ }));
145
+ });
146
+ //# sourceMappingURL=icc-calendar-item-x-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icc-calendar-item-x-api.js","sourceRoot":"","sources":["../../../test/icc-x-api/icc-calendar-item-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4BAAyB;AACzB,oDAAuH;AACvH,iCAA8B;AAC9B,+CAAkF;AAClF,wFAAyF;AACzF,2CAAkD;AAClD,yDAAqD;AAErD,mCAAmC;AAGnC,+BAAqC;AACrC,IAAO,OAAO,GAAG,sBAAS,CAAC,OAAO,CAAA;AAClC,mDAAmE;AAEnE,IAAA,4BAAe,EAAC,KAAK,CAAC,CAAA;AACtB,IAAI,GAAa,CAAA;AAEjB,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,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,S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import { getEnvironmentInitializer, hcp1Username, hcp2Username, setLocalStorage, TestUtils } from '../utils/test_utils'\nimport { before } from 'mocha'\nimport { IccCalendarItemXApi, IccPatientXApi, IccUserXApi } from '../../icc-x-api'\nimport { BasicAuthenticationProvider } from '../../icc-x-api/auth/AuthenticationProvider'\nimport { IccCalendarItemApi } from '../../icc-api'\nimport { Patient } from '../../icc-api/model/Patient'\nimport { User } from '../../icc-api/model/User'\nimport { randomUUID } from 'crypto'\nimport { crypto } from '../../node-compat'\nimport { CalendarItem } from '../../icc-api/model/CalendarItem'\nimport { assert, expect } from 'chai'\nimport initApi = TestUtils.initApi\nimport { getEnvVariables, TestVars } from '@icure/test-setup/types'\n\nsetLocalStorage(fetch)\nlet env: TestVars\n\ndescribe('icc-calendar-item-x-api 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 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('Test', async () => {\n // Given\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n\n const userApi = new IccUserXApi(env.iCureUrl, {}, authProvider, null as any, fetch)\n const calenderItemApi = new IccCalendarItemApi(env.iCureUrl, {}, authProvider, fetch)\n\n const currentUser = await userApi.getCurrentUser()\n })\n\n it('Test findBy', async () => {\n // Given\n const {\n userApi: userApiForHcp,\n dataOwnerApi: dataOwnerApiForHcp,\n patientApi: patientApiForHcp,\n cryptoApi: cryptoApiForHcp,\n dataOwnerApi: dateOwnerApiForHcp,\n } = await initApi(env!, hcp1Username)\n const hcpUser = await userApiForHcp.getCurrentUser()\n\n const username = env.dataOwnerDetails[hcp1Username].user\n const password = env.dataOwnerDetails[hcp1Username].password\n\n const authProvider = new BasicAuthenticationProvider(username, password)\n const calendarItemXApi = new IccCalendarItemXApi(env.iCureUrl, {}, cryptoApiForHcp, dateOwnerApiForHcp, undefined, authProvider, fetch)\n const patient = (await createPatient(patientApiForHcp, hcpUser)) as Patient\n\n const calendarItem: CalendarItem = {\n id: randomUUID(),\n created: new Date().getTime(),\n modified: new Date().getTime(),\n startTime: 20230327131313,\n endTime: 20230327141313,\n responsible: hcpUser.healthcarePartyId!,\n author: hcpUser.id,\n codes: [],\n tags: [],\n }\n const calendarItemToCreate: CalendarItem = await calendarItemXApi.newInstancePatient(hcpUser, patient, calendarItem)\n const createdCalendarItem = await calendarItemXApi.createCalendarItemWithHcParty(hcpUser, calendarItemToCreate)\n\n const foundItems = await calendarItemXApi.findBy(hcpUser.healthcarePartyId!, patient, false)\n const foundItemsUsingPost = await calendarItemXApi.findBy(hcpUser.healthcarePartyId!, patient, true)\n\n assert(foundItems.length == 1, 'Found items should be 1')\n assert(foundItems[0].id == createdCalendarItem.id, 'Found item should be the same as created item')\n\n assert(foundItemsUsingPost.length == 1, 'Found items using post should be 1')\n assert(foundItemsUsingPost[0].id == createdCalendarItem.id, 'Found item using post should be the same as created item')\n })\n\n it('Should be able to link a calendar item with an existing patient', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const patient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(\n user1,\n {\n firstName: 'Gigio',\n lastName: 'Bagigio',\n },\n { additionalDelegates: { [user2.healthcarePartyId!]: 'WRITE' } }\n )\n )\n const patientSecretIds = await api2.patientApi.decryptNonConfidentialSecretIdsOf(patient)\n expect(patientSecretIds).to.have.length(1)\n const itemTitle = 'An interesting title'\n const calendarItem = await api2.calendarItemApi.createCalendarItemWithHcParty(\n user2,\n await api2.calendarItemApi.newInstance(user2, { title: itemTitle }, { additionalDelegates: { [user1.healthcarePartyId!]: 'WRITE' } })\n )\n expect(calendarItem.title).to.equal(itemTitle)\n expect((await api1.calendarItemApi.getCalendarItemWithUser(user1, calendarItem.id)).title).to.equal(itemTitle)\n expect(await api1.calendarItemApi.decryptPatientIdOf(calendarItem)).to.have.length(0)\n expect(calendarItem.secretForeignKeys ?? []).to.have.length(0)\n const linked = await api1.calendarItemApi.linkToPatient(calendarItem, patient, [user2.healthcarePartyId!])\n expect(linked.title).to.equal(itemTitle)\n expect(linked.secretForeignKeys ?? []).to.have.length(1)\n expect(linked.secretForeignKeys![0]).to.equal(patientSecretIds[0])\n const decryptedPatientIdBy1 = await api1.calendarItemApi.decryptPatientIdOf(linked)\n expect(decryptedPatientIdBy1).to.have.length(1)\n expect(decryptedPatientIdBy1[0]).to.equal(patient.id)\n const retrievedBy2AfterLink = await api2.calendarItemApi.getCalendarItemWithUser(user2, calendarItem.id)\n expect(retrievedBy2AfterLink.title).to.equal(itemTitle)\n const decryptedPatientIdBy2 = await api2.calendarItemApi.decryptPatientIdOf(retrievedBy2AfterLink)\n expect(decryptedPatientIdBy2).to.have.length(1)\n expect(decryptedPatientIdBy2[0]).to.equal(patient.id)\n })\n\n it('Share with should work as expected', async () => {\n const api1 = await initApi(env!, hcp1Username)\n const user1 = await api1.userApi.getCurrentUser()\n const api2 = await initApi(env!, hcp2Username)\n const user2 = await api2.userApi.getCurrentUser()\n const samplePatient = await api1.patientApi.createPatientWithUser(\n user1,\n await api1.patientApi.newInstance(user1, { firstName: 'Gigio', lastName: 'Bagigio' })\n )\n const encryptedField = 'Something encrypted'\n const entity = await api1.calendarItemApi.createCalendarItemWithHcParty(\n user1,\n await api1.calendarItemApi.newInstancePatient(user1, samplePatient, { details: encryptedField })\n )\n expect(entity.details).to.be.equal(encryptedField)\n await api2.calendarItemApi\n .getCalendarItemWithUser(user2, entity.id)\n .then(() => {\n throw new Error('Should not be able to get the entity')\n })\n .catch(() => {\n /* expected */\n })\n await api1.calendarItemApi.shareWith(user2.healthcarePartyId!, entity)\n const retrieved = await api2.calendarItemApi.getCalendarItemWithUser(user2, entity.id)\n expect(retrieved.details).to.be.equal(encryptedField)\n expect((await api2.calendarItemApi.decryptPatientIdOf(retrieved))[0]).to.equal(samplePatient.id)\n })\n\n it('newInstance should honor non-default values unless they are undefined', async () => {\n const apis = await initApi(env!, hcp1Username)\n const user = await apis.userApi.getCurrentUser()\n const calendarItemUndefinedId = await apis.calendarItemApi.newInstance(user, { id: undefined })\n expect(calendarItemUndefinedId.id).to.not.be.undefined\n const customId = 'customId'\n const calendarItemCustomId = await apis.calendarItemApi.newInstance(user, { id: customId })\n expect(calendarItemCustomId.id).to.equal(customId)\n const calendarItemUndefinedInit = await apis.calendarItemApi.newInstance(user, undefined as any)\n expect(calendarItemUndefinedInit.id).to.not.be.undefined\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import 'isomorphic-fetch';