triangle-types 1.0.49 → 1.0.50

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.
@@ -45,10 +45,12 @@ export * from "./types/legistar/LegistarAgency.js";
45
45
  export * from "./types/legistar/LegistarDocument.js";
46
46
  export * from "./types/prism/Prism.js";
47
47
  export * from "./types/prism/PrismMetric.js";
48
- export * from "./types/prism/PrismVoter.js";
49
48
  export * from "./types/prism/PrismSubPrism.js";
49
+ export * from "./types/prism/PrismTarget.js";
50
+ export * from "./types/prism/PrismVoter.js";
50
51
  export * from "./types/prism/UserPrism.js";
51
52
  export * from "./types/prism/Voter.js";
53
+ export * from "./types/prism/VoterTarget.js";
52
54
  export * from "./types/prism/VoterTurnout.js";
53
55
  export * from "./types/scout/Scout.js";
54
56
  export * from "./types/scout/ScoutDocument.js";
package/dist/src/index.js CHANGED
@@ -45,10 +45,12 @@ export * from "./types/legistar/LegistarAgency.js";
45
45
  export * from "./types/legistar/LegistarDocument.js";
46
46
  export * from "./types/prism/Prism.js";
47
47
  export * from "./types/prism/PrismMetric.js";
48
- export * from "./types/prism/PrismVoter.js";
49
48
  export * from "./types/prism/PrismSubPrism.js";
49
+ export * from "./types/prism/PrismTarget.js";
50
+ export * from "./types/prism/PrismVoter.js";
50
51
  export * from "./types/prism/UserPrism.js";
51
52
  export * from "./types/prism/Voter.js";
53
+ export * from "./types/prism/VoterTarget.js";
52
54
  export * from "./types/prism/VoterTurnout.js";
53
55
  export * from "./types/scout/Scout.js";
54
56
  export * from "./types/scout/ScoutDocument.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ // export const jurisdiction_type_ids = ["state", "federal_house_district", "state_house_district", "state_senate_district"] as const
2
+ export {};
3
+ // export type JurisdictionTypeID = typeof jurisdiction_type_ids[number]
4
+ // export function is_jurisdiction_type_id(jurisdiction_type_id : any) : jurisdiction_type_id is JurisdictionTypeID {
5
+ // return jurisdiction_type_ids.includes(jurisdiction_type_id)
6
+ // }
7
+ // export class Jurisdiction {
8
+ // readonly jurisdiction_id : string
9
+ // constructor(jurisdiction : any) {
10
+ // if (!Jurisdiction.is(jurisdiction)) {
11
+ // throw Error("Invalid input.")
12
+ // }
13
+ // this.jurisdiction_id = jurisdiction.jurisdiction_id
14
+ // }
15
+ // static is(jurisdiction : any) : jurisdiction is Jurisdiction {
16
+ // return (
17
+ // jurisdiction !== undefined &&
18
+ // typeof jurisdiction.jurisdiction_id === "string"
19
+ // )
20
+ // }
21
+ // }
@@ -1,6 +1,10 @@
1
+ import { StateID } from "../State.js";
1
2
  export declare class Prism {
2
3
  readonly prism_id: string;
3
- readonly state_id: string;
4
+ readonly state_id: StateID;
5
+ readonly federal_house_district?: number;
6
+ readonly state_house_district?: number;
7
+ readonly state_senate_district?: number;
4
8
  constructor(prism: any);
5
9
  static is(prism: any): prism is Prism;
6
10
  }
@@ -1,17 +1,27 @@
1
+ import { is_state_id } from "../State.js";
1
2
  export class Prism {
2
3
  prism_id;
3
4
  state_id;
5
+ federal_house_district;
6
+ state_house_district;
7
+ state_senate_district;
4
8
  constructor(prism) {
5
9
  if (!Prism.is(prism)) {
6
10
  throw Error("Invalid input.");
7
11
  }
8
12
  this.prism_id = prism.prism_id;
9
13
  this.state_id = prism.state_id;
14
+ this.federal_house_district = prism.federal_house_district;
15
+ this.state_house_district = prism.state_house_district;
16
+ this.state_senate_district = prism.state_senate_district;
10
17
  }
11
18
  static is(prism) {
12
19
  return (prism !== undefined &&
13
20
  typeof prism.prism_id === "string" &&
14
- typeof prism.state_id === "string");
21
+ is_state_id(prism.state_id) &&
22
+ (prism.federal_house_district === undefined || typeof prism.federal_house_district === "string") &&
23
+ (prism.state_house_district === undefined || typeof prism.state_house_district === "string") &&
24
+ (prism.state_senate_district === undefined || typeof prism.state_senate_district === "string"));
15
25
  }
16
26
  }
17
27
  // export class PrismAux extends Prism {
