@medplum/core 3.1.1 → 3.1.3

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.
@@ -6,6 +6,7 @@ import { Address } from '@medplum/fhirtypes';
6
6
  import { Agent } from '@medplum/fhirtypes';
7
7
  import { Attachment } from '@medplum/fhirtypes';
8
8
  import { Binary } from '@medplum/fhirtypes';
9
+ import { Bot } from '@medplum/fhirtypes';
9
10
  import { BulkDataExport } from '@medplum/fhirtypes';
10
11
  import { Bundle } from '@medplum/fhirtypes';
11
12
  import { CodeableConcept } from '@medplum/fhirtypes';
@@ -107,6 +108,7 @@ export declare interface AgentHeartbeatRequest extends BaseAgentRequestMessage {
107
108
 
108
109
  export declare interface AgentHeartbeatResponse extends BaseAgentMessage {
109
110
  type: 'agent:heartbeat:response';
111
+ version: string;
110
112
  }
111
113
 
112
114
  export declare type AgentMessage = AgentError | AgentConnectRequest | AgentConnectResponse | AgentHeartbeatRequest | AgentHeartbeatResponse | AgentTransmitRequest | AgentTransmitResponse;
@@ -124,6 +126,7 @@ export declare interface AgentTransmitResponse extends BaseAgentMessage {
124
126
  channel?: string;
125
127
  remote: string;
126
128
  contentType: string;
129
+ statusCode?: number;
127
130
  body: string;
128
131
  }
129
132
 
@@ -261,6 +264,7 @@ export declare abstract class BooleanInfixOperatorAtom extends InfixOperatorAtom
261
264
  export declare function booleanToTypedValue(value: boolean): [TypedValue];
262
265
 
263
266
  export declare interface BotEvent<T = Resource | Hl7Message | string | Record<string, any>> {
267
+ readonly bot: Reference<Bot>;
264
268
  readonly contentType: string;
265
269
  readonly input: T;
266
270
  readonly secrets: Record<string, ProjectSecret>;
@@ -1439,6 +1443,14 @@ export declare function getPathDisplayName(path: string): string;
1439
1443
  */
1440
1444
  export declare function getPropertyDisplayName(propertyName: string): string;
1441
1445
 
1446
+ /**
1447
+ * Converts the given `query` to a string.
1448
+ *
1449
+ * @param query - The query to convert. The type can be any member of `QueryTypes`.
1450
+ * @returns The query as a string.
1451
+ */
1452
+ export declare function getQueryString(query: QueryTypes): string;
1453
+
1442
1454
  /**
1443
1455
  * Returns all questionnaire answers as a map by link ID.
1444
1456
  * @param response - The questionnaire response resource.
@@ -1527,6 +1539,13 @@ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue,
1527
1539
 
1528
1540
  export declare function getValueSliceName(value: any, slices: SliceDefinitionWithTypes[], discriminators: SliceDiscriminator[], profileUrl: string | undefined): string | undefined;
1529
1541
 
1542
+ /**
1543
+ * Concatenates a given base URL and path, ensuring the URL has the appropriate `ws://` or `wss://` protocol instead of `http://` or `https://`.
1544
+ *
1545
+ * @param baseUrl - The base URL.
1546
+ * @param path - The URL to concat. Can be relative or absolute.
1547
+ * @returns The concatenated WebSocket URL.
1548
+ */
1530
1549
  export declare function getWebSocketUrl(baseUrl: URL | string, path: string): string;
1531
1550
 
1532
1551
  /**
@@ -2166,6 +2185,34 @@ export declare function isUUID(input: string): input is string;
2166
2185
  */
2167
2186
  export declare function isValidDate(date: Date): boolean;
2168
2187
 
2188
+ /**
2189
+ * Tests whether a given input is a valid hostname.
2190
+ *
2191
+ * __NOTE: Does not validate that the input is a valid domain name, only a valid hostname.__
2192
+ *
2193
+ * @param input - The input to test.
2194
+ * @returns True if `input` is a valid hostname, otherwise returns false.
2195
+ *
2196
+ * ### Valid matches:
2197
+ * - foo
2198
+ * - foo.com
2199
+ * - foo.bar.com
2200
+ * - foo.org
2201
+ * - foo.bar.co.uk
2202
+ * - localhost
2203
+ * - LOCALHOST
2204
+ * - foo-bar-baz
2205
+ * - foo_bar
2206
+ * - foobar123
2207
+ *
2208
+ * ### Invalid matches:
2209
+ * - foo.com/bar
2210
+ * - https://foo.com
2211
+ * - foo_-bar_-
2212
+ * - foo | rm -rf /
2213
+ */
2214
+ export declare function isValidHostname(input: string): boolean;
2215
+
2169
2216
  /**
2170
2217
  * Memoizes the result of a parameterless function
2171
2218
  * @param fn - The function to be wrapped
@@ -2363,7 +2410,7 @@ export declare function matchesSearchRequest(resource: Resource, searchRequest:
2363
2410
 
2364
2411
  export declare const MEDPLUM_CLI_CLIENT_ID = "medplum-cli";
2365
2412
 
2366
- export declare const MEDPLUM_VERSION: any;
2413
+ export declare const MEDPLUM_VERSION: string;
2367
2414
 
2368
2415
  /**
2369
2416
  * The MedplumClient class provides a client for the Medplum FHIR server.
@@ -3052,6 +3099,15 @@ export declare class MedplumClient extends EventTarget_2 {
3052
3099
  * @returns The result of the create operation.
3053
3100
  */
3054
3101
  createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: MedplumRequestOptions): Promise<T>;
3102
+ /**
3103
+ * Upsert a resource: update it in place if it exists, otherwise create it. This is done in a single, transactional
3104
+ * request to guarantee data consistency.
3105
+ * @param resource - The resource to update or create.
3106
+ * @param query - A FHIR search query to uniquely identify the resource if it already exists.
3107
+ * @param options - Optional fetch options.
3108
+ * @returns The updated/created resource.
3109
+ */
3110
+ upsertResource<T extends Resource>(resource: T, query: QueryTypes, options?: MedplumRequestOptions): Promise<T>;
3055
3111
  /**
3056
3112
  * Creates a FHIR `Attachment` with the provided data content.
3057
3113
  *
@@ -4302,6 +4358,8 @@ export declare class MockAsyncClientStorage extends ClientStorage implements ICl
4302
4358
  get isInitialized(): boolean;
4303
4359
  }
4304
4360
 
4361
+ export declare const multipleMatches: OperationOutcome;
4362
+
4305
4363
  export declare interface NewPatientRequest {
4306
4364
  readonly login: string;
4307
4365
  readonly projectId: string;
@@ -4817,7 +4875,7 @@ export declare const protectedResourceTypes: string[];
4817
4875
  * Web browsers and Node.js automatically coerce values to strings.
4818
4876
  * See: https://github.com/microsoft/TypeScript/issues/32951
4819
4877
  */
4820
- export declare type QueryTypes = URLSearchParams | string[][] | Record<string, any> | string | undefined;
4878
+ export declare type QueryTypes = URLSearchParams | string[][] | Record<string, string | number | boolean | undefined> | string | undefined;
4821
4879
 
4822
4880
  /**
4823
4881
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
@@ -5389,6 +5447,8 @@ export declare class UnionAtom extends InfixOperatorAtom {
5389
5447
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
5390
5448
  }
5391
5449
 
5450
+ export declare const VALID_HOSTNAME_REGEX: RegExp;
5451
+
5392
5452
  /**
5393
5453
  * Validates that a `SubscriptionRequest`.
5394
5454
  *
@@ -6,6 +6,7 @@ import { Address } from '@medplum/fhirtypes';
6
6
  import { Agent } from '@medplum/fhirtypes';
7
7
  import { Attachment } from '@medplum/fhirtypes';
8
8
  import { Binary } from '@medplum/fhirtypes';
9
+ import { Bot } from '@medplum/fhirtypes';
9
10
  import { BulkDataExport } from '@medplum/fhirtypes';
10
11
  import { Bundle } from '@medplum/fhirtypes';
11
12
  import { CodeableConcept } from '@medplum/fhirtypes';
@@ -107,6 +108,7 @@ export declare interface AgentHeartbeatRequest extends BaseAgentRequestMessage {
107
108
 
108
109
  export declare interface AgentHeartbeatResponse extends BaseAgentMessage {
109
110
  type: 'agent:heartbeat:response';
111
+ version: string;
110
112
  }
111
113
 
112
114
  export declare type AgentMessage = AgentError | AgentConnectRequest | AgentConnectResponse | AgentHeartbeatRequest | AgentHeartbeatResponse | AgentTransmitRequest | AgentTransmitResponse;
@@ -124,6 +126,7 @@ export declare interface AgentTransmitResponse extends BaseAgentMessage {
124
126
  channel?: string;
125
127
  remote: string;
126
128
  contentType: string;
129
+ statusCode?: number;
127
130
  body: string;
128
131
  }
129
132
 
@@ -261,6 +264,7 @@ export declare abstract class BooleanInfixOperatorAtom extends InfixOperatorAtom
261
264
  export declare function booleanToTypedValue(value: boolean): [TypedValue];
262
265
 
263
266
  export declare interface BotEvent<T = Resource | Hl7Message | string | Record<string, any>> {
267
+ readonly bot: Reference<Bot>;
264
268
  readonly contentType: string;
265
269
  readonly input: T;
266
270
  readonly secrets: Record<string, ProjectSecret>;
@@ -1439,6 +1443,14 @@ export declare function getPathDisplayName(path: string): string;
1439
1443
  */
1440
1444
  export declare function getPropertyDisplayName(propertyName: string): string;
1441
1445
 
1446
+ /**
1447
+ * Converts the given `query` to a string.
1448
+ *
1449
+ * @param query - The query to convert. The type can be any member of `QueryTypes`.
1450
+ * @returns The query as a string.
1451
+ */
1452
+ export declare function getQueryString(query: QueryTypes): string;
1453
+
1442
1454
  /**
1443
1455
  * Returns all questionnaire answers as a map by link ID.
1444
1456
  * @param response - The questionnaire response resource.
@@ -1527,6 +1539,13 @@ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue,
1527
1539
 
1528
1540
  export declare function getValueSliceName(value: any, slices: SliceDefinitionWithTypes[], discriminators: SliceDiscriminator[], profileUrl: string | undefined): string | undefined;
1529
1541
 
1542
+ /**
1543
+ * Concatenates a given base URL and path, ensuring the URL has the appropriate `ws://` or `wss://` protocol instead of `http://` or `https://`.
1544
+ *
1545
+ * @param baseUrl - The base URL.
1546
+ * @param path - The URL to concat. Can be relative or absolute.
1547
+ * @returns The concatenated WebSocket URL.
1548
+ */
1530
1549
  export declare function getWebSocketUrl(baseUrl: URL | string, path: string): string;
1531
1550
 
1532
1551
  /**
@@ -2166,6 +2185,34 @@ export declare function isUUID(input: string): input is string;
2166
2185
  */
2167
2186
  export declare function isValidDate(date: Date): boolean;
2168
2187
 
2188
+ /**
2189
+ * Tests whether a given input is a valid hostname.
2190
+ *
2191
+ * __NOTE: Does not validate that the input is a valid domain name, only a valid hostname.__
2192
+ *
2193
+ * @param input - The input to test.
2194
+ * @returns True if `input` is a valid hostname, otherwise returns false.
2195
+ *
2196
+ * ### Valid matches:
2197
+ * - foo
2198
+ * - foo.com
2199
+ * - foo.bar.com
2200
+ * - foo.org
2201
+ * - foo.bar.co.uk
2202
+ * - localhost
2203
+ * - LOCALHOST
2204
+ * - foo-bar-baz
2205
+ * - foo_bar
2206
+ * - foobar123
2207
+ *
2208
+ * ### Invalid matches:
2209
+ * - foo.com/bar
2210
+ * - https://foo.com
2211
+ * - foo_-bar_-
2212
+ * - foo | rm -rf /
2213
+ */
2214
+ export declare function isValidHostname(input: string): boolean;
2215
+
2169
2216
  /**
2170
2217
  * Memoizes the result of a parameterless function
2171
2218
  * @param fn - The function to be wrapped
@@ -2363,7 +2410,7 @@ export declare function matchesSearchRequest(resource: Resource, searchRequest:
2363
2410
 
2364
2411
  export declare const MEDPLUM_CLI_CLIENT_ID = "medplum-cli";
2365
2412
 
2366
- export declare const MEDPLUM_VERSION: any;
2413
+ export declare const MEDPLUM_VERSION: string;
2367
2414
 
2368
2415
  /**
2369
2416
  * The MedplumClient class provides a client for the Medplum FHIR server.
@@ -3052,6 +3099,15 @@ export declare class MedplumClient extends EventTarget_2 {
3052
3099
  * @returns The result of the create operation.
3053
3100
  */
3054
3101
  createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: MedplumRequestOptions): Promise<T>;
