@medplum/core 2.0.22 → 2.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +348 -214
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +66 -13
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/fhirlexer/parse.mjs.map +1 -1
- package/dist/esm/fhirlexer/tokenize.mjs +2 -2
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
- package/dist/esm/fhirpath/atoms.mjs +63 -56
- package/dist/esm/fhirpath/atoms.mjs.map +1 -1
- package/dist/esm/fhirpath/functions.mjs +196 -128
- package/dist/esm/fhirpath/functions.mjs.map +1 -1
- package/dist/esm/fhirpath/parse.mjs +4 -2
- package/dist/esm/fhirpath/parse.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/outcomes.mjs +14 -11
- package/dist/esm/outcomes.mjs.map +1 -1
- package/dist/esm/search/details.mjs +4 -4
- package/dist/esm/search/details.mjs.map +1 -1
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/client.d.ts +54 -5
- package/dist/types/fhirlexer/parse.d.ts +7 -3
- package/dist/types/fhirpath/atoms.d.ts +21 -21
- package/dist/types/fhirpath/functions.d.ts +2 -2
- package/dist/types/fhirpath/parse.d.ts +2 -1
- package/dist/types/outcomes.d.ts +7 -1
- package/dist/types/utils.d.ts +1 -8
- package/package.json +1 -1
package/dist/esm/client.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { LRUCache } from './cache.mjs';
|
|
|
3
3
|
import { getRandomString, encryptSHA256 } from './crypto.mjs';
|
|
4
4
|
import { EventTarget } from './eventtarget.mjs';
|
|
5
5
|
import { parseJWTPayload } from './jwt.mjs';
|
|
6
|
-
import { OperationOutcomeError, notFound, normalizeOperationOutcome, isOk } from './outcomes.mjs';
|
|
6
|
+
import { OperationOutcomeError, notFound, normalizeOperationOutcome, isOk, badRequest } from './outcomes.mjs';
|
|
7
7
|
import { ReadablePromise } from './readablepromise.mjs';
|
|
8
8
|
import { ClientStorage } from './storage.mjs';
|
|
9
9
|
import { globalSchema, indexStructureDefinition, indexSearchParameter } from './types.mjs';
|
|
@@ -11,7 +11,7 @@ import { createReference, arrayBufferToBase64 } from './utils.mjs';
|
|
|
11
11
|
|
|
12
12
|
// PKCE auth based on:
|
|
13
13
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
14
|
-
const MEDPLUM_VERSION = "2.0.
|
|
14
|
+
const MEDPLUM_VERSION = "2.0.23-b244eeae" ;
|
|
15
15
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
16
16
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
17
17
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -150,6 +150,16 @@ class MedplumClient extends EventTarget {
|
|
|
150
150
|
getBaseUrl() {
|
|
151
151
|
return this.baseUrl;
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns the current authorize URL.
|
|
155
|
+
* By default, this is set to `https://api.medplum.com/oauth2/authorize`.
|
|
156
|
+
* This can be overridden by setting the `authorizeUrl` option when creating the client.
|
|
157
|
+
* @category HTTP
|
|
158
|
+
* @returns The current authorize URL.
|
|
159
|
+
*/
|
|
160
|
+
getAuthorizeUrl() {
|
|
161
|
+
return this.authorizeUrl;
|
|
162
|
+
}
|
|
153
163
|
/**
|
|
154
164
|
* Clears all auth state including local storage and session storage.
|
|
155
165
|
* @category Authentication
|
|
@@ -171,8 +181,7 @@ class MedplumClient extends EventTarget {
|
|
|
171
181
|
this.requestCache?.clear();
|
|
172
182
|
this.accessToken = undefined;
|
|
173
183
|
this.refreshToken = undefined;
|
|
174
|
-
this.
|
|
175
|
-
this.config = undefined;
|
|
184
|
+
this.sessionDetails = undefined;
|
|
176
185
|
this.dispatchEvent({ type: 'change' });
|
|
177
186
|
}
|
|
178
187
|
/**
|
|
@@ -1451,8 +1460,7 @@ class MedplumClient extends EventTarget {
|
|
|
1451
1460
|
setAccessToken(accessToken) {
|
|
1452
1461
|
this.accessToken = accessToken;
|
|
1453
1462
|
this.refreshToken = undefined;
|
|
1454
|
-
this.
|
|
1455
|
-
this.config = undefined;
|
|
1463
|
+
this.sessionDetails = undefined;
|
|
1456
1464
|
}
|
|
1457
1465
|
/**
|
|
1458
1466
|
* Returns the list of available logins.
|
|
@@ -1475,10 +1483,9 @@ class MedplumClient extends EventTarget {
|
|
|
1475
1483
|
this.get('auth/me')
|
|
1476
1484
|
.then((result) => {
|
|
1477
1485
|
this.profilePromise = undefined;
|
|
1478
|
-
this.
|
|
1479
|
-
this.config = result.config;
|
|
1486
|
+
this.sessionDetails = result;
|
|
1480
1487
|
this.dispatchEvent({ type: 'change' });
|
|
1481
|
-
resolve(
|
|
1488
|
+
resolve(result.profile);
|
|
1482
1489
|
})
|
|
1483
1490
|
.catch(reject);
|
|
1484
1491
|
});
|
|
@@ -1492,6 +1499,38 @@ class MedplumClient extends EventTarget {
|
|
|
1492
1499
|
isLoading() {
|
|
1493
1500
|
return !!this.profilePromise;
|
|
1494
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Returns true if the current user is authenticated as a super admin.
|
|
1504
|
+
* @returns True if the current user is authenticated as a super admin.
|
|
1505
|
+
* @category Authentication
|
|
1506
|
+
*/
|
|
1507
|
+
isSuperAdmin() {
|
|
1508
|
+
return !!this.sessionDetails?.project?.superAdmin;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Returns true if the current user is authenticated as a project admin.
|
|
1512
|
+
* @returns True if the current user is authenticated as a project admin.
|
|
1513
|
+
* @category Authentication
|
|
1514
|
+
*/
|
|
1515
|
+
isProjectAdmin() {
|
|
1516
|
+
return !!this.sessionDetails?.membership?.admin;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Returns the current project if available.
|
|
1520
|
+
* @returns The current project if available.
|
|
1521
|
+
* @category User Profile
|
|
1522
|
+
*/
|
|
1523
|
+
getProject() {
|
|
1524
|
+
return this.sessionDetails?.project;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Returns the current project membership if available.
|
|
1528
|
+
* @returns The current project membership if available.
|
|
1529
|
+
* @category User Profile
|
|
1530
|
+
*/
|
|
1531
|
+
getProjectMembership() {
|
|
1532
|
+
return this.sessionDetails?.membership;
|
|
1533
|
+
}
|
|
1495
1534
|
/**
|
|
1496
1535
|
* Returns the current user profile resource if available.
|
|
1497
1536
|
* This method does not wait for loading promises.
|
|
@@ -1499,7 +1538,7 @@ class MedplumClient extends EventTarget {
|
|
|
1499
1538
|
* @category User Profile
|
|
1500
1539
|
*/
|
|
1501
1540
|
getProfile() {
|
|
1502
|
-
return this.profile;
|
|
1541
|
+
return this.sessionDetails?.profile;
|
|
1503
1542
|
}
|
|
1504
1543
|
/**
|
|
1505
1544
|
* Returns the current user profile resource if available.
|
|
@@ -1519,7 +1558,15 @@ class MedplumClient extends EventTarget {
|
|
|
1519
1558
|
* @category User Profile
|
|
1520
1559
|
*/
|
|
1521
1560
|
getUserConfiguration() {
|
|
1522
|
-
return this.config;
|
|
1561
|
+
return this.sessionDetails?.config;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Returns the current user access policy if available.
|
|
1565
|
+
* @returns The current user access policy if available.
|
|
1566
|
+
* @category User Profile
|
|
1567
|
+
*/
|
|
1568
|
+
getAccessPolicy() {
|
|
1569
|
+
return this.sessionDetails?.accessPolicy;
|
|
1523
1570
|
}
|
|
1524
1571
|
/**
|
|
1525
1572
|
* Downloads the URL as a blob.
|
|
@@ -1963,7 +2010,7 @@ class MedplumClient extends EventTarget {
|
|
|
1963
2010
|
* Invite a user to a project.
|
|
1964
2011
|
* @param projectId The project ID.
|
|
1965
2012
|
* @param body The InviteBody.
|
|
1966
|
-
* @returns Promise that returns
|
|
2013
|
+
* @returns Promise that returns a project membership or an operation outcome.
|
|
1967
2014
|
*/
|
|
1968
2015
|
async invite(projectId, body) {
|
|
1969
2016
|
return this.post('admin/projects/' + projectId + '/invite', body);
|
|
@@ -1988,7 +2035,13 @@ class MedplumClient extends EventTarget {
|
|
|
1988
2035
|
const response = await this.fetch(this.tokenUrl, options);
|
|
1989
2036
|
if (!response.ok) {
|
|
1990
2037
|
this.clearActiveLogin();
|
|
1991
|
-
|
|
2038
|
+
try {
|
|
2039
|
+
const error = await response.json();
|
|
2040
|
+
throw new OperationOutcomeError(badRequest(error.error_description));
|
|
2041
|
+
}
|
|
2042
|
+
catch (err) {
|
|
2043
|
+
throw new OperationOutcomeError(badRequest('Failed to fetch tokens'), err);
|
|
2044
|
+
}
|
|
1992
2045
|
}
|
|
1993
2046
|
const tokens = await response.json();
|
|
1994
2047
|
await this.verifyTokens(tokens);
|