@medplum/core 2.0.11 → 2.0.13
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 +58 -11
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/client.mjs +32 -3
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/eventtarget.mjs.map +1 -1
- package/dist/esm/fhirlexer/parse.mjs.map +1 -1
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
- package/dist/esm/fhirmapper/parse.mjs +1 -1
- package/dist/esm/fhirmapper/parse.mjs.map +1 -1
- package/dist/esm/fhirpath/atoms.mjs +1 -1
- package/dist/esm/fhirpath/atoms.mjs.map +1 -1
- package/dist/esm/fhirpath/functions.mjs +14 -5
- package/dist/esm/fhirpath/functions.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/schema.mjs +4 -0
- package/dist/esm/schema.mjs.map +1 -1
- package/dist/esm/search/details.mjs +1 -0
- package/dist/esm/search/details.mjs.map +1 -1
- package/dist/esm/search/match.mjs +1 -0
- package/dist/esm/search/match.mjs.map +1 -1
- package/dist/esm/search/search.mjs +3 -0
- package/dist/esm/search/search.mjs.map +1 -1
- package/dist/esm/storage.mjs.map +1 -1
- package/dist/esm/types.mjs +1 -1
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/client.d.ts +39 -4
- package/dist/types/search/details.d.ts +2 -1
- package/dist/types/search/search.d.ts +7 -6
- package/dist/types/utils.d.ts +8 -1
- package/package.json +1 -1
package/dist/esm/cache.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.mjs","sources":["../../src/cache.ts"],"sourcesContent":["/**\n * LRU cache (least recently used)\n * Source: https://stackoverflow.com/a/46432113\n */\nexport class LRUCache<T> {\n readonly #max: number;\n readonly #cache: Map<string, T>;\n\n constructor(max = 10) {\n this.#max = max;\n this.#cache = new Map();\n }\n\n /**\n * Deletes all values from the cache.\n */\n clear(): void {\n this.#cache.clear();\n }\n\n /**\n * Returns the value for the given key.\n * @param key The key to retrieve.\n * @returns The value if found; undefined otherwise.\n */\n get(key: string): T | undefined {\n const item = this.#cache.get(key);\n if (item) {\n this.#cache.delete(key);\n this.#cache.set(key, item);\n }\n return item;\n }\n\n /**\n * Sets the value for the given key.\n * @param key The key to set.\n * @param val The value to set.\n */\n set(key: string, val: T): void {\n if (this.#cache.has(key)) {\n this.#cache.delete(key);\n } else if (this.#cache.size >= this.#max) {\n this.#cache.delete(this.#first());\n }\n this.#cache.set(key, val);\n }\n\n /**\n * Deletes the value for the given key.\n * @param key The key to delete.\n */\n delete(key: string): void {\n this.#cache.delete(key);\n }\n\n /**\n * Returns the list of all keys in the cache.\n * @returns The array of keys in the cache.\n */\n keys(): IterableIterator<string> {\n return this.#cache.keys();\n }\n\n #first(): string {\n // This works because the Map class maintains ordered keys.\n return this.#cache.keys().next().value;\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;AAGG;MACU,QAAQ,CAAA;IAInB,WAAY,CAAA,GAAG,GAAG,EAAE,EAAA;;
|
|
1
|
+
{"version":3,"file":"cache.mjs","sources":["../../src/cache.ts"],"sourcesContent":["/**\n * LRU cache (least recently used)\n * Source: https://stackoverflow.com/a/46432113\n */\nexport class LRUCache<T> {\n readonly #max: number;\n readonly #cache: Map<string, T>;\n\n constructor(max = 10) {\n this.#max = max;\n this.#cache = new Map();\n }\n\n /**\n * Deletes all values from the cache.\n */\n clear(): void {\n this.#cache.clear();\n }\n\n /**\n * Returns the value for the given key.\n * @param key The key to retrieve.\n * @returns The value if found; undefined otherwise.\n */\n get(key: string): T | undefined {\n const item = this.#cache.get(key);\n if (item) {\n this.#cache.delete(key);\n this.#cache.set(key, item);\n }\n return item;\n }\n\n /**\n * Sets the value for the given key.\n * @param key The key to set.\n * @param val The value to set.\n */\n set(key: string, val: T): void {\n if (this.#cache.has(key)) {\n this.#cache.delete(key);\n } else if (this.#cache.size >= this.#max) {\n this.#cache.delete(this.#first());\n }\n this.#cache.set(key, val);\n }\n\n /**\n * Deletes the value for the given key.\n * @param key The key to delete.\n */\n delete(key: string): void {\n this.#cache.delete(key);\n }\n\n /**\n * Returns the list of all keys in the cache.\n * @returns The array of keys in the cache.\n */\n keys(): IterableIterator<string> {\n return this.#cache.keys();\n }\n\n #first(): string {\n // This works because the Map class maintains ordered keys.\n return this.#cache.keys().next().value;\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;AAGG;MACU,QAAQ,CAAA;IAInB,WAAY,CAAA,GAAG,GAAG,EAAE,EAAA;;QAHX,aAAa,CAAA,GAAA,CAAA,IAAA,EAAA,KAAA,CAAA,CAAA,CAAA;QACb,eAAuB,CAAA,GAAA,CAAA,IAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG9B,QAAA,sBAAA,CAAA,IAAI,EAAA,aAAA,EAAQ,GAAG,EAAA,GAAA,CAAA,CAAC;AAChB,QAAA,sBAAA,CAAA,IAAI,EAAU,eAAA,EAAA,IAAI,GAAG,EAAE,MAAA,CAAC;KACzB;AAED;;AAEG;IACH,KAAK,GAAA;AACH,QAAA,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,KAAK,EAAE,CAAC;KACrB;AAED;;;;AAIG;AACH,IAAA,GAAG,CAAC,GAAW,EAAA;QACb,MAAM,IAAI,GAAG,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClC,QAAA,IAAI,IAAI,EAAE;AACR,YAAA,sBAAA,CAAA,IAAI,EAAO,eAAA,EAAA,GAAA,CAAA,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,sBAAA,CAAA,IAAI,uBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;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
|
|
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.13-ee64d72c";
|
|
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
|
|
@@ -567,7 +567,7 @@ class MedplumClient extends EventTarget {
|
|
|
567
567
|
* @param resourceType The FHIR resource type.
|
|
568
568
|
* @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
569
569
|
* @param options Optional fetch options.
|
|
570
|
-
* @returns Promise to the search result
|
|
570
|
+
* @returns Promise to the first search result.
|
|
571
571
|
*/
|
|
572
572
|
searchOne(resourceType, query, options = {}) {
|
|
573
573
|
const url = this.fhirSearchUrl(resourceType, query);
|
|
@@ -602,7 +602,7 @@ class MedplumClient extends EventTarget {
|
|
|
602
602
|
* @param resourceType The FHIR resource type.
|
|
603
603
|
* @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
|
|
604
604
|
* @param options Optional fetch options.
|
|
605
|
-
* @returns Promise to the search
|
|
605
|
+
* @returns Promise to the array of search results.
|
|
606
606
|
*/
|
|
607
607
|
searchResources(resourceType, query, options = {}) {
|
|
608
608
|
const url = this.fhirSearchUrl(resourceType, query);
|
|
@@ -1165,6 +1165,26 @@ class MedplumClient extends EventTarget {
|
|
|
1165
1165
|
validateResource(resource) {
|
|
1166
1166
|
return this.post(this.fhirUrl(resource.resourceType, '$validate'), resource);
|
|
1167
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Executes a bot by ID or Identifier.
|
|
1170
|
+
* @param idOrIdentifier The Bot ID or Identifier.
|
|
1171
|
+
* @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
|
|
1172
|
+
* @param contentType The content type to be included in the "Content-Type" header.
|
|
1173
|
+
* @param options Optional fetch options.
|
|
1174
|
+
* @returns The Bot return value.
|
|
1175
|
+
*/
|
|
1176
|
+
executeBot(idOrIdentifier, body, contentType, options = {}) {
|
|
1177
|
+
let url;
|
|
1178
|
+
if (typeof idOrIdentifier === 'string') {
|
|
1179
|
+
const id = idOrIdentifier;
|
|
1180
|
+
url = this.fhirUrl('Bot', id, '$execute');
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
const identifier = idOrIdentifier;
|
|
1184
|
+
url = this.fhirUrl('Bot', '$execute') + `?identifier=${identifier.system}|${identifier.value}`;
|
|
1185
|
+
}
|
|
1186
|
+
return this.post(url, body, contentType, options);
|
|
1187
|
+
}
|
|
1168
1188
|
/**
|
|
1169
1189
|
* Executes a batch or transaction of FHIR operations.
|
|
1170
1190
|
*
|
|
@@ -1457,6 +1477,15 @@ class MedplumClient extends EventTarget {
|
|
|
1457
1477
|
formBody.set('client_secret', clientSecret);
|
|
1458
1478
|
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_fetchTokens).call(this, formBody);
|
|
1459
1479
|
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Invite a user to a project.
|
|
1482
|
+
* @param projectId The project ID.
|
|
1483
|
+
* @param body The InviteBody.
|
|
1484
|
+
* @returns Promise that returns an invite result or an operation outcome.
|
|
1485
|
+
*/
|
|
1486
|
+
async invite(projectId, body) {
|
|
1487
|
+
return this.post('admin/projects/' + projectId + '/invite', body);
|
|
1488
|
+
}
|
|
1460
1489
|
}
|
|
1461
1490
|
_MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(), _MedplumClient_storage = new WeakMap(), _MedplumClient_requestCache = new WeakMap(), _MedplumClient_cacheTime = new WeakMap(), _MedplumClient_baseUrl = new WeakMap(), _MedplumClient_fhirBaseUrl = new WeakMap(), _MedplumClient_authorizeUrl = new WeakMap(), _MedplumClient_tokenUrl = new WeakMap(), _MedplumClient_logoutUrl = new WeakMap(), _MedplumClient_onUnauthenticated = new WeakMap(), _MedplumClient_autoBatchTime = new WeakMap(), _MedplumClient_autoBatchQueue = new WeakMap(), _MedplumClient_clientId = new WeakMap(), _MedplumClient_clientSecret = new WeakMap(), _MedplumClient_autoBatchTimerId = new WeakMap(), _MedplumClient_accessToken = new WeakMap(), _MedplumClient_refreshToken = new WeakMap(), _MedplumClient_refreshPromise = new WeakMap(), _MedplumClient_profilePromise = new WeakMap(), _MedplumClient_profile = new WeakMap(), _MedplumClient_config = new WeakMap(), _MedplumClient_instances = new WeakSet(), _MedplumClient_addLogin = function _MedplumClient_addLogin(newLogin) {
|
|
1462
1491
|
const logins = this.getLogins().filter((login) => login.profile?.reference !== newLogin.profile?.reference);
|