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.
@@ -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>;
@@ -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
- await this.admin_alert(error.stack.toString());
16
+ console.log(error.stack.toString());
55
17
  }
56
18
  else {
57
- await this.admin_alert(error.toString());
19
+ console.log(error.toString());
58
20
  }
59
21
  }
60
22
  }
@@ -28,6 +28,7 @@ export class UtilsSES {
28
28
  });
29
29
  }
30
30
  async admin_alert(text) {
31
+ console.log("ADMIN ALERT:", text);
31
32
  await this.send_email("louishou@triangleanalytics.com", "ADMIN ALERT", text);
32
33
  }
33
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.32",
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
- await this.admin_alert(error.stack.toString())
26
+ console.log(error.stack.toString())
66
27
  } else {
67
- await this.admin_alert(error.toString())
28
+ console.log(error.toString())
68
29
  }
69
30
  }
70
31
  }
package/src/UtilsSES.ts CHANGED
@@ -33,6 +33,7 @@ export class UtilsSES {
33
33
  }
34
34
 
35
35
  async admin_alert(text : string) {
36
+ console.log("ADMIN ALERT:", text)
36
37
  await this.send_email("louishou@triangleanalytics.com", "ADMIN ALERT", text)
37
38
  }
38
39