@medplum/core 2.0.17 → 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 +708 -498
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/esm/client.mjs +44 -2
- 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/search/search.mjs +56 -4
- package/dist/esm/search/search.mjs.map +1 -1
- package/dist/esm/sftp.mjs +25 -0
- package/dist/esm/sftp.mjs.map +1 -0
- package/dist/esm/storage.mjs +1 -1
- package/dist/esm/storage.mjs.map +1 -1
- package/dist/esm/utils.mjs +13 -1
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/client.d.ts +27 -3
- 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/search/search.d.ts +10 -3
- package/dist/types/sftp.d.ts +9 -0
- package/dist/types/storage.d.ts +1 -1
- 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, normalizeOperationOutcome, isOk } from './outcomes.mjs';
|
|
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
|
//
|
|
@@ -1586,6 +1607,12 @@ class MedplumClient extends EventTarget {
|
|
|
1586
1607
|
// No content or change
|
|
1587
1608
|
return undefined;
|
|
1588
1609
|
}
|
|
1610
|
+
if (response.status === 404) {
|
|
1611
|
+
const contentType = response.headers.get('content-type');
|
|
1612
|
+
if (!contentType?.includes('application/fhir+json')) {
|
|
1613
|
+
throw new OperationOutcomeError(notFound);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1589
1616
|
let obj = undefined;
|
|
1590
1617
|
try {
|
|
1591
1618
|
obj = await response.json();
|
|
@@ -1810,6 +1837,14 @@ class MedplumClient extends EventTarget {
|
|
|
1810
1837
|
}
|
|
1811
1838
|
/**
|
|
1812
1839
|
* Starts a new OAuth2 client credentials flow.
|
|
1840
|
+
*
|
|
1841
|
+
* ```typescript
|
|
1842
|
+
* await medplum.startClientLogin(process.env.MEDPLUM_CLIENT_ID, process.env.MEDPLUM_CLIENT_SECRET)
|
|
1843
|
+
* // Example Search
|
|
1844
|
+
* await medplum.searchResources('Patient')
|
|
1845
|
+
* ```
|
|
1846
|
+
*
|
|
1847
|
+
*
|
|
1813
1848
|
* See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
1814
1849
|
* @category Authentication
|
|
1815
1850
|
* @param clientId The client ID.
|
|
@@ -1827,6 +1862,13 @@ class MedplumClient extends EventTarget {
|
|
|
1827
1862
|
}
|
|
1828
1863
|
/**
|
|
1829
1864
|
* Sets the client ID and secret for basic auth.
|
|
1865
|
+
*
|
|
1866
|
+
* ```typescript
|
|
1867
|
+
* medplum.setBasicAuth(process.env.MEDPLUM_CLIENT_ID, process.env.MEDPLUM_CLIENT_SECRET)
|
|
1868
|
+
* // Example Search
|
|
1869
|
+
* await medplum.searchResources('Patient')
|
|
1870
|
+
* ```
|
|
1871
|
+
*
|
|
1830
1872
|
* @category Authentication
|
|
1831
1873
|
* @param clientId The client ID.
|
|
1832
1874
|
* @param clientSecret The client secret.
|