elections-types 1.0.74 → 1.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { CommitteeAux } from "./Committee.js";
2
2
  import { ElectionID, OfficeID } from "./Election.js";
3
- import { Expenditure } from "./Expenditure.js";
3
+ import { ExpenditureAux } from "./Expenditure.js";
4
4
  import { FECF3File } from "./FECF3File.js";
5
5
  import { StateID } from "./State.js";
6
6
  export declare class ActivityIndex {
@@ -32,7 +32,7 @@ export declare class Candidate {
32
32
  export declare class CandidateAux extends Candidate {
33
33
  readonly committees: CommitteeAux[];
34
34
  readonly fec_f3_files: FECF3File[];
35
- readonly expenditures: Expenditure[];
35
+ readonly expenditures: ExpenditureAux[];
36
36
  constructor(candidate: any);
37
37
  static is(candidate: any): candidate is CandidateAux;
38
38
  }
@@ -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 { Expenditure } from "./Expenditure.js";
3
+ import { ExpenditureAux } from "./Expenditure.js";
4
4
  import { FECF3File } from "./FECF3File.js";
5
5
  import { is_state_id } from "./State.js";
6
6
  export class ActivityIndex {
@@ -85,7 +85,7 @@ export class CandidateAux extends Candidate {
85
85
  super(candidate);
86
86
  this.committees = candidate.committees;
87
87
  this.fec_f3_files = candidate.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file));
88
- this.expenditures = candidate.expenditures.map(expenditure => new Expenditure(expenditure));
88
+ this.expenditures = candidate.expenditures.map(expenditure => new ExpenditureAux(expenditure));
89
89
  }
90
90
  static is(candidate) {
91
91
  return (Candidate.is(candidate) &&
@@ -94,6 +94,6 @@ export class CandidateAux extends Candidate {
94
94
  Array.isArray(candidate.fec_f3_files) &&
95
95
  candidate.fec_f3_files.every(FECF3File.is) &&
96
96
  Array.isArray(candidate.expenditures) &&
97
- candidate.expenditures.every(Expenditure.is));
97
+ candidate.expenditures.every(ExpenditureAux.is));
98
98
  }
99
99
  }
@@ -51,9 +51,9 @@ export class CommitteeAux extends Committee {
51
51
  super(committee);
52
52
  this.candidates = committee.candidates;
53
53
  this.fec_f3_files = committee.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file));
54
- this.jfp_committees = committee.jfp_committees;
55
- this.jfr_committees = committee.jfr_committees;
56
- this.aff_committees = committee.aff_committees;
54
+ this.jfp_committees = committee.jfp_committees !== undefined ? committee.jfp_committees.map(committee => new Committee(committee)) : undefined;
55
+ this.jfr_committees = committee.jfr_committees.map(committee => new Committee(committee));
56
+ this.aff_committees = committee.aff_committees.map(committee => new Committee(committee));
57
57
  }