3102
+ /**
3103
+ * Upsert a resource: update it in place if it exists, otherwise create it. This is done in a single, transactional
3104
+ * request to guarantee data consistency.
3105
+ * @param resource - The resource to update or create.
3106
+ * @param query - A FHIR search query to uniquely identify the resource if it already exists.
3107
+ * @param options - Optional fetch options.
3108
+ * @returns The updated/created resource.
3109
+ */
3110
+ upsertResource<T extends Resource>(resource: T, query: QueryTypes, options?: MedplumRequestOptions): Promise<T>;
3055
3111
  /**
3056
3112
  * Creates a FHIR `Attachment` with the provided data content.
3057
3113
  *
@@ -4302,6 +4358,8 @@ export declare class MockAsyncClientStorage extends ClientStorage implements ICl
4302
4358
  get isInitialized(): boolean;
4303
4359
  }
4304
4360
 
4361
+ export declare const multipleMatches: OperationOutcome;
4362
+
4305
4363
  export declare interface NewPatientRequest {
4306
4364
  readonly login: string;
4307
4365
  readonly projectId: string;
@@ -4817,7 +4875,7 @@ export declare const protectedResourceTypes: string[];
4817
4875
  * Web browsers and Node.js automatically coerce values to strings.
4818
4876
  * See: https://github.com/microsoft/TypeScript/issues/32951
4819
4877
  */
4820
- export declare type QueryTypes = URLSearchParams | string[][] | Record<string, any> | string | undefined;
4878
+ export declare type QueryTypes = URLSearchParams | string[][] | Record<string, string | number | boolean | undefined> | string | undefined;
4821
4879
 
4822
4880
  /**
4823
4881
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
@@ -5389,6 +5447,8 @@ export declare class UnionAtom extends InfixOperatorAtom {
5389
5447
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
5390
5448
  }
5391
5449
 
5450
+ export declare const VALID_HOSTNAME_REGEX: RegExp;
5451
+
5392
5452
  /**
5393
5453
  * Validates that a `SubscriptionRequest`.
5394
5454
  *