elections-types 1.0.38 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/types/Candidate.d.ts +9 -0
- package/dist/src/types/Candidate.js +21 -2
- package/dist/src/types/Committee.d.ts +9 -0
- package/dist/src/types/Committee.js +25 -0
- package/dist/src/types/ElectionsConfig.d.ts +1 -0
- package/dist/src/types/FECIndependentExpenditureReport.d.ts +1 -0
- package/dist/src/types/FECIndependentExpenditureReport.js +77 -0
- package/dist/src/types/FECReport.d.ts +10 -0
- package/dist/src/types/FECReport.js +28 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/Candidate.ts +27 -0
- package/src/types/Committee.ts +31 -0
- package/src/types/ElectionsConfig.ts +1 -0
- package/src/types/FECIndependentExpenditureReport.ts +81 -0
- package/src/types/FECReport.ts +32 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./types/Committee.js";
|
|
|
8
8
|
export * from "./types/Donation.js";
|
|
9
9
|
export * from "./types/Election.js";
|
|
10
10
|
export * from "./types/ElectionsConfig.js";
|
|
11
|
+
export * from "./types/FECReport.js";
|
|
11
12
|
export * from "./types/FormTypeID.js";
|
|
12
13
|
export * from "./types/State.js";
|
|
13
14
|
export * from "./types/Tweet.js";
|
package/dist/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./types/Committee.js";
|
|
|
8
8
|
export * from "./types/Donation.js";
|
|
9
9
|
export * from "./types/Election.js";
|
|
10
10
|
export * from "./types/ElectionsConfig.js";
|
|
11
|
+
export * from "./types/FECReport.js";
|
|
11
12
|
export * from "./types/FormTypeID.js";
|
|
12
13
|
export * from "./types/State.js";
|
|
13
14
|
export * from "./types/Tweet.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Committee } from "./Committee.js";
|
|
1
2
|
import { ElectionID, OfficeID } from "./Election.js";
|
|
3
|
+
import { FECReport } from "./FECReport.js";
|
|
2
4
|
import { StateID } from "./State.js";
|
|
3
5
|
export declare class ActivityIndex {
|
|
4
6
|
readonly news_index: number;
|
|
@@ -26,6 +28,13 @@ export declare class Candidate {
|
|
|
26
28
|
readonly ballotpedia_url?: string;
|
|
27
29
|
readonly ballotpedia_data?: Record<string, any>;
|
|
28
30
|
readonly activity_index?: ActivityIndex;
|
|
31
|
+
[x: string]: any;
|
|
29
32
|
constructor(candidate: any);
|
|
30
33
|
static is(candidate: any): candidate is Candidate;
|
|
31
34
|
}
|
|
35
|
+
export declare class CandidateAux extends Candidate {
|
|
36
|
+
readonly committees: Committee[];
|
|
37
|
+
readonly fec_reports: FECReport[];
|
|
38
|
+
constructor(candidate: any);
|
|
39
|
+
static is(candidate: any): candidate is CandidateAux;
|
|
40
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Committee } from "./Committee.js";
|
|
1
2
|
import { is_election_id, is_office_id } from "./Election.js";
|
|
3
|
+
import { FECReport } from "./FECReport.js";
|
|
2
4
|
import { is_state_id } from "./State.js";
|
|
3
5
|
export class ActivityIndex {
|
|
4
6
|
news_index;
|
|
@@ -38,8 +40,6 @@ export class Candidate {
|
|
|
38
40
|
ballotpedia_url;
|
|
39
41
|
ballotpedia_data;
|
|
40
42
|
activity_index;
|
|
41
|
-
// readonly urls? : string[]
|
|
42
|
-
// readonly previews? : string[]
|
|
43
43
|
constructor(candidate) {
|
|
44
44
|
if (!Candidate.is(candidate)) {
|
|
45
45
|
throw Error("Invalid input.");
|
|
@@ -85,3 +85,22 @@ export class Candidate {
|
|
|
85
85
|
(candidate.activity_index === undefined || ActivityIndex.is(candidate.activity_index)));
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
export class CandidateAux extends Candidate {
|
|
89
|
+
committees;
|
|
90
|
+
fec_reports;
|
|
91
|
+
constructor(candidate) {
|
|
92
|
+
if (!CandidateAux.is(candidate)) {
|
|
93
|
+
throw Error("Invalid input.");
|
|
94
|
+
}
|
|
95
|
+
super(candidate);
|
|
96
|
+
this.committees = candidate.committees;
|
|
97
|
+
this.fec_reports = candidate.fec_reports;
|
|
98
|
+
}
|
|
99
|
+
static is(candidate) {
|
|
100
|
+
return (Candidate.is(candidate) &&
|
|
101
|
+
Array.isArray(candidate.committees) &&
|
|
102
|
+
candidate.committees.every(Committee.is) &&
|
|
103
|
+
Array.isArray(candidate.fec_reports) &&
|
|
104
|
+
candidate.fec_reports.every(FECReport.is));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate.js";
|
|
2
|
+
import { FECReport } from "./FECReport.js";
|
|
1
3
|
export declare const designations: readonly ["P", "A", "U", "J", "D", "B"];
|
|
2
4
|
export type CommitteeDesignation = typeof designations[number];
|
|
3
5
|
export declare function is_committee_designation(designation: any): designation is CommitteeDesignation;
|
|
@@ -19,3 +21,10 @@ export declare class Committee {
|
|
|
19
21
|
constructor(committee: any);
|
|
20
22
|
static is(committee: any): committee is Committee;
|
|
21
23
|
}
|
|
24
|
+
export declare class CommitteeAux extends Committee {
|
|
25
|
+
readonly candidates: Candidate[];
|
|
26
|
+
readonly fec_reports: FECReport[];
|
|
27
|
+
readonly jfp_committees: Committee[];
|
|
28
|
+
constructor(committee: any);
|
|
29
|
+
static is(committee: any): committee is CommitteeAux;
|
|
30
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate.js";
|
|
2
|
+
import { FECReport } from "./FECReport.js";
|
|
1
3
|
export const designations = ["P", "A", "U", "J", "D", "B"];
|
|
2
4
|
export function is_committee_designation(designation) {
|
|
3
5
|
return designations.includes(designation);
|
|
@@ -51,3 +53,26 @@ export class Committee {
|
|
|
51
53
|
(committee.election_ids === undefined || Array.isArray(committee.election_ids) && committee.election_ids.every((committee_id) => typeof committee_id === "string")));
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
export class CommitteeAux extends Committee {
|
|
57
|
+
candidates;
|
|
58
|
+
fec_reports;
|
|
59
|
+
jfp_committees;
|
|
60
|
+
constructor(committee) {
|
|
61
|
+
if (!CommitteeAux.is(committee)) {
|
|
62
|
+
throw Error("Invalid input.");
|
|
63
|
+
}
|
|
64
|
+
super(committee);
|
|
65
|
+
this.candidates = committee.candidates;
|
|
66
|
+
this.fec_reports = committee.fec_reports;
|
|
67
|
+
this.jfp_committees = committee.jfp_committees;
|
|
68
|
+
}
|
|
69
|
+
static is(committee) {
|
|
70
|
+
return (Committee.is(committee) &&
|
|
71
|
+
Array.isArray(committee.candidates) &&
|
|
72
|
+
committee.candidates.every(Candidate.is) &&
|
|
73
|
+
Array.isArray(committee.fec_reports) &&
|
|
74
|
+
committee.fec_reports.every(FECReport.is) &&
|
|
75
|
+
Array.isArray(committee.jfp_committees) &&
|
|
76
|
+
committee.jfp_committees.every(Committee.is));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// export class IndependentExpenditure {
|
|
2
|
+
// readonly transaction_id : string
|
|
3
|
+
// readonly date : string
|
|
4
|
+
// readonly payee : string
|
|
5
|
+
// readonly election_stage : string
|
|
6
|
+
// readonly election_id : string
|
|
7
|
+
// readonly amount : number
|
|
8
|
+
// readonly cumulative_amount : number
|
|
9
|
+
// readonly purpose : string
|
|
10
|
+
// readonly candidate_id : string
|
|
11
|
+
// readonly support : string
|
|
12
|
+
export {};
|
|
13
|
+
// constructor(independent_expenditure : any) {
|
|
14
|
+
// if (!IndependentExpenditure.is(independent_expenditure)) {
|
|
15
|
+
// throw Error("Invalid input.")
|
|
16
|
+
// }
|
|
17
|
+
// this.transaction_id = independent_expenditure.transaction_id
|
|
18
|
+
// this.date = independent_expenditure.date
|
|
19
|
+
// this.payee = independent_expenditure.payee
|
|
20
|
+
// this.election_stage = independent_expenditure.election_stage
|
|
21
|
+
// this.election_id = independent_expenditure.election_id
|
|
22
|
+
// this.amount = independent_expenditure.amount
|
|
23
|
+
// this.cumulative_amount = independent_expenditure.cumulative_amount
|
|
24
|
+
// this.purpose = independent_expenditure.purpose
|
|
25
|
+
// this.candidate_id = independent_expenditure.candidate_id
|
|
26
|
+
// this.support = independent_expenditure.support
|
|
27
|
+
// }
|
|
28
|
+
// static is(independent_expenditure : any) : independent_expenditure is IndependentExpenditure {
|
|
29
|
+
// return (
|
|
30
|
+
// independent_expenditure !== undefined &&
|
|
31
|
+
// typeof independent_expenditure.independent_expenditure === "string" &&
|
|
32
|
+
// typeof independent_expenditure.date === "string" &&
|
|
33
|
+
// typeof independent_expenditure.payee === "string" &&
|
|
34
|
+
// typeof independent_expenditure.election_stage === "string" &&
|
|
35
|
+
// typeof independent_expenditure.election_id === "string" &&
|
|
36
|
+
// typeof independent_expenditure.amount === "number" &&
|
|
37
|
+
// typeof independent_expenditure.cumulative_amount === "number" &&
|
|
38
|
+
// typeof independent_expenditure.purpose === "string" &&
|
|
39
|
+
// typeof independent_expenditure.candidate_id === "string" &&
|
|
40
|
+
// typeof independent_expenditure.support === "string"
|
|
41
|
+
// )
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// export class FECIndependentExpenditureReport {
|
|
45
|
+
// readonly committee_id : string
|
|
46
|
+
// readonly first_file_number : number
|
|
47
|
+
// readonly report_type : string
|
|
48
|
+
// readonly first_report_date : string
|
|
49
|
+
// readonly report_date : string
|
|
50
|
+
// readonly transaction_ids : string[]
|
|
51
|
+
// readonly expenditures_by_transaction_id : Record<string, IndependentExpenditure>
|
|
52
|
+
// constructor(fec_independent_expenditure_report : any) {
|
|
53
|
+
// if (!FECIndependentExpenditureReport.is(fec_independent_expenditure_report)) {
|
|
54
|
+
// throw Error("Invalid input.")
|
|
55
|
+
// }
|
|
56
|
+
// this.committee_id = fec_independent_expenditure_report.committee_id
|
|
57
|
+
// this.first_file_number = fec_independent_expenditure_report.first_file_number
|
|
58
|
+
// this.report_type = fec_independent_expenditure_report.report_type
|
|
59
|
+
// this.first_report_date = fec_independent_expenditure_report.first_report_date
|
|
60
|
+
// this.report_date = fec_independent_expenditure_report.report_date
|
|
61
|
+
// this.transaction_ids = fec_independent_expenditure_report.transaction_ids
|
|
62
|
+
// this.expenditures_by_transaction_id = fec_independent_expenditure_report.expenditures_by_transaction_id
|
|
63
|
+
// }
|
|
64
|
+
// static is(fec_independent_expenditure_report : any) : fec_independent_expenditure_report is FECIndependentExpenditureReport {
|
|
65
|
+
// return (
|
|
66
|
+
// fec_independent_expenditure_report !== undefined &&
|
|
67
|
+
// typeof fec_independent_expenditure_report.committee_id === "string" &&
|
|
68
|
+
// typeof fec_independent_expenditure_report.first_file_number === "number" &&
|
|
69
|
+
// typeof fec_independent_expenditure_report.report_type === "string" &&
|
|
70
|
+
// typeof fec_independent_expenditure_report.first_report_date === "string" &&
|
|
71
|
+
// typeof fec_independent_expenditure_report.report_date === "string" &&
|
|
72
|
+
// Array.isArray(fec_independent_expenditure_report.transaction_ids) && fec_independent_expenditure_report.transaction_ids.map((transaction_id : any) => typeof transaction_id === "string") &&
|
|
73
|
+
// typeof fec_independent_expenditure_report.expenditures_by_transaction_id === "object" &&
|
|
74
|
+
// Object.entries(fec_independent_expenditure_report.expenditures_by_transaction_id).every(([key, value]) => typeof key === "string" && IndependentExpenditure.is(value))
|
|
75
|
+
// )
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class FECReport {
|
|
2
|
+
readonly committee_id: string;
|
|
3
|
+
readonly report_type: string;
|
|
4
|
+
readonly file_number: number;
|
|
5
|
+
readonly cash_on_hand: number;
|
|
6
|
+
readonly cumulative_receipts: number;
|
|
7
|
+
readonly new_receipts: number;
|
|
8
|
+
constructor(fec_report: any);
|
|
9
|
+
static is(fec_report: any): fec_report is FECReport;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class FECReport {
|
|
2
|
+
committee_id;
|
|
3
|
+
report_type;
|
|
4
|
+
file_number;
|
|
5
|
+
cash_on_hand;
|
|
6
|
+
cumulative_receipts;
|
|
7
|
+
new_receipts;
|
|
8
|
+
constructor(fec_report) {
|
|
9
|
+
if (!FECReport.is(fec_report)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.committee_id = fec_report.committee_id;
|
|
13
|
+
this.report_type = fec_report.report_type;
|
|
14
|
+
this.file_number = fec_report.file_number;
|
|
15
|
+
this.cash_on_hand = fec_report.cash_on_hand;
|
|
16
|
+
this.cumulative_receipts = fec_report.cumulative_receipts;
|
|
17
|
+
this.new_receipts = fec_report.new_receipts;
|
|
18
|
+
}
|
|
19
|
+
static is(fec_report) {
|
|
20
|
+
return (fec_report !== undefined &&
|
|
21
|
+
typeof fec_report.committee_id === "string" &&
|
|
22
|
+
typeof fec_report.report_type === "string" &&
|
|
23
|
+
typeof fec_report.file_number === "number" &&
|
|
24
|
+
typeof fec_report.cash_on_hand === "number" &&
|
|
25
|
+
typeof fec_report.cumulative_receipts === "number" &&
|
|
26
|
+
typeof fec_report.new_receipts === "number");
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./types/Committee"
|
|
|
8
8
|
export * from "./types/Donation"
|
|
9
9
|
export * from "./types/Election"
|
|
10
10
|
export * from "./types/ElectionsConfig"
|
|
11
|
+
export * from "./types/FECReport"
|
|
11
12
|
export * from "./types/FormTypeID"
|
|
12
13
|
export * from "./types/State"
|
|
13
14
|
export * from "./types/Tweet"
|
package/src/types/Candidate.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Committee } from "./Committee"
|
|
1
2
|
import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
|
|
3
|
+
import { FECReport } from "./FECReport"
|
|
2
4
|
import { is_state_id, StateID } from "./State"
|
|
3
5
|
|
|
4
6
|
export class ActivityIndex {
|
|
@@ -46,6 +48,7 @@ export class Candidate {
|
|
|
46
48
|
readonly activity_index? : ActivityIndex
|
|
47
49
|
// readonly urls? : string[]
|
|
48
50
|
// readonly previews? : string[]
|
|
51
|
+
[x : string] : any
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
constructor(candidate : any) {
|
|
@@ -95,4 +98,28 @@ export class Candidate {
|
|
|
95
98
|
(candidate.activity_index === undefined || ActivityIndex.is(candidate.activity_index))
|
|
96
99
|
)
|
|
97
100
|
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class CandidateAux extends Candidate {
|
|
104
|
+
readonly committees : Committee[]
|
|
105
|
+
readonly fec_reports : FECReport[]
|
|
106
|
+
|
|
107
|
+
constructor(candidate : any) {
|
|
108
|
+
if (!CandidateAux.is(candidate)) {
|
|
109
|
+
throw Error("Invalid input.")
|
|
110
|
+
}
|
|
111
|
+
super(candidate)
|
|
112
|
+
this.committees = candidate.committees
|
|
113
|
+
this.fec_reports = candidate.fec_reports
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static is(candidate : any) : candidate is CandidateAux {
|
|
117
|
+
return (
|
|
118
|
+
Candidate.is(candidate) &&
|
|
119
|
+
Array.isArray(candidate.committees) &&
|
|
120
|
+
candidate.committees.every(Committee.is) &&
|
|
121
|
+
Array.isArray(candidate.fec_reports) &&
|
|
122
|
+
candidate.fec_reports.every(FECReport.is)
|
|
123
|
+
)
|
|
124
|
+
}
|
|
98
125
|
}
|
package/src/types/Committee.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Candidate } from "./Candidate"
|
|
2
|
+
import { FECReport } from "./FECReport"
|
|
3
|
+
|
|
1
4
|
export const designations = ["P", "A", "U", "J", "D", "B"] as const
|
|
2
5
|
|
|
3
6
|
export type CommitteeDesignation = typeof designations[number]
|
|
@@ -59,4 +62,32 @@ export class Committee {
|
|
|
59
62
|
(committee.election_ids === undefined || Array.isArray(committee.election_ids) && committee.election_ids.every((committee_id : any) => typeof committee_id === "string"))
|
|
60
63
|
)
|
|
61
64
|
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class CommitteeAux extends Committee {
|
|
68
|
+
readonly candidates : Candidate[]
|
|
69
|
+
readonly fec_reports : FECReport[]
|
|
70
|
+
readonly jfp_committees : Committee[]
|
|
71
|
+
|
|
72
|
+
constructor(committee : any) {
|
|
73
|
+
if (!CommitteeAux.is(committee)) {
|
|
74
|
+
throw Error("Invalid input.")
|
|
75
|
+
}
|
|
76
|
+
super(committee)
|
|
77
|
+
this.candidates = committee.candidates
|
|
78
|
+
this.fec_reports = committee.fec_reports
|
|
79
|
+
this.jfp_committees = committee.jfp_committees
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static is(committee : any) : committee is CommitteeAux {
|
|
83
|
+
return (
|
|
84
|
+
Committee.is(committee) &&
|
|
85
|
+
Array.isArray(committee.candidates) &&
|
|
86
|
+
committee.candidates.every(Candidate.is) &&
|
|
87
|
+
Array.isArray(committee.fec_reports) &&
|
|
88
|
+
committee.fec_reports.every(FECReport.is) &&
|
|
89
|
+
Array.isArray(committee.jfp_committees) &&
|
|
90
|
+
committee.jfp_committees.every(Committee.is)
|
|
91
|
+
)
|
|
92
|
+
}
|
|
62
93
|
}
|
|
@@ -29,6 +29,7 @@ export interface ElectionsConfig extends ElectionsUtilsConfig {
|
|
|
29
29
|
dynamodb_candidate_tweets : string,
|
|
30
30
|
dynamodb_videos : string,
|
|
31
31
|
dynamodb_candidate_videos : string,
|
|
32
|
+
dynamodb_fec_reports : string,
|
|
32
33
|
dynamodb_donations : string,
|
|
33
34
|
s3_bucket : string
|
|
34
35
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// export class IndependentExpenditure {
|
|
2
|
+
// readonly transaction_id : string
|
|
3
|
+
// readonly date : string
|
|
4
|
+
// readonly payee : string
|
|
5
|
+
// readonly election_stage : string
|
|
6
|
+
// readonly election_id : string
|
|
7
|
+
// readonly amount : number
|
|
8
|
+
// readonly cumulative_amount : number
|
|
9
|
+
// readonly purpose : string
|
|
10
|
+
// readonly candidate_id : string
|
|
11
|
+
// readonly support : string
|
|
12
|
+
|
|
13
|
+
// constructor(independent_expenditure : any) {
|
|
14
|
+
// if (!IndependentExpenditure.is(independent_expenditure)) {
|
|
15
|
+
// throw Error("Invalid input.")
|
|
16
|
+
// }
|
|
17
|
+
// this.transaction_id = independent_expenditure.transaction_id
|
|
18
|
+
// this.date = independent_expenditure.date
|
|
19
|
+
// this.payee = independent_expenditure.payee
|
|
20
|
+
// this.election_stage = independent_expenditure.election_stage
|
|
21
|
+
// this.election_id = independent_expenditure.election_id
|
|
22
|
+
// this.amount = independent_expenditure.amount
|
|
23
|
+
// this.cumulative_amount = independent_expenditure.cumulative_amount
|
|
24
|
+
// this.purpose = independent_expenditure.purpose
|
|
25
|
+
// this.candidate_id = independent_expenditure.candidate_id
|
|
26
|
+
// this.support = independent_expenditure.support
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
// static is(independent_expenditure : any) : independent_expenditure is IndependentExpenditure {
|
|
30
|
+
// return (
|
|
31
|
+
// independent_expenditure !== undefined &&
|
|
32
|
+
// typeof independent_expenditure.independent_expenditure === "string" &&
|
|
33
|
+
// typeof independent_expenditure.date === "string" &&
|
|
34
|
+
// typeof independent_expenditure.payee === "string" &&
|
|
35
|
+
// typeof independent_expenditure.election_stage === "string" &&
|
|
36
|
+
// typeof independent_expenditure.election_id === "string" &&
|
|
37
|
+
// typeof independent_expenditure.amount === "number" &&
|
|
38
|
+
// typeof independent_expenditure.cumulative_amount === "number" &&
|
|
39
|
+
// typeof independent_expenditure.purpose === "string" &&
|
|
40
|
+
// typeof independent_expenditure.candidate_id === "string" &&
|
|
41
|
+
// typeof independent_expenditure.support === "string"
|
|
42
|
+
// )
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
// export class FECIndependentExpenditureReport {
|
|
47
|
+
// readonly committee_id : string
|
|
48
|
+
// readonly first_file_number : number
|
|
49
|
+
// readonly report_type : string
|
|
50
|
+
// readonly first_report_date : string
|
|
51
|
+
// readonly report_date : string
|
|
52
|
+
// readonly transaction_ids : string[]
|
|
53
|
+
// readonly expenditures_by_transaction_id : Record<string, IndependentExpenditure>
|
|
54
|
+
|
|
55
|
+
// constructor(fec_independent_expenditure_report : any) {
|
|
56
|
+
// if (!FECIndependentExpenditureReport.is(fec_independent_expenditure_report)) {
|
|
57
|
+
// throw Error("Invalid input.")
|
|
58
|
+
// }
|
|
59
|
+
// this.committee_id = fec_independent_expenditure_report.committee_id
|
|
60
|
+
// this.first_file_number = fec_independent_expenditure_report.first_file_number
|
|
61
|
+
// this.report_type = fec_independent_expenditure_report.report_type
|
|
62
|
+
// this.first_report_date = fec_independent_expenditure_report.first_report_date
|
|
63
|
+
// this.report_date = fec_independent_expenditure_report.report_date
|
|
64
|
+
// this.transaction_ids = fec_independent_expenditure_report.transaction_ids
|
|
65
|
+
// this.expenditures_by_transaction_id = fec_independent_expenditure_report.expenditures_by_transaction_id
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// static is(fec_independent_expenditure_report : any) : fec_independent_expenditure_report is FECIndependentExpenditureReport {
|
|
69
|
+
// return (
|
|
70
|
+
// fec_independent_expenditure_report !== undefined &&
|
|
71
|
+
// typeof fec_independent_expenditure_report.committee_id === "string" &&
|
|
72
|
+
// typeof fec_independent_expenditure_report.first_file_number === "number" &&
|
|
73
|
+
// typeof fec_independent_expenditure_report.report_type === "string" &&
|
|
74
|
+
// typeof fec_independent_expenditure_report.first_report_date === "string" &&
|
|
75
|
+
// typeof fec_independent_expenditure_report.report_date === "string" &&
|
|
76
|
+
// Array.isArray(fec_independent_expenditure_report.transaction_ids) && fec_independent_expenditure_report.transaction_ids.map((transaction_id : any) => typeof transaction_id === "string") &&
|
|
77
|
+
// typeof fec_independent_expenditure_report.expenditures_by_transaction_id === "object" &&
|
|
78
|
+
// Object.entries(fec_independent_expenditure_report.expenditures_by_transaction_id).every(([key, value]) => typeof key === "string" && IndependentExpenditure.is(value))
|
|
79
|
+
// )
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class FECReport {
|
|
2
|
+
readonly committee_id : string
|
|
3
|
+
readonly report_type : string
|
|
4
|
+
readonly file_number : number
|
|
5
|
+
readonly cash_on_hand : number
|
|
6
|
+
readonly cumulative_receipts : number
|
|
7
|
+
readonly new_receipts : number
|
|
8
|
+
|
|
9
|
+
constructor(fec_report : any) {
|
|
10
|
+
if (!FECReport.is(fec_report)) {
|
|
11
|
+
throw Error("Invalid input.")
|
|
12
|
+
}
|
|
13
|
+
this.committee_id = fec_report.committee_id
|
|
14
|
+
this.report_type = fec_report.report_type
|
|
15
|
+
this.file_number = fec_report.file_number
|
|
16
|
+
this.cash_on_hand = fec_report.cash_on_hand
|
|
17
|
+
this.cumulative_receipts = fec_report.cumulative_receipts
|
|
18
|
+
this.new_receipts = fec_report.new_receipts
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static is(fec_report : any) : fec_report is FECReport {
|
|
22
|
+
return (
|
|
23
|
+
fec_report !== undefined &&
|
|
24
|
+
typeof fec_report.committee_id === "string" &&
|
|
25
|
+
typeof fec_report.report_type === "string" &&
|
|
26
|
+
typeof fec_report.file_number === "number" &&
|
|
27
|
+
typeof fec_report.cash_on_hand === "number" &&
|
|
28
|
+
typeof fec_report.cumulative_receipts === "number" &&
|
|
29
|
+
typeof fec_report.new_receipts === "number"
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|