elections-types 1.0.27 → 1.0.29
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/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/types/CandidateArticle.d.ts +10 -0
- package/dist/src/types/CandidateArticle.js +28 -0
- package/dist/src/types/Tweet.d.ts +1 -1
- package/dist/src/types/Tweet.js +1 -1
- package/dist/src/types/User.d.ts +1 -1
- package/dist/src/types/User.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/CandidateArticle.ts +32 -0
- package/src/types/Tweet.ts +2 -2
- package/src/types/User.ts +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./types/APIError.js";
|
|
2
2
|
export * from "./types/Article.js";
|
|
3
3
|
export * from "./types/Candidate.js";
|
|
4
|
+
export * from "./types/CandidateArticle.js";
|
|
4
5
|
export * from "./types/Committee.js";
|
|
5
6
|
export * from "./types/Donation.js";
|
|
6
7
|
export * from "./types/Election.js";
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./types/APIError.js";
|
|
2
2
|
export * from "./types/Article.js";
|
|
3
3
|
export * from "./types/Candidate.js";
|
|
4
|
+
export * from "./types/CandidateArticle.js";
|
|
4
5
|
export * from "./types/Committee.js";
|
|
5
6
|
export * from "./types/Donation.js";
|
|
6
7
|
export * from "./types/Election.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class CandidateArticle {
|
|
2
|
+
readonly candidate_id: string;
|
|
3
|
+
readonly article_id: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly fetch_time: string;
|
|
6
|
+
readonly relevance_text?: string;
|
|
7
|
+
readonly sentiment?: string;
|
|
8
|
+
constructor(candidate_article: any);
|
|
9
|
+
static is(candidate_article: any): candidate_article is CandidateArticle;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class CandidateArticle {
|
|
2
|
+
candidate_id;
|
|
3
|
+
article_id;
|
|
4
|
+
url;
|
|
5
|
+
fetch_time;
|
|
6
|
+
relevance_text;
|
|
7
|
+
sentiment;
|
|
8
|
+
constructor(candidate_article) {
|
|
9
|
+
if (!CandidateArticle.is(candidate_article)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.candidate_id = candidate_article.candidate_id;
|
|
13
|
+
this.article_id = candidate_article.article_id;
|
|
14
|
+
this.url = candidate_article.url;
|
|
15
|
+
this.fetch_time = candidate_article.fetch_time;
|
|
16
|
+
this.relevance_text = candidate_article.relevance_text;
|
|
17
|
+
this.sentiment = candidate_article.sentiment;
|
|
18
|
+
}
|
|
19
|
+
static is(candidate_article) {
|
|
20
|
+
return (candidate_article !== undefined &&
|
|
21
|
+
typeof candidate_article.candidate_id === "string" &&
|
|
22
|
+
typeof candidate_article.article_id === "string" &&
|
|
23
|
+
typeof candidate_article.url === "string" &&
|
|
24
|
+
typeof candidate_article.fetch_time === "string" &&
|
|
25
|
+
(candidate_article.relevance_text === undefined || typeof candidate_article.relevance_text === "string") &&
|
|
26
|
+
(candidate_article.sentiment === undefined || typeof candidate_article.sentiment === "string"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -5,7 +5,7 @@ export declare class Tweet {
|
|
|
5
5
|
readonly tweet_time: string;
|
|
6
6
|
readonly tweet_content: string;
|
|
7
7
|
readonly quote?: string;
|
|
8
|
-
readonly html
|
|
8
|
+
readonly html?: string;
|
|
9
9
|
readonly text: string;
|
|
10
10
|
constructor(tweet: any);
|
|
11
11
|
static is(tweet: any): tweet is Tweet;
|
package/dist/src/types/Tweet.js
CHANGED
|
@@ -28,7 +28,7 @@ export class Tweet {
|
|
|
28
28
|
typeof tweet.tweet_time === "string" &&
|
|
29
29
|
typeof tweet.tweet_content === "string" &&
|
|
30
30
|
(tweet.quote === undefined || typeof tweet.quote === "string") &&
|
|
31
|
-
(typeof tweet.html === "string") &&
|
|
31
|
+
(tweet.html === undefined || typeof tweet.html === "string") &&
|
|
32
32
|
(typeof tweet.text === "string"));
|
|
33
33
|
}
|
|
34
34
|
}
|
package/dist/src/types/User.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare class User {
|
|
|
4
4
|
readonly admin: boolean;
|
|
5
5
|
readonly premium: boolean;
|
|
6
6
|
readonly email: string;
|
|
7
|
-
readonly email_settings: Record<LongFormTypeID, boolean>;
|
|
7
|
+
readonly email_settings: Record<LongFormTypeID | "NEWS", boolean>;
|
|
8
8
|
constructor(user: any);
|
|
9
9
|
static is(user: any): user is User;
|
|
10
10
|
}
|
package/dist/src/types/User.js
CHANGED
|
@@ -24,6 +24,6 @@ export class User {
|
|
|
24
24
|
typeof user.email === "string" &&
|
|
25
25
|
Array.isArray(user.scout_ids) &&
|
|
26
26
|
typeof user.email_settings === "object" &&
|
|
27
|
-
Object.entries(user.email_settings).every(([key, value]) => is_long_form_type_id(key) && typeof value === "boolean"));
|
|
27
|
+
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "boolean"));
|
|
28
28
|
}
|
|
29
29
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class CandidateArticle {
|
|
2
|
+
readonly candidate_id : string
|
|
3
|
+
readonly article_id : string
|
|
4
|
+
readonly url : string
|
|
5
|
+
readonly fetch_time : string
|
|
6
|
+
readonly relevance_text? : string
|
|
7
|
+
readonly sentiment? : string
|
|
8
|
+
|
|
9
|
+
constructor(candidate_article : any) {
|
|
10
|
+
if (!CandidateArticle.is(candidate_article)) {
|
|
11
|
+
throw Error("Invalid input.")
|
|
12
|
+
}
|
|
13
|
+
this.candidate_id = candidate_article.candidate_id
|
|
14
|
+
this.article_id = candidate_article.article_id
|
|
15
|
+
this.url = candidate_article.url
|
|
16
|
+
this.fetch_time = candidate_article.fetch_time
|
|
17
|
+
this.relevance_text = candidate_article.relevance_text
|
|
18
|
+
this.sentiment = candidate_article.sentiment
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static is(candidate_article : any) : candidate_article is CandidateArticle {
|
|
22
|
+
return (
|
|
23
|
+
candidate_article !== undefined &&
|
|
24
|
+
typeof candidate_article.candidate_id === "string" &&
|
|
25
|
+
typeof candidate_article.article_id === "string" &&
|
|
26
|
+
typeof candidate_article.url === "string" &&
|
|
27
|
+
typeof candidate_article.fetch_time === "string" &&
|
|
28
|
+
(candidate_article.relevance_text === undefined || typeof candidate_article.relevance_text === "string") &&
|
|
29
|
+
(candidate_article.sentiment === undefined || typeof candidate_article.sentiment === "string")
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/types/Tweet.ts
CHANGED
|
@@ -5,7 +5,7 @@ export class Tweet {
|
|
|
5
5
|
readonly tweet_time : string
|
|
6
6
|
readonly tweet_content : string
|
|
7
7
|
readonly quote? : string
|
|
8
|
-
readonly html : string
|
|
8
|
+
readonly html? : string
|
|
9
9
|
readonly text : string
|
|
10
10
|
|
|
11
11
|
constructor(tweet : any) {
|
|
@@ -31,7 +31,7 @@ export class Tweet {
|
|
|
31
31
|
typeof tweet.tweet_time === "string" &&
|
|
32
32
|
typeof tweet.tweet_content === "string" &&
|
|
33
33
|
(tweet.quote === undefined || typeof tweet.quote === "string") &&
|
|
34
|
-
(typeof tweet.html === "string") &&
|
|
34
|
+
(tweet.html === undefined || typeof tweet.html === "string") &&
|
|
35
35
|
(typeof tweet.text === "string")
|
|
36
36
|
)
|
|
37
37
|
}
|
package/src/types/User.ts
CHANGED
|
@@ -5,7 +5,7 @@ export class User {
|
|
|
5
5
|
readonly admin : boolean
|
|
6
6
|
readonly premium : boolean
|
|
7
7
|
readonly email : string
|
|
8
|
-
readonly email_settings : Record<LongFormTypeID, boolean>
|
|
8
|
+
readonly email_settings : Record<LongFormTypeID | "NEWS", boolean>
|
|
9
9
|
// readonly [x : string] : any
|
|
10
10
|
|
|
11
11
|
constructor(user : any) {
|
|
@@ -28,7 +28,7 @@ export class User {
|
|
|
28
28
|
typeof user.email === "string" &&
|
|
29
29
|
Array.isArray(user.scout_ids) &&
|
|
30
30
|
typeof user.email_settings === "object" &&
|
|
31
|
-
Object.entries(user.email_settings).every(([key, value]) => is_long_form_type_id(key) && typeof value === "boolean")
|
|
31
|
+
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "boolean")
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
34
|
}
|