@medplum/core 0.9.31 → 0.9.34

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.
@@ -104,6 +104,8 @@ export interface IndexedStructureDefinition {
104
104
  * 4) Patient_Link
105
105
  */
106
106
  export interface TypeSchema {
107
+ structureDefinition: StructureDefinition;
108
+ elementDefinition: ElementDefinition;
107
109
  display: string;
108
110
  properties: {
109
111
  [name: string]: ElementDefinition;
@@ -120,7 +122,6 @@ export interface TypeSchema {
120
122
  * @deprecated Use globalSchema
121
123
  */
122
124
  export declare function createSchema(): IndexedStructureDefinition;
123
- export declare function createTypeSchema(typeName: string, description: string | undefined): TypeSchema;
124
125
  /**
125
126
  * Indexes a bundle of StructureDefinitions for faster lookup.
126
127
  * @param bundle A FHIR bundle StructureDefinition resources.
@@ -92,7 +92,7 @@ export declare function getIdentifier(resource: Resource, system: string): strin
92
92
  * @param urls Array of extension URLs. Each entry represents a nested extension.
93
93
  * @returns The extension value if found; undefined otherwise.
94
94
  */
95
- export declare function getExtensionValue(resource: Resource, ...urls: string[]): string | undefined;
95
+ export declare function getExtensionValue(resource: any, ...urls: string[]): string | undefined;
96
96
  /**
97
97
  * FHIR JSON stringify.
98
98
  * Removes properties with empty string values.
@@ -1,4 +1,4 @@
1
- import { Binary, Bundle, Communication, ExtractResource, OperationOutcome, Project, ProjectMembership, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
1
+ import { Binary, Bundle, Communication, ExtractResource, OperationOutcome, Project, ProjectMembership, ProjectSecret, Reference, Resource, ResourceType, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
2
  /** @ts-ignore */
3
3
  import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
4
4
  import { EventTarget } from './eventtarget';
@@ -143,6 +143,8 @@ export interface LoginRequest {
143
143
  readonly clientId?: string;
144
144
  readonly scope?: string;
145
145
  readonly nonce?: string;
146
+ readonly codeChallenge?: string;
147
+ readonly codeChallengeMethod?: string;
146
148
  }
147
149
  export interface NewUserRequest {
148
150
  readonly firstName: string;
@@ -173,6 +175,8 @@ export interface GoogleLoginRequest {
173
175
  readonly clientId?: string;
174
176
  readonly scope?: string;
175
177
  readonly nonce?: string;
178
+ readonly codeChallenge?: string;
179
+ readonly codeChallengeMethod?: string;
176
180
  readonly createUser?: boolean;
177
181
  }
178
182
  export interface LoginAuthenticationResponse {
@@ -203,9 +207,10 @@ export interface TokenResponse {
203
207
  readonly project: Reference<Project>;
204
208
  readonly profile: Reference<ProfileResource>;
205
209
  }
206
- export interface BotEvent {
210
+ export interface BotEvent<T = Resource | Hl7Message | string> {
207
211
  readonly contentType: string;
208
- readonly input: Resource | Hl7Message | string;
212
+ readonly input: T;
213
+ readonly secrets: Record<string, ProjectSecret>;
209
214
  }
210
215
  /**
211
216
  * JSONPatch patch operation.
@@ -613,7 +618,7 @@ export declare class MedplumClient extends EventTarget {
613
618
  *
614
619
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
615
620
  *
616
- * @category Caching
621
+ * @category Read
617
622
  * @param resourceType The FHIR resource type.
618
623
  * @param id The resource ID.
619
624
  * @returns The resource if available; undefined otherwise.
@@ -1032,6 +1037,18 @@ export declare class MedplumClient extends EventTarget {
1032
1037
  * @returns The GraphQL result.
1033
1038
  */
1034
1039
  graphql(query: string, operationName?: string | null, variables?: any, options?: RequestInit): Promise<any>;
1040
+ /**
1041
+ *
1042
+ * Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource
1043
+ * according to a graph definition
1044
+
1045
+ * @category Read
1046
+ * @param resourceType The FHIR resource type.
1047
+ * @param id The resource ID.
1048
+ * @param graphName `name` parameter of the GraphDefinition
1049
+ * @returns A Bundle
1050
+ */
1051
+ readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string): ReadablePromise<Bundle<Resource>>;
1035
1052
  /**
1036
1053
  * @category Authentication
1037
1054
  * @returns The Login State
@@ -318,8 +318,10 @@ class MedplumClient extends EventTarget {
318
318
  startLogin(loginRequest) {
319
319
  var _a, _b;
320
320
  return __awaiter(this, void 0, void 0, function* () {
321
- yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
322
- return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
321
+ if (!loginRequest.codeChallenge || !loginRequest.codeChallengeMethod) {
322
+ yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
323
+ }
324
+ return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: loginRequest.codeChallengeMethod || 'S256', codeChallenge: loginRequest.codeChallenge || __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
323
325
  });
324
326
  }
325
327
  /**
@@ -333,8 +335,10 @@ class MedplumClient extends EventTarget {
333
335
  startGoogleLogin(loginRequest) {
334
336
  var _a, _b;
335
337
  return __awaiter(this, void 0, void 0, function* () {
336
- yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
337
- return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE }));
338
+ if (!loginRequest.codeChallenge || !loginRequest.codeChallengeMethod) {
339
+ yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
340
+ }
341
+ return this.post('auth/google', Object.assign(Object.assign({}, loginRequest), { clientId: (_a = loginRequest.clientId) !== null && _a !== void 0 ? _a : __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: (_b = loginRequest.scope) !== null && _b !== void 0 ? _b : DEFAULT_SCOPE, codeChallengeMethod: loginRequest.codeChallengeMethod || 'S256', codeChallenge: loginRequest.codeChallenge || __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
338
342
  });
339
343
  }
340
344
  /**
@@ -561,7 +565,7 @@ class MedplumClient extends EventTarget {
561
565
  *
562
566
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
563
567
  *
564
- * @category Caching
568
+ * @category Read
565
569
  * @param resourceType The FHIR resource type.
566
570
  * @param id The resource ID.
567
571
  * @returns The resource if available; undefined otherwise.
@@ -1116,6 +1120,20 @@ class MedplumClient extends EventTarget {
1116
1120
  graphql(query, operationName, variables, options) {
1117
1121
  return this.post(this.fhirUrl('$graphql'), { query, operationName, variables }, JSON_CONTENT_TYPE, options);
1118
1122
  }
1123
+ /**
1124
+ *
1125
+ * Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource
1126
+ * according to a graph definition
1127
+
1128
+ * @category Read
1129
+ * @param resourceType The FHIR resource type.
1130
+ * @param id The resource ID.
1131
+ * @param graphName `name` parameter of the GraphDefinition
1132
+ * @returns A Bundle
1133
+ */
1134
+ readResourceGraph(resourceType, id, graphName) {
1135
+ return this.get(`${this.fhirUrl(resourceType, id)}/$graph?graph=${graphName}`);
1136
+ }
1119
1137
  /**
1120
1138
  * @category Authentication
1121
1139
  * @returns The Login State