@medplum/core 3.2.4 → 3.2.6

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.
@@ -234,6 +234,8 @@ export declare class AsAtom extends InfixOperatorAtom {
234
234
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
235
235
  }
236
236
 
237
+ export declare function assert(condition: unknown, msg?: string): asserts condition;
238
+
237
239
  export declare function assertContextVersionOptional(event: string): asserts event is FhircastEventVersionOptional;
238
240
 
239
241
  /**
@@ -421,6 +423,13 @@ export declare class ClientStorage implements IClientStorage {
421
423
  setObject<T>(key: string, value: T): void;
422
424
  }
423
425
 
426
+ declare interface CloseEvent_2 extends globalThis.Event {
427
+ code: number;
428
+ reason: string;
429
+ wasClean: boolean;
430
+ }
431
+ export { CloseEvent_2 as CloseEvent }
432
+
424
433
  export declare interface Code {
425
434
  code?: CodeableConcept;
426
435
  }
@@ -533,10 +542,42 @@ export declare type ConvertToUnion<T> = T[keyof T];
533
542
 
534
543
  export declare const CPT = "http://www.ama-assn.org/go/cpt";
535
544
 
545
+ /**
546
+ * Crawls the resource synchronously.
547
+ * @param resource - The resource to crawl.
548
+ * @param visitor - The visitor functions to apply while crawling.
549
+ * @param schema - The schema to use for the resource.
550
+ * @param initialPath - The path within the resource form which to start crawling.
551
+ * @deprecated
552
+ */
536
553
  export declare function crawlResource(resource: Resource, visitor: ResourceVisitor, schema?: InternalTypeSchema, initialPath?: string): void;
537
554
 
555
+ /**
556
+ * Crawls the resource asynchronously.
557
+ * @param resource - The resource to crawl.
558
+ * @param visitor - The visitor functions to apply while crawling.
559
+ * @param options - Options for how to crawl the resource.
560
+ * @returns void
561
+ * @deprecated
562
+ */
538
563
  export declare function crawlResource(resource: Resource, visitor: AsyncResourceVisitor, options: ResourceCrawlerOptions): Promise<void>;
539
564
 
565
+ /**
566
+ * Crawls the resource synchronously.
567
+ * @param resource - The resource to crawl.
568
+ * @param visitor - The visitor functions to apply while crawling.
569
+ * @param options - Options for how to crawl the resource.
570
+ */
571
+ export declare function crawlResource(resource: Resource, visitor: ResourceVisitor, options?: ResourceCrawlerOptions): void;
572
+
573
+ /**
574
+ * Crawls the resource asynchronously.
575
+ * @param resource - The resource to crawl.
576
+ * @param visitor - The visitor functions to apply while crawling.
577
+ * @param options - Options for how to crawl the resource.
578
+ */
579
+ export declare function crawlResourceAsync(resource: Resource, visitor: AsyncResourceVisitor, options: ResourceCrawlerOptions): Promise<void>;
580
+
540
581
  /**
541
582
  * Binary upload options.
542
583
  */
@@ -786,6 +827,12 @@ export declare class EquivalentAtom extends BooleanInfixOperatorAtom {
786
827
  eval(context: AtomContext, input: TypedValue[]): TypedValue[];
787
828
  }
788
829
 
830
+ declare interface ErrorEvent_2 extends globalThis.Event {
831
+ message: string;
832
+ error: Error;
833
+ }
834
+ export { ErrorEvent_2 as ErrorEvent }
835
+
789
836
  /**
790
837
  * Evaluates a FHIRPath expression against a resource or other object.
791
838
  * @param expression - The FHIRPath expression to parse.
@@ -1990,9 +2037,8 @@ export declare function indexSearchParameterBundle(bundle: Bundle<SearchParamete
1990
2037
  /**
1991
2038
  * Parses and indexes structure definitions
1992
2039
  * @param bundle - Bundle or array of structure definitions to be parsed and indexed
1993
- * @param profileUrl - (optional) URL of the profile the SDs are related to
1994
2040
  */
1995
- export declare function indexStructureDefinitionBundle(bundle: StructureDefinition[] | Bundle, profileUrl?: string | undefined): void;
2041
+ export declare function indexStructureDefinitionBundle(bundle: StructureDefinition[] | Bundle): void;
1996
2042
 
