triangle-types 1.0.82 → 1.0.84
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/prism/Voter.d.ts +6 -1
- package/dist/src/types/prism/Voter.js +10 -3
- package/dist/src/types/prism/VoterTarget.d.ts +2 -0
- package/dist/src/types/prism/VoterTarget.js +5 -1
- package/package.json +1 -1
- package/src/types/prism/Voter.ts +14 -3
- package/src/types/prism/VoterTarget.ts +5 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { StateID } from "../State.js";
|
|
2
2
|
import { VoterTarget } from "./VoterTarget.js";
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout.js";
|
|
4
|
+
declare const voter_party_type_ids: readonly ["D", "R", "I"];
|
|
5
|
+
export type VoterPartyTypeID = typeof voter_party_type_ids[number];
|
|
6
|
+
export declare function is_voter_party_type_id(voter_party_type_id: any): voter_party_type_id is VoterPartyTypeID;
|
|
4
7
|
export declare class Voter {
|
|
5
8
|
readonly voter_id: string;
|
|
6
9
|
readonly state_id: StateID;
|
|
@@ -27,6 +30,8 @@ export declare class Voter {
|
|
|
27
30
|
readonly federal_congress_district_id: string;
|
|
28
31
|
readonly state_legislature_house_district_id: string;
|
|
29
32
|
readonly state_legislature_senate_district_id: string;
|
|
33
|
+
readonly party_description?: string;
|
|
34
|
+
readonly party_type_id: VoterPartyTypeID;
|
|
30
35
|
readonly occupation_group?: string;
|
|
31
36
|
readonly occupation_description?: string;
|
|
32
37
|
readonly phone_home?: string;
|
|
@@ -35,7 +40,6 @@ export declare class Voter {
|
|
|
35
40
|
readonly ethnic_group?: string;
|
|
36
41
|
readonly ethnic_description?: string;
|
|
37
42
|
readonly religion_description?: string;
|
|
38
|
-
readonly party_description?: string;
|
|
39
43
|
readonly language?: string;
|
|
40
44
|
readonly education_level?: string;
|
|
41
45
|
readonly marital_status?: string;
|
|
@@ -49,3 +53,4 @@ export declare class VoterAux extends Voter {
|
|
|
49
53
|
constructor(voter: any);
|
|
50
54
|
static is(voter: any): voter is Voter;
|
|
51
55
|
}
|
|
56
|
+
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { is_state_id } from "../State.js";
|
|
2
2
|
import { VoterTarget } from "./VoterTarget.js";
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout.js";
|
|
4
|
+
const voter_party_type_ids = ["D", "R", "I"];
|
|
5
|
+
export function is_voter_party_type_id(voter_party_type_id) {
|
|
6
|
+
return voter_party_type_ids.includes(voter_party_type_id);
|
|
7
|
+
}
|
|
4
8
|
export class Voter {
|
|
5
9
|
voter_id;
|
|
6
10
|
state_id;
|
|
@@ -27,6 +31,8 @@ export class Voter {
|
|
|
27
31
|
federal_congress_district_id;
|
|
28
32
|
state_legislature_house_district_id;
|
|
29
33
|
state_legislature_senate_district_id;
|
|
34
|
+
party_description;
|
|
35
|
+
party_type_id;
|
|
30
36
|
occupation_group;
|
|
31
37
|
occupation_description;
|
|
32
38
|
phone_home;
|
|
@@ -35,7 +41,6 @@ export class Voter {
|
|
|
35
41
|
ethnic_group;
|
|
36
42
|
ethnic_description;
|
|
37
43
|
religion_description;
|
|
38
|
-
party_description;
|
|
39
44
|
language;
|
|
40
45
|
education_level;
|
|
41
46
|
marital_status;
|
|
@@ -68,6 +73,8 @@ export class Voter {
|
|
|
68
73
|
this.federal_congress_district_id = voter.federal_congress_district_id;
|
|
69
74
|
this.state_legislature_house_district_id = voter.state_legislature_house_district_id;
|
|
70
75
|
this.state_legislature_senate_district_id = voter.state_legislature_senate_district_id;
|
|
76
|
+
this.party_description = voter.party_description;
|
|
77
|
+
this.party_type_id = voter.party_type_id;
|
|
71
78
|
this.occupation_group = voter.occupation_group;
|
|
72
79
|
this.occupation_description = voter.occupation_description;
|
|
73
80
|
this.phone_home = voter.phone_home;
|
|
@@ -76,7 +83,6 @@ export class Voter {
|
|
|
76
83
|
this.ethnic_group = voter.ethnic_group;
|
|
77
84
|
this.ethnic_description = voter.ethnic_description;
|
|
78
85
|
this.religion_description = voter.religion_description;
|
|
79
|
-
this.party_description = voter.party_description;
|
|
80
86
|
this.language = voter.language;
|
|
81
87
|
this.education_level = voter.education_level;
|
|
82
88
|
this.marital_status = voter.marital_status;
|
|
@@ -108,6 +114,8 @@ export class Voter {
|
|
|
108
114
|
typeof voter.federal_congress_district_id === "string" &&
|
|
109
115
|
typeof voter.state_legislature_house_district_id === "string" &&
|
|
110
116
|
typeof voter.state_legislature_senate_district_id === "string" &&
|
|
117
|
+
(voter.party_description === undefined || typeof voter.party_description === "string") &&
|
|
118
|
+
is_voter_party_type_id(voter.party_type_id) &&
|
|
111
119
|
(voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
|
|
112
120
|
(voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
|
|
113
121
|
(voter.phone_home === undefined || typeof voter.phone_home === "string") &&
|
|
@@ -116,7 +124,6 @@ export class Voter {
|
|
|
116
124
|
(voter.ethnic_group === undefined || typeof voter.ethnic_group === "string") &&
|
|
117
125
|
(voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
|
|
118
126
|
(voter.religion_description === undefined || typeof voter.religion_description === "string") &&
|
|
119
|
-
(voter.party_description === undefined || typeof voter.party_description === "string") &&
|
|
120
127
|
(voter.language === undefined || typeof voter.language === "string") &&
|
|
121
128
|
(voter.education_level === undefined || typeof voter.education_level === "string") &&
|
|
122
129
|
(voter.marital_status === undefined || typeof voter.marital_status === "string"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StateID } from "../State.js";
|
|
2
|
+
import { VoterPartyTypeID } from "./Voter.js";
|
|
2
3
|
export declare class VoterTarget {
|
|
3
4
|
readonly voter_target_id: string;
|
|
4
5
|
readonly voter_id: string;
|
|
@@ -8,6 +9,7 @@ export declare class VoterTarget {
|
|
|
8
9
|
readonly federal_congress_district_id: string;
|
|
9
10
|
readonly state_legislature_house_district_id: string;
|
|
10
11
|
readonly state_legislature_senate_district_id: string;
|
|
12
|
+
readonly party_type_id: VoterPartyTypeID;
|
|
11
13
|
constructor(voter_target: any);
|
|
12
14
|
static is(voter_target: any): voter_target is VoterTarget;
|
|
13
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { is_state_id } from "../State.js";
|
|
2
|
+
import { is_voter_party_type_id } from "./Voter.js";
|
|
2
3
|
export class VoterTarget {
|
|
3
4
|
voter_target_id;
|
|
4
5
|
voter_id;
|
|
@@ -8,6 +9,7 @@ export class VoterTarget {
|
|
|
8
9
|
federal_congress_district_id;
|
|
9
10
|
state_legislature_house_district_id;
|
|
10
11
|
state_legislature_senate_district_id;
|
|
12
|
+
party_type_id;
|
|
11
13
|
constructor(voter_target) {
|
|
12
14
|
if (!VoterTarget.is(voter_target)) {
|
|
13
15
|
throw Error("Invalid input.");
|
|
@@ -20,6 +22,7 @@ export class VoterTarget {
|
|
|
20
22
|
this.federal_congress_district_id = voter_target.federal_congress_district_id;
|
|
21
23
|
this.state_legislature_house_district_id = voter_target.state_legislature_house_district_id;
|
|
22
24
|
this.state_legislature_senate_district_id = voter_target.state_legislature_senate_district_id;
|
|
25
|
+
this.party_type_id = voter_target.party_type_id;
|
|
23
26
|
}
|
|
24
27
|
static is(voter_target) {
|
|
25
28
|
return (voter_target !== undefined &&
|
|
@@ -30,6 +33,7 @@ export class VoterTarget {
|
|
|
30
33
|
is_state_id(voter_target.state_id) &&
|
|
31
34
|
typeof voter_target.federal_congress_district_id === "string" &&
|
|
32
35
|
typeof voter_target.state_legislature_house_district_id === "string" &&
|
|
33
|
-
typeof voter_target.state_legislature_senate_district_id === "string"
|
|
36
|
+
typeof voter_target.state_legislature_senate_district_id === "string" &&
|
|
37
|
+
is_voter_party_type_id(voter_target.party_type_id));
|
|
34
38
|
}
|
|
35
39
|
}
|
package/package.json
CHANGED
package/src/types/prism/Voter.ts
CHANGED
|
@@ -2,6 +2,14 @@ import { is_state_id, StateID } from "../State"
|
|
|
2
2
|
import { VoterTarget } from "./VoterTarget"
|
|
3
3
|
import { VoterTurnout } from "./VoterTurnout"
|
|
4
4
|
|
|
5
|
+
const voter_party_type_ids = ["D", "R", "I"] as const
|
|
6
|
+
|
|
7
|
+
export type VoterPartyTypeID = typeof voter_party_type_ids[number]
|
|
8
|
+
|
|
9
|
+
export function is_voter_party_type_id(voter_party_type_id : any) : voter_party_type_id is VoterPartyTypeID {
|
|
10
|
+
return voter_party_type_ids.includes(voter_party_type_id)
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
export class Voter {
|
|
6
14
|
readonly voter_id : string
|
|
7
15
|
readonly state_id : StateID
|
|
@@ -28,6 +36,8 @@ export class Voter {
|
|
|
28
36
|
readonly federal_congress_district_id : string
|
|
29
37
|
readonly state_legislature_house_district_id : string
|
|
30
38
|
readonly state_legislature_senate_district_id : string
|
|
39
|
+
readonly party_description? : string
|
|
40
|
+
readonly party_type_id : VoterPartyTypeID
|
|
31
41
|
readonly occupation_group? : string
|
|
32
42
|
readonly occupation_description? : string
|
|
33
43
|
readonly phone_home? : string
|
|
@@ -36,7 +46,6 @@ export class Voter {
|
|
|
36
46
|
readonly ethnic_group? : string
|
|
37
47
|
readonly ethnic_description? : string
|
|
38
48
|
readonly religion_description? : string
|
|
39
|
-
readonly party_description? : string
|
|
40
49
|
readonly language? : string
|
|
41
50
|
readonly education_level? : string
|
|
42
51
|
readonly marital_status? : string
|
|
@@ -71,6 +80,8 @@ export class Voter {
|
|
|
71
80
|
this.federal_congress_district_id = voter.federal_congress_district_id
|
|
72
81
|
this.state_legislature_house_district_id = voter.state_legislature_house_district_id
|
|
73
82
|
this.state_legislature_senate_district_id = voter.state_legislature_senate_district_id
|
|
83
|
+
this.party_description = voter.party_description
|
|
84
|
+
this.party_type_id = voter.party_type_id
|
|
74
85
|
this.occupation_group = voter.occupation_group
|
|
75
86
|
this.occupation_description = voter.occupation_description
|
|
76
87
|
this.phone_home = voter.phone_home
|
|
@@ -79,7 +90,6 @@ export class Voter {
|
|
|
79
90
|
this.ethnic_group = voter.ethnic_group
|
|
80
91
|
this.ethnic_description = voter.ethnic_description
|
|
81
92
|
this.religion_description = voter.religion_description
|
|
82
|
-
this.party_description = voter.party_description
|
|
83
93
|
this.language = voter.language
|
|
84
94
|
this.education_level = voter.education_level
|
|
85
95
|
this.marital_status = voter.marital_status
|
|
@@ -113,6 +123,8 @@ export class Voter {
|
|
|
113
123
|
typeof voter.federal_congress_district_id === "string" &&
|
|
114
124
|
typeof voter.state_legislature_house_district_id === "string" &&
|
|
115
125
|
typeof voter.state_legislature_senate_district_id === "string" &&
|
|
126
|
+
(voter.party_description === undefined || typeof voter.party_description === "string") &&
|
|
127
|
+
is_voter_party_type_id(voter.party_type_id) &&
|
|
116
128
|
(voter.occupation_group === undefined || typeof voter.occupation_group === "string") &&
|
|
117
129
|
(voter.occupation_description === undefined || typeof voter.occupation_description === "string") &&
|
|
118
130
|
(voter.phone_home === undefined || typeof voter.phone_home === "string") &&
|
|
@@ -121,7 +133,6 @@ export class Voter {
|
|
|
121
133
|
(voter.ethnic_group === undefined || typeof voter.ethnic_group === "string") &&
|
|
122
134
|
(voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
|
|
123
135
|
(voter.religion_description === undefined || typeof voter.religion_description === "string") &&
|
|
124
|
-
(voter.party_description === undefined || typeof voter.party_description === "string") &&
|
|
125
136
|
(voter.language === undefined || typeof voter.language === "string") &&
|
|
126
137
|
(voter.education_level === undefined || typeof voter.education_level === "string") &&
|
|
127
138
|
(voter.marital_status === undefined || typeof voter.marital_status === "string")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { is_state_id, StateID } from "../State"
|
|
2
|
+
import { is_voter_party_type_id, VoterPartyTypeID } from "./Voter"
|
|
2
3
|
|
|
3
4
|
export class VoterTarget {
|
|
4
5
|
readonly voter_target_id : string
|
|
@@ -9,6 +10,7 @@ export class VoterTarget {
|
|
|
9
10
|
readonly federal_congress_district_id : string
|
|
10
11
|
readonly state_legislature_house_district_id : string
|
|
11
12
|
readonly state_legislature_senate_district_id : string
|
|
13
|
+
readonly party_type_id : VoterPartyTypeID
|
|
12
14
|
|
|
13
15
|
constructor(voter_target : any) {
|
|
14
16
|
if (!VoterTarget.is(voter_target)) {
|
|
@@ -22,6 +24,7 @@ export class VoterTarget {
|
|
|
22
24
|
this.federal_congress_district_id = voter_target.federal_congress_district_id
|
|
23
25
|
this.state_legislature_house_district_id = voter_target.state_legislature_house_district_id
|
|
24
26
|
this.state_legislature_senate_district_id = voter_target.state_legislature_senate_district_id
|
|
27
|
+
this.party_type_id = voter_target.party_type_id
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
static is(voter_target : any) : voter_target is VoterTarget {
|
|
@@ -34,7 +37,8 @@ export class VoterTarget {
|
|
|
34
37
|
is_state_id(voter_target.state_id) &&
|
|
35
38
|
typeof voter_target.federal_congress_district_id === "string" &&
|
|
36
39
|
typeof voter_target.state_legislature_house_district_id === "string" &&
|
|
37
|
-
typeof voter_target.state_legislature_senate_district_id === "string"
|
|
40
|
+
typeof voter_target.state_legislature_senate_district_id === "string" &&
|
|
41
|
+
is_voter_party_type_id(voter_target.party_type_id)
|
|
38
42
|
)
|
|
39
43
|
}
|
|
40
44
|
}
|