@medplum/core 2.0.18 → 2.0.19
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 +806 -665
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +27 -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 +11 -5
- 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 +10 -1
- package/dist/types/filter/types.d.ts +3 -2
- package/dist/types/hl7.d.ts +12 -0
- package/dist/types/index.d.ts +1 -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.19-40e6e27d" ;
|
|
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
|
|
@@ -1512,6 +1513,26 @@ class MedplumClient extends EventTarget {
|
|
|
1512
1513
|
const response = await this.fetch(url.toString(), options);
|
|
1513
1514
|
return response.blob();
|
|
1514
1515
|
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Upload media to the server and create a Media instance for the uploaded content.
|
|
1518
|
+
* @param contents The contents of the media file, as a string, Uint8Array, File, or Blob.
|
|
1519
|
+
* @param contentType The media type of the content
|
|
1520
|
+
* @param filename The name of the file to be uploaded, or undefined if not applicable
|
|
1521
|
+
* @param additionalFields Additional fields for Media
|
|
1522
|
+
* @returns Promise that resolves to the created Media
|
|
1523
|
+
*/
|
|
1524
|
+
async uploadMedia(contents, contentType, filename, additionalFields) {
|
|
1525
|
+
const binary = await this.createBinary(contents, filename, contentType);
|
|
1526
|
+
return this.createResource({
|
|
1527
|
+
...additionalFields,
|
|
1528
|
+
resourceType: 'Media',
|
|
1529
|
+
content: {
|
|
1530
|
+
contentType: contentType,
|
|
1531
|
+
url: 'Binary/' + binary.id,
|
|
1532
|
+
title: filename,
|
|
1533
|
+
},
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1515
1536
|
//
|
|
1516
1537
|
// Private helpers
|
|
1517
1538
|
//
|
|
@@ -1587,7 +1608,10 @@ class MedplumClient extends EventTarget {
|
|
|
1587
1608
|
return undefined;
|
|
1588
1609
|
}
|
|
1589
1610
|
if (response.status === 404) {
|
|
1590
|
-
|
|
1611
|
+
const contentType = response.headers.get('content-type');
|
|
1612
|
+
if (!contentType?.includes('application/fhir+json')) {
|
|
1613
|
+
throw new OperationOutcomeError(notFound);
|
|
1614
|
+
}
|
|
1591
1615
|
}
|
|
1592
1616
|
let obj = undefined;
|
|
1593
1617
|
try {
|