@medplum/core 2.0.32 → 2.1.1
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/access.d.ts +0 -5
- package/dist/types/bundle.d.ts +11 -1
- package/dist/types/client.d.ts +63 -18
- package/dist/types/config.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jwt.d.ts +6 -0
- package/dist/types/typeschema/crawler.d.ts +12 -0
- package/dist/types/typeschema/validation.d.ts +23 -0
- package/dist/types/utils.d.ts +12 -1
- package/package.json +1 -1
package/dist/types/access.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { AccessPolicy, AccessPolicyResource, Resource, ResourceType } from '@medplum/fhirtypes';
|
|
2
|
-
/**
|
|
3
|
-
* Public resource types are in the "public" project.
|
|
4
|
-
* They are available to all users.
|
|
5
|
-
*/
|
|
6
|
-
export declare const publicResourceTypes: string[];
|
|
7
2
|
/**
|
|
8
3
|
* Protected resource types are in the "medplum" project.
|
|
9
4
|
* Reading and writing is limited to the system account.
|
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
|
@@ -6,7 +6,7 @@ import { Hl7Message } from './hl7';
|
|
|
6
6
|
import { ReadablePromise } from './readablepromise';
|
|
7
7
|
import { ClientStorage } from './storage';
|
|
8
8
|
import { IndexedStructureDefinition } from './types';
|
|
9
|
-
import { ProfileResource } from './utils';
|
|
9
|
+
import { CodeChallengeMethod, ProfileResource } from './utils';
|
|
10
10
|
export declare const MEDPLUM_VERSION: string;
|
|
11
11
|
/**
|
|
12
12
|
* The MedplumClientOptions interface defines configuration options for MedplumClient.
|
|
@@ -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>;
|
|
@@ -203,7 +215,7 @@ export interface BaseLoginRequest {
|
|
|
203
215
|
readonly scope?: string;
|
|
204
216
|
readonly nonce?: string;
|
|
205
217
|
readonly codeChallenge?: string;
|
|
206
|
-
readonly codeChallengeMethod?:
|
|
218
|
+
readonly codeChallengeMethod?: CodeChallengeMethod;
|
|
207
219
|
readonly googleClientId?: string;
|
|
208
220
|
readonly launch?: string;
|
|
209
221
|
readonly redirectUri?: string;
|
|
@@ -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
|
|
@@ -1427,13 +1464,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1427
1464
|
* @category User Profile
|
|
1428
1465
|
*/
|
|
1429
1466
|
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
1467
|
/**
|
|
1438
1468
|
* Downloads the URL as a blob. Can accept binary URLs in the form of `Binary/{id}` as well.
|
|
1439
1469
|
* @category Read
|
|
@@ -1504,6 +1534,8 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1504
1534
|
private request;
|
|
1505
1535
|
private parseResponse;
|
|
1506
1536
|
private fetchWithRetry;
|
|
1537
|
+
private logRequest;
|
|
1538
|
+
private logResponse;
|
|
1507
1539
|
private pollStatus;
|
|
1508
1540
|
/**
|
|
1509
1541
|
* Executes a batch of requests that were automatically batched together.
|
|
@@ -1543,7 +1575,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1543
1575
|
* @returns The PKCE code challenge details.
|
|
1544
1576
|
*/
|
|
1545
1577
|
startPkce(): Promise<{
|
|
1546
|
-
codeChallengeMethod:
|
|
1578
|
+
codeChallengeMethod: CodeChallengeMethod;
|
|
1547
1579
|
codeChallenge: string;
|
|
1548
1580
|
}>;
|
|
1549
1581
|
/**
|
|
@@ -1578,6 +1610,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1578
1610
|
* ```
|
|
1579
1611
|
*
|
|
1580
1612
|
* See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
1613
|
+
*
|
|
1581
1614
|
* @category Authentication
|
|
1582
1615
|
* @param clientId The client ID.
|
|
1583
1616
|
* @param clientSecret The client secret.
|
|
@@ -1594,12 +1627,24 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1594
1627
|
* ```
|
|
1595
1628
|
*
|
|
1596
1629
|
* See: https://datatracker.ietf.org/doc/html/rfc7523#section-2.1
|
|
1630
|
+
*
|
|
1631
|
+
* @category Authentication
|
|
1597
1632
|
* @param clientId The client ID.
|
|
1598
1633
|
* @param assertion The JWT assertion.
|
|
1599
1634
|
* @param scope The OAuth scope.
|
|
1600
1635
|
* @returns Promise that resolves to the client profile.
|
|
1601
1636
|
*/
|
|
1602
1637
|
startJwtBearerLogin(clientId: string, assertion: string, scope: string): Promise<ProfileResource>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Starts a new OAuth2 JWT assertion flow.
|
|
1640
|
+
*
|
|
1641
|
+
* See: https://datatracker.ietf.org/doc/html/rfc7523#section-2.2
|
|
1642
|
+
*
|
|
1643
|
+
* @category Authentication
|
|
1644
|
+
* @param jwt The JWT assertion.
|
|
1645
|
+
* @returns Promise that resolves to the client profile.
|
|
1646
|
+
*/
|
|
1647
|
+
startJwtAssertionLogin(jwt: string): Promise<ProfileResource>;
|
|
1603
1648
|
/**
|
|
1604
1649
|
* Sets the client ID and secret for basic auth.
|
|
1605
1650
|
*
|
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';
|
package/dist/types/jwt.d.ts
CHANGED
|
@@ -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,2 +1,25 @@
|
|
|
1
1
|
import { Resource, StructureDefinition } from '@medplum/fhirtypes';
|
|
2
|
+
export declare const fhirTypeToJsType: {
|
|
3
|
+
readonly base64Binary: "string";
|
|
4
|
+
readonly boolean: "boolean";
|
|
5
|
+
readonly canonical: "string";
|
|
6
|
+
readonly code: "string";
|
|
7
|
+
readonly date: "string";
|
|
8
|
+
readonly dateTime: "string";
|
|
9
|
+
readonly decimal: "number";
|
|
10
|
+
readonly id: "string";
|
|
11
|
+
readonly instant: "string";
|
|
12
|
+
readonly integer: "number";
|
|
13
|
+
readonly markdown: "string";
|
|
14
|
+
readonly oid: "string";
|
|
15
|
+
readonly positiveInt: "number";
|
|
16
|
+
readonly string: "string";
|
|
17
|
+
readonly time: "string";
|
|
18
|
+
readonly unsignedInt: "number";
|
|
19
|
+
readonly uri: "string";
|
|
20
|
+
readonly url: "string";
|
|
21
|
+
readonly uuid: "string";
|
|
22
|
+
readonly xhtml: "string";
|
|
23
|
+
readonly 'http://hl7.org/fhirpath/System.String': "string";
|
|
24
|
+
};
|
|
2
25
|
export declare function validate(resource: Resource, profile?: StructureDefinition): void;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { CodeableConcept, Extension, ObservationDefinition, ObservationDefinitio
|
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
export type ProfileResource = Patient | Practitioner | RelatedPerson;
|
|
6
|
+
/**
|
|
7
|
+
* Allowed values for `code_challenge_method` in a PKCE exchange.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export type CodeChallengeMethod = 'plain' | 'S256';
|
|
6
11
|
interface Code {
|
|
7
12
|
code?: CodeableConcept;
|
|
8
13
|
}
|
|
@@ -88,6 +93,12 @@ export declare function calculateAgeString(birthDateStr: string, endDateStr?: st
|
|
|
88
93
|
* @returns Questionnaire answers mapped by link ID.
|
|
89
94
|
*/
|
|
90
95
|
export declare function getQuestionnaireAnswers(response: QuestionnaireResponse): Record<string, QuestionnaireResponseItemAnswer>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns an array of questionnaire answers as a map by link ID.
|
|
98
|
+
* @param response The questionnaire response resource.
|
|
99
|
+
* @returns Questionnaire answer arrays mapped by link ID.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getAllQuestionnaireAnswers(response: QuestionnaireResponse): Record<string, QuestionnaireResponseItemAnswer[]>;
|
|
91
102
|
/**
|
|
92
103
|
* Returns the resource identifier for the given system.
|
|
93
104
|
*
|
|
@@ -165,7 +176,7 @@ export declare function deepClone<T>(input: T): T;
|
|
|
165
176
|
* @param input The input string.
|
|
166
177
|
* @returns True if the input string matches the UUID format.
|
|
167
178
|
*/
|
|
168
|
-
export declare function isUUID(input: string):
|
|
179
|
+
export declare function isUUID(input: string): input is `${string}-${string}-${string}-${string}-${string}`;
|
|
169
180
|
/**
|
|
170
181
|
* Returns true if the input is an object.
|
|
171
182
|
* @param obj The candidate object.
|