elections-types 1.0.92 → 1.0.93
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 +6 -6
- package/dist/src/index.js +6 -6
- package/dist/src/types/ElectionsConfig.d.ts +6 -6
- package/dist/src/types/FederalElection.d.ts +27 -0
- package/dist/src/types/FederalElection.js +86 -0
- package/dist/src/types/FederalElectionCandidate.d.ts +38 -0
- package/dist/src/types/FederalElectionCandidate.js +99 -0
- package/dist/src/types/FederalElectionCandidateCommittee.d.ts +7 -0
- package/dist/src/types/FederalElectionCandidateCommittee.js +32 -0
- package/dist/src/types/FederalElectionCommittee.d.ts +27 -0
- package/dist/src/types/FederalElectionCommittee.js +68 -0
- package/dist/src/types/FederalElectionF1File.d.ts +10 -10
- package/dist/src/types/FederalElectionF1File.js +24 -24
- package/dist/src/types/FederalElectionF24File.d.ts +3 -3
- package/dist/src/types/FederalElectionF24File.js +5 -5
- package/dist/src/types/FederalElectionF2File.d.ts +5 -5
- package/dist/src/types/FederalElectionF2File.js +13 -13
- package/dist/src/types/FederalElectionF3File.d.ts +1 -1
- package/dist/src/types/FederalElectionF3File.js +3 -3
- package/dist/src/types/FederalElectionFileExpenditure.d.ts +28 -0
- package/dist/src/types/FederalElectionFileExpenditure.js +70 -0
- package/dist/src/types/Tweet.d.ts +1 -4
- package/dist/src/types/Tweet.js +14 -13
- package/dist/src/types/UserFederalElection.d.ts +9 -0
- package/dist/src/types/UserFederalElection.js +24 -0
- package/package.json +1 -1
- package/src/index.ts +6 -6
- package/src/types/ElectionsConfig.ts +6 -6
- package/src/types/FederalElection.ts +105 -0
- package/src/types/FederalElectionCandidate.ts +118 -0
- package/src/types/FederalElectionCandidateCommittee.ts +42 -0
- package/src/types/FederalElectionCommittee.ts +84 -0
- package/src/types/FederalElectionF1File.ts +25 -25
- package/src/types/FederalElectionF24File.ts +6 -6
- package/src/types/FederalElectionF2File.ts +13 -13
- package/src/types/FederalElectionF3File.ts +3 -3
- package/src/types/FederalElectionFileExpenditure.ts +82 -0
- package/src/types/Tweet.ts +13 -13
- package/src/types/UserFederalElection.ts +31 -0
- package/src/types/Candidate.ts +0 -118
- package/src/types/CandidateCommittee.ts +0 -42
- package/src/types/Committee.ts +0 -84
- package/src/types/Election.ts +0 -105
- package/src/types/Expenditure.ts +0 -82
- package/src/types/UserElection.ts +0 -31
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { FederalElectionCandidate } from "./FederalElectionCandidate"
|
|
2
|
+
import { FederalElectionCandidateCommittee } from "./FederalElectionCandidateCommittee"
|
|
3
|
+
import { FederalElectionF3File } from "./FederalElectionF3File"
|
|
4
|
+
|
|
5
|
+
export const designations = ["P", "A", "U", "J", "D", "B"] as const
|
|
6
|
+
|
|
7
|
+
export type FederalElectionCommitteeDesignation = typeof designations[number]
|
|
8
|
+
|
|
9
|
+
export function is_federal_election_committee_designation(designation : any) : designation is FederalElectionCommitteeDesignation {
|
|
10
|
+
return designations.includes(designation)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class FederalElectionCommittee {
|
|
14
|
+
readonly federal_election_federal_election_committee_id : string
|
|
15
|
+
readonly name : string
|
|
16
|
+
readonly url? : string
|
|
17
|
+
readonly designation? : FederalElectionCommitteeDesignation
|
|
18
|
+
readonly federal_election_file_id? : number
|
|
19
|
+
readonly jfp_federal_election_federal_election_committee_ids? : string[]
|
|
20
|
+
readonly jfr_federal_election_federal_election_committee_ids : string[]
|
|
21
|
+
readonly aff_federal_election_federal_election_committee_ids : string[]
|
|
22
|
+
readonly [x : string] : any
|
|
23
|
+
|
|
24
|
+
constructor(federal_election_committee : FederalElectionCommittee) {
|
|
25
|
+
if (!FederalElectionCommittee.is(federal_election_committee)) {
|
|
26
|
+
throw Error("Invalid input.")
|
|
27
|
+
}
|
|
28
|
+
this.federal_election_federal_election_committee_id = federal_election_committee.federal_election_federal_election_committee_id
|
|
29
|
+
this.name = federal_election_committee.name
|
|
30
|
+
this.url = federal_election_committee.url
|
|
31
|
+
this.designation = federal_election_committee.designation
|
|
32
|
+
this.federal_election_file_id = federal_election_committee.federal_election_file_id
|
|
33
|
+
this.jfp_federal_election_federal_election_committee_ids = federal_election_committee.jfp_federal_election_federal_election_committee_ids
|
|
34
|
+
this.jfr_federal_election_federal_election_committee_ids = federal_election_committee.jfr_federal_election_federal_election_committee_ids
|
|
35
|
+
this.aff_federal_election_federal_election_committee_ids = federal_election_committee.aff_federal_election_federal_election_committee_ids
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static is(federal_election_committee : any) : federal_election_committee is FederalElectionCommittee {
|
|
39
|
+
return (
|
|
40
|
+
federal_election_committee !== undefined &&
|
|
41
|
+
typeof federal_election_committee.federal_election_federal_election_committee_id === "string" &&
|
|
42
|
+
typeof federal_election_committee.name === "string" &&
|
|
43
|
+
(federal_election_committee.url === undefined || typeof federal_election_committee.url === "string") &&
|
|
44
|
+
(federal_election_committee.designation === undefined || is_federal_election_committee_designation(federal_election_committee.designation)) &&
|
|
45
|
+
(federal_election_committee.federal_election_file_id === undefined || typeof federal_election_committee.federal_election_file_id === "number" && !isNaN(federal_election_committee.federal_election_file_id)) &&
|
|
46
|
+
(federal_election_committee.jfp_federal_election_federal_election_committee_ids === undefined || Array.isArray(federal_election_committee.jfp_federal_election_federal_election_committee_ids) && federal_election_committee.jfp_federal_election_federal_election_committee_ids.every((federal_election_federal_election_committee_id : any) => typeof federal_election_federal_election_committee_id === "string")) &&
|
|
47
|
+
(Array.isArray(federal_election_committee.jfr_federal_election_federal_election_committee_ids) && federal_election_committee.jfr_federal_election_federal_election_committee_ids.every((federal_election_federal_election_committee_id : any) => typeof federal_election_federal_election_committee_id === "string")) &&
|
|
48
|
+
(Array.isArray(federal_election_committee.aff_federal_election_federal_election_committee_ids) && federal_election_committee.aff_federal_election_federal_election_committee_ids.every((federal_election_federal_election_committee_id : any) => typeof federal_election_federal_election_committee_id === "string"))
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class FederalElectionCommitteeAux extends FederalElectionCommittee {
|
|
54
|
+
readonly federal_election_candidates : FederalElectionCandidate[]
|
|
55
|
+
readonly federal_election_f3_files : FederalElectionF3File[]
|
|
56
|
+
readonly jfp_federal_election_committees? : FederalElectionCommittee[]
|
|
57
|
+
readonly jfr_federal_election_committees : FederalElectionCommittee[]
|
|
58
|
+
readonly aff_federal_election_committees : FederalElectionCommittee[]
|
|
59
|
+
|
|
60
|
+
constructor(federal_election_committee : any) {
|
|
61
|
+
if (!FederalElectionCommitteeAux.is(federal_election_committee)) {
|
|
62
|
+
throw Error("Invalid input.")
|
|
63
|
+
}
|
|
64
|
+
super(federal_election_committee)
|
|
65
|
+
this.federal_election_candidates = federal_election_committee.federal_election_candidates
|
|
66
|
+
this.federal_election_f3_files = federal_election_committee.federal_election_f3_files
|
|
67
|
+
this.jfp_federal_election_committees = federal_election_committee.jfp_federal_election_committees
|
|
68
|
+
this.jfr_federal_election_committees = federal_election_committee.jfr_federal_election_committees
|
|
69
|
+
this.aff_federal_election_committees = federal_election_committee.aff_federal_election_committees
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static is(federal_election_committee : any) : federal_election_committee is FederalElectionCommitteeAux {
|
|
73
|
+
return (
|
|
74
|
+
FederalElectionCommittee.is(federal_election_committee) &&
|
|
75
|
+
Array.isArray(federal_election_committee.federal_election_candidates) &&
|
|
76
|
+
federal_election_committee.federal_election_candidates.every(FederalElectionCandidate.is) &&
|
|
77
|
+
Array.isArray(federal_election_committee.federal_election_f3_files) &&
|
|
78
|
+
federal_election_committee.federal_election_f3_files.every(FederalElectionF3File.is) &&
|
|
79
|
+
(federal_election_committee.jfp_federal_election_committees === undefined || Array.isArray(federal_election_committee.jfp_federal_election_committees) && federal_election_committee.jfp_federal_election_committees.every(FederalElectionCommittee.is)) &&
|
|
80
|
+
(Array.isArray(federal_election_committee.jfr_federal_election_committees) && federal_election_committee.jfr_federal_election_committees.every(FederalElectionCommittee.is)) &&
|
|
81
|
+
(Array.isArray(federal_election_committee.aff_federal_election_committees) && federal_election_committee.aff_federal_election_committees.every(FederalElectionCommittee.is))
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { FederalElectionCommitteeDesignation, is_federal_election_committee_designation } from "./FederalElectionCommittee"
|
|
2
|
+
import { FederalElectionID, is_federal_election_id } from "./FederalElection"
|
|
3
3
|
import { FederalElectionFile } from "./FederalElectionFile"
|
|
4
4
|
|
|
5
5
|
export class FederalElectionF1File extends FederalElectionFile {
|
|
6
|
-
readonly
|
|
6
|
+
readonly federal_election_committee_id : string
|
|
7
7
|
readonly name : string
|
|
8
8
|
readonly url? : string
|
|
9
9
|
readonly report_date : string
|
|
10
|
-
readonly designation :
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
10
|
+
readonly designation : FederalElectionCommitteeDesignation
|
|
11
|
+
readonly federal_election_id? : FederalElectionID
|
|
12
|
+
readonly federal_election_candidate_id? : string
|
|
13
|
+
readonly jfp_federal_election_committee_ids? : string[]
|
|
14
|
+
readonly jfr_federal_election_committee_ids : string[]
|
|
15
|
+
readonly aff_federal_election_committee_ids : string[]
|
|
16
|
+
readonly sponsor_federal_election_candidate_ids? : string[]
|
|
17
17
|
|
|
18
18
|
constructor(federal_election_file : any) {
|
|
19
19
|
if (!FederalElectionF1File.is(federal_election_file)) {
|
|
20
20
|
throw Error("Invalid input.")
|
|
21
21
|
}
|
|
22
22
|
super(federal_election_file)
|
|
23
|
-
this.
|
|
23
|
+
this.federal_election_committee_id = federal_election_file.federal_election_committee_id
|
|
24
24
|
this.name = federal_election_file.name
|
|
25
25
|
this.url = federal_election_file.url
|
|
26
26
|
this.report_date = federal_election_file.report_date
|
|
27
27
|
this.designation = federal_election_file.designation
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
28
|
+
this.federal_election_id = federal_election_file.federal_election_id
|
|
29
|
+
this.federal_election_candidate_id = federal_election_file.federal_election_candidate_id
|
|
30
|
+
this.jfp_federal_election_committee_ids = federal_election_file.jfp_federal_election_committee_ids
|
|
31
|
+
this.jfr_federal_election_committee_ids = federal_election_file.jfr_federal_election_committee_ids
|
|
32
|
+
this.aff_federal_election_committee_ids = federal_election_file.aff_federal_election_committee_ids
|
|
33
|
+
this.sponsor_federal_election_candidate_ids = federal_election_file.sponsor_federal_election_candidate_ids
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static is(federal_election_file : any) : federal_election_file is FederalElectionF1File {
|
|
37
37
|
return (
|
|
38
38
|
FederalElectionFile.is(federal_election_file) &&
|
|
39
39
|
federal_election_file.form_type_id === "F1" &&
|
|
40
|
-
typeof federal_election_file.
|
|
40
|
+
typeof federal_election_file.federal_election_committee_id === "string" &&
|
|
41
41
|
typeof federal_election_file.name === "string" &&
|
|
42
42
|
(federal_election_file.url === undefined || typeof federal_election_file.url === "string") &&
|
|
43
43
|
typeof federal_election_file.report_date === "string" &&
|
|
44
|
-
|
|
45
|
-
(federal_election_file.
|
|
46
|
-
(federal_election_file.
|
|
47
|
-
(federal_election_file.
|
|
48
|
-
(Array.isArray(federal_election_file.
|
|
49
|
-
(Array.isArray(federal_election_file.
|
|
50
|
-
(federal_election_file.
|
|
44
|
+
is_federal_election_committee_designation(federal_election_file.designation) &&
|
|
45
|
+
(federal_election_file.federal_election_id === undefined || is_federal_election_id(federal_election_file.federal_election_id)) &&
|
|
46
|
+
(federal_election_file.federal_election_candidate_id === undefined || typeof federal_election_file.federal_election_candidate_id === "string") &&
|
|
47
|
+
(federal_election_file.jfp_federal_election_committee_ids === undefined || Array.isArray(federal_election_file.jfp_federal_election_committee_ids) && federal_election_file.jfp_federal_election_committee_ids.every((federal_election_committee_id : any) => typeof federal_election_committee_id === "string")) &&
|
|
48
|
+
(Array.isArray(federal_election_file.jfr_federal_election_committee_ids) && federal_election_file.jfr_federal_election_committee_ids.every((federal_election_committee_id : any) => typeof federal_election_committee_id === "string")) &&
|
|
49
|
+
(Array.isArray(federal_election_file.aff_federal_election_committee_ids) && federal_election_file.aff_federal_election_committee_ids.every((federal_election_committee_id : any) => typeof federal_election_committee_id === "string")) &&
|
|
50
|
+
(federal_election_file.sponsor_federal_election_candidate_ids === undefined || Array.isArray(federal_election_file.sponsor_federal_election_candidate_ids) && federal_election_file.sponsor_federal_election_candidate_ids.every((federal_election_committee_id : any) => typeof federal_election_committee_id === "string"))
|
|
51
51
|
)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FederalElectionFileExpenditure } from "./FederalElectionFileExpenditure"
|
|
2
2
|
import { FederalElectionFile } from "./FederalElectionFile"
|
|
3
3
|
|
|
4
4
|
export class FederalElectionF24File extends FederalElectionFile {
|
|
5
|
-
readonly
|
|
5
|
+
readonly federal_election_committee_id : string
|
|
6
6
|
readonly first_federal_election_file_id : number
|
|
7
7
|
readonly report_type : string
|
|
8
8
|
readonly first_report_date : string
|
|
9
9
|
readonly report_date : string
|
|
10
|
-
readonly expenditures :
|
|
10
|
+
readonly expenditures : FederalElectionFileExpenditure[]
|
|
11
11
|
|
|
12
12
|
constructor(federal_election_file : any) {
|
|
13
13
|
if (!FederalElectionF24File.is(federal_election_file)) {
|
|
14
14
|
throw Error("Invalid input.")
|
|
15
15
|
}
|
|
16
16
|
super(federal_election_file)
|
|
17
|
-
this.
|
|
17
|
+
this.federal_election_committee_id = federal_election_file.federal_election_committee_id
|
|
18
18
|
this.first_federal_election_file_id = federal_election_file.first_federal_election_file_id
|
|
19
19
|
this.report_type = federal_election_file.report_type
|
|
20
20
|
this.first_report_date = federal_election_file.first_report_date
|
|
@@ -26,12 +26,12 @@ export class FederalElectionF24File extends FederalElectionFile {
|
|
|
26
26
|
return (
|
|
27
27
|
FederalElectionFile.is(federal_election_file) &&
|
|
28
28
|
federal_election_file.form_type_id === "F24" &&
|
|
29
|
-
typeof federal_election_file.
|
|
29
|
+
typeof federal_election_file.federal_election_committee_id === "string" &&
|
|
30
30
|
typeof federal_election_file.first_federal_election_file_id === "number" &&
|
|
31
31
|
typeof federal_election_file.report_type === "string" &&
|
|
32
32
|
typeof federal_election_file.first_report_date === "string" &&
|
|
33
33
|
typeof federal_election_file.report_date === "string" &&
|
|
34
|
-
Array.isArray(federal_election_file.expenditures) && federal_election_file.expenditures.every(
|
|
34
|
+
Array.isArray(federal_election_file.expenditures) && federal_election_file.expenditures.every(FederalElectionFileExpenditure.is)
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FederalElectionID, is_federal_election_id, is_federal_election_office_id, FederalElectionOfficeID } from "./FederalElection"
|
|
2
2
|
import { FederalElectionFile } from "./FederalElectionFile"
|
|
3
3
|
import { is_state_id, StateID } from "./State"
|
|
4
4
|
|
|
5
5
|
export class FederalElectionF2File extends FederalElectionFile {
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
6
|
+
readonly federal_election_candidate_id : string
|
|
7
|
+
readonly name : string
|
|
8
|
+
readonly federal_election_office_id : FederalElectionOfficeID
|
|
9
9
|
readonly state_id : StateID
|
|
10
10
|
readonly district? : number
|
|
11
|
-
readonly
|
|
11
|
+
readonly federal_election_id : FederalElectionID
|
|
12
12
|
readonly party_id? : string
|
|
13
13
|
readonly report_date : string
|
|
14
14
|
|
|
@@ -17,12 +17,12 @@ export class FederalElectionF2File extends FederalElectionFile {
|
|
|
17
17
|
throw Error("Invalid input.")
|
|
18
18
|
}
|
|
19
19
|
super(federal_election_file)
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
20
|
+
this.federal_election_candidate_id = federal_election_file.federal_election_candidate_id
|
|
21
|
+
this.name = federal_election_file.name
|
|
22
|
+
this.federal_election_office_id = federal_election_file.federal_election_office_id
|
|
23
23
|
this.state_id = federal_election_file.state_id
|
|
24
24
|
this.district = federal_election_file.district
|
|
25
|
-
this.
|
|
25
|
+
this.federal_election_id = federal_election_file.federal_election_id
|
|
26
26
|
this.party_id = federal_election_file.party_id
|
|
27
27
|
this.report_date = federal_election_file.report_date
|
|
28
28
|
}
|
|
@@ -31,12 +31,12 @@ export class FederalElectionF2File extends FederalElectionFile {
|
|
|
31
31
|
return (
|
|
32
32
|
FederalElectionFile.is(federal_election_file) &&
|
|
33
33
|
federal_election_file.form_type_id === "F2" &&
|
|
34
|
-
typeof federal_election_file.
|
|
35
|
-
typeof federal_election_file.
|
|
36
|
-
|
|
34
|
+
typeof federal_election_file.federal_election_candidate_id === "string" &&
|
|
35
|
+
typeof federal_election_file.name === "string" &&
|
|
36
|
+
is_federal_election_office_id(federal_election_file.federal_election_office_id) &&
|
|
37
37
|
is_state_id(federal_election_file.state_id) &&
|
|
38
38
|
(federal_election_file.district === undefined || typeof federal_election_file.district === "number") &&
|
|
39
|
-
|
|
39
|
+
is_federal_election_id(federal_election_file.federal_election_id) &&
|
|
40
40
|
(federal_election_file.party_id === undefined || typeof federal_election_file.party_id === "string") &&
|
|
41
41
|
typeof federal_election_file.report_date === "string"
|
|
42
42
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FederalElectionFile } from "./FederalElectionFile"
|
|
2
2
|
|
|
3
3
|
export class FederalElectionF3File extends FederalElectionFile {
|
|
4
|
-
readonly
|
|
4
|
+
readonly federal_election_committee_id : string
|
|
5
5
|
readonly period_id : string
|
|
6
6
|
readonly period_start_date : string
|
|
7
7
|
readonly period_end_date : string
|
|
@@ -15,7 +15,7 @@ export class FederalElectionF3File extends FederalElectionFile {
|
|
|
15
15
|
throw Error("Invalid input.")
|
|
16
16
|
}
|
|
17
17
|
super(federal_election_file)
|
|
18
|
-
this.
|
|
18
|
+
this.federal_election_committee_id = federal_election_file.federal_election_committee_id
|
|
19
19
|
this.period_id = federal_election_file.period_id
|
|
20
20
|
this.period_start_date = federal_election_file.period_start_date
|
|
21
21
|
this.period_end_date = federal_election_file.period_end_date
|
|
@@ -29,7 +29,7 @@ export class FederalElectionF3File extends FederalElectionFile {
|
|
|
29
29
|
return (
|
|
30
30
|
FederalElectionFile.is(federal_election_file) &&
|
|
31
31
|
federal_election_file.form_type_id === "F3" &&
|
|
32
|
-
typeof federal_election_file.
|
|
32
|
+
typeof federal_election_file.federal_election_committee_id === "string" &&
|
|
33
33
|
typeof federal_election_file.period_id === "string" &&
|
|
34
34
|
typeof federal_election_file.period_start_date === "string" &&
|
|
35
35
|
typeof federal_election_file.period_end_date === "string" &&
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FederalElectionCandidate } from "./FederalElectionCandidate"
|
|
2
|
+
import { FederalElectionCommittee } from "./FederalElectionCommittee"
|
|
3
|
+
import { FederalElectionID, is_federal_election_id } from "./FederalElection"
|
|
4
|
+
import { FederalElectionF24File } from "./FederalElectionF24File"
|
|
5
|
+
|
|
6
|
+
export class FederalElectionFileExpenditure {
|
|
7
|
+
readonly federal_election_file_id : number
|
|
8
|
+
readonly expenditure_id : string
|
|
9
|
+
readonly federal_election_committee_id : string
|
|
10
|
+
readonly date : string
|
|
11
|
+
readonly payee : string
|
|
12
|
+
readonly election_stage : string
|
|
13
|
+
readonly federal_election_id : FederalElectionID
|
|
14
|
+
readonly federal_election_candidate_id : string
|
|
15
|
+
readonly amount : number
|
|
16
|
+
readonly cumulative_amount : number
|
|
17
|
+
readonly purpose : string
|
|
18
|
+
readonly is_support : boolean
|
|
19
|
+
readonly [x : string] : any
|
|
20
|
+
|
|
21
|
+
constructor(federal_election_file_expenditure : any) {
|
|
22
|
+
if (!FederalElectionFileExpenditure.is(federal_election_file_expenditure)) {
|
|
23
|
+
throw Error("Invalid input.")
|
|
24
|
+
}
|
|
25
|
+
this.federal_election_file_id = federal_election_file_expenditure.federal_election_file_id
|
|
26
|
+
this.expenditure_id = federal_election_file_expenditure.expenditure_id
|
|
27
|
+
this.federal_election_committee_id = federal_election_file_expenditure.federal_election_committee_id
|
|
28
|
+
this.date = federal_election_file_expenditure.date
|
|
29
|
+
this.payee = federal_election_file_expenditure.payee
|
|
30
|
+
this.election_stage = federal_election_file_expenditure.election_stage
|
|
31
|
+
this.federal_election_id = federal_election_file_expenditure.federal_election_id
|
|
32
|
+
this.federal_election_candidate_id = federal_election_file_expenditure.federal_election_candidate_id
|
|
33
|
+
this.amount = federal_election_file_expenditure.amount
|
|
34
|
+
this.cumulative_amount = federal_election_file_expenditure.cumulative_amount
|
|
35
|
+
this.purpose = federal_election_file_expenditure.purpose
|
|
36
|
+
this.is_support = federal_election_file_expenditure.is_support
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static is(federal_election_file_expenditure : any) : federal_election_file_expenditure is FederalElectionFileExpenditure {
|
|
40
|
+
return (
|
|
41
|
+
federal_election_file_expenditure !== undefined &&
|
|
42
|
+
typeof federal_election_file_expenditure.federal_election_file_id === "number" &&
|
|
43
|
+
typeof federal_election_file_expenditure.expenditure_id === "string" &&
|
|
44
|
+
typeof federal_election_file_expenditure.federal_election_committee_id === "string" &&
|
|
45
|
+
typeof federal_election_file_expenditure.date === "string" &&
|
|
46
|
+
typeof federal_election_file_expenditure.payee === "string" &&
|
|
47
|
+
typeof federal_election_file_expenditure.election_stage === "string" &&
|
|
48
|
+
is_federal_election_id(federal_election_file_expenditure.federal_election_id) &&
|
|
49
|
+
typeof federal_election_file_expenditure.federal_election_candidate_id === "string" &&
|
|
50
|
+
typeof federal_election_file_expenditure.amount === "number" &&
|
|
51
|
+
typeof federal_election_file_expenditure.cumulative_amount === "number" &&
|
|
52
|
+
typeof federal_election_file_expenditure.purpose === "string" &&
|
|
53
|
+
typeof federal_election_file_expenditure.is_support === "boolean"
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class FederalElectionFileExpenditureAux extends FederalElectionFileExpenditure {
|
|
60
|
+
readonly federal_election_candidate : FederalElectionCandidate
|
|
61
|
+
readonly federal_election_committee : FederalElectionCommittee
|
|
62
|
+
readonly federal_election_f24_file : FederalElectionF24File
|
|
63
|
+
|
|
64
|
+
constructor(federal_election_file_expenditure : any) {
|
|
65
|
+
if (!FederalElectionFileExpenditureAux.is(federal_election_file_expenditure)) {
|
|
66
|
+
throw Error("Invalid input.")
|
|
67
|
+
}
|
|
68
|
+
super(federal_election_file_expenditure)
|
|
69
|
+
this.federal_election_candidate = federal_election_file_expenditure.federal_election_candidate
|
|
70
|
+
this.federal_election_committee = federal_election_file_expenditure.federal_election_committee
|
|
71
|
+
this.federal_election_f24_file = federal_election_file_expenditure.federal_election_f24_file
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static is(federal_election_file_expenditure : any) : federal_election_file_expenditure is FederalElectionFileExpenditureAux {
|
|
75
|
+
return (
|
|
76
|
+
FederalElectionFileExpenditure.is(federal_election_file_expenditure) &&
|
|
77
|
+
FederalElectionCandidate.is(federal_election_file_expenditure.federal_election_candidate) &&
|
|
78
|
+
FederalElectionCommittee.is(federal_election_file_expenditure.federal_election_committee) &&
|
|
79
|
+
FederalElectionF24File.is(federal_election_file_expenditure.federal_election_f24_file)
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/types/Tweet.ts
CHANGED
|
@@ -2,11 +2,11 @@ export class Tweet {
|
|
|
2
2
|
readonly tweet_id : string
|
|
3
3
|
readonly username : string
|
|
4
4
|
readonly url : string
|
|
5
|
-
readonly
|
|
6
|
-
readonly tweet_content : string
|
|
7
|
-
readonly quote? : string
|
|
5
|
+
readonly publish_time : string
|
|
6
|
+
// readonly tweet_content : string
|
|
7
|
+
// readonly quote? : string
|
|
8
8
|
readonly html : string
|
|
9
|
-
readonly text : string
|
|
9
|
+
// readonly text : string
|
|
10
10
|
|
|
11
11
|
constructor(tweet : Tweet) {
|
|
12
12
|
if (!Tweet.is(tweet)) {
|
|
@@ -15,11 +15,11 @@ export class Tweet {
|
|
|
15
15
|
this.tweet_id = tweet.tweet_id
|
|
16
16
|
this.username = tweet.username
|
|
17
17
|
this.url = tweet.url
|
|
18
|
-
this.
|
|
19
|
-
this.tweet_content = tweet.tweet_content
|
|
20
|
-
this.quote = tweet.quote
|
|
18
|
+
this.publish_time = tweet.publish_time
|
|
19
|
+
// this.tweet_content = tweet.tweet_content
|
|
20
|
+
// this.quote = tweet.quote
|
|
21
21
|
this.html = tweet.html
|
|
22
|
-
this.text = tweet.text
|
|
22
|
+
// this.text = tweet.text
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static is(tweet : any) : tweet is Tweet {
|
|
@@ -28,11 +28,11 @@ export class Tweet {
|
|
|
28
28
|
typeof tweet.tweet_id === "string" &&
|
|
29
29
|
typeof tweet.username === "string" &&
|
|
30
30
|
typeof tweet.url === "string" &&
|
|
31
|
-
typeof tweet.
|
|
32
|
-
typeof tweet.tweet_content === "string" &&
|
|
33
|
-
(tweet.quote === undefined || typeof tweet.quote === "string") &&
|
|
34
|
-
typeof tweet.html === "string"
|
|
35
|
-
(typeof tweet.text === "string")
|
|
31
|
+
typeof tweet.publish_time === "string" &&
|
|
32
|
+
// typeof tweet.tweet_content === "string" &&
|
|
33
|
+
// (tweet.quote === undefined || typeof tweet.quote === "string") &&
|
|
34
|
+
typeof tweet.html === "string"
|
|
35
|
+
// (typeof tweet.text === "string")
|
|
36
36
|
)
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FederalElectionID, is_federal_election_id } from "./FederalElection"
|
|
2
|
+
import { is_long_form_type_id, LongFormTypeID } from "./FormTypeID"
|
|
3
|
+
|
|
4
|
+
export class UserFederalElection {
|
|
5
|
+
readonly user_id : string
|
|
6
|
+
readonly federal_election_id : FederalElectionID
|
|
7
|
+
readonly candidate_display : Record<string, number>
|
|
8
|
+
readonly notify : boolean
|
|
9
|
+
|
|
10
|
+
// readonly [x : string] : any
|
|
11
|
+
|
|
12
|
+
constructor(user_federal_election : UserFederalElection) {
|
|
13
|
+
if (!UserFederalElection.is(user_federal_election)) {
|
|
14
|
+
throw Error("Invalid Input.")
|
|
15
|
+
}
|
|
16
|
+
this.user_id = user_federal_election.user_id
|
|
17
|
+
this.federal_election_id = user_federal_election.federal_election_id
|
|
18
|
+
this.candidate_display = user_federal_election.candidate_display
|
|
19
|
+
this.notify = user_federal_election.notify
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static is(user_federal_election : any) : user_federal_election is UserFederalElection {
|
|
23
|
+
return (
|
|
24
|
+
user_federal_election !== undefined &&
|
|
25
|
+
typeof user_federal_election.user_id === "string" &&
|
|
26
|
+
is_federal_election_id(user_federal_election.federal_election_id) &&
|
|
27
|
+
Object.entries(user_federal_election.candidate_display).every(([key, value]) => (typeof key === "string" && typeof value === "number")) &&
|
|
28
|
+
typeof user_federal_election.notify === "boolean"
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/types/Candidate.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Committee, CommitteeAux } from "./Committee"
|
|
2
|
-
import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
|
|
3
|
-
import { Expenditure, ExpenditureAux } from "./Expenditure"
|
|
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 Candidate {
|
|
32
|
-
readonly candidate_id : string
|
|
33
|
-
readonly fec_name : string
|
|
34
|
-
readonly office_id : OfficeID
|
|
35
|
-
readonly state_id : StateID
|
|
36
|
-
readonly district? : number
|
|
37
|
-
readonly election_id : ElectionID
|
|
38
|
-
readonly party_id? : string
|
|
39
|
-
readonly 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(candidate : Candidate) {
|
|
52
|
-
if (!Candidate.is(candidate)) {
|
|
53
|
-
throw Error("Invalid input.")
|
|
54
|
-
}
|
|
55
|
-
this.candidate_id = candidate.candidate_id
|
|
56
|
-
this.fec_name = candidate.fec_name
|
|
57
|
-
this.office_id = candidate.office_id
|
|
58
|
-
this.state_id = candidate.state_id
|
|
59
|
-
this.district = candidate.district
|
|
60
|
-
this.election_id = candidate.election_id
|
|
61
|
-
this.party_id = candidate.party_id
|
|
62
|
-
this.active = candidate.active
|
|
63
|
-
this.status = candidate.status
|
|
64
|
-
this.federal_election_file_id = candidate.federal_election_file_id
|
|
65
|
-
this.ballotpedia_name = candidate.ballotpedia_name
|
|
66
|
-
this.ballotpedia_url = candidate.ballotpedia_url
|
|
67
|
-
this.ballotpedia_data = candidate.ballotpedia_data
|
|
68
|
-
this.activity_index = candidate.activity_index !== undefined ? new ActivityIndex(candidate.activity_index) : undefined
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static is(candidate : any) : candidate is Candidate {
|
|
72
|
-
return (
|
|
73
|
-
candidate !== undefined &&
|
|
74
|
-
typeof candidate.candidate_id === "string" &&
|
|
75
|
-
typeof candidate.fec_name === "string" &&
|
|
76
|
-
is_office_id(candidate.office_id) &&
|
|
77
|
-
is_state_id(candidate.state_id) &&
|
|
78
|
-
(candidate.district === undefined || typeof candidate.district === "number") &&
|
|
79
|
-
is_election_id(candidate.election_id) &&
|
|
80
|
-
(candidate.party_id === undefined || typeof candidate.party_id === "string") &&
|
|
81
|
-
(candidate.active === undefined || typeof candidate.active === "boolean") &&
|
|
82
|
-
(candidate.status === undefined || typeof candidate.status === "string") &&
|
|
83
|
-
(candidate.federal_election_file_id === undefined || typeof candidate.federal_election_file_id === "number" && !isNaN(candidate.federal_election_file_id)) &&
|
|
84
|
-
(candidate.ballotpedia_name === undefined || typeof candidate.ballotpedia_name === "string") &&
|
|
85
|
-
(candidate.ballotpedia_url === undefined || typeof candidate.ballotpedia_url === "string") &&
|
|
86
|
-
(candidate.ballotpedia_data === undefined || typeof candidate.ballotpedia_data === "object" && Object.keys(candidate.ballotpedia_data).map((key : any) => typeof key === "string")) &&
|
|
87
|
-
(candidate.activity_index === undefined || ActivityIndex.is(candidate.activity_index))
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export class CandidateAux extends Candidate {
|
|
93
|
-
readonly committees : CommitteeAux[]
|
|
94
|
-
readonly federal_election_f3_files : FederalElectionF3File[]
|
|
95
|
-
readonly expenditures : ExpenditureAux[]
|
|
96
|
-
|
|
97
|
-
constructor(candidate : any) {
|
|
98
|
-
if (!CandidateAux.is(candidate)) {
|
|
99
|
-
throw Error("Invalid input.")
|
|
100
|
-
}
|
|
101
|
-
super(candidate)
|
|
102
|
-
this.committees = candidate.committees
|
|
103
|
-
this.federal_election_f3_files = candidate.federal_election_f3_files
|
|
104
|
-
this.expenditures = candidate.expenditures
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static is(candidate : any) : candidate is CandidateAux {
|
|
108
|
-
return (
|
|
109
|
-
Candidate.is(candidate) &&
|
|
110
|
-
Array.isArray(candidate.committees) &&
|
|
111
|
-
candidate.committees.every(CommitteeAux.is) &&
|
|
112
|
-
Array.isArray(candidate.federal_election_f3_files) &&
|
|
113
|
-
candidate.federal_election_f3_files.every(FederalElectionF3File.is) &&
|
|
114
|
-
Array.isArray(candidate.expenditures) &&
|
|
115
|
-
candidate.expenditures.every(ExpenditureAux.is)
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Committee, CommitteeAux } from "./Committee"
|
|
2
|
-
|
|
3
|
-
export class CandidateCommittee {
|
|
4
|
-
readonly candidate_id : string
|
|
5
|
-
readonly committee_id : string
|
|
6
|
-
[x : string] : any
|
|
7
|
-
|
|
8
|
-
constructor(candidate_committee : CandidateCommittee) {
|
|
9
|
-
if (!CandidateCommittee.is(candidate_committee)) {
|
|
10
|
-
throw Error("Invalid input.")
|
|
11
|
-
}
|
|
12
|
-
this.candidate_id = candidate_committee.candidate_id
|
|
13
|
-
this.committee_id = candidate_committee.committee_id
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static is(candidate_committee : any) : candidate_committee is CandidateCommittee {
|
|
17
|
-
return (
|
|
18
|
-
candidate_committee !== undefined &&
|
|
19
|
-
typeof candidate_committee.candidate_id === "string" &&
|
|
20
|
-
typeof candidate_committee.committee_id === "string"
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// export class CandidateCommitteeAux extends CandidateCommittee {
|
|
26
|
-
// readonly committee : CommitteeAux
|
|
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
|
-
// CommitteeAux.is(candidate_committee.committee)
|
|
40
|
-
// )
|
|
41
|
-
// }
|
|
42
|
-
// }
|