@auxcode/auxta 1.3.19 → 1.3.21
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/README.md +4 -0
- package/build/cjs/macros/helpers/code.helper.d.ts +5 -1
- package/build/cjs/macros/helpers/code.helper.js +24 -9
- package/build/esm/macros/helpers/code.helper.d.ts +5 -1
- package/build/esm/macros/helpers/code.helper.js +24 -9
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
2
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { gmail_v1 } from "googleapis";
|
|
3
4
|
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
4
5
|
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
6
|
suggest(name: string): void;
|
|
@@ -16,8 +17,11 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
17
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
18
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
19
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
-
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
clickInMail(from_name: string, from_email: string, subject: string, body: string): Promise<boolean>;
|
|
20
21
|
private getHeader;
|
|
22
|
+
private getBody;
|
|
23
|
+
}
|
|
24
|
+
export interface gmailResponse extends gmail_v1.Gmail {
|
|
21
25
|
}
|
|
22
26
|
declare const _default: FunctionHelper;
|
|
23
27
|
export default _default;
|
|
@@ -20,7 +20,7 @@ const AuxTA_1 = require("../../AuxTA");
|
|
|
20
20
|
const extend_default_page_1 = require("./extend-default-page");
|
|
21
21
|
const puppeteer_2 = require("puppeteer");
|
|
22
22
|
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
23
|
-
const
|
|
23
|
+
const buffer_1 = require("buffer");
|
|
24
24
|
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
25
25
|
log(keyword, name, status) {
|
|
26
26
|
log_service_1.default.push(keyword, name, status);
|
|
@@ -189,11 +189,11 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
189
189
|
yield loginPage.waitForNetworkIdle();
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
clickInMail(from_name, from_email, subject) {
|
|
192
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
194
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
195
195
|
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
196
|
-
userId:
|
|
196
|
+
userId: "me",
|
|
197
197
|
maxResults: 3
|
|
198
198
|
});
|
|
199
199
|
const messagesIds = res.data.messages;
|
|
@@ -205,12 +205,18 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
205
205
|
while (timeoutCount <= 60000) {
|
|
206
206
|
for (const messageId of messagesIds) {
|
|
207
207
|
if (messageId.id) {
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
209
|
+
userId: "me",
|
|
210
|
+
id: messageId.id.toString(),
|
|
211
|
+
format: 'FULL'
|
|
212
|
+
});
|
|
213
|
+
if (gmailResponse.data.payload) {
|
|
214
|
+
const message_sender = this.getHeader('from', gmailResponse.data.payload.headers);
|
|
215
|
+
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
216
|
+
const message_body = this.getBody(from_name, from_email, subject, gmailResponse);
|
|
217
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
218
|
+
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
219
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
214
220
|
return true;
|
|
215
221
|
}
|
|
216
222
|
}
|
|
@@ -231,6 +237,15 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
}
|
|
240
|
+
getBody(from_name, from_email, subject, gmailResponse) {
|
|
241
|
+
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
242
|
+
if (body) {
|
|
243
|
+
return (0, buffer_1.atob)(body).toLocaleLowerCase();
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} body is empty`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
234
249
|
}
|
|
235
250
|
exports.FunctionHelper = FunctionHelper;
|
|
236
251
|
exports.default = new FunctionHelper();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
2
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { gmail_v1 } from "googleapis";
|
|
3
4
|
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
4
5
|
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
6
|
suggest(name: string): void;
|
|
@@ -16,8 +17,11 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
17
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
18
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
19
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
-
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
clickInMail(from_name: string, from_email: string, subject: string, body: string): Promise<boolean>;
|
|
20
21
|
private getHeader;
|
|
22
|
+
private getBody;
|
|
23
|
+
}
|
|
24
|
+
export interface gmailResponse extends gmail_v1.Gmail {
|
|
21
25
|
}
|
|
22
26
|
declare const _default: FunctionHelper;
|
|
23
27
|
export default _default;
|
|
@@ -14,7 +14,7 @@ import { StepStatus } from "../../AuxTA";
|
|
|
14
14
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
15
15
|
import { KnownDevices } from "puppeteer";
|
|
16
16
|
import { AuxGoogleAuth } from "./AuxGoogleAuth";
|
|
17
|
-
import {
|
|
17
|
+
import { atob } from "buffer";
|
|
18
18
|
export class FunctionHelper extends ExtendDefaultPage {
|
|
19
19
|
log(keyword, name, status) {
|
|
20
20
|
log.push(keyword, name, status);
|
|
@@ -183,11 +183,11 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
183
183
|
yield loginPage.waitForNetworkIdle();
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
clickInMail(from_name, from_email, subject) {
|
|
186
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
187
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
188
|
yield AuxGoogleAuth.setup();
|
|
189
189
|
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
190
|
-
userId:
|
|
190
|
+
userId: "me",
|
|
191
191
|
maxResults: 3
|
|
192
192
|
});
|
|
193
193
|
const messagesIds = res.data.messages;
|
|
@@ -199,12 +199,18 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
199
199
|
while (timeoutCount <= 60000) {
|
|
200
200
|
for (const messageId of messagesIds) {
|
|
201
201
|
if (messageId.id) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
203
|
+
userId: "me",
|
|
204
|
+
id: messageId.id.toString(),
|
|
205
|
+
format: 'FULL'
|
|
206
|
+
});
|
|
207
|
+
if (gmailResponse.data.payload) {
|
|
208
|
+
const message_sender = this.getHeader('from', gmailResponse.data.payload.headers);
|
|
209
|
+
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
210
|
+
const message_body = this.getBody(from_name, from_email, subject, gmailResponse);
|
|
211
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
212
|
+
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
213
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.PASSED);
|
|
208
214
|
return true;
|
|
209
215
|
}
|
|
210
216
|
}
|
|
@@ -225,5 +231,14 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
225
231
|
}
|
|
226
232
|
}
|
|
227
233
|
}
|
|
234
|
+
getBody(from_name, from_email, subject, gmailResponse) {
|
|
235
|
+
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
236
|
+
if (body) {
|
|
237
|
+
return atob(body).toLocaleLowerCase();
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} body is empty`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
228
243
|
}
|
|
229
244
|
export default new FunctionHelper();
|