@medplum/core 5.0.8 → 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.
@@ -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.
@@ -4789,10 +4806,46 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4789
4806
  * @param clientSecret - The client secret.
4790
4807
  */
4791
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;
4792
4843
  /**
4793
4844
  * Sets the verbose mode for the client.
4794
4845
  * When verbose is enabled, the client will log all requests and responses to the console.
4795
4846
  *
4847
+ * @deprecated Use setLogLevel instead. This method will be removed in a future version.
4848
+ *
4796
4849
  * @example
4797
4850
  * ```typescript
4798
4851
  * medplum.setVerbose(true);
@@ -5172,8 +5225,18 @@ export declare interface MedplumClientOptions {
5172
5225
  redirect?: RequestRedirect;
5173
5226
  /**
5174
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.
5175
5229
  */
5176
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;
5177
5240
  /**
5178
5241
  * Optional flag to enable or disable Medplum extended mode.
5179
5242
  *
@@ -5902,6 +5965,14 @@ export declare class ParserBuilder {
5902
5965
  readonly value?: any;
5903
5966
  }
5904
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
+
5905
5976
  export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
5906
5977
 
5907
5978
  /**
@@ -6310,9 +6381,9 @@ export declare class ParserBuilder {
6310
6381
  *
6311
6382
  * Note that the spec says:
6312
6383
  *
6313
- * > Individual hooks specify which of their `context` fields can be used as prefetch tokens.
6314
- * > Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
6315
- * > For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
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.
6316
6387
  *
6317
6388
  * Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
6318
6389
  *
@@ -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.
@@ -4789,10 +4806,46 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4789
4806
  * @param clientSecret - The client secret.
4790
4807
  */
4791
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;
4792
4843
  /**
4793
4844
  * Sets the verbose mode for the client.
4794
4845
  * When verbose is enabled, the client will log all requests and responses to the console.
4795
4846
  *
4847
+ * @deprecated Use setLogLevel instead. This method will be removed in a future version.
4848
+ *
4796
4849
  * @example
4797
4850
  * ```typescript
4798
4851
  * medplum.setVerbose(true);
@@ -5172,8 +5225,18 @@ export declare interface MedplumClientOptions {
5172
5225
  redirect?: RequestRedirect;
5173
5226
  /**
5174
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.
5175
5229
  */
5176
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;
5177
5240
  /**
5178
5241
  * Optional flag to enable or disable Medplum extended mode.
5179
5242
  *
@@ -5902,6 +5965,14 @@ export declare class ParserBuilder {
5902
5965
  readonly value?: any;
5903
5966
  }
5904
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
+
5905
5976
  export declare type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
5906
5977
 
5907
5978
  /**
@@ -6310,9 +6381,9 @@ export declare class ParserBuilder {
6310
6381
  *
6311
6382
  * Note that the spec says:
6312
6383
  *
6313
- * > Individual hooks specify which of their `context` fields can be used as prefetch tokens.
6314
- * > Only root-level fields with a primitive value within the `context` object are eligible to be used as prefetch tokens.
6315
- * > For example, `{{context.medication.id}}` is not a valid prefetch token because it attempts to access the `id` field of the `medication` field.
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.
6316
6387
  *
6317
6388
  * Unfortunately, many CDS Hooks services do not follow this rule. Therefore, this implementation allows access to nested fields.
6318
6389
  *