@medplum/core 5.1.17 → 5.1.21

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.
@@ -1825,6 +1825,32 @@ export declare function fhirPathIs(typedValue: TypedValue, desiredType: string):
1825
1825
  */
1826
1826
  export declare function fhirPathNot(input: TypedValue[]): TypedValue[];
1827
1827
 
1828
+ export declare type FhirPathPatch = {
1829
+ type: 'add';
1830
+ path: string;
1831
+ name: string;
1832
+ value: TypedValue;
1833
+ } | {
1834
+ type: 'insert';
1835
+ path: string;
1836
+ value: TypedValue;
1837
+ index: number;
1838
+ } | {
1839
+ type: 'delete';
1840
+ path: string;
1841
+ } | {
1842
+ type: 'replace';
1843
+ path: string;
1844
+ value: TypedValue;
1845
+ } | {
1846
+ type: 'move';
1847
+ path: string;
1848
+ source: number;
1849
+ destination: number;
1850
+ };
1851
+
1852
+ export declare function fhirpathPatchTypedValue(original: TypedValue, patch: FhirPathPatch[]): void;
1853
+
1828
1854
  export declare const fhirTypeToJsType: {
1829
1855
  readonly base64Binary: "string";
1830
1856
  readonly boolean: "boolean";
@@ -3355,31 +3381,40 @@ export declare function isValidMedplumSemver(version: string): boolean;
3355
3381
 
3356
3382
  /**
3357
3383
  * Generic interface that an implementation of `WebSocket` must satisfy to be used with `ReconnectingWebSocket`.
3358
- * This is a slightly modified fork of the `WebSocket` global type used in Node.
3384
+ * This is a slightly modified fork of the `WebSocket` global type used in Node, narrowed to exactly the members
3385
+ * `ReconnectingWebSocket` actually depends on.
3386
+ *
3387
+ * `addEventListener`/`removeEventListener` declare a typed overload against `IWebSocketEventMap` (the global event
3388
+ * interfaces, used here rather than the local `WebSocketEventMap` since they are generic enough to describe the
3389
+ * events `ReconnectingWebSocket` attaches to). They also declare the permissive string overload that the real
3390
+ * `WebSocket` types carry, which is what lets conformant implementations whose event types do not structurally
3391
+ * match the global ones (e.g. the `ws` library, whose events are a minimal subset and use `target: WebSocket`)
3392
+ * still satisfy this interface.
3393
+ *
3394
+ * The `onopen`/`onclose`/`onmessage`/`onerror` handler properties are intentionally omitted: `ReconnectingWebSocket`
3395
+ * never assigns to them (it uses `addEventListener`), and because they are function-valued properties their
3396
+ * parameters are checked contravariantly, which no single precise event type can satisfy across implementations
3397
+ * (e.g. `ws`'s events use `target: WebSocket` while the DOM's use `target: EventTarget | null`).
3359
3398
  *
3360
- * The main key difference is making all the `onclose`, `onerror`, etc. functions have `any[]` args, making `data` in `send()` of type `any`, and making `binaryType` of type string,
3361
- * though the particular implementation should narrow each of these implementation-specific types.
3399
+ * `binaryType` is widened to `string` and `send()` accepts the full `Message` union; a particular implementation
3400
+ * should narrow each of these implementation-specific types.
3362
3401
  */
3363
3402
  export declare interface IWebSocket {
3364
3403
  binaryType: string;
3365
3404
  readonly bufferedAmount: number;
3366
3405
  readonly extensions: string;
3367
- onclose: ((...args: any[]) => any) | null;
3368
- onerror: ((...args: any[]) => any) | null;
3369
- onmessage: ((...args: any[]) => any) | null;
3370
- onopen: ((...args: any[]) => any) | null;
3371
3406
  readonly protocol: string;
3372
3407
  readonly readyState: number;
3373
3408
  readonly url: string;
3374
3409
  close(code?: number, reason?: string): void;
3375
- send(data: any): void;
3410
+ send(data: Message): void;
3376
3411
  readonly CLOSED: number;
3377
3412
  readonly CLOSING: number;
3378
3413
  readonly CONNECTING: number;
3379
3414
  readonly OPEN: number;
3380
- addEventListener<K extends keyof WebSocketEventMap_2>(type: K, listener: (ev: WebSocketEventMap_2[K]) => any, options?: boolean | AddEventListenerOptions): void;
3415
+ addEventListener<K extends keyof IWebSocketEventMap>(type: K, listener: (event: IWebSocketEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
3381
3416
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
3382
- removeEventListener<K extends keyof WebSocketEventMap_2>(type: K, listener: (ev: WebSocketEventMap_2[K]) => any, options?: boolean | EventListenerOptions): void;
3417
+ removeEventListener<K extends keyof IWebSocketEventMap>(type: K, listener: (event: IWebSocketEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
3383
3418
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
3384
3419
  }
3385
3420
 
@@ -6407,6 +6442,22 @@ export declare function normalizeCreateBinaryOptions(arg1: BinarySource | Create
6407
6442
 
6408
6443
  export declare function normalizeCreatePdfOptions(arg1: TDocumentDefinitions | CreatePdfOptions, arg2: string | undefined | MedplumRequestOptions, arg3: Record<string, CustomTableLayout> | undefined, arg4: TFontDictionary | undefined): CreatePdfOptions;
6409
6444
 
6445
+ /**
6446
+ * Normalizes the various `error` event shapes dispatched by different `WebSocket` implementations
6447
+ * into a single `ErrorEvent` carrying a real `Error`, so downstream listeners always get `message`
6448
+ * and `error` regardless of the underlying implementation:
6449
+ *
6450
+ * - Browsers dispatch a plain `Event` with no error details (per the WHATWG WebSocket spec).
6451
+ * - Node's `ws` library and Node's built-in (undici) `WebSocket` dispatch an `ErrorEvent` with both
6452
+ * `message` and `error`.
6453
+ * - Bun dispatches a plain `Event` with a `message` string but no `error`.
6454
+ *
6455
+ * @param event - The `error` event as dispatched by the underlying `WebSocket`.
6456
+ * @param target - The `ReconnectingWebSocket` instance the normalized event is dispatched from.
6457
+ * @returns An `ErrorEvent` with a populated `message` and `error`.
6458
+ */
6459
+ export declare function normalizeErrorEvent(event: Event | ErrorEvent_2, target: unknown): ErrorEvent_2;
6460
+
6410
6461
  /**
6411
6462
  * Normalizes an error object into a displayable error string.
6412
6463
  * @param error - The error value which could be a string, Error, OperationOutcome, or other unknown type.
@@ -1825,6 +1825,32 @@ export declare function fhirPathIs(typedValue: TypedValue, desiredType: string):
1825
1825
  */
1826
1826
  export declare function fhirPathNot(input: TypedValue[]): TypedValue[];
1827
1827
 
1828
+ export declare type FhirPathPatch = {
1829
+ type: 'add';
1830
+ path: string;
1831
+ name: string;
1832
+ value: TypedValue;
1833
+ } | {
1834
+ type: 'insert';
1835
+ path: string;
1836
+ value: TypedValue;
1837
+ index: number;
1838
+ } | {
1839
+ type: 'delete';
1840
+ path: string;
1841
+ } | {
1842
+ type: 'replace';
1843
+ path: string;
1844
+ value: TypedValue;
1845
+ } | {
1846
+ type: 'move';
1847
+ path: string;
1848
+ source: number;
1849
+ destination: number;
1850
+ };
1851
+
1852
+ export declare function fhirpathPatchTypedValue(original: TypedValue, patch: FhirPathPatch[]): void;
1853
+
1828
1854
  export declare const fhirTypeToJsType: {
1829
1855
  readonly base64Binary: "string";
1830
1856
  readonly boolean: "boolean";
@@ -3355,31 +3381,40 @@ export declare function isValidMedplumSemver(version: string): boolean;
3355
3381
 
3356
3382
  /**
3357
3383
  * Generic interface that an implementation of `WebSocket` must satisfy to be used with `ReconnectingWebSocket`.
3358
- * This is a slightly modified fork of the `WebSocket` global type used in Node.
3384
+ * This is a slightly modified fork of the `WebSocket` global type used in Node, narrowed to exactly the members
3385
+ * `ReconnectingWebSocket` actually depends on.
3386
+ *
3387
+ * `addEventListener`/`removeEventListener` declare a typed overload against `IWebSocketEventMap` (the global event
3388
+ * interfaces, used here rather than the local `WebSocketEventMap` since they are generic enough to describe the
3389
+ * events `ReconnectingWebSocket` attaches to). They also declare the permissive string overload that the real
3390
+ * `WebSocket` types carry, which is what lets conformant implementations whose event types do not structurally
3391
+ * match the global ones (e.g. the `ws` library, whose events are a minimal subset and use `target: WebSocket`)
3392
+ * still satisfy this interface.
3393
+ *
3394
+ * The `onopen`/`onclose`/`onmessage`/`onerror` handler properties are intentionally omitted: `ReconnectingWebSocket`
3395
+ * never assigns to them (it uses `addEventListener`), and because they are function-valued properties their
3396
+ * parameters are checked contravariantly, which no single precise event type can satisfy across implementations
3397
+ * (e.g. `ws`'s events use `target: WebSocket` while the DOM's use `target: EventTarget | null`).
3359
3398
  *
3360
- * The main key difference is making all the `onclose`, `onerror`, etc. functions have `any[]` args, making `data` in `send()` of type `any`, and making `binaryType` of type string,
3361
- * though the particular implementation should narrow each of these implementation-specific types.
3399
+ * `binaryType` is widened to `string` and `send()` accepts the full `Message` union; a particular implementation
3400
+ * should narrow each of these implementation-specific types.
3362
3401
  */
3363
3402
  export declare interface IWebSocket {
3364
3403
  binaryType: string;
3365
3404
  readonly bufferedAmount: number;
3366
3405
  readonly extensions: string;
3367
- onclose: ((...args: any[]) => any) | null;
3368
- onerror: ((...args: any[]) => any) | null;
3369
- onmessage: ((...args: any[]) => any) | null;
3370
- onopen: ((...args: any[]) => any) | null;
3371
3406
  readonly protocol: string;
3372
3407
  readonly readyState: number;
3373
3408
  readonly url: string;
3374
3409
  close(code?: number, reason?: string): void;
3375
- send(data: any): void;
3410
+ send(data: Message): void;
3376
3411
  readonly CLOSED: number;
3377
3412
  readonly CLOSING: number;
3378
3413
  readonly CONNECTING: number;
3379
3414
  readonly OPEN: number;
3380
- addEventListener<K extends keyof WebSocketEventMap_2>(type: K, listener: (ev: WebSocketEventMap_2[K]) => any, options?: boolean | AddEventListenerOptions): void;
3415
+ addEventListener<K extends keyof IWebSocketEventMap>(type: K, listener: (event: IWebSocketEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
3381
3416
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
3382
- removeEventListener<K extends keyof WebSocketEventMap_2>(type: K, listener: (ev: WebSocketEventMap_2[K]) => any, options?: boolean | EventListenerOptions): void;
3417
+ removeEventListener<K extends keyof IWebSocketEventMap>(type: K, listener: (event: IWebSocketEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
3383
3418
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
3384
3419
  }
3385
3420
 
@@ -6407,6 +6442,22 @@ export declare function normalizeCreateBinaryOptions(arg1: BinarySource | Create
6407
6442
 
6408
6443
  export declare function normalizeCreatePdfOptions(arg1: TDocumentDefinitions | CreatePdfOptions, arg2: string | undefined | MedplumRequestOptions, arg3: Record<string, CustomTableLayout> | undefined, arg4: TFontDictionary | undefined): CreatePdfOptions;
6409
6444
 
6445
+ /**
6446
+ * Normalizes the various `error` event shapes dispatched by different `WebSocket` implementations
6447
+ * into a single `ErrorEvent` carrying a real `Error`, so downstream listeners always get `message`
6448
+ * and `error` regardless of the underlying implementation:
6449
+ *
6450
+ * - Browsers dispatch a plain `Event` with no error details (per the WHATWG WebSocket spec).
6451
+ * - Node's `ws` library and Node's built-in (undici) `WebSocket` dispatch an `ErrorEvent` with both
6452
+ * `message` and `error`.
6453
+ * - Bun dispatches a plain `Event` with a `message` string but no `error`.
6454
+ *
6455
+ * @param event - The `error` event as dispatched by the underlying `WebSocket`.
6456
+ * @param target - The `ReconnectingWebSocket` instance the normalized event is dispatched from.
6457
+ * @returns An `ErrorEvent` with a populated `message` and `error`.
6458
+ */
6459
+ export declare function normalizeErrorEvent(event: Event | ErrorEvent_2, target: unknown): ErrorEvent_2;
6460
+
6410
6461
  /**
6411
6462
  * Normalizes an error object into a displayable error string.
6412
6463
  * @param error - The error value which could be a string, Error, OperationOutcome, or other unknown type.