triangle-types 1.0.139 → 1.0.141

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.
@@ -7,7 +7,7 @@ export declare class FederalElectionCandidate {
7
7
  readonly federal_election_candidate_id: string;
8
8
  readonly name: string;
9
9
  readonly federal_election_office_id: FederalElectionOfficeID;
10
- readonly state_id: StateID;
10
+ readonly state_id?: StateID;
11
11
  readonly district_id?: number;
12
12
  readonly federal_election_id: string;
13
13
  readonly party_id?: string;
@@ -53,7 +53,7 @@ export class FederalElectionCandidate {
53
53
  typeof federal_election_candidate.federal_election_candidate_id === "string" &&
54
54
  typeof federal_election_candidate.name === "string" &&
55
55
  is_federal_election_office_id(federal_election_candidate.federal_election_office_id) &&
56
- is_state_id(federal_election_candidate.state_id) &&
56
+ (federal_election_candidate.state_id === undefined || is_state_id(federal_election_candidate.state_id)) &&
57
57
  (federal_election_candidate.district_id === undefined || typeof federal_election_candidate.district_id === "number") &&
58
58
  typeof federal_election_candidate.federal_election_id === "string" &&
59
59
  (federal_election_candidate.party_id === undefined || typeof federal_election_candidate.party_id === "string") &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-types",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -64,7 +64,8 @@ export * from "./types/prism/PrismFeature"
64
64
  export * from "./types/prism/PrismSubPrism"
65
65
  export * from "./types/prism/PrismSegment"
66
66
  export * from "./types/prism/PrismTarget"
67
- export * from "./types/prism/TenantVoterTarget"
67
+ export * from "./types/prism/Target"
68
+ export * from "./types/prism/TenantVoterTag"
68
69
  export * from "./types/prism/UserPrismSegment"
69
70
  export * from "./types/prism/Voter"
70
71
  export * from "./types/prism/VoterFeature"
@@ -32,7 +32,7 @@ export class FederalElectionCandidate {
32
32
  readonly federal_election_candidate_id : string
33
33
  readonly name : string
34
34
  readonly federal_election_office_id : FederalElectionOfficeID
35
- readonly state_id : StateID
35
+ readonly state_id? : StateID
36
36
  readonly district_id? : number
37
37
  readonly federal_election_id : string
38
38
  readonly party_id? : string
@@ -62,7 +62,7 @@ export class FederalElectionCandidate {
62
62
  typeof federal_election_candidate.federal_election_candidate_id === "string" &&
63
63
  typeof federal_election_candidate.name === "string" &&
64
64
  is_federal_election_office_id(federal_election_candidate.federal_election_office_id) &&
65
- is_state_id(federal_election_candidate.state_id) &&
65
+ (federal_election_candidate.state_id === undefined || is_state_id(federal_election_candidate.state_id)) &&
66
66
  (federal_election_candidate.district_id === undefined || typeof federal_election_candidate.district_id === "number") &&
67
67
  typeof federal_election_candidate.federal_election_id === "string" &&
68
68
  (federal_election_candidate.party_id === undefined || typeof federal_election_candidate.party_id === "string") &&
@@ -0,0 +1,23 @@
1
+ export class Target {
2
+ readonly target_id : string
3
+ readonly name : string
4
+ readonly description : string
5
+
6
+ constructor(target : any) {
7
+ if (!Target.is(target)) {
8
+ throw Error("Invalid input.")
9
+ }
10
+ this.target_id = target.target_id
11
+ this.name = target.name
12
+ this.description = target.description
13
+ }
14
+
15
+ static is(target : any) : target is Target {
16
+ return (
17
+ target !== undefined &&
18
+ typeof target.target_id === "string" &&
19
+ typeof target.name === "string" &&
20
+ typeof target.description === "string"
21
+ )
22
+ }
23
+ }
@@ -0,0 +1,36 @@
1
+ import { is_state_id, StateID } from "../regions/State"
2
+
3
+ export class TenantVoterTag {
4
+ readonly tenant_voter_tag_id : string
5
+ readonly tenant_id : string
6
+ readonly voter_id : string
7
+ readonly tag_id : string
8
+ readonly target_id? : string
9
+ readonly user_id : string
10
+ readonly time : string
11
+
12
+ constructor(tenant_voter_tag : any) {
13
+ if (!TenantVoterTag.is(tenant_voter_tag)) {
14
+ throw Error("Invalid input.")
15
+ }
16
+ this.tenant_voter_tag_id = tenant_voter_tag.tenant_voter_tag_id
17
+ this.tenant_id = tenant_voter_tag.tenant_id
18
+ this.voter_id = tenant_voter_tag.voter_id
19
+ this.tag_id = tenant_voter_tag.tag_id
20
+ this.user_id = tenant_voter_tag.user_id
21
+ this.time = tenant_voter_tag.time
22
+ }
23
+
24
+ static is(tenant_voter_tag : any) : tenant_voter_tag is TenantVoterTag {
25
+ return (
26
+ tenant_voter_tag !== undefined &&
27
+ typeof tenant_voter_tag.tenant_voter_tag_id === "string" &&
28
+ typeof tenant_voter_tag.tenant_id === "string" &&
29
+ typeof tenant_voter_tag.voter_id === "string" &&
30
+ typeof tenant_voter_tag.tag_id === "string" &&
31
+ (tenant_voter_tag.target_id === undefined || typeof tenant_voter_tag === "string") &&
32
+ typeof tenant_voter_tag.user_id === "string" &&
33
+ typeof tenant_voter_tag.time === "string"
34
+ )
35
+ }
36
+ }
@@ -1,52 +0,0 @@
1
- import { is_state_id, StateID } from "../regions/State"
2
-
3
- export class TenantVoterTarget {
4
- readonly tenant_voter_target_id : string
5
- readonly tenant_id : string
6
- readonly voter_id : string
7
- readonly target_id : string
8
- readonly value : number
9
- readonly user_id : string
10
- // readonly federal_congress_district_id? : string
11
- // readonly state_legislature_house_district_id? : string
12
- // readonly state_legislature_senate_district_id? : string
13
- // readonly county_id? : string
14
- // readonly school_district_id? : string
15
- // readonly party_type_id : VoterPartyTypeID
16
-
17
- constructor(tenant_voter_target : any) {
18
- if (!TenantVoterTarget.is(tenant_voter_target)) {
19
- throw Error("Invalid input.")
20
- }
21
- this.tenant_voter_target_id = tenant_voter_target.tenant_voter_target_id
22
- this.tenant_id = tenant_voter_target.tenant_id
23
- this.voter_id = tenant_voter_target.voter_id
24
- this.target_id = tenant_voter_target.target_id
25
- this.value = tenant_voter_target.value
26
- this.user_id = tenant_voter_target.user_id
27
- // this.federal_congress_district_id = tenant_voter_target.federal_congress_district_id
28
- // this.state_legislature_house_district_id = tenant_voter_target.state_legislature_house_district_id
29
- // this.state_legislature_senate_district_id = tenant_voter_target.state_legislature_senate_district_id
30
- // this.county_id = tenant_voter_target.county_id
31
- // this.school_district_id = tenant_voter_target.school_district_id
32
- // this.party_type_id = tenant_voter_target.party_type_id
33
- }
34
-
35
- static is(tenant_voter_target : any) : tenant_voter_target is TenantVoterTarget {
36
- return (
37
- tenant_voter_target !== undefined &&
38
- typeof tenant_voter_target.tenant_voter_target_id === "string" &&
39
- typeof tenant_voter_target.tenant_id === "string" &&
40
- typeof tenant_voter_target.voter_id === "string" &&
41
- typeof tenant_voter_target.target_id === "string" &&
42
- typeof tenant_voter_target.value === "number" &&
43
- typeof tenant_voter_target.user_id === "string"// &&
44
- // (tenant_voter_target.federal_congress_district_id === undefined || typeof tenant_voter_target.federal_congress_district_id === "string") &&
45
- // (tenant_voter_target.state_legislature_house_district_id === undefined || typeof tenant_voter_target.state_legislature_house_district_id === "string") &&
46
- // (tenant_voter_target.state_legislature_senate_district_id === undefined || typeof tenant_voter_target.state_legislature_senate_district_id === "string") &&
47
- // (tenant_voter_target.county_id === undefined || typeof tenant_voter_target.county_id === "string") &&
48
- // (tenant_voter_target.school_district_id === undefined || typeof tenant_voter_target.school_district_id === "string") &&
49
- // is_voter_party_type_id(tenant_voter_target.party_type_id)
50
- )
51
- }
52
- }