@auxcode/auxta 1.3.20 → 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 +19 -7
- package/build/esm/macros/helpers/code.helper.d.ts +5 -1
- package/build/esm/macros/helpers/code.helper.js +19 -7
- 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,6 +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 buffer_1 = require("buffer");
|
|
23
24
|
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
24
25
|
log(keyword, name, status) {
|
|
25
26
|
log_service_1.default.push(keyword, name, status);
|
|
@@ -188,7 +189,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
188
189
|
yield loginPage.waitForNetworkIdle();
|
|
189
190
|
});
|
|
190
191
|
}
|
|
191
|
-
clickInMail(from_name, from_email, subject) {
|
|
192
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
192
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
194
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
194
195
|
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
@@ -204,16 +205,18 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
204
205
|
while (timeoutCount <= 60000) {
|
|
205
206
|
for (const messageId of messagesIds) {
|
|
206
207
|
if (messageId.id) {
|
|
207
|
-
const
|
|
208
|
+
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
208
209
|
userId: "me",
|
|
209
210
|
id: messageId.id.toString(),
|
|
210
211
|
format: 'FULL'
|
|
211
212
|
});
|
|
212
|
-
if (
|
|
213
|
-
const message_sender = this.getHeader('from',
|
|
214
|
-
const message_subject = this.getHeader('subject',
|
|
215
|
-
|
|
216
|
-
|
|
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);
|
|
217
220
|
return true;
|
|
218
221
|
}
|
|
219
222
|
}
|
|
@@ -234,6 +237,15 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
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
|
+
}
|
|
237
249
|
}
|
|
238
250
|
exports.FunctionHelper = FunctionHelper;
|
|
239
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,6 +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 { atob } from "buffer";
|
|
17
18
|
export class FunctionHelper extends ExtendDefaultPage {
|
|
18
19
|
log(keyword, name, status) {
|
|
19
20
|
log.push(keyword, name, status);
|
|
@@ -182,7 +183,7 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
182
183
|
yield loginPage.waitForNetworkIdle();
|
|
183
184
|
});
|
|
184
185
|
}
|
|
185
|
-
clickInMail(from_name, from_email, subject) {
|
|
186
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
186
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
188
|
yield AuxGoogleAuth.setup();
|
|
188
189
|
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
@@ -198,16 +199,18 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
198
199
|
while (timeoutCount <= 60000) {
|
|
199
200
|
for (const messageId of messagesIds) {
|
|
200
201
|
if (messageId.id) {
|
|
201
|
-
const
|
|
202
|
+
const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
202
203
|
userId: "me",
|
|
203
204
|
id: messageId.id.toString(),
|
|
204
205
|
format: 'FULL'
|
|
205
206
|
});
|
|
206
|
-
if (
|
|
207
|
-
const message_sender = this.getHeader('from',
|
|
208
|
-
const message_subject = this.getHeader('subject',
|
|
209
|
-
|
|
210
|
-
|
|
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);
|
|
211
214
|
return true;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
@@ -228,5 +231,14 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
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
|
+
}
|
|
231
243
|
}
|
|
232
244
|
export default new FunctionHelper();
|