elections-types 1.0.92 → 1.1.0

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.
Files changed (45) hide show
  1. package/dist/src/index.d.ts +6 -6
  2. package/dist/src/index.js +6 -6
  3. package/dist/src/types/ElectionsConfig.d.ts +6 -6
  4. package/dist/src/types/FederalElection.d.ts +27 -0
  5. package/dist/src/types/FederalElection.js +86 -0
  6. package/dist/src/types/FederalElectionCandidate.d.ts +38 -0
  7. package/dist/src/types/FederalElectionCandidate.js +99 -0
  8. package/dist/src/types/FederalElectionCandidateCommittee.d.ts +7 -0
  9. package/dist/src/types/FederalElectionCandidateCommittee.js +32 -0
  10. package/dist/src/types/FederalElectionCommittee.d.ts +27 -0
  11. package/dist/src/types/FederalElectionCommittee.js +68 -0
  12. package/dist/src/types/FederalElectionF1File.d.ts +10 -10
  13. package/dist/src/types/FederalElectionF1File.js +24 -24
  14. package/dist/src/types/FederalElectionF24File.d.ts +3 -3
  15. package/dist/src/types/FederalElectionF24File.js +5 -5
  16. package/dist/src/types/FederalElectionF2File.d.ts +5 -5
  17. package/dist/src/types/FederalElectionF2File.js +13 -13
  18. package/dist/src/types/FederalElectionF3File.d.ts +1 -1
  19. package/dist/src/types/FederalElectionF3File.js +3 -3
  20. package/dist/src/types/FederalElectionFileExpenditure.d.ts +28 -0
  21. package/dist/src/types/FederalElectionFileExpenditure.js +70 -0
  22. package/dist/src/types/Tweet.d.ts +1 -4
  23. package/dist/src/types/Tweet.js +14 -13
  24. package/dist/src/types/UserFederalElection.d.ts +9 -0
  25. package/dist/src/types/UserFederalElection.js +24 -0
  26. package/package.json +1 -1
  27. package/src/index.ts +6 -6
  28. package/src/types/ElectionsConfig.ts +6 -6
  29. package/src/types/FederalElection.ts +105 -0
  30. package/src/types/FederalElectionCandidate.ts +118 -0
  31. package/src/types/FederalElectionCandidateCommittee.ts +42 -0
  32. package/src/types/FederalElectionCommittee.ts +84 -0
  33. package/src/types/FederalElectionF1File.ts +25 -25
  34. package/src/types/FederalElectionF24File.ts +6 -6
  35. package/src/types/FederalElectionF2File.ts +13 -13
  36. package/src/types/FederalElectionF3File.ts +3 -3
  37. package/src/types/FederalElectionFileExpenditure.ts +82 -0
  38. package/src/types/Tweet.ts +13 -13
  39. package/src/types/UserFederalElection.ts +31 -0
  40. package/src/types/Candidate.ts +0 -118
  41. package/src/types/CandidateCommittee.ts +0 -42
  42. package/src/types/Committee.ts +0 -84
  43. package/src/types/Election.ts +0 -105
  44. package/src/types/Expenditure.ts +0 -82
  45. package/src/types/UserElection.ts +0 -31
@@ -1,13 +1,13 @@
1
- import { ElectionID, OfficeID } from "./Election.js";
1
+ import { FederalElectionID, FederalElectionOfficeID } from "./FederalElection.js";
2
2
  import { FederalElectionFile } from "./FederalElectionFile.js";
3
3
  import { StateID } from "./State.js";
