triangle-types 1.0.51 → 1.0.53
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/types/federal_congress/FederalCongressBill.d.ts +1 -1
- package/dist/src/types/federal_congress/FederalCongressBill.js +3 -3
- package/dist/src/types/federal_congress/FederalCongressBillDocument.d.ts +1 -1
- package/dist/src/types/federal_congress/FederalCongressBillDocument.js +3 -3
- package/dist/src/types/federal_congress/FederalCongressDistrict.d.ts +10 -0
- package/dist/src/types/federal_congress/FederalCongressDistrict.js +26 -0
- package/dist/src/types/prism/Voter.d.ts +11 -3
- package/dist/src/types/prism/Voter.js +28 -28
- package/dist/src/types/state_legislature/StateLegislatureDistrict.d.ts +10 -0
- package/dist/src/types/state_legislature/StateLegislatureDistrict.js +26 -0
- package/package.json +1 -1
- package/src/types/federal_congress/FederalCongressBill.ts +3 -3
- package/src/types/federal_congress/FederalCongressBillDocument.ts +3 -3
- package/src/types/federal_congress/FederalCongressDistrict.ts +33 -0
- package/src/types/prism/Voter.ts +31 -28
- package/src/types/state_legislature/StateLegislatureDistrict.ts +33 -0
|
@@ -3,7 +3,7 @@ export type FederalCongressBillTypeID = typeof federal_congress_bill_type_ids[nu
|
|
|
3
3
|
export declare function is_federal_congress_bill_type_id(federal_congress_bill_type_id: any): federal_congress_bill_type_id is FederalCongressBillTypeID;
|
|
4
4
|
export declare class FederalCongressBill {
|
|
5
5
|
readonly federal_congress_bill_id: string;
|
|
6
|
-
readonly
|
|
6
|
+
readonly federal_congress_id: number;
|
|
7
7
|
readonly bill_type_id: FederalCongressBillTypeID;
|
|
8
8
|
readonly number: number;
|
|
9
9
|
readonly bill_id: string;
|
|
@@ -4,7 +4,7 @@ export function is_federal_congress_bill_type_id(federal_congress_bill_type_id)
|
|
|
4
4
|
}
|
|
5
5
|
export class FederalCongressBill {
|
|
6
6
|
federal_congress_bill_id;
|
|
7
|
-
|
|
7
|
+
federal_congress_id;
|
|
8
8
|
bill_type_id;
|
|
9
9
|
number;
|
|
10
10
|
bill_id;
|
|
@@ -18,7 +18,7 @@ export class FederalCongressBill {
|
|
|
18
18
|
throw Error("Invalid input.");
|
|
19
19
|
}
|
|
20
20
|
this.federal_congress_bill_id = federal_congress_bill.federal_congress_bill_id;
|
|
21
|
-
this.
|
|
21
|
+
this.federal_congress_id = federal_congress_bill.federal_congress_id;
|
|
22
22
|
this.bill_type_id = federal_congress_bill.bill_type_id;
|
|
23
23
|
this.number = federal_congress_bill.number;
|
|
24
24
|
this.bill_id = federal_congress_bill.bill_id;
|
|
@@ -31,7 +31,7 @@ export class FederalCongressBill {
|
|
|
31
31
|
static is(federal_congress_bill) {
|
|
32
32
|
return (federal_congress_bill !== undefined &&
|
|
33
33
|
typeof federal_congress_bill.federal_congress_bill_id === "string" &&
|
|
34
|
-
typeof federal_congress_bill.
|
|
34
|
+
typeof federal_congress_bill.federal_congress_id === "number" &&
|
|
35
35
|
is_federal_congress_bill_type_id(federal_congress_bill.bill_type_id) &&
|
|
36
36
|
typeof federal_congress_bill.number === "number" &&
|
|
37
37
|
typeof federal_congress_bill.bill_id === "string" &&
|
|
@@ -6,7 +6,7 @@ export declare class FederalCongressBillDocument {
|
|
|
6
6
|
readonly federal_congress_bill_document_id: string;
|
|
7
7
|
readonly federal_congress_bill_id: string;
|
|
8
8
|
readonly document_id: string;
|
|
9
|
-
readonly
|
|
9
|
+
readonly federal_congress_id: number;
|
|
10
10
|
readonly bill_id: string;
|
|
11
11
|
readonly bill_type_id: FederalCongressBillTypeID;
|
|
12
12
|
readonly number: number;
|
|
@@ -8,7 +8,7 @@ export class FederalCongressBillDocument {
|
|
|
8
8
|
federal_congress_bill_document_id;
|
|
9
9
|
federal_congress_bill_id;
|
|
10
10
|
document_id;
|
|
11
|
-
|
|
11
|
+
federal_congress_id;
|
|
12
12
|
bill_id;
|
|
13
13
|
bill_type_id;
|
|
14
14
|
number;
|
|
@@ -22,7 +22,7 @@ export class FederalCongressBillDocument {
|
|
|
22
22
|
}
|
|
23
23
|
this.federal_congress_bill_document_id = federal_congress_bill_document.federal_congress_bill_document_id;
|
|
24
24
|
this.federal_congress_bill_id = federal_congress_bill_document.federal_congress_bill_id;
|
|
25
|
-
this.
|
|
25
|
+
this.federal_congress_id = federal_congress_bill_document.federal_congress_id;
|
|
26
26
|
this.bill_id = federal_congress_bill_document.bill_id;
|
|
27
27
|
this.bill_type_id = federal_congress_bill_document.bill_type_id;
|
|
28
28
|
this.number = federal_congress_bill_document.number;
|
|
@@ -36,7 +36,7 @@ export class FederalCongressBillDocument {
|
|
|
36
36
|
return (federal_congress_bill_document !== undefined &&
|
|
37
37
|
typeof federal_congress_bill_document.federal_congress_bill_document_id === "string" &&
|
|
38
38
|
typeof federal_congress_bill_document.federal_congress_bill_id === "string" &&
|
|
39
|
-
typeof federal_congress_bill_document.
|
|
39
|
+
typeof federal_congress_bill_document.federal_congress_id === "number" &&
|
|
40
40
|
typeof federal_congress_bill_document.bill_id === "string" &&
|
|
41
41
|
typeof federal_congress_bill_document.bill_type_id === "string" &&
|
|
42
42
|
typeof federal_congress_bill_document.number === "number" &&
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StateID } from "../State.js";
|
|
2
|
+
export declare class FederalCongressDistrict {
|
|
3
|
+
readonly federal_congress_district_id: string;
|
|
4
|
+
readonly congress_id: number;
|
|
5
|
+
readonly chamber_id: string;
|
|
6
|
+
readonly state_id: StateID;
|
|
7
|
+
readonly district_id: number;
|
|
8
|
+
constructor(federal_congress_district: any);
|
|
9
|
+
static is(federal_congress_district: any): federal_congress_district is FederalCongressDistrict;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { is_state_id } from "../State.js";
|
|
2
|
+
export class FederalCongressDistrict {
|
|
3
|
+
federal_congress_district_id;
|
|
4
|
+
congress_id;
|
|
5
|
+
chamber_id;
|
|
6
|
+
state_id;
|
|
7
|
+
district_id;
|
|
8
|
+
constructor(federal_congress_district) {
|
|
9
|
+
if (!FederalCongressDistrict.is(federal_congress_district)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.federal_congress_district_id = federal_congress_district.federal_congress_district_id;
|
|
13
|
+
this.congress_id = federal_congress_district.congress_id;
|
|
14
|
+
this.chamber_id = federal_congress_district.chamber_id;
|
|
15
|
+
this.state_id = federal_congress_district.state_id;
|
|
16
|
+
this.district_id = federal_congress_district.district_id;
|
|
17
|
+
}
|
|
18
|
+
static is(federal_congress_district) {
|
|
19
|
+
return (federal_congress_district !== undefined &&
|
|
20
|
+
typeof federal_congress_district.federal_congress_district_id === "string" &&
|
|
21
|
+
typeof federal_congress_district.congress_id === "string" &&
|
|
22
|
+
typeof federal_congress_district.chamber_id === "string" &&
|
|
23
|
+
is_state_id(federal_congress_district.state_id) &&
|
|
24
|
+
typeof federal_congress_district === "number");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { VoterTarget } from "./VoterTarget.js";
|
|
2
|
+
import { VoterTurnout } from "./VoterTurnout.js";
|
|
1
3
|
export declare class Voter {
|
|
2
4
|
readonly voter_id: string;
|
|
3
5
|
readonly state_id: string;
|
|
@@ -21,9 +23,9 @@ export declare class Voter {
|
|
|
21
23
|
readonly address_mail_city?: string;
|
|
22
24
|
readonly address_mail_state_id: string;
|
|
23
25
|
readonly address_mail_zip?: string;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
26
|
+
readonly federal_house_district_id: string;
|
|
27
|
+
readonly state_house_district_id: string;
|
|
28
|
+
readonly state_senate_district_id: string;
|
|
27
29
|
readonly occupation_group?: string;
|
|
28
30
|
readonly occupation_description?: string;
|
|
29
31
|
readonly phone_home?: string;
|
|
@@ -40,3 +42,9 @@ export declare class Voter {
|
|
|
40
42
|
constructor(voter: any);
|
|
41
43
|
static is(voter: any): voter is Voter;
|
|
42
44
|
}
|
|
45
|
+
export declare class VoterAux extends Voter {
|
|
46
|
+
readonly targets: VoterTarget[];
|
|
47
|
+
readonly turnouts: VoterTurnout[];
|
|
48
|
+
constructor(voter: any);
|
|
49
|
+
static is(voter: any): voter is Voter;
|
|
50
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { VoterTarget } from "./VoterTarget.js";
|
|
2
|
+
import { VoterTurnout } from "./VoterTurnout.js";
|
|
1
3
|
export class Voter {
|
|
2
4
|
voter_id;
|
|
3
5
|
state_id;
|
|
@@ -21,9 +23,9 @@ export class Voter {
|
|
|
21
23
|
address_mail_city;
|
|
22
24
|
address_mail_state_id;
|
|
23
25
|
address_mail_zip;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
federal_house_district_id;
|
|
27
|
+
state_house_district_id;
|
|
28
|
+
state_senate_district_id;
|
|
27
29
|
occupation_group;
|
|
28
30
|
occupation_description;
|
|
29
31
|
phone_home;
|
|
@@ -62,9 +64,9 @@ export class Voter {
|
|
|
62
64
|
this.address_mail_city = voter.address_mail_city;
|
|
63
65
|
this.address_mail_state_id = voter.address_mail_state_id;
|
|
64
66
|
this.address_mail_zip = voter.address_mail_zip;
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
67
|
+
this.federal_house_district_id = voter.federal_house_district_id;
|
|
68
|
+
this.state_house_district_id = voter.state_house_district_id;
|
|
69
|
+
this.state_senate_district_id = voter.state_senate_district_id;
|
|
68
70
|
this.occupation_group = voter.occupation_group;
|
|
69
71
|
this.occupation_description = voter.occupation_description;
|
|
70
72
|
this.phone_home = voter.phone_home;
|
|
@@ -102,9 +104,9 @@ export class Voter {
|
|
|
102
104
|
(voter.address_mail_city === undefined || typeof voter.address_mail_city === "string") &&
|
|
103
105
|
typeof voter.address_mail_state_id === "string" &&
|
|
104
106
|
(voter.address_mail_zip === undefined || typeof voter.address_mail_zip === "string") &&
|
|
105
|
-
typeof voter.
|
|
106
|
-
typeof voter.
|
|
107
|
-
typeof voter.
|
|
107
|
+
typeof voter.federal_house_district_id === "string" &&
|
|
108
|
+
typeof voter.state_house_district_id === "string" &&
|
|
109
|
+
typeof voter.state_senate_district_id === "string" &&
|
|
108
110
|
(voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
|
|
109
111
|
(voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
|
|
110
112
|
(voter.phone_home === undefined || typeof voter.phone_home === "string") &&
|
|
@@ -119,22 +121,20 @@ export class Voter {
|
|
|
119
121
|
(voter.marital_status === undefined || typeof voter.marital_status === "string"));
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// }
|
|
140
|
-
// }
|
|
124
|
+
export class VoterAux extends Voter {
|
|
125
|
+
targets;
|
|
126
|
+
turnouts;
|
|
127
|
+
constructor(voter) {
|
|
128
|
+
if (!VoterAux.is(voter)) {
|
|
129
|
+
throw Error("Invalid input.");
|
|
130
|
+
}
|
|
131
|
+
super(voter);
|
|
132
|
+
this.targets = voter.targets;
|
|
133
|
+
this.turnouts = voter.turnouts;
|
|
134
|
+
}
|
|
135
|
+
static is(voter) {
|
|
136
|
+
return (Voter.is(voter) &&
|
|
137
|
+
Array.isArray(voter.targets) && voter.targets.every(VoterTarget.is) &&
|
|
138
|
+
Array.isArray(voter.turnouts) && voter.turnouts.every(VoterTurnout.is));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StateID } from "../State.js";
|
|
2
|
+
export declare class StateLegislatureDistrict {
|
|
3
|
+
readonly state_legislature_district_id: string;
|
|
4
|
+
readonly legislature_id: number;
|
|
5
|
+
readonly state_id: StateID;
|
|
6
|
+
readonly chamber_id: string;
|
|
7
|
+
readonly district_id: number;
|
|
8
|
+
constructor(state_legislature_district: any);
|
|
9
|
+
static is(state_legislature_district: any): state_legislature_district is StateLegislatureDistrict;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { is_state_id } from "../State.js";
|
|
2
|
+
export class StateLegislatureDistrict {
|
|
3
|
+
state_legislature_district_id;
|
|
4
|
+
legislature_id;
|
|
5
|
+
state_id;
|
|
6
|
+
chamber_id;
|
|
7
|
+
district_id;
|
|
8
|
+
constructor(state_legislature_district) {
|
|
9
|
+
if (!StateLegislatureDistrict.is(state_legislature_district)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.state_legislature_district_id = state_legislature_district.state_legislature_district_id;
|
|
13
|
+
this.legislature_id = state_legislature_district.legislature_id;
|
|
14
|
+
this.state_id = state_legislature_district.state_id;
|
|
15
|
+
this.chamber_id = state_legislature_district.chamber_id;
|
|
16
|
+
this.district_id = state_legislature_district.district_id;
|
|
17
|
+
}
|
|
18
|
+
static is(state_legislature_district) {
|
|
19
|
+
return (state_legislature_district !== undefined &&
|
|
20
|
+
typeof state_legislature_district.state_legislature_district_id === "string" &&
|
|
21
|
+
typeof state_legislature_district.legislature_id === "string" &&
|
|
22
|
+
is_state_id(state_legislature_district.state_id) &&
|
|
23
|
+
typeof state_legislature_district.chamber_id === "string" &&
|
|
24
|
+
typeof state_legislature_district === "number");
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ export function is_federal_congress_bill_type_id(federal_congress_bill_type_id :
|
|
|
8
8
|
|
|
9
9
|
export class FederalCongressBill {
|
|
10
10
|
readonly federal_congress_bill_id : string
|
|
11
|
-
readonly
|
|
11
|
+
readonly federal_congress_id : number
|
|
12
12
|
readonly bill_type_id : FederalCongressBillTypeID
|
|
13
13
|
readonly number : number
|
|
14
14
|
readonly bill_id : string
|
|
@@ -23,7 +23,7 @@ export class FederalCongressBill {
|
|
|
23
23
|
throw Error("Invalid input.")
|
|
24
24
|
}
|
|
25
25
|
this.federal_congress_bill_id = federal_congress_bill.federal_congress_bill_id
|
|
26
|
-
this.
|
|
26
|
+
this.federal_congress_id = federal_congress_bill.federal_congress_id
|
|
27
27
|
this.bill_type_id = federal_congress_bill.bill_type_id
|
|
28
28
|
this.number = federal_congress_bill.number
|
|
29
29
|
this.bill_id = federal_congress_bill.bill_id
|
|
@@ -38,7 +38,7 @@ export class FederalCongressBill {
|
|
|
38
38
|
return (
|
|
39
39
|
federal_congress_bill !== undefined &&
|
|
40
40
|
typeof federal_congress_bill.federal_congress_bill_id === "string" &&
|
|
41
|
-
typeof federal_congress_bill.
|
|
41
|
+
typeof federal_congress_bill.federal_congress_id === "number" &&
|
|
42
42
|
is_federal_congress_bill_type_id(federal_congress_bill.bill_type_id) &&
|
|
43
43
|
typeof federal_congress_bill.number === "number" &&
|
|
44
44
|
typeof federal_congress_bill.bill_id === "string" &&
|
|
@@ -14,7 +14,7 @@ export class FederalCongressBillDocument {
|
|
|
14
14
|
readonly federal_congress_bill_document_id : string
|
|
15
15
|
readonly federal_congress_bill_id : string
|
|
16
16
|
readonly document_id : string
|
|
17
|
-
readonly
|
|
17
|
+
readonly federal_congress_id : number
|
|
18
18
|
readonly bill_id : string
|
|
19
19
|
readonly bill_type_id : FederalCongressBillTypeID
|
|
20
20
|
readonly number : number
|
|
@@ -29,7 +29,7 @@ export class FederalCongressBillDocument {
|
|
|
29
29
|
}
|
|
30
30
|
this.federal_congress_bill_document_id = federal_congress_bill_document.federal_congress_bill_document_id
|
|
31
31
|
this.federal_congress_bill_id = federal_congress_bill_document.federal_congress_bill_id
|
|
32
|
-
this.
|
|
32
|
+
this.federal_congress_id = federal_congress_bill_document.federal_congress_id
|
|
33
33
|
this.bill_id = federal_congress_bill_document.bill_id
|
|
34
34
|
this.bill_type_id = federal_congress_bill_document.bill_type_id
|
|
35
35
|
this.number = federal_congress_bill_document.number
|
|
@@ -45,7 +45,7 @@ export class FederalCongressBillDocument {
|
|
|
45
45
|
federal_congress_bill_document !== undefined &&
|
|
46
46
|
typeof federal_congress_bill_document.federal_congress_bill_document_id === "string" &&
|
|
47
47
|
typeof federal_congress_bill_document.federal_congress_bill_id === "string" &&
|
|
48
|
-
typeof federal_congress_bill_document.
|
|
48
|
+
typeof federal_congress_bill_document.federal_congress_id === "number" &&
|
|
49
49
|
typeof federal_congress_bill_document.bill_id === "string" &&
|
|
50
50
|
typeof federal_congress_bill_document.bill_type_id === "string" &&
|
|
51
51
|
typeof federal_congress_bill_document.number === "number" &&
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { is_state_id, StateID } from "../State"
|
|
2
|
+
|
|
3
|
+
export class FederalCongressDistrict {
|
|
4
|
+
readonly federal_congress_district_id : string
|
|
5
|
+
readonly congress_id : number
|
|
6
|
+
readonly chamber_id : string
|
|
7
|
+
readonly state_id : StateID
|
|
8
|
+
readonly district_id : number
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
constructor(federal_congress_district : any) {
|
|
12
|
+
if (!FederalCongressDistrict.is(federal_congress_district)) {
|
|
13
|
+
throw Error("Invalid input.")
|
|
14
|
+
}
|
|
15
|
+
this.federal_congress_district_id = federal_congress_district.federal_congress_district_id
|
|
16
|
+
this.congress_id = federal_congress_district.congress_id
|
|
17
|
+
this.chamber_id = federal_congress_district.chamber_id
|
|
18
|
+
this.state_id = federal_congress_district.state_id
|
|
19
|
+
this.district_id = federal_congress_district.district_id
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static is(federal_congress_district : any) : federal_congress_district is FederalCongressDistrict {
|
|
23
|
+
return (
|
|
24
|
+
federal_congress_district !== undefined &&
|
|
25
|
+
typeof federal_congress_district.federal_congress_district_id === "string" &&
|
|
26
|
+
typeof federal_congress_district.congress_id === "string" &&
|
|
27
|
+
typeof federal_congress_district.chamber_id === "string" &&
|
|
28
|
+
is_state_id(federal_congress_district.state_id) &&
|
|
29
|
+
typeof federal_congress_district === "number"
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
package/src/types/prism/Voter.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { VoterTarget } from "./VoterTarget"
|
|
2
|
+
import { VoterTurnout } from "./VoterTurnout"
|
|
3
|
+
|
|
1
4
|
export class Voter {
|
|
2
5
|
readonly voter_id : string
|
|
3
6
|
readonly state_id : string
|
|
@@ -21,9 +24,9 @@ export class Voter {
|
|
|
21
24
|
readonly address_mail_city? : string
|
|
22
25
|
readonly address_mail_state_id : string
|
|
23
26
|
readonly address_mail_zip? : string
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
27
|
+
readonly federal_house_district_id : string
|
|
28
|
+
readonly state_house_district_id : string
|
|
29
|
+
readonly state_senate_district_id : string
|
|
27
30
|
readonly occupation_group? : string
|
|
28
31
|
readonly occupation_description? : string
|
|
29
32
|
readonly phone_home? : string
|
|
@@ -64,9 +67,9 @@ export class Voter {
|
|
|
64
67
|
this.address_mail_city = voter.address_mail_city
|
|
65
68
|
this.address_mail_state_id = voter.address_mail_state_id
|
|
66
69
|
this.address_mail_zip = voter.address_mail_zip
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
+
this.federal_house_district_id = voter.federal_house_district_id
|
|
71
|
+
this.state_house_district_id = voter.state_house_district_id
|
|
72
|
+
this.state_senate_district_id = voter.state_senate_district_id
|
|
70
73
|
this.occupation_group = voter.occupation_group
|
|
71
74
|
this.occupation_description = voter.occupation_description
|
|
72
75
|
this.phone_home = voter.phone_home
|
|
@@ -106,9 +109,9 @@ export class Voter {
|
|
|
106
109
|
(voter.address_mail_city === undefined || typeof voter.address_mail_city === "string") &&
|
|
107
110
|
typeof voter.address_mail_state_id === "string" &&
|
|
108
111
|
(voter.address_mail_zip === undefined || typeof voter.address_mail_zip === "string") &&
|
|
109
|
-
typeof voter.
|
|
110
|
-
typeof voter.
|
|
111
|
-
typeof voter.
|
|
112
|
+
typeof voter.federal_house_district_id === "string" &&
|
|
113
|
+
typeof voter.state_house_district_id === "string" &&
|
|
114
|
+
typeof voter.state_senate_district_id === "string" &&
|
|
112
115
|
(voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
|
|
113
116
|
(voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
|
|
114
117
|
(voter.phone_home === undefined || typeof voter.phone_home === "string") &&
|
|
@@ -125,24 +128,24 @@ export class Voter {
|
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
export class VoterAux extends Voter {
|
|
132
|
+
readonly targets : VoterTarget[]
|
|
133
|
+
readonly turnouts : VoterTurnout[]
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
constructor(voter : any) {
|
|
136
|
+
if (!VoterAux.is(voter)) {
|
|
137
|
+
throw Error("Invalid input.")
|
|
138
|
+
}
|
|
139
|
+
super(voter)
|
|
140
|
+
this.targets = voter.targets
|
|
141
|
+
this.turnouts = voter.turnouts
|
|
142
|
+
}
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
static is(voter : any) : voter is Voter {
|
|
145
|
+
return (
|
|
146
|
+
Voter.is(voter) &&
|
|
147
|
+
Array.isArray(voter.targets) && voter.targets.every(VoterTarget.is) &&
|
|
148
|
+
Array.isArray(voter.turnouts) && voter.turnouts.every(VoterTurnout.is)
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { is_state_id, StateID } from "../State"
|
|
2
|
+
|
|
3
|
+
export class StateLegislatureDistrict {
|
|
4
|
+
readonly state_legislature_district_id : string
|
|
5
|
+
readonly legislature_id : number
|
|
6
|
+
readonly state_id : StateID
|
|
7
|
+
readonly chamber_id : string
|
|
8
|
+
readonly district_id : number
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
constructor(state_legislature_district : any) {
|
|
12
|
+
if (!StateLegislatureDistrict.is(state_legislature_district)) {
|
|
13
|
+
throw Error("Invalid input.")
|
|
14
|
+
}
|
|
15
|
+
this.state_legislature_district_id = state_legislature_district.state_legislature_district_id
|
|
16
|
+
this.legislature_id = state_legislature_district.legislature_id
|
|
17
|
+
this.state_id = state_legislature_district.state_id
|
|
18
|
+
this.chamber_id = state_legislature_district.chamber_id
|
|
19
|
+
this.district_id = state_legislature_district.district_id
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static is(state_legislature_district : any) : state_legislature_district is StateLegislatureDistrict {
|
|
23
|
+
return (
|
|
24
|
+
state_legislature_district !== undefined &&
|
|
25
|
+
typeof state_legislature_district.state_legislature_district_id === "string" &&
|
|
26
|
+
typeof state_legislature_district.legislature_id === "string" &&
|
|
27
|
+
is_state_id(state_legislature_district.state_id) &&
|
|
28
|
+
typeof state_legislature_district.chamber_id === "string" &&
|
|
29
|
+
typeof state_legislature_district === "number"
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|