triangle-types 1.0.58 → 1.0.60
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/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/types/prism/Prism.d.ts +8 -0
- package/dist/src/types/prism/Prism.js +18 -19
- package/dist/src/types/prism/PrismSegment.d.ts +23 -0
- package/dist/src/types/prism/PrismSegment.js +54 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/prism/Prism.ts +21 -19
- package/src/types/prism/PrismSegment.ts +71 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export * from "./types/legistar/LegistarDocument.js";
|
|
|
47
47
|
export * from "./types/prism/Prism.js";
|
|
48
48
|
export * from "./types/prism/PrismMetric.js";
|
|
49
49
|
export * from "./types/prism/PrismSubPrism.js";
|
|
50
|
+
export * from "./types/prism/PrismSegment.js";
|
|
50
51
|
export * from "./types/prism/PrismTarget.js";
|
|
51
52
|
export * from "./types/prism/UserPrism.js";
|
|
52
53
|
export * from "./types/prism/Voter.js";
|
package/dist/src/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export * from "./types/legistar/LegistarDocument.js";
|
|
|
47
47
|
export * from "./types/prism/Prism.js";
|
|
48
48
|
export * from "./types/prism/PrismMetric.js";
|
|
49
49
|
export * from "./types/prism/PrismSubPrism.js";
|
|
50
|
+
export * from "./types/prism/PrismSegment.js";
|
|
50
51
|
export * from "./types/prism/PrismTarget.js";
|
|
51
52
|
export * from "./types/prism/UserPrism.js";
|
|
52
53
|
export * from "./types/prism/Voter.js";
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { StateID } from "../State.js";
|
|
2
|
+
import { PrismTarget } from "./PrismTarget.js";
|
|
2
3
|
export declare class Prism {
|
|
3
4
|
readonly prism_id: string;
|
|
4
5
|
readonly state_id: StateID;
|
|
6
|
+
readonly name: string;
|
|
5
7
|
readonly federal_congress_district_id?: string;
|
|
6
8
|
readonly state_legislature_house_district_id?: string;
|
|
7
9
|
readonly state_legislature_senate_district_id?: string;
|
|
10
|
+
readonly [x: string]: any;
|
|
11
|
+
constructor(prism: any);
|
|
12
|
+
static is(prism: any): prism is Prism;
|
|
13
|
+
}
|
|
14
|
+
export declare class PrismAux extends Prism {
|
|
15
|
+
readonly targets: PrismTarget[];
|
|
8
16
|
constructor(prism: any);
|
|
9
17
|
static is(prism: any): prism is Prism;
|
|
10
18
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { is_state_id } from "../State.js";
|
|
2
|
+
import { PrismTarget } from "./PrismTarget.js";
|
|
2
3
|
export class Prism {
|
|
3
4
|
prism_id;
|
|
4
5
|
state_id;
|
|
6
|
+
name;
|
|
5
7
|
federal_congress_district_id;
|
|
6
8
|
state_legislature_house_district_id;
|
|
7
9
|
state_legislature_senate_district_id;
|
|
@@ -11,6 +13,7 @@ export class Prism {
|
|
|
11
13
|
}
|
|
12
14
|
this.prism_id = prism.prism_id;
|
|
13
15
|
this.state_id = prism.state_id;
|
|
16
|
+
this.name = prism.name;
|
|
14
17
|
this.federal_congress_district_id = prism.federal_congress_district_id;
|
|
15
18
|
this.state_legislature_house_district_id = prism.state_legislature_house_district_id;
|
|
16
19
|
this.state_legislature_senate_district_id = prism.state_legislature_senate_district_id;
|
|
@@ -19,27 +22,23 @@ export class Prism {
|
|
|
19
22
|
return (prism !== undefined &&
|
|
20
23
|
typeof prism.prism_id === "string" &&
|
|
21
24
|
is_state_id(prism.state_id) &&
|
|
25
|
+
typeof prism.name === "string" &&
|
|
22
26
|
(prism.federal_congress_district_id === undefined || typeof prism.federal_congress_district_id === "string") &&
|
|
23
27
|
(prism.state_legislature_house_district_id === undefined || typeof prism.state_legislature_house_district_id === "string") &&
|
|
24
28
|
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string"));
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Array.isArray(prism.scores) && prism.scores.every(PrismScore.is) &&
|
|
42
|
-
// Array.isArray(prism.turnouts) && prism.turnouts.every(PrismTurnout.is)
|
|
43
|
-
// )
|
|
44
|
-
// }
|
|
45
|
-
// }
|
|
31
|
+
export class PrismAux extends Prism {
|
|
32
|
+
targets;
|
|
33
|
+
constructor(prism) {
|
|
34
|
+
if (!PrismAux.is(prism)) {
|
|
35
|
+
throw Error("Invalid input.");
|
|
36
|
+
}
|
|
37
|
+
super(prism);
|
|
38
|
+
this.targets = prism.targets;
|
|
39
|
+
}
|
|
40
|
+
static is(prism) {
|
|
41
|
+
return (Prism.is(prism) &&
|
|
42
|
+
Array.isArray(prism.targets) && prism.targets.every(PrismTarget.is));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class PrismSegment {
|
|
2
|
+
readonly prism_segment_id: string;
|
|
3
|
+
readonly prism_id: string;
|
|
4
|
+
readonly segment_id: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly min_value: number;
|
|
7
|
+
readonly max_value: number;
|
|
8
|
+
readonly [x: string]: any;
|
|
9
|
+
constructor(prism_segment: any);
|
|
10
|
+
static is(prism_segment: any): prism_segment is PrismSegment;
|
|
11
|
+
}
|
|
12
|
+
export declare class PrismFeatureSegment {
|
|
13
|
+
readonly feature_id: string;
|
|
14
|
+
readonly [x: string]: any;
|
|
15
|
+
constructor(prism_segment: any);
|
|
16
|
+
static is(prism_segment: any): prism_segment is PrismFeatureSegment;
|
|
17
|
+
}
|
|
18
|
+
export declare class PrismTargetSegment {
|
|
19
|
+
readonly target_id: string;
|
|
20
|
+
readonly [x: string]: any;
|
|
21
|
+
constructor(prism_segment: any);
|
|
22
|
+
static is(prism_segment: any): prism_segment is PrismTargetSegment;
|
|
23
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class PrismSegment {
|
|
2
|
+
prism_segment_id;
|
|
3
|
+
prism_id;
|
|
4
|
+
segment_id;
|
|
5
|
+
name;
|
|
6
|
+
min_value;
|
|
7
|
+
max_value;
|
|
8
|
+
constructor(prism_segment) {
|
|
9
|
+
if (!PrismSegment.is(prism_segment)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.prism_segment_id = prism_segment.prism_segment_id;
|
|
13
|
+
this.prism_id = prism_segment.prism_id;
|
|
14
|
+
this.segment_id = prism_segment.segment_id;
|
|
15
|
+
this.name = prism_segment.name;
|
|
16
|
+
this.min_value = prism_segment.min_value;
|
|
17
|
+
this.max_value = prism_segment.max_value;
|
|
18
|
+
}
|
|
19
|
+
static is(prism_segment) {
|
|
20
|
+
return (prism_segment !== undefined &&
|
|
21
|
+
typeof prism_segment.prism_segment_id === "string" &&
|
|
22
|
+
typeof prism_segment.prism_id === "string" &&
|
|
23
|
+
typeof prism_segment.segment_id === "string" &&
|
|
24
|
+
typeof prism_segment.name === "string" &&
|
|
25
|
+
typeof prism_segment.min_value === "number" &&
|
|
26
|
+
typeof prism_segment.max_value === "number");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class PrismFeatureSegment {
|
|
30
|
+
feature_id;
|
|
31
|
+
constructor(prism_segment) {
|
|
32
|
+
if (!PrismFeatureSegment.is(prism_segment)) {
|
|
33
|
+
throw Error("Invalid input.");
|
|
34
|
+
}
|
|
35
|
+
this.feature_id = prism_segment.feature_id;
|
|
36
|
+
}
|
|
37
|
+
static is(prism_segment) {
|
|
38
|
+
return (PrismFeatureSegment.is(prism_segment) &&
|
|
39
|
+
typeof prism_segment.feature_id === "string");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class PrismTargetSegment {
|
|
43
|
+
target_id;
|
|
44
|
+
constructor(prism_segment) {
|
|
45
|
+
if (!PrismTargetSegment.is(prism_segment)) {
|
|
46
|
+
throw Error("Invalid input.");
|
|
47
|
+
}
|
|
48
|
+
this.target_id = prism_segment.target_id;
|
|
49
|
+
}
|
|
50
|
+
static is(prism_segment) {
|
|
51
|
+
return (PrismTargetSegment.is(prism_segment) &&
|
|
52
|
+
typeof prism_segment.target_id === "string");
|
|
53
|
+
}
|
|
54
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -57,6 +57,7 @@ export * from "./types/legistar/LegistarDocument"
|
|
|
57
57
|
export * from "./types/prism/Prism"
|
|
58
58
|
export * from "./types/prism/PrismMetric"
|
|
59
59
|
export * from "./types/prism/PrismSubPrism"
|
|
60
|
+
export * from "./types/prism/PrismSegment"
|
|
60
61
|
export * from "./types/prism/PrismTarget"
|
|
61
62
|
export * from "./types/prism/UserPrism"
|
|
62
63
|
export * from "./types/prism/Voter"
|
package/src/types/prism/Prism.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { is_state_id, StateID } from "../State"
|
|
2
|
+
import { PrismTarget } from "./PrismTarget"
|
|
2
3
|
|
|
3
4
|
export class Prism {
|
|
4
5
|
readonly prism_id : string
|
|
5
6
|
readonly state_id : StateID
|
|
7
|
+
readonly name : string
|
|
6
8
|
readonly federal_congress_district_id? : string
|
|
7
9
|
readonly state_legislature_house_district_id? : string
|
|
8
10
|
readonly state_legislature_senate_district_id? : string
|
|
11
|
+
readonly [x : string] : any
|
|
9
12
|
|
|
10
13
|
constructor(prism : any) {
|
|
11
14
|
if (!Prism.is(prism)) {
|
|
@@ -13,6 +16,7 @@ export class Prism {
|
|
|
13
16
|
}
|
|
14
17
|
this.prism_id = prism.prism_id
|
|
15
18
|
this.state_id = prism.state_id
|
|
19
|
+
this.name = prism.name
|
|
16
20
|
this.federal_congress_district_id = prism.federal_congress_district_id
|
|
17
21
|
this.state_legislature_house_district_id = prism.state_legislature_house_district_id
|
|
18
22
|
this.state_legislature_senate_district_id = prism.state_legislature_senate_district_id
|
|
@@ -23,6 +27,7 @@ export class Prism {
|
|
|
23
27
|
prism !== undefined &&
|
|
24
28
|
typeof prism.prism_id === "string" &&
|
|
25
29
|
is_state_id(prism.state_id) &&
|
|
30
|
+
typeof prism.name === "string" &&
|
|
26
31
|
(prism.federal_congress_district_id === undefined || typeof prism.federal_congress_district_id === "string") &&
|
|
27
32
|
(prism.state_legislature_house_district_id === undefined || typeof prism.state_legislature_house_district_id === "string") &&
|
|
28
33
|
(prism.state_legislature_senate_district_id === undefined || typeof prism.state_legislature_senate_district_id === "string")
|
|
@@ -30,24 +35,21 @@ export class Prism {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// readonly turnouts : PrismTurnout[]
|
|
38
|
+
export class PrismAux extends Prism {
|
|
39
|
+
readonly targets : PrismTarget[]
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// }
|
|
41
|
+
constructor(prism : any) {
|
|
42
|
+
if (!PrismAux.is(prism)) {
|
|
43
|
+
throw Error("Invalid input.")
|
|
44
|
+
}
|
|
45
|
+
super(prism)
|
|
46
|
+
this.targets = prism.targets
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// }
|
|
49
|
+
static is(prism : any) : prism is Prism {
|
|
50
|
+
return (
|
|
51
|
+
Prism.is(prism) &&
|
|
52
|
+
Array.isArray(prism.targets) && prism.targets.every(PrismTarget.is)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class PrismSegment {
|
|
2
|
+
readonly prism_segment_id : string
|
|
3
|
+
readonly prism_id : string
|
|
4
|
+
readonly segment_id : string
|
|
5
|
+
readonly name : string
|
|
6
|
+
readonly min_value : number
|
|
7
|
+
readonly max_value : number
|
|
8
|
+
readonly [x : string] : any
|
|
9
|
+
|
|
10
|
+
constructor(prism_segment : any) {
|
|
11
|
+
if (!PrismSegment.is(prism_segment)) {
|
|
12
|
+
throw Error("Invalid input.")
|
|
13
|
+
}
|
|
14
|
+
this.prism_segment_id = prism_segment.prism_segment_id
|
|
15
|
+
this.prism_id = prism_segment.prism_id
|
|
16
|
+
this.segment_id = prism_segment.segment_id
|
|
17
|
+
this.name = prism_segment.name
|
|
18
|
+
this.min_value = prism_segment.min_value
|
|
19
|
+
this.max_value = prism_segment.max_value
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static is(prism_segment : any) : prism_segment is PrismSegment {
|
|
23
|
+
return (
|
|
24
|
+
prism_segment !== undefined &&
|
|
25
|
+
typeof prism_segment.prism_segment_id === "string" &&
|
|
26
|
+
typeof prism_segment.prism_id === "string" &&
|
|
27
|
+
typeof prism_segment.segment_id === "string" &&
|
|
28
|
+
typeof prism_segment.name === "string" &&
|
|
29
|
+
typeof prism_segment.min_value === "number" &&
|
|
30
|
+
typeof prism_segment.max_value === "number"
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class PrismFeatureSegment {
|
|
36
|
+
readonly feature_id : string
|
|
37
|
+
readonly [x : string] : any
|
|
38
|
+
|
|
39
|
+
constructor(prism_segment : any) {
|
|
40
|
+
if (!PrismFeatureSegment.is(prism_segment)) {
|
|
41
|
+
throw Error("Invalid input.")
|
|
42
|
+
}
|
|
43
|
+
this.feature_id = prism_segment.feature_id
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static is(prism_segment : any) : prism_segment is PrismFeatureSegment {
|
|
47
|
+
return (
|
|
48
|
+
PrismFeatureSegment.is(prism_segment) &&
|
|
49
|
+
typeof prism_segment.feature_id === "string"
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class PrismTargetSegment {
|
|
55
|
+
readonly target_id : string
|
|
56
|
+
readonly [x : string] : any
|
|
57
|
+
|
|
58
|
+
constructor(prism_segment : any) {
|
|
59
|
+
if (!PrismTargetSegment.is(prism_segment)) {
|
|
60
|
+
throw Error("Invalid input.")
|
|
61
|
+
}
|
|
62
|
+
this.target_id = prism_segment.target_id
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static is(prism_segment : any) : prism_segment is PrismTargetSegment {
|
|
66
|
+
return (
|
|
67
|
+
PrismTargetSegment.is(prism_segment) &&
|
|
68
|
+
typeof prism_segment.target_id === "string"
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|