biz-email-builder-shared 1.6.73 → 1.6.75

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,4 +1,4 @@
1
- import { ISendGridConfig } from '../entity';
2
- import { Recipient } from './types';
1
+ import { ISendGridConfig } from "../entity";
2
+ import { Recipient } from "./types";
3
3
  export declare function sendFromSendGrid(config: ISendGridConfig, recipient: Recipient, subject: string, text: string, isHtml: boolean, analytics: any): Promise<any>;
4
4
  //# sourceMappingURL=sendFromSendGrid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAUpC,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,GAAG,gBA+Cf"}
1
+ {"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,gBA8CnJ"}
@@ -2,18 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sendFromSendGrid = sendFromSendGrid;
4
4
  function normalizeEmails(input) {
5
- return Array.isArray(input)
6
- ? input.map((email) => ({ email }))
7
- : [{ email: input }];
5
+ return Array.isArray(input) ? input.map((email) => ({ email })) : [{ email: input }];
8
6
  }
9
7
  async function sendFromSendGrid(config, recipient, subject, text, isHtml, analytics) {
10
8
  var _a;
11
- const client = require('@sendgrid/client'); // isolate per call
9
+ const client = require("@sendgrid/client");
12
10
  client.setApiKey(config.api_key);
13
- const contentType = isHtml ? 'text/html' : 'text/plain';
11
+ const contentType = isHtml ? "text/html" : "text/plain";
14
12
  const request = {
15
- method: 'POST',
16
- url: '/v3/mail/send',
13
+ method: "POST",
14
+ url: "/v3/mail/send",
17
15
  body: {
18
16
  personalizations: [
19
17
  {
@@ -21,32 +19,32 @@ async function sendFromSendGrid(config, recipient, subject, text, isHtml, analyt
21
19
  cc: recipient.cc ? normalizeEmails(recipient.cc) : undefined,
22
20
  bcc: recipient.bcc ? normalizeEmails(recipient.bcc) : undefined,
23
21
  subject,
24
- custom_args: Object.assign({}, ((analytics === null || analytics === void 0 ? void 0 : analytics.custom_args) || {}))
25
- }
22
+ custom_args: Object.assign({}, ((analytics === null || analytics === void 0 ? void 0 : analytics.custom_args) || {})),
23
+ },
26
24
  ],
27
25
  from: {
28
- email: config.email // must be verified in SendGrid
26
+ email: config.email,
29
27
  },
30
28
  content: [
31
29
  {
32
30
  type: contentType,
33
- value: text
34
- }
31
+ value: text,
32
+ },
35
33
  ],
36
34
  tracking_settings: {
37
35
  open_tracking: {
38
36
  enable: true,
39
- substitution_tag: "%opentrack%"
40
- }
41
- }
42
- }
37
+ substitution_tag: "%opentrack%",
38
+ },
39
+ },
40
+ },
43
41
  };
44
42
  try {
45
43
  const [response] = await client.request(request);
46
44
  return response;
47
45
  }
48
46
  catch (error) {
49
- console.error('SendGrid client error:', ((_a = error.response) === null || _a === void 0 ? void 0 : _a.body) || error.message);
47
+ console.error("SendGrid client error:", ((_a = error.response) === null || _a === void 0 ? void 0 : _a.body) || error.message);
50
48
  throw error;
51
49
  }
52
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-email-builder-shared",
3
- "version": "1.6.73",
3
+ "version": "1.6.75",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [