triangle-types 1.0.81 → 1.0.83

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.
@@ -49,6 +49,7 @@ export * from "./types/fragments/FragmentVector.js";
49
49
  export * from "./types/legistar/LegistarAgency.js";
50
50
  export * from "./types/legistar/LegistarDocument.js";
51
51
  export * from "./types/prism/Prism.js";
52
+ export * from "./types/prism/PrismFeature.js";
52
53
  export * from "./types/prism/PrismMetric.js";
53
54
  export * from "./types/prism/PrismSubPrism.js";
54
55
  export * from "./types/prism/PrismSegment.js";
@@ -56,6 +57,7 @@ export * from "./types/prism/PrismTarget.js";
56
57
  export * from "./types/prism/UserPrism.js";
57
58
  export * from "./types/prism/UserPrismSegment.js";
58
59
  export * from "./types/prism/Voter.js";
60
+ export * from "./types/prism/VoterFeature.js";
59
61
  export * from "./types/prism/VoterTarget.js";
60
62
  export * from "./types/prism/VoterTurnout.js";
61
63
  export * from "./types/scout/Scout.js";
package/dist/src/index.js CHANGED
@@ -49,6 +49,7 @@ export * from "./types/fragments/FragmentVector.js";
49
49
  export * from "./types/legistar/LegistarAgency.js";
50
50
  export * from "./types/legistar/LegistarDocument.js";
51
51
  export * from "./types/prism/Prism.js";
52
+ export * from "./types/prism/PrismFeature.js";
52
53
  export * from "./types/prism/PrismMetric.js";
53
54
  export * from "./types/prism/PrismSubPrism.js";
54
55
  export * from "./types/prism/PrismSegment.js";
@@ -56,6 +57,7 @@ export * from "./types/prism/PrismTarget.js";
56
57
  export * from "./types/prism/UserPrism.js";
57
58
  export * from "./types/prism/UserPrismSegment.js";
58
59
  export * from "./types/prism/Voter.js";
60
+ export * from "./types/prism/VoterFeature.js";
59
61
  export * from "./types/prism/VoterTarget.js";
60
62
  export * from "./types/prism/VoterTurnout.js";
61
63
  export * from "./types/scout/Scout.js";
@@ -0,0 +1,7 @@
1
+ export declare class PrismFeature {
2
+ readonly prism_feature_id: string;
3
+ readonly prism_id: string;
4
+ readonly feature_id: string;
5
+ constructor(prism_feature: any);
6
+ static is(prism_feature: any): prism_feature is PrismFeature;
7
+ }
@@ -0,0 +1,19 @@
1
+ export class PrismFeature {
2
+ prism_feature_id;
3
+ prism_id;
4
+ feature_id;
5
+ constructor(prism_feature) {
6
+ if (!PrismFeature.is(prism_feature)) {
7
+ throw Error("Invalid input.");
8
+ }
9
+ this.prism_feature_id = prism_feature.prism_feature_id;
10
+ this.prism_id = prism_feature.prism_id;
11
+ this.feature_id = prism_feature.feature_id;
12
+ }
13
+ static is(prism_feature) {
14
+ return (prism_feature !== undefined &&
15
+ typeof prism_feature.prism_feature_id === "string" &&
16
+ typeof prism_feature.prism_id === "string" &&
17
+ typeof prism_feature.feature_id === "string");
18
+ }
19
+ }
@@ -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;
@@ -36,6 +39,7 @@ export declare class Voter {
36
39
  readonly ethnic_description?: string;
37
40
  readonly religion_description?: string;
38
41
  readonly party_description?: string;
42
+ readonly party_type_id?: VoterPartyTypeID;
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;
@@ -36,6 +40,7 @@ export class Voter {
36
40
  ethnic_description;
37
41
  religion_description;
38
42
  party_description;
43
+ party_type_id;
39
44
  language;
40
45
  education_level;
41
46
  marital_status;
@@ -77,6 +82,7 @@ export class Voter {
77
82
  this.ethnic_description = voter.ethnic_description;
78
83
  this.religion_description = voter.religion_description;
79
84
  this.party_description = voter.party_description;
85
+ this.party_type_id = voter.party_type_id;
80
86
  this.language = voter.language;
81
87
  this.education_level = voter.education_level;
82
88
  this.marital_status = voter.marital_status;
@@ -117,6 +123,7 @@ export class Voter {
117
123
  (voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
118
124
  (voter.religion_description === undefined || typeof voter.religion_description === "string") &&
119
125
  (voter.party_description === undefined || typeof voter.party_description === "string") &&
126
+ (voter.party_type_id === undefined || is_voter_party_type_id(voter.party_type_id)) &&
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"));
@@ -0,0 +1,13 @@
1
+ import { StateID } from "../State.js";
2
+ export declare class VoterFeature {
3
+ readonly voter_feature_id: string;
4
+ readonly voter_id: string;
5
+ readonly feature_id: string;
6
+ readonly value: number;
7
+ readonly state_id: StateID;
8
+ readonly federal_congress_district_id: string;
9
+ readonly state_legislature_house_district_id: string;
10
+ readonly state_legislature_senate_district_id: string;
11
+ constructor(voter_feature: any);
12
+ static is(voter_feature: any): voter_feature is VoterFeature;
13
+ }
@@ -0,0 +1,35 @@
1
+ import { is_state_id } from "../State.js";
2
+ export class VoterFeature {
3
+ voter_feature_id;
4
+ voter_id;
5
+ feature_id;
6
+ value;
7
+ state_id;
8
+ federal_congress_district_id;
9
+ state_legislature_house_district_id;
10
+ state_legislature_senate_district_id;
11
+ constructor(voter_feature) {
12
+ if (!VoterFeature.is(voter_feature)) {
13
+ throw Error("Invalid input.");
14
+ }
15
+ this.voter_feature_id = voter_feature.voter_feature_id;
16
+ this.voter_id = voter_feature.voter_id;
17
+ this.feature_id = voter_feature.feature_id;
18
+ this.value = voter_feature.value;
19
+ this.state_id = voter_feature.state_id;
20
+ this.federal_congress_district_id = voter_feature.federal_congress_district_id;
21
+ this.state_legislature_house_district_id = voter_feature.state_legislature_house_district_id;
22
+ this.state_legislature_senate_district_id = voter_feature.state_legislature_senate_district_id;
23
+ }
24
+ static is(voter_feature) {
25
+ return (voter_feature !== undefined &&
26
+ typeof voter_feature.voter_feature_id === "string" &&
27
+ typeof voter_feature.voter_id === "string" &&
28
+ typeof voter_feature.feature_id === "string" &&
29
+ typeof voter_feature.value === "number" &&
30
+ is_state_id(voter_feature.state_id) &&
31
+ typeof voter_feature.federal_congress_district_id === "string" &&
32
+ typeof voter_feature.state_legislature_house_district_id === "string" &&
33
+ typeof voter_feature.state_legislature_senate_district_id === "string");
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -59,6 +59,7 @@ export * from "./types/legistar/LegistarAgency"
59
59
  export * from "./types/legistar/LegistarDocument"
60
60
 
61
61
  export * from "./types/prism/Prism"
62
+ export * from "./types/prism/PrismFeature"
62
63
  export * from "./types/prism/PrismMetric"
63
64
  export * from "./types/prism/PrismSubPrism"
64
65
  export * from "./types/prism/PrismSegment"
@@ -66,6 +67,7 @@ export * from "./types/prism/PrismTarget"
66
67
  export * from "./types/prism/UserPrism"
67
68
  export * from "./types/prism/UserPrismSegment"
68
69
  export * from "./types/prism/Voter"
70
+ export * from "./types/prism/VoterFeature"
69
71
  export * from "./types/prism/VoterTarget"
70
72
  export * from "./types/prism/VoterTurnout"
71
73
 
@@ -0,0 +1,23 @@
1
+ export class PrismFeature {
2
+ readonly prism_feature_id : string
3
+ readonly prism_id : string
4
+ readonly feature_id : string
5
+
6
+ constructor(prism_feature : any) {
7
+ if (!PrismFeature.is(prism_feature)) {
8
+ throw Error("Invalid input.")
9
+ }
10
+ this.prism_feature_id = prism_feature.prism_feature_id
11
+ this.prism_id = prism_feature.prism_id
12
+ this.feature_id = prism_feature.feature_id
13
+ }
14
+
15
+ static is(prism_feature : any) : prism_feature is PrismFeature {
16
+ return (
17
+ prism_feature !== undefined &&
18
+ typeof prism_feature.prism_feature_id === "string" &&
19
+ typeof prism_feature.prism_id === "string" &&
20
+ typeof prism_feature.feature_id === "string"
21
+ )
22
+ }
23
+ }
@@ -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
@@ -37,6 +45,7 @@ export class Voter {
37
45
  readonly ethnic_description? : string
38
46
  readonly religion_description? : string
39
47
  readonly party_description? : string
48
+ readonly party_type_id? : VoterPartyTypeID
40
49
  readonly language? : string
41
50
  readonly education_level? : string
42
51
  readonly marital_status? : string
@@ -80,6 +89,7 @@ export class Voter {
80
89
  this.ethnic_description = voter.ethnic_description
81
90
  this.religion_description = voter.religion_description
82
91
  this.party_description = voter.party_description
92
+ this.party_type_id = voter.party_type_id
83
93
  this.language = voter.language
84
94
  this.education_level = voter.education_level
85
95
  this.marital_status = voter.marital_status
@@ -122,6 +132,7 @@ export class Voter {
122
132
  (voter.ethnic_description === undefined || typeof voter.ethnic_description === "string") &&
123
133
  (voter.religion_description === undefined || typeof voter.religion_description === "string") &&
124
134
  (voter.party_description === undefined || typeof voter.party_description === "string") &&
135
+ (voter.party_type_id === undefined || is_voter_party_type_id(voter.party_type_id)) &&
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")
@@ -0,0 +1,40 @@
1
+ import { is_state_id, StateID } from "../State"
2
+
3
+ export class VoterFeature {
4
+ readonly voter_feature_id : string
5
+ readonly voter_id : string
6
+ readonly feature_id : string
7
+ readonly value : number
8
+ readonly state_id : StateID
9
+ readonly federal_congress_district_id : string
10
+ readonly state_legislature_house_district_id : string
11
+ readonly state_legislature_senate_district_id : string
12
+
13
+ constructor(voter_feature : any) {
14
+ if (!VoterFeature.is(voter_feature)) {
15
+ throw Error("Invalid input.")
16
+ }
17
+ this.voter_feature_id = voter_feature.voter_feature_id
18
+ this.voter_id = voter_feature.voter_id
19
+ this.feature_id = voter_feature.feature_id
20
+ this.value = voter_feature.value
21
+ this.state_id = voter_feature.state_id
22
+ this.federal_congress_district_id = voter_feature.federal_congress_district_id
23
+ this.state_legislature_house_district_id = voter_feature.state_legislature_house_district_id
24
+ this.state_legislature_senate_district_id = voter_feature.state_legislature_senate_district_id
25
+ }
26
+
27
+ static is(voter_feature : any) : voter_feature is VoterFeature {
28
+ return (
29
+ voter_feature !== undefined &&
30
+ typeof voter_feature.voter_feature_id === "string" &&
31
+ typeof voter_feature.voter_id === "string" &&
32
+ typeof voter_feature.feature_id === "string" &&
33
+ typeof voter_feature.value === "number" &&
34
+ is_state_id(voter_feature.state_id) &&
35
+ typeof voter_feature.federal_congress_district_id === "string" &&
36
+ typeof voter_feature.state_legislature_house_district_id === "string" &&
37
+ typeof voter_feature.state_legislature_senate_district_id === "string"
38
+ )
39
+ }
40
+ }