@medplum/core 2.1.0 → 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.
@@ -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;
@@ -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
@@ -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.
@@ -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
  *
@@ -48,4 +48,10 @@ export interface MedplumInfraConfig {
48
48
  [key: string]: string;
49
49
  };
50
50
  }[];
51
+ cloudTrailAlarms?: {
52
+ logGroupName: string;
53
+ logGroupCreate?: boolean;
54
+ snsTopicArn?: string;
55
+ snsTopicName?: string;
56
+ };
51
57
  }
@@ -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)[];
@@ -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): boolean;
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",