@medplum/core 2.1.11 → 2.1.13

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/types.d.ts CHANGED
@@ -375,6 +375,12 @@ export declare function createReference<T extends Resource>(resource: T): Refere
375
375
 
376
376
  export declare function createStructureIssue(expression: string, details: string): OperationOutcomeIssue;
377
377
 
378
+ export declare type CurrentContext<EventName extends FhircastResourceEventName = FhircastResourceEventName> = {
379
+ 'context.type': ResourceType | '';
380
+ 'context.versionId'?: string;
381
+ context: FhircastEventContext<EventName>[];
382
+ };
383
+
378
384
  /**
379
385
  * Decodes a base64 string.
380
386
  * Handles both browser and Node environments.
@@ -748,6 +754,8 @@ export declare type FhircastMultiResourceContext<EventName extends FhircastEvent
748
754
  resources: FhircastEventResource<EventName, K>[];
749
755
  };
750
756
 
757
+ export declare type FhircastResourceEventName = Exclude<FhircastEventName, 'syncerror'>;
758
+
751
759
  export declare type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[number];
752
760
 
753
761
  export declare type FhircastSingleResourceContext<EventName extends FhircastEventName = FhircastEventName, K extends FhircastEventContextKey<EventName> = FhircastEventContextKey<EventName>> = {
@@ -1254,14 +1262,9 @@ export declare interface GoogleLoginRequest extends BaseLoginRequest {
1254
1262
  /**
1255
1263
  * The Hl7Context class represents the parsing context for an HL7 message.
1256
1264
  *
1257
- * MSH-1:
1258
- * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.1
1259
- *
1260
- * MSH-2:
1261
- * https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.2
1262
- *
1263
- * See this tutorial on MSH, and why it's a bad idea to use anything other than the default values:
1264
- * https://www.hl7soup.com/HL7TutorialMSH.html
1265
+ * @see MSH-1: https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.1
1266
+ * @see MSH-2: https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.2
1267
+ * @see See this tutorial on MSH, and why it's a bad idea to use anything other than the default values: https://www.hl7soup.com/HL7TutorialMSH.html
1265
1268
  */
