mail-monster-lib 0.0.2 → 0.0.4

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,26 +1,17 @@
1
- export declare const myLib: {
2
- /**
3
- * Add two numbers
4
- * @param number1 First number to add
5
- * @param number2 Second number to add
6
- */
7
- add(number1: number, number2: number): number;
8
- /**
9
- * Subtract two numbers
10
- * @param number1 First number to be subtracted
11
- * @param number2 Second number to subtract
12
- */
13
- subtract(number1: number, number2: number): number;
14
- /**
15
- * Multiply two numbers
16
- * @param number1 First number to multiply
17
- * @param number2 Second number to multiply
18
- */
19
- multiply(number1: number, number2: number): number;
20
- /**
21
- * Divide two numbers
22
- * @param number1 First number to be divided
23
- * @param number2 Second number to divide
24
- */
25
- divide(number1: number, number2: number): number;
26
- };
1
+ /**
2
+ * Parameters for fetching the latest emails via Mail Monster API.
3
+ *
4
+ * @property api_key - (Required) The API key used for authentication.
5
+ * @property email - (Optional) Only return messages for this recipient email address.
6
+ * @property title - (Optional) Case-insensitive substring to search for in the subject.
7
+ * @property keyword - (Optional) Case-insensitive string to match anywhere in subject, sender, content, or attachments.
8
+ * @property count - (Optional) Maximum number of email messages to return. Defaults to a small value if not specified.
9
+ */
10
+ export interface IGetLatestEmailParams {
11
+ api_key: string;
12
+ email?: string;
13
+ title?: string;
14
+ keyword?: string;
15
+ count?: number;
16
+ }
17
+ export declare function getLatestEmails(params: IGetLatestEmailParams): Promise<string>;
@@ -1,39 +1,72 @@
1
1
  "use strict";
2
- // my awesome library
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- // Intentionally avoid using 'export default' to reduce confusion.
5
- exports.myLib = {
6
- /**
7
- * Add two numbers
8
- * @param number1 First number to add
9
- * @param number2 Second number to add
10
- */
11
- add: function (number1, number2) {
12
- return number1 + number2;
13
- },
14
- /**
15
- * Subtract two numbers
16
- * @param number1 First number to be subtracted
17
- * @param number2 Second number to subtract
18
- */
19
- subtract: function (number1, number2) {
20
- return number1 - number2;
21
- },
22
- /**
23
- * Multiply two numbers
24
- * @param number1 First number to multiply
25
- * @param number2 Second number to multiply
26
- */
27
- multiply: function (number1, number2) {
28
- return number1 * number2;
29
- },
30
- /**
31
- * Divide two numbers
32
- * @param number1 First number to be divided
33
- * @param number2 Second number to divide
34
- */
35
- divide: function (number1, number2) {
36
- return number1 / number2;
37
- },
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ 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
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
38
36
  };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ var LATEST_EMAIL_ENDPOINT = 'https://mail-monster-api.create-flow.ai/api/latest?';
39
+ function getLatestEmails(params) {
40
+ return __awaiter(this, void 0, void 0, function () {
41
+ var url, fetchEndpoint, response;
42
+ return __generator(this, function (_a) {
43
+ switch (_a.label) {
44
+ case 0:
45
+ url = new URL(LATEST_EMAIL_ENDPOINT);
46
+ url.searchParams.append('apikey', params.api_key);
47
+ if (params.email) {
48
+ url.searchParams.append('email', params.email);
49
+ }
50
+ if (params.title) {
51
+ url.searchParams.append('title', params.title);
52
+ }
53
+ if (params.keyword) {
54
+ url.searchParams.append('keyword', params.keyword);
55
+ }
56
+ if (params.count !== undefined) {
57
+ url.searchParams.append('count', String(params.count));
58
+ }
59
+ fetchEndpoint = url.toString();
60
+ return [4 /*yield*/, fetch(fetchEndpoint)];
61
+ case 1:
62
+ response = _a.sent();
63
+ if (!response.ok) {
64
+ throw new Error("Failed to fetch email: " + response.status + " " + response.statusText);
65
+ }
66
+ return [2 /*return*/, response.text()];
67
+ }
68
+ });
69
+ });
70
+ }
71
+ exports.getLatestEmails = getLatestEmails;
39
72
  //# sourceMappingURL=mail-monster-lib.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail-monster-lib.js","sourceRoot":"","sources":["../src/mail-monster-lib.ts"],"names":[],"mappings":";AAAA,qBAAqB;;AAErB,kEAAkE;AACrD,QAAA,KAAK,GAAG;IACnB;;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,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,4BAA0B,QAAQ,CAAC,MAAM,SAAI,QAAQ,CAAC,UAAY,CAAC,CAAC;qBACrF;oBACD,sBAAO,QAAQ,CAAC,IAAI,EAAE,EAAC;;;;CACxB;AAbD,0CAaC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.myLib={add:function(number1,number2){return number1+number2},subtract:function(number1,number2){return number1-number2},multiply:function(number1,number2){return number1*number2},divide:function(number1,number2){return number1/number2}};
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):new P(function(resolve){resolve(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(_)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});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: "+response.status+" "+response.statusText)}return[2,response.text()]}})})}exports.getLatestEmails=getLatestEmails;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mail-monster-lib",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
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",