@flink-app/email-plugin 0.12.1-alpha.0 → 0.12.1-alpha.2
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/flowmailerClient.js +27 -24
- package/dist/index.d.ts +1 -1
- package/dist/schemas/email.d.ts +4 -1
- package/dist/schemas/emailFlowmailer.d.ts +2 -2
- package/dist/schemas/emailSendgrid.d.ts +1 -1
- package/dist/sendgridClient.js +1 -1
- package/dist/smtpClient.js +1 -1
- package/package.json +28 -28
package/dist/flowmailerClient.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -92,11 +92,11 @@ var flowMailerClient = /** @class */ (function () {
|
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
94
|
flowMailerClient.prototype.sendEmail = function (email, to) {
|
|
95
|
-
var _a, _b, _c;
|
|
96
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
96
|
var data, resp, ex_2;
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
var _a, _b;
|
|
98
|
+
return __generator(this, function (_c) {
|
|
99
|
+
switch (_c.label) {
|
|
100
100
|
case 0:
|
|
101
101
|
data = {
|
|
102
102
|
messageType: "EMAIL",
|
|
@@ -109,24 +109,24 @@ var flowMailerClient = /** @class */ (function () {
|
|
|
109
109
|
if (email.attachments) {
|
|
110
110
|
data = __assign(__assign({}, data), { attachments: email.attachments.map(function (a) { return (__assign(__assign({}, a), { disposition: "attachment" })); }) });
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
_c.label = 1;
|
|
113
113
|
case 1:
|
|
114
|
-
|
|
115
|
-
return [4 /*yield*/, axios_1.default.post("https://api.flowmailer.net/"
|
|
114
|
+
_c.trys.push([1, 3, , 4]);
|
|
115
|
+
return [4 /*yield*/, axios_1.default.post("https://api.flowmailer.net/".concat(this.account_id, "/messages/submit"), data, {
|
|
116
116
|
headers: {
|
|
117
117
|
Accept: "application/vnd.flowmailer.v1.12+json",
|
|
118
118
|
"Content-Type": "application/vnd.flowmailer.v1.12+json;charset=UTF-8",
|
|
119
|
-
Authorization: "Bearer "
|
|
119
|
+
Authorization: "Bearer ".concat(this.accessToken),
|
|
120
120
|
},
|
|
121
121
|
})];
|
|
122
122
|
case 2:
|
|
123
|
-
resp =
|
|
123
|
+
resp = _c.sent();
|
|
124
124
|
if (resp.status == 201)
|
|
125
125
|
return [2 /*return*/, true];
|
|
126
126
|
return [3 /*break*/, 4];
|
|
127
127
|
case 3:
|
|
128
|
-
ex_2 =
|
|
129
|
-
if (((
|
|
128
|
+
ex_2 = _c.sent();
|
|
129
|
+
if (((_b = (_a = ex_2 === null || ex_2 === void 0 ? void 0 : ex_2.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) != "invalid_token") {
|
|
130
130
|
}
|
|
131
131
|
return [3 /*break*/, 4];
|
|
132
132
|
case 4: return [2 /*return*/, false];
|
|
@@ -136,37 +136,40 @@ var flowMailerClient = /** @class */ (function () {
|
|
|
136
136
|
};
|
|
137
137
|
flowMailerClient.prototype.send = function (email) {
|
|
138
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
var failure, _a, _b, _i, i, success;
|
|
140
|
-
return __generator(this, function (
|
|
141
|
-
switch (
|
|
139
|
+
var failure, _a, _b, _c, _i, i, success;
|
|
140
|
+
return __generator(this, function (_d) {
|
|
141
|
+
switch (_d.label) {
|
|
142
142
|
case 0:
|
|
143
143
|
failure = false;
|
|
144
|
-
_a =
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
_a = email.to;
|
|
145
|
+
_b = [];
|
|
146
|
+
for (_c in _a)
|
|
147
|
+
_b.push(_c);
|
|
147
148
|
_i = 0;
|
|
148
|
-
|
|
149
|
+
_d.label = 1;
|
|
149
150
|
case 1:
|
|
150
|
-
if (!(_i <
|
|
151
|
-
|
|
151
|
+
if (!(_i < _b.length)) return [3 /*break*/, 8];
|
|
152
|
+
_c = _b[_i];
|
|
153
|
+
if (!(_c in _a)) return [3 /*break*/, 7];
|
|
154
|
+
i = _c;
|
|
152
155
|
if (!this.client_secrect) {
|
|
153
156
|
this.getToken();
|
|
154
157
|
}
|
|
155
158
|
return [4 /*yield*/, this.sendEmail(email, email.to[i])];
|
|
156
159
|
case 2:
|
|
157
|
-
success =
|
|
160
|
+
success = _d.sent();
|
|
158
161
|
if (!!success) return [3 /*break*/, 4];
|
|
159
162
|
return [4 /*yield*/, this.getToken()];
|
|
160
163
|
case 3:
|
|
161
|
-
|
|
164
|
+
_d.sent();
|
|
162
165
|
return [3 /*break*/, 5];
|
|
163
166
|
case 4: return [3 /*break*/, 7];
|
|
164
167
|
case 5: return [4 /*yield*/, this.sendEmail(email, email.to[i])];
|
|
165
168
|
case 6:
|
|
166
|
-
success =
|
|
169
|
+
success = _d.sent();
|
|
167
170
|
if (!success)
|
|
168
171
|
failure = true;
|
|
169
|
-
|
|
172
|
+
_d.label = 7;
|
|
170
173
|
case 7:
|
|
171
174
|
_i++;
|
|
172
175
|
return [3 /*break*/, 1];
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { sendgridClient } from "./sendgridClient";
|
|
|
4
4
|
export { smtpClient } from "./smtpClient";
|
|
5
5
|
export { flowMailerClient } from "./flowmailerClient";
|
|
6
6
|
export type { email } from "./schemas/email";
|
|
7
|
-
export
|
|
7
|
+
export type emailPluginOptions = {
|
|
8
8
|
/**
|
|
9
9
|
* Path for request
|
|
10
10
|
*/
|
package/dist/schemas/email.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
2
5
|
import { Readable } from "stream";
|
|
3
6
|
import { Url } from "url";
|
|
4
|
-
export
|
|
7
|
+
export type email = {
|
|
5
8
|
/**
|
|
6
9
|
* From address used to send the email
|
|
7
10
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type emailFlowmailer = {
|
|
2
2
|
/**
|
|
3
3
|
* From address used to send the email
|
|
4
4
|
*/
|
|
@@ -23,7 +23,7 @@ export declare type emailFlowmailer = {
|
|
|
23
23
|
html?: string;
|
|
24
24
|
attachments?: fowmailerAttachment[];
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type fowmailerAttachment = {
|
|
27
27
|
content: string;
|
|
28
28
|
contentType: string;
|
|
29
29
|
filename: string;
|
package/dist/sendgridClient.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
package/dist/smtpClient.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@flink-app/email-plugin",
|
|
3
|
+
"version": "0.12.1-alpha.2",
|
|
4
|
+
"description": "Flink plugin that makes it possible to send email",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\"",
|
|
7
|
+
"prepublish": "tsc"
|
|
8
|
+
},
|
|
9
|
+
"author": "johan@frost.se",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@sendgrid/mail": "^7.4.5",
|
|
18
|
+
"@types/nodemailer": "^6.4.4",
|
|
19
|
+
"axios": "^0.27.2",
|
|
20
|
+
"nodemailer": "^6.6.2",
|
|
21
|
+
"querystring": "^0.2.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@flink-app/flink": "^0.12.1-alpha.2",
|
|
25
|
+
"@types/node": "22.13.10",
|
|
26
|
+
"ts-node": "^9.1.1",
|
|
27
|
+
"typescript": "5.4.5"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "b5be77c75e10067c81e0ecab8716b30f99833b83"
|
|
30
30
|
}
|