@medplum/core 0.9.2 → 0.9.5

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.
@@ -1,644 +1,713 @@
1
- import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
- import type { Operation } from 'fast-json-patch';
3
- import { EventTarget } from './eventtarget';
4
- import { SearchRequest } from './search';
5
- import { IndexedStructureDefinition } from './types';
6
- import { ProfileResource } from './utils';
7
- export interface MedplumClientOptions {
8
- /**
9
- * The client ID.
10
- * Optional. Default is to defer to the server to use the default client.
11
- * Use this to use a specific client for SMART-on-FHIR.
12
- */
13
- clientId?: string;
14
- /**
15
- * Base server URL.
16
- * Optional. Default value is "https://api.medplum.com/".
17
- * Use this to point to a custom Medplum deployment.
18
- */
19
- baseUrl?: string;
20
- /**
21
- * OAuth2 authorize URL.
22
- * Optional. Default value is baseUrl + "/oauth2/authorize".
23
- * Use this if you want to use a separate OAuth server.
24
- */
25
- authorizeUrl?: string;
26
- /**
27
- * OAuth2 token URL.
28
- * Optional. Default value is baseUrl + "/oauth2/token".
29
- * Use this if you want to use a separate OAuth server.
30
- */
31
- tokenUrl?: string;
32
- /**
33
- * OAuth2 logout URL.
34
- * Optional. Default value is baseUrl + "/oauth2/logout".
35
- * Use this if you want to use a separate OAuth server.
36
- */
37
- logoutUrl?: string;
38
- /**
39
- * Number of resources to store in the cache.
40
- * Optional. Default value is 1000.
41
- * Consider using this for performance of displaying Patient or Practitioner resources.
42
- */
43
- resourceCacheSize?: number;
44
- /**
45
- * Optional fetch implementation.
46
- * Optional. Default is window.fetch.
47
- * For nodejs applications, consider the 'node-fetch' package.
48
- */
49
- fetch?: FetchLike;
50
- /**
51
- * Optional callback for when the client is unauthenticated.
52
- * Default is do nothing.
53
- * For client side applications, consider redirecting to a sign in page.
54
- */
55
- onUnauthenticated?: () => void;
56
- }
57
- export interface FetchLike {
58
- (url: string, options?: any): Promise<any>;
59
- }
60
- export interface RegisterRequest {
61
- readonly firstName: string;
62
- readonly lastName: string;
63
- readonly projectName: string;
64
- readonly email: string;
65
- readonly password: string;
66
- readonly remember?: boolean;
67
- readonly recaptchaToken: string;
68
- }
69
- export interface GoogleCredentialResponse {
70
- readonly clientId: string;
71
- readonly credential: string;
72
- }
73
- export interface LoginAuthenticationResponse {
74
- readonly login: string;
75
- readonly code?: string;
76
- readonly memberships?: ProjectMembership[];
77
- }
78
- export interface LoginProfileResponse {
79
- readonly login: string;
80
- readonly scope: string;
81
- }
82
- export interface LoginScopeResponse {
83
- readonly login: string;
84
- readonly code: string;
85
- }
86
- export interface LoginState {
87
- readonly project: Reference<Project>;
88
- readonly profile: Reference<ProfileResource>;
89
- readonly accessToken: string;
90
- readonly refreshToken: string;
91
- }
92
- export interface TokenResponse {
93
- readonly token_type: string;
94
- readonly id_token: string;
95
- readonly access_token: string;
96
- readonly refresh_token: string;
97
- readonly expires_in: number;
98
- readonly project: Reference<Project>;
99
- readonly profile: Reference<ProfileResource>;
100
- }
101
- /**
102
- * The MedplumClient class provides a client for the Medplum FHIR server.
103
- *
104
- * The client can be used in the browser, in a NodeJS application, or in a Medplum Bot.
105
- *
106
- * The client provides helpful methods for common operations such as:
107
- * 1) Authenticating
108
- * 2) Creating resources
109
- * 2) Reading resources
110
- * 3) Updating resources
111
- * 5) Deleting resources
112
- * 6) Searching
113
- * 7) Making GraphQL queries
114
- *
115
- * Here is a quick example of how to use the client:
116
- *
117
- * ```typescript
118
- * import { MedplumClient } from '@medplum/core';
119
- * const medplum = new MedplumClient();
120
- * ```
121
- *
122
- * Create a `Patient`:
123
- *
124
- * ```typescript
125
- * const patient = await medplum.createResource({
126
- * resourceType: 'Patient',
127
- * name: [{
128
- * given: ['Alice'],
129
- * family: 'Smith'
130
- * }]
131
- * });
132
- * ```
133
- *
134
- * Read a `Patient` by ID:
135
- *
136
- * ```typescript
137
- * const patient = await medplum.readResource('Patient', '123');
138
- * console.log(patient.name[0].given[0]);
139
- * ```
140
- *
141
- * Search for a `Patient` by name:
142
- *
143
- * ```typescript
144
- * const bundle = await medplum.search('Patient?name=Alice');
145
- * console.log(bundle.total);
146
- * ```
147
- *
148
- */
149
- export declare class MedplumClient extends EventTarget {
150
- #private;
151
- constructor(options?: MedplumClientOptions);
152
- /**
153
- * Clears all auth state including local storage and session storage.
154
- */
155
- clear(): void;
156
- /**
157
- * Makes an HTTP GET request to the specified URL.
158
- *
159
- * This is a lower level method for custom requests.
160
- * For common operations, we recommend using higher level methods
161
- * such as `readResource()`, `search()`, etc.
162
- *
163
- * @param url The target URL.
164
- * @param options Optional fetch options.
165
- * @returns Promise to the response content.
166
- */
167
- get(url: string, options?: RequestInit): Promise<any>;
168
- /**
169
- * Makes an HTTP POST request to the specified URL.
170
- *
171
- * This is a lower level method for custom requests.
172
- * For common operations, we recommend using higher level methods
173
- * such as `createResource()`.
174
- *
175
- * @param url The target URL.
176
- * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
177
- * @param contentType The content type to be included in the "Content-Type" header.
178
- * @param options Optional fetch options.
179
- * @returns Promise to the response content.
180
- */
181
- post(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
182
- /**
183
- * Makes an HTTP PUT request to the specified URL.
184
- *
185
- * This is a lower level method for custom requests.
186
- * For common operations, we recommend using higher level methods
187
- * such as `updateResource()`.
188
- *
189
- * @param url The target URL.
190
- * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
191
- * @param contentType The content type to be included in the "Content-Type" header.
192
- * @param options Optional fetch options.
193
- * @returns Promise to the response content.
194
- */
195
- put(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
196
- /**
197
- * Makes an HTTP PATCH request to the specified URL.
198
- *
199
- * This is a lower level method for custom requests.
200
- * For common operations, we recommend using higher level methods
201
- * such as `patchResource()`.
202
- *
203
- * @param url The target URL.
204
- * @param operations Array of JSONPatch operations.
205
- * @param options Optional fetch options.
206
- * @returns Promise to the response content.
207
- */
208
- patch(url: string, operations: Operation[], options?: RequestInit): Promise<any>;
209
- /**
210
- * Makes an HTTP DELETE request to the specified URL.
211
- *
212
- * This is a lower level method for custom requests.
213
- * For common operations, we recommend using higher level methods
214
- * such as `deleteResource()`.
215
- *
216
- * @param url The target URL.
217
- * @param options Optional fetch options.
218
- * @returns Promise to the response content.
219
- */
220
- delete(url: string, options?: RequestInit): Promise<any>;
221
- /**
222
- * Tries to register a new user.
223
- * @param request The registration request.
224
- * @returns Promise to the authentication response.
225
- */
226
- register(request: RegisterRequest): Promise<void>;
227
- /**
228
- * Initiates a user login flow.
229
- * @param email The email address of the user.
230
- * @param password The password of the user.
231
- * @param remember Optional flag to remember the user.
232
- * @returns Promise to the authentication response.
233
- */
234
- startLogin(email: string, password: string, remember?: boolean): Promise<LoginAuthenticationResponse>;
235
- /**
236
- * Tries to sign in with Google authentication.
237
- * The response parameter is the result of a Google authentication.
238
- * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
239
- * @param googleResponse The Google credential response.
240
- * @returns Promise to the authentication response.
241
- */
242
- startGoogleLogin(googleResponse: GoogleCredentialResponse): Promise<LoginAuthenticationResponse>;
243
- /**
244
- * Signs out locally.
245
- * Does not invalidate tokens with the server.
246
- */
247
- signOut(): Promise<void>;
248
- /**
249
- * Tries to sign in the user.
250
- * Returns true if the user is signed in.
251
- * This may result in navigating away to the sign in page.
252
- */
253
- signInWithRedirect(): Promise<ProfileResource | void> | undefined;
254
- /**
255
- * Tries to sign out the user.
256
- * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
257
- */
258
- signOutWithRedirect(): void;
259
- /**
260
- * Builds a FHIR URL from a collection of URL path components.
261
- * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
262
- * @param path The path component of the URL.
263
- * @returns The well-formed FHIR URL.
264
- */
265
- fhirUrl(...path: string[]): string;
266
- /**
267
- * Sends a FHIR search request.
268
- *
269
- * Example using a FHIR search string:
270
- *
271
- * ```typescript
272
- * const bundle = await client.search('Patient?name=Alice');
273
- * console.log(bundle);
274
- * ```
275
- *
276
- * Example using a structured search:
277
- *
278
- * ```typescript
279
- * const bundle = await client.search({
280
- * resourceType: 'Patient',
281
- * filters: [{
282
- * code: 'name',
283
- * operator: 'eq',
284
- * value: 'Alice',
285
- * }]
286
- * });
287
- * console.log(bundle);
288
- * ```
289
- *
290
- * The return value is a FHIR bundle:
291
- *
292
- * ```json
293
- * {
294
- * "resourceType": "Bundle",
295
- * "type": "searchest",
296
- * "total": 1,
297
- * "entry": [
298
- * {
299
- * "resource": {
300
- * "resourceType": "Patient",
301
- * "name": [
302
- * {
303
- * "given": [
304
- * "George"
305
- * ],
306
- * "family": "Washington"
307
- * }
308
- * ],
309
- * }
310
- * }
311
- * ]
312
- * }
313
- * ```
314
- *
315
- * See FHIR search for full details: https://www.hl7.org/fhir/search.html
316
- *
317
- * @param query The search query as either a string or a structured search object.
318
- * @returns Promise to the search result bundle.
319
- */
320
- search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<Bundle<T>>;
321
- /**
322
- * Sends a FHIR search request for a single resource.
323
- *
324
- * This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.
325
- *
326
- * Example using a FHIR search string:
327
- *
328
- * ```typescript
329
- * const patient = await client.searchOne('Patient?identifier=123');
330
- * console.log(patient);
331
- * ```
332
- *
333
- * The return value is the resource, if available; otherwise, undefined.
334
- *
335
- * See FHIR search for full details: https://www.hl7.org/fhir/search.html
336
- *
337
- * @param query The search query as either a string or a structured search object.
338
- * @returns Promise to the search result bundle.
339
- */
340
- searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T | undefined>;
341
- /**
342
- * Sends a FHIR search request for an array of resources.
343
- *
344
- * This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.
345
- *
346
- * Example using a FHIR search string:
347
- *
348
- * ```typescript
349
- * const patients = await client.searchResources('Patient?name=Alice');
350
- * console.log(patients);
351
- * ```
352
- *
353
- * The return value is an array of resources.
354
- *
355
- * See FHIR search for full details: https://www.hl7.org/fhir/search.html
356
- *
357
- * @param query The search query as either a string or a structured search object.
358
- * @returns Promise to the search result bundle.
359
- */
360
- searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T[]>;
361
- /**
362
- * Searches a ValueSet resource using the "expand" operation.
363
- * See: https://www.hl7.org/fhir/operation-valueset-expand.html
364
- * @param system The ValueSet system url.
365
- * @param filter The search string.
366
- * @returns Promise to expanded ValueSet.
367
- */
368
- searchValueSet(system: string, filter: string, options?: RequestInit): Promise<ValueSet>;
369
- /**
370
- * Returns a cached resource if it is available.
371
- * @param resourceType The FHIR resource type.
372
- * @param id The FHIR resource ID.
373
- * @returns The resource if it is available in the cache; undefined otherwise.
374
- */
375
- getCached<T extends Resource>(resourceType: string, id: string): T | undefined;
376
- /**
377
- * Returns a cached resource if it is available.
378
- * @param resourceType The FHIR resource type.
379
- * @param id The FHIR resource ID.
380
- * @returns The resource if it is available in the cache; undefined otherwise.
381
- */
382
- getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined;
383
- /**
384
- * Reads a resource by resource type and ID.
385
- *
386
- * Example:
387
- *
388
- * ```typescript
389
- * const patient = await medplum.readResource('Patient', '123');
390
- * console.log(patient);
391
- * ```
392
- *
393
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
394
- *
395
- * @param resourceType The FHIR resource type.
396
- * @param id The resource ID.
397
- * @returns The resource if available; undefined otherwise.
398
- */
399
- readResource<T extends Resource>(resourceType: string, id: string): Promise<T>;
400
- /**
401
- * Reads a resource by resource type and ID using the in-memory resource cache.
402
- *
403
- * If the resource is not available in the cache, it will be read from the server.
404
- *
405
- * Example:
406
- *
407
- * ```typescript
408
- * const patient = await medplum.readCached('Patient', '123');
409
- * console.log(patient);
410
- * ```
411
- *
412
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
413
- *
414
- * @param resourceType The FHIR resource type.
415
- * @param id The resource ID.
416
- * @returns The resource if available; undefined otherwise.
417
- */
418
- readCached<T extends Resource>(resourceType: string, id: string): Promise<T>;
419
- /**
420
- * Reads a resource by `Reference`.
421
- *
422
- * This is a convenience method for `readResource()` that accepts a `Reference` object.
423
- *
424
- * Example:
425
- *
426
- * ```typescript
427
- * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
428
- * const patient = await medplum.readReference(serviceRequest.subject);
429
- * console.log(patient);
430
- * ```
431
- *
432
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
433
- *
434
- * @param reference The FHIR reference object.
435
- * @returns The resource if available; undefined otherwise.
436
- */
437
- readReference<T extends Resource>(reference: Reference<T>): Promise<T>;
438
- /**
439
- * Reads a resource by `Reference` using the in-memory resource cache.
440
- *
441
- * This is a convenience method for `readResource()` that accepts a `Reference` object.
442
- *
443
- * If the resource is not available in the cache, it will be read from the server.
444
- *
445
- * Example:
446
- *
447
- * ```typescript
448
- * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
449
- * const patient = await medplum.readCachedReference(serviceRequest.subject);
450
- * console.log(patient);
451
- * ```
452
- *
453
- * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
454
- *
455
- * @param reference The FHIR reference object.
456
- * @returns The resource if available; undefined otherwise.
457
- */
458
- readCachedReference<T extends Resource>(reference: Reference<T>): Promise<T>;
459
- /**
460
- * Returns a cached schema for a resource type.
461
- * If the schema is not cached, returns undefined.
462
- * It is assumed that a client will call requestSchema before using this method.
463
- * @param resourceType The FHIR resource type.
464
- * @returns The schema if immediately available, undefined otherwise.
465
- */
466
- getSchema(): IndexedStructureDefinition;
467
- /**
468
- * Requests the schema for a resource type.
469
- * If the schema is already cached, the promise is resolved immediately.
470
- * @param resourceType The FHIR resource type.
471
- * @returns Promise to a schema with the requested resource type.
472
- */
473
- requestSchema(resourceType: string): Promise<IndexedStructureDefinition>;
474
- /**
475
- * Reads resource history by resource type and ID.
476
- *
477
- * The return value is a bundle of all versions of the resource.
478
- *
479
- * Example:
480
- *
481
- * ```typescript
482
- * const history = await medplum.readHistory('Patient', '123');
483
- * console.log(history);
484
- * ```
485
- *
486
- * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
487
- *
488
- * @param resourceType The FHIR resource type.
489
- * @param id The resource ID.
490
- * @returns The resource if available; undefined otherwise.
491
- */
492
- readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
493
- /**
494
- * Reads a specific version of a resource by resource type, ID, and version ID.
495
- *
496
- * Example:
497
- *
498
- * ```typescript
499
- * const version = await medplum.readVersion('Patient', '123', '456');
500
- * console.log(version);
501
- * ```
502
- *
503
- * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
504
- *
505
- * @param resourceType The FHIR resource type.
506
- * @param id The resource ID.
507
- * @returns The resource if available; undefined otherwise.
508
- */
509
- readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>;
510
- readPatientEverything(id: string): Promise<Bundle>;
511
- /**
512
- * Creates a new FHIR resource.
513
- *
514
- * The return value is the newly created resource, including the ID and meta.
515
- *
516
- * Example:
517
- *
518
- * ```typescript
519
- * const result = await medplum.createResource({
520
- * resourceType: 'Patient',
521
- * name: [{
522
- * family: 'Smith',
523
- * given: ['John']
524
- * }]
525
- * });
526
- * console.log(result.id);
527
- * ```
528
- *
529
- * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
530
- *
531
- * @param resource The FHIR resource to create.
532
- * @returns The result of the create operation.
533
- */
534
- createResource<T extends Resource>(resource: T): Promise<T>;
535
- /**
536
- * Creates a FHIR `Binary` resource with the provided data content.
537
- *
538
- * The return value is the newly created resource, including the ID and meta.
539
- *
540
- * The `data` parameter can be a string or a `File` object.
541
- *
542
- * A `File` object often comes from a `<input type="file">` element.
543
- *
544
- * Example:
545
- *
546
- * ```typescript
547
- * const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');
548
- * console.log(result.id);
549
- * ```
550
- *
551
- * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
552
- *
553
- * @param resource The FHIR resource to create.
554
- * @returns The result of the create operation.
555
- */
556
- createBinary(data: any, filename: string, contentType: string): Promise<Binary>;
557
- /**
558
- * Updates a FHIR resource.
559
- *
560
- * The return value is the updated resource, including the ID and meta.
561
- *
562
- * Example:
563
- *
564
- * ```typescript
565
- * const result = await medplum.updateResource({
566
- * resourceType: 'Patient',
567
- * id: '123',
568
- * name: [{
569
- * family: 'Smith',
570
- * given: ['John']
571
- * }]
572
- * });
573
- * console.log(result.meta.versionId);
574
- * ```
575
- *
576
- * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
577
- *
578
- * @param resource The FHIR resource to update.
579
- * @returns The result of the update operation.
580
- */
581
- updateResource<T extends Resource>(resource: T): Promise<T>;
582
- /**
583
- * Updates a FHIR resource using JSONPatch operations.
584
- *
585
- * The return value is the updated resource, including the ID and meta.
586
- *
587
- * Example:
588
- *
589
- * ```typescript
590
- * const result = await medplum.patchResource('Patient', '123', [
591
- * {op: 'replace', path: '/name/0/family', value: 'Smith'},
592
- * ]);
593
- * console.log(result.meta.versionId);
594
- * ```
595
- *
596
- * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
597
- *
598
- * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
599
- *
600
- * @param resourceType The FHIR resource type.
601
- * @param id The resource ID.
602
- * @param operations The JSONPatch operations.
603
- * @returns The result of the patch operations.
604
- */
605
- patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>;
606
- /**
607
- * Deletes a FHIR resource by resource type and ID.
608
- *
609
- * Example:
610
- *
611
- * ```typescript
612
- * await medplum.deleteResource('Patient', '123');
613
- * ```
614
- *
615
- * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
616
- *
617
- * @param resourceType The FHIR resource type.
618
- * @param id The resource ID.
619
- * @returns The result of the delete operation.
620
- */
621
- deleteResource(resourceType: string, id: string): Promise<any>;
622
- graphql(query: string, options?: RequestInit): Promise<any>;
623
- getActiveLogin(): LoginState | undefined;
624
- setActiveLogin(login: LoginState): Promise<void>;
625
- setAccessToken(accessToken: string): void;
626
- getLogins(): LoginState[];
627
- isLoading(): boolean;
628
- getProfile(): ProfileResource | undefined;
629
- getProfileAsync(): Promise<ProfileResource | undefined>;
630
- getUserConfiguration(): UserConfiguration | undefined;
631
- /**
632
- * Downloads the URL as a blob.
633
- * @param url The URL to request.
634
- * @returns Promise to the response body as a blob.
635
- */
636
- download(url: string, options?: RequestInit): Promise<Blob>;
637
- /**
638
- * Processes an OAuth authorization code.
639
- * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
640
- * @param code The authorization code received by URL parameter.
641
- */
642
- processCode(code: string): Promise<ProfileResource>;
643
- clientCredentials(clientId: string, clientSecret: string): Promise<ProfileResource>;
644
- }
1
+ import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
+ import type { Operation } from 'fast-json-patch';
3
+ import { EventTarget } from './eventtarget';
4
+ import { Hl7Message } from './hl7';
5
+ import { ReadablePromise } from './readablepromise';
6
+ import { SearchRequest } from './search';
7
+ import { IndexedStructureDefinition } from './types';
8
+ import { ProfileResource } from './utils';
9
+ export interface MedplumClientOptions {
10
+ /**
11
+ * The client ID.
12
+ * Optional. Default is to defer to the server to use the default client.
13
+ * Use this to use a specific client for SMART-on-FHIR.
14
+ */
15
+ clientId?: string;
16
+ /**
17
+ * Base server URL.
18
+ * Optional. Default value is "https://api.medplum.com/".
19
+ * Use this to point to a custom Medplum deployment.
20
+ */
21
+ baseUrl?: string;
22
+ /**
23
+ * OAuth2 authorize URL.
24
+ * Optional. Default value is baseUrl + "/oauth2/authorize".
25
+ * Use this if you want to use a separate OAuth server.
26
+ */
27
+ authorizeUrl?: string;
28
+ /**
29
+ * OAuth2 token URL.
30
+ * Optional. Default value is baseUrl + "/oauth2/token".
31
+ * Use this if you want to use a separate OAuth server.
32
+ */
33
+ tokenUrl?: string;
34
+ /**
35
+ * OAuth2 logout URL.
36
+ * Optional. Default value is baseUrl + "/oauth2/logout".
37
+ * Use this if you want to use a separate OAuth server.
38
+ */
39
+ logoutUrl?: string;
40
+ /**
41
+ * Number of resources to store in the cache.
42
+ * Optional. Default value is 1000.
43
+ * Consider using this for performance of displaying Patient or Practitioner resources.
44
+ */
45
+ resourceCacheSize?: number;
46
+ /**
47
+ * Optional fetch implementation.
48
+ * Optional. Default is window.fetch.
49
+ * For nodejs applications, consider the 'node-fetch' package.
50
+ */
51
+ fetch?: FetchLike;
52
+ /**
53
+ * Optional callback for when the client is unauthenticated.
54
+ * Default is do nothing.
55
+ * For client side applications, consider redirecting to a sign in page.
56
+ */
57
+ onUnauthenticated?: () => void;
58
+ }
59
+ export interface FetchLike {
60
+ (url: string, options?: any): Promise<any>;
61
+ }
62
+ export interface RegisterRequest {
63
+ readonly firstName: string;
64
+ readonly lastName: string;
65
+ readonly projectName: string;
66
+ readonly email: string;
67
+ readonly password: string;
68
+ readonly remember?: boolean;
69
+ readonly recaptchaToken: string;
70
+ }
71
+ export interface GoogleCredentialResponse {
72
+ readonly clientId: string;
73
+ readonly credential: string;
74
+ }
75
+ export interface LoginAuthenticationResponse {
76
+ readonly login: string;
77
+ readonly code?: string;
78
+ readonly memberships?: ProjectMembership[];
79
+ }
80
+ export interface LoginProfileResponse {
81
+ readonly login: string;
82
+ readonly scope: string;
83
+ }
84
+ export interface LoginScopeResponse {
85
+ readonly login: string;
86
+ readonly code: string;
87
+ }
88
+ export interface LoginState {
89
+ readonly project: Reference<Project>;
90
+ readonly profile: Reference<ProfileResource>;
91
+ readonly accessToken: string;
92
+ readonly refreshToken: string;
93
+ }
94
+ export interface TokenResponse {
95
+ readonly token_type: string;
96
+ readonly id_token: string;
97
+ readonly access_token: string;
98
+ readonly refresh_token: string;
99
+ readonly expires_in: number;
100
+ readonly project: Reference<Project>;
101
+ readonly profile: Reference<ProfileResource>;
102
+ }
103
+ export interface BotEvent {
104
+ readonly contentType: string;
105
+ readonly input: Resource | Hl7Message | string;
106
+ }
107
+ /**
108
+ * The MedplumClient class provides a client for the Medplum FHIR server.
109
+ *
110
+ * The client can be used in the browser, in a NodeJS application, or in a Medplum Bot.
111
+ *
112
+ * The client provides helpful methods for common operations such as:
113
+ * 1) Authenticating
114
+ * 2) Creating resources
115
+ * 2) Reading resources
116
+ * 3) Updating resources
117
+ * 5) Deleting resources
118
+ * 6) Searching
119
+ * 7) Making GraphQL queries
120
+ *
121
+ * Here is a quick example of how to use the client:
122
+ *
123
+ * ```typescript
124
+ * import { MedplumClient } from '@medplum/core';
125
+ * const medplum = new MedplumClient();
126
+ * ```
127
+ *
128
+ * Create a `Patient`:
129
+ *
130
+ * ```typescript
131
+ * const patient = await medplum.createResource({
132
+ * resourceType: 'Patient',
133
+ * name: [{
134
+ * given: ['Alice'],
135
+ * family: 'Smith'
136
+ * }]
137
+ * });
138
+ * ```
139
+ *
140
+ * Read a `Patient` by ID:
141
+ *
142
+ * ```typescript
143
+ * const patient = await medplum.readResource('Patient', '123');
144
+ * console.log(patient.name[0].given[0]);
145
+ * ```
146
+ *
147
+ * Search for a `Patient` by name:
148
+ *
149
+ * ```typescript
150
+ * const bundle = await medplum.search('Patient?name=Alice');
151
+ * console.log(bundle.total);
152
+ * ```
153
+ *
154
+ */
155
+ export declare class MedplumClient extends EventTarget {
156
+ #private;
157
+ constructor(options?: MedplumClientOptions);
158
+ /**
159
+ * Clears all auth state including local storage and session storage.
160
+ */
161
+ clear(): void;
162
+ /**
163
+ * Makes an HTTP GET request to the specified URL.
164
+ *
165
+ * This is a lower level method for custom requests.
166
+ * For common operations, we recommend using higher level methods
167
+ * such as `readResource()`, `search()`, etc.
168
+ *
169
+ * @param url The target URL.
170
+ * @param options Optional fetch options.
171
+ * @returns Promise to the response content.
172
+ */
173
+ get<T = any>(url: string, options?: RequestInit): ReadablePromise<T>;
174
+ /**
175
+ * Makes an HTTP POST request to the specified URL.
176
+ *
177
+ * This is a lower level method for custom requests.
178
+ * For common operations, we recommend using higher level methods
179
+ * such as `createResource()`.
180
+ *
181
+ * @param url The target URL.
182
+ * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
183
+ * @param contentType The content type to be included in the "Content-Type" header.
184
+ * @param options Optional fetch options.
185
+ * @returns Promise to the response content.
186
+ */
187
+ post(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
188
+ /**
189
+ * Makes an HTTP PUT request to the specified URL.
190
+ *
191
+ * This is a lower level method for custom requests.
192
+ * For common operations, we recommend using higher level methods
193
+ * such as `updateResource()`.
194
+ *
195
+ * @param url The target URL.
196
+ * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
197
+ * @param contentType The content type to be included in the "Content-Type" header.
198
+ * @param options Optional fetch options.
199
+ * @returns Promise to the response content.
200
+ */
201
+ put(url: string, body: any, contentType?: string, options?: RequestInit): Promise<any>;
202
+ /**
203
+ * Makes an HTTP PATCH request to the specified URL.
204
+ *
205
+ * This is a lower level method for custom requests.
206
+ * For common operations, we recommend using higher level methods
207
+ * such as `patchResource()`.
208
+ *
209
+ * @param url The target URL.
210
+ * @param operations Array of JSONPatch operations.
211
+ * @param options Optional fetch options.
212
+ * @returns Promise to the response content.
213
+ */
214
+ patch(url: string, operations: Operation[], options?: RequestInit): Promise<any>;
215
+ /**
216
+ * Makes an HTTP DELETE request to the specified URL.
217
+ *
218
+ * This is a lower level method for custom requests.
219
+ * For common operations, we recommend using higher level methods
220
+ * such as `deleteResource()`.
221
+ *
222
+ * @param url The target URL.
223
+ * @param options Optional fetch options.
224
+ * @returns Promise to the response content.
225
+ */
226
+ delete(url: string, options?: RequestInit): Promise<any>;
227
+ /**
228
+ * Tries to register a new user.
229
+ * @param request The registration request.
230
+ * @returns Promise to the authentication response.
231
+ */
232
+ register(request: RegisterRequest): Promise<void>;
233
+ /**
234
+ * Initiates a user login flow.
235
+ * @param email The email address of the user.
236
+ * @param password The password of the user.
237
+ * @param remember Optional flag to remember the user.
238
+ * @returns Promise to the authentication response.
239
+ */
240
+ startLogin(email: string, password: string, remember?: boolean): Promise<LoginAuthenticationResponse>;
241
+ /**
242
+ * Tries to sign in with Google authentication.
243
+ * The response parameter is the result of a Google authentication.
244
+ * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
245
+ * @param googleResponse The Google credential response.
246
+ * @returns Promise to the authentication response.
247
+ */
248
+ startGoogleLogin(googleResponse: GoogleCredentialResponse): Promise<LoginAuthenticationResponse>;
249
+ /**
250
+ * Signs out locally.
251
+ * Does not invalidate tokens with the server.
252
+ */
253
+ signOut(): Promise<void>;
254
+ /**
255
+ * Tries to sign in the user.
256
+ * Returns true if the user is signed in.
257
+ * This may result in navigating away to the sign in page.
258
+ */
259
+ signInWithRedirect(): Promise<ProfileResource | void> | undefined;
260
+ /**
261
+ * Tries to sign out the user.
262
+ * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
263
+ */
264
+ signOutWithRedirect(): void;
265
+ /**
266
+ * Builds a FHIR URL from a collection of URL path components.
267
+ * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
268
+ * @param path The path component of the URL.
269
+ * @returns The well-formed FHIR URL.
270
+ */
271
+ fhirUrl(...path: string[]): string;
272
+ /**
273
+ * Sends a FHIR search request.
274
+ *
275
+ * Example using a FHIR search string:
276
+ *
277
+ * ```typescript
278
+ * const bundle = await client.search('Patient?name=Alice');
279
+ * console.log(bundle);
280
+ * ```
281
+ *
282
+ * Example using a structured search:
283
+ *
284
+ * ```typescript
285
+ * const bundle = await client.search({
286
+ * resourceType: 'Patient',
287
+ * filters: [{
288
+ * code: 'name',
289
+ * operator: 'eq',
290
+ * value: 'Alice',
291
+ * }]
292
+ * });
293
+ * console.log(bundle);
294
+ * ```
295
+ *
296
+ * The return value is a FHIR bundle:
297
+ *
298
+ * ```json
299
+ * {
300
+ * "resourceType": "Bundle",
301
+ * "type": "searchest",
302
+ * "total": 1,
303
+ * "entry": [
304
+ * {
305
+ * "resource": {
306
+ * "resourceType": "Patient",
307
+ * "name": [
308
+ * {
309
+ * "given": [
310
+ * "George"
311
+ * ],
312
+ * "family": "Washington"
313
+ * }
314
+ * ],
315
+ * }
316
+ * }
317
+ * ]
318
+ * }
319
+ * ```
320
+ *
321
+ * See FHIR search for full details: https://www.hl7.org/fhir/search.html
322
+ *
323
+ * @param query The search query as either a string or a structured search object.
324
+ * @returns Promise to the search result bundle.
325
+ */
326
+ search<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<Bundle<T>>;
327
+ /**
328
+ * Sends a FHIR search request for a single resource.
329
+ *
330
+ * This is a convenience method for `search()` that returns the first resource rather than a `Bundle`.
331
+ *
332
+ * Example using a FHIR search string:
333
+ *
334
+ * ```typescript
335
+ * const patient = await client.searchOne('Patient?identifier=123');
336
+ * console.log(patient);
337
+ * ```
338
+ *
339
+ * The return value is the resource, if available; otherwise, undefined.
340
+ *
341
+ * See FHIR search for full details: https://www.hl7.org/fhir/search.html
342
+ *
343
+ * @param query The search query as either a string or a structured search object.
344
+ * @returns Promise to the search result bundle.
345
+ */
346
+ searchOne<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T | undefined>;
347
+ /**
348
+ * Sends a FHIR search request for an array of resources.
349
+ *
350
+ * This is a convenience method for `search()` that returns the resources as an array rather than a `Bundle`.
351
+ *
352
+ * Example using a FHIR search string:
353
+ *
354
+ * ```typescript
355
+ * const patients = await client.searchResources('Patient?name=Alice');
356
+ * console.log(patients);
357
+ * ```
358
+ *
359
+ * The return value is an array of resources.
360
+ *
361
+ * See FHIR search for full details: https://www.hl7.org/fhir/search.html
362
+ *
363
+ * @param query The search query as either a string or a structured search object.
364
+ * @returns Promise to the search result bundle.
365
+ */
366
+ searchResources<T extends Resource>(query: string | SearchRequest, options?: RequestInit): Promise<T[]>;
367
+ /**
368
+ * Searches a ValueSet resource using the "expand" operation.
369
+ * See: https://www.hl7.org/fhir/operation-valueset-expand.html
370
+ * @param system The ValueSet system url.
371
+ * @param filter The search string.
372
+ * @returns Promise to expanded ValueSet.
373
+ */
374
+ searchValueSet(system: string, filter: string, options?: RequestInit): Promise<ValueSet>;
375
+ /**
376
+ * Returns a cached resource if it is available.
377
+ * @param resourceType The FHIR resource type.
378
+ * @param id The FHIR resource ID.
379
+ * @returns The resource if it is available in the cache; undefined otherwise.
380
+ */
381
+ getCached<T extends Resource>(resourceType: string, id: string): T | undefined;
382
+ /**
383
+ * Returns a cached resource if it is available.
384
+ * @param resourceType The FHIR resource type.
385
+ * @param id The FHIR resource ID.
386
+ * @returns The resource if it is available in the cache; undefined otherwise.
387
+ */
388
+ getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined;
389
+ /**
390
+ * Reads a resource by resource type and ID.
391
+ *
392
+ * Example:
393
+ *
394
+ * ```typescript
395
+ * const patient = await medplum.readResource('Patient', '123');
396
+ * console.log(patient);
397
+ * ```
398
+ *
399
+ * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
400
+ *
401
+ * @param resourceType The FHIR resource type.
402
+ * @param id The resource ID.
403
+ * @returns The resource if available; undefined otherwise.
404
+ */
405
+ readResource<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
406
+ /**
407
+ * Reads a resource by resource type and ID using the in-memory resource cache.
408
+ *
409
+ * If the resource is not available in the cache, it will be read from the server.
410
+ *
411
+ * Example:
412
+ *
413
+ * ```typescript
414
+ * const patient = await medplum.readCached('Patient', '123');
415
+ * console.log(patient);
416
+ * ```
417
+ *
418
+ * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
419
+ *
420
+ * @param resourceType The FHIR resource type.
421
+ * @param id The resource ID.
422
+ * @returns The resource if available; undefined otherwise.
423
+ */
424
+ readCached<T extends Resource>(resourceType: string, id: string): ReadablePromise<T>;
425
+ /**
426
+ * Reads a resource by `Reference`.
427
+ *
428
+ * This is a convenience method for `readResource()` that accepts a `Reference` object.
429
+ *
430
+ * Example:
431
+ *
432
+ * ```typescript
433
+ * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
434
+ * const patient = await medplum.readReference(serviceRequest.subject);
435
+ * console.log(patient);
436
+ * ```
437
+ *
438
+ * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
439
+ *
440
+ * @param reference The FHIR reference object.
441
+ * @returns The resource if available; undefined otherwise.
442
+ */
443
+ readReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
444
+ /**
445
+ * Reads a resource by `Reference` using the in-memory resource cache.
446
+ *
447
+ * This is a convenience method for `readResource()` that accepts a `Reference` object.
448
+ *
449
+ * If the resource is not available in the cache, it will be read from the server.
450
+ *
451
+ * Example:
452
+ *
453
+ * ```typescript
454
+ * const serviceRequest = await medplum.readResource('ServiceRequest', '123');
455
+ * const patient = await medplum.readCachedReference(serviceRequest.subject);
456
+ * console.log(patient);
457
+ * ```
458
+ *
459
+ * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
460
+ *
461
+ * @param reference The FHIR reference object.
462
+ * @returns The resource if available; undefined otherwise.
463
+ */
464
+ readCachedReference<T extends Resource>(reference: Reference<T>): ReadablePromise<T>;
465
+ /**
466
+ * Returns a cached schema for a resource type.
467
+ * If the schema is not cached, returns undefined.
468
+ * It is assumed that a client will call requestSchema before using this method.
469
+ * @param resourceType The FHIR resource type.
470
+ * @returns The schema if immediately available, undefined otherwise.
471
+ */
472
+ getSchema(): IndexedStructureDefinition;
473
+ /**
474
+ * Requests the schema for a resource type.
475
+ * If the schema is already cached, the promise is resolved immediately.
476
+ * @param resourceType The FHIR resource type.
477
+ * @returns Promise to a schema with the requested resource type.
478
+ */
479
+ requestSchema(resourceType: string): Promise<IndexedStructureDefinition>;
480
+ /**
481
+ * Reads resource history by resource type and ID.
482
+ *
483
+ * The return value is a bundle of all versions of the resource.
484
+ *
485
+ * Example:
486
+ *
487
+ * ```typescript
488
+ * const history = await medplum.readHistory('Patient', '123');
489
+ * console.log(history);
490
+ * ```
491
+ *
492
+ * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
493
+ *
494
+ * @param resourceType The FHIR resource type.
495
+ * @param id The resource ID.
496
+ * @returns The resource if available; undefined otherwise.
497
+ */
498
+ readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>;
499
+ /**
500
+ * Reads a specific version of a resource by resource type, ID, and version ID.
501
+ *
502
+ * Example:
503
+ *
504
+ * ```typescript
505
+ * const version = await medplum.readVersion('Patient', '123', '456');
506
+ * console.log(version);
507
+ * ```
508
+ *
509
+ * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
510
+ *
511
+ * @param resourceType The FHIR resource type.
512
+ * @param id The resource ID.
513
+ * @returns The resource if available; undefined otherwise.
514
+ */
515
+ readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>;
516
+ readPatientEverything(id: string): Promise<Bundle>;
517
+ /**
518
+ * Creates a new FHIR resource.
519
+ *
520
+ * The return value is the newly created resource, including the ID and meta.
521
+ *
522
+ * Example:
523
+ *
524
+ * ```typescript
525
+ * const result = await medplum.createResource({
526
+ * resourceType: 'Patient',
527
+ * name: [{
528
+ * family: 'Smith',
529
+ * given: ['John']
530
+ * }]
531
+ * });
532
+ * console.log(result.id);
533
+ * ```
534
+ *
535
+ * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
536
+ *
537
+ * @param resource The FHIR resource to create.
538
+ * @returns The result of the create operation.
539
+ */
540
+ createResource<T extends Resource>(resource: T): Promise<T>;
541
+ /**
542
+ * Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
543
+ *
544
+ * The return value is the existing resource or the newly created resource, including the ID and meta.
545
+ *
546
+ * Example:
547
+ *
548
+ * ```typescript
549
+ * const result = await medplum.createResourceIfNoneExist(
550
+ * 'Patient?identifier=123',
551
+ * {
552
+ * resourceType: 'Patient',
553
+ * identifier: [{
554
+ * system: 'http://example.com/mrn',
555
+ * value: '123'
556
+ * }]
557
+ * name: [{
558
+ * family: 'Smith',
559
+ * given: ['John']
560
+ * }]
561
+ * });
562
+ * console.log(result.id);
563
+ * ```
564
+ *
565
+ * This method is syntactic sugar for:
566
+ *
567
+ * ```typescript
568
+ * return searchOne(query) ?? createResource(resource);
569
+ * ```
570
+ *
571
+ * The query parameter only contains the search parameters (what would be in the URL following the "?").
572
+ *
573
+ * See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
574
+ *
575
+ * @param resource The FHIR resource to create.
576
+ * @param query The search query for an equivalent resource.
577
+ * @returns The result of the create operation.
578
+ */
579
+ createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T>;
580
+ /**
581
+ * Creates a FHIR `Binary` resource with the provided data content.
582
+ *
583
+ * The return value is the newly created resource, including the ID and meta.
584
+ *
585
+ * The `data` parameter can be a string or a `File` object.
586
+ *
587
+ * A `File` object often comes from a `<input type="file">` element.
588
+ *
589
+ * Example:
590
+ *
591
+ * ```typescript
592
+ * const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');
593
+ * console.log(result.id);
594
+ * ```
595
+ *
596
+ * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
597
+ *
598
+ * @param data The binary data to upload.
599
+ * @param filename Optional filename for the binary.
600
+ * @param contentType Content type for the binary.
601
+ * @returns The result of the create operation.
602
+ */
603
+ createBinary(data: string | File, filename: string | undefined, contentType: string): Promise<Binary>;
604
+ /**
605
+ * Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
606
+ *
607
+ * The return value is the newly created resource, including the ID and meta.
608
+ *
609
+ * The `docDefinition` parameter is a pdfmake document definition.
610
+ *
611
+ * Example:
612
+ *
613
+ * ```typescript
614
+ * const result = await medplum.createPdf({
615
+ * content: ['Hello world']
616
+ * });
617
+ * console.log(result.id);
618
+ * ```
619
+ *
620
+ * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
621
+ *
622
+ * @param docDefinition The FHIR resource to create.
623
+ * @returns The result of the create operation.
624
+ */
625
+ createPdf(docDefinition: Record<string, unknown>, filename?: string): Promise<Binary>;
626
+ /**
627
+ * Updates a FHIR resource.
628
+ *
629
+ * The return value is the updated resource, including the ID and meta.
630
+ *
631
+ * Example:
632
+ *
633
+ * ```typescript
634
+ * const result = await medplum.updateResource({
635
+ * resourceType: 'Patient',
636
+ * id: '123',
637
+ * name: [{
638
+ * family: 'Smith',
639
+ * given: ['John']
640
+ * }]
641
+ * });
642
+ * console.log(result.meta.versionId);
643
+ * ```
644
+ *
645
+ * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
646
+ *
647
+ * @param resource The FHIR resource to update.
648
+ * @returns The result of the update operation.
649
+ */
650
+ updateResource<T extends Resource>(resource: T): Promise<T>;
651
+ /**
652
+ * Updates a FHIR resource using JSONPatch operations.
653
+ *
654
+ * The return value is the updated resource, including the ID and meta.
655
+ *
656
+ * Example:
657
+ *
658
+ * ```typescript
659
+ * const result = await medplum.patchResource('Patient', '123', [
660
+ * {op: 'replace', path: '/name/0/family', value: 'Smith'},
661
+ * ]);
662
+ * console.log(result.meta.versionId);
663
+ * ```
664
+ *
665
+ * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
666
+ *
667
+ * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
668
+ *
669
+ * @param resourceType The FHIR resource type.
670
+ * @param id The resource ID.
671
+ * @param operations The JSONPatch operations.
672
+ * @returns The result of the patch operations.
673
+ */
674
+ patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>;
675
+ /**
676
+ * Deletes a FHIR resource by resource type and ID.
677
+ *
678
+ * Example:
679
+ *
680
+ * ```typescript
681
+ * await medplum.deleteResource('Patient', '123');
682
+ * ```
683
+ *
684
+ * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
685
+ *
686
+ * @param resourceType The FHIR resource type.
687
+ * @param id The resource ID.
688
+ * @returns The result of the delete operation.
689
+ */
690
+ deleteResource(resourceType: string, id: string): Promise<any>;
691
+ graphql(query: string, options?: RequestInit): Promise<any>;
692
+ getActiveLogin(): LoginState | undefined;
693
+ setActiveLogin(login: LoginState): Promise<void>;
694
+ setAccessToken(accessToken: string): void;
695
+ getLogins(): LoginState[];
696
+ isLoading(): boolean;
697
+ getProfile(): ProfileResource | undefined;
698
+ getProfileAsync(): Promise<ProfileResource | undefined>;
699
+ getUserConfiguration(): UserConfiguration | undefined;
700
+ /**
701
+ * Downloads the URL as a blob.
702
+ * @param url The URL to request.
703
+ * @returns Promise to the response body as a blob.
704
+ */
705
+ download(url: string, options?: RequestInit): Promise<Blob>;
706
+ /**
707
+ * Processes an OAuth authorization code.
708
+ * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
709
+ * @param code The authorization code received by URL parameter.
710
+ */
711
+ processCode(code: string): Promise<ProfileResource>;
712
+ clientCredentials(clientId: string, clientSecret: string): Promise<ProfileResource>;
713
+ }