58
58
  static is(committee) {
59
59
  return (Committee.is(committee) &&
@@ -1,6 +1,6 @@
1
1
  import { CandidateAux } from "./Candidate.js";
2
2
  import { CommitteeAux } from "./Committee.js";
3
- import { Expenditure } from "./Expenditure.js";
3
+ import { ExpenditureAux } from "./Expenditure.js";
4
4
  import { StateID } from "./State.js";
5
5
  declare const office_ids: readonly ["H", "S"];
6
6
  export type OfficeID = typeof office_ids[number];
@@ -20,7 +20,7 @@ export declare class Election {
20
20
  export declare class ElectionAux extends Election {
21
21
  readonly candidates: CandidateAux[];
22
22
  readonly committees: CommitteeAux[];
23
- readonly expenditures: Expenditure[];
23
+ readonly expenditures: ExpenditureAux[];
24
24
  constructor(election: any);
25
25
  static is(election: any): election is ElectionAux;
26
26
  }
@@ -1,6 +1,6 @@
1
1
  import { CandidateAux } from "./Candidate.js";
2
2
  import { CommitteeAux } from "./Committee.js";
3
- import { Expenditure } from "./Expenditure.js";
3
+ import { ExpenditureAux } from "./Expenditure.js";
4
4
  import { is_state_id } from "./State.js";
5
5
  const office_ids = ["H", "S"];
6
6
  export function is_office_id(office_id) {
@@ -54,9 +54,9 @@ export class ElectionAux extends Election {
54
54
  throw Error("Invalid input.");
55
55
  }
56
56
  super(election);
57
- this.candidates = election.candidates;
58
- this.committees = election.committees;
59
- this.expenditures = election.expenditures;
57
+ this.candidates = election.candidates.map(candidate => new CandidateAux(candidate));
58
+ this.committees = election.committees.map(committee => new CommitteeAux(committee));
59
+ this.expenditures = election.expenditures.map(expenditure => new ExpenditureAux(expenditure));
60
60
  }
61
61
  static is(election) {
62
62
  return (Election.is(election) &&
@@ -65,6 +65,6 @@ export class ElectionAux extends Election {
65
65
  Array.isArray(election.committees) &&
66
66
  election.committees.every(CommitteeAux.is) &&
67
67
  Array.isArray(election.expenditures) &&
68
- election.expenditures.every(Expenditure.is));
68
+ election.expenditures.every(ExpenditureAux.is));
69
69
  }
70
70
  }
@@ -18,7 +18,7 @@ export declare class Expenditure {
18
18
  static is(expenditure: any): expenditure is Expenditure;
19
19
  }
20
20
  export declare class ExpenditureAux extends Expenditure {
21
- readonly committee: Committee[];
21
+ readonly committee: Committee;
22
22
  constructor(expenditure: any);
23
23
  static is(expenditure: any): expenditure is ExpenditureAux;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elections-types",
3
- "version": "1.0.74",
3
+ "version": "1.0.76",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -1,7 +1,6 @@
1
1
  import { Committee, CommitteeAux } from "./Committee"
2
2
  import { ElectionID, is_election_id, is_office_id, OfficeID } from "./Election"
3
- import { Expenditure } from "./Expenditure"
4
- import { FECF24File } from "./FECF24File"
3
+ import { Expenditure, ExpenditureAux } from "./Expenditure"
5
4
  import { FECF3File } from "./FECF3File"
6
5
  import { is_state_id, StateID } from "./State"
7
6
 
@@ -93,7 +92,7 @@ export class Candidate {
93
92
  export class CandidateAux extends Candidate {
94
93
  readonly committees : CommitteeAux[]
95
94
  readonly fec_f3_files : FECF3File[]
96
- readonly expenditures : Expenditure[]
95
+ readonly expenditures : ExpenditureAux[]
97
96
 
98
97
  constructor(candidate : any) {
99
98
  if (!CandidateAux.is(candidate)) {
@@ -102,7 +101,7 @@ export class CandidateAux extends Candidate {
102
101
  super(candidate)
103
102
  this.committees = candidate.committees
104
103
  this.fec_f3_files = candidate.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file))
105
- this.expenditures = candidate.expenditures.map(expenditure => new Expenditure(expenditure))
104
+ this.expenditures = candidate.expenditures.map(expenditure => new ExpenditureAux(expenditure))
106
105
  }
107
106
 
108
107
  static is(candidate : any) : candidate is CandidateAux {
@@ -113,7 +112,7 @@ export class CandidateAux extends Candidate {
113
112
  Array.isArray(candidate.fec_f3_files) &&
114
113
  candidate.fec_f3_files.every(FECF3File.is) &&
115
114
  Array.isArray(candidate.expenditures) &&
116
- candidate.expenditures.every(Expenditure.is)
115
+ candidate.expenditures.every(ExpenditureAux.is)
117
116
  )
118
117
  }
119
118
  }
@@ -64,9 +64,9 @@ export class CommitteeAux extends Committee {
64
64
  super(committee)
65
65
  this.candidates = committee.candidates
66
66
  this.fec_f3_files = committee.fec_f3_files.map(fec_f3_file => new FECF3File(fec_f3_file))
67
- this.jfp_committees = committee.jfp_committees
68
- this.jfr_committees = committee.jfr_committees
69
- this.aff_committees = committee.aff_committees
67
+ this.jfp_committees = committee.jfp_committees !== undefined ? committee.jfp_committees.map(committee => new Committee(committee)) : undefined
68
+ this.jfr_committees = committee.jfr_committees.map(committee => new Committee(committee))
69
+ this.aff_committees = committee.aff_committees.map(committee => new Committee(committee))
70
70
  }
71
71
 
72
72
  static is(committee : any) : committee is CommitteeAux {
@@ -1,6 +1,6 @@
1
1
  import { Candidate, CandidateAux } from "./Candidate"
2
2
  import { Committee, CommitteeAux } from "./Committee"
3
- import { Expenditure } from "./Expenditure"
3
+ import { ExpenditureAux } from "./Expenditure"
4
4
  import { is_state_id, state_ids, StateID } from "./State"
5
5
 
6
6
  const office_ids = ["H", "S"] as const
@@ -65,16 +65,16 @@ export class Election {
65
65
  export class ElectionAux extends Election {
66
66
  readonly candidates : CandidateAux[]
67
67
  readonly committees : CommitteeAux[]
68
- readonly expenditures : Expenditure[]
68
+ readonly expenditures : ExpenditureAux[]
69
69
 
70
70
  constructor(election : any) {
71
71
  if (!ElectionAux.is(election)) {
72
72
  throw Error("Invalid input.")
73
73
  }
74
74
  super(election)
75
- this.candidates = election.candidates
76
- this.committees = election.committees
77
- this.expenditures = election.expenditures
75
+ this.candidates = election.candidates.map(candidate => new CandidateAux(candidate))
76
+ this.committees = election.committees.map(committee => new CommitteeAux(committee))
77
+ this.expenditures = election.expenditures.map(expenditure => new ExpenditureAux(expenditure))
78
78
  }
79
79
 
80
80
  static is(election : any) : election is ElectionAux {
@@ -85,7 +85,7 @@ export class ElectionAux extends Election {
85
85
  Array.isArray(election.committees) &&
86
86
  election.committees.every(CommitteeAux.is) &&
87
87
  Array.isArray(election.expenditures) &&
88
- election.expenditures.every(Expenditure.is)
88
+ election.expenditures.every(ExpenditureAux.is)
89
89
  )
90
90
  }
91
91
  }
@@ -55,7 +55,7 @@ export class Expenditure {
55
55
  }
56
56
 
57
57
  export class ExpenditureAux extends Expenditure {
58
- readonly committee : Committee[]
58
+ readonly committee : Committee
59
59
 
60
60
  constructor(expenditure : any) {
61
61
  if (!ExpenditureAux.is(expenditure)) {