@medplum/core 2.0.18 → 2.0.20
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/README.md +1 -1
- package/dist/cjs/index.cjs +724 -577
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +34 -3
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/filter/parse.mjs +54 -1
- package/dist/esm/filter/parse.mjs.map +1 -1
- package/dist/esm/filter/types.mjs.map +1 -1
- package/dist/esm/hl7.mjs +23 -1
- package/dist/esm/hl7.mjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.mjs +3 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/search/details.mjs +20 -15
- package/dist/esm/search/details.mjs.map +1 -1
- package/dist/esm/sftp.mjs +25 -0
- package/dist/esm/sftp.mjs.map +1 -0
- package/dist/esm/utils.mjs +13 -1
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/client.d.ts +15 -1
- package/dist/types/config.d.ts +45 -0
- package/dist/types/filter/types.d.ts +3 -2
- package/dist/types/hl7.d.ts +12 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/search/details.d.ts +1 -0
- package/dist/types/sftp.d.ts +9 -0
- package/dist/types/utils.d.ts +16 -0
- package/package.json +1 -1
package/dist/esm/client.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { LRUCache } from './cache.mjs';
|
|
|
2
2
|
import { getRandomString, encryptSHA256 } from './crypto.mjs';
|
|
3
3
|
import { EventTarget } from './eventtarget.mjs';
|
|
4
4
|
import { parseJWTPayload } from './jwt.mjs';
|
|
5
|
-
import { OperationOutcomeError,
|
|
5
|
+
import { OperationOutcomeError, notFound, normalizeOperationOutcome, isOk } from './outcomes.mjs';
|
|
6
6
|
import { ReadablePromise } from './readablepromise.mjs';
|
|
7
7
|
import { ClientStorage } from './storage.mjs';
|
|
8
8
|
import { globalSchema, indexStructureDefinition, indexSearchParameter } from './types.mjs';
|
|
@@ -10,7 +10,8 @@ import { createReference, arrayBufferToBase64 } from './utils.mjs';
|
|
|
10
10
|
import { encodeBase64 } from './base64.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.20-effeb76c" ;
|
|
14
15
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
15
16
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
16
17
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -181,6 +182,13 @@ class MedplumClient extends EventTarget {
|
|
|
181
182
|
url = url.toString();
|
|
182
183
|
this.requestCache?.delete(url);
|
|
183
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Invalidates all cached values and flushes the cache.
|
|
187
|
+
* @category Caching
|
|
188
|
+
*/
|
|
189
|
+
invalidateAll() {
|
|
190
|
+
this.requestCache?.clear();
|
|
191
|
+
}
|
|
184
192
|
/**
|
|
185
193
|
* Invalidates all cached search results or cached requests for the given resourceType.
|
|
186
194
|
* @category Caching
|
|
@@ -1512,6 +1520,26 @@ class MedplumClient extends EventTarget {
|
|
|
1512
1520
|
const response = await this.fetch(url.toString(), options);
|
|
1513
1521
|
return response.blob();
|
|
1514
1522
|
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Upload media to the server and create a Media instance for the uploaded content.
|
|
1525
|
+
* @param contents The contents of the media file, as a string, Uint8Array, File, or Blob.
|
|
1526
|
+
* @param contentType The media type of the content
|
|
1527
|
+
* @param filename The name of the file to be uploaded, or undefined if not applicable
|
|
1528
|
+
* @param additionalFields Additional fields for Media
|
|
1529
|
+
* @returns Promise that resolves to the created Media
|
|
1530
|
+
*/
|
|
1531
|
+
async uploadMedia(contents, contentType, filename, additionalFields) {
|
|
1532
|
+
const binary = await this.createBinary(contents, filename, contentType);
|
|
1533
|
+
return this.createResource({
|
|
1534
|
+
...additionalFields,
|
|
1535
|
+
resourceType: 'Media',
|
|
1536
|
+
content: {
|
|
1537
|
+
contentType: contentType,
|
|
1538
|
+
url: 'Binary/' + binary.id,
|
|
1539
|
+
title: filename,
|
|
1540
|
+
},
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1515
1543
|
//
|
|
1516
1544
|
// Private helpers
|
|
1517
1545
|
//
|
|
@@ -1587,7 +1615,10 @@ class MedplumClient extends EventTarget {
|
|
|
1587
1615
|
return undefined;
|
|
1588
1616
|
}
|
|
1589
1617
|
if (response.status === 404) {
|
|
1590
|
-
|
|
1618
|
+
const contentType = response.headers.get('content-type');
|
|
1619
|
+
if (!contentType?.includes('application/fhir+json')) {
|
|
1620
|
+
throw new OperationOutcomeError(notFound);
|
|
1621
|
+
}
|
|
1591
1622
|
}
|
|
1592
1623
|
let obj = undefined;
|
|
1593
1624
|
try {
|