@medplum/core 5.0.7 → 5.0.9
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 +7 -7
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/cjs/index.d.ts +96 -0
- package/dist/esm/index.d.ts +96 -0
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/index.mjs.map +3 -3
- package/package.json +3 -3
package/dist/cjs/index.d.ts
CHANGED
|
@@ -266,6 +266,8 @@ export declare function arrayBufferToBase64(arrayBuffer: ArrayBufferLike | Array
|
|
|
266
266
|
*/
|
|
267
267
|
export declare function arrayBufferToHex(arrayBuffer: ArrayBufferLike | ArrayBufferView): string;
|
|
268
268
|
|
|
269
|
+
export declare function arrayify<T>(value: NonNullable<T> | NonNullable<T>[]): T[];
|
|
270
|
+
|
|
269
271
|
export declare function arrayify<T>(value: T | T[] | undefined): T[] | undefined;
|
|
270
272
|
|
|
271
273
|
export declare class AsAtom extends InfixOperatorAtom {
|
|
@@ -629,6 +631,14 @@ export declare function checkIfValidMedplumVersion(appName: string, version: str
|
|
|
629
631
|
*/
|
|
630
632
|
export declare function clearReleaseCache(): void;
|
|
631
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Log level for MedplumClient requests and responses.
|
|
636
|
+
* - 'none': No logging
|
|
637
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
638
|
+
* - 'verbose': Log all details including headers (may include sensitive data)
|
|
639
|
+
*/
|
|
640
|
+
export declare type ClientLogLevel = 'none' | 'basic' | 'verbose';
|
|
641
|
+
|
|
632
642
|
/**
|
|
633
643
|
* The ClientStorage class is a utility class for storing strings and objects.
|
|
634
644
|
*
|
|
@@ -3406,6 +3416,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3406
3416
|
private initPromise;
|
|
3407
3417
|
private initComplete;
|
|
3408
3418
|
private keyValueClient?;
|
|
3419
|
+
private logLevel;
|
|
3409
3420
|
constructor(options?: MedplumClientOptions);
|
|
3410
3421
|
/**
|
|
3411
3422
|
* @returns Whether the client has been fully initialized or not. Should always be true unless a custom asynchronous `ClientStorage` was passed into the constructor.
|
|
@@ -3416,6 +3427,12 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3416
3427
|
* @returns A Promise that resolves when any async initialization of the client is finished.
|
|
3417
3428
|
*/
|
|
3418
3429
|
getInitPromise(): Promise<void>;
|
|
3430
|
+
/**
|
|
3431
|
+
* Initializes the log level with backward compatibility for the verbose option.
|
|
3432
|
+
* @param options - The client options.
|
|
3433
|
+
* @returns The initialized log level.
|
|
3434
|
+
*/
|
|
3435
|
+
private initializeLogLevel;
|
|
3419
3436
|
private attemptResumeActiveLogin;
|
|
3420
3437
|
/**
|
|
3421
3438
|
* Returns the current base URL for all API requests.
|
|
@@ -3869,6 +3886,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3869
3886
|
* @returns The resource if available.
|
|
3870
3887
|
*/
|
|
3871
3888
|
readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<WithId<T>>;
|
|
3889
|
+
readCanonical<RT extends ResourceType>(resourceType: RT | RT[], url: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
|
|
3872
3890
|
/**
|
|
3873
3891
|
* Requests the schema for a resource type.
|
|
3874
3892
|
* If the schema is already cached, the promise is resolved immediately.
|
|
@@ -4788,10 +4806,46 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
4788
4806
|
* @param clientSecret - The client secret.
|
|
4789
4807
|
*/
|
|
4790
4808
|
setBasicAuth(clientId: string, clientSecret: string): void;
|
|
4809
|
+
/**
|
|
4810
|
+
* Sets the log level for the client.
|
|
4811
|
+
* - 'none': No logging
|
|
4812
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
4813
|
+
* - 'verbose': Log all details including headers (may include sensitive data)
|
|
4814
|
+
*
|
|
4815
|
+
* @example
|
|
4816
|
+
* ```typescript
|
|
4817
|
+
* // Basic logging for production
|
|
4818
|
+
* medplum.setLogLevel('basic');
|
|
4819
|
+
* await medplum.searchResources('Patient');
|
|
4820
|
+
* // Output:
|
|
4821
|
+
* // > GET https://api.medplum.com/fhir/R4/Patient
|
|
4822
|
+
* // < 200 OK
|
|
4823
|
+
* ```
|
|
4824
|
+
*
|
|
4825
|
+
* @example
|
|
4826
|
+
* ```typescript
|
|
4827
|
+
* // Verbose logging for debugging
|
|
4828
|
+
* medplum.setLogLevel('verbose');
|
|
4829
|
+
* await medplum.searchResources('Patient');
|
|
4830
|
+
* // Output includes all headers
|
|
4831
|
+
* ```
|
|
4832
|
+
*
|
|
4833
|
+
* @category HTTP
|
|
4834
|
+
* @param level - The log level to set.
|
|
4835
|
+
*/
|
|
4836
|
+
setLogLevel(level: ClientLogLevel): void;
|
|
4837
|
+
/**
|
|
4838
|
+
* Gets the current log level.
|
|
4839
|
+
* @category HTTP
|
|
4840
|
+
* @returns The current log level.
|
|
4841
|
+
*/
|
|
4842
|
+
getLogLevel(): ClientLogLevel;
|
|
4791
4843
|
/**
|
|
4792
4844
|
* Sets the verbose mode for the client.
|
|
4793
4845
|
* When verbose is enabled, the client will log all requests and responses to the console.
|
|
4794
4846
|
*
|
|
4847
|
+
* @deprecated Use setLogLevel instead. This method will be removed in a future version.
|
|
4848
|
+
*
|
|
4795
4849
|
* @example
|
|
4796
4850
|
* ```typescript
|
|
4797
4851
|
* medplum.setVerbose(true);
|
|
@@ -5171,8 +5225,18 @@ export declare interface MedplumClientOptions {
|
|
|
5171
5225
|
redirect?: RequestRedirect;
|
|
5172
5226
|
/**
|
|
5173
5227
|
* When the verbose flag is set, the client will log all requests and responses to the console.
|
|
5228
|
+
* @deprecated Use logLevel instead. Will be removed in a future version.
|
|
5174
5229
|
*/
|
|
5175
5230
|
verbose?: boolean;
|
|
5231
|
+
/**
|
|
5232
|
+
* Log level for requests and responses.
|
|
5233
|
+
* - 'none': No logging (default)
|
|
5234
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
5235
|
+
* - 'verbose': Log all details including headers (may include sensitive data like tokens)
|
|
5236
|
+
*
|
|
5237
|
+
* @default 'none'
|
|
5238
|
+
*/
|
|
5239
|
+
logLevel?: ClientLogLevel;
|
|
5176
5240
|
/**
|
|
5177
5241
|
* Optional flag to enable or disable Medplum extended mode.
|
|
5178
5242
|
*
|
|
@@ -5901,6 +5965,14 @@ export declare class ParserBuilder {
|
|
|
5901
5965
|
readonly value?: any;
|
|
5902
5966
|
}
|
|
5903
5967
|
|
|
5968
|
+
/**
|
|
5969
|
+
* Translates a path emitted by this crawler into an RFC6902 JSON Patch pointer
|
|
5970
|
+
*
|
|
5971
|
+
* @param path - A path emitted from a Crawler
|
|
5972
|
+
* @returns pointer -An RFC6902 pointer describing the path
|
|
5973
|
+
*/
|
|
5974
|
+
export declare function pathToJSONPointer(path: string): string;
|
|
5975
|
+
|
|
5904
5976
|
export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
|
|
5905
5977
|
|
|
5906
5978
|
/**
|
|
@@ -6298,6 +6370,30 @@ export declare class ParserBuilder {
|
|
|
6298
6370
|
*/
|
|
6299
6371
|
export declare function reorderBundle(bundle: Bundle): Bundle;
|
|
6300
6372
|
|
|
6373
|
+
/**
|
|
6374
|
+
* Replaces prefetch query variables with values from the context or user profile.
|
|
6375
|
+
*
|
|
6376
|
+
* A prefetch token is a placeholder in a prefetch template that is *replaced by information from the hook's context*
|
|
6377
|
+
* to construct the FHIR URL used to request the prefetch data.
|
|
6378
|
+
*
|
|
6379
|
+
* Prefetch tokens MUST be delimited by `{{` and `}}`, and MUST contain only the qualified path to a hook context field
|
|
6380
|
+
* or one of the following user identifiers: `userPractitionerId`, `userPractitionerRoleId`, `userPatientId`, or `userRelatedPersonId`.
|
|
6381
|
+
*
|
|
6382
|
+
* Note that the spec says:
|
|
6383
|
+
*
|
|
6384
|
+
* Individual hooks specify which of their `context` fields can be used as prefetch tokens.
|
|
6385
|
+
* Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
|
|
6386
|
+
* For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
|
|
6387
|
+
*
|
|
6388
|
+
* Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
|
|
6389
|
+
*
|
|
6390
|
+
* @param user - The user resource.
|
|
6391
|
+
* @param context - The CDS request context.
|
|
6392
|
+
* @param query - The prefetch query template.
|
|
6393
|
+
* @returns The prefetch query with variables replaced.
|
|
6394
|
+
*/
|
|
6395
|
+
export declare function replaceQueryVariables(user: CdsUserResource, context: Record<string, unknown>, query: string): string;
|
|
6396
|
+
|
|
6301
6397
|
export declare interface RequestProfileSchemaOptions {
|
|
6302
6398
|
/** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
|
|
6303
6399
|
expandProfile?: boolean;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -266,6 +266,8 @@ export declare function arrayBufferToBase64(arrayBuffer: ArrayBufferLike | Array
|
|
|
266
266
|
*/
|
|
267
267
|
export declare function arrayBufferToHex(arrayBuffer: ArrayBufferLike | ArrayBufferView): string;
|
|
268
268
|
|
|
269
|
+
export declare function arrayify<T>(value: NonNullable<T> | NonNullable<T>[]): T[];
|
|
270
|
+
|
|
269
271
|
export declare function arrayify<T>(value: T | T[] | undefined): T[] | undefined;
|
|
270
272
|
|
|
271
273
|
export declare class AsAtom extends InfixOperatorAtom {
|
|
@@ -629,6 +631,14 @@ export declare function checkIfValidMedplumVersion(appName: string, version: str
|
|
|
629
631
|
*/
|
|
630
632
|
export declare function clearReleaseCache(): void;
|
|
631
633
|
|
|
634
|
+
/**
|
|
635
|
+
* Log level for MedplumClient requests and responses.
|
|
636
|
+
* - 'none': No logging
|
|
637
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
638
|
+
* - 'verbose': Log all details including headers (may include sensitive data)
|
|
639
|
+
*/
|
|
640
|
+
export declare type ClientLogLevel = 'none' | 'basic' | 'verbose';
|
|
641
|
+
|
|
632
642
|
/**
|
|
633
643
|
* The ClientStorage class is a utility class for storing strings and objects.
|
|
634
644
|
*
|
|
@@ -3406,6 +3416,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3406
3416
|
private initPromise;
|
|
3407
3417
|
private initComplete;
|
|
3408
3418
|
private keyValueClient?;
|
|
3419
|
+
private logLevel;
|
|
3409
3420
|
constructor(options?: MedplumClientOptions);
|
|
3410
3421
|
/**
|
|
3411
3422
|
* @returns Whether the client has been fully initialized or not. Should always be true unless a custom asynchronous `ClientStorage` was passed into the constructor.
|
|
@@ -3416,6 +3427,12 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3416
3427
|
* @returns A Promise that resolves when any async initialization of the client is finished.
|
|
3417
3428
|
*/
|
|
3418
3429
|
getInitPromise(): Promise<void>;
|
|
3430
|
+
/**
|
|
3431
|
+
* Initializes the log level with backward compatibility for the verbose option.
|
|
3432
|
+
* @param options - The client options.
|
|
3433
|
+
* @returns The initialized log level.
|
|
3434
|
+
*/
|
|
3435
|
+
private initializeLogLevel;
|
|
3419
3436
|
private attemptResumeActiveLogin;
|
|
3420
3437
|
/**
|
|
3421
3438
|
* Returns the current base URL for all API requests.
|
|
@@ -3869,6 +3886,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
3869
3886
|
* @returns The resource if available.
|
|
3870
3887
|
*/
|
|
3871
3888
|
readReference<T extends Resource>(reference: Reference<T>, options?: MedplumRequestOptions): ReadablePromise<WithId<T>>;
|
|
3889
|
+
readCanonical<RT extends ResourceType>(resourceType: RT | RT[], url: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
|
|
3872
3890
|
/**
|
|
3873
3891
|
* Requests the schema for a resource type.
|
|
3874
3892
|
* If the schema is already cached, the promise is resolved immediately.
|
|
@@ -4788,10 +4806,46 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
|
|
|
4788
4806
|
* @param clientSecret - The client secret.
|
|
4789
4807
|
*/
|
|
4790
4808
|
setBasicAuth(clientId: string, clientSecret: string): void;
|
|
4809
|
+
/**
|
|
4810
|
+
* Sets the log level for the client.
|
|
4811
|
+
* - 'none': No logging
|
|
4812
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
4813
|
+
* - 'verbose': Log all details including headers (may include sensitive data)
|
|
4814
|
+
*
|
|
4815
|
+
* @example
|
|
4816
|
+
* ```typescript
|
|
4817
|
+
* // Basic logging for production
|
|
4818
|
+
* medplum.setLogLevel('basic');
|
|
4819
|
+
* await medplum.searchResources('Patient');
|
|
4820
|
+
* // Output:
|
|
4821
|
+
* // > GET https://api.medplum.com/fhir/R4/Patient
|
|
4822
|
+
* // < 200 OK
|
|
4823
|
+
* ```
|
|
4824
|
+
*
|
|
4825
|
+
* @example
|
|
4826
|
+
* ```typescript
|
|
4827
|
+
* // Verbose logging for debugging
|
|
4828
|
+
* medplum.setLogLevel('verbose');
|
|
4829
|
+
* await medplum.searchResources('Patient');
|
|
4830
|
+
* // Output includes all headers
|
|
4831
|
+
* ```
|
|
4832
|
+
*
|
|
4833
|
+
* @category HTTP
|
|
4834
|
+
* @param level - The log level to set.
|
|
4835
|
+
*/
|
|
4836
|
+
setLogLevel(level: ClientLogLevel): void;
|
|
4837
|
+
/**
|
|
4838
|
+
* Gets the current log level.
|
|
4839
|
+
* @category HTTP
|
|
4840
|
+
* @returns The current log level.
|
|
4841
|
+
*/
|
|
4842
|
+
getLogLevel(): ClientLogLevel;
|
|
4791
4843
|
/**
|
|
4792
4844
|
* Sets the verbose mode for the client.
|
|
4793
4845
|
* When verbose is enabled, the client will log all requests and responses to the console.
|
|
4794
4846
|
*
|
|
4847
|
+
* @deprecated Use setLogLevel instead. This method will be removed in a future version.
|
|
4848
|
+
*
|
|
4795
4849
|
* @example
|
|
4796
4850
|
* ```typescript
|
|
4797
4851
|
* medplum.setVerbose(true);
|
|
@@ -5171,8 +5225,18 @@ export declare interface MedplumClientOptions {
|
|
|
5171
5225
|
redirect?: RequestRedirect;
|
|
5172
5226
|
/**
|
|
5173
5227
|
* When the verbose flag is set, the client will log all requests and responses to the console.
|
|
5228
|
+
* @deprecated Use logLevel instead. Will be removed in a future version.
|
|
5174
5229
|
*/
|
|
5175
5230
|
verbose?: boolean;
|
|
5231
|
+
/**
|
|
5232
|
+
* Log level for requests and responses.
|
|
5233
|
+
* - 'none': No logging (default)
|
|
5234
|
+
* - 'basic': Log method, URL, and status code only (no sensitive headers)
|
|
5235
|
+
* - 'verbose': Log all details including headers (may include sensitive data like tokens)
|
|
5236
|
+
*
|
|
5237
|
+
* @default 'none'
|
|
5238
|
+
*/
|
|
5239
|
+
logLevel?: ClientLogLevel;
|
|
5176
5240
|
/**
|
|
5177
5241
|
* Optional flag to enable or disable Medplum extended mode.
|
|
5178
5242
|
*
|
|
@@ -5901,6 +5965,14 @@ export declare class ParserBuilder {
|
|
|
5901
5965
|
readonly value?: any;
|
|
5902
5966
|
}
|
|
5903
5967
|
|
|
5968
|
+
/**
|
|
5969
|
+
* Translates a path emitted by this crawler into an RFC6902 JSON Patch pointer
|
|
5970
|
+
*
|
|
5971
|
+
* @param path - A path emitted from a Crawler
|
|
5972
|
+
* @returns pointer -An RFC6902 pointer describing the path
|
|
5973
|
+
*/
|
|
5974
|
+
export declare function pathToJSONPointer(path: string): string;
|
|
5975
|
+
|
|
5904
5976
|
export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
|
|
5905
5977
|
|
|
5906
5978
|
/**
|
|
@@ -6298,6 +6370,30 @@ export declare class ParserBuilder {
|
|
|
6298
6370
|
*/
|
|
6299
6371
|
export declare function reorderBundle(bundle: Bundle): Bundle;
|
|
6300
6372
|
|
|
6373
|
+
/**
|
|
6374
|
+
* Replaces prefetch query variables with values from the context or user profile.
|
|
6375
|
+
*
|
|
6376
|
+
* A prefetch token is a placeholder in a prefetch template that is *replaced by information from the hook's context*
|
|
6377
|
+
* to construct the FHIR URL used to request the prefetch data.
|
|
6378
|
+
*
|
|
6379
|
+
* Prefetch tokens MUST be delimited by `{{` and `}}`, and MUST contain only the qualified path to a hook context field
|
|
6380
|
+
* or one of the following user identifiers: `userPractitionerId`, `userPractitionerRoleId`, `userPatientId`, or `userRelatedPersonId`.
|
|
6381
|
+
*
|
|
6382
|
+
* Note that the spec says:
|
|
6383
|
+
*
|
|
6384
|
+
* Individual hooks specify which of their `context` fields can be used as prefetch tokens.
|
|
6385
|
+
* Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
|
|
6386
|
+
* For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
|
|
6387
|
+
*
|
|
6388
|
+
* Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
|
|
6389
|
+
*
|
|
6390
|
+
* @param user - The user resource.
|
|
6391
|
+
* @param context - The CDS request context.
|
|
6392
|
+
* @param query - The prefetch query template.
|
|
6393
|
+
* @returns The prefetch query with variables replaced.
|
|
6394
|
+
*/
|
|
6395
|
+
export declare function replaceQueryVariables(user: CdsUserResource, context: Record<string, unknown>, query: string): string;
|
|
6396
|
+
|
|
6301
6397
|
export declare interface RequestProfileSchemaOptions {
|
|
6302
6398
|
/** (optional) Whether to include nested profiles, e.g. from extensions. Defaults to false. */
|
|
6303
6399
|
expandProfile?: boolean;
|