@medplum/core 2.1.0 → 2.1.2
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 +4 -4
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/bundle.d.ts +11 -1
- package/dist/types/client.d.ts +71 -17
- package/dist/types/config.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/typeschema/crawler.d.ts +12 -0
- package/dist/types/typeschema/types.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/types/bundle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bundle } from '@medplum/fhirtypes';
|
|
1
|
+
import { Bundle, Resource } from '@medplum/fhirtypes';
|
|
2
2
|
/**
|
|
3
3
|
* More on Bundles can be found here
|
|
4
4
|
* http://hl7.org/fhir/R4/bundle.html
|
|
@@ -20,3 +20,13 @@ export declare function convertToTransactionBundle(bundle: Bundle): Bundle;
|
|
|
20
20
|
* @returns Bundle of the same type, with Bundle.entry reordered
|
|
21
21
|
*/
|
|
22
22
|
export declare function reorderBundle(bundle: Bundle): Bundle;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a resource with contained resources to a transaction bundle.
|
|
25
|
+
* This function is useful when creating a resource that contains other resources.
|
|
26
|
+
* Handles local references and topological sorting.
|
|
27
|
+
* @param resource The input resource which may or may not include contained resources.
|
|
28
|
+
* @returns A bundle with the input resource and all contained resources.
|
|
29
|
+
*/
|
|
30
|
+
export declare function convertContainedResourcesToBundle(resource: Resource & {
|
|
31
|
+
contained?: Resource[];
|
|
32
|
+
}): Bundle;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessPolicy, Attachment, Binary, BulkDataExport, Bundle, Communication, ExtractResource, Identifier, Media, OperationOutcome, Project, ProjectMembership, ProjectMembershipAccess, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
1
|
+
import { AccessPolicy, Agent, Attachment, Binary, BulkDataExport, Bundle, Communication, ExtractResource, Identifier, Media, OperationOutcome, Project, ProjectMembership, ProjectMembershipAccess, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
|
|
2
2
|
/** @ts-ignore */
|
|
3
3
|
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
4
4
|
import { EventTarget } from './eventtarget';
|
|
@@ -27,6 +27,8 @@ export interface MedplumClientOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* Default value is baseUrl + "/oauth2/authorize".
|
|
29
29
|
*
|
|
30
|
+
* Can be specified as absolute URL or relative to baseUrl.
|
|
31
|
+
*
|
|
30
32
|
* Use this if you want to use a separate OAuth server.
|
|
31
33
|
*/
|
|
32
34
|
authorizeUrl?: string;
|
|
@@ -35,6 +37,8 @@ export interface MedplumClientOptions {
|
|
|
35
37
|
*
|
|
36
38
|
* Default value is "fhir/R4/".
|
|
37
39
|
*
|
|
40
|
+
* Can be specified as absolute URL or relative to baseUrl.
|
|
41
|
+
*
|
|
38
42
|
* Use this if you want to use a different path when connecting to a FHIR server.
|
|
39
43
|
*/
|
|
40
44
|
fhirUrlPath?: string;
|
|
@@ -43,6 +47,8 @@ export interface MedplumClientOptions {
|
|
|
43
47
|
*
|
|
44
48
|
* Default value is baseUrl + "/oauth2/token".
|
|
45
49
|
*
|
|
50
|
+
* Can be specified as absolute URL or relative to baseUrl.
|
|
51
|
+
*
|
|
46
52
|
* Use this if you want to use a separate OAuth server.
|
|
47
53
|
*/
|
|
48
54
|
tokenUrl?: string;
|
|
@@ -51,6 +57,8 @@ export interface MedplumClientOptions {
|
|
|
51
57
|
*
|
|
52
58
|
* Default value is baseUrl + "/oauth2/logout".
|
|
53
59
|
*
|
|
60
|
+
* Can be specified as absolute URL or relative to baseUrl.
|
|
61
|
+
*
|
|
54
62
|
* Use this if you want to use a separate OAuth server.
|
|
55
63
|
*/
|
|
56
64
|
logoutUrl?: string;
|
|
@@ -108,14 +116,6 @@ export interface MedplumClientOptions {
|
|
|
108
116
|
* For Node.js applications, consider the 'node-fetch' package.
|
|
109
117
|
*/
|
|
110
118
|
fetch?: FetchLike;
|
|
111
|
-
/**
|
|
112
|
-
* The profile name.
|
|
113
|
-
*
|
|
114
|
-
* This is for handling multiple profiles to access different FHIR Servers
|
|
115
|
-
*
|
|
116
|
-
* If undefined, the default profile is "default".
|
|
117
|
-
*/
|
|
118
|
-
profile?: string;
|
|
119
119
|
/**
|
|
120
120
|
* Storage implementation.
|
|
121
121
|
*
|
|
@@ -170,6 +170,18 @@ export interface MedplumClientOptions {
|
|
|
170
170
|
* For client side applications, consider redirecting to a sign in page.
|
|
171
171
|
*/
|
|
172
172
|
onUnauthenticated?: () => void;
|
|
173
|
+
/**
|
|
174
|
+
* The default redirect behavior.
|
|
175
|
+
*
|
|
176
|
+
* The default behavior is to not follow redirects.
|
|
177
|
+
*
|
|
178
|
+
* Use "follow" to automatically follow redirects.
|
|
179
|
+
*/
|
|
180
|
+
redirect?: RequestRedirect;
|
|
181
|
+
/**
|
|
182
|
+
* When the verbose flag is set, the client will log all requests and responses to the console.
|
|
183
|
+
*/
|
|
184
|
+
verbose?: boolean;
|
|
173
185
|
}
|
|
174
186
|
export interface FetchLike {
|
|
175
187
|
(url: string, options?: any): Promise<any>;
|
|
@@ -386,6 +398,14 @@ export declare enum OAuthTokenType {
|
|
|
386
398
|
/** Indicates that the token is a base64url-encoded SAML 2.0 [OASIS.saml-core-2.0-os] assertion. */
|
|
387
399
|
Saml2Token = "urn:ietf:params:oauth:token-type:saml2"
|
|
388
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* OAuth 2.0 Client Authentication Methods
|
|
403
|
+
* See: https://datatracker.ietf.org/doc/html/rfc7523#section-2.2
|
|
404
|
+
*/
|
|
405
|
+
export declare enum OAuthClientAssertionType {
|
|
406
|
+
/** Using JWTs for Client Authentication */
|
|
407
|
+
JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
|
|
408
|
+
}
|
|
389
409
|
/**
|
|
390
410
|
* The MedplumClient class provides a client for the Medplum FHIR server.
|
|
391
411
|
*
|
|
@@ -438,6 +458,7 @@ export declare enum OAuthTokenType {
|
|
|
438
458
|
* </head>
|
|
439
459
|
*/
|
|
440
460
|
export declare class MedplumClient extends EventTarget {
|
|
461
|
+
private readonly options;
|
|
441
462
|
private readonly fetch;
|
|
442
463
|
private readonly createPdfImpl?;
|
|
443
464
|
private readonly storage;
|
|
@@ -478,6 +499,22 @@ export declare class MedplumClient extends EventTarget {
|
|
|
478
499
|
* @returns The current authorize URL.
|
|
479
500
|
*/
|
|
480
501
|
getAuthorizeUrl(): string;
|
|
502
|
+
/**
|
|
503
|
+
* Returns the current token URL.
|
|
504
|
+
* By default, this is set to `https://api.medplum.com/oauth2/token`.
|
|
505
|
+
* This can be overridden by setting the `tokenUrl` option when creating the client.
|
|
506
|
+
* @category HTTP
|
|
507
|
+
* @returns The current token URL.
|
|
508
|
+
*/
|
|
509
|
+
getTokenUrl(): string;
|
|
510
|
+
/**
|
|
511
|
+
* Returns the current logout URL.
|
|
512
|
+
* By default, this is set to `https://api.medplum.com/oauth2/logout`.
|
|
513
|
+
* This can be overridden by setting the `logoutUrl` option when creating the client.
|
|
514
|
+
* @category HTTP
|
|
515
|
+
* @returns The current logout URL.
|
|
516
|
+
*/
|
|
517
|
+
getLogoutUrl(): string;
|
|
481
518
|
/**
|
|
482
519
|
* Clears all auth state including local storage and session storage.
|
|
483
520
|
* @category Authentication
|
|
@@ -1328,7 +1365,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1328
1365
|
*/
|
|
1329
1366
|
graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any>;
|
|
1330
1367
|
/**
|
|
1331
|
-
*
|
|
1332
1368
|
* Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource
|
|
1333
1369
|
* according to a graph definition
|
|
1334
1370
|
* @category Read
|
|
@@ -1339,6 +1375,16 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1339
1375
|
* @returns A Bundle
|
|
1340
1376
|
*/
|
|
1341
1377
|
readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string, options?: RequestInit): ReadablePromise<Bundle>;
|
|
1378
|
+
/**
|
|
1379
|
+
* Pushes a message to an agent.
|
|
1380
|
+
*
|
|
1381
|
+
* @param agent The agent to push to.
|
|
1382
|
+
* @param body The message body.
|
|
1383
|
+
* @param contentType Optional message content type.
|
|
1384
|
+
* @param options Optional fetch options.
|
|
1385
|
+
* @returns Promise to the operation outcome.
|
|
1386
|
+
*/
|
|
1387
|
+
pushToAgent(agent: Agent, body: any, contentType?: string, options?: RequestInit): Promise<OperationOutcome>;
|
|
1342
1388
|
/**
|
|
1343
1389
|
* @category Authentication
|
|
1344
1390
|
* @returns The Login State
|
|
@@ -1427,13 +1473,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1427
1473
|
* @category User Profile
|
|
1428
1474
|
*/
|
|
1429
1475
|
getAccessPolicy(): AccessPolicy | undefined;
|
|
1430
|
-
/**
|
|
1431
|
-
* Translates/normalizes a URL so that it can be directly used with `MedplumClient.fetch`.
|
|
1432
|
-
* Especially useful for translating `Binary/{id}` URLs to FHIR paths.
|
|
1433
|
-
* @param url A valid URL within the `MedplumClient` context.
|
|
1434
|
-
* @returns URL as a string that can be used with `MedplumClient.fetch`
|
|
1435
|
-
*/
|
|
1436
|
-
normalizeFetchUrl(url: URL | string): string;
|
|
1437
1476
|
/**
|
|
1438
1477
|
* Downloads the URL as a blob. Can accept binary URLs in the form of `Binary/{id}` as well.
|
|
1439
1478
|
* @category Read
|
|
@@ -1504,6 +1543,8 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1504
1543
|
private request;
|
|
1505
1544
|
private parseResponse;
|
|
1506
1545
|
private fetchWithRetry;
|
|
1546
|
+
private logRequest;
|
|
1547
|
+
private logResponse;
|
|
1507
1548
|
private pollStatus;
|
|
1508
1549
|
/**
|
|
1509
1550
|
* Executes a batch of requests that were automatically batched together.
|
|
@@ -1578,6 +1619,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1578
1619
|
* ```
|
|
1579
1620
|
*
|
|
1580
1621
|
* See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
1622
|
+
*
|
|
1581
1623
|
* @category Authentication
|
|
1582
1624
|
* @param clientId The client ID.
|
|
1583
1625
|
* @param clientSecret The client secret.
|
|
@@ -1594,12 +1636,24 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1594
1636
|
* ```
|
|
1595
1637
|
*
|
|
1596
1638
|
* See: https://datatracker.ietf.org/doc/html/rfc7523#section-2.1
|
|
1639
|
+
*
|
|
1640
|
+
* @category Authentication
|
|
1597
1641
|
* @param clientId The client ID.
|
|
1598
1642
|
* @param assertion The JWT assertion.
|
|
1599
1643
|
* @param scope The OAuth scope.
|
|
1600
1644
|
* @returns Promise that resolves to the client profile.
|
|
1601
1645
|
*/
|
|
1602
1646
|
startJwtBearerLogin(clientId: string, assertion: string, scope: string): Promise<ProfileResource>;
|
|
1647
|
+
/**
|
|
1648
|
+
* Starts a new OAuth2 JWT assertion flow.
|
|
1649
|
+
*
|
|
1650
|
+
* See: https://datatracker.ietf.org/doc/html/rfc7523#section-2.2
|
|
1651
|
+
*
|
|
1652
|
+
* @category Authentication
|
|
1653
|
+
* @param jwt The JWT assertion.
|
|
1654
|
+
* @returns Promise that resolves to the client profile.
|
|
1655
|
+
*/
|
|
1656
|
+
startJwtAssertionLogin(jwt: string): Promise<ProfileResource>;
|
|
1603
1657
|
/**
|
|
1604
1658
|
* Sets the client ID and secret for basic auth.
|
|
1605
1659
|
*
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './search/search';
|
|
|
23
23
|
export * from './sftp';
|
|
24
24
|
export * from './storage';
|
|
25
25
|
export * from './types';
|
|
26
|
+
export * from './typeschema/crawler';
|
|
26
27
|
export * from './typeschema/types';
|
|
27
28
|
export * from './typeschema/validation';
|
|
28
29
|
export * from './utils';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Resource } from '@medplum/fhirtypes';
|
|
2
|
+
import { TypedValue } from '../types';
|
|
3
|
+
import { InternalTypeSchema } from './types';
|
|
4
|
+
export interface ResourceVisitor {
|
|
5
|
+
onEnterObject?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
|
|
6
|
+
onExitObject?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
|
|
7
|
+
onEnterResource?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
|
|
8
|
+
onExitResource?: (path: string, value: TypedValue, schema: InternalTypeSchema) => void;
|
|
9
|
+
visitProperty?: (parent: TypedValue, key: string, path: string, propertyValues: (TypedValue | TypedValue[] | undefined)[], schema: InternalTypeSchema) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function crawlResource(resource: Resource, visitor: ResourceVisitor, schema?: InternalTypeSchema, initialPath?: string): void;
|
|
12
|
+
export declare function getNestedProperty(value: TypedValue, key: string): (TypedValue | TypedValue[] | undefined)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bundle,
|
|
1
|
+
import { Bundle, Resource, StructureDefinition } from '@medplum/fhirtypes';
|
|
2
2
|
import { TypedValue } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Internal representation of a non-primitive FHIR type, suitable for use in resource validation
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -176,7 +176,7 @@ export declare function deepClone<T>(input: T): T;
|
|
|
176
176
|
* @param input The input string.
|
|
177
177
|
* @returns True if the input string matches the UUID format.
|
|
178
178
|
*/
|
|
179
|
-
export declare function isUUID(input: string):
|
|
179
|
+
export declare function isUUID(input: string): input is `${string}-${string}-${string}-${string}-${string}`;
|
|
180
180
|
/**
|
|
181
181
|
* Returns true if the input is an object.
|
|
182
182
|
* @param obj The candidate object.
|