@medplum/core 4.1.5 → 4.1.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.
@@ -276,6 +276,7 @@ export declare interface AtomContext {
276
276
  }
277
277
 
278
278
  export declare interface BackgroundJobContext {
279
+ project?: WithId<Project>;
279
280
  interaction: BackgroundJobInteraction;
280
281
  }
281
282
 
@@ -1964,6 +1965,16 @@ export declare class Hl7Field {
1964
1965
  * @returns The parsed HL7 field.
1965
1966
  */
1966
1967
  static parse(text: string, context?: Hl7Context): Hl7Field;
1968
+ /**
1969
+ * Sets a component value at the specified indices.
1970
+ * Note that the indices are 1-based, not 0-based.
1971
+ * @param component - The component index
1972
+ * @param value - The new component value
1973
+ * @param subcomponent - Optional subcomponent index
1974
+ * @param repetition - Optional repetition index
1975
+ * @returns true if the component was set, false otherwise
1976
+ */
1977
+ setComponent(component: number, value: string, subcomponent?: number, repetition?: number): boolean;
1967
1978
  }
1968
1979
 
1969
1980
  /**
@@ -2032,6 +2043,16 @@ export declare class Hl7Message {
2032
2043
  * @returns The parsed HL7 message.
2033
2044
  */
2034
2045
  static parse(text: string): Hl7Message;
2046
+ /**
2047
+ * Sets or replaces a segment at the specified index.
2048
+ * Only allows MSH header to be replaced as first segment.
2049
+ * If index is a number and is larger than the length of the segments array, it will be appended as the last segment.
2050
+ * If the index is a string, replaces the first segment with that name.
2051
+ * @param index - The segment index or name
2052
+ * @param segment - The new segment to set
2053
+ * @returns true if the segment was set, false otherwise
2054
+ */
2055
+ setSegment(index: number | string, segment: Hl7Segment): boolean;
2035
2056
  }
2036
2057
 
2037
2058
  /**
@@ -2053,7 +2074,7 @@ export declare class Hl7Segment {
2053
2074
  * Returns an HL7 field by index.
2054
2075
  * @param index - The HL7 field index.
2055
2076
  * @returns The HL7 field.
2056
- * @deprecated Use getSegment() instead. This method includes the segment name in the index, which leads to confusing behavior. This method will be removed in a future release.
2077
+ * @deprecated Use getField() instead. This method includes the segment name in the index, which leads to confusing behavior. This method will be removed in a future release.
2057
2078
  */
2058
2079
  get(index: number): Hl7Field;
2059
2080
  /**
@@ -2101,6 +2122,26 @@ export declare class Hl7Segment {
2101
2122
  * @returns The parsed HL7 segment.
2102
2123
  */
2103
2124
  static parse(text: string, context?: Hl7Context): Hl7Segment;
2125
+ /**
2126
+ * Sets a field at the specified index. If that index does not exist, it will be added.
2127
+ * Note that the index is 1-based, not 0-based.
2128
+ * @param index - The field index
2129
+ * @param field - The new field value
2130
+ * @returns true if the field was set, false otherwise
2131
+ */
2132
+ setField(index: number, field: Hl7Field | string): boolean;
2133
+ /**
2134
+ * Sets a component value by field index and component index.
2135
+ * This is a shortcut for `getField(field).setComponent(component, value)`.
2136
+ * Note that both indices are 1-based, not 0-based.
2137
+ * @param fieldIndex - The HL7 field index
2138
+ * @param component - The component index
2139
+ * @param value - The new component value
2140
+ * @param subcomponent - Optional subcomponent index
2141
+ * @param repetition - Optional repetition index
2142
+ * @returns true if the component was set, false otherwise
2143
+ */
2144
+ setComponent(fieldIndex: number, component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2104
2145
  }
2105
2146
 
2106
2147
  export declare const HTTP_HL7_ORG = "http://hl7.org";
@@ -2960,6 +3001,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
2960
3001
  private refreshPromise?;
2961
3002
  private profilePromise?;
2962
3003
  private sessionDetails?;
3004
+ private currentRateLimits?;
2963
3005
  private basicAuth?;
2964
3006
  private initPromise;
2965
3007
  private initComplete;
@@ -4172,6 +4214,13 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4172
4214
  private fetchWithRetry;
4173
4215
  private logRequest;
4174
4216
  private logResponse;
4217
+ private setCurrentRateLimit;
4218
+ /**
4219
+ * Reports the last-seen rate limit information from the server.
4220
+ * @returns Array of applicable rate limits.
4221
+ */
4222
+ rateLimitStatus(): RateLimitInfo[];
4223
+ private getRetryDelay;
4175
4224
  private pollStatus;
4176
4225
  /**
4177
4226
  * Executes a batch of requests that were automatically batched together.
@@ -5503,6 +5552,12 @@ export declare type ProtocolsProvider = null | string | string[];
5503
5552
  */
5504
5553
  export declare type QueryTypes = URLSearchParams | string[][] | Record<string, string | number | boolean | undefined> | string | undefined;
5505
5554
 
5555
+ export declare type RateLimitInfo = {
5556
+ name: string;
5557
+ remainingUnits: number;
5558
+ secondsUntilReset: number;
5559
+ };
5560
+
5506
5561
  /**
5507
5562
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
5508
5563
  * See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js
@@ -276,6 +276,7 @@ export declare interface AtomContext {
276
276
  }
277
277
 
278
278
  export declare interface BackgroundJobContext {
279
+ project?: WithId<Project>;
279
280
  interaction: BackgroundJobInteraction;
280
281
  }
281
282
 
@@ -1964,6 +1965,16 @@ export declare class Hl7Field {
1964
1965
  * @returns The parsed HL7 field.
1965
1966
  */
