@medplum/core 2.0.4 → 2.0.5
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 +35 -21
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +10 -17
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/outcomes.mjs +17 -2
- package/dist/esm/outcomes.mjs.map +1 -1
- package/dist/esm/search/match.mjs +9 -4
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/{esm → types}/outcomes.d.ts +7 -1
- package/package.json +4 -4
- package/tsconfig.build.json +9 -0
- package/dist/cjs/outcomes.d.ts +0 -31
- package/dist/esm/cache.d.ts +0 -34
- package/dist/esm/client.d.ts +0 -1218
- package/dist/esm/crypto.d.ts +0 -9
- package/dist/esm/eventtarget.d.ts +0 -13
- package/dist/esm/fhirlexer/index.d.ts +0 -2
- package/dist/esm/fhirlexer/parse.d.ts +0 -47
- package/dist/esm/fhirlexer/tokenize.d.ts +0 -14
- package/dist/esm/fhirmapper/parse.d.ts +0 -7
- package/dist/esm/fhirmapper/tokenize.d.ts +0 -2
- package/dist/esm/fhirpath/atoms.d.ts +0 -120
- package/dist/esm/fhirpath/date.d.ts +0 -1
- package/dist/esm/fhirpath/functions.d.ts +0 -6
- package/dist/esm/fhirpath/index.d.ts +0 -4
- package/dist/esm/fhirpath/parse.d.ts +0 -64
- package/dist/esm/fhirpath/tokenize.d.ts +0 -4
- package/dist/esm/fhirpath/utils.d.ts +0 -95
- package/dist/esm/format.d.ts +0 -118
- package/dist/esm/hl7.d.ts +0 -136
- package/dist/esm/index.d.ts +0 -14
- package/dist/esm/jwt.d.ts +0 -5
- package/dist/esm/readablepromise.d.ts +0 -48
- package/dist/esm/search/details.d.ts +0 -33
- package/dist/esm/search/match.d.ts +0 -9
- package/dist/esm/search/parse.d.ts +0 -17
- package/dist/esm/search/search.d.ts +0 -66
- package/dist/esm/storage.d.ts +0 -47
- package/dist/esm/types.d.ts +0 -200
- package/dist/esm/utils.d.ts +0 -259
- /package/dist/{cjs → types}/cache.d.ts +0 -0
- /package/dist/{cjs → types}/client.d.ts +0 -0
- /package/dist/{cjs → types}/crypto.d.ts +0 -0
- /package/dist/{cjs → types}/eventtarget.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/index.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirlexer/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirmapper/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirmapper/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/atoms.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/date.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/functions.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/index.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/parse.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/tokenize.d.ts +0 -0
- /package/dist/{cjs → types}/fhirpath/utils.d.ts +0 -0
- /package/dist/{cjs → types}/format.d.ts +0 -0
- /package/dist/{cjs → types}/hl7.d.ts +0 -0
- /package/dist/{cjs → types}/index.d.ts +0 -0
- /package/dist/{cjs → types}/jwt.d.ts +0 -0
- /package/dist/{cjs → types}/readablepromise.d.ts +0 -0
- /package/dist/{cjs → types}/search/details.d.ts +0 -0
- /package/dist/{cjs → types}/search/match.d.ts +0 -0
- /package/dist/{cjs → types}/search/parse.d.ts +0 -0
- /package/dist/{cjs → types}/search/search.d.ts +0 -0
- /package/dist/{cjs → types}/storage.d.ts +0 -0
- /package/dist/{cjs → types}/types.d.ts +0 -0
- /package/dist/{cjs → types}/utils.d.ts +0 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -1353,11 +1353,26 @@
|
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
1355
|
class OperationOutcomeError extends Error {
|
|
1356
|
-
constructor(outcome) {
|
|
1356
|
+
constructor(outcome, cause) {
|
|
1357
1357
|
super(outcome?.issue?.[0].details?.text);
|
|
1358
1358
|
this.outcome = outcome;
|
|
1359
|
+
this.cause = cause;
|
|
1359
1360
|
}
|
|
1360
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Normalizes an error object into an OperationOutcome.
|
|
1364
|
+
* @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.
|
|
1365
|
+
* @returns The normalized OperationOutcome.
|
|
1366
|
+
*/
|
|
1367
|
+
function normalizeOperationOutcome(error) {
|
|
1368
|
+
if (error instanceof OperationOutcomeError) {
|
|
1369
|
+
return error.outcome;
|
|
1370
|
+
}
|
|
1371
|
+
if (isOperationOutcome(error)) {
|
|
1372
|
+
return error;
|
|
1373
|
+
}
|
|
1374
|
+
return badRequest(normalizeErrorString(error));
|
|
1375
|
+
}
|
|
1361
1376
|
/**
|
|
1362
1377
|
* Normalizes an error object into a displayable error string.
|
|
1363
1378
|
* @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.
|
|
@@ -6297,7 +6312,7 @@
|
|
|
6297
6312
|
// PKCE auth based on:
|
|
6298
6313
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
6299
6314
|
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_fhirBaseUrl, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_autoBatchTime, _MedplumClient_autoBatchQueue, _MedplumClient_clientId, _MedplumClient_clientSecret, _MedplumClient_autoBatchTimerId, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_cacheResource, _MedplumClient_deleteCacheEntry, _MedplumClient_request, _MedplumClient_fetchWithRetry, _MedplumClient_executeAutoBatch, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
6300
|
-
const MEDPLUM_VERSION = "2.0.
|
|
6315
|
+
const MEDPLUM_VERSION = "2.0.5-886af1d8";
|
|
6301
6316
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
6302
6317
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
6303
6318
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -7812,7 +7827,7 @@
|
|
|
7812
7827
|
throw err;
|
|
7813
7828
|
}
|
|
7814
7829
|
if (response.status >= 400) {
|
|
7815
|
-
throw obj;
|
|
7830
|
+
throw new OperationOutcomeError(normalizeOperationOutcome(obj));
|
|
7816
7831
|
}
|
|
7817
7832
|
return obj;
|
|
7818
7833
|
}, _MedplumClient_fetchWithRetry = async function _MedplumClient_fetchWithRetry(url, options) {
|
|
@@ -7863,7 +7878,7 @@
|
|
|
7863
7878
|
const entry = entries[i];
|
|
7864
7879
|
const responseEntry = response.entry?.[i];
|
|
7865
7880
|
if (responseEntry?.response?.outcome && !isOk(responseEntry.response.outcome)) {
|
|
7866
|
-
entry.reject(responseEntry.response.outcome);
|
|
7881
|
+
entry.reject(new OperationOutcomeError(responseEntry.response.outcome));
|
|
7867
7882
|
}
|
|
7868
7883
|
else {
|
|
7869
7884
|
entry.resolve(responseEntry?.resource);
|
|
@@ -8007,14 +8022,6 @@
|
|
|
8007
8022
|
// Silently ignore if this environment does not support storage events
|
|
8008
8023
|
}
|
|
8009
8024
|
};
|
|
8010
|
-
/**
|
|
8011
|
-
* Returns the current window if available.
|
|
8012
|
-
* All access to the current window should use this to support SSR such as Next.js.
|
|
8013
|
-
* @returns The current window or undefined if not available.
|
|
8014
|
-
*/
|
|
8015
|
-
function getWindow() {
|
|
8016
|
-
return typeof window === 'undefined' ? undefined : window;
|
|
8017
|
-
}
|
|
8018
8025
|
/**
|
|
8019
8026
|
* Returns the default fetch method.
|
|
8020
8027
|
* The default fetch is currently only available in browser environments.
|
|
@@ -8022,19 +8029,20 @@
|
|
|
8022
8029
|
* @returns The default fetch function for the current environment.
|
|
8023
8030
|
*/
|
|
8024
8031
|
function getDefaultFetch() {
|
|
8025
|
-
|
|
8026
|
-
if (!window) {
|
|
8032
|
+
if (!globalThis.fetch) {
|
|
8027
8033
|
throw new Error('Fetch not available in this environment');
|
|
8028
8034
|
}
|
|
8029
|
-
return
|
|
8035
|
+
return globalThis.fetch.bind(globalThis);
|
|
8030
8036
|
}
|
|
8031
8037
|
/**
|
|
8032
8038
|
* Returns the base URL for the current page.
|
|
8033
8039
|
* @category HTTP
|
|
8034
8040
|
*/
|
|
8035
8041
|
function getWindowOrigin() {
|
|
8036
|
-
|
|
8037
|
-
|
|
8042
|
+
if (typeof window === 'undefined') {
|
|
8043
|
+
return '';
|
|
8044
|
+
}
|
|
8045
|
+
return window.location.protocol + '//' + window.location.host + '/';
|
|
8038
8046
|
}
|
|
8039
8047
|
function ensureTrailingSlash(url) {
|
|
8040
8048
|
if (!url) {
|
|
@@ -11386,7 +11394,7 @@
|
|
|
11386
11394
|
return matchesBooleanFilter(resource, filter, searchParam);
|
|
11387
11395
|
}
|
|
11388
11396
|
else {
|
|
11389
|
-
return matchesStringFilter(resource, filter, searchParam);
|
|
11397
|
+
return matchesStringFilter(resource, filter, searchParam, true);
|
|
11390
11398
|
}
|
|
11391
11399
|
}
|
|
11392
11400
|
function matchesBooleanFilter(resource, filter, searchParam) {
|
|
@@ -11395,13 +11403,13 @@
|
|
|
11395
11403
|
const result = values.includes(expected);
|
|
11396
11404
|
return isNegated(filter.operator) ? !result : result;
|
|
11397
11405
|
}
|
|
11398
|
-
function matchesStringFilter(resource, filter, searchParam) {
|
|
11406
|
+
function matchesStringFilter(resource, filter, searchParam, asToken) {
|
|
11399
11407
|
const resourceValues = evalFhirPath(searchParam.expression, resource);
|
|
11400
11408
|
const filterValues = filter.value.split(',');
|
|
11401
11409
|
const negated = isNegated(filter.operator);
|
|
11402
11410
|
for (const resourceValue of resourceValues) {
|
|
11403
11411
|
for (const filterValue of filterValues) {
|
|
11404
|
-
const match = matchesStringValue(resourceValue, filter.operator, filterValue);
|
|
11412
|
+
const match = matchesStringValue(resourceValue, filter.operator, filterValue, asToken);
|
|
11405
11413
|
if (match) {
|
|
11406
11414
|
return !negated;
|
|
11407
11415
|
}
|
|
@@ -11411,7 +11419,12 @@
|
|
|
11411
11419
|
// If "equals" and no matches, then return false
|
|
11412
11420
|
return negated;
|
|
11413
11421
|
}
|
|
11414
|
-
function matchesStringValue(resourceValue, operator, filterValue) {
|
|
11422
|
+
function matchesStringValue(resourceValue, operator, filterValue, asToken) {
|
|
11423
|
+
if (asToken && filterValue.includes('|')) {
|
|
11424
|
+
const [system, code] = filterValue.split('|');
|
|
11425
|
+
return (matchesStringValue(resourceValue, operator, system, false) &&
|
|
11426
|
+
(!code || matchesStringValue(resourceValue, operator, code, false)));
|
|
11427
|
+
}
|
|
11415
11428
|
let str = '';
|
|
11416
11429
|
if (resourceValue) {
|
|
11417
11430
|
if (typeof resourceValue === 'string') {
|
|
@@ -11792,6 +11805,7 @@
|
|
|
11792
11805
|
exports.matchesRange = matchesRange;
|
|
11793
11806
|
exports.matchesSearchRequest = matchesSearchRequest;
|
|
11794
11807
|
exports.normalizeErrorString = normalizeErrorString;
|
|
11808
|
+
exports.normalizeOperationOutcome = normalizeOperationOutcome;
|
|
11795
11809
|
exports.notFound = notFound;
|
|
11796
11810
|
exports.notModified = notModified;
|
|
11797
11811
|
exports.parseFhirPath = parseFhirPath;
|