@@ -0,0 +1,7 @@
1
+ export declare class PrismTarget {
2
+ readonly prism_target_id: string;
3
+ readonly prism_id: string;
4
+ readonly target_id: string;
5
+ constructor(prism_target: any);
6
+ static is(prism_target: any): prism_target is PrismTarget;
7
+ }
@@ -0,0 +1,19 @@
1
+ export class PrismTarget {
2
+ prism_target_id;
3
+ prism_id;
4
+ target_id;
5
+ constructor(prism_target) {
6
+ if (!PrismTarget.is(prism_target)) {
7
+ throw Error("Invalid input.");
8
+ }
9
+ this.prism_target_id = prism_target.prism_target_id;
10
+ this.prism_id = prism_target.prism_id;
11
+ this.target_id = prism_target.target_id;
12
+ }
13
+ static is(prism_target) {
14
+ return (prism_target !== undefined &&
15
+ typeof prism_target.prism_target_id === "string" &&
16
+ typeof prism_target.prism_id === "string" &&
17
+ typeof prism_target.target_id === "string");
18
+ }
19
+ }
@@ -2,6 +2,7 @@ export declare class UserPrism {
2
2
  readonly user_prism_id: string;
3
3
  readonly user_id: string;
4
4
  readonly prism_id: string;
5
+ readonly target_id: string;
5
6
  constructor(user_prism: any);
6
7
  static is(user_prism: any): user_prism is UserPrism;
7
8
  }
