triangle-utils 1.4.32 → 1.4.33
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/dist/src/UtilsMisc.d.ts +0 -4
- package/dist/src/UtilsMisc.js +2 -40
- package/dist/src/UtilsSES.js +1 -0
- package/package.json +1 -2
- package/src/UtilsMisc.ts +2 -41
- package/src/UtilsSES.ts +1 -0
package/dist/src/UtilsMisc.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as nodemailer from "nodemailer";
|
|
2
1
|
import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig.js";
|
|
3
2
|
interface Encryption {
|
|
4
3
|
iv: string;
|
|
@@ -6,10 +5,7 @@ interface Encryption {
|
|
|
6
5
|
}
|
|
7
6
|
export declare class UtilsMisc {
|
|
8
7
|
readonly config: TriangleUtilsConfig;
|
|
9
|
-
readonly transporter: nodemailer.Transporter<import("nodemailer/lib/smtp-transport").SentMessageInfo, import("nodemailer/lib/smtp-transport").Options> | undefined;
|
|
10
8
|
constructor(config: TriangleUtilsConfig);
|
|
11
|
-
send_email(recipient: string, subject: string, text: string): Promise<boolean>;
|
|
12
|
-
admin_alert(text: string): Promise<boolean>;
|
|
13
9
|
safe_run(f: () => Promise<any>): Promise<void>;
|
|
14
10
|
iterate<T>(inputs: T[], f: (input: T, iterator_id: number, index: number) => Promise<any>, num_iterators?: number, print_option?: number | boolean): Promise<void>;
|
|
15
11
|
static wait(duration: number): Promise<unknown>;
|
package/dist/src/UtilsMisc.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
import * as nodemailer from "nodemailer";
|
|
2
1
|
import * as crypto from "crypto";
|
|
3
2
|
export class UtilsMisc {
|
|
4
3
|
config;
|
|
5
|
-
transporter;
|
|
6
4
|
constructor(config) {
|
|
7
5
|
this.config = config;
|
|
8
|
-
if (config.google_email !== undefined && config.google_app_password !== undefined) {
|
|
9
|
-
this.transporter = nodemailer.createTransport({
|
|
10
|
-
service: "Gmail",
|
|
11
|
-
host: "smtp.gmail.com",
|
|
12
|
-
port: 465,
|
|
13
|
-
secure: true,
|
|
14
|
-
auth: {
|
|
15
|
-
user: config.google_email,
|
|
16
|
-
pass: config.google_app_password,
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
async send_email(recipient, subject, text) {
|
|
22
|
-
if (this.transporter === undefined) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
for (let i = 0; i < 3; i++) {
|
|
26
|
-
try {
|
|
27
|
-
await this.transporter.sendMail({
|
|
28
|
-
from: this.config.alerts_email,
|
|
29
|
-
to: recipient,
|
|
30
|
-
subject: subject,
|
|
31
|
-
text: text
|
|
32
|
-
});
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.log("EMAIL ERROR", error);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
async admin_alert(text) {
|
|
42
|
-
console.log("ADMIN ALERT:", text);
|
|
43
|
-
return await this.send_email(this.config.google_email, "ADMIN ALERT", text);
|
|
44
6
|
}
|
|
45
7
|
async safe_run(f) {
|
|
46
8
|
try {
|
|
@@ -51,10 +13,10 @@ export class UtilsMisc {
|
|
|
51
13
|
return;
|
|
52
14
|
}
|
|
53
15
|
if (error.stack !== undefined) {
|
|
54
|
-
|
|
16
|
+
console.log(error.stack.toString());
|
|
55
17
|
}
|
|
56
18
|
else {
|
|
57
|
-
|
|
19
|
+
console.log(error.toString());
|
|
58
20
|
}
|
|
59
21
|
}
|
|
60
22
|
}
|
package/dist/src/UtilsSES.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triangle-utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.33",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"directories": {
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@types/nodemailer": "^7.0.9",
|
|
29
29
|
"googleapis": "^170.0.0",
|
|
30
30
|
"jsdom": "^29.0.1",
|
|
31
|
-
"nodemailer": "^7.0.11",
|
|
32
31
|
"scrapingbee": "^1.8.2"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
package/src/UtilsMisc.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as nodemailer from "nodemailer"
|
|
2
1
|
import * as crypto from "crypto"
|
|
3
2
|
|
|
4
3
|
import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig"
|
|
@@ -11,47 +10,9 @@ interface Encryption {
|
|
|
11
10
|
export class UtilsMisc {
|
|
12
11
|
|
|
13
12
|
readonly config : TriangleUtilsConfig
|
|
14
|
-
readonly transporter
|
|
15
13
|
|
|
16
14
|
constructor(config : TriangleUtilsConfig) {
|
|
17
15
|
this.config = config
|
|
18
|
-
if (config.google_email !== undefined && config.google_app_password !== undefined) {
|
|
19
|
-
this.transporter = nodemailer.createTransport({
|
|
20
|
-
service: "Gmail",
|
|
21
|
-
host: "smtp.gmail.com",
|
|
22
|
-
port: 465,
|
|
23
|
-
secure: true,
|
|
24
|
-
auth: {
|
|
25
|
-
user: config.google_email,
|
|
26
|
-
pass: config.google_app_password,
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async send_email(recipient : string, subject : string, text : string) : Promise<boolean> {
|
|
33
|
-
if (this.transporter === undefined) {
|
|
34
|
-
return false
|
|
35
|
-
}
|
|
36
|
-
for (let i = 0; i < 3; i++) {
|
|
37
|
-
try {
|
|
38
|
-
await this.transporter.sendMail({
|
|
39
|
-
from: this.config.alerts_email,
|
|
40
|
-
to: recipient,
|
|
41
|
-
subject: subject,
|
|
42
|
-
text: text
|
|
43
|
-
})
|
|
44
|
-
return true
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log("EMAIL ERROR", error)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return false
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async admin_alert(text : string) : Promise<boolean> {
|
|
53
|
-
console.log("ADMIN ALERT:", text)
|
|
54
|
-
return await this.send_email(this.config.google_email, "ADMIN ALERT", text)
|
|
55
16
|
}
|
|
56
17
|
|
|
57
18
|
async safe_run(f : () => Promise<any>) : Promise<void> {
|
|
@@ -62,9 +23,9 @@ export class UtilsMisc {
|
|
|
62
23
|
return
|
|
63
24
|
}
|
|
64
25
|
if (error.stack !== undefined) {
|
|
65
|
-
|
|
26
|
+
console.log(error.stack.toString())
|
|
66
27
|
} else {
|
|
67
|
-
|
|
28
|
+
console.log(error.toString())
|
|
68
29
|
}
|
|
69
30
|
}
|
|
70
31
|
}
|