triangle-types 1.0.292 → 1.0.294

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.
@@ -4,6 +4,7 @@ import { County } from "./County.js";
4
4
  import { JurisdictionMetric } from "./JurisdictionMetric.js";
5
5
  import { Municipality } from "./Municipality.js";
6
6
  import { SchoolDistrict } from "./SchoolDistrict.js";
7
+ import { State } from "./State.js";
7
8
  export declare const jurisdiction_type_ids: readonly ["state", "federal_congress_district", "state_legislature_district", "county", "municipality", "school_district", "federal_census_tract", "federal_census_block"];
8
9
  export type JurisdictionTypeID = typeof jurisdiction_type_ids[number];
9
10
  export declare function is_jurisdiction_type_id(jurisdiction_type_id: any): jurisdiction_type_id is JurisdictionTypeID;
@@ -19,6 +20,12 @@ export declare class JurisdictionAux extends Jurisdiction {
19
20
  constructor(jurisdiction: any);
20
21
  static is(jurisdiction: any): jurisdiction is JurisdictionAux;
21
22
  }
23
+ export declare class StateJurisdictionAux extends JurisdictionAux {
24
+ readonly jurisdiction_type_id: "state";
25
+ readonly state: State;
26
+ constructor(jurisdiction: any);
27
+ static is(jurisdiction: any): jurisdiction is StateJurisdictionAux;
28
+ }
22
29
  export declare class CountyJurisdictionAux extends JurisdictionAux {
23
30
  readonly jurisdiction_type_id: "county";
24
31
  readonly county: County;
@@ -4,6 +4,7 @@ import { County } from "./County.js";
4
4
  import { JurisdictionMetric } from "./JurisdictionMetric.js";
5
5
  import { Municipality } from "./Municipality.js";
6
6
  import { SchoolDistrict } from "./SchoolDistrict.js";
7
+ import { State } from "./State.js";
7
8
  export const jurisdiction_type_ids = ["state", "federal_congress_district", "state_legislature_district", "county", "municipality", "school_district", "federal_census_tract", "federal_census_block"];
8
9
  export function is_jurisdiction_type_id(jurisdiction_type_id) {
9
10
  return jurisdiction_type_ids.includes(jurisdiction_type_id);
@@ -38,6 +39,23 @@ export class JurisdictionAux extends Jurisdiction {
38
39
  Array.isArray(jurisdiction.metrics) && jurisdiction.metrics.every(JurisdictionMetric.is));
39
40
  }
40
41
  }
42
+ export class StateJurisdictionAux extends JurisdictionAux {
43
+ jurisdiction_type_id;
44
+ state;
45
+ constructor(jurisdiction) {
46
+ if (!StateJurisdictionAux.is(jurisdiction)) {
47
+ throw Error("Invalid input.");
48
+ }
49
+ super(jurisdiction);
50
+ this.jurisdiction_type_id = jurisdiction.jurisdiction_type_id;
51
+ this.state = jurisdiction.state;
52
+ }
53
+ static is(jurisdiction) {
54
+ return (jurisdiction !== undefined &&
55
+ jurisdiction.jurisdiction_type_id === "state" &&
56
+ State.is(jurisdiction.state));
57
+ }
58
+ }
41
59
  export class CountyJurisdictionAux extends JurisdictionAux {
42
60
  jurisdiction_type_id;
43
61
  county;
@@ -1,5 +1,6 @@
1
1
  import { LALFileVoter } from "../lal/LALFileVoter.js";
2
2
  import { StateID } from "../jurisdictions/State.js";
3
+ import { StateVoterTarget } from "./StateVoterTarget.js";
3
4
  import { VoterPartyTypeID } from "./Voter.js";
4
5
  import { Geom } from "../jurisdictions/Geom.js";
5
6
  export declare class StateVoter {
@@ -24,11 +25,10 @@ export declare class StateVoter {
24
25
  readonly [x: string]: any;
25
26
  constructor(state_voter: any);
26
27
  static is(state_voter: any): state_voter is StateVoter;
27
- static keys(): string[];
28
28
  }
29
29
  export declare class StateVoterAux extends StateVoter {
30
30
  readonly lal_file_voter: LALFileVoter;
31
+ readonly targets: StateVoterTarget[];
31
32
  constructor(state_voter: any);
32
33
  static is(state_voter: any): state_voter is StateVoter;
33
- static keys(): string[];
34
34
  }
@@ -1,5 +1,6 @@
1
1
  import { LALFileVoter } from "../lal/LALFileVoter.js";
2
2
  import { is_state_id } from "../jurisdictions/State.js";
3
+ import { StateVoterTarget } from "./StateVoterTarget.js";
3
4
  import { is_voter_party_type_id } from "./Voter.js";
4
5
  import { Geom } from "../jurisdictions/Geom.js";
5
6
  export class StateVoter {
@@ -65,45 +66,21 @@ export class StateVoter {
65
66
  typeof state_voter.address_residence_coordinates_type_id === "string" &&
66
67
  is_voter_party_type_id(state_voter.party_type_id));
67
68
  }
68
- static keys() {
69
- return [
70
- "state_id",
71
- "voter_id",
72
- "lal_file_id",
73
- "lal_voter_id",
74
- "name_first",
75
- "name_middle",
76
- "name_last",
77
- "name_suffix",
78
- "address_residence_1",
79
- "address_residence_2",
80
- "address_residence_city",
81
- "address_residence_state_id",
82
- "address_residence_zip_id",
83
- "address_residence_latitude",
84
- "address_residence_longitude",
85
- "address_residence_coordinates_type_id",
86
- "party_type_id"
87
- ];
88
- }
89
69
  }
90
70
  export class StateVoterAux extends StateVoter {
91
71
  lal_file_voter;
72
+ targets;
92
73
  constructor(state_voter) {
93
74
  if (!StateVoterAux.is(state_voter)) {
94
75
  throw Error("Invalid input.");
95
76
  }
96
77
  super(state_voter);
97
78
  this.lal_file_voter = state_voter.lal_file_voter;
79
+ this.targets = state_voter.targets;
98
80
  }
99
81
  static is(state_voter) {
100
82
  return (StateVoter.is(state_voter) &&
101
- LALFileVoter.is(state_voter.lal_file_voter));
102
- }
103
- static keys() {
104
- return [
105
- ...StateVoter.keys(),
106
- "lal_file_voter"
107
- ];
83
+ LALFileVoter.is(state_voter.lal_file_voter) &&
84
+ Array.isArray(state_voter.targets) && state_voter.targets.every(StateVoterTarget.is));
108
85
  }
109
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.292",
3
+ "version": "1.0.294",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
@@ -4,6 +4,7 @@ import { County } from "./County"
4
4
  import { JurisdictionMetric } from "./JurisdictionMetric"
5
5
  import { Municipality } from "./Municipality"
6
6
  import { SchoolDistrict } from "./SchoolDistrict"
7
+ import { State } from "./State"
7
8
 
8
9
  export const jurisdiction_type_ids = ["state", "federal_congress_district", "state_legislature_district", "county", "municipality", "school_district", "federal_census_tract", "federal_census_block"] as const
9
10
 
@@ -56,6 +57,29 @@ export class JurisdictionAux extends Jurisdiction {
56
57
  }
57
58
  }
58
59
 
60
+ export class StateJurisdictionAux extends JurisdictionAux {
61
+ readonly jurisdiction_type_id : "state"
62
+ readonly state : State
63
+
64
+
65
+ constructor(jurisdiction : any) {
66
+ if (!StateJurisdictionAux.is(jurisdiction)) {
67
+ throw Error("Invalid input.")
68
+ }
69
+ super(jurisdiction)
70
+ this.jurisdiction_type_id = jurisdiction.jurisdiction_type_id
71
+ this.state = jurisdiction.state
72
+ }
73
+
74
+ static is(jurisdiction : any) : jurisdiction is StateJurisdictionAux {
75
+ return (
76
+ jurisdiction !== undefined &&
77
+ jurisdiction.jurisdiction_type_id === "state" &&
78
+ State.is(jurisdiction.state)
79
+ )
80
+ }
81
+ }
82
+
59
83
  export class CountyJurisdictionAux extends JurisdictionAux {
60
84
  readonly jurisdiction_type_id : "county"
61
85
  readonly county : County
@@ -73,32 +73,11 @@ export class StateVoter {
73
73
  is_voter_party_type_id(state_voter.party_type_id)
74
74
  )
75
75
  }
76
-
77
- static keys() : string[] {
78
- return [
79
- "state_id",
80
- "voter_id",
81
- "lal_file_id",
82
- "lal_voter_id",
83
- "name_first",
84
- "name_middle",
85
- "name_last",
86
- "name_suffix",
87
- "address_residence_1",
88
- "address_residence_2",
89
- "address_residence_city",
90
- "address_residence_state_id",
91
- "address_residence_zip_id",
92
- "address_residence_latitude",
93
- "address_residence_longitude",
94
- "address_residence_coordinates_type_id",
95
- "party_type_id"
96
- ]
97
- }
98
76
  }
99
77
 
100
78
  export class StateVoterAux extends StateVoter {
101
79
  readonly lal_file_voter : LALFileVoter
80
+ readonly targets : StateVoterTarget[]
102
81
 
103
82
  constructor(state_voter : any) {
104
83
  if (!StateVoterAux.is(state_voter)) {
@@ -106,19 +85,14 @@ export class StateVoterAux extends StateVoter {
106
85
  }
107
86
  super(state_voter)
108
87
  this.lal_file_voter = state_voter.lal_file_voter
88
+ this.targets = state_voter.targets
109
89
  }
110
90
 
111
91
  static is(state_voter : any) : state_voter is StateVoter {
112
92
  return (
113
93
  StateVoter.is(state_voter) &&
114
- LALFileVoter.is(state_voter.lal_file_voter)
94
+ LALFileVoter.is(state_voter.lal_file_voter) &&
95
+ Array.isArray(state_voter.targets) && state_voter.targets.every(StateVoterTarget.is)
115
96
  )
116
97
  }
117
-
118
- static keys() : string[] {
119
- return [
120
- ...StateVoter.keys(),
121
- "lal_file_voter"
122
- ]
123
- }
124
98
  }