@@ -2,6 +2,7 @@ export class UserPrism {
2
2
  user_prism_id;
3
3
  user_id;
4
4
  prism_id;
5
+ target_id;
5
6
  constructor(user_prism) {
6
7
  if (!UserPrism.is(user_prism)) {
7
8
  throw Error("Invalid input.");
@@ -9,11 +10,13 @@ export class UserPrism {
9
10
  this.user_prism_id = user_prism.user_prism_id;
10
11
  this.user_id = user_prism.user_id;
11
12
  this.prism_id = user_prism.prism_id;
13
+ this.target_id = user_prism.target_id;
12
14
  }
13
15
  static is(user_prism) {
14
16
  return (user_prism !== undefined &&
15
17
  typeof user_prism.user_prism_id === "string" &&
16
18
  typeof user_prism.user_id === "string" &&
17
- typeof user_prism.prism_id === "string");
19
+ typeof user_prism.prism_id === "string" &&
20
+ typeof user_prism.target_id === "string");
18
21
  }
19
22
  }
@@ -0,0 +1,8 @@
1
+ export declare class VoterTarget {
2
+ readonly voter_target_id: string;
3
+ readonly voter_id: string;
4
+ readonly prism_id: string;
5
+ readonly target_id: string;
6
+ constructor(voter_target: any);
7
+ static is(voter_target: any): voter_target is VoterTarget;
8
+ }
@@ -0,0 +1,22 @@
1
+ export class VoterTarget {
2
+ voter_target_id;
3
+ voter_id;
4
+ prism_id;
5
+ target_id;
6
+ constructor(voter_target) {
7
+ if (!VoterTarget.is(voter_target)) {
8
+ throw Error("Invalid input.");
9
+ }
10
+ this.voter_target_id = voter_target.voter_target_id;
11
+ this.voter_id = voter_target.voter_id;
12
+ this.prism_id = voter_target.prism_id;
13
+ this.target_id = voter_target.target_id;
14
+ }
15
+ static is(voter_target) {
16
+ return (voter_target !== undefined &&
17
+ typeof voter_target.voter_target_id === "string" &&
18
+ typeof voter_target.voter_id === "string" &&
19
+ typeof voter_target.prism_id === "string" &&
20
+ typeof voter_target.target_id === "string");
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -55,10 +55,12 @@ export * from "./types/legistar/LegistarDocument"
55
55
 
56
56
  export * from "./types/prism/Prism"
57
57
  export * from "./types/prism/PrismMetric"
58
- export * from "./types/prism/PrismVoter"
59
58
  export * from "./types/prism/PrismSubPrism"
59
+ export * from "./types/prism/PrismTarget"
60
+ export * from "./types/prism/PrismVoter"
60
61
  export * from "./types/prism/UserPrism"
61
62
  export * from "./types/prism/Voter"
63
+ export * from "./types/prism/VoterTarget"
62
64
  export * from "./types/prism/VoterTurnout"
63
65
 
64
66
  export * from "./types/scout/Scout"
@@ -0,0 +1,25 @@
1
+ // export const jurisdiction_type_ids = ["state", "federal_house_district", "state_house_district", "state_senate_district"] as const
2
+
3
+ // export type JurisdictionTypeID = typeof jurisdiction_type_ids[number]
4
+
5
+ // export function is_jurisdiction_type_id(jurisdiction_type_id : any) : jurisdiction_type_id is JurisdictionTypeID {
6
+ // return jurisdiction_type_ids.includes(jurisdiction_type_id)
7
+ // }
8
+
9
+ // export class Jurisdiction {
10
+ // readonly jurisdiction_id : string
11
+
12
+ // constructor(jurisdiction : any) {
13
+ // if (!Jurisdiction.is(jurisdiction)) {
14
+ // throw Error("Invalid input.")
15
+ // }
16
+ // this.jurisdiction_id = jurisdiction.jurisdiction_id
17
+ // }
18
+
19
+ // static is(jurisdiction : any) : jurisdiction is Jurisdiction {
20
+ // return (
21
+ // jurisdiction !== undefined &&
22
+ // typeof jurisdiction.jurisdiction_id === "string"
23
+ // )
24
+ // }
25
+ // }
@@ -1,6 +1,11 @@
1
+ import { is_state_id, StateID } from "../State"
2
+
1
3
  export class Prism {
2
4
  readonly prism_id : string
3
- readonly state_id : string
5
+ readonly state_id : StateID
6
+ readonly federal_house_district? : number
7
+ readonly state_house_district? : number
8
+ readonly state_senate_district? : number
4
9
 
5
10
  constructor(prism : any) {
6
11
  if (!Prism.is(prism)) {
@@ -8,13 +13,19 @@ export class Prism {
8
13
  }
9
14
  this.prism_id = prism.prism_id
10
15
  this.state_id = prism.state_id
16
+ this.federal_house_district = prism.federal_house_district
17
+ this.state_house_district = prism.state_house_district
18
+ this.state_senate_district = prism.state_senate_district
11
19
  }
12
20
 
13
21
  static is(prism : any) : prism is Prism {
14
22
  return (
15
23
  prism !== undefined &&
16
24
  typeof prism.prism_id === "string" &&
17
- typeof prism.state_id === "string"
25
+ is_state_id(prism.state_id) &&
26
+ (prism.federal_house_district === undefined || typeof prism.federal_house_district === "string") &&
27
+ (prism.state_house_district === undefined || typeof prism.state_house_district === "string") &&
28
+ (prism.state_senate_district === undefined || typeof prism.state_senate_district === "string")
18
29
  )
19
30
  }
20
31
  }
@@ -0,0 +1,23 @@
1
+ export class PrismTarget {
2
+ readonly prism_target_id : string
3
+ readonly prism_id : string
4
+ readonly target_id : string
5
+
6
+ constructor(prism_target : any) {
7
+ if (!PrismTarget.is(prism_target)) {
8
+ throw Error("Invalid input.")
9
+ }
10
+ this.prism_target_id = prism_target.prism_target_id
11
+ this.prism_id = prism_target.prism_id
12
+ this.target_id = prism_target.target_id
13
+ }
14
+
15
+ static is(prism_target : any) : prism_target is PrismTarget {
16
+ return (
17
+ prism_target !== undefined &&
18
+ typeof prism_target.prism_target_id === "string" &&
19
+ typeof prism_target.prism_id === "string" &&
20
+ typeof prism_target.target_id === "string"
21
+ )
22
+ }
23
+ }
@@ -2,6 +2,7 @@ export class UserPrism {
2
2
  readonly user_prism_id : string
3
3
  readonly user_id : string
4
4
  readonly prism_id : string
5
+ readonly target_id : string
5
6
 
6
7
  constructor(user_prism : any) {
7
8
  if (!UserPrism.is(user_prism)) {
@@ -10,6 +11,7 @@ export class UserPrism {
10
11
  this.user_prism_id = user_prism.user_prism_id
11
12
  this.user_id = user_prism.user_id
12
13
  this.prism_id = user_prism.prism_id
14
+ this.target_id = user_prism.target_id
13
15
  }
14
16
 
15
17
  static is(user_prism : any) : user_prism is UserPrism {
@@ -17,7 +19,8 @@ export class UserPrism {
17
19
  user_prism !== undefined &&
18
20
  typeof user_prism.user_prism_id === "string" &&
19
21
  typeof user_prism.user_id === "string" &&
20
- typeof user_prism.prism_id === "string"
22
+ typeof user_prism.prism_id === "string" &&
23
+ typeof user_prism.target_id === "string"
21
24
  )
22
25
  }
23
26
  }
@@ -0,0 +1,26 @@
1
+ export class VoterTarget {
2
+ readonly voter_target_id : string
3
+ readonly voter_id : string
4
+ readonly prism_id : string
5
+ readonly target_id : string
6
+
7
+ constructor(voter_target : any) {
8
+ if (!VoterTarget.is(voter_target)) {
9
+ throw Error("Invalid input.")
10
+ }
11
+ this.voter_target_id = voter_target.voter_target_id
12
+ this.voter_id = voter_target.voter_id
13
+ this.prism_id = voter_target.prism_id
14
+ this.target_id = voter_target.target_id
15
+ }
16
+
17
+ static is(voter_target : any) : voter_target is VoterTarget {
18
+ return (
19
+ voter_target !== undefined &&
20
+ typeof voter_target.voter_target_id === "string" &&
21
+ typeof voter_target.voter_id === "string" &&
22
+ typeof voter_target.prism_id === "string" &&
23
+ typeof voter_target.target_id === "string"
24
+ )
25
+ }
26
+ }