@medplum/core 3.1.2 → 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.
@@ -108,6 +108,7 @@ export declare interface AgentHeartbeatRequest extends BaseAgentRequestMessage {
108
108
 
109
109
  export declare interface AgentHeartbeatResponse extends BaseAgentMessage {
110
110
  type: 'agent:heartbeat:response';
111
+ version: string;
111
112
  }
112
113
 
113
114
  export declare type AgentMessage = AgentError | AgentConnectRequest | AgentConnectResponse | AgentHeartbeatRequest | AgentHeartbeatResponse | AgentTransmitRequest | AgentTransmitResponse;
@@ -125,6 +126,7 @@ export declare interface AgentTransmitResponse extends BaseAgentMessage {
125
126
  channel?: string;
126
127
  remote: string;
127
128
  contentType: string;
129
+ statusCode?: number;
128
130
  body: string;
129
131
  }
130
132
 
@@ -1441,6 +1443,14 @@ export declare function getPathDisplayName(path: string): string;
1441
1443
  */
1442
1444
  export declare function getPropertyDisplayName(propertyName: string): string;
1443
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
+
1444
1454
  /**
1445
1455
  * Returns all questionnaire answers as a map by link ID.
1446
1456
  * @param response - The questionnaire response resource.
@@ -1529,6 +1539,13 @@ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue,
1529
1539
 
1530
1540
  export declare function getValueSliceName(value: any, slices: SliceDefinitionWithTypes[], discriminators: SliceDiscriminator[], profileUrl: string | undefined): string | undefined;
1531
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
+ */
1532
1549
  export declare function getWebSocketUrl(baseUrl: URL | string, path: string): string;
1533
1550
 
1534
1551
  /**
@@ -2168,6 +2185,34 @@ export declare function isUUID(input: string): input is string;
2168
2185
  */
2169
2186
  export declare function isValidDate(date: Date): boolean;
2170
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
+
2171
2216
  /**
2172
2217
  * Memoizes the result of a parameterless function
2173
2218
  * @param fn - The function to be wrapped
@@ -2365,7 +2410,7 @@ export declare function matchesSearchRequest(resource: Resource, searchRequest:
2365
2410
 
2366
2411
  export declare const MEDPLUM_CLI_CLIENT_ID = "medplum-cli";
2367
2412
 
2368
- export declare const MEDPLUM_VERSION: any;
2413
+ export declare const MEDPLUM_VERSION: string;
2369
2414
 
2370
2415
  /**
2371
2416
  * The MedplumClient class provides a client for the Medplum FHIR server.
@@ -3054,6 +3099,15 @@ export declare class MedplumClient extends EventTarget_2 {
3054
3099
  * @returns The result of the create operation.
3055
3100
  */
3056
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>;
3057
3111
  /**
3058
3112
  * Creates a FHIR `Attachment` with the provided data content.
3059
3113
  *
@@ -4304,6 +4358,8 @@ export declare class MockAsyncClientStorage extends ClientStorage implements ICl
4304
4358
  get isInitialized(): boolean;
4305
4359
  }
4306
4360
 
4361
+ export declare const multipleMatches: OperationOutcome;
4362
+
4307
4363
  export declare interface NewPatientRequest {
4308
4364
  readonly login: string;
4309
4365
  readonly projectId: string;
@@ -4819,7 +4875,7 @@ export declare const protectedResourceTypes: string[];
4819
4875
  * Web browsers and Node.js automatically coerce values to strings.
4820
4876
  * See: https://github.com/microsoft/TypeScript/issues/32951
4821
4877
  */
4822
- 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;
4823
4879
 
4824
4880
  /**
4825
4881
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
@@ -5391,6 +5447,8 @@ export declare class UnionAtom extends InfixOperatorAtom {
5391
5447
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
5392
5448
  }
5393
5449
 
5450
+ export declare const VALID_HOSTNAME_REGEX: RegExp;
5451
+
5394
5452
  /**
5395
5453
  * Validates that a `SubscriptionRequest`.
5396
5454
  *
@@ -108,6 +108,7 @@ export declare interface AgentHeartbeatRequest extends BaseAgentRequestMessage {
108
108
 
109
109
  export declare interface AgentHeartbeatResponse extends BaseAgentMessage {
110
110
  type: 'agent:heartbeat:response';
111
+ version: string;
111
112
  }
112
113
 
113
114
  export declare type AgentMessage = AgentError | AgentConnectRequest | AgentConnectResponse | AgentHeartbeatRequest | AgentHeartbeatResponse | AgentTransmitRequest | AgentTransmitResponse;
@@ -125,6 +126,7 @@ export declare interface AgentTransmitResponse extends BaseAgentMessage {
125
126
  channel?: string;
126
127
  remote: string;
127
128
  contentType: string;
129
+ statusCode?: number;
128
130
  body: string;
129
131
  }
130
132
 
@@ -1441,6 +1443,14 @@ export declare function getPathDisplayName(path: string): string;
1441
1443
  */
1442
1444
  export declare function getPropertyDisplayName(propertyName: string): string;
1443
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
+
1444
1454
  /**
1445
1455
  * Returns all questionnaire answers as a map by link ID.
1446
1456
  * @param response - The questionnaire response resource.
@@ -1529,6 +1539,13 @@ export declare function getTypedPropertyValueWithSchema(typedValue: TypedValue,
1529
1539
 
1530
1540
  export declare function getValueSliceName(value: any, slices: SliceDefinitionWithTypes[], discriminators: SliceDiscriminator[], profileUrl: string | undefined): string | undefined;
1531
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
+ */
1532
1549
  export declare function getWebSocketUrl(baseUrl: URL | string, path: string): string;
1533
1550
 
1534
1551
  /**
@@ -2168,6 +2185,34 @@ export declare function isUUID(input: string): input is string;
2168
2185
  */
2169
2186
  export declare function isValidDate(date: Date): boolean;
2170
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
+
2171
2216
  /**
2172
2217
  * Memoizes the result of a parameterless function
2173
2218
  * @param fn - The function to be wrapped
@@ -2365,7 +2410,7 @@ export declare function matchesSearchRequest(resource: Resource, searchRequest:
2365
2410
 
2366
2411
  export declare const MEDPLUM_CLI_CLIENT_ID = "medplum-cli";
2367
2412
 
2368
- export declare const MEDPLUM_VERSION: any;
2413
+ export declare const MEDPLUM_VERSION: string;
2369
2414
 
2370
2415
  /**
2371
2416
  * The MedplumClient class provides a client for the Medplum FHIR server.
@@ -3054,6 +3099,15 @@ export declare class MedplumClient extends EventTarget_2 {
3054
3099
  * @returns The result of the create operation.
3055
3100
  */
3056
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>;
3057
3111
  /**
3058
3112
  * Creates a FHIR `Attachment` with the provided data content.
3059
3113
  *
@@ -4304,6 +4358,8 @@ export declare class MockAsyncClientStorage extends ClientStorage implements ICl
4304
4358
  get isInitialized(): boolean;
4305
4359
  }
4306
4360
 
4361
+ export declare const multipleMatches: OperationOutcome;
4362
+
4307
4363
  export declare interface NewPatientRequest {
4308
4364
  readonly login: string;
4309
4365
  readonly projectId: string;
@@ -4819,7 +4875,7 @@ export declare const protectedResourceTypes: string[];
4819
4875
  * Web browsers and Node.js automatically coerce values to strings.
4820
4876
  * See: https://github.com/microsoft/TypeScript/issues/32951
4821
4877
  */
4822
- 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;
4823
4879
 
4824
4880
  /**
4825
4881
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
@@ -5391,6 +5447,8 @@ export declare class UnionAtom extends InfixOperatorAtom {
5391
5447
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
5392
5448
  }
5393
5449
 
5450
+ export declare const VALID_HOSTNAME_REGEX: RegExp;
5451
+
5394
5452
  /**
5395
5453
  * Validates that a `SubscriptionRequest`.
5396
5454
  *