triangle-types 1.0.247 → 1.0.248
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/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,6 +2,10 @@ export * from "./types/errors/TriangleAPIError"
|
|
|
2
2
|
|
|
3
3
|
export * from "./types/application/ApplicationStage"
|
|
4
4
|
|
|
5
|
+
export * from "./types/ballotpedia/BallotpediaJurisdiction"
|
|
6
|
+
export * from "./types/ballotpedia/BallotpediaOffice"
|
|
7
|
+
export * from "./types/ballotpedia/BallotpediaPerson"
|
|
8
|
+
|
|
5
9
|
export * from "./types/twitter/TwitterTweet"
|
|
6
10
|
export * from "./types/twitter/TwitterUser"
|
|
7
11
|
export * from "./types/twitter/TwitterUserTag"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// const ballotpedia_jurisdiction_type_ids = ["federal_congress_district", "municipality", "country", "county", "sub_county", "ju"] as const
|
|
2
|
+
|
|
3
|
+
// export type BallotpediaJurisdictionTypeID = typeof ballotpedia_jurisdiction_type_ids[number]
|
|
4
|
+
|
|
5
|
+
// export function is_ballotpedia_jurisdiction_type_id(ballotpedia_jurisdiction_type_id : any) : ballotpedia_jurisdiction_type_id is BallotpediaJurisdictionTypeID {
|
|
6
|
+
// return ballotpedia_jurisdiction_type_ids.includes(ballotpedia_jurisdiction_type_id)
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
export class BallotpediaJurisdiction {
|
|
10
|
+
readonly ballotpedia_jurisdiction_id : number
|
|
11
|
+
readonly name : string
|
|
12
|
+
readonly jurisdiction_type_id : string
|
|
13
|
+
readonly geo_id? : string
|
|
14
|
+
readonly [x : string] : any
|
|
15
|
+
|
|
16
|
+
constructor(ballotpedia_jurisdiction : any) {
|
|
17
|
+
if (!BallotpediaJurisdiction.is(ballotpedia_jurisdiction)) {
|
|
18
|
+
throw Error("Invalid input.")
|
|
19
|
+
}
|
|
20
|
+
this.ballotpedia_jurisdiction_id = ballotpedia_jurisdiction.ballotpedia_jurisdiction_id
|
|
21
|
+
this.name = ballotpedia_jurisdiction.name
|
|
22
|
+
this.jurisdiction_type_id = ballotpedia_jurisdiction.jurisdiction_type_id
|
|
23
|
+
this.jurisdiction_type_id = ballotpedia_jurisdiction.jurisdiction_type_id
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static is(ballotpedia_jurisdiction : any) : ballotpedia_jurisdiction is BallotpediaJurisdiction {
|
|
27
|
+
return (
|
|
28
|
+
ballotpedia_jurisdiction !== undefined &&
|
|
29
|
+
typeof ballotpedia_jurisdiction.ballotpedia_jurisdiction_id === "number" &&
|
|
30
|
+
typeof ballotpedia_jurisdiction.name === "string" &&
|
|
31
|
+
typeof ballotpedia_jurisdiction.jurisdiction_type_id === "string" &&
|
|
32
|
+
(ballotpedia_jurisdiction.geo_id === undefined || typeof ballotpedia_jurisdiction.geo_id === "string")
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { is_state_id, StateID } from "../regions/State"
|
|
2
|
+
|
|
3
|
+
const ballotpedia_office_type_ids = ["F", "S", "L"] as const
|
|
4
|
+
|
|
5
|
+
export type BallotpediaOfficeTypeID = typeof ballotpedia_office_type_ids[number]
|
|
6
|
+
|
|
7
|
+
export function is_ballotpedia_office_type_id(ballotpedia_office_type_id : any) : ballotpedia_office_type_id is BallotpediaOfficeTypeID {
|
|
8
|
+
return ballotpedia_office_type_ids.includes(ballotpedia_office_type_id)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class BallotpediaOffice {
|
|
12
|
+
readonly ballotpedia_office_id : number
|
|
13
|
+
readonly ballotpedia_jurisdiction_id : number
|
|
14
|
+
readonly name : string
|
|
15
|
+
readonly state_id? : StateID
|
|
16
|
+
readonly office_type_id : BallotpediaOfficeTypeID
|
|
17
|
+
|
|
18
|
+
readonly [x : string] : any
|
|
19
|
+
|
|
20
|
+
constructor(ballotpedia_office : any) {
|
|
21
|
+
if (!BallotpediaOffice.is(ballotpedia_office)) {
|
|
22
|
+
throw Error("Invalid input.")
|
|
23
|
+
}
|
|
24
|
+
this.ballotpedia_office_id = ballotpedia_office.ballotpedia_office_id
|
|
25
|
+
this.ballotpedia_jurisdiction_id = ballotpedia_office.ballotpedia_jurisdiction_id
|
|
26
|
+
this.name = ballotpedia_office.name
|
|
27
|
+
this.state_id = ballotpedia_office.state_id
|
|
28
|
+
this.office_type_id = ballotpedia_office.office_type_id
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static is(ballotpedia_office : any) : ballotpedia_office is BallotpediaOffice {
|
|
32
|
+
return (
|
|
33
|
+
ballotpedia_office !== undefined &&
|
|
34
|
+
typeof ballotpedia_office.ballotpedia_office_id === "number" &&
|
|
35
|
+
typeof ballotpedia_office.ballotpedia_jurisdiction_id === "number" &&
|
|
36
|
+
typeof ballotpedia_office.name === "string" &&
|
|
37
|
+
(ballotpedia_office.state_id === undefined || is_state_id(ballotpedia_office.state_id)) &&
|
|
38
|
+
is_ballotpedia_office_type_id(ballotpedia_office.office_type_id)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export class BallotpediaPerson {
|
|
2
|
+
readonly ballotpedia_person_id : number
|
|
3
|
+
readonly url : string
|
|
4
|
+
readonly name : string
|
|
5
|
+
readonly name_first : string
|
|
6
|
+
readonly name_last : string
|
|
7
|
+
readonly name_nick? : string
|
|
8
|
+
readonly is_alive? : boolean
|
|
9
|
+
readonly gender_id? : string
|
|
10
|
+
readonly birth_date? : string
|
|
11
|
+
readonly birth_city? : string
|
|
12
|
+
readonly religion_id : string
|
|
13
|
+
readonly profession_id? : string
|
|
14
|
+
readonly contacts_json : string
|
|
15
|
+
readonly campaigns_json : string
|
|
16
|
+
readonly terms_json : string
|
|
17
|
+
readonly education_json : string
|
|
18
|
+
readonly military_json : string
|
|
19
|
+
readonly [x : string] : any
|
|
20
|
+
|
|
21
|
+
constructor(ballotpedia_person : any) {
|
|
22
|
+
if (!BallotpediaPerson.is(ballotpedia_person)) {
|
|
23
|
+
throw Error("Invalid input.")
|
|
24
|
+
}
|
|
25
|
+
this.ballotpedia_person_id = ballotpedia_person.ballotpedia_person_id
|
|
26
|
+
this.url = ballotpedia_person.url
|
|
27
|
+
this.name = ballotpedia_person.name
|
|
28
|
+
this.name_first = ballotpedia_person.name_first
|
|
29
|
+
this.name_last = ballotpedia_person.name_last
|
|
30
|
+
this.name_nick = ballotpedia_person.name_nick
|
|
31
|
+
this.is_alive = ballotpedia_person.is_alive
|
|
32
|
+
this.gender_id = ballotpedia_person.gender_id
|
|
33
|
+
this.birth_date = ballotpedia_person.birth_date
|
|
34
|
+
this.birth_city = ballotpedia_person.birth_city
|
|
35
|
+
this.religion_id = ballotpedia_person.religion_id
|
|
36
|
+
this.profession_id = ballotpedia_person.profession_id
|
|
37
|
+
this.contacts_json = ballotpedia_person.contacts_json
|
|
38
|
+
this.campaigns_json = ballotpedia_person.campaigns_json
|
|
39
|
+
this.terms_json = ballotpedia_person.terms_json
|
|
40
|
+
this.education_json = ballotpedia_person.education_json
|
|
41
|
+
this.military_json = ballotpedia_person.military_json
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static is(ballotpedia_person : any) : ballotpedia_person is BallotpediaPerson {
|
|
45
|
+
return (
|
|
46
|
+
ballotpedia_person !== undefined &&
|
|
47
|
+
typeof ballotpedia_person.ballotpedia_person_id === "number" &&
|
|
48
|
+
typeof ballotpedia_person.url === "string" &&
|
|
49
|
+
typeof ballotpedia_person.name === "string" &&
|
|
50
|
+
typeof ballotpedia_person.name_first === "string" &&
|
|
51
|
+
typeof ballotpedia_person.name_last === "string" &&
|
|
52
|
+
(ballotpedia_person.name_nick === undefined || typeof ballotpedia_person.name_nick === "string") &&
|
|
53
|
+
(ballotpedia_person.is_alive === undefined || typeof ballotpedia_person.is_alive === "boolean") &&
|
|
54
|
+
(ballotpedia_person.gender_id === undefined || typeof ballotpedia_person.gender_id === "string") &&
|
|
55
|
+
(ballotpedia_person.birth_date === undefined || typeof ballotpedia_person.birth_date === "string") &&
|
|
56
|
+
(ballotpedia_person.birth_city === undefined || typeof ballotpedia_person.birth_city === "string") &&
|
|
57
|
+
(ballotpedia_person.religion_id === undefined || typeof ballotpedia_person.religion_id === "string") &&
|
|
58
|
+
(ballotpedia_person.profession_id === undefined || typeof ballotpedia_person.profession_id === "string") &&
|
|
59
|
+
typeof ballotpedia_person.contacts_json === "string" &&
|
|
60
|
+
typeof ballotpedia_person.terms_json === "string" &&
|
|
61
|
+
typeof ballotpedia_person.education_json === "string" &&
|
|
62
|
+
typeof ballotpedia_person.military_json === "string"
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|