elections-types 1.0.26 → 1.0.28
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/Article.d.ts +1 -1
- package/dist/src/types/Article.js +1 -1
- 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/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/Article.ts +2 -2
- package/src/types/CandidateArticle.ts +32 -0
- package/src/types/Tweet.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";
|
|
@@ -30,7 +30,7 @@ export class Article {
|
|
|
30
30
|
typeof article.publish_date === "string" &&
|
|
31
31
|
typeof article.hash === "string" &&
|
|
32
32
|
typeof article.title === "string" &&
|
|
33
|
-
typeof article.publisher === "string" &&
|
|
33
|
+
(article.publisher === undefined || typeof article.publisher === "string") &&
|
|
34
34
|
typeof article.domain === "string" &&
|
|
35
35
|
typeof article.url === "string" &&
|
|
36
36
|
typeof article.fetch_time === "string" &&
|
|
@@ -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/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/types/Article.ts
CHANGED
|
@@ -3,7 +3,7 @@ export class Article {
|
|
|
3
3
|
readonly publish_date : string
|
|
4
4
|
readonly hash : string
|
|
5
5
|
readonly title : string
|
|
6
|
-
readonly publisher : string
|
|
6
|
+
readonly publisher? : string
|
|
7
7
|
readonly domain : string
|
|
8
8
|
readonly url : string
|
|
9
9
|
readonly fetch_time : string
|
|
@@ -33,7 +33,7 @@ export class Article {
|
|
|
33
33
|
typeof article.publish_date === "string" &&
|
|
34
34
|
typeof article.hash === "string" &&
|
|
35
35
|
typeof article.title === "string" &&
|
|
36
|
-
typeof article.publisher === "string" &&
|
|
36
|
+
(article.publisher === undefined || typeof article.publisher === "string") &&
|
|
37
37
|
typeof article.domain === "string" &&
|
|
38
38
|
typeof article.url === "string" &&
|
|
39
39
|
typeof article.fetch_time === "string" &&
|
|
@@ -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
|
}
|