4
4
  export declare class FederalElectionF2File extends FederalElectionFile {
5
- readonly candidate_id: string;
6
- readonly fec_name: string;
7
- readonly office_id: OfficeID;
5
+ readonly federal_election_candidate_id: string;
6
+ readonly name: string;
7
+ readonly federal_election_office_id: FederalElectionOfficeID;
8
8
  readonly state_id: StateID;
9
9
  readonly district?: number;
10
- readonly election_id: ElectionID;
10
+ readonly federal_election_id: FederalElectionID;
11
11
  readonly party_id?: string;
12
12
  readonly report_date: string;
13
13
  constructor(federal_election_file: any);
@@ -1,13 +1,13 @@
1
- import { is_election_id, is_office_id } from "./Election.js";
1
+ import { is_federal_election_id, is_federal_election_office_id } from "./FederalElection.js";
2
2
  import { FederalElectionFile } from "./FederalElectionFile.js";
3
3
  import { is_state_id } from "./State.js";
4
4
  export class FederalElectionF2File extends FederalElectionFile {
5
- candidate_id;
6
- fec_name;
7
- office_id;
5
+ federal_election_candidate_id;
6
+ name;
7
+ federal_election_office_id;
8
8
  state_id;
9
9
  district;
10
- election_id;
10
+ federal_election_id;
11
11
  party_id;
12
12
  report_date;
13
13
  constructor(federal_election_file) {
@@ -15,24 +15,24 @@ export class FederalElectionF2File extends FederalElectionFile {
15
15
  throw Error("Invalid input.");
16
16
  }
17
17
  super(federal_election_file);
18
- this.candidate_id = federal_election_file.candidate_id;
19
- this.fec_name = federal_election_file.fec_name;
20
- this.office_id = federal_election_file.office_id;
18
+ this.federal_election_candidate_id = federal_election_file.federal_election_candidate_id;
19
+ this.name = federal_election_file.name;
20
+ this.federal_election_office_id = federal_election_file.federal_election_office_id;
21
21
  this.state_id = federal_election_file.state_id;
22
22
  this.district = federal_election_file.district;
23
- this.election_id = federal_election_file.election_id;
23
+ this.federal_election_id = federal_election_file.federal_election_id;
24
24
  this.party_id = federal_election_file.party_id;
25
25
  this.report_date = federal_election_file.report_date;
26
26
  }
27
27
  static is(federal_election_file) {
28
28
  return (FederalElectionFile.is(federal_election_file) &&
29
29
  federal_election_file.form_type_id === "F2" &&
30
- typeof federal_election_file.candidate_id === "string" &&
31
- typeof federal_election_file.fec_name === "string" &&
32
- is_office_id(federal_election_file.office_id) &&
30
+ typeof federal_election_file.federal_election_candidate_id === "string" &&
31
+ typeof federal_election_file.name === "string" &&
32
+ is_federal_election_office_id(federal_election_file.federal_election_office_id) &&
33
33
  is_state_id(federal_election_file.state_id) &&
34
34
  (federal_election_file.district === undefined || typeof federal_election_file.district === "number") &&
35
- is_election_id(federal_election_file.election_id) &&
35
+ is_federal_election_id(federal_election_file.federal_election_id) &&
36
36
  (federal_election_file.party_id === undefined || typeof federal_election_file.party_id === "string") &&
37
37
  typeof federal_election_file.report_date === "string");
38
38
  }
@@ -1,6 +1,6 @@
1
1
  import { FederalElectionFile } from "./FederalElectionFile.js";
2
2
  export declare class FederalElectionF3File extends FederalElectionFile {
3
- readonly committee_id: string;
3
+ readonly federal_election_committee_id: string;
4
4
  readonly period_id: string;
5
5
  readonly period_start_date: string;
6
6
  readonly period_end_date: string;
@@ -1,6 +1,6 @@
1
1
  import { FederalElectionFile } from "./FederalElectionFile.js";
2
2
  export class FederalElectionF3File extends FederalElectionFile {
3
- committee_id;
3
+ federal_election_committee_id;
4
4
  period_id;
5
5
  period_start_date;
6
6
  period_end_date;
@@ -13,7 +13,7 @@ export class FederalElectionF3File extends FederalElectionFile {
13
13
  throw Error("Invalid input.");
14
14
  }
15
15
  super(federal_election_file);
16
- this.committee_id = federal_election_file.committee_id;
16
+ this.federal_election_committee_id = federal_election_file.federal_election_committee_id;
17
17
  this.period_id = federal_election_file.period_id;
18
18
  this.period_start_date = federal_election_file.period_start_date;
19
19
  this.period_end_date = federal_election_file.period_end_date;
@@ -25,7 +25,7 @@ export class FederalElectionF3File extends FederalElectionFile {
25
25
  static is(federal_election_file) {
26
26
  return (FederalElectionFile.is(federal_election_file) &&
27
27
  federal_election_file.form_type_id === "F3" &&
28
- typeof federal_election_file.committee_id === "string" &&
28
+ typeof federal_election_file.federal_election_committee_id === "string" &&
29
29
  typeof federal_election_file.period_id === "string" &&
30
30
  typeof federal_election_file.period_start_date === "string" &&
31
31
  typeof federal_election_file.period_end_date === "string" &&
@@ -0,0 +1,28 @@
1
+ import { FederalElectionCandidate } from "./FederalElectionCandidate.js";
2
+ import { FederalElectionCommittee } from "./FederalElectionCommittee.js";
3
+ import { FederalElectionID } from "./FederalElection.js";
4
+ import { FederalElectionF24File } from "./FederalElectionF24File.js";
5
+ export declare class FederalElectionFileExpenditure {
6
+ readonly federal_election_file_id: number;
7
+ readonly expenditure_id: string;
8
+ readonly federal_election_committee_id: string;
9
+ readonly date: string;
10
+ readonly payee: string;
11
+ readonly election_stage: string;
12
+ readonly federal_election_id: FederalElectionID;
13
+ readonly federal_election_candidate_id: string;
14
+ readonly amount: number;
15
+ readonly cumulative_amount: number;
16
+ readonly purpose: string;
17
+ readonly is_support: boolean;
18
+ readonly [x: string]: any;
19
+ constructor(federal_election_file_expenditure: any);
20
+ static is(federal_election_file_expenditure: any): federal_election_file_expenditure is FederalElectionFileExpenditure;
21
+ }
22
+ export declare class FederalElectionFileExpenditureAux extends FederalElectionFileExpenditure {
23
+ readonly federal_election_candidate: FederalElectionCandidate;
24
+ readonly federal_election_committee: FederalElectionCommittee;
25
+ readonly federal_election_f24_file: FederalElectionF24File;
26
+ constructor(federal_election_file_expenditure: any);
27
+ static is(federal_election_file_expenditure: any): federal_election_file_expenditure is FederalElectionFileExpenditureAux;
28
+ }
@@ -0,0 +1,70 @@
1
+ import { FederalElectionCandidate } from "./FederalElectionCandidate.js";
2
+ import { FederalElectionCommittee } from "./FederalElectionCommittee.js";
3
+ import { is_federal_election_id } from "./FederalElection.js";
4
+ import { FederalElectionF24File } from "./FederalElectionF24File.js";
5
+ export class FederalElectionFileExpenditure {
6
+ federal_election_file_id;
7
+ expenditure_id;
8
+ federal_election_committee_id;
9
+ date;
10
+ payee;
11
+ election_stage;
12
+ federal_election_id;
13
+ federal_election_candidate_id;
14
+ amount;
15
+ cumulative_amount;
16
+ purpose;
17
+ is_support;
18
+ constructor(federal_election_file_expenditure) {
19
+ if (!FederalElectionFileExpenditure.is(federal_election_file_expenditure)) {
20
+ throw Error("Invalid input.");
21
+ }
22
+ this.federal_election_file_id = federal_election_file_expenditure.federal_election_file_id;
23
+ this.expenditure_id = federal_election_file_expenditure.expenditure_id;
24
+ this.federal_election_committee_id = federal_election_file_expenditure.federal_election_committee_id;
25
+ this.date = federal_election_file_expenditure.date;
26
+ this.payee = federal_election_file_expenditure.payee;
27
+ this.election_stage = federal_election_file_expenditure.election_stage;
28
+ this.federal_election_id = federal_election_file_expenditure.federal_election_id;
29
+ this.federal_election_candidate_id = federal_election_file_expenditure.federal_election_candidate_id;
30
+ this.amount = federal_election_file_expenditure.amount;
31
+ this.cumulative_amount = federal_election_file_expenditure.cumulative_amount;
32
+ this.purpose = federal_election_file_expenditure.purpose;
33
+ this.is_support = federal_election_file_expenditure.is_support;
34
+ }
35
+ static is(federal_election_file_expenditure) {
36
+ return (federal_election_file_expenditure !== undefined &&
37
+ typeof federal_election_file_expenditure.federal_election_file_id === "number" &&
38
+ typeof federal_election_file_expenditure.expenditure_id === "string" &&
39
+ typeof federal_election_file_expenditure.federal_election_committee_id === "string" &&
40
+ typeof federal_election_file_expenditure.date === "string" &&
41
+ typeof federal_election_file_expenditure.payee === "string" &&
42
+ typeof federal_election_file_expenditure.election_stage === "string" &&
43
+ is_federal_election_id(federal_election_file_expenditure.federal_election_id) &&
44
+ typeof federal_election_file_expenditure.federal_election_candidate_id === "string" &&
45
+ typeof federal_election_file_expenditure.amount === "number" &&
46
+ typeof federal_election_file_expenditure.cumulative_amount === "number" &&
47
+ typeof federal_election_file_expenditure.purpose === "string" &&
48
+ typeof federal_election_file_expenditure.is_support === "boolean");
49
+ }
50
+ }
51
+ export class FederalElectionFileExpenditureAux extends FederalElectionFileExpenditure {
52
+ federal_election_candidate;
53
+ federal_election_committee;
54
+ federal_election_f24_file;
55
+ constructor(federal_election_file_expenditure) {
56
+ if (!FederalElectionFileExpenditureAux.is(federal_election_file_expenditure)) {
57
+ throw Error("Invalid input.");
58
+ }
59
+ super(federal_election_file_expenditure);
60
+ this.federal_election_candidate = federal_election_file_expenditure.federal_election_candidate;
61
+ this.federal_election_committee = federal_election_file_expenditure.federal_election_committee;
62
+ this.federal_election_f24_file = federal_election_file_expenditure.federal_election_f24_file;
63
+ }
64
+ static is(federal_election_file_expenditure) {
65
+ return (FederalElectionFileExpenditure.is(federal_election_file_expenditure) &&
66
+ FederalElectionCandidate.is(federal_election_file_expenditure.federal_election_candidate) &&
67
+ FederalElectionCommittee.is(federal_election_file_expenditure.federal_election_committee) &&
68
+ FederalElectionF24File.is(federal_election_file_expenditure.federal_election_f24_file));
69
+ }
70
+ }
@@ -2,11 +2,8 @@ export declare class Tweet {
2
2
  readonly tweet_id: string;
3
3
  readonly username: string;
4
4
  readonly url: string;
5
- readonly tweet_time: string;
6
- readonly tweet_content: string;
7
- readonly quote?: string;
5
+ readonly publish_time: string;
8
6
  readonly html: string;
9
- readonly text: string;
10
7
  constructor(tweet: Tweet);
11
8
  static is(tweet: any): tweet is Tweet;
12
9
  }
@@ -2,11 +2,11 @@ export class Tweet {
2
2
  tweet_id;
3
3
  username;
4
4
  url;
5
- tweet_time;
6
- tweet_content;
7
- quote;
5
+ publish_time;
6
+ // readonly tweet_content : string
7
+ // readonly quote? : string
8
8
  html;
9
- text;
9
+ // readonly text : string
10
10
  constructor(tweet) {
11
11
  if (!Tweet.is(tweet)) {
12
12
  throw Error("Invalid input.");
@@ -14,21 +14,22 @@ export class Tweet {
14
14
  this.tweet_id = tweet.tweet_id;
15
15
  this.username = tweet.username;
16
16
  this.url = tweet.url;
17
- this.tweet_time = tweet.tweet_time;
18
- this.tweet_content = tweet.tweet_content;
19
- this.quote = tweet.quote;
17
+ this.publish_time = tweet.publish_time;
18
+ // this.tweet_content = tweet.tweet_content
19
+ // this.quote = tweet.quote
20
20
  this.html = tweet.html;
21
- this.text = tweet.text;
21
+ // this.text = tweet.text
22
22
  }
23
23
  static is(tweet) {
24
24
  return (tweet !== undefined &&
25
25
  typeof tweet.tweet_id === "string" &&
26
26
  typeof tweet.username === "string" &&
27
27
  typeof tweet.url === "string" &&
28
- typeof tweet.tweet_time === "string" &&
29
- typeof tweet.tweet_content === "string" &&
30
- (tweet.quote === undefined || typeof tweet.quote === "string") &&
31
- typeof tweet.html === "string" &&
32
- (typeof tweet.text === "string"));
28
+ typeof tweet.publish_time === "string" &&
29
+ // typeof tweet.tweet_content === "string" &&
30
+ // (tweet.quote === undefined || typeof tweet.quote === "string") &&
31
+ typeof tweet.html === "string"
32
+ // (typeof tweet.text === "string")
33
+ );
33
34
  }
34
35
  }
@@ -0,0 +1,9 @@
1
+ import { FederalElectionID } from "./FederalElection.js";
2
+ export declare class UserFederalElection {
3
+ readonly user_id: string;
4
+ readonly federal_election_id: FederalElectionID;
5
+ readonly candidate_display: Record<string, number>;
6
+ readonly notify: boolean;
7
+ constructor(user_federal_election: UserFederalElection);
8
+ static is(user_federal_election: any): user_federal_election is UserFederalElection;
9
+ }
@@ -0,0 +1,24 @@
1
+ import { is_federal_election_id } from "./FederalElection.js";
2
+ export class UserFederalElection {
3
+ user_id;
4
+ federal_election_id;
5
+ candidate_display;
6
+ notify;
7
+ // readonly [x : string] : any
8
+ constructor(user_federal_election) {
9
+ if (!UserFederalElection.is(user_federal_election)) {
10
+ throw Error("Invalid Input.");
11
+ }
12
+ this.user_id = user_federal_election.user_id;
13
+ this.federal_election_id = user_federal_election.federal_election_id;
14
+ this.candidate_display = user_federal_election.candidate_display;
15
+ this.notify = user_federal_election.notify;
16
+ }
17
+ static is(user_federal_election) {
18
+ return (user_federal_election !== undefined &&
19
+ typeof user_federal_election.user_id === "string" &&
20
+ is_federal_election_id(user_federal_election.federal_election_id) &&
21
+ Object.entries(user_federal_election.candidate_display).every(([key, value]) => (typeof key === "string" && typeof value === "number")) &&
22
+ typeof user_federal_election.notify === "boolean");
23
+ }
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elections-types",
3
- "version": "1.0.92",
3
+ "version": "1.1.0",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/index.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  export * from "./types/APIError"
2
2
  export * from "./types/Article"
3
- export * from "./types/Candidate"
4
3
  export * from "./types/CandidateArticle"
5
- export * from "./types/CandidateCommittee"
6
4
  export * from "./types/CandidateTweet"
7
5
  export * from "./types/CandidateVideo"
8
- export * from "./types/Committee"
9
- export * from "./types/Election"
6
+ export * from "./types/FederalElection"
10
7
  export * from "./types/ElectionsConfig"
11
- export * from "./types/Expenditure"
8
+ export * from "./types/FederalElectionCommittee"
9
+ export * from "./types/FederalElectionCandidate"
10
+ export * from "./types/FederalElectionCandidateCommittee"
11
+ export * from "./types/FederalElectionFileExpenditure"
12
12
  export * from "./types/FederalElectionDonation"
13
13
  export * from "./types/FederalElectionFile"
14
14
  export * from "./types/FederalElectionF1File"
@@ -19,5 +19,5 @@ export * from "./types/FormTypeID"
19
19
  export * from "./types/State"
20
20
  export * from "./types/Tweet"
21
21
  export * from "./types/User"
22
- export * from "./types/UserElection"
22
+ export * from "./types/UserFederalElection"
23
23
  export * from "./types/Video"
@@ -20,13 +20,13 @@ export interface ElectionsConfig extends ElectionsUtilsConfig {
20
20
  super_gov_api_keys : string[],
21
21
  gov_api_keys : string[],
22
22
  lobby_api_key : string,
23
- dynamodb_elections : string,
24
- dynamodb_candidates : string,
25
- dynamodb_committees : string,
26
- dynamodb_candidate_committees : string,
27
- dynamodb_expenditures : string,
23
+ dynamodb_federal_elections : string,
24
+ dynamodb_federal_election_candidates : string,
25
+ dynamodb_federal_election_committees : string,
26
+ dynamodb_federal_election_candidate_committees : string,
27
+ dynamodb_federal_election_file_expenditures : string,
28
28
  dynamodb_users : string,
29
- dynamodb_user_elections : string,
29
+ dynamodb_user_federal_elections : string,
30
30
  dynamodb_articles : string,
31
31
  dynamodb_candidate_articles : string,
32
32
  dynamodb_tweets : string,
@@ -0,0 +1,105 @@
1
+ import { FederalElectionCandidate, FederalElectionCandidateAux } from "./FederalElectionCandidate"
2
+ import { FederalElectionCommittee, FederalElectionCommitteeAux } from "./FederalElectionCommittee"
3
+ import { FederalElectionFileExpenditureAux } from "./FederalElectionFileExpenditure"
4
+ import { is_state_id, state_ids, StateID } from "./State"
5
+
6
+ const federal_election_office_ids = ["H", "S", "P"] as const
7
+
8
+ export type FederalElectionOfficeID = typeof federal_election_office_ids[number]
9
+
10
+ export function is_federal_election_office_id(federal_election_office_id : any) : federal_election_office_id is FederalElectionOfficeID {
11
+ return federal_election_office_ids.includes(federal_election_office_id)
12
+ }
13
+
14
+ const state_ids_without_district : StateID[] = ["AK", "DE", "ND", "SD", "VT", "WY"]
15
+
16
+ export type FederalElectionID = string
17
+
18
+ export function is_federal_election_id(federal_election_id : any) : federal_election_id is FederalElectionID {
19
+ const parts = federal_election_id.split("-")
20
+ const year = Number(parts[0])
21
+ const federal_election_office_id = parts[1]
22
+ const state_id = parts[2]
23
+ const district = Number(parts[3])
24
+ if (!(Number.isInteger(year) && year > 1700 && year < 3000 && is_federal_election_office_id(federal_election_office_id))) {
25
+ return false
26
+ }
27
+ if (federal_election_office_id === "P" && parts.length === 2) {
28
+ return true
29
+ }
30
+ if (!is_state_id(state_id)) {
31
+ return false
32
+ }
33
+ if (federal_election_office_id === "S" && parts.length === 3) {
34
+ return true
35
+ }
36
+ if (federal_election_office_id !== "H") {
37
+ return false
38
+ }
39
+ if (!(state_ids_without_district.includes(state_id) && parts.length === 3 || parts.length === 4)) {
40
+ return false
41
+ }
42
+ if (!Number.isInteger(district) && district < 100) {
43
+ return false
44
+ }
45
+ return true
46
+ }
47
+
48
+ export class FederalElection {
49
+ readonly federal_election_id : FederalElectionID
50
+ readonly name : string
51
+ readonly federal_election_office_id : FederalElectionOfficeID
52
+ readonly state_id? : StateID
53
+ readonly district? : number
54
+ readonly [x : string] : any
55
+
56
+ constructor(federal_election : FederalElection) {
57
+ if (!FederalElection.is(federal_election)) {
58
+ throw Error("Invalid input.")
59
+ }
60
+ this.federal_election_id = federal_election.federal_election_id
61
+ this.name = federal_election.name
62
+ this.federal_election_office_id = federal_election.federal_election_office_id
63
+ this.state_id = federal_election.state_id
64
+ this.district = federal_election.district
65
+ }
66
+
67
+ static is(federal_election : any) : federal_election is FederalElection {
68
+ return (
69
+ federal_election !== undefined &&
70
+ is_federal_election_id(federal_election.federal_election_id) &&
71
+ typeof federal_election.name === "string" &&
72
+ is_federal_election_office_id(federal_election.federal_election_office_id) &&
73
+ (federal_election.state_id === undefined || is_state_id(federal_election.state_id)) &&
74
+ (federal_election.district === undefined || typeof federal_election.district === "number")
75
+ )
76
+ }
77
+ }
78
+
79
+ export class ElectionAux extends FederalElection {
80
+ readonly federal_election_candidates : FederalElectionCandidateAux[]
81
+ readonly federal_election_committees : FederalElectionCommitteeAux[]
82
+ readonly federal_election_file_expenditures : FederalElectionFileExpenditureAux[]
83
+
84
+ constructor(federal_election : any) {
85
+ if (!ElectionAux.is(federal_election)) {
86
+ throw Error("Invalid input.")
87
+ }
88
+ super(federal_election)
89
+ this.federal_election_candidates = federal_election.federal_election_candidates
90
+ this.federal_election_committees = federal_election.committees
91
+ this.federal_election_file_expenditures = federal_election.federal_election_file_expenditures
92
+ }
93
+
94
+ static is(federal_election : any) : federal_election is ElectionAux {
95
+ return (
96
+ FederalElection.is(federal_election) &&
97
+ Array.isArray(federal_election.federal_election_candidates) &&
98
+ federal_election.federal_election_candidates.every(FederalElectionCandidateAux.is) &&
99
+ Array.isArray(federal_election.federal_election_committees) &&
100
+ federal_election.federal_election_committees.every(FederalElectionCommitteeAux.is) &&
101
+ Array.isArray(federal_election.federal_election_file_expenditures) &&
102
+ federal_election.federal_election_file_expenditures.every(FederalElectionFileExpenditureAux.is)
103
+ )
104
+ }
105
+ }
@@ -0,0 +1,118 @@
1
+ import { FederalElectionCommittee, FederalElectionCommitteeAux } from "./FederalElectionCommittee"
2
+ import { FederalElectionID, is_federal_election_id, is_federal_election_office_id, FederalElectionOfficeID } from "./FederalElection"
3
+ import { FederalElectionFileExpenditure, FederalElectionFileExpenditureAux } from "./FederalElectionFileExpenditure"
4
+ import { FederalElectionF3File } from "./FederalElectionF3File"
5
+ import { is_state_id, StateID } from "./State"
6
+
7
+ export class ActivityIndex {
8
+ readonly news_index : number
9
+ readonly twitter_index : number
10
+ readonly total_index : number
11
+
12
+ constructor(activity_index : any) {
13
+ if (!ActivityIndex.is(activity_index)) {
14
+ throw Error("Invalid input.")
15
+ }
16
+ this.news_index = activity_index.news_index
17
+ this.twitter_index = activity_index.twitter_index
18
+ this.total_index = activity_index.total_index
19
+ }
20
+
21
+ static is(activity_index : any) : activity_index is ActivityIndex {
22
+ return (
23
+ activity_index !== undefined &&
24
+ typeof activity_index.news_index === "number" &&
25
+ typeof activity_index.twitter_index === "number" &&
26
+ typeof activity_index.total_index === "number"
27
+ )
28
+ }
29
+ }
30
+
31
+ export class FederalElectionCandidate {
32
+ readonly federal_election_candidate_id : string
33
+ readonly name : string
34
+ readonly federal_election_office_id : FederalElectionOfficeID
35
+ readonly state_id : StateID
36
+ readonly district? : number
37
+ readonly federal_election_id : FederalElectionID
38
+ readonly party_id? : string
39
+ readonly is_active? : boolean
40
+ readonly status? : string
41
+ readonly federal_election_file_id? : number
42
+ readonly ballotpedia_name? : string
43
+ readonly ballotpedia_url? : string
44
+ readonly ballotpedia_data? : Record<string, any>
45
+ readonly activity_index? : ActivityIndex
46
+ // readonly urls? : string[]
47
+ // readonly previews? : string[]
48
+ [x : string] : any
49
+
50
+
51
+ constructor(federal_election_candidate : FederalElectionCandidate) {
52
+ if (!FederalElectionCandidate.is(federal_election_candidate)) {
53
+ throw Error("Invalid input.")
54
+ }
55
+ this.federal_election_candidate_id = federal_election_candidate.federal_election_candidate_id
56
+ this.name = federal_election_candidate.name
57
+ this.federal_election_office_id = federal_election_candidate.federal_election_office_id
58
+ this.state_id = federal_election_candidate.state_id
59
+ this.district = federal_election_candidate.district
60
+ this.federal_election_id = federal_election_candidate.federal_election_id
61
+ this.party_id = federal_election_candidate.party_id
62
+ this.is_active = federal_election_candidate.is_active
63
+ this.status = federal_election_candidate.status
64
+ this.federal_election_file_id = federal_election_candidate.federal_election_file_id
65
+ this.ballotpedia_name = federal_election_candidate.ballotpedia_name
66
+ this.ballotpedia_url = federal_election_candidate.ballotpedia_url
67
+ this.ballotpedia_data = federal_election_candidate.ballotpedia_data
68
+ this.activity_index = federal_election_candidate.activity_index !== undefined ? new ActivityIndex(federal_election_candidate.activity_index) : undefined
69
+ }
70
+
71
+ static is(federal_election_candidate : any) : federal_election_candidate is FederalElectionCandidate {
72
+ return (
73
+ federal_election_candidate !== undefined &&
74
+ typeof federal_election_candidate.federal_election_candidate_id === "string" &&
75
+ typeof federal_election_candidate.name === "string" &&
76
+ is_federal_election_office_id(federal_election_candidate.federal_election_office_id) &&
77
+ is_state_id(federal_election_candidate.state_id) &&
78
+ (federal_election_candidate.district === undefined || typeof federal_election_candidate.district === "number") &&
79
+ is_federal_election_id(federal_election_candidate.federal_election_id) &&
80
+ (federal_election_candidate.party_id === undefined || typeof federal_election_candidate.party_id === "string") &&
81
+ (federal_election_candidate.is_active === undefined || typeof federal_election_candidate.is_active === "boolean") &&
82
+ (federal_election_candidate.status === undefined || typeof federal_election_candidate.status === "string") &&
83
+ (federal_election_candidate.federal_election_file_id === undefined || typeof federal_election_candidate.federal_election_file_id === "number" && !isNaN(federal_election_candidate.federal_election_file_id)) &&
84
+ (federal_election_candidate.ballotpedia_name === undefined || typeof federal_election_candidate.ballotpedia_name === "string") &&
85
+ (federal_election_candidate.ballotpedia_url === undefined || typeof federal_election_candidate.ballotpedia_url === "string") &&
86
+ (federal_election_candidate.ballotpedia_data === undefined || typeof federal_election_candidate.ballotpedia_data === "object" && Object.keys(federal_election_candidate.ballotpedia_data).map((key : any) => typeof key === "string")) &&
87
+ (federal_election_candidate.activity_index === undefined || ActivityIndex.is(federal_election_candidate.activity_index))
88
+ )
89
+ }
90
+ }
91
+
92
+ export class FederalElectionCandidateAux extends FederalElectionCandidate {
93
+ readonly federal_election_committees : FederalElectionCommitteeAux[]
94
+ readonly federal_election_f3_files : FederalElectionF3File[]
95
+ readonly federal_election_file_expenditures : FederalElectionFileExpenditureAux[]
96
+
97
+ constructor(federal_election_candidate : any) {
98
+ if (!FederalElectionCandidateAux.is(federal_election_candidate)) {
99
+ throw Error("Invalid input.")
100
+ }
101
+ super(federal_election_candidate)
102
+ this.federal_election_committees = federal_election_candidate.federal_election_committees
103
+ this.federal_election_f3_files = federal_election_candidate.federal_election_f3_files
104
+ this.federal_election_file_expenditures = federal_election_candidate.federal_election_file_expenditures
105
+ }
106
+
107
+ static is(federal_election_candidate : any) : federal_election_candidate is FederalElectionCandidateAux {
108
+ return (
109
+ FederalElectionCandidate.is(federal_election_candidate) &&
110
+ Array.isArray(federal_election_candidate.federal_election_committees) &&
111
+ federal_election_candidate.federal_election_committees.every(FederalElectionCommitteeAux.is) &&
112
+ Array.isArray(federal_election_candidate.federal_election_f3_files) &&
113
+ federal_election_candidate.federal_election_f3_files.every(FederalElectionF3File.is) &&
114
+ Array.isArray(federal_election_candidate.federal_election_file_expenditures) &&
115
+ federal_election_candidate.federal_election_file_expenditures.every(FederalElectionFileExpenditureAux.is)
116
+ )
117
+ }
118
+ }
@@ -0,0 +1,42 @@
1
+ import { FederalElectionCommittee, FederalElectionCommitteeAux } from "./FederalElectionCommittee"
2
+
3
+ export class FederalElectionCandidateCommittee {
4
+ readonly federal_election_candidate_id : string
5
+ readonly federal_election_committee_id : string
6
+ [x : string] : any
7
+
8
+ constructor(federal_election_candidate_committee : FederalElectionCandidateCommittee) {
9
+ if (!FederalElectionCandidateCommittee.is(federal_election_candidate_committee)) {
10
+ throw Error("Invalid input.")
11
+ }
12
+ this.federal_election_candidate_id = federal_election_candidate_committee.federal_election_candidate_id
13
+ this.federal_election_committee_id = federal_election_candidate_committee.federal_election_committee_id
14
+ }
15
+
16
+ static is(federal_election_candidate_committee : any) : federal_election_candidate_committee is FederalElectionCandidateCommittee {
17
+ return (
18
+ federal_election_candidate_committee !== undefined &&
19
+ typeof federal_election_candidate_committee.federal_election_candidate_id === "string" &&
20
+ typeof federal_election_candidate_committee.federal_election_committee_id === "string"
21
+ )
22
+ }
23
+ }
24
+
25
+ // export class CandidateCommitteeAux extends CandidateCommittee {
26
+ // readonly committee : FederalElectionCommitteeAux
27
+
28
+ // constructor(candidate_committee : any) {
29
+ // if (!CandidateCommitteeAux.is(candidate_committee)) {
30
+ // throw Error("Invalid input.")
31
+ // }
32
+ // super(candidate_committee)
33
+ // this.committee = candidate_committee.committee
34
+ // }
35
+
36
+ // static is(candidate_committee : any) : candidate_committee is CandidateCommitteeAux {
37
+ // return (
38
+ // CandidateCommittee.is(candidate_committee) &&
39
+ // FederalElectionCommitteeAux.is(candidate_committee.committee)
40
+ // )
41
+ // }
42
+ // }