1997
2043
  export declare abstract class InfixOperatorAtom implements Atom {
1998
2044
  readonly operator: string;
@@ -2033,10 +2079,10 @@ export declare interface InternalSchemaElement {
2033
2079
  */
2034
2080
  export declare interface InternalTypeSchema {
2035
2081
  name: string;
2082
+ type: string;
2036
2083
  title?: string;
2037
2084
  url?: string;
2038
2085
  kind?: string;
2039
- type?: string;
2040
2086
  description?: string;
2041
2087
  elements: Record<string, InternalSchemaElement>;
2042
2088
  constraints?: Constraint[];
@@ -2064,14 +2110,15 @@ export declare interface InviteRequest {
2064
2110
  admin?: boolean;
2065
2111
  }
2066
2112
 
2067
- export declare interface IRobustWebSocket extends TypedEventTarget<RobustWebSocketEventMap> {
2113
+ export declare interface IReconnectingWebSocket extends TypedEventTarget<WebSocketEventMap_2> {
2068
2114
  readyState: number;
2069
- close(): void;
2115
+ close(code?: number, reason?: string): void;
2070
2116
  send(message: string): void;
2117
+ reconnect(code?: number, reason?: string): void;
2071
2118
  }
2072
2119
 
2073
- export declare interface IRobustWebSocketCtor {
2074
- new (url: string): IRobustWebSocket;
2120
+ export declare interface IReconnectingWebSocketCtor {
2121
+ new (url: string, protocols?: ProtocolsProvider, options?: Options): IReconnectingWebSocket;
2075
2122
  }
2076
2123
 
2077
2124
  export declare function isAccepted(outcome: OperationOutcome): boolean;
@@ -2333,7 +2380,7 @@ export declare class LiteralAtom implements Atom {
2333
2380
  toString(): string;
2334
2381
  }
2335
2382
 
2336
- export declare function loadDataType(sd: StructureDefinition, profileUrl?: string | undefined): void;
2383
+ export declare function loadDataType(sd: StructureDefinition): void;
2337
2384
 
2338
2385
  export declare class Logger {
2339
2386
  readonly write: (msg: string) => void;
@@ -3100,9 +3147,9 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
3100
3147
  * @category Schema
3101
3148
  * @param profileUrl - The FHIR URL of the profile
3102
3149
  * @param options - (optional) Additional options
3103
- * @returns Promise with an array of URLs of the profile(s) loaded.
3150
+ * @returns Promise for schema request.
3104
3151
  */
3105
- requestProfileSchema(profileUrl: string, options?: RequestProfileSchemaOptions): Promise<string[]>;
3152
+ requestProfileSchema(profileUrl: string, options?: RequestProfileSchemaOptions): Promise<void>;
3106
3153
  /**
3107
3154
  * Reads resource history by resource type and ID.
3108
3155
  *
@@ -4519,6 +4566,8 @@ export declare class MemoryStorage implements Storage {
4519
4566
  key(index: number): string | null;
4520
4567
  }
4521
4568
 
4569
+ export declare type Message = string | ArrayBuffer | Blob | ArrayBufferView;
4570
+
4522
4571
  /**
4523
4572
  * The MockAsyncClientStorage class is a mock implementation of the ClientStorage class.
4524
4573
  * This can be used for testing async initialization of the MedplumClient.
@@ -4728,6 +4777,20 @@ export declare const OperatorPrecedence: {
4728
4777
  Semicolon: number;
4729
4778
  };
4730
4779
 
4780
+ export declare type Options = {
4781
+ WebSocket?: any;
4782
+ maxReconnectionDelay?: number;
4783
+ minReconnectionDelay?: number;
4784
+ reconnectionDelayGrowFactor?: number;
4785
+ minUptime?: number;
4786
+ connectionTimeout?: number;
4787
+ maxRetries?: number;
4788
+ maxEnqueuedMessages?: number;
4789
+ startClosed?: boolean;
4790
+ debug?: boolean;
4791
+ debugLogger?: (...args: any[]) => void;
4792
+ };
4793
+
4731
4794
  /**
4732
4795
  * 6.5.2. or
4733
4796
  * Returns false if both operands evaluate to false,
@@ -5046,6 +5109,8 @@ export declare const PropertyType: {
5046
5109
  */
5047
5110
  export declare const protectedResourceTypes: string[];
5048
5111
 
5112
+ export declare type ProtocolsProvider = null | string | string[];
5113
+
5049
5114
  /**
5050
5115
  * QueryTypes defines the different ways to specify FHIR search parameters.
5051
5116
  *
@@ -5110,6 +5175,118 @@ export declare class ReadablePromise<T> implements Promise<T> {
5110
5175
  finally(onfinally?: (() => void) | undefined | null): Promise<T>;
5111
5176
  }
5112
5177
 
5178
+ export declare class ReconnectingWebSocket extends TypedEventTarget<WebSocketEventMap_2> implements IReconnectingWebSocket {
5179
+ private _ws;
5180
+ private _retryCount;
5181
+ private _uptimeTimeout;
5182
+ private _connectTimeout;
5183
+ private _shouldReconnect;
5184
+ private _connectLock;
5185
+ private _binaryType;
5186
+ private _closeCalled;
5187
+ private _messageQueue;
5188
+ private _debugLogger;
5189
+ protected _url: string;
5190
+ protected _protocols?: ProtocolsProvider;
5191
+ protected _options: Options;
5192
+ constructor(url: string, protocols?: ProtocolsProvider, options?: Options);
5193
+ static get CONNECTING(): number;
5194
+ static get OPEN(): number;
5195
+ static get CLOSING(): number;
5196
+ static get CLOSED(): number;
5197
+ get CONNECTING(): number;
5198
+ get OPEN(): number;
5199
+ get CLOSING(): number;
5200
+ get CLOSED(): number;
5201
+ get binaryType(): 'arraybuffer' | 'blob';
5202
+ set binaryType(value: BinaryType);
5203
+ /**
5204
+ * @returns The number or connection retries.
5205
+ */
5206
+ get retryCount(): number;
5207
+ /**
5208
+ * @returns The number of bytes of data that have been queued using calls to send() but not yet
5209
+ * transmitted to the network. This value resets to zero once all queued data has been sent.
5210
+ * This value does not reset to zero when the connection is closed; if you keep calling send(),
5211
+ * this will continue to climb. Read only
5212
+ *
5213
+ */
5214
+ get bufferedAmount(): number;
5215
+ /**
5216
+ * @returns The extensions selected by the server. This is currently only the empty string or a list of
5217
+ * extensions as negotiated by the connection
5218
+ */
5219
+ get extensions(): string;
5220
+ /**
5221
+ * @returns A string indicating the name of the sub-protocol the server selected;
5222
+ * this will be one of the strings specified in the protocols parameter when creating the
5223
+ * WebSocket object.
5224
+ */
5225
+ get protocol(): string;
5226
+ /**
5227
+ * @returns The current state of the connection; this is one of the Ready state constants.
5228
+ */
5229
+ get readyState(): number;
5230
+ /**
5231
+ * @returns The URL as resolved by the constructor.
5232
+ */
5233
+ get url(): string;
5234
+ /**
5235
+ * @returns Whether the websocket object is now in reconnectable state.
5236
+ */
5237
+ get shouldReconnect(): boolean;
5238
+ /**
5239
+ * An event listener to be called when the WebSocket connection's readyState changes to CLOSED
5240
+ */
5241
+ onclose: ((event: CloseEvent_2) => void) | null;
5242
+ /**
5243
+ * An event listener to be called when an error occurs
5244
+ */
5245
+ onerror: ((event: ErrorEvent_2) => void) | null;
5246
+ /**
5247
+ * An event listener to be called when a message is received from the server
5248
+ */
5249
+ onmessage: ((event: MessageEvent) => void) | null;
5250
+ /**
5251
+ * An event listener to be called when the WebSocket connection's readyState changes to OPEN;
5252
+ * this indicates that the connection is ready to send and receive data
5253
+ */
5254
+ onopen: ((event: Event) => void) | null;
5255
+ /**
5256
+ * Closes the WebSocket connection or connection attempt, if any. If the connection is already
5257
+ * CLOSED, this method does nothing
5258
+ * @param code - The code to close with. Default is 1000.
5259
+ * @param reason - An optional reason for closing the connection.
5260
+ */
5261
+ close(code?: number, reason?: string): void;
5262
+ /**
5263
+ * Closes the WebSocket connection or connection attempt and connects again.
5264
+ * Resets retry counter;
5265
+ * @param code - The code to disconnect with. Default is 1000.
5266
+ * @param reason - An optional reason for disconnecting the connection.
5267
+ */
5268
+ reconnect(code?: number, reason?: string): void;
5269
+ /**
5270
+ * Enqueue specified data to be transmitted to the server over the WebSocket connection
5271
+ * @param data - The data to enqueue.
5272
+ */
5273
+ send(data: Message): void;
5274
+ private _debug;
5275
+ private _getNextDelay;
5276
+ private _wait;
5277
+ private _connect;
5278
+ private _handleTimeout;
5279
+ private _disconnect;
5280
+ private _acceptOpen;
5281
+ private _handleOpen;
5282
+ private _handleMessage;
5283
+ private _handleError;
5284
+ private _handleClose;
5285
+ private _removeListeners;
5286
+ private _addListeners;
5287
+ private _clearTimeouts;
5288
+ }
5289
+
5113
5290
  /**
5114
5291
  * Removes duplicates in array using FHIRPath equality rules.
5115
5292
  * @param arr - The input array.
@@ -5184,26 +5361,6 @@ export declare interface ResourceVisitor {
5184
5361
 
5185
5362
  export declare type ResourceWithCode = Resource & Code;
5186
5363
 
5187
- export declare class RobustWebSocket extends TypedEventTarget<RobustWebSocketEventMap> implements IRobustWebSocket {
5188
- private ws;
5189
- private messageBuffer;
5190
- bufferedAmount: number;
5191
- extensions: string;
5192
- constructor(url: string);
5193
- get readyState(): number;
5194
- close(): void;
5195
- send(message: string): void;
5196
- }
5197
-
5198
- export declare type RobustWebSocketEventMap = {
5199
- open: {
5200
- type: 'open';
5201
- };
5202
- message: MessageEvent;
5203
- error: Event;
5204
- close: CloseEvent;
5205
- };
5206
-
5207
5364
  export declare const RXNORM = "http://www.nlm.nih.gov/research/umls/rxnorm";
5208
5365
 
5209
5366
  /**
@@ -5417,7 +5574,10 @@ export declare type StringMap = {
5417
5574
  export declare function structureMapTransform(structureMap: StructureMap, input: TypedValue[], loader?: (url: string) => StructureMap[]): TypedValue[];
5418
5575
 
5419
5576
  export declare interface SubManagerOptions {
5420
- RobustWebSocket: IRobustWebSocketCtor;
5577
+ ReconnectingWebSocket?: IReconnectingWebSocketCtor;
5578
+ pingIntervalMs?: number;
5579
+ debug?: boolean;
5580
+ debugLogger?: (...args: any[]) => void;
5421
5581
  }
5422
5582
 
5423
5583
  /**
@@ -5491,9 +5651,11 @@ export declare class SubscriptionManager {
5491
5651
  private criteriaEntries;
5492
5652
  private criteriaEntriesBySubscriptionId;
5493
5653
  private wsClosed;
5654
+ private pingTimer;
5655
+ private pingIntervalMs;
5656
+ private waitingForPong;
5494
5657
  constructor(medplum: MedplumClient, wsUrl: URL | string, options?: SubManagerOptions);
5495
5658
  private setupWebSocketListeners;
5496
- private emitConnect;
5497
5659
  private emitError;
5498
5660
  private maybeEmitDisconnect;
5499
5661
  private getTokenForCriteria;
@@ -5501,9 +5663,13 @@ export declare class SubscriptionManager {
5501
5663
  private getAllCriteriaEmitters;
5502
5664
  private addCriteriaEntry;
5503
5665
  private removeCriteriaEntry;
5666
+ private subscribeToCriteria;
5667
+ private refreshAllSubscriptions;
5504
5668
  addCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): SubscriptionEmitter;
5505
5669
  removeCriteria(criteria: string, subscriptionProps?: Partial<Subscription>): void;
5670
+ getWebSocket(): IReconnectingWebSocket;
5506
5671
  closeWebSocket(): void;
5672
+ reconnectWebSocket(): void;
5507
5673
  getCriteriaCount(): number;
5508
5674
  getMasterEmitter(): SubscriptionEmitter;
5509
5675
  }
@@ -5753,6 +5919,14 @@ export declare interface ValueSetExpandParams {
5753
5919
  count?: number;
5754
5920
  }
5755
5921
 
5922
+ declare type WebSocketEventMap_2 = {
5923
+ close: CloseEvent_2;
5924
+ error: ErrorEvent_2;
5925
+ message: MessageEvent;
5926
+ open: Event;
5927
+ };
5928
+ export { WebSocketEventMap_2 as WebSocketEventMap }
5929
+
5756
5930
  /**
5757
5931
  * 6.5.4. xor
5758
5932
  * Returns true if exactly one of the operands evaluates to true,