@medplum/core 2.0.21 → 2.0.23

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.
Files changed (58) hide show
  1. package/dist/cjs/index.cjs +720 -494
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.min.cjs +1 -1
  4. package/dist/esm/client.mjs +197 -114
  5. package/dist/esm/client.mjs.map +1 -1
  6. package/dist/esm/crypto.mjs +3 -1
  7. package/dist/esm/crypto.mjs.map +1 -1
  8. package/dist/esm/fhirlexer/parse.mjs.map +1 -1
  9. package/dist/esm/fhirlexer/tokenize.mjs +2 -2
  10. package/dist/esm/fhirlexer/tokenize.mjs.map +1 -1
  11. package/dist/esm/fhirpath/atoms.mjs +63 -56
  12. package/dist/esm/fhirpath/atoms.mjs.map +1 -1
  13. package/dist/esm/fhirpath/functions.mjs +370 -252
  14. package/dist/esm/fhirpath/functions.mjs.map +1 -1
  15. package/dist/esm/fhirpath/parse.mjs +4 -2
  16. package/dist/esm/fhirpath/parse.mjs.map +1 -1
  17. package/dist/esm/format.mjs +6 -4
  18. package/dist/esm/format.mjs.map +1 -1
  19. package/dist/esm/hl7.mjs +1 -1
  20. package/dist/esm/hl7.mjs.map +1 -1
  21. package/dist/esm/index.min.mjs +1 -1
  22. package/dist/esm/index.mjs +2 -1
  23. package/dist/esm/index.mjs.map +1 -1
  24. package/dist/esm/jwt.mjs +4 -2
  25. package/dist/esm/jwt.mjs.map +1 -1
  26. package/dist/esm/outcomes.mjs +14 -11
  27. package/dist/esm/outcomes.mjs.map +1 -1
  28. package/dist/esm/schema.mjs +4 -10
  29. package/dist/esm/schema.mjs.map +1 -1
  30. package/dist/esm/search/details.mjs +4 -5
  31. package/dist/esm/search/details.mjs.map +1 -1
  32. package/dist/esm/search/match.mjs +1 -0
  33. package/dist/esm/search/match.mjs.map +1 -1
  34. package/dist/esm/search/search.mjs +1 -1
  35. package/dist/esm/search/search.mjs.map +1 -1
  36. package/dist/esm/storage.mjs +8 -0
  37. package/dist/esm/storage.mjs.map +1 -1
  38. package/dist/esm/types.mjs +1 -0
  39. package/dist/esm/types.mjs.map +1 -1
  40. package/dist/esm/utils.mjs +8 -7
  41. package/dist/esm/utils.mjs.map +1 -1
  42. package/dist/types/client.d.ts +128 -69
  43. package/dist/types/crypto.d.ts +3 -1
  44. package/dist/types/fhirlexer/parse.d.ts +7 -3
  45. package/dist/types/fhirpath/atoms.d.ts +21 -21
  46. package/dist/types/fhirpath/functions.d.ts +2 -2
  47. package/dist/types/fhirpath/parse.d.ts +2 -1
  48. package/dist/types/hl7.d.ts +1 -1
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/jwt.d.ts +2 -1
  51. package/dist/types/outcomes.d.ts +7 -1
  52. package/dist/types/schema.d.ts +4 -10
  53. package/dist/types/search/details.d.ts +0 -1
  54. package/dist/types/search/search.d.ts +1 -1
  55. package/dist/types/storage.d.ts +8 -0
  56. package/dist/types/typeschema/types.d.ts +0 -1
  57. package/dist/types/utils.d.ts +5 -12
  58. package/package.json +1 -1
@@ -6,7 +6,7 @@ import { Hl7Message } from './hl7';
6
6
  import { ReadablePromise } from './readablepromise';
7
7
  import { ClientStorage } from './storage';
8
8
  import { IndexedStructureDefinition } from './types';
9
- import { InviteResult, ProfileResource } from './utils';
9
+ import { ProfileResource } from './utils';
10
10
  export declare const MEDPLUM_VERSION: string;
11
11
  /**
12
12
  * The MedplumClientOptions interface defines configuration options for MedplumClient.
@@ -60,6 +60,18 @@ export interface MedplumClientOptions {
60
60
  * Client ID can be used for SMART-on-FHIR customization.
61
61
  */
62
62
  clientId?: string;
