@auxcode/auxta 1.3.78-beta.113 → 1.3.78-beta.115

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.
@@ -19,28 +19,54 @@ const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
19
19
  const RETRY_NUMBERS = 10;
20
20
  function captureScreenshot() {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- let count = 0;
23
- while (count <= RETRY_NUMBERS) {
24
- try {
25
- const pages = yield puppeteer_1.default.defaultPage.browser().pages();
26
- if (!pages.length)
27
- return undefined;
28
- const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
29
- log_service_1.default.push('When', `Before the screenshot the number of pages are ${pages.length}`, status_of_step_1.default.PASSED);
30
- const screenshotBuffer = yield lastPage.screenshot({
31
- captureBeyondViewport: false,
32
- encoding: 'binary'
33
- });
34
- if (Buffer.isBuffer(screenshotBuffer))
35
- return screenshotBuffer;
22
+ const pages = yield puppeteer_1.default.defaultPage.browser().pages();
23
+ if (!pages.length)
24
+ return undefined;
25
+ for (let i = 0; i < pages.length; i++) {
26
+ const page = pages[i];
27
+ if ((pages.length - 1) == i || pages.length == 1) {
28
+ let count = 0;
29
+ while (count <= RETRY_NUMBERS) {
30
+ try {
31
+ const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
32
+ const screenshotBuffer = yield lastPage.screenshot({
33
+ captureBeyondViewport: false,
34
+ encoding: 'binary'
35
+ });
36
+ if (Buffer.isBuffer(screenshotBuffer))
37
+ return screenshotBuffer;
38
+ }
39
+ catch (e) {
40
+ if (count == RETRY_NUMBERS) {
41
+ log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
42
+ return undefined;
43
+ }
44
+ }
45
+ count++;
46
+ }
36
47
  }
37
- catch (e) {
38
- if (count == RETRY_NUMBERS) {
39
- log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
40
- return undefined;
48
+ else {
49
+ let count = 0;
50
+ while (count <= RETRY_NUMBERS) {
51
+ try {
52
+ const screenshotBuffer = yield page.screenshot({
53
+ captureBeyondViewport: false,
54
+ encoding: 'binary'
55
+ });
56
+ if (Buffer.isBuffer(screenshotBuffer)) {
57
+ log_service_1.default.push("When", `${i} Image`, status_of_step_1.default.FAILED, screenshotBuffer.toString("base64"));
58
+ break;
59
+ }
60
+ }
61
+ catch (e) {
62
+ if (count == RETRY_NUMBERS) {
63
+ log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
64
+ return undefined;
65
+ }
66
+ }
67
+ count++;
41
68
  }
42
69
  }
43
- count++;
44
70
  }
45
71
  return undefined;
46
72
  });
@@ -2,11 +2,6 @@ export declare class EmailHelper {
2
2
  verifyEmail(from_name: string, from_email: string, subject: string, body: string, link?: boolean): Promise<{
3
3
  link: any;
4
4
  } | undefined>;
5
- sendEmail(to: string, subject: string, body: string): Promise<void>;
6
- replyEmail(id: string, threadId: string, body: string): Promise<void>;
7
- private static send;
8
- private getHeader;
9
- private getCurrentUserEmail;
10
5
  }
11
6
  declare const _default: EmailHelper;
12
7
  export default _default;
@@ -17,7 +17,6 @@ const log_service_1 = __importDefault(require("../../auxta/services/log.service"
17
17
  const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
18
18
  const AuxTA_1 = require("../../AuxTA");
19
19
  const report_service_1 = require("../../auxta/services/report.service");
20
- const MailComposer = require('nodemailer/lib/mail-composer');
21
20
  class EmailHelper {
22
21
  verifyEmail(from_name, from_email, subject, body, link = false) {
23
22
  return __awaiter(this, void 0, void 0, function* () {
@@ -52,70 +51,6 @@ class EmailHelper {
52
51
  }
53
52
  });
54
53
  }
55
- sendEmail(to, subject, body) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
58
- const options = {
59
- to: to,
60
- from: this.getCurrentUserEmail(),
61
- subject: subject,
62
- html: body
63
- };
64
- yield EmailHelper.send(options);
65
- });
66
- }
67
- replyEmail(id, threadId, body) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
70
- const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
71
- userId: "me",
72
- id: id,
73
- format: 'FULL'
74
- });
75
- if (gmailResponse.data.payload) {
76
- const message_subject = this.getHeader('subject', gmailResponse);
77
- const message_messageID = this.getHeader('Message-ID', gmailResponse);
78
- const reply_to = this.getHeader('reply-to', gmailResponse);
79
- const options = {
80
- to: reply_to,
81
- from: this.getCurrentUserEmail(),
82
- subject: `Re: ${message_subject}`,
83
- references: message_messageID,
84
- inReplyTo: [message_messageID],
85
- html: body
86
- };
87
- yield EmailHelper.send(options, threadId);
88
- }
89
- });
90
- }
91
- static send(options, threadId) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const mailComposer = new MailComposer(options);
94
- const message = yield mailComposer.compile().build();
95
- const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
96
- yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
97
- userId: "me",
98
- requestBody: {
99
- threadId: threadId,
100
- raw: encodeMessage
101
- }
102
- });
103
- });
104
- }
105
- getHeader(value, headers) {
106
- for (const header of headers.data.payload.headers) {
107
- if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
108
- return header.value;
109
- }
110
- }
111
- }
112
- getCurrentUserEmail() {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
115
- const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
116
- return profile.data.emailAddress;
117
- });
118
- }
119
54
  }
120
55
  exports.EmailHelper = EmailHelper;
121
56
  exports.default = new EmailHelper();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.78-beta.113",
3
+ "version": "1.3.78-beta.115",
4
4
  "description": "",
5
5
  "main": "./build/AuxTA.js",
6
6
  "types": "./build/AuxTA.d.ts",