elections-types 1.0.35 → 1.0.37
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/CandidateTweet.d.ts +10 -0
- package/dist/src/types/CandidateTweet.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/CandidateTweet.ts +32 -0
- package/src/types/Tweet.ts +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./types/APIError.js";
|
|
|
2
2
|
export * from "./types/Article.js";
|
|
3
3
|
export * from "./types/Candidate.js";
|
|
4
4
|
export * from "./types/CandidateArticle.js";
|
|
5
|
+
export * from "./types/CandidateTweet.js";
|
|
5
6
|
export * from "./types/CandidateVideo.js";
|
|
6
7
|
export * from "./types/Committee.js";
|
|
7
8
|
export * from "./types/Donation.js";
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./types/APIError.js";
|
|
|
2
2
|
export * from "./types/Article.js";
|
|
3
3
|
export * from "./types/Candidate.js";
|
|
4
4
|
export * from "./types/CandidateArticle.js";
|
|
5
|
+
export * from "./types/CandidateTweet.js";
|
|
5
6
|
export * from "./types/CandidateVideo.js";
|
|
6
7
|
export * from "./types/Committee.js";
|
|
7
8
|
export * from "./types/Donation.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class CandidateTweet {
|
|
2
|
+
readonly candidate_id: string;
|
|
3
|
+
readonly tweet_id: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly fetch_time: string;
|
|
6
|
+
readonly relevance?: string;
|
|
7
|
+
readonly sentiment?: string;
|
|
8
|
+
constructor(candidate_tweet: any);
|
|
9
|
+
static is(candidate_tweet: any): candidate_tweet is CandidateTweet;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class CandidateTweet {
|
|
2
|
+
candidate_id;
|
|
3
|
+
tweet_id;
|
|
4
|
+
url;
|
|
5
|
+
fetch_time;
|
|
6
|
+
relevance;
|
|
7
|
+
sentiment;
|
|
8
|
+
constructor(candidate_tweet) {
|
|
9
|
+
if (!CandidateTweet.is(candidate_tweet)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.candidate_id = candidate_tweet.candidate_id;
|
|
13
|
+
this.tweet_id = candidate_tweet.tweet_id;
|
|
14
|
+
this.url = candidate_tweet.url;
|
|
15
|
+
this.fetch_time = candidate_tweet.fetch_time;
|
|
16
|
+
this.relevance = candidate_tweet.relevance;
|
|
17
|
+
this.sentiment = candidate_tweet.sentiment;
|
|
18
|
+
}
|
|
19
|
+
static is(candidate_tweet) {
|
|
20
|
+
return (candidate_tweet !== undefined &&
|
|
21
|
+
typeof candidate_tweet.candidate_id === "string" &&
|
|
22
|
+
typeof candidate_tweet.tweet_id === "string" &&
|
|
23
|
+
typeof candidate_tweet.url === "string" &&
|
|
24
|
+
typeof candidate_tweet.fetch_time === "string" &&
|
|
25
|
+
(candidate_tweet.relevance === undefined || typeof candidate_tweet.relevance === "string") &&
|
|
26
|
+
(candidate_tweet.sentiment === undefined || typeof candidate_tweet.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
|
-
|
|
31
|
+
typeof tweet.html === "string" &&
|
|
32
32
|
(typeof tweet.text === "string"));
|
|
33
33
|
}
|
|
34
34
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./types/APIError"
|
|
|
2
2
|
export * from "./types/Article"
|
|
3
3
|
export * from "./types/Candidate"
|
|
4
4
|
export * from "./types/CandidateArticle"
|
|
5
|
+
export * from "./types/CandidateTweet"
|
|
5
6
|
export * from "./types/CandidateVideo"
|
|
6
7
|
export * from "./types/Committee"
|
|
7
8
|
export * from "./types/Donation"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class CandidateTweet {
|
|
2
|
+
readonly candidate_id : string
|
|
3
|
+
readonly tweet_id : string
|
|
4
|
+
readonly url : string
|
|
5
|
+
readonly fetch_time : string
|
|
6
|
+
readonly relevance? : string
|
|
7
|
+
readonly sentiment? : string
|
|
8
|
+
|
|
9
|
+
constructor(candidate_tweet : any) {
|
|
10
|
+
if (!CandidateTweet.is(candidate_tweet)) {
|
|
11
|
+
throw Error("Invalid input.")
|
|
12
|
+
}
|
|
13
|
+
this.candidate_id = candidate_tweet.candidate_id
|
|
14
|
+
this.tweet_id = candidate_tweet.tweet_id
|
|
15
|
+
this.url = candidate_tweet.url
|
|
16
|
+
this.fetch_time = candidate_tweet.fetch_time
|
|
17
|
+
this.relevance = candidate_tweet.relevance
|
|
18
|
+
this.sentiment = candidate_tweet.sentiment
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static is(candidate_tweet : any) : candidate_tweet is CandidateTweet {
|
|
22
|
+
return (
|
|
23
|
+
candidate_tweet !== undefined &&
|
|
24
|
+
typeof candidate_tweet.candidate_id === "string" &&
|
|
25
|
+
typeof candidate_tweet.tweet_id === "string" &&
|
|
26
|
+
typeof candidate_tweet.url === "string" &&
|
|
27
|
+
typeof candidate_tweet.fetch_time === "string" &&
|
|
28
|
+
(candidate_tweet.relevance === undefined || typeof candidate_tweet.relevance === "string") &&
|
|
29
|
+
(candidate_tweet.sentiment === undefined || typeof candidate_tweet.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
|
|
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
|
-
|
|
34
|
+
typeof tweet.html === "string" &&
|
|
35
35
|
(typeof tweet.text === "string")
|
|
36
36
|
)
|
|
37
37
|
}
|