doersiq-types 2.0.0
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/Bot.d.ts +28 -0
- package/dist/src/Bot.js +73 -0
- package/dist/src/BotDocument.d.ts +14 -0
- package/dist/src/BotDocument.js +38 -0
- package/dist/src/Conversation.d.ts +16 -0
- package/dist/src/Conversation.js +42 -0
- package/dist/src/DoersAPIError.d.ts +4 -0
- package/dist/src/DoersAPIError.js +18 -0
- package/dist/src/Jurisdiction.d.ts +22 -0
- package/dist/src/Jurisdiction.js +53 -0
- package/dist/src/JurisdictionDocument.d.ts +15 -0
- package/dist/src/JurisdictionDocument.js +44 -0
- package/dist/src/Message.d.ts +29 -0
- package/dist/src/Message.js +79 -0
- package/dist/src/OfficeClass.d.ts +17 -0
- package/dist/src/OfficeClass.js +131 -0
- package/dist/src/Party.d.ts +10 -0
- package/dist/src/Party.js +26 -0
- package/dist/src/Sources.d.ts +38 -0
- package/dist/src/Sources.js +105 -0
- package/dist/src/State.d.ts +10 -0
- package/dist/src/State.js +256 -0
- package/dist/src/Tweet.d.ts +11 -0
- package/dist/src/Tweet.js +32 -0
- package/dist/src/User.d.ts +15 -0
- package/dist/src/User.js +39 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +13 -0
- package/dist/src/types/Bot.d.ts +29 -0
- package/dist/src/types/Bot.js +76 -0
- package/dist/src/types/BotDocument.d.ts +14 -0
- package/dist/src/types/BotDocument.js +38 -0
- package/dist/src/types/Conversation.d.ts +18 -0
- package/dist/src/types/Conversation.js +48 -0
- package/dist/src/types/DoersAPIError.d.ts +4 -0
- package/dist/src/types/DoersAPIError.js +19 -0
- package/dist/src/types/Jurisdiction.d.ts +24 -0
- package/dist/src/types/Jurisdiction.js +57 -0
- package/dist/src/types/JurisdictionDocument.d.ts +15 -0
- package/dist/src/types/JurisdictionDocument.js +44 -0
- package/dist/src/types/Message.d.ts +31 -0
- package/dist/src/types/Message.js +85 -0
- package/dist/src/types/OfficeClass.d.ts +17 -0
- package/dist/src/types/OfficeClass.js +132 -0
- package/dist/src/types/Party.d.ts +10 -0
- package/dist/src/types/Party.js +26 -0
- package/dist/src/types/Sources.d.ts +38 -0
- package/dist/src/types/Sources.js +105 -0
- package/dist/src/types/State.d.ts +11 -0
- package/dist/src/types/State.js +306 -0
- package/dist/src/types/Tweet.d.ts +12 -0
- package/dist/src/types/Tweet.js +34 -0
- package/dist/src/types/User.d.ts +16 -0
- package/dist/src/types/User.js +42 -0
- package/eslint.config.ts +13 -0
- package/jest.config.js +20 -0
- package/package.json +31 -0
- package/src/index.ts +13 -0
- package/src/types/Bot.ts +87 -0
- package/src/types/BotDocument.ts +43 -0
- package/src/types/Conversation.ts +59 -0
- package/src/types/DoersAPIError.ts +21 -0
- package/src/types/Jurisdiction.ts +62 -0
- package/src/types/JurisdictionDocument.ts +48 -0
- package/src/types/Message.ts +100 -0
- package/src/types/OfficeClass.ts +150 -0
- package/src/types/Party.ts +36 -0
- package/src/types/Sources.ts +125 -0
- package/src/types/State.ts +317 -0
- package/src/types/Tweet.ts +38 -0
- package/src/types/User.ts +53 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { OfficeClassID } from "./OfficeClass.js";
|
|
2
|
+
import { Jurisdiction } from "./Jurisdiction.js";
|
|
3
|
+
import { StateID } from "./State.js";
|
|
4
|
+
import { PartyID } from "./Party.js";
|
|
5
|
+
export declare class Bot {
|
|
6
|
+
readonly office_id: string;
|
|
7
|
+
readonly number: string;
|
|
8
|
+
readonly bot_id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly active: boolean;
|
|
11
|
+
readonly state_id: StateID;
|
|
12
|
+
readonly district?: number;
|
|
13
|
+
readonly party_id: PartyID;
|
|
14
|
+
readonly guidelines: string;
|
|
15
|
+
readonly topics: string[];
|
|
16
|
+
readonly jurisdiction_ids: number[];
|
|
17
|
+
readonly office_class_id: OfficeClassID;
|
|
18
|
+
readonly office_name?: string;
|
|
19
|
+
readonly [x: string]: any;
|
|
20
|
+
constructor(bot: any);
|
|
21
|
+
static is(bot: any): bot is Bot;
|
|
22
|
+
}
|
|
23
|
+
export declare class BotAux extends Bot {
|
|
24
|
+
readonly jurisdictions: Jurisdiction[];
|
|
25
|
+
readonly photo_download_url?: string;
|
|
26
|
+
constructor(bot: any);
|
|
27
|
+
static is(bot: any): bot is BotAux;
|
|
28
|
+
}
|
package/dist/src/Bot.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { is_office_class_id } from "./OfficeClass.js";
|
|
2
|
+
import { Jurisdiction } from "./Jurisdiction.js";
|
|
3
|
+
import { is_state_id } from "./State.js";
|
|
4
|
+
import { is_party_id } from "./Party.js";
|
|
5
|
+
export class Bot {
|
|
6
|
+
office_id;
|
|
7
|
+
number;
|
|
8
|
+
bot_id;
|
|
9
|
+
name;
|
|
10
|
+
active;
|
|
11
|
+
state_id;
|
|
12
|
+
district;
|
|
13
|
+
party_id;
|
|
14
|
+
guidelines;
|
|
15
|
+
topics;
|
|
16
|
+
jurisdiction_ids;
|
|
17
|
+
office_class_id;
|
|
18
|
+
office_name;
|
|
19
|
+
constructor(bot) {
|
|
20
|
+
if (!Bot.is(bot)) {
|
|
21
|
+
throw Error("Invalid input.");
|
|
22
|
+
}
|
|
23
|
+
this.office_id = bot.office_id;
|
|
24
|
+
this.number = bot.number;
|
|
25
|
+
this.bot_id = bot.bot_id;
|
|
26
|
+
this.name = bot.name;
|
|
27
|
+
this.active = bot.active;
|
|
28
|
+
this.state_id = bot.state_id;
|
|
29
|
+
this.district = bot.district;
|
|
30
|
+
this.party_id = bot.party_id;
|
|
31
|
+
this.guidelines = bot.guidelines;
|
|
32
|
+
this.topics = bot.topics;
|
|
33
|
+
this.jurisdiction_ids = bot.jurisdiction_ids;
|
|
34
|
+
this.office_class_id = bot.office_class_id;
|
|
35
|
+
this.office_name = bot.office_name;
|
|
36
|
+
}
|
|
37
|
+
static is(bot) {
|
|
38
|
+
return (bot !== undefined &&
|
|
39
|
+
typeof bot.office_id === "string" &&
|
|
40
|
+
typeof bot.number === "string" &&
|
|
41
|
+
typeof bot.bot_id === "string" &&
|
|
42
|
+
typeof bot.name === "string" &&
|
|
43
|
+
typeof bot.active === "boolean" &&
|
|
44
|
+
is_state_id(bot.state_id) &&
|
|
45
|
+
(bot.district === undefined || typeof bot.district === "number") &&
|
|
46
|
+
is_party_id(bot.party_id) &&
|
|
47
|
+
typeof bot.guidelines === "string" &&
|
|
48
|
+
Array.isArray(bot.topics) &&
|
|
49
|
+
bot.topics.every((topic) => typeof topic === "string") &&
|
|
50
|
+
Array.isArray(bot.jurisdiction_ids) &&
|
|
51
|
+
bot.jurisdiction_ids.every((jurisdiction_id) => typeof jurisdiction_id === "number") &&
|
|
52
|
+
is_office_class_id(bot.office_class_id) &&
|
|
53
|
+
(bot.office_name === undefined || typeof bot.office_name === "string"));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class BotAux extends Bot {
|
|
57
|
+
jurisdictions;
|
|
58
|
+
photo_download_url;
|
|
59
|
+
constructor(bot) {
|
|
60
|
+
if (!BotAux.is(bot)) {
|
|
61
|
+
throw Error("Invalid input.");
|
|
62
|
+
}
|
|
63
|
+
super(bot);
|
|
64
|
+
this.jurisdictions = bot.jurisdictions;
|
|
65
|
+
this.photo_download_url = bot.photo_download_url;
|
|
66
|
+
}
|
|
67
|
+
static is(bot) {
|
|
68
|
+
return (Bot.is(bot) &&
|
|
69
|
+
Array.isArray(bot.jurisdictions) &&
|
|
70
|
+
bot.jurisdictions.every(Jurisdiction.is) &&
|
|
71
|
+
(bot.photo_download_url === undefined || typeof bot.photo_download_url === "string"));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tweet } from "./Tweet.js";
|
|
2
|
+
export declare class BotDocument {
|
|
3
|
+
readonly bot_id: string;
|
|
4
|
+
readonly document_id: string;
|
|
5
|
+
readonly type: "URL" | "TWEET" | "TWITTER";
|
|
6
|
+
readonly s3_filename?: string;
|
|
7
|
+
readonly url?: string;
|
|
8
|
+
readonly username?: string;
|
|
9
|
+
readonly vector_keys?: string[];
|
|
10
|
+
readonly tweet?: Tweet;
|
|
11
|
+
readonly text?: string;
|
|
12
|
+
constructor(bot_document: any);
|
|
13
|
+
static is(bot_document: any): bot_document is BotDocument;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Tweet } from "./Tweet.js";
|
|
2
|
+
export class BotDocument {
|
|
3
|
+
bot_id;
|
|
4
|
+
document_id;
|
|
5
|
+
type;
|
|
6
|
+
s3_filename;
|
|
7
|
+
url;
|
|
8
|
+
username;
|
|
9
|
+
vector_keys;
|
|
10
|
+
tweet;
|
|
11
|
+
text;
|
|
12
|
+
constructor(bot_document) {
|
|
13
|
+
if (!BotDocument.is(bot_document)) {
|
|
14
|
+
throw Error("Invalid input.");
|
|
15
|
+
}
|
|
16
|
+
this.bot_id = bot_document.bot_id;
|
|
17
|
+
this.document_id = bot_document.document_id;
|
|
18
|
+
this.type = bot_document.type;
|
|
19
|
+
this.s3_filename = bot_document.s3_filename;
|
|
20
|
+
this.url = bot_document.url;
|
|
21
|
+
this.username = bot_document.username;
|
|
22
|
+
this.vector_keys = bot_document.vector_keys;
|
|
23
|
+
this.tweet = bot_document.tweet;
|
|
24
|
+
this.text = bot_document.text;
|
|
25
|
+
}
|
|
26
|
+
static is(bot_document) {
|
|
27
|
+
return (bot_document !== undefined &&
|
|
28
|
+
typeof bot_document.bot_id === "string" &&
|
|
29
|
+
typeof bot_document.document_id === "string" &&
|
|
30
|
+
typeof bot_document.type === "string" &&
|
|
31
|
+
(bot_document.s3_filename === undefined || typeof bot_document.s3_filename === "string") &&
|
|
32
|
+
(bot_document.url === undefined || typeof bot_document.url === "string") &&
|
|
33
|
+
(bot_document.username === undefined || typeof bot_document.username === "string") &&
|
|
34
|
+
(bot_document.vector_keys === undefined || Array.isArray(bot_document.vector_keys) && bot_document.vector_keys.every((vector_key) => typeof vector_key === "string")) &&
|
|
35
|
+
(bot_document.tweet === undefined || Tweet.is(bot_document.tweet)) &&
|
|
36
|
+
(bot_document.text === undefined || typeof bot_document.text === "string"));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Message } from "./Message.js";
|
|
2
|
+
export declare class Conversation {
|
|
3
|
+
readonly user_id: string;
|
|
4
|
+
readonly conversation_id: string;
|
|
5
|
+
readonly bot_id: string;
|
|
6
|
+
readonly mode: "email" | "general";
|
|
7
|
+
readonly topics?: string[];
|
|
8
|
+
readonly [x: string]: any;
|
|
9
|
+
constructor(conversation: any);
|
|
10
|
+
static is(conversation: any): conversation is Conversation;
|
|
11
|
+
}
|
|
12
|
+
export declare class ConversationAux extends Conversation {
|
|
13
|
+
readonly messages: Message[];
|
|
14
|
+
constructor(conversation: any);
|
|
15
|
+
static is(conversation: any): conversation is ConversationAux;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Message } from "./Message.js";
|
|
2
|
+
export class Conversation {
|
|
3
|
+
user_id;
|
|
4
|
+
conversation_id;
|
|
5
|
+
bot_id;
|
|
6
|
+
mode;
|
|
7
|
+
topics;
|
|
8
|
+
constructor(conversation) {
|
|
9
|
+
if (!Conversation.is(conversation)) {
|
|
10
|
+
throw Error("Invalid input.");
|
|
11
|
+
}
|
|
12
|
+
this.user_id = conversation.user_id;
|
|
13
|
+
this.conversation_id = conversation.conversation_id;
|
|
14
|
+
this.bot_id = conversation.bot_id;
|
|
15
|
+
this.mode = conversation.mode;
|
|
16
|
+
this.topics = conversation.topics;
|
|
17
|
+
}
|
|
18
|
+
static is(conversation) {
|
|
19
|
+
return (conversation !== undefined &&
|
|
20
|
+
typeof conversation.user_id === "string" &&
|
|
21
|
+
typeof conversation.conversation_id === "string" &&
|
|
22
|
+
typeof conversation.bot_id === "string" &&
|
|
23
|
+
["email", "general"].includes(conversation.mode) &&
|
|
24
|
+
(conversation.topics === undefined || Array.isArray(conversation.topics) &&
|
|
25
|
+
conversation.topics.every((topic) => typeof topic === "string")));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class ConversationAux extends Conversation {
|
|
29
|
+
messages;
|
|
30
|
+
constructor(conversation) {
|
|
31
|
+
if (!ConversationAux.is(conversation)) {
|
|
32
|
+
throw Error("Invalid input.");
|
|
33
|
+
}
|
|
34
|
+
super(conversation);
|
|
35
|
+
this.messages = conversation.messages;
|
|
36
|
+
}
|
|
37
|
+
static is(conversation) {
|
|
38
|
+
return (Conversation.is(conversation) &&
|
|
39
|
+
Array.isArray(conversation.messages) &&
|
|
40
|
+
conversation.messages.every(Message.is));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const default_messages_by_status = {
|
|
2
|
+
400: "Bad Request",
|
|
3
|
+
401: "Unauthorized",
|
|
4
|
+
403: "Forbidden",
|
|
5
|
+
404: "Not Found",
|
|
6
|
+
405: "Method Not Allowed",
|
|
7
|
+
500: "Internal Server Error",
|
|
8
|
+
600: "Failed to Parse Output"
|
|
9
|
+
};
|
|
10
|
+
export class DoersAPIError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
constructor(status, message) {
|
|
13
|
+
const default_message = default_messages_by_status[status];
|
|
14
|
+
super(message !== undefined ? message : default_message !== undefined ? default_message : "Error");
|
|
15
|
+
this.name = "DoersAPIError";
|
|
16
|
+
this.status = status;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum JurisdictionLevel {
|
|
2
|
+
SCHOOL = 0,
|
|
3
|
+
NATION = 1,
|
|
4
|
+
STATE = 2,
|
|
5
|
+
COUNTY = 3,
|
|
6
|
+
CITY = 4
|
|
7
|
+
}
|
|
8
|
+
export declare function is_jurisdiction_level(jurisdiction_level: any): jurisdiction_level is JurisdictionLevel;
|
|
9
|
+
export declare class Jurisdiction {
|
|
10
|
+
readonly jurisdiction_id: number;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly path: number[];
|
|
13
|
+
readonly sub_jurisdiction_ids: number[];
|
|
14
|
+
readonly super_jurisdiction_id?: number;
|
|
15
|
+
readonly level: JurisdictionLevel;
|
|
16
|
+
readonly state_jurisdiction_id?: number;
|
|
17
|
+
readonly county_jurisdiction_id?: number;
|
|
18
|
+
readonly city_jurisdiction_id?: number;
|
|
19
|
+
readonly geographic: boolean;
|
|
20
|
+
constructor(jurisdiction: any);
|
|
21
|
+
static is(jurisdiction: any): jurisdiction is Jurisdiction;
|
|
22
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export var JurisdictionLevel;
|
|
2
|
+
(function (JurisdictionLevel) {
|
|
3
|
+
JurisdictionLevel[JurisdictionLevel["SCHOOL"] = 0] = "SCHOOL";
|
|
4
|
+
JurisdictionLevel[JurisdictionLevel["NATION"] = 1] = "NATION";
|
|
5
|
+
JurisdictionLevel[JurisdictionLevel["STATE"] = 2] = "STATE";
|
|
6
|
+
JurisdictionLevel[JurisdictionLevel["COUNTY"] = 3] = "COUNTY";
|
|
7
|
+
JurisdictionLevel[JurisdictionLevel["CITY"] = 4] = "CITY";
|
|
8
|
+
})(JurisdictionLevel || (JurisdictionLevel = {}));
|
|
9
|
+
export function is_jurisdiction_level(jurisdiction_level) {
|
|
10
|
+
return [0, 1, 2, 3, 4].includes(jurisdiction_level);
|
|
11
|
+
}
|
|
12
|
+
export class Jurisdiction {
|
|
13
|
+
jurisdiction_id;
|
|
14
|
+
name;
|
|
15
|
+
path;
|
|
16
|
+
sub_jurisdiction_ids;
|
|
17
|
+
super_jurisdiction_id;
|
|
18
|
+
level;
|
|
19
|
+
state_jurisdiction_id;
|
|
20
|
+
county_jurisdiction_id;
|
|
21
|
+
city_jurisdiction_id;
|
|
22
|
+
geographic;
|
|
23
|
+
constructor(jurisdiction) {
|
|
24
|
+
if (!Jurisdiction.is(jurisdiction)) {
|
|
25
|
+
throw Error("Invalid input.");
|
|
26
|
+
}
|
|
27
|
+
this.jurisdiction_id = jurisdiction.jurisdiction_id;
|
|
28
|
+
this.name = jurisdiction.name;
|
|
29
|
+
this.path = jurisdiction.path;
|
|
30
|
+
this.sub_jurisdiction_ids = jurisdiction.sub_jurisdiction_ids;
|
|
31
|
+
this.super_jurisdiction_id = jurisdiction.super_jurisdiction_id;
|
|
32
|
+
this.level = jurisdiction.level;
|
|
33
|
+
this.state_jurisdiction_id = jurisdiction.state_jurisdiction_id;
|
|
34
|
+
this.county_jurisdiction_id = jurisdiction.county_jurisdiction_id;
|
|
35
|
+
this.city_jurisdiction_id = jurisdiction.city_jurisdiction_id;
|
|
36
|
+
this.geographic = jurisdiction.geographic;
|
|
37
|
+
}
|
|
38
|
+
static is(jurisdiction) {
|
|
39
|
+
return (jurisdiction !== undefined &&
|
|
40
|
+
typeof jurisdiction.jurisdiction_id === "number" &&
|
|
41
|
+
typeof jurisdiction.name === "string" &&
|
|
42
|
+
Array.isArray(jurisdiction.path) &&
|
|
43
|
+
jurisdiction.path.every((jurisdiction_id) => typeof jurisdiction_id === "number") &&
|
|
44
|
+
Array.isArray(jurisdiction.sub_jurisdiction_ids) &&
|
|
45
|
+
jurisdiction.sub_jurisdiction_ids.every((jurisdiction_id) => typeof jurisdiction_id === "number") &&
|
|
46
|
+
is_jurisdiction_level(jurisdiction.level) &&
|
|
47
|
+
typeof jurisdiction.geographic === "boolean" &&
|
|
48
|
+
(jurisdiction.super_jurisdiction_id === undefined || typeof jurisdiction.super_jurisdiction_id === "number") &&
|
|
49
|
+
(jurisdiction.state_jurisdiction_id === undefined || typeof jurisdiction.state_jurisdiction_id === "number") &&
|
|
50
|
+
(jurisdiction.county_jurisdiction_id === undefined || typeof jurisdiction.county_jurisdiction_id === "number") &&
|
|
51
|
+
(jurisdiction.city_jurisdiction_id === undefined || typeof jurisdiction.city_jurisdiction_id === "number"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class JurisdictionDocument {
|
|
2
|
+
readonly jurisdiction_id: number;
|
|
3
|
+
readonly document_id: string;
|
|
4
|
+
readonly media_id: string;
|
|
5
|
+
readonly origin: string;
|
|
6
|
+
readonly s3_filename?: string;
|
|
7
|
+
readonly time?: string;
|
|
8
|
+
readonly title: string;
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly vector_keys?: string[];
|
|
12
|
+
readonly location?: string;
|
|
13
|
+
constructor(jurisdiction_document: any);
|
|
14
|
+
static is(jurisdiction_document: any): jurisdiction_document is JurisdictionDocument;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class JurisdictionDocument {
|
|
2
|
+
jurisdiction_id;
|
|
3
|
+
document_id;
|
|
4
|
+
media_id;
|
|
5
|
+
origin;
|
|
6
|
+
s3_filename;
|
|
7
|
+
time;
|
|
8
|
+
title;
|
|
9
|
+
type;
|
|
10
|
+
url;
|
|
11
|
+
vector_keys;
|
|
12
|
+
location;
|
|
13
|
+
constructor(jurisdiction_document) {
|
|
14
|
+
if (!JurisdictionDocument.is(jurisdiction_document)) {
|
|
15
|
+
throw Error("Invalid input.");
|
|
16
|
+
}
|
|
17
|
+
this.jurisdiction_id = jurisdiction_document.jurisdiction_id;
|
|
18
|
+
this.document_id = jurisdiction_document.document_id;
|
|
19
|
+
this.media_id = jurisdiction_document.media_id;
|
|
20
|
+
this.origin = jurisdiction_document.origin;
|
|
21
|
+
this.s3_filename = jurisdiction_document.s3_filename;
|
|
22
|
+
this.time = jurisdiction_document.time;
|
|
23
|
+
this.title = jurisdiction_document.title;
|
|
24
|
+
this.type = jurisdiction_document.type;
|
|
25
|
+
this.url = jurisdiction_document.url;
|
|
26
|
+
this.vector_keys = jurisdiction_document.vector_keys;
|
|
27
|
+
this.location = jurisdiction_document.location;
|
|
28
|
+
}
|
|
29
|
+
static is(jurisdiction_document) {
|
|
30
|
+
return (jurisdiction_document !== undefined &&
|
|
31
|
+
typeof jurisdiction_document.jurisdiction_id === "number" &&
|
|
32
|
+
typeof jurisdiction_document.document_id === "string" &&
|
|
33
|
+
typeof jurisdiction_document.media_id === "string" &&
|
|
34
|
+
typeof jurisdiction_document.origin === "string" &&
|
|
35
|
+
(jurisdiction_document.s3_filename === undefined || typeof jurisdiction_document.s3_filename === "string") &&
|
|
36
|
+
(jurisdiction_document.time === undefined || typeof jurisdiction_document.time === "string") &&
|
|
37
|
+
typeof jurisdiction_document.title === "string" &&
|
|
38
|
+
typeof jurisdiction_document.type === "string" &&
|
|
39
|
+
typeof jurisdiction_document.url === "string" &&
|
|
40
|
+
(jurisdiction_document.vector_keys === undefined || Array.isArray(jurisdiction_document.vector_keys)) &&
|
|
41
|
+
jurisdiction_document.vector_keys.every((vector_key) => typeof vector_key === "string") &&
|
|
42
|
+
(jurisdiction_document.location === undefined || typeof jurisdiction_document.location === "string"));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Sources } from "./Sources.js";
|
|
2
|
+
export declare class Fragment {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly sources: Sources;
|
|
5
|
+
constructor(fragment: any);
|
|
6
|
+
static is(fragment: any): fragment is Fragment;
|
|
7
|
+
}
|
|
8
|
+
export declare class Post {
|
|
9
|
+
text: string;
|
|
10
|
+
s3_image_filename?: string;
|
|
11
|
+
s3_image_url?: string;
|
|
12
|
+
constructor(post: any);
|
|
13
|
+
static is(post: any): post is Post;
|
|
14
|
+
}
|
|
15
|
+
export declare class Message {
|
|
16
|
+
readonly user_id: string;
|
|
17
|
+
readonly message_id: string;
|
|
18
|
+
readonly conversation_id: string;
|
|
19
|
+
readonly mode: "email" | "general";
|
|
20
|
+
readonly role: "user" | "bot";
|
|
21
|
+
readonly system_prompt?: string;
|
|
22
|
+
readonly grok_text?: string;
|
|
23
|
+
readonly fragments?: Fragment[];
|
|
24
|
+
readonly sources?: Sources;
|
|
25
|
+
readonly text: string;
|
|
26
|
+
readonly posts?: Post[];
|
|
27
|
+
constructor(message: any);
|
|
28
|
+
static is(message: any): message is Message;
|
|
29
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Sources } from "./Sources.js";
|
|
2
|
+
export class Fragment {
|
|
3
|
+
text;
|
|
4
|
+
sources;
|
|
5
|
+
constructor(fragment) {
|
|
6
|
+
if (!Fragment.is(fragment)) {
|
|
7
|
+
throw Error("Invalid input.");
|
|
8
|
+
}
|
|
9
|
+
this.text = fragment.text;
|
|
10
|
+
this.sources = fragment.sources;
|
|
11
|
+
}
|
|
12
|
+
static is(fragment) {
|
|
13
|
+
return (fragment !== undefined &&
|
|
14
|
+
typeof fragment.text === "string" &&
|
|
15
|
+
Sources.is(fragment.sources));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class Post {
|
|
19
|
+
text;
|
|
20
|
+
s3_image_filename;
|
|
21
|
+
s3_image_url;
|
|
22
|
+
constructor(post) {
|
|
23
|
+
if (!Post.is(post)) {
|
|
24
|
+
throw Error("Invalid input.");
|
|
25
|
+
}
|
|
26
|
+
this.text = post.text;
|
|
27
|
+
this.s3_image_filename = post.s3_image_filename;
|
|
28
|
+
this.s3_image_url = post.s3_image_url;
|
|
29
|
+
}
|
|
30
|
+
static is(post) {
|
|
31
|
+
return (post !== undefined &&
|
|
32
|
+
typeof post.text === "string" &&
|
|
33
|
+
(post.s3_image_filename === undefined || typeof post.s3_image_filename === "string") &&
|
|
34
|
+
(post.s3_image_url === undefined || typeof post.s3_image_url === "string"));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class Message {
|
|
38
|
+
user_id;
|
|
39
|
+
message_id;
|
|
40
|
+
conversation_id;
|
|
41
|
+
mode;
|
|
42
|
+
role;
|
|
43
|
+
system_prompt;
|
|
44
|
+
grok_text;
|
|
45
|
+
fragments;
|
|
46
|
+
sources;
|
|
47
|
+
text;
|
|
48
|
+
posts;
|
|
49
|
+
constructor(message) {
|
|
50
|
+
if (!Message.is(message)) {
|
|
51
|
+
throw Error("Invalid input.");
|
|
52
|
+
}
|
|
53
|
+
this.user_id = message.user_id;
|
|
54
|
+
this.message_id = message.message_id;
|
|
55
|
+
this.conversation_id = message.conversation_id;
|
|
56
|
+
this.mode = message.mode;
|
|
57
|
+
this.role = message.role;
|
|
58
|
+
this.system_prompt = message.system_prompt;
|
|
59
|
+
this.grok_text = message.grok_text;
|
|
60
|
+
this.fragments = message.fragments;
|
|
61
|
+
this.sources = message.sources;
|
|
62
|
+
this.text = message.text;
|
|
63
|
+
this.posts = message.posts;
|
|
64
|
+
}
|
|
65
|
+
static is(message) {
|
|
66
|
+
return (message !== undefined &&
|
|
67
|
+
typeof message.user_id === "string" &&
|
|
68
|
+
typeof message.message_id === "string" &&
|
|
69
|
+
typeof message.conversation_id === "string" &&
|
|
70
|
+
["email", "general"].includes(message.mode) &&
|
|
71
|
+
["user", "bot"].includes(message.role) &&
|
|
72
|
+
(message.system_prompt === undefined || typeof message.system_prompt === "string") &&
|
|
73
|
+
(message.grok_text === undefined || typeof message.grok_text === "string") &&
|
|
74
|
+
(message.fragments === undefined || Array.isArray(message.fragments) && message.fragments.every(Fragment.is)) &&
|
|
75
|
+
(message.sources === undefined || Sources.is(message.sources)) &&
|
|
76
|
+
typeof message.text === "string" &&
|
|
77
|
+
(message.posts === undefined || Array.isArray(message.posts) && message.posts.every(Post.is)));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JurisdictionLevel } from "./Jurisdiction.js";
|
|
2
|
+
declare const office_class_ids: readonly ["ORG", "USH", "USS", "STG", "STH", "STS", "STB", "COG", "CIG", "LOB"];
|
|
3
|
+
export type OfficeClassID = typeof office_class_ids[number];
|
|
4
|
+
export declare function is_office_class_id(office_class_id: any): office_class_id is OfficeClassID;
|
|
5
|
+
export interface OfficeClass {
|
|
6
|
+
office_class_id: OfficeClassID;
|
|
7
|
+
name: string;
|
|
8
|
+
type: "candidate" | "organization";
|
|
9
|
+
office_id_template: string;
|
|
10
|
+
jurisdiction_level?: JurisdictionLevel;
|
|
11
|
+
jurisdictions_mutable: Boolean;
|
|
12
|
+
require_district: Boolean;
|
|
13
|
+
require_initial_jurisdiction: Boolean;
|
|
14
|
+
office_names?: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare const office_classes_by_office_class_id: Record<OfficeClassID, OfficeClass>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { JurisdictionLevel } from "./Jurisdiction.js";
|
|
2
|
+
const office_class_ids = ["ORG", "USH", "USS", "STG", "STH", "STS", "STB", "COG", "CIG", "LOB"];
|
|
3
|
+
export function is_office_class_id(office_class_id) {
|
|
4
|
+
return office_class_ids.includes(office_class_id);
|
|
5
|
+
}
|
|
6
|
+
export const office_classes_by_office_class_id = {
|
|
7
|
+
"ORG": {
|
|
8
|
+
office_class_id: "ORG",
|
|
9
|
+
name: "Organization",
|
|
10
|
+
type: "organization",
|
|
11
|
+
office_id_template: "O-[state_id]",
|
|
12
|
+
jurisdictions_mutable: true,
|
|
13
|
+
require_district: false,
|
|
14
|
+
require_initial_jurisdiction: false
|
|
15
|
+
},
|
|
16
|
+
"USH": {
|
|
17
|
+
office_class_id: "USH",
|
|
18
|
+
name: "U.S. House",
|
|
19
|
+
type: "candidate",
|
|
20
|
+
office_id_template: "H-[state_id]",
|
|
21
|
+
jurisdictions_mutable: true,
|
|
22
|
+
require_district: true,
|
|
23
|
+
require_initial_jurisdiction: false
|
|
24
|
+
},
|
|
25
|
+
"USS": {
|
|
26
|
+
office_class_id: "USS",
|
|
27
|
+
name: "U.S. Senate",
|
|
28
|
+
type: "candidate",
|
|
29
|
+
office_id_template: "S-[state_id]",
|
|
30
|
+
jurisdiction_level: JurisdictionLevel.STATE,
|
|
31
|
+
jurisdictions_mutable: false,
|
|
32
|
+
require_district: false,
|
|
33
|
+
require_initial_jurisdiction: false
|
|
34
|
+
},
|
|
35
|
+
"STG": {
|
|
36
|
+
office_class_id: "STG",
|
|
37
|
+
name: "State (Executive) Government",
|
|
38
|
+
type: "candidate",
|
|
39
|
+
office_id_template: "[state_id]-G",
|
|
40
|
+
jurisdiction_level: JurisdictionLevel.STATE,
|
|
41
|
+
jurisdictions_mutable: false,
|
|
42
|
+
require_district: false,
|
|
43
|
+
require_initial_jurisdiction: false,
|
|
44
|
+
office_names: [
|
|
45
|
+
"Governor",
|
|
46
|
+
"Lieutenant Governor",
|
|
47
|
+
"Secretary of State",
|
|
48
|
+
"Treasurer",
|
|
49
|
+
"Auditor",
|
|
50
|
+
"Attorney General"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"STH": {
|
|
54
|
+
office_class_id: "STH",
|
|
55
|
+
name: "State House",
|
|
56
|
+
type: "candidate",
|
|
57
|
+
office_id_template: "[state_id]-H",
|
|
58
|
+
jurisdictions_mutable: true,
|
|
59
|
+
require_district: true,
|
|
60
|
+
require_initial_jurisdiction: false
|
|
61
|
+
},
|
|
62
|
+
"STS": {
|
|
63
|
+
office_class_id: "STS",
|
|
64
|
+
name: "State Senate",
|
|
65
|
+
type: "candidate",
|
|
66
|
+
office_id_template: "[state_id]-S",
|
|
67
|
+
jurisdictions_mutable: true,
|
|
68
|
+
require_district: true,
|
|
69
|
+
require_initial_jurisdiction: false
|
|
70
|
+
},
|
|
71
|
+
"STB": {
|
|
72
|
+
office_class_id: "STB",
|
|
73
|
+
name: "State School Board",
|
|
74
|
+
type: "candidate",
|
|
75
|
+
office_id_template: "[state_id]-B",
|
|
76
|
+
jurisdictions_mutable: true,
|
|
77
|
+
require_district: true,
|
|
78
|
+
require_initial_jurisdiction: false,
|
|
79
|
+
office_names: [
|
|
80
|
+
"Board Member"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"COG": {
|
|
84
|
+
office_class_id: "COG",
|
|
85
|
+
name: "County Government",
|
|
86
|
+
type: "candidate",
|
|
87
|
+
office_id_template: "[state_id]-C",
|
|
88
|
+
jurisdiction_level: JurisdictionLevel.COUNTY,
|
|
89
|
+
jurisdictions_mutable: true,
|
|
90
|
+
require_district: false,
|
|
91
|
+
require_initial_jurisdiction: true,
|
|
92
|
+
office_names: [
|
|
93
|
+
"Mayor",
|
|
94
|
+
"Councillor",
|
|
95
|
+
"Commissioner",
|
|
96
|
+
"Clerk",
|
|
97
|
+
"Recorder",
|
|
98
|
+
"Auditor",
|
|
99
|
+
"Surveyor",
|
|
100
|
+
"Recorder",
|
|
101
|
+
"District Attorney",
|
|
102
|
+
"Sheriff"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"CIG": {
|
|
106
|
+
office_class_id: "CIG",
|
|
107
|
+
name: "City Government",
|
|
108
|
+
type: "candidate",
|
|
109
|
+
office_id_template: "[state_id]-M",
|
|
110
|
+
jurisdiction_level: JurisdictionLevel.CITY,
|
|
111
|
+
jurisdictions_mutable: true,
|
|
112
|
+
require_district: false,
|
|
113
|
+
require_initial_jurisdiction: true,
|
|
114
|
+
office_names: [
|
|
115
|
+
"Mayor",
|
|
116
|
+
"Councillor"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"LOB": {
|
|
120
|
+
office_class_id: "LOB",
|
|
121
|
+
name: "Local School Board",
|
|
122
|
+
type: "candidate",
|
|
123
|
+
office_id_template: "[state_id]-E",
|
|
124
|
+
jurisdictions_mutable: true,
|
|
125
|
+
require_district: false,
|
|
126
|
+
require_initial_jurisdiction: false,
|
|
127
|
+
office_names: [
|
|
128
|
+
"Board Member"
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const party_ids: readonly ["DEM", "REP", "NON", "ETC"];
|
|
2
|
+
export type PartyID = typeof party_ids[number];
|
|
3
|
+
export declare function is_party_id(party_id: any): party_id is PartyID;
|
|
4
|
+
export interface Party {
|
|
5
|
+
party_id: PartyID;
|
|
6
|
+
name: string;
|
|
7
|
+
adjective: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const parties_by_party_id: Record<PartyID, Party>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const party_ids = ["DEM", "REP", "NON", "ETC"];
|
|
2
|
+
export function is_party_id(party_id) {
|
|
3
|
+
return party_ids.includes(party_id);
|
|
4
|
+
}
|
|
5
|
+
export const parties_by_party_id = {
|
|
6
|
+
DEM: {
|
|
7
|
+
party_id: "DEM",
|
|
8
|
+
name: "Democratic Party",
|
|
9
|
+
adjective: "Democratic"
|
|
10
|
+
},
|
|
11
|
+
REP: {
|
|
12
|
+
party_id: "REP",
|
|
13
|
+
name: "Republican Party",
|
|
14
|
+
adjective: "Republican"
|
|
15
|
+
},
|
|
16
|
+
ETC: {
|
|
17
|
+
party_id: "ETC",
|
|
18
|
+
name: "Other Party",
|
|
19
|
+
adjective: "Third-Party"
|
|
20
|
+
},
|
|
21
|
+
NON: {
|
|
22
|
+
party_id: "NON",
|
|
23
|
+
name: "Nonpartisan",
|
|
24
|
+
adjective: "Nonpartisan"
|
|
25
|
+
}
|
|
26
|
+
};
|