triangle-utils 1.4.72 → 1.4.73

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,11 +1,11 @@
1
- import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig.js";
1
+ import { GlobalConfig } from "./types/GlobalConfig.js";
2
2
  interface Encryption {
3
3
  iv: string;
4
4
  ciphertext: string;
5
5
  }
6
6
  export declare class UtilsMisc {
7
- readonly config: TriangleUtilsConfig;
8
- constructor(config: TriangleUtilsConfig);
7
+ readonly config: GlobalConfig;
8
+ constructor(config: GlobalConfig);
9
9
  safe_run<T>(f: () => Promise<T>): Promise<T | undefined>;
10
10
  iterate<T, U>(inputs: T[], f: (input: T, iterator_id: number, index: number) => Promise<U>, num_iterators?: number, print_option?: number | boolean): Promise<(U | undefined)[]>;
11
11
  static wait(duration: number): Promise<unknown>;
@@ -1,4 +1,3 @@
1
- import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig.js";
2
1
  import { UtilsDynamoDB } from "./UtilsDynamoDB.js";
3
2
  import { UtilsS3 } from "./UtilsS3.js";
4
3
  import { UtilsBedrock } from "./UtilsBedrock.js";
@@ -11,6 +10,7 @@ import { UtilsYoutube } from "./UtilsYoutube.js";
11
10
  import { UtilsXAI } from "./UtilsXAI.js";
12
11
  import { UtilsAnthropic } from "./UtilsAnthropic.js";
13
12
  import { UtilsTwitter } from "./UtilsTwitter.js";
13
+ import { GlobalConfig } from "./types/GlobalConfig.js";
14
14
  export declare class TriangleUtils extends UtilsMisc {
15
15
  readonly dynamodb: UtilsDynamoDB;
16
16
  readonly s3: UtilsS3;
@@ -23,9 +23,10 @@ export declare class TriangleUtils extends UtilsMisc {
23
23
  readonly anthropic: UtilsAnthropic;
24
24
  readonly xai: UtilsXAI;
25
25
  readonly twitter: UtilsTwitter;
26
- constructor(config: TriangleUtilsConfig);
26
+ constructor(config: GlobalConfig);
27
27
  }
28
- export * from "./types/TriangleUtilsConfig.js";
28
+ export * from "./types/ApplicationConfig.js";
29
+ export * from "./types/GlobalConfig.js";
29
30
  export * from "./UtilsMisc.js";
30
31
  export * from "./UtilsAnthropic.js";
31
32
  export * from "./UtilsDynamoDB.js";
package/dist/src/index.js CHANGED
@@ -37,7 +37,8 @@ export class TriangleUtils extends UtilsMisc {
37
37
  this.twitter = new UtilsTwitter(config.twitter_api_key);
38
38
  }
39
39
  }
40
- export * from "./types/TriangleUtilsConfig.js";
40
+ export * from "./types/ApplicationConfig.js";
41
+ export * from "./types/GlobalConfig.js";
41
42
  export * from "./UtilsMisc.js";
42
43
  export * from "./UtilsAnthropic.js";
43
44
  export * from "./UtilsDynamoDB.js";
@@ -0,0 +1,11 @@
1
+ export declare class ApplicationConfig {
2
+ readonly cognito_client_id: string;
3
+ readonly cognito_client_secret: string;
4
+ readonly client_url: string;
5
+ readonly client_dev_url: string;
6
+ readonly api_url: string;
7
+ readonly api_dev_url: string;
8
+ readonly [x: string]: any;
9
+ constructor(application_config: ApplicationConfig);
10
+ static is(application_config: any): application_config is ApplicationConfig;
11
+ }
@@ -0,0 +1,28 @@
1
+ export class ApplicationConfig {
2
+ cognito_client_id;
3
+ cognito_client_secret;
4
+ client_url;
5
+ client_dev_url;
6
+ api_url;
7
+ api_dev_url;
8
+ constructor(application_config) {
9
+ if (!ApplicationConfig.is(application_config)) {
10
+ throw Error("Invalid input.");
11
+ }
12
+ this.cognito_client_id = application_config.cognito_client_id;
13
+ this.cognito_client_secret = application_config.cognito_client_secret;
14
+ this.client_url = application_config.client_url;
15
+ this.client_dev_url = application_config.client_dev_url;
16
+ this.api_url = application_config.api_url;
17
+ this.api_dev_url = application_config.api_dev_url;
18
+ }
19
+ static is(application_config) {
20
+ return (application_config !== undefined &&
21
+ typeof application_config.cognito_client_id === "string" &&
22
+ typeof application_config.cognito_client_secret === "string" &&
23
+ typeof application_config.client_url === "string" &&
24
+ typeof application_config.client_dev_url === "string" &&
25
+ typeof application_config.api_url === "string" &&
26
+ typeof application_config.api_dev_url === "string");
27
+ }
28
+ }
@@ -0,0 +1,20 @@
1
+ export declare class GlobalConfig {
2
+ readonly region: string;
3
+ readonly cognito_user_pool_id: string;
4
+ readonly secret_key: string;
5
+ readonly auth_url: string;
6
+ readonly s3_elections: string;
7
+ readonly s3_prism: string;
8
+ readonly s3_triage: string;
9
+ readonly super_federal_gov_api_keys: string;
10
+ readonly federal_gov_api_keys: string;
11
+ readonly federal_lobby_api_key: string;
12
+ readonly scraping_bee_api_key: string;
13
+ readonly twitter_api_key: string;
14
+ readonly youtube_api_key: string;
15
+ readonly anthropic_api_key: string;
16
+ readonly xai_api_key: string;
17
+ readonly [x: string]: any;
18
+ constructor(global_config: GlobalConfig);
19
+ static is(global_config: any): global_config is GlobalConfig;
20
+ }
@@ -0,0 +1,55 @@
1
+ export class GlobalConfig {
2
+ region;
3
+ cognito_user_pool_id;
4
+ secret_key;
5
+ auth_url;
6
+ s3_elections;
7
+ s3_prism;
8
+ s3_triage;
9
+ super_federal_gov_api_keys;
10
+ federal_gov_api_keys;
11
+ federal_lobby_api_key;
12
+ scraping_bee_api_key;
13
+ twitter_api_key;
14
+ youtube_api_key;
15
+ anthropic_api_key;
16
+ xai_api_key;
17
+ constructor(global_config) {
18
+ if (!GlobalConfig.is(global_config)) {
19
+ throw Error("Invalid input.");
20
+ }
21
+ this.region = global_config.region;
22
+ this.cognito_user_pool_id = global_config.cognito_user_pool_id;
23
+ this.secret_key = global_config.secret_key;
24
+ this.auth_url = global_config.auth_url;
25
+ this.s3_elections = global_config.s3_elections;
26
+ this.s3_prism = global_config.s3_prism;
27
+ this.s3_triage = global_config.s3_triage;
28
+ this.super_federal_gov_api_keys = global_config.super_federal_gov_api_keys;
29
+ this.federal_gov_api_keys = global_config.federal_gov_api_keys;
30
+ this.federal_lobby_api_key = global_config.federal_lobby_api_key;
31
+ this.scraping_bee_api_key = global_config.scraping_bee_api_key;
32
+ this.twitter_api_key = global_config.twitter_api_key;
33
+ this.youtube_api_key = global_config.youtube_api_key;
34
+ this.anthropic_api_key = global_config.anthropic_api_key;
35
+ this.xai_api_key = global_config.xai_api_key;
36
+ }
37
+ static is(global_config) {
38
+ return (global_config !== undefined &&
39
+ typeof global_config.region === "string" &&
40
+ typeof global_config.cognito_user_pool_id === "string" &&
41
+ typeof global_config.secret_key === "string" &&
42
+ typeof global_config.auth_url === "string" &&
43
+ typeof global_config.s3_elections === "string" &&
44
+ typeof global_config.s3_prism === "string" &&
45
+ typeof global_config.s3_triage === "string" &&
46
+ typeof global_config.super_federal_gov_api_keys === "string" &&
47
+ typeof global_config.federal_gov_api_keys === "string" &&
48
+ typeof global_config.federal_lobby_api_key === "string" &&
49
+ typeof global_config.scraping_bee_api_key === "string" &&
50
+ typeof global_config.twitter_api_key === "string" &&
51
+ typeof global_config.youtube_api_key === "string" &&
52
+ typeof global_config.anthropic_api_key === "string" &&
53
+ typeof global_config.xai_api_key === "string");
54
+ }
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.72",
3
+ "version": "1.4.73",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsMisc.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as crypto from "crypto"
2
2
 
3
- import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig"
3
+ import { GlobalConfig } from "./types/GlobalConfig"
4
4
 
5
5
  interface Encryption {
6
6
  iv : string,
@@ -9,9 +9,9 @@ interface Encryption {
9
9
 
10
10
  export class UtilsMisc {
11
11
 
12
- readonly config : TriangleUtilsConfig
12
+ readonly config : GlobalConfig
13
13
 
14
- constructor(config : TriangleUtilsConfig) {
14
+ constructor(config : GlobalConfig) {
15
15
  this.config = config
16
16
  }
17
17
 
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { TriangleUtilsConfig } from "./types/TriangleUtilsConfig"
2
1
  import { UtilsDynamoDB } from "./UtilsDynamoDB"
3
2
  import { UtilsS3 } from "./UtilsS3"
4
3
  import { UtilsBedrock } from "./UtilsBedrock"
@@ -11,6 +10,7 @@ import { UtilsYoutube } from "./UtilsYoutube"
11
10
  import { UtilsXAI } from "./UtilsXAI"
12
11
  import { UtilsAnthropic } from "./UtilsAnthropic"
13
12
  import { UtilsTwitter } from "./UtilsTwitter"
13
+ import { GlobalConfig } from "./types/GlobalConfig"
14
14
 
15
15
 
16
16
 
@@ -28,7 +28,7 @@ export class TriangleUtils extends UtilsMisc {
28
28
  readonly xai : UtilsXAI
29
29
  readonly twitter : UtilsTwitter
30
30
 
31
- constructor(config : TriangleUtilsConfig) {
31
+ constructor(config : GlobalConfig) {
32
32
  super(config)
33
33
  this.dynamodb = new UtilsDynamoDB(config.region)
34
34
  this.s3 = new UtilsS3(config.region)
@@ -44,7 +44,8 @@ export class TriangleUtils extends UtilsMisc {
44
44
  }
45
45
  }
46
46
 
47
- export * from "./types/TriangleUtilsConfig"
47
+ export * from "./types/ApplicationConfig"
48
+ export * from "./types/GlobalConfig"
48
49
  export * from "./UtilsMisc"
49
50
  export * from "./UtilsAnthropic"
50
51
  export * from "./UtilsDynamoDB"
@@ -0,0 +1,34 @@
1
+
2
+ export class ApplicationConfig {
3
+ readonly cognito_client_id : string
4
+ readonly cognito_client_secret : string
5
+ readonly client_url : string
6
+ readonly client_dev_url : string
7
+ readonly api_url : string
8
+ readonly api_dev_url : string
9
+ readonly [x : string] : any
10
+
11
+ constructor(application_config : ApplicationConfig) {
12
+ if (!ApplicationConfig.is(application_config)) {
13
+ throw Error("Invalid input.")
14
+ }
15
+ this.cognito_client_id = application_config.cognito_client_id
16
+ this.cognito_client_secret = application_config.cognito_client_secret
17
+ this.client_url = application_config.client_url
18
+ this.client_dev_url = application_config.client_dev_url
19
+ this.api_url = application_config.api_url
20
+ this.api_dev_url = application_config.api_dev_url
21
+ }
22
+
23
+ static is(application_config : any) : application_config is ApplicationConfig {
24
+ return (
25
+ application_config !== undefined &&
26
+ typeof application_config.cognito_client_id === "string" &&
27
+ typeof application_config.cognito_client_secret === "string" &&
28
+ typeof application_config.client_url === "string" &&
29
+ typeof application_config.client_dev_url === "string" &&
30
+ typeof application_config.api_url === "string" &&
31
+ typeof application_config.api_dev_url === "string"
32
+ )
33
+ }
34
+ }
@@ -0,0 +1,60 @@
1
+ export class GlobalConfig {
2
+ readonly region : string
3
+ readonly cognito_user_pool_id : string
4
+ readonly secret_key : string
5
+ readonly auth_url : string
6
+ readonly s3_elections : string
7
+ readonly s3_prism : string
8
+ readonly s3_triage : string
9
+ readonly super_federal_gov_api_keys : string
10
+ readonly federal_gov_api_keys : string
11
+ readonly federal_lobby_api_key : string
12
+ readonly scraping_bee_api_key : string
13
+ readonly twitter_api_key : string
14
+ readonly youtube_api_key : string
15
+ readonly anthropic_api_key : string
16
+ readonly xai_api_key : string
17
+ readonly [x : string] : any
18
+
19
+ constructor(global_config : GlobalConfig) {
20
+ if (!GlobalConfig.is(global_config)) {
21
+ throw Error("Invalid input.")
22
+ }
23
+ this.region = global_config.region
24
+ this.cognito_user_pool_id = global_config.cognito_user_pool_id
25
+ this.secret_key = global_config.secret_key
26
+ this.auth_url = global_config.auth_url
27
+ this.s3_elections = global_config.s3_elections
28
+ this.s3_prism = global_config.s3_prism
29
+ this.s3_triage = global_config.s3_triage
30
+ this.super_federal_gov_api_keys = global_config.super_federal_gov_api_keys
31
+ this.federal_gov_api_keys = global_config.federal_gov_api_keys
32
+ this.federal_lobby_api_key = global_config.federal_lobby_api_key
33
+ this.scraping_bee_api_key = global_config.scraping_bee_api_key
34
+ this.twitter_api_key = global_config.twitter_api_key
35
+ this.youtube_api_key = global_config.youtube_api_key
36
+ this.anthropic_api_key = global_config.anthropic_api_key
37
+ this.xai_api_key = global_config.xai_api_key
38
+ }
39
+
40
+ static is(global_config : any) : global_config is GlobalConfig {
41
+ return (
42
+ global_config !== undefined &&
43
+ typeof global_config.region === "string" &&
44
+ typeof global_config.cognito_user_pool_id === "string" &&
45
+ typeof global_config.secret_key === "string" &&
46
+ typeof global_config.auth_url === "string" &&
47
+ typeof global_config.s3_elections === "string" &&
48
+ typeof global_config.s3_prism === "string" &&
49
+ typeof global_config.s3_triage === "string" &&
50
+ typeof global_config.super_federal_gov_api_keys === "string" &&
51
+ typeof global_config.federal_gov_api_keys === "string" &&
52
+ typeof global_config.federal_lobby_api_key === "string" &&
53
+ typeof global_config.scraping_bee_api_key === "string" &&
54
+ typeof global_config.twitter_api_key === "string" &&
55
+ typeof global_config.youtube_api_key === "string" &&
56
+ typeof global_config.anthropic_api_key === "string" &&
57
+ typeof global_config.xai_api_key === "string"
58
+ )
59
+ }
60
+ }
@@ -1,6 +0,0 @@
1
- export interface TriangleUtilsConfig {
2
- region : string,
3
- scraping_bee_api_key? : string,
4
- youtube_api_key? : string,
5
- [key : string]: any
6
- }