elections-types 1.0.61 → 1.0.63

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.
@@ -8,6 +8,11 @@ export * from "./types/Committee.js";
8
8
  export * from "./types/Election.js";
9
9
  export * from "./types/ElectionsConfig.js";
10
10
  export * from "./types/FederalDonation.js";
11
+ export * from "./types/FECFile.js";
12
+ export * from "./types/FECF1File.js";
13
+ export * from "./types/FECF2File.js";
14
+ export * from "./types/FECF3File.js";
15
+ export * from "./types/FECF24File.js";
11
16
  export * from "./types/FECReport.js";
12
17
  export * from "./types/FormTypeID.js";
13
18
  export * from "./types/State.js";
package/dist/src/index.js CHANGED
@@ -8,6 +8,11 @@ export * from "./types/Committee.js";
8
8
  export * from "./types/Election.js";
9
9
  export * from "./types/ElectionsConfig.js";
10
10
  export * from "./types/FederalDonation.js";
11
+ export * from "./types/FECFile.js";
12
+ export * from "./types/FECF1File.js";
13
+ export * from "./types/FECF2File.js";
14
+ export * from "./types/FECF3File.js";
15
+ export * from "./types/FECF24File.js";
11
16
  export * from "./types/FECReport.js";
12
17
  export * from "./types/FormTypeID.js";
13
18
  export * from "./types/State.js";
@@ -1,6 +1,6 @@
1
1
  import { CommitteeAux } from "./Committee.js";
2
2
  import { ElectionID, OfficeID } from "./Election.js";
3
- import { FECReport } from "./FECReport.js";
3
+ import { FECF3File } from "./FECF3File.js";
4
4
  import { StateID } from "./State.js";
5
5
  export declare class ActivityIndex {
6
6
  readonly news_index: number;
@@ -31,7 +31,7 @@ export declare class Candidate {
31
31
  }
32
32
  export declare class CandidateAux extends Candidate {
33
33
  readonly committees: CommitteeAux[];
34
- readonly fec_reports: FECReport[];
34
+ readonly fec_f3_files: FECF3File[];
35
35
  constructor(candidate: any);
36
36
  static is(candidate: any): candidate is CandidateAux;
37
37
  }
@@ -1,6 +1,6 @@
1
1
  import { CommitteeAux } from "./Committee.js";
2
2
  import { is_election_id, is_office_id } from "./Election.js";
3
- import { FECReport } from "./FECReport.js";
3
+ import { FECF3File } from "./FECF3File.js";
4
4
  import { is_state_id } from "./State.js";
5
5
  export class ActivityIndex {
6
6
  news_index;
@@ -78,21 +78,20 @@ export class Candidate {
78
78
  }
79
79
  export class CandidateAux extends Candidate {
80
80
  committees;
81
- fec_reports;
82
- // readonly fec_f3_files : FEC
81
+ fec_f3_files;
83
82
  constructor(candidate) {
84
83
  if (!CandidateAux.is(candidate)) {
85
84
  throw Error("Invalid input.");
86
85
  }
87
86
  super(candidate);
88
87
  this.committees = candidate.committees;
89
- this.fec_reports = candidate.fec_reports;
88
+ this.fec_f3_files = candidate.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file));
90
89
  }
91
90
  static is(candidate) {
92
91
  return (Candidate.is(candidate) &&
93
92
  Array.isArray(candidate.committees) &&
94
93
  candidate.committees.every(CommitteeAux.is) &&
95
- Array.isArray(candidate.fec_reports) &&
96
- candidate.fec_reports.every(FECReport.is));
94
+ Array.isArray(candidate.fec_f3_files) &&
95
+ candidate.fec_f3_files.every(FECF3File.is));
97
96
  }
98
97
  }
