@memberjunction/communication-sendgrid 1.4.1

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.
@@ -0,0 +1,9 @@
1
+ import { BaseCommunicationProvider, Message, MessageResult } from "@memberjunction/communication-core";
2
+ /**
3
+ * Implementation of the SendGrid provider for sending and receiving messages
4
+ */
5
+ export declare class SendGridProvider extends BaseCommunicationProvider {
6
+ SendSingleMessage(message: Message): Promise<MessageResult>;
7
+ }
8
+ export declare function LoadProvider(): void;
9
+ //# sourceMappingURL=SendGridProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendGridProvider.d.ts","sourceRoot":"","sources":["../src/SendGridProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAKvG;;GAEG;AACH,qBACa,gBAAiB,SAAQ,yBAAyB;IAC9C,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAyB3E;AAED,wBAAgB,YAAY,SAE3B"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LoadProvider = exports.SendGridProvider = void 0;
13
+ const communication_core_1 = require("@memberjunction/communication-core");
14
+ const global_1 = require("@memberjunction/global");
15
+ const mail_1 = __importDefault(require("@sendgrid/mail"));
16
+ const config_1 = require("./config");
17
+ /**
18
+ * Implementation of the SendGrid provider for sending and receiving messages
19
+ */
20
+ let SendGridProvider = class SendGridProvider extends communication_core_1.BaseCommunicationProvider {
21
+ async SendSingleMessage(message) {
22
+ // hook up with sendgrid and send stuff
23
+ mail_1.default.setApiKey(config_1.__API_KEY);
24
+ const msg = {
25
+ to: message.To,
26
+ from: 'amith@bluecypress.io',
27
+ subject: message.Subject,
28
+ text: message.Body,
29
+ html: message.Body
30
+ };
31
+ try {
32
+ const result = await mail_1.default.send(msg);
33
+ return {
34
+ Message: message,
35
+ Success: true,
36
+ Error: ''
37
+ };
38
+ }
39
+ catch (error) {
40
+ return {
41
+ Message: message,
42
+ Success: false,
43
+ Error: error.message
44
+ };
45
+ }
46
+ }
47
+ };
48
+ exports.SendGridProvider = SendGridProvider;
49
+ exports.SendGridProvider = SendGridProvider = __decorate([
50
+ (0, global_1.RegisterClass)(communication_core_1.BaseCommunicationProvider, 'SendGrid')
51
+ ], SendGridProvider);
52
+ function LoadProvider() {
53
+ // do nothing, this prevents tree shaking from removing this class
54
+ }
55
+ exports.LoadProvider = LoadProvider;
56
+ //# sourceMappingURL=SendGridProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendGridProvider.js","sourceRoot":"","sources":["../src/SendGridProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAAuG;AACvG,mDAAuD;AACvD,0DAAoC;AACpC,qCAAqC;AAErC;;GAEG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,8CAAyB;IACpD,KAAK,CAAC,iBAAiB,CAAC,OAAgB;QAC3C,uCAAuC;QACvC,cAAM,CAAC,SAAS,CAAC,kBAAS,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG;YACR,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,sBAAsB;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;SACrB,CAAC;QACF,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,cAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtC,OAAO;gBACH,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,EAAE;aACZ,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AA1BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAa,EAAC,8CAAyB,EAAE,UAAU,CAAC;GACxC,gBAAgB,CA0B5B;AAED,SAAgB,YAAY;IACxB,kEAAkE;AACtE,CAAC;AAFD,oCAEC"}
@@ -0,0 +1,2 @@
1
+ export declare const __API_KEY: string;
2
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,QAAqD,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.__API_KEY = void 0;
7
+ // TEMPORARY
8
+ const dotenv_1 = __importDefault(require("dotenv"));
9
+ // Load environment variables from .env file
10
+ dotenv_1.default.config();
11
+ exports.__API_KEY = process.env.COMMUNICATION_VENDOR_API_KEY__SENDGRID;
12
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,YAAY;AACZ,oDAA4B;AAE5B,4CAA4C;AAC5C,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEH,QAAA,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './SendGridProvider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // PUBLIC API SURFACE AREA
18
+ __exportStar(require("./SendGridProvider"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,qDAAmC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@memberjunction/communication-sendgrid",
3
+ "version": "1.4.1",
4
+ "description": "MemberJunction: SendGrid Provider for the MJ Communication Framework",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "start": "ts-node-dev src/index.ts",
12
+ "build": "tsc",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "author": "MemberJunction.com",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "ts-node-dev": "^2.0.0",
19
+ "typescript": "^5.3.3"
20
+ },
21
+ "dependencies": {
22
+ "@memberjunction/global": "~1.4.1",
23
+ "@memberjunction/core": "~1.4.1",
24
+ "@memberjunction/core-entities": "~1.4.1",
25
+ "@memberjunction/communication-core": "~1.4.1",
26
+ "@sendgrid/mail": "^8.1.3",
27
+ "rxjs": "^7.8.1"
28
+ }
29
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # @memberjunction/communication-core
2
+
3
+ The `@memberjunction/communication-core` library provides the fundamental objects that are used for the MemberJunction Communications framework. Other packages within the @memberjunction/communication-* world use this package as a foundation.
4
+
5
+