63
+ /**
64
+ * The client secret.
65
+ *
66
+ * Client secret can be used for FHIR Oauth Client Credential flows
67
+ */
68
+ clientSecret?: string;
69
+ /**
70
+ * The OAuth Access Token.
71
+ *
72
+ * Access Token used to connect to make request to FHIR servers
73
+ */
74
+ accessToken?: string;
63
75
  /**
64
76
  * Number of resources to store in the cache.
65
77
  *
@@ -392,7 +404,6 @@ export declare enum OAuthTokenType {
392
404
  * <head>
393
405
  * <meta name="algolia:pageRank" content="100" />
394
406
  * </head>
395
-
396
407
  */
397
408
  export declare class MedplumClient extends EventTarget {
398
409
  private readonly fetch;
@@ -415,8 +426,7 @@ export declare class MedplumClient extends EventTarget {
415
426
  private refreshToken?;
416
427
  private refreshPromise?;
417
428
  private profilePromise?;
418
- private profile?;
419
- private config?;
429
+ private sessionDetails?;
420
430
  private basicAuth?;
421
431
  constructor(options?: MedplumClientOptions);
422
432
  /**
@@ -427,6 +437,14 @@ export declare class MedplumClient extends EventTarget {
427
437
  * @returns The current base URL for all API requests.
428
438
  */
429
439
  getBaseUrl(): string;
440
+ /**
441
+ * Returns the current authorize URL.
442
+ * By default, this is set to `https://api.medplum.com/oauth2/authorize`.
443
+ * This can be overridden by setting the `authorizeUrl` option when creating the client.
444
+ * @category HTTP
445
+ * @returns The current authorize URL.
446
+ */
447
+ getAuthorizeUrl(): string;
430
448
  /**
431
449
  * Clears all auth state including local storage and session storage.
432
450
  * @category Authentication
@@ -461,7 +479,6 @@ export declare class MedplumClient extends EventTarget {
461
479
  * This is a lower level method for custom requests.
462
480
  * For common operations, we recommend using higher level methods
463
481
  * such as `readResource()`, `search()`, etc.
464
- *
465
482
  * @category HTTP
466
483
  * @param url The target URL.
467
484
  * @param options Optional fetch options.
@@ -474,7 +491,6 @@ export declare class MedplumClient extends EventTarget {
474
491
  * This is a lower level method for custom requests.
475
492
  * For common operations, we recommend using higher level methods
476
493
  * such as `createResource()`.
477
- *
478
494
  * @category HTTP
479
495
  * @param url The target URL.
480
496
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
@@ -489,7 +505,6 @@ export declare class MedplumClient extends EventTarget {
489
505
  * This is a lower level method for custom requests.
490
506
  * For common operations, we recommend using higher level methods
491
507
  * such as `updateResource()`.
492
- *
493
508
  * @category HTTP
494
509
  * @param url The target URL.
495
510
  * @param body The content body. Strings and `File` objects are passed directly. Other objects are converted to JSON.
@@ -504,7 +519,6 @@ export declare class MedplumClient extends EventTarget {
504
519
  * This is a lower level method for custom requests.
505
520
  * For common operations, we recommend using higher level methods
506
521
  * such as `patchResource()`.
507
- *
508
522
  * @category HTTP
509
523
  * @param url The target URL.
510
524
  * @param operations Array of JSONPatch operations.
@@ -519,7 +533,6 @@ export declare class MedplumClient extends EventTarget {
519
533
  * This is a lower level method for custom requests.
520
534
  * For common operations, we recommend using higher level methods
521
535
  * such as `deleteResource()`.
522
- *
523
536
  * @category HTTP
524
537
  * @param url The target URL.
525
538
  * @param options Optional fetch options.
@@ -532,46 +545,48 @@ export declare class MedplumClient extends EventTarget {
532
545
  * This method is part of the two different user registration flows:
533
546
  * 1) New Practitioner and new Project
534
547
  * 2) New Patient registration
535
- *
536
548
  * @category Authentication
537
549
  * @param newUserRequest Register request including email and password.
550
+ * @param options Optional fetch options.
538
551
  * @returns Promise to the authentication response.
539
552
  */
540
- startNewUser(newUserRequest: NewUserRequest): Promise<LoginAuthenticationResponse>;
553
+ startNewUser(newUserRequest: NewUserRequest, options?: RequestInit): Promise<LoginAuthenticationResponse>;
541
554
  /**
542
555
  * Initiates a new project flow.
543
556
  *
544
557
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
545
- *
546
558
  * @param newProjectRequest Register request including email and password.
559
+ * @param options Optional fetch options.
547
560
  * @returns Promise to the authentication response.
548
561
  */
549
- startNewProject(newProjectRequest: NewProjectRequest): Promise<LoginAuthenticationResponse>;
562
+ startNewProject(newProjectRequest: NewProjectRequest, options?: RequestInit): Promise<LoginAuthenticationResponse>;
550
563
  /**
551
564
  * Initiates a new patient flow.
552
565
  *
553
566
  * This requires a partial login from `startNewUser` or `startNewGoogleUser`.
554
- *
555
567
  * @param newPatientRequest Register request including email and password.
568
+ * @param options Optional fetch options.
556
569
  * @returns Promise to the authentication response.
557
570
  */
558
- startNewPatient(newPatientRequest: NewPatientRequest): Promise<LoginAuthenticationResponse>;
571
+ startNewPatient(newPatientRequest: NewPatientRequest, options?: RequestInit): Promise<LoginAuthenticationResponse>;
559
572
  /**
560
573
  * Initiates a user login flow.
561
574
  * @category Authentication
562
575
  * @param loginRequest Login request including email and password.
576
+ * @param options Optional fetch options.
563
577
  * @returns Promise to the authentication response.
564
578
  */
565
- startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse>;
579
+ startLogin(loginRequest: EmailPasswordLoginRequest, options?: RequestInit): Promise<LoginAuthenticationResponse>;
566
580
  /**
567
581
  * Tries to sign in with Google authentication.
568
582
  * The response parameter is the result of a Google authentication.
569
583
  * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
570
584
  * @category Authentication
571
585
  * @param loginRequest Login request including Google credential response.
586
+ * @param options Optional fetch options.
572
587
  * @returns Promise to the authentication response.
573
588
  */
574
- startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
589
+ startGoogleLogin(loginRequest: GoogleLoginRequest, options?: RequestInit): Promise<LoginAuthenticationResponse>;
575
590
  /**
576
591
  * Returns the PKCE code challenge and method.
577
592
  * If the login request already includes a code challenge, it is returned.
@@ -593,6 +608,7 @@ export declare class MedplumClient extends EventTarget {
593
608
  * This may result in navigating away to the sign in page.
594
609
  * @category Authentication
595
610
  * @param loginParams Optional login parameters.
611
+ * @returns The user profile resource if available.
596
612
  */
597
613
  signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void>;
598
614
  /**
@@ -614,6 +630,7 @@ export declare class MedplumClient extends EventTarget {
614
630
  * Exchange an external access token for a Medplum access token.
615
631
  * @param token The access token that was generated by the external identity provider.
616
632
  * @param clientId The ID of the `ClientApplication` in your Medplum project that will be making the exchange request.
633
+ * @returns The user profile resource.
617
634
  * @category Authentication
618
635
  */
619
636
  exchangeExternalAccessToken(token: string, clientId?: string): Promise<ProfileResource>;
@@ -685,7 +702,6 @@ export declare class MedplumClient extends EventTarget {
685
702
  * ```
686
703
  *
687
704
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
688
- *
689
705
  * @category Search
690
706
  * @param resourceType The FHIR resource type.
691
707
  * @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
@@ -708,7 +724,6 @@ export declare class MedplumClient extends EventTarget {
708
724
  * The return value is the resource, if available; otherwise, undefined.
709
725
  *
710
726
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
711
- *
712
727
  * @category Search
713
728
  * @param resourceType The FHIR resource type.
714
729
  * @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
@@ -731,7 +746,6 @@ export declare class MedplumClient extends EventTarget {
731
746
  * The return value is an array of resources.
732
747
  *
733
748
  * See FHIR search for full details: https://www.hl7.org/fhir/search.html
734
- *
735
749
  * @category Search
736
750
  * @param resourceType The FHIR resource type.
737
751
  * @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
@@ -753,18 +767,16 @@ export declare class MedplumClient extends EventTarget {
753
767
  * }
754
768
  * }
755
769
  * ```
756
- *
757
770
  * @category Search
758
771
  * @param resourceType The FHIR resource type.
759
772
  * @param query Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor.
760
773
  * @param options Optional fetch options.
761
- * @returns An async generator, where each result is an array of resources for each page.
774
+ * @yields An async generator, where each result is an array of resources for each page.
762
775
  */
763
776
  searchResourcePages<K extends ResourceType>(resourceType: K, query?: QueryTypes, options?: RequestInit): AsyncGenerator<ExtractResource<K>[]>;
764
777
  /**
765
778
  * Searches a ValueSet resource using the "expand" operation.
766
779
  * See: https://www.hl7.org/fhir/operation-valueset-expand.html
767
- *
768
780
  * @category Search
769
781
  * @param system The ValueSet system url.
770
782
  * @param filter The search string.
@@ -783,8 +795,7 @@ export declare class MedplumClient extends EventTarget {
783
795
  /**
784
796
  * Returns a cached resource if it is available.
785
797
  * @category Caching
786
- * @param resourceType The FHIR resource type.
787
- * @param id The FHIR resource ID.
798
+ * @param reference The FHIR reference.
788
799
  * @returns The resource if it is available in the cache; undefined otherwise.
789
800
  */
790
801
  getCachedReference<T extends Resource>(reference: Reference<T>): T | undefined;
@@ -799,7 +810,6 @@ export declare class MedplumClient extends EventTarget {
799
810
  * ```
800
811
  *
801
812
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
802
- *
803
813
  * @category Read
804
814
  * @param resourceType The FHIR resource type.
805
815
  * @param id The resource ID.
@@ -821,7 +831,6 @@ export declare class MedplumClient extends EventTarget {
821
831
  * ```
822
832
  *
823
833
  * See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
824
- *
825
834
  * @category Read
826
835
  * @param reference The FHIR reference object.
827
836
  * @param options Optional fetch options.
@@ -858,7 +867,6 @@ export declare class MedplumClient extends EventTarget {
858
867
  * ```
859
868
  *
860
869
  * See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
861
- *
862
870
  * @category Read
863
871
  * @param resourceType The FHIR resource type.
864
872
  * @param id The resource ID.
@@ -877,7 +885,6 @@ export declare class MedplumClient extends EventTarget {
877
885
  * ```
878
886
  *
879
887
  * See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
880
- *
881
888
  * @category Read
882
889
  * @param resourceType The FHIR resource type.
883
890
  * @param id The resource ID.
@@ -897,7 +904,6 @@ export declare class MedplumClient extends EventTarget {
897
904
  * ```
898
905
  *
899
906
  * See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
900
- *
901
907
  * @category Read
902
908
  * @param id The Patient Id
903
909
  * @param options Optional fetch options.
@@ -923,12 +929,12 @@ export declare class MedplumClient extends EventTarget {
923
929
  * ```
924
930
  *
925
931
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
926
- *
927
932
  * @category Create
928
933
  * @param resource The FHIR resource to create.
934
+ * @param options Optional fetch options.
929
935
  * @returns The result of the create operation.
930
936
  */
931
- createResource<T extends Resource>(resource: T): Promise<T>;
937
+ createResource<T extends Resource>(resource: T, options?: RequestInit): Promise<T>;
932
938
  /**
933
939
  * Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
934
940
  *
@@ -963,13 +969,13 @@ export declare class MedplumClient extends EventTarget {
963
969
  * The query parameter only contains the search parameters (what would be in the URL following the "?").
964
970
  *
965
971
  * See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
966
- *
967
972
  * @category Create
968
973
  * @param resource The FHIR resource to create.
969
974
  * @param query The search query for an equivalent resource (should not include resource type or "?").
975
+ * @param options Optional fetch options.
970
976
  * @returns The result of the create operation.
971
977
  */
972
- createResourceIfNoneExist<T extends Resource>(resource: T, query: string): Promise<T>;
978
+ createResourceIfNoneExist<T extends Resource>(resource: T, query: string, options?: RequestInit): Promise<T>;
973
979
  /**
974
980
  * Creates a FHIR `Binary` resource with the provided data content.
975
981
  *
@@ -987,11 +993,11 @@ export declare class MedplumClient extends EventTarget {
987
993
  * ```
988
994
  *
989
995
  * See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
990
- *
991
996
  * @category Create
992
997
  * @param data The binary data to upload.
993
998
  * @param filename Optional filename for the binary.
994
999
  * @param contentType Content type for the binary.
1000
+ * @param onProgress Optional callback for progress events.
995
1001
  * @returns The result of the create operation.
996
1002
  */
997
1003
  createBinary(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Binary>;
@@ -1013,9 +1019,11 @@ export declare class MedplumClient extends EventTarget {
1013
1019
  * ```
1014
1020
  *
1015
1021
  * See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
1016
- *
1017
1022
  * @category Media
1018
1023
  * @param docDefinition The PDF document definition.
1024
+ * @param filename Optional filename for the PDF binary resource.
1025
+ * @param tableLayouts Optional pdfmake custom table layout.
1026
+ * @param fonts Optional pdfmake custom font dictionary.
1019
1027
  * @returns The result of the create operation.
1020
1028
  */
1021
1029
  createPdf(docDefinition: TDocumentDefinitions, filename?: string, tableLayouts?: {
@@ -1025,13 +1033,13 @@ export declare class MedplumClient extends EventTarget {
1025
1033
  * Creates a FHIR `Communication` resource with the provided data content.
1026
1034
  *
1027
1035
  * This is a convenience method to handle commmon cases where a `Communication` resource is created with a `payload`.
1028
- *
1029
1036
  * @category Create
1030
1037
  * @param resource The FHIR resource to comment on.
1031
1038
  * @param text The text of the comment.
1039
+ * @param options Optional fetch options.
1032
1040
  * @returns The result of the create operation.
1033
1041
  */
1034
- createComment(resource: Resource, text: string): Promise<Communication>;
1042
+ createComment(resource: Resource, text: string, options?: RequestInit): Promise<Communication>;
1035
1043
  /**
1036
1044
  * Updates a FHIR resource.
1037
1045
  *
@@ -1052,12 +1060,12 @@ export declare class MedplumClient extends EventTarget {
1052
1060
  * ```
1053
1061
  *
1054
1062
  * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
1055
- *
1056
1063
  * @category Write
1057
1064
  * @param resource The FHIR resource to update.
1065
+ * @param options Optional fetch options.
1058
1066
  * @returns The result of the update operation.
1059
1067
  */
1060
- updateResource<T extends Resource>(resource: T): Promise<T>;
1068
+ updateResource<T extends Resource>(resource: T, options?: RequestInit): Promise<T>;
1061
1069
  /**
1062
1070
  * Updates a FHIR resource using JSONPatch operations.
1063
1071
  *
@@ -1075,14 +1083,14 @@ export declare class MedplumClient extends EventTarget {
1075
1083
  * See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
1076
1084
  *
1077
1085
  * See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
1078
- *
1079
1086
  * @category Write
1080
1087
  * @param resourceType The FHIR resource type.
1081
1088
  * @param id The resource ID.
1082
1089
  * @param operations The JSONPatch operations.
1090
+ * @param options Optional fetch options.
1083
1091
  * @returns The result of the patch operations.
1084
1092
  */
1085
- patchResource<K extends ResourceType>(resourceType: K, id: string, operations: PatchOperation[]): Promise<ExtractResource<K>>;
1093
+ patchResource<K extends ResourceType>(resourceType: K, id: string, operations: PatchOperation[], options?: RequestInit): Promise<ExtractResource<K>>;
1086
1094
  /**
1087
1095
  * Deletes a FHIR resource by resource type and ID.
1088
1096
  *
@@ -1093,13 +1101,13 @@ export declare class MedplumClient extends EventTarget {
1093
1101
  * ```
1094
1102
  *
1095
1103
  * See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
1096
- *
1097
1104
  * @category Delete
1098
1105
  * @param resourceType The FHIR resource type.
1099
1106
  * @param id The resource ID.
1107
+ * @param options Optional fetch options.
1100
1108
  * @returns The result of the delete operation.
1101
1109
  */
1102
- deleteResource(resourceType: ResourceType, id: string): Promise<any>;
1110
+ deleteResource(resourceType: ResourceType, id: string, options?: RequestInit): Promise<any>;
1103
1111
  /**
1104
1112
  * Executes the validate operation with the provided resource.
1105
1113
  *
@@ -1113,11 +1121,11 @@ export declare class MedplumClient extends EventTarget {
1113
1121
  * ```
1114
1122
  *
1115
1123
  * See the FHIR "$validate" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html
1116
- *
1117
1124
  * @param resource The FHIR resource.
1125
+ * @param options Optional fetch options.
1118
1126
  * @returns The validate operation outcome.
1119
1127
  */
1120
- validateResource<T extends Resource>(resource: T): Promise<OperationOutcome>;
1128
+ validateResource<T extends Resource>(resource: T, options?: RequestInit): Promise<OperationOutcome>;
1121
1129
  /**
1122
1130
  * Executes a bot by ID.
1123
1131
  * @param id The Bot ID.
@@ -1219,10 +1227,11 @@ export declare class MedplumClient extends EventTarget {
1219
1227
  *
1220
1228
  * See options here: https://nodemailer.com/extras/mailcomposer/
1221
1229
  * @category Media
1222
- * @param options The MailComposer options.
1230
+ * @param email The MailComposer options.
1231
+ * @param options Optional fetch options.
1223
1232
  * @returns Promise to the operation outcome.
1224
1233
  */
1225
- sendEmail(email: MailOptions): Promise<OperationOutcome>;
1234
+ sendEmail(email: MailOptions, options?: RequestInit): Promise<OperationOutcome>;
1226
1235
  /**
1227
1236
  * Executes a GraphQL query.
1228
1237
  *
@@ -1263,7 +1272,6 @@ export declare class MedplumClient extends EventTarget {
1263
1272
  * See the GraphQL documentation for more details: https://graphql.org/learn/
1264
1273
  *
1265
1274
  * See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
1266
- *
1267
1275
  * @category Read
1268
1276
  * @param query The GraphQL query.
1269
1277
  * @param operationName Optional GraphQL operation name.
@@ -1276,75 +1284,121 @@ export declare class MedplumClient extends EventTarget {
1276
1284
  *
1277
1285
  * Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource
1278
1286
  * according to a graph definition
1279
-
1280
1287
  * @category Read
1281
1288
  * @param resourceType The FHIR resource type.
1282
1289
  * @param id The resource ID.
1283
1290
  * @param graphName `name` parameter of the GraphDefinition
1291
+ * @param options Optional fetch options.
1284
1292
  * @returns A Bundle
1285
1293
  */
1286
- readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string): ReadablePromise<Bundle<Resource>>;
1294
+ readResourceGraph<K extends ResourceType>(resourceType: K, id: string, graphName: string, options?: RequestInit): ReadablePromise<Bundle<Resource>>;
1287
1295
  /**
1288
1296
  * @category Authentication
1289
1297
  * @returns The Login State
1290
1298
  */
1291
1299
  getActiveLogin(): LoginState | undefined;
1292
1300
  /**
1301
+ * Sets the active login.
1302
+ * @param login The new active login state.
1293
1303
  * @category Authentication
1294
1304
  */
1295
1305
  setActiveLogin(login: LoginState): Promise<void>;
1296
1306
  /**
1297
1307
  * Returns the current access token.
1308
+ * @returns The current access token.
1298
1309
  * @category Authentication
1299
1310
  */
1300
1311
  getAccessToken(): string | undefined;
1301
1312
  /**
1302
1313
  * Sets the current access token.
1314
+ * @param accessToken The new access token.
1303
1315
  * @category Authentication
1304
1316
  */
1305
1317
  setAccessToken(accessToken: string): void;
1306
1318
  /**
1319
+ * Returns the list of available logins.
1320
+ * @returns The list of available logins.
1307
1321
  * @category Authentication
1308
1322
  */
1309
1323
  getLogins(): LoginState[];
1310
1324
  private addLogin;
1311
1325
  private refreshProfile;
1312
1326
  /**
1327
+ * Returns true if the client is waiting for authentication.
1328
+ * @returns True if the client is waiting for authentication.
1313
1329
  * @category Authentication
1314
1330
  */
1315
1331
  isLoading(): boolean;
1316
1332
  /**
1333
+ * Returns true if the current user is authenticated as a super admin.
1334
+ * @returns True if the current user is authenticated as a super admin.
1335
+ * @category Authentication
1336
+ */
1337
+ isSuperAdmin(): boolean;
1338
+ /**
1339
+ * Returns true if the current user is authenticated as a project admin.
1340
+ * @returns True if the current user is authenticated as a project admin.
1341
+ * @category Authentication
1342
+ */
1343
+ isProjectAdmin(): boolean;
1344
+ /**
1345
+ * Returns the current project if available.
1346
+ * @returns The current project if available.
1347
+ * @category User Profile
1348
+ */
1349
+ getProject(): Project | undefined;
1350
+ /**
1351
+ * Returns the current project membership if available.
1352
+ * @returns The current project membership if available.
1353
+ * @category User Profile
1354
+ */
1355
+ getProjectMembership(): ProjectMembership | undefined;
1356
+ /**
1357
+ * Returns the current user profile resource if available.
1358
+ * This method does not wait for loading promises.
1359
+ * @returns The current user profile resource if available.
1317
1360
  * @category User Profile
1318
1361
  */
1319
1362
  getProfile(): ProfileResource | undefined;
1320
1363
  /**
1364
+ * Returns the current user profile resource if available.
1365
+ * This method waits for loading promises.
1366
+ * @returns The current user profile resource if available.
1321
1367
  * @category User Profile
1322
1368
  */
1323
1369
  getProfileAsync(): Promise<ProfileResource | undefined>;
1324
1370
  /**
1371
+ * Returns the current user configuration if available.
1372
+ * @returns The current user configuration if available.
1325
1373
  * @category User Profile
1326
1374
  */
1327
1375
  getUserConfiguration(): UserConfiguration | undefined;
1376
+ /**
1377
+ * Returns the current user access policy if available.
1378
+ * @returns The current user access policy if available.
1379
+ * @category User Profile
1380
+ */
1381
+ getAccessPolicy(): AccessPolicy | undefined;
1328
1382
  /**
1329
1383
  * Downloads the URL as a blob.
1330
- *
1331
1384
  * @category Read
1332
1385
  * @param url The URL to request.
1386
+ * @param options Optional fetch request init options.
1333
1387
  * @returns Promise to the response body as a blob.
1334
1388
  */
1335
1389
  download(url: URL | string, options?: RequestInit): Promise<Blob>;
1336
1390
  /**
1337
1391
  * Upload media to the server and create a Media instance for the uploaded content.
1338
1392
  * @param contents The contents of the media file, as a string, Uint8Array, File, or Blob.
1339
- * @param contentType The media type of the content
1340
- * @param filename The name of the file to be uploaded, or undefined if not applicable
1341
- * @param additionalFields Additional fields for Media
1393
+ * @param contentType The media type of the content.
1394
+ * @param filename The name of the file to be uploaded, or undefined if not applicable.
1395
+ * @param additionalFields Additional fields for Media.
1396
+ * @param options Optional fetch options.
1342
1397
  * @returns Promise that resolves to the created Media
1343
1398
  */
1344
- uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>): Promise<Media>;
1399
+ uploadMedia(contents: string | Uint8Array | File | Blob, contentType: string, filename: string | undefined, additionalFields?: Partial<Media>, options?: RequestInit): Promise<Media>;
1345
1400
  /**
1346
1401
  * Performs Bulk Data Export operation request flow. See The FHIR "Bulk Data Export" for full details: https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-export
1347
- *
1348
1402
  * @param exportLevel Optional export level. Defaults to system level export. 'Group/:id' - Group of Patients, 'Patient' - All Patients.
1349
1403
  * @param resourceTypes A string of comma-delimited FHIR resource types.
1350
1404
  * @param since Resources will be included in the response if their state has changed after the supplied time (e.g. if Resource.meta.lastUpdated is later than the supplied _since time).
@@ -1379,10 +1433,10 @@ export declare class MedplumClient extends EventTarget {
1379
1433
  private deleteCacheEntry;
1380
1434
  /**
1381
1435
  * Makes an HTTP request.
1382
- * @param {string} method
1383
- * @param {string} url
1384
- * @param {string=} contentType
1385
- * @param {Object=} body
1436
+ * @param method The HTTP method (GET, POST, etc).
1437
+ * @param url The target URL.
1438
+ * @param options Optional fetch request init options.
1439
+ * @returns The JSON content body if available.
1386
1440
  */
1387
1441
  private request;
1388
1442
  private parseResponse;
@@ -1415,14 +1469,15 @@ export declare class MedplumClient extends EventTarget {
1415
1469
  * Otherwise, calls unauthenticated callbacks and rejects.
1416
1470
  * @param method The HTTP method of the original request.
1417
1471
  * @param url The URL of the original request.
1418
- * @param contentType The content type of the original request.
1419
- * @param body The body of the original request.
1472
+ * @param options Optional fetch request init options.
1473
+ * @returns The result of the retry.
1420
1474
  */
1421
1475
  private handleUnauthenticated;
1422
1476
  /**
1423
1477
  * Starts a new PKCE flow.
1424
1478
  * These PKCE values are stateful, and must survive redirects and page refreshes.
1425
1479
  * @category Authentication
1480
+ * @returns The PKCE code challenge details.
1426
1481
  */
1427
1482
  startPkce(): Promise<{
1428
1483
  codeChallengeMethod: string;
@@ -1431,7 +1486,8 @@ export declare class MedplumClient extends EventTarget {
1431
1486
  /**
1432
1487
  * Redirects the user to the login screen for authorization.
1433
1488
  * Clears all auth state including local storage and session storage.
1434
- * See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
1489
+ * @param loginParams The authorization login parameters.
1490
+ * @see https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
1435
1491
  */
1436
1492
  private requestAuthorization;
1437
1493
  /**
@@ -1439,12 +1495,14 @@ export declare class MedplumClient extends EventTarget {
1439
1495
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
1440
1496
  * @param code The authorization code received by URL parameter.
1441
1497
  * @param loginParams Optional login parameters.
1498
+ * @returns The user profile resource.
1442
1499
  * @category Authentication
1443
1500
  */
1444
1501
  processCode(code: string, loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource>;
1445
1502
  /**
1446
1503
  * Tries to refresh the auth tokens.
1447
- * See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
1504
+ * @returns The refresh promise if available; otherwise undefined.
1505
+ * @see https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
1448
1506
  */
1449
1507
  private refresh;
1450
1508
  /**
@@ -1472,7 +1530,6 @@ export declare class MedplumClient extends EventTarget {
1472
1530
  * // Example Search
1473
1531
  * await medplum.searchResources('Patient')
1474
1532
  * ```
1475
- *
1476
1533
  * @category Authentication
1477
1534
  * @param clientId The client ID.
1478
1535
  * @param clientSecret The client secret.
@@ -1482,20 +1539,22 @@ export declare class MedplumClient extends EventTarget {
1482
1539
  * Invite a user to a project.
1483
1540
  * @param projectId The project ID.
1484
1541
  * @param body The InviteBody.
1485
- * @returns Promise that returns an invite result or an operation outcome.
1542
+ * @returns Promise that returns a project membership or an operation outcome.
1486
1543
  */
1487
- invite(projectId: string, body: InviteBody): Promise<InviteResult | OperationOutcome>;
1544
+ invite(projectId: string, body: InviteBody): Promise<ProjectMembership | OperationOutcome>;
1488
1545
  /**
1489
1546
  * Makes a POST request to the tokens endpoint.
1490
1547
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
1491
1548
  * @param formBody Token parameters in URL encoded format.
1549
+ * @returns The user profile resource.
1492
1550
  */
1493
1551
  private fetchTokens;
1494
1552
  /**
1495
1553
  * Verifies the tokens received from the auth server.
1496
1554
  * Validates the JWT against the JWKS.
1497
1555
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
1498
- * @param tokens
1556
+ * @param tokens The token response.
1557
+ * @returns Promise to complete.
1499
1558
  */
1500
1559
  private verifyTokens;
1501
1560
  /**
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * Returns a cryptographically secure random string.
3
+ * @returns A cryptographically secure random string.
3
4
  */
4
5
  export declare function getRandomString(): string;
5
6
  /**
6
7
  * Encrypts a string with SHA256 encryption.
7
- * @param str
8
+ * @param str The unencrypted input string.
9
+ * @returns The encrypted value in an ArrayBuffer.
8
10
  */
9
11
  export declare function encryptSHA256(str: string): Promise<ArrayBuffer>;
@@ -1,13 +1,17 @@
1
1
  import { TypedValue } from '../types';
2
2
  import { Token } from './tokenize';
3
+ export interface AtomContext {
4
+ parent?: AtomContext;
5
+ variables: Record<string, TypedValue>;
6
+ }
3
7
  export interface Atom {
4
- eval(context: TypedValue[]): TypedValue[];
8
+ eval(context: AtomContext, input: TypedValue[]): TypedValue[];
5
9
  }
6
10
  export declare abstract class PrefixOperatorAtom implements Atom {
7
11
  readonly operator: string;
8
12
  readonly child: Atom;
9
13
  constructor(operator: string, child: Atom);
10
- abstract eval(context: TypedValue[]): TypedValue[];
14
+ abstract eval(context: AtomContext, input: TypedValue[]): TypedValue[];
11
15
  toString(): string;
12
16
  }
13
17
  export declare abstract class InfixOperatorAtom implements Atom {
@@ -15,7 +19,7 @@ export declare abstract class InfixOperatorAtom implements Atom {
15
19
  readonly left: Atom;
16
20
  readonly right: Atom;
17
21
  constructor(operator: string, left: Atom, right: Atom);
18
- abstract eval(context: TypedValue[]): TypedValue[];
22
+ abstract eval(context: AtomContext, input: TypedValue[]): TypedValue[];
19
23
  toString(): string;
20
24
  }
21
25
  export interface PrefixParselet {