@medplum/core 2.0.4 → 2.0.6
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 +905 -46
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +16 -22
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/fhirlexer/tokenize.mjs +13 -4
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
- package/dist/esm/fhirmapper/parse.mjs +317 -0
- package/dist/esm/fhirmapper/parse.mjs.map +1 -0
- package/dist/esm/fhirmapper/tokenize.mjs +15 -0
- package/dist/esm/fhirmapper/tokenize.mjs.map +1 -0
- package/dist/esm/fhirpath/atoms.mjs +2 -2
- package/dist/esm/fhirpath/atoms.mjs.map +1 -1
- package/dist/esm/fhirpath/functions.mjs +2 -2
- package/dist/esm/fhirpath/functions.mjs.map +1 -1
- package/dist/esm/fhirpath/utils.mjs +4 -4
- package/dist/esm/fhirpath/utils.mjs.map +1 -1
- package/dist/esm/filter/parse.mjs +51 -0
- package/dist/esm/filter/parse.mjs.map +1 -0
- package/dist/esm/filter/tokenize.mjs +18 -0
- package/dist/esm/filter/tokenize.mjs.map +1 -0
- package/dist/esm/filter/types.mjs +34 -0
- package/dist/esm/filter/types.mjs.map +1 -0
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +8 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -1
- package/dist/esm/outcomes.mjs +31 -2
- package/dist/esm/outcomes.mjs.map +1 -1
- package/dist/esm/schema.mjs +397 -0
- package/dist/esm/schema.mjs.map +1 -0
- package/dist/esm/search/match.mjs +9 -4
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/esm/types.mjs +34 -8
- package/dist/esm/types.mjs.map +1 -1
- package/dist/{esm → types}/client.d.ts +20 -8
- package/dist/{cjs → types}/fhirlexer/tokenize.d.ts +5 -1
- package/dist/types/fhirmapper/index.d.ts +1 -0
- package/dist/types/filter/index.d.ts +2 -0
- package/dist/types/filter/parse.d.ts +7 -0
- package/dist/types/filter/types.d.ts +31 -0
- package/dist/{esm → types}/index.d.ts +4 -0
- package/dist/{esm → types}/outcomes.d.ts +8 -1
- package/dist/types/schema.d.ts +120 -0
- package/dist/{esm → types}/types.d.ts +19 -5
- package/package.json +4 -4
- package/tsconfig.build.json +9 -0
- package/dist/cjs/client.d.ts +0 -1218
- package/dist/cjs/index.d.ts +0 -14
- package/dist/cjs/outcomes.d.ts +0 -31
- package/dist/cjs/types.d.ts +0 -200
- package/dist/esm/cache.d.ts +0 -34
- 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/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/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/utils.d.ts +0 -259
- /package/dist/{cjs → types}/cache.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}/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/{esm/fhirmapper → types/filter}/tokenize.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}/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}/utils.d.ts +0 -0
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 { isOk } from './outcomes.mjs';
|
|
6
|
+
import { OperationOutcomeError, normalizeOperationOutcome, isOk } 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';
|
|
@@ -12,7 +12,7 @@ import { createReference, arrayBufferToBase64 } from './utils.mjs';
|
|
|
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
14
|
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;
|
|
15
|
-
const MEDPLUM_VERSION = "2.0.
|
|
15
|
+
const MEDPLUM_VERSION = "2.0.6-c4b403f5";
|
|
16
16
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
17
17
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
18
18
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -469,13 +469,14 @@ class MedplumClient extends EventTarget {
|
|
|
469
469
|
* Builds a FHIR search URL from a search query or structured query object.
|
|
470
470
|
* @category HTTP
|
|
471
471
|
* @category Search
|
|
472
|
-
* @param
|
|
472
|
+
* @param resourceType The FHIR resource type.
|
|
473
|
+
* @param query The FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
473
474
|
* @returns The well-formed FHIR URL.
|
|
474
475
|
*/
|
|
475
476
|
fhirSearchUrl(resourceType, query) {
|
|
476
477
|
const url = this.fhirUrl(resourceType);
|
|
477
478
|
if (query) {
|
|
478
|
-
url.search = query.toString();
|
|
479
|
+
url.search = new URLSearchParams(query).toString();
|
|
479
480
|
}
|
|
480
481
|
return url;
|
|
481
482
|
}
|
|
@@ -523,7 +524,7 @@ class MedplumClient extends EventTarget {
|
|
|
523
524
|
*
|
|
524
525
|
* @category Search
|
|
525
526
|
* @param resourceType The FHIR resource type.
|
|
526
|
-
* @param query
|
|
527
|
+
* @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
527
528
|
* @param options Optional fetch options.
|
|
528
529
|
* @returns Promise to the search result bundle.
|
|
529
530
|
*/
|
|
@@ -564,7 +565,7 @@ class MedplumClient extends EventTarget {
|
|
|
564
565
|
*
|
|
565
566
|
* @category Search
|
|
566
567
|
* @param resourceType The FHIR resource type.
|
|
567
|
-
* @param query
|
|
568
|
+
* @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
568
569
|
* @param options Optional fetch options.
|
|
569
570
|
* @returns Promise to the search result bundle.
|
|
570
571
|
*/
|
|
@@ -599,7 +600,7 @@ class MedplumClient extends EventTarget {
|
|
|
599
600
|
*
|
|
600
601
|
* @category Search
|
|
601
602
|
* @param resourceType The FHIR resource type.
|
|
602
|
-
* @param query
|
|
603
|
+
* @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
603
604
|
* @param options Optional fetch options.
|
|
604
605
|
* @returns Promise to the search result bundle.
|
|
605
606
|
*/
|
|
@@ -1527,7 +1528,7 @@ async function _MedplumClient_request(method, url, options = {}) {
|
|
|
1527
1528
|
throw err;
|
|
1528
1529
|
}
|
|
1529
1530
|
if (response.status >= 400) {
|
|
1530
|
-
throw obj;
|
|
1531
|
+
throw new OperationOutcomeError(normalizeOperationOutcome(obj));
|
|
1531
1532
|
}
|
|
1532
1533
|
return obj;
|
|
1533
1534
|
}, _MedplumClient_fetchWithRetry = async function _MedplumClient_fetchWithRetry(url, options) {
|
|
@@ -1578,7 +1579,7 @@ async function _MedplumClient_executeAutoBatch() {
|
|
|
1578
1579
|
const entry = entries[i];
|
|
1579
1580
|
const responseEntry = response.entry?.[i];
|
|
1580
1581
|
if (responseEntry?.response?.outcome && !isOk(responseEntry.response.outcome)) {
|
|
1581
|
-
entry.reject(responseEntry.response.outcome);
|
|
1582
|
+
entry.reject(new OperationOutcomeError(responseEntry.response.outcome));
|
|
1582
1583
|
}
|
|
1583
1584
|
else {
|
|
1584
1585
|
entry.resolve(responseEntry?.resource);
|
|
@@ -1722,14 +1723,6 @@ async function _MedplumClient_verifyTokens(tokens) {
|
|
|
1722
1723
|
// Silently ignore if this environment does not support storage events
|
|
1723
1724
|
}
|
|
1724
1725
|
};
|
|
1725
|
-
/**
|
|
1726
|
-
* Returns the current window if available.
|
|
1727
|
-
* All access to the current window should use this to support SSR such as Next.js.
|
|
1728
|
-
* @returns The current window or undefined if not available.
|
|
1729
|
-
*/
|
|
1730
|
-
function getWindow() {
|
|
1731
|
-
return typeof window === 'undefined' ? undefined : window;
|
|
1732
|
-
}
|
|
1733
1726
|
/**
|
|
1734
1727
|
* Returns the default fetch method.
|
|
1735
1728
|
* The default fetch is currently only available in browser environments.
|
|
@@ -1737,19 +1730,20 @@ function getWindow() {
|
|
|
1737
1730
|
* @returns The default fetch function for the current environment.
|
|
1738
1731
|
*/
|
|
1739
1732
|
function getDefaultFetch() {
|
|
1740
|
-
|
|
1741
|
-
if (!window) {
|
|
1733
|
+
if (!globalThis.fetch) {
|
|
1742
1734
|
throw new Error('Fetch not available in this environment');
|
|
1743
1735
|
}
|
|
1744
|
-
return
|
|
1736
|
+
return globalThis.fetch.bind(globalThis);
|
|
1745
1737
|
}
|
|
1746
1738
|
/**
|
|
1747
1739
|
* Returns the base URL for the current page.
|
|
1748
1740
|
* @category HTTP
|
|
1749
1741
|
*/
|
|
1750
1742
|
function getWindowOrigin() {
|
|
1751
|
-
|
|
1752
|
-
|
|
1743
|
+
if (typeof window === 'undefined') {
|
|
1744
|
+
return '';
|
|
1745
|
+
}
|
|
1746
|
+
return window.location.protocol + '//' + window.location.host + '/';
|
|
1753
1747
|
}
|
|
1754
1748
|
function ensureTrailingSlash(url) {
|
|
1755
1749
|
if (!url) {
|