@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.
package/dist/esm/index.js CHANGED
@@ -1548,23 +1548,13 @@ class MedplumClient extends EventTarget {
1548
1548
  }
1549
1549
  /**
1550
1550
  * Initiates a user login flow.
1551
- * @param email The email address of the user.
1552
- * @param password The password of the user.
1553
- * @param remember Optional flag to remember the user.
1551
+ * @param loginRequest Login request including email and password.
1554
1552
  * @returns Promise to the authentication response.
1555
1553
  */
1556
- startLogin(email, password, remember) {
1554
+ startLogin(loginRequest) {
1557
1555
  return __awaiter(this, void 0, void 0, function* () {
1558
1556
  yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
1559
- return this.post('auth/login', {
1560
- clientId: __classPrivateFieldGet(this, _MedplumClient_clientId, "f"),
1561
- scope: DEFAULT_SCOPE,
1562
- codeChallengeMethod: 'S256',
1563
- codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge'),
1564
- email,
1565
- password,
1566
- remember: !!remember,
1567
- });
1557
+ return this.post('auth/login', Object.assign(Object.assign({}, loginRequest), { clientId: __classPrivateFieldGet(this, _MedplumClient_clientId, "f"), scope: DEFAULT_SCOPE, codeChallengeMethod: 'S256', codeChallenge: __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge') }));
1568
1558
  });
1569
1559
  }
1570
1560
  /**
@@ -2171,6 +2161,46 @@ class MedplumClient extends EventTarget {
2171
2161
  deleteResource(resourceType, id) {
2172
2162
  return this.delete(this.fhirUrl(resourceType, id));
2173
2163
  }
2164
+ /**
2165
+ * Sends an email using the Medplum Email API.
2166
+ *
2167
+ * Builds the email using nodemailer MailComposer.
2168
+ *
2169
+ * Examples:
2170
+ *
2171
+ * Send a simple text email:
2172
+ *
2173
+ * ```typescript
2174
+ * await medplum.sendEmail({
2175
+ * to: 'alice@example.com',
2176
+ * cc: 'bob@example.com',
2177
+ * subject: 'Hello',
2178
+ * text: 'Hello Alice',
2179
+ * });
2180
+ * ```
2181
+ *
2182
+ * Send an email with a `Binary` attachment:
2183
+ *
2184
+ * ```typescript
2185
+ * await medplum.sendEmail({
2186
+ * to: 'alice@example.com',
2187
+ * subject: 'Email with attachment',
2188
+ * text: 'See the attached report',
2189
+ * attachments: [{
2190
+ * filename: 'report.pdf',
2191
+ * path: "Binary/" + binary.id
2192
+ * }]
2193
+ * });
2194
+ * ```
2195
+ *
2196
+ * See options here: https://nodemailer.com/extras/mailcomposer/
2197
+ *
2198
+ * @param options The MailComposer options.
2199
+ * @returns Promise to the operation outcome.
2200
+ */
2201
+ sendEmail(email) {
2202
+ return this.post('email/v1/send', email);
2203
+ }
2174
2204
  graphql(query, options) {
2175
2205
  return this.post(this.fhirUrl('$graphql'), { query }, JSON_CONTENT_TYPE, options);
2176
2206
  }