1266
1269
  export declare class Hl7Context {
1267
1270
  readonly segmentSeparator: string;
@@ -1536,9 +1539,7 @@ export declare interface IncludeTarget {
1536
1539
  * PropertySchema - one per property/field
1537
1540
  */
1538
1541
  export declare interface IndexedStructureDefinition {
1539
- types: {
1540
- [resourceType: string]: TypeInfo;
1541
- };
1542
+ types: Record<string, TypeInfo>;
1542
1543
  }
1543
1544
 
1544
1545
  export declare class IndexerAtom implements Atom {
@@ -1768,7 +1769,7 @@ export declare function isStringArray(arr: any[]): arr is string[];
1768
1769
  * @param input - The input string.
1769
1770
  * @returns True if the input string matches the UUID format.
1770
1771
  */
1771
- export declare function isUUID(input: string): input is `${string}-${string}-${string}-${string}-${string}`;
1772
+ export declare function isUUID(input: string): input is string;
1772
1773
 
1773
1774
  /**
1774
1775
  * Returns true if the given date object is a valid date.
@@ -1939,7 +1940,7 @@ export declare function matchesRange(value: number, range: Range_2, precision?:
1939
1940
  */
1940
1941
  export declare function matchesSearchRequest(resource: Resource, searchRequest: SearchRequest): boolean;
1941
1942
 
1942
- export declare const MEDPLUM_VERSION: string;
1943
+ export declare const MEDPLUM_VERSION: any;
1943
1944
 
1944
1945
  /**
1945
1946
  * The MedplumClient class provides a client for the Medplum FHIR server.
@@ -2232,9 +2233,10 @@ export declare class MedplumClient extends EventTarget_2 {
2232
2233
  * @param clientId - The external client ID.
2233
2234
  * @param redirectUri - The external identity provider redirect URI.
2234
2235
  * @param baseLogin - The Medplum login request.
2236
+ * @param pkceEnabled - Whether `PKCE` should be enabled for this external auth request. Defaults to `true`.
2235
2237
  * @category Authentication
2236
2238
  */
2237
- signInWithExternalAuth(authorizeUrl: string, clientId: string, redirectUri: string, baseLogin: BaseLoginRequest): Promise<void>;
2239
+ signInWithExternalAuth(authorizeUrl: string, clientId: string, redirectUri: string, baseLogin: BaseLoginRequest, pkceEnabled?: boolean): Promise<void>;
2238
2240
  /**
2239
2241
  * Exchange an external access token for a Medplum access token.
2240
2242
  * @param token - The access token that was generated by the external identity provider.
@@ -2249,10 +2251,11 @@ export declare class MedplumClient extends EventTarget_2 {
2249
2251
  * @param clientId - The external client ID.
2250
2252
  * @param redirectUri - The external identity provider redirect URI.
2251
2253
  * @param loginRequest - The Medplum login request.
2254
+ * @param pkceEnabled - Whether `PKCE` should be enabled for this external auth request. Defaults to `true`.
2252
2255
  * @returns The external identity provider redirect URI.
2253
2256
  * @category Authentication
2254
2257
  */
2255
- getExternalAuthRedirectUri(authorizeUrl: string, clientId: string, redirectUri: string, loginRequest: BaseLoginRequest): string;
2258
+ getExternalAuthRedirectUri(authorizeUrl: string, clientId: string, redirectUri: string, loginRequest: BaseLoginRequest, pkceEnabled?: boolean): string;
2256
2259
  /**
2257
2260
  * Builds a FHIR URL from a collection of URL path components.
2258
2261
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
@@ -3171,7 +3174,7 @@ export declare class MedplumClient extends EventTarget_2 {
3171
3174
  *
3172
3175
  * @example
3173
3176
  * ```typescript
3174
- * await medplum.startClientLogin(process.env.MEDPLUM_CLIENT_ID, process.env.MEDPLUM_CLIENT_SECRET)
3177
+ * await medplum.startClientLogin(import.meta.env.MEDPLUM_CLIENT_ID, import.meta.env.MEDPLUM_CLIENT_SECRET)
3175
3178
  * // Example Search
3176
3179
  * await medplum.searchResources('Patient')
3177
3180
  * ```
@@ -3189,7 +3192,7 @@ export declare class MedplumClient extends EventTarget_2 {
3189
3192
  *
3190
3193
  * @example
3191
3194
  * ```typescript
3192
- * await medplum.startJwtBearerLogin(process.env.MEDPLUM_CLIENT_ID, process.env.MEDPLUM_JWT_BEARER_ASSERTION, 'openid profile');
3195
+ * await medplum.startJwtBearerLogin(import.meta.env.MEDPLUM_CLIENT_ID, import.meta.env.MEDPLUM_JWT_BEARER_ASSERTION, 'openid profile');
3193
3196
  * // Example Search
3194
3197
  * await medplum.searchResources('Patient')
3195
3198
  * ```
@@ -3218,7 +3221,7 @@ export declare class MedplumClient extends EventTarget_2 {
3218
3221
  *
3219
3222
  * @example
3220
3223
  * ```typescript
3221
- * medplum.setBasicAuth(process.env.MEDPLUM_CLIENT_ID, process.env.MEDPLUM_CLIENT_SECRET);
3224
+ * medplum.setBasicAuth(import.meta.env.MEDPLUM_CLIENT_ID, import.meta.env.MEDPLUM_CLIENT_SECRET);
3222
3225
  * // Example Search
3223
3226
  * await medplum.searchResources('Patient');
3224
3227
  * ```
@@ -3267,6 +3270,14 @@ export declare class MedplumClient extends EventTarget_2 {
3267
3270
  */
3268
3271
  fhircastPublish<EventName extends FhircastEventVersionOptional>(topic: string, event: EventName, context: FhircastEventContext<EventName> | FhircastEventContext<EventName>[], versionId?: never): Promise<void>;
3269
3272
  fhircastPublish<RequiredVersionEvent extends FhircastEventVersionRequired>(topic: string, event: RequiredVersionEvent, context: FhircastEventContext<RequiredVersionEvent> | FhircastEventContext<RequiredVersionEvent>[], versionId: string): Promise<void>;
3273
+ /**
3274
+ * Gets the current context of the given FHIRcast `topic`.
3275
+ *
3276
+ * @category FHIRcast
3277
+ * @param topic - The topic to get the current context for. Usually a UUID.
3278
+ * @returns A Promise which resolves to the `CurrentContext` for the given topic.
3279
+ */
3280
+ fhircastGetContext(topic: string): Promise<CurrentContext>;
3270
3281
  /**
3271
3282
  * Invite a user to a project.
3272
3283
  * @param projectId - The project ID.
@@ -3951,8 +3962,16 @@ export declare function parseSearchUrl<T extends Resource = Resource>(url: URL):
3951
3962
  export declare function parseStructureDefinition(sd: StructureDefinition): InternalTypeSchema;
3952
3963
 
3953
3964
  /**
3954
- * Parses an extended FHIR search criteria string (i.e. application/x-fhir-query), evaluating
3955
- * any embedded FHIRPath subexpressions (e.g. `{{ %patient.id }}`) with the provided variables.
3965
+ * Parses an extended FHIR search criteria string (i.e. application/x-fhir-query).
3966
+ *
3967
+ * @example Evaluating a FHIRPath subexpression
3968
+ *
3969
+ * ```typescript
3970
+ * const query = 'Patient?name={{ %patient.name }}';
3971
+ * const variables = { patient: { name: 'John Doe' } };
3972
+ * const request = parseXFhirQuery(query, variables);
3973
+ * console.log(request.filters[0].value); // "John Doe"
3974
+ * ```
3956
3975
  *
3957
3976
  * @see https://hl7.org/fhir/fhir-xquery.html
3958
3977
  * @param query - The X-Fhir-Query string to parse
@@ -4499,12 +4518,8 @@ export declare interface TypedValue {
4499
4518
  * 4) Patient_Link
4500
4519
  */
4501
4520
  export declare interface TypeInfo {
4502
- searchParams?: {
4503
- [code: string]: SearchParameter;
4504
- };
4505
- searchParamsDetails?: {
4506
- [code: string]: SearchParameterDetails;
4507
- };
4521
+ searchParams?: Record<string, SearchParameter>;
4522
+ searchParamsDetails?: Record<string, SearchParameterDetails>;
4508
4523
  }
4509
4524
 
4510
4525
  export declare type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : 'object';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "keywords": [
6
6
  "medplum",
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "author": "Medplum <hello@medplum.com>",
28
+ "type": "module",
28
29
  "sideEffects": false,
29
30
  "exports": {
30
31
  "types": "./dist/types.d.ts",
@@ -44,6 +45,8 @@
44
45
  "devDependencies": {
45
46
  "@medplum/definitions": "*",
46
47
  "@medplum/fhirtypes": "*",
48
+ "@types/jest": "^29.5.5",
49
+ "jest": "^29.7.0",
47
50
  "jest-websocket-mock": "2.5.0"
48
51
  },
49
52
  "peerDependencies": {