@@ -0,0 +1,18 @@
1
+ import { CommitteeDesignation } from "./Committee.js";
2
+ import { ElectionID } from "./Election.js";
3
+ import { FECFile } from "./FECFile.js";
4
+ export declare class FECF1File extends FECFile {
5
+ readonly committee_id: string;
6
+ readonly name: string;
7
+ readonly url?: string;
8
+ readonly report_date: string;
9
+ readonly designation: CommitteeDesignation;
10
+ readonly election_id?: ElectionID;
11
+ readonly candidate_id?: string;
12
+ readonly jfp_committee_ids?: string[];
13
+ readonly jfr_committee_ids: string[];
14
+ readonly aff_committee_ids: string[];
15
+ readonly sponsor_candidate_ids?: string[];
16
+ constructor(fec_file: any);
17
+ static is(fec_file: any): fec_file is FECF1File;
18
+ }
@@ -0,0 +1,48 @@
1
+ import { is_committee_designation } from "./Committee.js";
2
+ import { is_election_id } from "./Election.js";
3
+ import { FECFile } from "./FECFile.js";
4
+ export class FECF1File extends FECFile {
5
+ committee_id;
6
+ name;
7
+ url;
8
+ report_date;
9
+ designation;
10
+ election_id;
11
+ candidate_id;
12
+ jfp_committee_ids;
13
+ jfr_committee_ids;
14
+ aff_committee_ids;
15
+ sponsor_candidate_ids;
16
+ constructor(fec_file) {
17
+ if (!FECF1File.is(fec_file)) {
18
+ throw Error("Invalid input.");
19
+ }
20
+ super(fec_file);
21
+ this.committee_id = fec_file.committee_id;
22
+ this.name = fec_file.name;
23
+ this.url = fec_file.url;
24
+ this.report_date = fec_file.report_date;
25
+ this.designation = fec_file.designation;
26
+ this.election_id = fec_file.election_id;
27
+ this.candidate_id = fec_file.candidate_id;
28
+ this.jfp_committee_ids = fec_file.jfp_committee_ids;
29
+ this.jfr_committee_ids = fec_file.jfr_committee_ids;
30
+ this.aff_committee_ids = fec_file.aff_committee_ids;
31
+ this.sponsor_candidate_ids = fec_file.sponsor_candidate_ids;
32
+ }
33
+ static is(fec_file) {
34
+ return (FECFile.is(fec_file) &&
35
+ fec_file.form_type_id === "F1" &&
36
+ typeof fec_file.committee_id === "string" &&
37
+ typeof fec_file.name === "string" &&
38
+ (fec_file.url === undefined || typeof fec_file.url === "string") &&
39
+ typeof fec_file.report_date === "string" &&
40
+ is_committee_designation(fec_file.designation) &&
41
+ (fec_file.election_id === undefined || is_election_id(fec_file.election_id)) &&
42
+ (fec_file.candidate_id === undefined || typeof fec_file.election_id === "string") &&
43
+ (fec_file.jfp_committee_ids === undefined || Array.isArray(fec_file.jfp_committee_ids) && fec_file.jfp_committee_ids.every((committee_id) => typeof committee_id === "string")) &&
44
+ (Array.isArray(fec_file.jfr_committee_ids) && fec_file.jfr_committee_ids.every((committee_id) => typeof committee_id === "string")) &&
45
+ (Array.isArray(fec_file.aff_committee_ids) && fec_file.aff_committee_ids.every((committee_id) => typeof committee_id === "string")) &&
46
+ (fec_file.sponsor_candidate_ids === undefined || Array.isArray(fec_file.sponsor_candidate_ids) && fec_file.sponsor_candidate_ids.every((committee_id) => typeof committee_id === "string")));
47
+ }
48
+ }
@@ -0,0 +1,27 @@
1
+ import { ElectionID } from "./Election.js";
2
+ import { FECFile } from "./FECFile.js";
3
+ export declare class Expenditure {
4
+ readonly fec_file_id: number;
5
+ readonly expenditure_id: string;
6
+ readonly date: string;
7
+ readonly payee: string;
8
+ readonly election_stage: string;
9
+ readonly election_id: ElectionID;
10
+ readonly candidate_id: string;
11
+ readonly amount: number;
12
+ readonly cumulative_amount: number;
13
+ readonly purpose: string;
14
+ readonly is_support: boolean;
15
+ constructor(expenditure: any);
16
+ static is(expenditure: any): expenditure is Expenditure;
17
+ }
18
+ export declare class FECF24File extends FECFile {
19
+ readonly committee_id: string;
20
+ readonly first_fec_file_id: number;
21
+ readonly report_type: string;
22
+ readonly first_report_date: string;
23
+ readonly report_date: string;
24
+ readonly expenditures: Expenditure[];
25
+ constructor(fec_file: any);
26
+ static is(fec_file: any): fec_file is FECF24File;
27
+ }
@@ -0,0 +1,75 @@
1
+ import { is_election_id } from "./Election.js";
2
+ import { FECFile } from "./FECFile.js";
3
+ export class Expenditure {
4
+ fec_file_id;
5
+ expenditure_id;
6
+ date;
7
+ payee;
8
+ election_stage;
9
+ election_id;
10
+ candidate_id;
11
+ amount;
12
+ cumulative_amount;
13
+ purpose;
14
+ is_support;
15
+ constructor(expenditure) {
16
+ if (!Expenditure.is(expenditure)) {
17
+ throw Error("Invalid input.");
18
+ }
19
+ this.fec_file_id = expenditure.fec_file_id;
20
+ this.expenditure_id = expenditure.expenditure_id;
21
+ this.date = expenditure.date;
22
+ this.payee = expenditure.payee;
23
+ this.election_stage = expenditure.election_stage;
24
+ this.election_id = expenditure.election_id;
25
+ this.candidate_id = expenditure.candidate_id;
26
+ this.amount = expenditure.amount;
27
+ this.cumulative_amount = expenditure.cumulative_amount;
28
+ this.purpose = expenditure.purpose;
29
+ this.is_support = expenditure.is_support;
30
+ }
31
+ static is(expenditure) {
32
+ return (expenditure !== undefined &&
33
+ typeof expenditure.fec_file_id === "number" &&
34
+ typeof expenditure.expenditure_id === "string" &&
35
+ typeof expenditure.date === "string" &&
36
+ typeof expenditure.payee === "string" &&
37
+ typeof expenditure.election_stage === "string" &&
38
+ is_election_id(expenditure.election_id) &&
39
+ typeof expenditure.candidate_id === "string" &&
40
+ typeof expenditure.amount === "number" &&
41
+ typeof expenditure.cumulative_amount === "number" &&
42
+ typeof expenditure.purpose === "string" &&
43
+ typeof expenditure.is_support === "boolean");
44
+ }
45
+ }
46
+ export class FECF24File extends FECFile {
47
+ committee_id;
48
+ first_fec_file_id;
49
+ report_type;
50
+ first_report_date;
51
+ report_date;
52
+ expenditures;
53
+ constructor(fec_file) {
54
+ if (!FECF24File.is(fec_file)) {
55
+ throw Error("Invalid input.");
56
+ }
57
+ super(fec_file);
58
+ this.committee_id = fec_file.committee_id;
59
+ this.first_fec_file_id = fec_file.first_fec_file_id;
60
+ this.report_type = fec_file.report_type;
61
+ this.first_report_date = fec_file.first_report_date;
62
+ this.report_date = fec_file.report_date;
63
+ this.expenditures = fec_file.expenditures;
64
+ }
65
+ static is(fec_file) {
66
+ return (FECFile.is(fec_file) &&
67
+ fec_file.form_type_id === "F24" &&
68
+ typeof fec_file.committee_id === "string" &&
69
+ typeof fec_file.first_fec_file_id === "number" &&
70
+ typeof fec_file.report_type === "string" &&
71
+ typeof fec_file.first_report_date === "string" &&
72
+ typeof fec_file.report_date === "string" &&
73
+ Array.isArray(fec_file.expenditures) && fec_file.expenditures.every(Expenditure.is));
74
+ }
75
+ }
@@ -0,0 +1,15 @@
1
+ import { ElectionID, OfficeID } from "./Election.js";
2
+ import { FECFile } from "./FECFile.js";
3
+ import { StateID } from "./State.js";
4
+ export declare class FECF2File extends FECFile {
5
+ readonly candidate_id: string;
6
+ readonly fec_name: string;
7
+ readonly office_id: OfficeID;
8
+ readonly state_id: StateID;
9
+ readonly district?: number;
10
+ readonly election_id: ElectionID;
11
+ readonly party_id?: string;
12
+ readonly report_date: string;
13
+ constructor(fec_file: any);
14
+ static is(fec_file: any): fec_file is FECF2File;
15
+ }
@@ -0,0 +1,39 @@
1
+ import { is_election_id, is_office_id } from "./Election.js";
2
+ import { FECFile } from "./FECFile.js";
3
+ import { is_state_id } from "./State.js";
4
+ export class FECF2File extends FECFile {
5
+ candidate_id;
6
+ fec_name;
7
+ office_id;
8
+ state_id;
9
+ district;
10
+ election_id;
11
+ party_id;
12
+ report_date;
13
+ constructor(fec_file) {
14
+ if (!FECF2File.is(fec_file)) {
15
+ throw Error("Invalid input.");
16
+ }
17
+ super(fec_file);
18
+ this.candidate_id = fec_file.candidate_id;
19
+ this.fec_name = fec_file.fec_name;
20
+ this.office_id = fec_file.office_id;
21
+ this.state_id = fec_file.state_id;
22
+ this.district = fec_file.district;
23
+ this.election_id = fec_file.election_id;
24
+ this.party_id = fec_file.party_id;
25
+ this.report_date = fec_file.report_date;
26
+ }
27
+ static is(fec_file) {
28
+ return (FECFile.is(fec_file) &&
29
+ fec_file.form_type_id === "F2" &&
30
+ typeof fec_file.candidate_id === "string" &&
31
+ typeof fec_file.fec_name === "string" &&
32
+ is_office_id(fec_file.office_id) &&
33
+ is_state_id(fec_file.state_id) &&
34
+ (fec_file.district === undefined || typeof fec_file.district === "number") &&
35
+ is_election_id(fec_file.election_id) &&
36
+ (fec_file.party_id === undefined || typeof fec_file.party_id === "string") &&
37
+ typeof fec_file.report_date === "string");
38
+ }
39
+ }
@@ -0,0 +1,13 @@
1
+ import { FECFile } from "./FECFile.js";
2
+ export declare class FECF3File extends FECFile {
3
+ readonly committee_id: string;
4
+ readonly period_id: string;
5
+ readonly period_start_date: string;
6
+ readonly period_end_date: string;
7
+ readonly report_date: string;
8
+ readonly cash_on_hand: number;
9
+ readonly cumulative_receipts: number;
10
+ readonly new_receipts: number;
11
+ constructor(fec_file: any);
12
+ static is(fec_file: any): fec_file is FECF3File;
13
+ }
@@ -0,0 +1,37 @@
1
+ import { FECFile } from "./FECFile.js";
2
+ export class FECF3File extends FECFile {
3
+ committee_id;
4
+ period_id;
5
+ period_start_date;
6
+ period_end_date;
7
+ report_date;
8
+ cash_on_hand;
9
+ cumulative_receipts;
10
+ new_receipts;
11
+ constructor(fec_file) {
12
+ if (!FECF3File.is(fec_file)) {
13
+ throw Error("Invalid input.");
14
+ }
15
+ super(fec_file);
16
+ this.committee_id = fec_file.committee_id;
17
+ this.period_id = fec_file.period_id;
18
+ this.period_start_date = fec_file.period_start_date;
19
+ this.period_end_date = fec_file.period_end_date;
20
+ this.report_date = fec_file.report_date;
21
+ this.cash_on_hand = fec_file.cash_on_hand;
22
+ this.cumulative_receipts = fec_file.cumulative_receipts;
23
+ this.new_receipts = fec_file.new_receipts;
24
+ }
25
+ static is(fec_file) {
26
+ return (FECFile.is(fec_file) &&
27
+ fec_file.form_type_id === "F3" &&
28
+ typeof fec_file.committee_id === "string" &&
29
+ typeof fec_file.period_id === "string" &&
30
+ typeof fec_file.period_start_date === "string" &&
31
+ typeof fec_file.period_end_date === "string" &&
32
+ typeof fec_file.report_date === "string" &&
33
+ typeof fec_file.cash_on_hand === "number" &&
34
+ typeof fec_file.cumulative_receipts === "number" &&
35
+ typeof fec_file.new_receipts === "number");
36
+ }
37
+ }
@@ -0,0 +1,11 @@
1
+ import { AmendmentTypeID, FormTypeID, LongFormTypeID } from "./FormTypeID.js";
2
+ export declare class FECFile {
3
+ readonly fec_file_id: number;
4
+ readonly form_type_id: FormTypeID;
5
+ readonly amendment_type_id: AmendmentTypeID;
6
+ readonly long_form_type_id: LongFormTypeID;
7
+ readonly s3_filename: string;
8
+ [x: string]: any;
9
+ constructor(fec_file: any);
10
+ static is(fec_file: any): fec_file is FECFile;
11
+ }
@@ -0,0 +1,26 @@
1
+ import { is_amendment_type_id, is_form_type_id, is_long_form_type_id } from "./FormTypeID.js";
2
+ export class FECFile {
3
+ fec_file_id;
4
+ form_type_id;
5
+ amendment_type_id;
6
+ long_form_type_id;
7
+ s3_filename;
8
+ constructor(fec_file) {
9
+ if (!FECFile.is(fec_file)) {
10
+ throw Error("Invalid input.");
11
+ }
12
+ this.fec_file_id = fec_file.fec_file_id;
13
+ this.form_type_id = fec_file.form_type_id;
14
+ this.amendment_type_id = fec_file.amendment_type_id;
15
+ this.long_form_type_id = fec_file.long_form_type_id;
16
+ this.s3_filename = fec_file.s3_filename;
17
+ }
18
+ static is(fec_file) {
19
+ return (fec_file !== undefined &&
20
+ typeof fec_file.fec_file_id === "number" &&
21
+ is_form_type_id(fec_file.form_type_id) &&
22
+ is_amendment_type_id(fec_file.amendment_type_id) &&
23
+ is_long_form_type_id(fec_file.long_form_type_id) &&
24
+ (fec_file.s3_filename === undefined || typeof fec_file.s3_filename === "string"));
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elections-types",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/index.ts CHANGED
@@ -8,6 +8,11 @@ export * from "./types/Committee"
8
8
  export * from "./types/Election"
9
9
  export * from "./types/ElectionsConfig"
10
10
  export * from "./types/FederalDonation"
11
+ export * from "./types/FECFile"
12
+ export * from "./types/FECF1File"
13
+ export * from "./types/FECF2File"
14
+ export * from "./types/FECF3File"
15
+ export * from "./types/FECF24File"
11
16
  export * from "./types/FECReport"
12
17
  export * from "./types/FormTypeID"
13
18
  export * from "./types/State"
@@ -1,5 +1,7 @@
1
1
  import { Committee, CommitteeAux } from "./Committee"
2
2
  import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
3
+ import { FECF24File } from "./FECF24File"
4
+ import { FECF3File } from "./FECF3File"
3
5
  import { FECReport } from "./FECReport"
4
6
  import { is_state_id, StateID } from "./State"
5
7
 
@@ -93,8 +95,7 @@ export class Candidate {
93
95
 
94
96
  export class CandidateAux extends Candidate {
95
97
  readonly committees : CommitteeAux[]
96
- readonly fec_reports : FECReport[]
97
- // readonly fec_f3_files : FEC
98
+ readonly fec_f3_files : FECF3File[]
98
99
 
99
100
  constructor(candidate : any) {
100
101
  if (!CandidateAux.is(candidate)) {
@@ -102,7 +103,7 @@ export class CandidateAux extends Candidate {
102
103
  }
103
104
  super(candidate)
104
105
  this.committees = candidate.committees
105
- this.fec_reports = candidate.fec_reports
106
+ this.fec_f3_files = candidate.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file))
106
107
  }
107
108
 
108
109
  static is(candidate : any) : candidate is CandidateAux {
@@ -110,8 +111,8 @@ export class CandidateAux extends Candidate {
110
111
  Candidate.is(candidate) &&
111
112
  Array.isArray(candidate.committees) &&
112
113
  candidate.committees.every(CommitteeAux.is) &&
113
- Array.isArray(candidate.fec_reports) &&
114
- candidate.fec_reports.every(FECReport.is)
114
+ Array.isArray(candidate.fec_f3_files) &&
115
+ candidate.fec_f3_files.every(FECF3File.is)
115
116
  )
116
117
  }
117
118
  }
@@ -0,0 +1,53 @@
1
+ import { CommitteeDesignation, is_committee_designation } from "./Committee"
2
+ import { ElectionID, is_election_id } from "./Election"
3
+ import { FECFile } from "./FECFile"
4
+
5
+ export class FECF1File extends FECFile {
6
+ readonly committee_id : string
7
+ readonly name : string
8
+ readonly url? : string
9
+ readonly report_date : string
10
+ readonly designation : CommitteeDesignation
11
+ readonly election_id? : ElectionID
12
+ readonly candidate_id? : string
13
+ readonly jfp_committee_ids? : string[]
14
+ readonly jfr_committee_ids : string[]
15
+ readonly aff_committee_ids : string[]
16
+ readonly sponsor_candidate_ids? : string[]
17
+
18
+ constructor(fec_file : any) {
19
+ if (!FECF1File.is(fec_file)) {
20
+ throw Error("Invalid input.")
21
+ }
22
+ super(fec_file)
23
+ this.committee_id = fec_file.committee_id
24
+ this.name = fec_file.name
25
+ this.url = fec_file.url
26
+ this.report_date = fec_file.report_date
27
+ this.designation = fec_file.designation
28
+ this.election_id = fec_file.election_id
29
+ this.candidate_id = fec_file.candidate_id
30
+ this.jfp_committee_ids = fec_file.jfp_committee_ids
31
+ this.jfr_committee_ids = fec_file.jfr_committee_ids
32
+ this.aff_committee_ids = fec_file.aff_committee_ids
33
+ this.sponsor_candidate_ids = fec_file.sponsor_candidate_ids
34
+ }
35
+
36
+ static is(fec_file : any) : fec_file is FECF1File {
37
+ return (
38
+ FECFile.is(fec_file) &&
39
+ fec_file.form_type_id === "F1" &&
40
+ typeof fec_file.committee_id === "string" &&
41
+ typeof fec_file.name === "string" &&
42
+ (fec_file.url === undefined || typeof fec_file.url === "string") &&
43
+ typeof fec_file.report_date === "string" &&
44
+ is_committee_designation(fec_file.designation) &&
45
+ (fec_file.election_id === undefined || is_election_id(fec_file.election_id)) &&
46
+ (fec_file.candidate_id === undefined || typeof fec_file.election_id === "string") &&
47
+ (fec_file.jfp_committee_ids === undefined || Array.isArray(fec_file.jfp_committee_ids) && fec_file.jfp_committee_ids.every((committee_id : any) => typeof committee_id === "string")) &&
48
+ (Array.isArray(fec_file.jfr_committee_ids) && fec_file.jfr_committee_ids.every((committee_id : any) => typeof committee_id === "string")) &&
49
+ (Array.isArray(fec_file.aff_committee_ids) && fec_file.aff_committee_ids.every((committee_id : any) => typeof committee_id === "string")) &&
50
+ (fec_file.sponsor_candidate_ids === undefined || Array.isArray(fec_file.sponsor_candidate_ids) && fec_file.sponsor_candidate_ids.every((committee_id : any) => typeof committee_id === "string"))
51
+ )
52
+ }
53
+ }
@@ -0,0 +1,86 @@
1
+ import { ElectionID, is_election_id } from "./Election"
2
+ import { FECFile } from "./FECFile"
3
+
4
+ export class Expenditure {
5
+ readonly fec_file_id : number
6
+ readonly expenditure_id : string
7
+ readonly date : string
8
+ readonly payee : string
9
+ readonly election_stage : string
10
+ readonly election_id : ElectionID
11
+ readonly candidate_id : string
12
+ readonly amount : number
13
+ readonly cumulative_amount : number
14
+ readonly purpose : string
15
+ readonly is_support : boolean
16
+
17
+ constructor(expenditure : any) {
18
+ if (!Expenditure.is(expenditure)) {
19
+ throw Error("Invalid input.")
20
+ }
21
+ this.fec_file_id = expenditure.fec_file_id
22
+ this.expenditure_id = expenditure.expenditure_id
23
+ this.date = expenditure.date
24
+ this.payee = expenditure.payee
25
+ this.election_stage = expenditure.election_stage
26
+ this.election_id = expenditure.election_id
27
+ this.candidate_id = expenditure.candidate_id
28
+ this.amount = expenditure.amount
29
+ this.cumulative_amount = expenditure.cumulative_amount
30
+ this.purpose = expenditure.purpose
31
+ this.is_support = expenditure.is_support
32
+ }
33
+
34
+ static is(expenditure : any) : expenditure is Expenditure {
35
+ return (
36
+ expenditure !== undefined &&
37
+ typeof expenditure.fec_file_id === "number" &&
38
+ typeof expenditure.expenditure_id === "string" &&
39
+ typeof expenditure.date === "string" &&
40
+ typeof expenditure.payee === "string" &&
41
+ typeof expenditure.election_stage === "string" &&
42
+ is_election_id(expenditure.election_id) &&
43
+ typeof expenditure.candidate_id === "string" &&
44
+ typeof expenditure.amount === "number" &&
45
+ typeof expenditure.cumulative_amount === "number" &&
46
+ typeof expenditure.purpose === "string" &&
47
+ typeof expenditure.is_support === "boolean"
48
+ )
49
+ }
50
+
51
+ }
52
+
53
+ export class FECF24File extends FECFile {
54
+ readonly committee_id : string
55
+ readonly first_fec_file_id : number
56
+ readonly report_type : string
57
+ readonly first_report_date : string
58
+ readonly report_date : string
59
+ readonly expenditures : Expenditure[]
60
+
61
+ constructor(fec_file : any) {
62
+ if (!FECF24File.is(fec_file)) {
63
+ throw Error("Invalid input.")
64
+ }
65
+ super(fec_file)
66
+ this.committee_id = fec_file.committee_id
67
+ this.first_fec_file_id = fec_file.first_fec_file_id
68
+ this.report_type = fec_file.report_type
69
+ this.first_report_date = fec_file.first_report_date
70
+ this.report_date = fec_file.report_date
71
+ this.expenditures = fec_file.expenditures
72
+ }
73
+
74
+ static is(fec_file : any) : fec_file is FECF24File {
75
+ return (
76
+ FECFile.is(fec_file) &&
77
+ fec_file.form_type_id === "F24" &&
78
+ typeof fec_file.committee_id === "string" &&
79
+ typeof fec_file.first_fec_file_id === "number" &&
80
+ typeof fec_file.report_type === "string" &&
81
+ typeof fec_file.first_report_date === "string" &&
82
+ typeof fec_file.report_date === "string" &&
83
+ Array.isArray(fec_file.expenditures) && fec_file.expenditures.every(Expenditure.is)
84
+ )
85
+ }
86
+ }
@@ -0,0 +1,44 @@
1
+ import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
2
+ import { FECFile } from "./FECFile"
3
+ import { is_state_id, StateID } from "./State"
4
+
5
+ export class FECF2File extends FECFile {
6
+ readonly candidate_id : string
7
+ readonly fec_name : string
8
+ readonly office_id : OfficeID
9
+ readonly state_id : StateID
10
+ readonly district? : number
11
+ readonly election_id : ElectionID
12
+ readonly party_id? : string
13
+ readonly report_date : string
14
+
15
+ constructor(fec_file : any) {
16
+ if (!FECF2File.is(fec_file)) {
17
+ throw Error("Invalid input.")
18
+ }
19
+ super(fec_file)
20
+ this.candidate_id = fec_file.candidate_id
21
+ this.fec_name = fec_file.fec_name
22
+ this.office_id = fec_file.office_id
23
+ this.state_id = fec_file.state_id
24
+ this.district = fec_file.district
25
+ this.election_id = fec_file.election_id
26
+ this.party_id = fec_file.party_id
27
+ this.report_date = fec_file.report_date
28
+ }
29
+
30
+ static is(fec_file : any) : fec_file is FECF2File {
31
+ return (
32
+ FECFile.is(fec_file) &&
33
+ fec_file.form_type_id === "F2" &&
34
+ typeof fec_file.candidate_id === "string" &&
35
+ typeof fec_file.fec_name === "string" &&
36
+ is_office_id(fec_file.office_id) &&
37
+ is_state_id(fec_file.state_id) &&
38
+ (fec_file.district === undefined || typeof fec_file.district === "number") &&
39
+ is_election_id(fec_file.election_id) &&
40
+ (fec_file.party_id === undefined || typeof fec_file.party_id === "string") &&
41
+ typeof fec_file.report_date === "string"
42
+ )
43
+ }
44
+ }
@@ -0,0 +1,42 @@
1
+ import { FECFile } from "./FECFile"
2
+
3
+ export class FECF3File extends FECFile {
4
+ readonly committee_id : string
5
+ readonly period_id : string
6
+ readonly period_start_date : string
7
+ readonly period_end_date : string
8
+ readonly report_date : string
9
+ readonly cash_on_hand : number
10
+ readonly cumulative_receipts : number
11
+ readonly new_receipts : number
12
+
13
+ constructor(fec_file : any) {
14
+ if (!FECF3File.is(fec_file)) {
15
+ throw Error("Invalid input.")
16
+ }
17
+ super(fec_file)
18
+ this.committee_id = fec_file.committee_id
19
+ this.period_id = fec_file.period_id
20
+ this.period_start_date = fec_file.period_start_date
21
+ this.period_end_date = fec_file.period_end_date
22
+ this.report_date = fec_file.report_date
23
+ this.cash_on_hand = fec_file.cash_on_hand
24
+ this.cumulative_receipts = fec_file.cumulative_receipts
25
+ this.new_receipts = fec_file.new_receipts
26
+ }
27
+
28
+ static is(fec_file : any) : fec_file is FECF3File {
29
+ return (
30
+ FECFile.is(fec_file) &&
31
+ fec_file.form_type_id === "F3" &&
32
+ typeof fec_file.committee_id === "string" &&
33
+ typeof fec_file.period_id === "string" &&
34
+ typeof fec_file.period_start_date === "string" &&
35
+ typeof fec_file.period_end_date === "string" &&
36
+ typeof fec_file.report_date === "string" &&
37
+ typeof fec_file.cash_on_hand === "number" &&
38
+ typeof fec_file.cumulative_receipts === "number" &&
39
+ typeof fec_file.new_receipts === "number"
40
+ )
41
+ }
42
+ }
@@ -0,0 +1,32 @@
1
+ import { AmendmentTypeID, FormTypeID, is_amendment_type_id, is_form_type_id, is_long_form_type_id, LongFormTypeID } from "./FormTypeID"
2
+
3
+ export class FECFile {
4
+ readonly fec_file_id : number
5
+ readonly form_type_id : FormTypeID
6
+ readonly amendment_type_id : AmendmentTypeID
7
+ readonly long_form_type_id : LongFormTypeID
8
+ readonly s3_filename : string
9
+ [x : string] : any
10
+
11
+ constructor(fec_file : any) {
12
+ if (!FECFile.is(fec_file)) {
13
+ throw Error("Invalid input.")
14
+ }
15
+ this.fec_file_id = fec_file.fec_file_id
16
+ this.form_type_id = fec_file.form_type_id
17
+ this.amendment_type_id = fec_file.amendment_type_id
18
+ this.long_form_type_id = fec_file.long_form_type_id
19
+ this.s3_filename = fec_file.s3_filename
20
+ }
21
+
22
+ static is(fec_file : any) : fec_file is FECFile {
23
+ return (
24
+ fec_file !== undefined &&
25
+ typeof fec_file.fec_file_id === "number" &&
26
+ is_form_type_id(fec_file.form_type_id) &&
27
+ is_amendment_type_id(fec_file.amendment_type_id) &&
28
+ is_long_form_type_id(fec_file.long_form_type_id) &&
29
+ (fec_file.s3_filename === undefined || typeof fec_file.s3_filename === "string")
30
+ )
31
+ }
32
+ }