mail-monster-lib 0.0.4 → 0.0.5
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,3 +1,4 @@
|
|
|
1
|
+
import { Attachment } from 'mailparser';
|
|
1
2
|
/**
|
|
2
3
|
* Parameters for fetching the latest emails via Mail Monster API.
|
|
3
4
|
*
|
|
@@ -14,4 +15,12 @@ export interface IGetLatestEmailParams {
|
|
|
14
15
|
keyword?: string;
|
|
15
16
|
count?: number;
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
+
export interface IGetLatestEmail {
|
|
19
|
+
id: string;
|
|
20
|
+
email_from: string;
|
|
21
|
+
email_recipients: string;
|
|
22
|
+
email_subject: string;
|
|
23
|
+
content: string;
|
|
24
|
+
attachments: Attachment[];
|
|
25
|
+
}
|
|
26
|
+
export declare function getLatestEmails(params: IGetLatestEmailParams): Promise<IGetLatestEmail[]>;
|
package/dist/mail-monster-lib.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
5
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
6
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) :
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
@@ -13,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
13
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
15
|
function step(op) {
|
|
15
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
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;
|
|
18
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
20
|
switch (op[0]) {
|
|
@@ -35,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getLatestEmails = void 0;
|
|
38
40
|
var LATEST_EMAIL_ENDPOINT = 'https://mail-monster-api.create-flow.ai/api/latest?';
|
|
39
41
|
function getLatestEmails(params) {
|
|
40
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -61,9 +63,10 @@ function getLatestEmails(params) {
|
|
|
61
63
|
case 1:
|
|
62
64
|
response = _a.sent();
|
|
63
65
|
if (!response.ok) {
|
|
64
|
-
throw new Error("Failed to fetch email: "
|
|
66
|
+
throw new Error("Failed to fetch email: ".concat(response.status, " ").concat(response.statusText));
|
|
65
67
|
}
|
|
66
|
-
return [
|
|
68
|
+
return [4 /*yield*/, response.json()];
|
|
69
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
67
70
|
}
|
|
68
71
|
});
|
|
69
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail-monster-lib.js","sourceRoot":"","sources":["../src/mail-monster-lib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mail-monster-lib.js","sourceRoot":"","sources":["../src/mail-monster-lib.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,qBAAqB,GAAG,qDAAqD,CAAC;AA4BpF,SAAsB,eAAe,CAAC,MAA6B;;;;;;oBAC3D,GAAG,GAAG,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;oBAC3C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;oBAClD,IAAI,MAAM,CAAC,KAAK,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;qBAAE;oBACrE,IAAI,MAAM,CAAC,KAAK,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;qBAAE;oBACrE,IAAI,MAAM,CAAC,OAAO,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;qBAAE;oBAC3E,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;qBAAE;oBACrF,aAAa,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;oBACpB,qBAAM,KAAK,CAAC,aAAa,CAAC,EAAA;;oBAArC,QAAQ,GAAG,SAA0B;oBAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;wBAChB,MAAM,IAAI,KAAK,CAAC,iCAA0B,QAAQ,CAAC,MAAM,cAAI,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;qBACrF;oBACM,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;wBAA5B,sBAAO,SAA0C,EAAC;;;;CACnD;AAbD,0CAaC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{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;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});exports.getLatestEmails=void 0;var LATEST_EMAIL_ENDPOINT="https://mail-monster-api.create-flow.ai/api/latest?";function getLatestEmails(params){return __awaiter(this,void 0,void 0,function(){var url,fetchEndpoint,response;return __generator(this,function(_a){switch(_a.label){case 0:url=new URL(LATEST_EMAIL_ENDPOINT);url.searchParams.append("apikey",params.api_key);if(params.email){url.searchParams.append("email",params.email)}if(params.title){url.searchParams.append("title",params.title)}if(params.keyword){url.searchParams.append("keyword",params.keyword)}if(params.count!==undefined){url.searchParams.append("count",String(params.count))}fetchEndpoint=url.toString();return[4,fetch(fetchEndpoint)];case 1:response=_a.sent();if(!response.ok){throw new Error("Failed to fetch email: ".concat(response.status," ").concat(response.statusText))}return[4,response.json()];case 2:return[2,_a.sent()]}})})}exports.getLatestEmails=getLatestEmails;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mail-monster-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Typescript library for Flow AI's MailMonster",
|
|
5
5
|
"main": "./dist/mail-monster-lib.min.js",
|
|
6
6
|
"types": "./dist/mail-monster-lib.d.ts",
|
|
@@ -22,11 +22,16 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/jest": "^23.3.7",
|
|
25
|
+
"@types/mailparser": "^3.4.6",
|
|
26
|
+
"@types/node": "^18.0.0",
|
|
25
27
|
"jest": "^23.6.0",
|
|
26
28
|
"nodemon": "^1.17.5",
|
|
27
29
|
"ts-jest": "^23.10.4",
|
|
28
30
|
"tslint": "^5.10.0",
|
|
29
|
-
"typescript": "^
|
|
31
|
+
"typescript": "^4.9.5",
|
|
30
32
|
"uglify-js": "^3.4.9"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"mailparser": "^3.9.1"
|
|
31
36
|
}
|
|
32
|
-
}
|
|
37
|
+
}
|