@medplum/core 0.9.30 → 0.9.33

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.
@@ -103,6 +103,12 @@ export declare function getExtensionValue(resource: Resource, ...urls: string[])
103
103
  * @returns The resulting JSON string.
104
104
  */
105
105
  export declare function stringify(value: any, pretty?: boolean): string;
106
+ /**
107
+ * Returns true if the value is empty (null, undefined, empty string, or empty object).
108
+ * @param v Any value.
109
+ * @returns True if the value is an empty string or an empty object.
110
+ */
111
+ export declare function isEmpty(v: any): boolean;
106
112
  /**
107
113
  * Resource equality.
108
114
  * Ignores meta.versionId and meta.lastUpdated.
@@ -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;
@@ -152,11 +154,14 @@ export interface NewUserRequest {
152
154
  readonly recaptchaToken: string;
153
155
  readonly recaptchaSiteKey?: string;
154
156
  readonly remember?: boolean;
157
+ readonly projectId?: string;
155
158
  }
156
159
  export interface NewProjectRequest {
160
+ readonly login: string;
157
161
  readonly projectName: string;
158
162
  }
159
163
  export interface NewPatientRequest {
164
+ readonly login: string;
160
165
  readonly projectId: string;
161
166
  }
162
167
  export interface GoogleCredentialResponse {
@@ -170,6 +175,9 @@ export interface GoogleLoginRequest {
170
175
  readonly clientId?: string;
171
176
  readonly scope?: string;
172
177
  readonly nonce?: string;
178
+ readonly codeChallenge?: string;
179
+ readonly codeChallengeMethod?: string;
180
+ readonly createUser?: boolean;
173
181
  }
174
182
  export interface LoginAuthenticationResponse {
175
183
  readonly login: string;
@@ -199,9 +207,10 @@ export interface TokenResponse {
199
207
  readonly project: Reference<Project>;
200
208
  readonly profile: Reference<ProfileResource>;
201
209
  }
202
- export interface BotEvent {
210
+ export interface BotEvent<T = Resource | Hl7Message | string> {
203
211
  readonly contentType: string;
204
- readonly input: Resource | Hl7Message | string;
212
+ readonly input: T;
213
+ readonly secrets: Record<string, ProjectSecret>;
205
214
  }
206
215
  /**
207
216
  * JSONPatch patch operation.
@@ -424,20 +433,18 @@ export declare class MedplumClient extends EventTarget {
424
433
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
425
434
  *
426
435
  * @param newProjectRequest Register request including email and password.
427
- * @param login The partial login to complete. This should come from the `startNewUser` method.
428
436
  * @returns Promise to the authentication response.
429
437
  */
430
- startNewProject(newProjectRequest: NewProjectRequest, login: LoginAuthenticationResponse): Promise<LoginAuthenticationResponse>;
438
+ startNewProject(newProjectRequest: NewProjectRequest): Promise<LoginAuthenticationResponse>;
431
439
  /**
432
440
  * Initiates a new patient flow.
433
441
  *
434
442
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
435
443
  *
436
444
  * @param newPatientRequest Register request including email and password.
437
- * @param login The partial login to complete. This should come from the `startNewUser` method.
438
445
  * @returns Promise to the authentication response.
439
446
  */
440
- startNewPatient(newPatientRequest: NewPatientRequest, login: LoginAuthenticationResponse): Promise<LoginAuthenticationResponse>;
447
+ startNewPatient(newPatientRequest: NewPatientRequest): Promise<LoginAuthenticationResponse>;
441
448
  /**
442
449
  * Initiates a user login flow.
443
450
  * @category Authentication
@@ -289,12 +289,11 @@ class MedplumClient extends EventTarget {
289
289
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
290
290
  *
291
291
  * @param newProjectRequest Register request including email and password.
292
- * @param login The partial login to complete. This should come from the `startNewUser` method.
293
292
  * @returns Promise to the authentication response.
294
293
  */
295
- startNewProject(newProjectRequest, login) {
294
+ startNewProject(newProjectRequest) {
296
295
  return __awaiter(this, void 0, void 0, function* () {
297
- return this.post('auth/newproject', Object.assign(Object.assign({}, newProjectRequest), login));
296
+ return this.post('auth/newproject', newProjectRequest);
298
297
  });
299
298
  }
300
299
  /**
@@ -303,12 +302,11 @@ class MedplumClient extends EventTarget {
303
302
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
304
303
  *
305
304
  * @param newPatientRequest Register request including email and password.
306
- * @param login The partial login to complete. This should come from the `startNewUser` method.
307
305
  * @returns Promise to the authentication response.
308
306
  */
309
- startNewPatient(newPatientRequest, login) {
307
+ startNewPatient(newPatientRequest) {
310
308
  return __awaiter(this, void 0, void 0, function* () {
311
- return this.post('auth/newpatient', Object.assign(Object.assign({}, newPatientRequest), login));
309
+ return this.post('auth/newpatient', newPatientRequest);
312
310
  });
313
311
  }
314
312
  /**
@@ -320,8 +318,10 @@ class MedplumClient extends EventTarget {
320
318
  startLogin(loginRequest) {
321
319
  var _a, _b;
322
320
  return __awaiter(this, void 0, void 0, function* () {
323
- yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
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: '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') }));
325
325
  });
326
326
  }
327
327
  /**
@@ -335,8 +335,10 @@ class MedplumClient extends EventTarget {
335
335
  startGoogleLogin(loginRequest) {
336
336
  var _a, _b;
337
337
  return __awaiter(this, void 0, void 0, function* () {
338
- yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
339
- 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') }));
340
342
  });
341
343
  }
342
344
  /**