@medplum/core 0.9.5 → 0.9.6

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,5 +1,6 @@
1
- import { Binary, Bundle, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
1
+ import { Binary, Bundle, OperationOutcome, Project, ProjectMembership, Reference, Resource, UserConfiguration, ValueSet } from '@medplum/fhirtypes';
2
2
  import type { Operation } from 'fast-json-patch';
3
+ import type Mail from 'nodemailer/lib/mailer';
3
4
  import { EventTarget } from './eventtarget';
4
5
  import { Hl7Message } from './hl7';
5
6
  import { ReadablePromise } from './readablepromise';
@@ -59,6 +60,12 @@ export interface MedplumClientOptions {
59
60
  export interface FetchLike {
60
61
  (url: string, options?: any): Promise<any>;
61
62
  }
63
+ export interface LoginRequest {
64
+ readonly email: string;
65
+ readonly password: string;
66
+ readonly remember?: boolean;
67
+ readonly projectId?: string;
68
+ }
62
69
  export interface RegisterRequest {
63
70
  readonly firstName: string;
64
71
  readonly lastName: string;
@@ -232,12 +239,10 @@ export declare class MedplumClient extends EventTarget {
232
239
  register(request: RegisterRequest): Promise<void>;
233
240
  /**
234
241
  * 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.
242
+ * @param loginRequest Login request including email and password.
238
243
  * @returns Promise to the authentication response.
239
244
  */
240
- startLogin(email: string, password: string, remember?: boolean): Promise<LoginAuthenticationResponse>;
245
+ startLogin(loginRequest: LoginRequest): Promise<LoginAuthenticationResponse>;
241
246
  /**
242
247
  * Tries to sign in with Google authentication.
243
248
  * The response parameter is the result of a Google authentication.
@@ -688,6 +693,44 @@ export declare class MedplumClient extends EventTarget {
688
693
  * @returns The result of the delete operation.
689
694
  */
690
695
  deleteResource(resourceType: string, id: string): Promise<any>;
696
+ /**
697
+ * Sends an email using the Medplum Email API.
698
+ *
699
+ * Builds the email using nodemailer MailComposer.
700
+ *
701
+ * Examples:
702
+ *
703
+ * Send a simple text email:
704
+ *
705
+ * ```typescript
706
+ * await medplum.sendEmail({
707
+ * to: 'alice@example.com',
708
+ * cc: 'bob@example.com',
709
+ * subject: 'Hello',
710
+ * text: 'Hello Alice',
711
+ * });
712
+ * ```
713
+ *
714
+ * Send an email with a `Binary` attachment:
715
+ *
716
+ * ```typescript
717
+ * await medplum.sendEmail({
718
+ * to: 'alice@example.com',
719
+ * subject: 'Email with attachment',
720
+ * text: 'See the attached report',
721
+ * attachments: [{
722
+ * filename: 'report.pdf',
723
+ * path: "Binary/" + binary.id
724
+ * }]
725
+ * });
726
+ * ```
727
+ *
728
+ * See options here: https://nodemailer.com/extras/mailcomposer/
729
+ *
730
+ * @param options The MailComposer options.
731
+ * @returns Promise to the operation outcome.
732
+ */
733
+ sendEmail(email: Mail.Options): Promise<OperationOutcome>;
691
734
  graphql(query: string, options?: RequestInit): Promise<any>;
692
735
  getActiveLogin(): LoginState | undefined;
693
736
  setActiveLogin(login: LoginState): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/core",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Medplum TS/JS Library",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -17,7 +17,8 @@
17
17
  "test": "jest"
18
18
  },
19
19
  "devDependencies": {
20
- "@medplum/fhirtypes": "0.9.5",
20
+ "@medplum/fhirtypes": "0.9.6",
21
+ "@types/nodemailer": "6.4.4",
21
22
  "fast-json-patch": "3.1.1"
22
23
  },
23
24
  "main": "dist/cjs/index.js",