mail-monster-lib 0.0.5 → 0.0.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.
|
@@ -4,23 +4,28 @@ import { Attachment } from 'mailparser';
|
|
|
4
4
|
*
|
|
5
5
|
* @property api_key - (Required) The API key used for authentication.
|
|
6
6
|
* @property email - (Optional) Only return messages for this recipient email address.
|
|
7
|
-
* @property
|
|
7
|
+
* @property subject - (Optional) Case-insensitive substring to search for in the subject.
|
|
8
8
|
* @property keyword - (Optional) Case-insensitive string to match anywhere in subject, sender, content, or attachments.
|
|
9
9
|
* @property count - (Optional) Maximum number of email messages to return. Defaults to a small value if not specified.
|
|
10
10
|
*/
|
|
11
11
|
export interface IGetLatestEmailParams {
|
|
12
12
|
api_key: string;
|
|
13
13
|
email?: string;
|
|
14
|
-
|
|
14
|
+
subject?: string;
|
|
15
15
|
keyword?: string;
|
|
16
16
|
count?: number;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface IGetLatestEmailCore {
|
|
19
19
|
id: string;
|
|
20
20
|
email_from: string;
|
|
21
|
-
email_recipients
|
|
22
|
-
email_subject
|
|
23
|
-
content
|
|
21
|
+
email_recipients?: string;
|
|
22
|
+
email_subject?: string;
|
|
23
|
+
content?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IGetLatestEmailRaw {
|
|
26
|
+
attachments?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IGetLatestEmail {
|
|
24
29
|
attachments: Attachment[];
|
|
25
30
|
}
|
|
26
31
|
export declare function getLatestEmails(params: IGetLatestEmailParams): Promise<IGetLatestEmail[]>;
|
package/dist/mail-monster-lib.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -40,7 +51,7 @@ exports.getLatestEmails = void 0;
|
|
|
40
51
|
var LATEST_EMAIL_ENDPOINT = 'https://mail-monster-api.create-flow.ai/api/latest?';
|
|
41
52
|
function getLatestEmails(params) {
|
|
42
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var url, fetchEndpoint, response;
|
|
54
|
+
var url, fetchEndpoint, response, emails;
|
|
44
55
|
return __generator(this, function (_a) {
|
|
45
56
|
switch (_a.label) {
|
|
46
57
|
case 0:
|
|
@@ -49,8 +60,8 @@ function getLatestEmails(params) {
|
|
|
49
60
|
if (params.email) {
|
|
50
61
|
url.searchParams.append('email', params.email);
|
|
51
62
|
}
|
|
52
|
-
if (params.
|
|
53
|
-
url.searchParams.append('title', params.
|
|
63
|
+
if (params.subject) {
|
|
64
|
+
url.searchParams.append('title', params.subject);
|
|
54
65
|
}
|
|
55
66
|
if (params.keyword) {
|
|
56
67
|
url.searchParams.append('keyword', params.keyword);
|
|
@@ -66,7 +77,12 @@ function getLatestEmails(params) {
|
|
|
66
77
|
throw new Error("Failed to fetch email: ".concat(response.status, " ").concat(response.statusText));
|
|
67
78
|
}
|
|
68
79
|
return [4 /*yield*/, response.json()];
|
|
69
|
-
case 2:
|
|
80
|
+
case 2:
|
|
81
|
+
emails = _a.sent();
|
|
82
|
+
return [2 /*return*/, emails.map(function (em) {
|
|
83
|
+
var attachments = em.attachments ? JSON.parse(em.attachments) : [];
|
|
84
|
+
return __assign(__assign({}, em), { attachments: attachments });
|
|
85
|
+
})];
|
|
70
86
|
}
|
|
71
87
|
});
|
|
72
88
|
});
|
|
@@ -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;AAmCpF,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,OAAO,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;qBAAE;oBACzE,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;oBACc,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;oBAA9B,MAAM,GAAG,SAA6C;oBAC5D,sBAAO,MAAM,CAAC,GAAG,CAAC,UAAC,EAAE;4BACnB,IAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;4BACrE,OAAO,sBACF,EAAE,KACL,WAAW,aAAA,GACO,CAAC;wBACvB,CAAC,CAAC,EAAC;;;;CACJ;AApBD,0CAoBC"}
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
1
|
+
"use strict";var __assign=this&&this.__assign||function(){__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p]}return t};return __assign.apply(this,arguments)};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,emails;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.subject){url.searchParams.append("title",params.subject)}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:emails=_a.sent();return[2,emails.map(function(em){var attachments=em.attachments?JSON.parse(em.attachments):[];return __assign(__assign({},em),{attachments:attachments})})]}})})}exports.getLatestEmails=getLatestEmails;
|