1966
1967
  static parse(text: string, context?: Hl7Context): Hl7Field;
1968
+ /**
1969
+ * Sets a component value at the specified indices.
1970
+ * Note that the indices are 1-based, not 0-based.
1971
+ * @param component - The component index
1972
+ * @param value - The new component value
1973
+ * @param subcomponent - Optional subcomponent index
1974
+ * @param repetition - Optional repetition index
1975
+ * @returns true if the component was set, false otherwise
1976
+ */
1977
+ setComponent(component: number, value: string, subcomponent?: number, repetition?: number): boolean;
1967
1978
  }
1968
1979
 
1969
1980
  /**
@@ -2032,6 +2043,16 @@ export declare class Hl7Message {
2032
2043
  * @returns The parsed HL7 message.
2033
2044
  */
2034
2045
  static parse(text: string): Hl7Message;
2046
+ /**
2047
+ * Sets or replaces a segment at the specified index.
2048
+ * Only allows MSH header to be replaced as first segment.
2049
+ * If index is a number and is larger than the length of the segments array, it will be appended as the last segment.
2050
+ * If the index is a string, replaces the first segment with that name.
2051
+ * @param index - The segment index or name
2052
+ * @param segment - The new segment to set
2053
+ * @returns true if the segment was set, false otherwise
2054
+ */
2055
+ setSegment(index: number | string, segment: Hl7Segment): boolean;
2035
2056
  }
2036
2057
 
2037
2058
  /**
@@ -2053,7 +2074,7 @@ export declare class Hl7Segment {
2053
2074
  * Returns an HL7 field by index.
2054
2075
  * @param index - The HL7 field index.
2055
2076
  * @returns The HL7 field.
2056
- * @deprecated Use getSegment() instead. This method includes the segment name in the index, which leads to confusing behavior. This method will be removed in a future release.
2077
+ * @deprecated Use getField() instead. This method includes the segment name in the index, which leads to confusing behavior. This method will be removed in a future release.
2057
2078
  */
2058
2079
  get(index: number): Hl7Field;
2059
2080
  /**
@@ -2101,6 +2122,26 @@ export declare class Hl7Segment {
2101
2122
  * @returns The parsed HL7 segment.
2102
2123
  */
2103
2124
  static parse(text: string, context?: Hl7Context): Hl7Segment;
2125
+ /**
2126
+ * Sets a field at the specified index. If that index does not exist, it will be added.
2127
+ * Note that the index is 1-based, not 0-based.
2128
+ * @param index - The field index
2129
+ * @param field - The new field value
2130
+ * @returns true if the field was set, false otherwise
2131
+ */
2132
+ setField(index: number, field: Hl7Field | string): boolean;
2133
+ /**
2134
+ * Sets a component value by field index and component index.
2135
+ * This is a shortcut for `getField(field).setComponent(component, value)`.
2136
+ * Note that both indices are 1-based, not 0-based.
2137
+ * @param fieldIndex - The HL7 field index
2138
+ * @param component - The component index
2139
+ * @param value - The new component value
2140
+ * @param subcomponent - Optional subcomponent index
2141
+ * @param repetition - Optional repetition index
2142
+ * @returns true if the component was set, false otherwise
2143
+ */
2144
+ setComponent(fieldIndex: number, component: number, value: string, subcomponent?: number, repetition?: number): boolean;
2104
2145
  }
2105
2146
 
2106
2147
  export declare const HTTP_HL7_ORG = "http://hl7.org";
@@ -2960,6 +3001,7 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
2960
3001
  private refreshPromise?;
2961
3002
  private profilePromise?;
2962
3003
  private sessionDetails?;
3004
+ private currentRateLimits?;
2963
3005
  private basicAuth?;
2964
3006
  private initPromise;
2965
3007
  private initComplete;
@@ -4172,6 +4214,13 @@ export declare class MedplumClient extends TypedEventTarget<MedplumClientEventMa
4172
4214
  private fetchWithRetry;
4173
4215
  private logRequest;
4174
4216
  private logResponse;
4217
+ private setCurrentRateLimit;
4218
+ /**
4219
+ * Reports the last-seen rate limit information from the server.
4220
+ * @returns Array of applicable rate limits.
4221
+ */
4222
+ rateLimitStatus(): RateLimitInfo[];
4223
+ private getRetryDelay;
4175
4224
  private pollStatus;
4176
4225
  /**
4177
4226
  * Executes a batch of requests that were automatically batched together.
@@ -5503,6 +5552,12 @@ export declare type ProtocolsProvider = null | string | string[];
5503
5552
  */
5504
5553
  export declare type QueryTypes = URLSearchParams | string[][] | Record<string, string | number | boolean | undefined> | string | undefined;
5505
5554
 
5555
+ export declare type RateLimitInfo = {
5556
+ name: string;
5557
+ remainingUnits: number;
5558
+ secondsUntilReset: number;
5559
+ };
5560
+
5506
5561
  /**
5507
5562
  * The ReadablePromise class wraps a request promise suitable for React Suspense.
5508
5563
  * See: https://blog.logrocket.com/react-suspense-data-fetching/#wrappromise-js