elections-types 1.0.14 → 1.0.15

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,5 @@
1
1
  export * from "./types/APIError.js";
2
+ export * from "./types/Article.js";
2
3
  export * from "./types/Candidate.js";
3
4
  export * from "./types/Committee.js";
4
5
  export * from "./types/Donation.js";
@@ -8,3 +9,4 @@ export * from "./types/FormTypeID.js";
8
9
  export * from "./types/State.js";
9
10
  export * from "./types/Tweet.js";
10
11
  export * from "./types/User.js";
12
+ export * from "./types/Video.js";
package/dist/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types/APIError.js";
2
+ export * from "./types/Article.js";
2
3
  export * from "./types/Candidate.js";
3
4
  export * from "./types/Committee.js";
4
5
  export * from "./types/Donation.js";
@@ -8,3 +9,4 @@ export * from "./types/FormTypeID.js";
8
9
  export * from "./types/State.js";
9
10
  export * from "./types/Tweet.js";
10
11
  export * from "./types/User.js";
12
+ export * from "./types/Video.js";
@@ -0,0 +1,13 @@
1
+ export declare class Article {
2
+ readonly article_id: string;
3
+ readonly publish_date: string;
4
+ readonly hash: string;
5
+ readonly title: string;
6
+ readonly publisher: string;
7
+ readonly domain: string;
8
+ readonly url: string;
9
+ readonly fetch_time: string;
10
+ readonly s3_filename?: string;
11
+ constructor(article: any);
12
+ static is(article: any): article is Article;
13
+ }
@@ -0,0 +1,37 @@
1
+ export class Article {
2
+ article_id;
3
+ publish_date;
4
+ hash;
5
+ title;
6
+ publisher;
7
+ domain;
8
+ url;
9
+ fetch_time;
10
+ s3_filename;
11
+ constructor(article) {
12
+ if (!Article.is(article)) {
13
+ throw Error("Invalid input.");
14
+ }
15
+ this.article_id = article.article_id;
16
+ this.publish_date = article.publish_date;
17
+ this.hash = article.hash;
18
+ this.title = article.title;
19
+ this.publisher = article.publisher;
20
+ this.domain = article.domain;
21
+ this.url = article.url;
22
+ this.fetch_time = article.fetch_time;
23
+ this.s3_filename = article.s3_filename;
24
+ }
25
+ static is(article) {
26
+ return (article !== undefined &&
27
+ typeof article.article_id === "string" &&
28
+ typeof article.publish_date === "string" &&
29
+ typeof article.hash === "string" &&
30
+ typeof article.title === "string" &&
31
+ typeof article.publisher === "string" &&
32
+ typeof article.domain === "string" &&
33
+ typeof article.url === "string" &&
34
+ typeof article.fetch_time === "string" &&
35
+ (article.s3_filename === undefined || typeof article.s3_filename === "string"));
36
+ }
37
+ }
@@ -1 +1,30 @@
1
- export {};
1
+ import { ElectionID, OfficeID } from "./Election.js";
2
+ import { StateID } from "./State.js";
3
+ export declare class ActivityIndex {
4
+ readonly news_index: number;
5
+ readonly twitter_index: number;
6
+ readonly total_index: number;
7
+ constructor(activity_index: any);
8
+ static is(activity_index: any): activity_index is ActivityIndex;
9
+ }
10
+ export declare class Candidate {
11
+ readonly candidate_id: string;
12
+ readonly fec_name: string;
13
+ readonly office_id: OfficeID;
14
+ readonly state_id: StateID;
15
+ readonly election_id: ElectionID;
16
+ readonly party_id: string;
17
+ readonly active: boolean;
18
+ readonly status: string;
19
+ readonly file_number: number;
20
+ readonly committee_ids?: string[];
21
+ readonly principal_committee_ids?: string[];
22
+ readonly authorized_committee_ids?: string[];
23
+ readonly sponsor_committee_ids?: string[];
24
+ readonly expenditure_ids?: string[];
25
+ readonly ballotpedia_name?: string;
26
+ readonly ballotpedia_url?: string;
27
+ readonly ballotpedia_data?: Record<string, any>;
28
+ constructor(candidate: any);
29
+ static is(candidate: any): candidate is Candidate;
30
+ }
@@ -1,50 +1,84 @@
1
- // import { ElectionID, OfficeID } from "./Election.js"
2
- // import { StateID } from "./State.js"
3
- export {};
4
- // export class Candidate {
5
- // readonly candidate_id : string
6
- // readonly fec_name : string
7
- // readonly office_id : OfficeID
8
- // readonly state_id : StateID
9
- // readonly election_id : ElectionID
10
- // readonly party_id : string
11
- // readonly active : boolean
12
- // readonly status : boolean
13
- // constructor(candidate : any) {
14
- // if (!Candidate.is(candidate)) {
15
- // throw Error("Invalid input.")
16
- // }
17
- // this.office_id = candidate.office_id
18
- // this.number = candidate.number
19
- // this.scout_id = candidate.scout_id
20
- // this.name = candidate.name
21
- // this.active = candidate.active
22
- // this.state_id = candidate.state_id
23
- // this.district = candidate.district
24
- // this.party_id = candidate.party_id
25
- // this.tone_description_refresh = candidate.tone_description_refresh
26
- // this.jurisdiction_ids = candidate.jurisdiction_ids
27
- // this.sub_scout_ids = candidate.sub_scout_ids
28
- // this.office_class_id = candidate.office_class_id
29
- // this.office_name = candidate.office_name
30
- // }
31
- // static is(candidate : any) : candidate is Candidate {
32
- // return (
33
- // candidate !== undefined &&
34
- // typeof candidate.office_id === "string" &&
35
- // typeof candidate.number === "string" &&
36
- // typeof candidate.scout_id === "string" &&
37
- // typeof candidate.name === "string" &&
38
- // typeof candidate.active === "boolean" &&
39
- // (candidate.state_id === undefined || is_state_id(candidate.state_id)) &&
40
- // (candidate.district === undefined || typeof candidate.district === "number") &&
41
- // is_party_id(candidate.party_id) &&
42
- // typeof candidate.tone_description_refresh === "boolean" &&
43
- // Array.isArray(candidate.jurisdiction_ids) &&
44
- // candidate.jurisdiction_ids.every((jurisdiction_id : any) => typeof jurisdiction_id === "number") &&
45
- // (candidate.sub_scout_ids === undefined || Array.isArray(candidate.sub_scout_ids) && candidate.sub_scout_ids.every((sub_scout_id : any) => typeof sub_scout_id === "string")) &&
46
- // is_office_class_id(candidate.office_class_id) &&
47
- // (candidate.office_name === undefined || typeof candidate.office_name === "string")
48
- // )
49
- // }
50
- // }
1
+ import { is_election_id, is_office_id } from "./Election.js";
2
+ import { is_state_id } from "./State.js";
3
+ export class ActivityIndex {
4
+ news_index;
5
+ twitter_index;
6
+ total_index;
7
+ constructor(activity_index) {
8
+ if (!ActivityIndex.is(activity_index)) {
9
+ throw Error("Invalid input.");
10
+ }
11
+ this.news_index = activity_index.news_index;
12
+ this.twitter_index = activity_index.twitter_index;
13
+ this.total_index = activity_index.total_index;
14
+ }
15
+ static is(activity_index) {
16
+ return (activity_index !== undefined &&
17
+ typeof activity_index.news_index === "number" &&
18
+ typeof activity_index.twitter_index === "number" &&
19
+ typeof activity_index.total_index === "number");
20
+ }
21
+ }
22
+ export class Candidate {
23
+ candidate_id;
24
+ fec_name;
25
+ office_id;
26
+ state_id;
27
+ election_id;
28
+ party_id;
29
+ active;
30
+ status;
31
+ file_number;
32
+ committee_ids;
33
+ principal_committee_ids;
34
+ authorized_committee_ids;
35
+ sponsor_committee_ids;
36
+ expenditure_ids;
37
+ ballotpedia_name;
38
+ ballotpedia_url;
39
+ ballotpedia_data;
40
+ // readonly urls? : string[]
41
+ // readonly previews? : string[]
42
+ constructor(candidate) {
43
+ if (!Candidate.is(candidate)) {
44
+ throw Error("Invalid input.");
45
+ }
46
+ this.candidate_id = candidate.candidate_id;
47
+ this.fec_name = candidate.fec_name;
48
+ this.office_id = candidate.office_id;
49
+ this.state_id = candidate.state_id;
50
+ this.election_id = candidate.election_id;
51
+ this.party_id = candidate.party_id;
52
+ this.active = candidate.active;
53
+ this.status = candidate.status;
54
+ this.file_number = candidate.file_number;
55
+ this.committee_ids = candidate.committee_ids;
56
+ this.principal_committee_ids = candidate.principal_committee_ids;
57
+ this.authorized_committee_ids = candidate.authorized_committee_ids;
58
+ this.sponsor_committee_ids = candidate.sponsor_committee_ids;
59
+ this.expenditure_ids = candidate.expenditure_ids;
60
+ this.ballotpedia_name = candidate.ballotpedia_name;
61
+ this.ballotpedia_url = candidate.ballotpedia_url;
62
+ this.ballotpedia_data = candidate.ballotpedia_data;
63
+ }
64
+ static is(candidate) {
65
+ return (candidate !== undefined &&
66
+ typeof candidate.candidate_id === "string" &&
67
+ typeof candidate.fec_name === "string" &&
68
+ is_office_id(candidate.office_id) &&
69
+ is_state_id(candidate.state_id) &&
70
+ is_election_id(candidate.election_id) &&
71
+ typeof candidate.party_id === "string" &&
72
+ typeof candidate.active === "boolean" &&
73
+ typeof candidate.status === "string" &&
74
+ typeof candidate.file_number === "number" &&
75
+ (candidate.committee_id === undefined || Array.isArray(candidate.committee_id) && candidate.committee_id.map((committee_id) => typeof committee_id === "string")) &&
76
+ (candidate.principal_committee_ids === undefined || Array.isArray(candidate.principal_committee_ids) && candidate.principal_committee_ids.map((committee_id) => typeof committee_id === "string")) &&
77
+ (candidate.authorized_committee_ids === undefined || Array.isArray(candidate.authorized_committee_ids) && candidate.authorized_committee_ids.map((committee_id) => typeof committee_id === "string")) &&
78
+ (candidate.sponsor_committee_ids === undefined || Array.isArray(candidate.sponsor_committee_ids) && candidate.sponsor_committee_ids.map((committee_id) => typeof committee_id === "string")) &&
79
+ (candidate.expenditure_ids === undefined || Array.isArray(candidate.expenditure_ids) && candidate.expenditure_ids.map((committee_id) => typeof committee_id === "string")) &&
80
+ (candidate.ballotpedia_name === undefined || typeof candidate.ballotpedia_name === "string") &&
81
+ (candidate.ballotpedia_url === undefined || typeof candidate.ballotpedia_url === "string") &&
82
+ (candidate.ballotpedia_data === undefined || typeof candidate.ballotpedia_data === "object" && Object.keys(candidate.ballotpedia_data).map((key) => typeof key === "string")));
83
+ }
84
+ }
@@ -0,0 +1,14 @@
1
+ export declare class Video {
2
+ readonly video_id: string;
3
+ readonly publish_time: string;
4
+ readonly hash: string;
5
+ readonly channel_id: string;
6
+ readonly channel_name: string;
7
+ readonly title: string;
8
+ readonly description: string;
9
+ readonly tags?: string[];
10
+ readonly duration: number;
11
+ readonly fetch_time: string;
12
+ constructor(video: any);
13
+ static is(video: any): video is Video;
14
+ }
@@ -0,0 +1,40 @@
1
+ export class Video {
2
+ video_id;
3
+ publish_time;
4
+ hash;
5
+ channel_id;
6
+ channel_name;
7
+ title;
8
+ description;
9
+ tags;
10
+ duration;
11
+ fetch_time;
12
+ constructor(video) {
13
+ if (!Video.is(video)) {
14
+ throw Error("Invalid input.");
15
+ }
16
+ this.video_id = video.video_id;
17
+ this.publish_time = video.publish_time;
18
+ this.hash = video.hash;
19
+ this.channel_id = video.channel_id;
20
+ this.channel_name = video.channel_name;
21
+ this.title = video.title;
22
+ this.description = video.description;
23
+ this.tags = video.tags;
24
+ this.duration = video.duration;
25
+ this.fetch_time = video.fetch_time;
26
+ }
27
+ static is(video) {
28
+ return (video !== undefined &&
29
+ typeof video.video_id === "string" &&
30
+ typeof video.publish_time === "string" &&
31
+ typeof video.hash === "string" &&
32
+ typeof video.channel_id === "string" &&
33
+ typeof video.channel_name === "string" &&
34
+ typeof video.title === "string" &&
35
+ typeof video.description === "string" &&
36
+ (video.tags === undefined || Array.isArray(video.tags) && video.tags.map((tag) => typeof tag === "string")) &&
37
+ typeof video.duration === "number" &&
38
+ typeof video.fetch_time === "number");
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elections-types",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./types/APIError"
2
+ export * from "./types/Article"
2
3
  export * from "./types/Candidate"
3
4
  export * from "./types/Committee"
4
5
  export * from "./types/Donation"
@@ -7,4 +8,5 @@ export * from "./types/ElectionsConfig"
7
8
  export * from "./types/FormTypeID"
8
9
  export * from "./types/State"
9
10
  export * from "./types/Tweet"
10
- export * from "./types/User"
11
+ export * from "./types/User"
12
+ export * from "./types/Video"
@@ -0,0 +1,41 @@
1
+ export class Article {
2
+ readonly article_id : string
3
+ readonly publish_date : string
4
+ readonly hash : string
5
+ readonly title : string
6
+ readonly publisher : string
7
+ readonly domain : string
8
+ readonly url : string
9
+ readonly fetch_time : string
10
+ readonly s3_filename? : string
11
+
12
+ constructor(article : any) {
13
+ if (!Article.is(article)) {
14
+ throw Error("Invalid input.")
15
+ }
16
+ this.article_id = article.article_id
17
+ this.publish_date = article.publish_date
18
+ this.hash = article.hash
19
+ this.title = article.title
20
+ this.publisher = article.publisher
21
+ this.domain = article.domain
22
+ this.url = article.url
23
+ this.fetch_time = article.fetch_time
24
+ this.s3_filename = article.s3_filename
25
+ }
26
+
27
+ static is(article : any) : article is Article {
28
+ return (
29
+ article !== undefined &&
30
+ typeof article.article_id === "string" &&
31
+ typeof article.publish_date === "string" &&
32
+ typeof article.hash === "string" &&
33
+ typeof article.title === "string" &&
34
+ typeof article.publisher === "string" &&
35
+ typeof article.domain === "string" &&
36
+ typeof article.url === "string" &&
37
+ typeof article.fetch_time === "string" &&
38
+ (article.s3_filename === undefined || typeof article.s3_filename === "string")
39
+ )
40
+ }
41
+ }
@@ -1,52 +1,95 @@
1
- // import { ElectionID, OfficeID } from "./Election"
2
- // import { StateID } from "./State"
1
+ import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
2
+ import { is_state_id, StateID } from "./State"
3
3
 
4
- // export class Candidate {
5
- // readonly candidate_id : string
6
- // readonly fec_name : string
7
- // readonly office_id : OfficeID
8
- // readonly state_id : StateID
9
- // readonly election_id : ElectionID
10
- // readonly party_id : string
11
- // readonly active : boolean
12
- // readonly status : boolean
4
+ export class ActivityIndex {
5
+ readonly news_index : number
6
+ readonly twitter_index : number
7
+ readonly total_index : number
13
8
 
14
- // constructor(candidate : any) {
15
- // if (!Candidate.is(candidate)) {
16
- // throw Error("Invalid input.")
17
- // }
18
- // this.office_id = candidate.office_id
19
- // this.number = candidate.number
20
- // this.scout_id = candidate.scout_id
21
- // this.name = candidate.name
22
- // this.active = candidate.active
23
- // this.state_id = candidate.state_id
24
- // this.district = candidate.district
25
- // this.party_id = candidate.party_id
26
- // this.tone_description_refresh = candidate.tone_description_refresh
27
- // this.jurisdiction_ids = candidate.jurisdiction_ids
28
- // this.sub_scout_ids = candidate.sub_scout_ids
29
- // this.office_class_id = candidate.office_class_id
30
- // this.office_name = candidate.office_name
31
- // }
9
+ constructor(activity_index : any) {
10
+ if (!ActivityIndex.is(activity_index)) {
11
+ throw Error("Invalid input.")
12
+ }
13
+ this.news_index = activity_index.news_index
14
+ this.twitter_index = activity_index.twitter_index
15
+ this.total_index = activity_index.total_index
16
+ }
32
17
 
33
- // static is(candidate : any) : candidate is Candidate {
34
- // return (
35
- // candidate !== undefined &&
36
- // typeof candidate.office_id === "string" &&
37
- // typeof candidate.number === "string" &&
38
- // typeof candidate.scout_id === "string" &&
39
- // typeof candidate.name === "string" &&
40
- // typeof candidate.active === "boolean" &&
41
- // (candidate.state_id === undefined || is_state_id(candidate.state_id)) &&
42
- // (candidate.district === undefined || typeof candidate.district === "number") &&
43
- // is_party_id(candidate.party_id) &&
44
- // typeof candidate.tone_description_refresh === "boolean" &&
45
- // Array.isArray(candidate.jurisdiction_ids) &&
46
- // candidate.jurisdiction_ids.every((jurisdiction_id : any) => typeof jurisdiction_id === "number") &&
47
- // (candidate.sub_scout_ids === undefined || Array.isArray(candidate.sub_scout_ids) && candidate.sub_scout_ids.every((sub_scout_id : any) => typeof sub_scout_id === "string")) &&
48
- // is_office_class_id(candidate.office_class_id) &&
49
- // (candidate.office_name === undefined || typeof candidate.office_name === "string")
50
- // )
51
- // }
52
- // }
18
+ static is(activity_index : any) : activity_index is ActivityIndex {
19
+ return (
20
+ activity_index !== undefined &&
21
+ typeof activity_index.news_index === "number" &&
22
+ typeof activity_index.twitter_index === "number" &&
23
+ typeof activity_index.total_index === "number"
24
+ )
25
+ }
26
+ }
27
+
28
+ export class Candidate {
29
+ readonly candidate_id : string
30
+ readonly fec_name : string
31
+ readonly office_id : OfficeID
32
+ readonly state_id : StateID
33
+ readonly election_id : ElectionID
34
+ readonly party_id : string
35
+ readonly active : boolean
36
+ readonly status : string
37
+ readonly file_number : number
38
+ readonly committee_ids? : string[]
39
+ readonly principal_committee_ids? : string[]
40
+ readonly authorized_committee_ids? : string[]
41
+ readonly sponsor_committee_ids? : string[]
42
+ readonly expenditure_ids? : string[]
43
+ readonly ballotpedia_name? : string
44
+ readonly ballotpedia_url? : string
45
+ readonly ballotpedia_data? : Record<string, any>
46
+ // readonly urls? : string[]
47
+ // readonly previews? : string[]
48
+
49
+
50
+ constructor(candidate : any) {
51
+ if (!Candidate.is(candidate)) {
52
+ throw Error("Invalid input.")
53
+ }
54
+ this.candidate_id = candidate.candidate_id
55
+ this.fec_name = candidate.fec_name
56
+ this.office_id = candidate.office_id
57
+ this.state_id = candidate.state_id
58
+ this.election_id = candidate.election_id
59
+ this.party_id = candidate.party_id
60
+ this.active = candidate.active
61
+ this.status = candidate.status
62
+ this.file_number = candidate.file_number
63
+ this.committee_ids = candidate.committee_ids
64
+ this.principal_committee_ids = candidate.principal_committee_ids
65
+ this.authorized_committee_ids = candidate.authorized_committee_ids
66
+ this.sponsor_committee_ids = candidate.sponsor_committee_ids
67
+ this.expenditure_ids = candidate.expenditure_ids
68
+ this.ballotpedia_name = candidate.ballotpedia_name
69
+ this.ballotpedia_url = candidate.ballotpedia_url
70
+ this.ballotpedia_data = candidate.ballotpedia_data
71
+ }
72
+
73
+ static is(candidate : any) : candidate is Candidate {
74
+ return (
75
+ candidate !== undefined &&
76
+ typeof candidate.candidate_id === "string" &&
77
+ typeof candidate.fec_name === "string" &&
78
+ is_office_id(candidate.office_id) &&
79
+ is_state_id(candidate.state_id) &&
80
+ is_election_id(candidate.election_id) &&
81
+ typeof candidate.party_id === "string" &&
82
+ typeof candidate.active === "boolean" &&
83
+ typeof candidate.status === "string" &&
84
+ typeof candidate.file_number === "number" &&
85
+ (candidate.committee_id === undefined || Array.isArray(candidate.committee_id) && candidate.committee_id.map((committee_id : any) => typeof committee_id === "string")) &&
86
+ (candidate.principal_committee_ids === undefined || Array.isArray(candidate.principal_committee_ids) && candidate.principal_committee_ids.map((committee_id : any) => typeof committee_id === "string")) &&
87
+ (candidate.authorized_committee_ids === undefined || Array.isArray(candidate.authorized_committee_ids) && candidate.authorized_committee_ids.map((committee_id : any) => typeof committee_id === "string")) &&
88
+ (candidate.sponsor_committee_ids === undefined || Array.isArray(candidate.sponsor_committee_ids) && candidate.sponsor_committee_ids.map((committee_id : any) => typeof committee_id === "string")) &&
89
+ (candidate.expenditure_ids === undefined || Array.isArray(candidate.expenditure_ids) && candidate.expenditure_ids.map((committee_id : any) => typeof committee_id === "string")) &&
90
+ (candidate.ballotpedia_name === undefined || typeof candidate.ballotpedia_name === "string") &&
91
+ (candidate.ballotpedia_url === undefined || typeof candidate.ballotpedia_url === "string") &&
92
+ (candidate.ballotpedia_data === undefined || typeof candidate.ballotpedia_data === "object" && Object.keys(candidate.ballotpedia_data).map((key : any) => typeof key === "string"))
93
+ )
94
+ }
95
+ }
@@ -0,0 +1,44 @@
1
+ export class Video {
2
+ readonly video_id : string
3
+ readonly publish_time : string
4
+ readonly hash : string
5
+ readonly channel_id : string
6
+ readonly channel_name : string
7
+ readonly title : string
8
+ readonly description : string
9
+ readonly tags? : string[]
10
+ readonly duration : number
11
+ readonly fetch_time : string
12
+
13
+ constructor(video : any) {
14
+ if (!Video.is(video)) {
15
+ throw Error("Invalid input.")
16
+ }
17
+ this.video_id = video.video_id
18
+ this.publish_time = video.publish_time
19
+ this.hash = video.hash
20
+ this.channel_id = video.channel_id
21
+ this.channel_name = video.channel_name
22
+ this.title = video.title
23
+ this.description = video.description
24
+ this.tags = video.tags
25
+ this.duration = video.duration
26
+ this.fetch_time = video.fetch_time
27
+ }
28
+
29
+ static is(video : any) : video is Video {
30
+ return (
31
+ video !== undefined &&
32
+ typeof video.video_id === "string" &&
33
+ typeof video.publish_time === "string" &&
34
+ typeof video.hash === "string" &&
35
+ typeof video.channel_id === "string" &&
36
+ typeof video.channel_name === "string" &&
37
+ typeof video.title === "string" &&
38
+ typeof video.description === "string" &&
39
+ (video.tags === undefined || Array.isArray(video.tags) && video.tags.map((tag : any) => typeof tag === "string")) &&
40
+ typeof video.duration === "number" &&
41
+ typeof video.fetch_time === "number"
42
+ )
43
+ }
44
+ }