scout-types 1.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/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/types/APIError.d.ts +4 -0
- package/dist/src/types/APIError.js +19 -0
- package/dist/src/types/Bill.d.ts +19 -0
- package/dist/src/types/Bill.js +47 -0
- package/dist/src/types/Bot.d.ts +28 -0
- package/dist/src/types/Bot.js +72 -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 +16 -0
- package/dist/src/types/Conversation.js +41 -0
- package/dist/src/types/DoersAPIError.d.ts +4 -0
- package/dist/src/types/DoersAPIError.js +19 -0
- package/dist/src/types/DoersIQConfig.d.ts +27 -0
- package/dist/src/types/DoersIQConfig.js +1 -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 +23 -0
- package/dist/src/types/Message.js +63 -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/Scout.d.ts +28 -0
- package/dist/src/types/Scout.js +72 -0
- package/dist/src/types/ScoutConfig.d.ts +27 -0
- package/dist/src/types/ScoutConfig.js +1 -0
- package/dist/src/types/ScoutDocument.d.ts +14 -0
- package/dist/src/types/ScoutDocument.js +38 -0
- package/dist/src/types/Sources.d.ts +50 -0
- package/dist/src/types/Sources.js +138 -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 +14 -0
- package/src/types/APIError.ts +21 -0
- package/src/types/Bill.ts +57 -0
- package/src/types/Conversation.ts +52 -0
- package/src/types/Jurisdiction.ts +62 -0
- package/src/types/JurisdictionDocument.ts +48 -0
- package/src/types/Message.ts +73 -0
- package/src/types/OfficeClass.ts +150 -0
- package/src/types/Party.ts +36 -0
- package/src/types/Scout.ts +83 -0
- package/src/types/ScoutConfig.ts +28 -0
- package/src/types/ScoutDocument.ts +43 -0
- package/src/types/Sources.ts +163 -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,306 @@
|
|
|
1
|
+
const state_ids = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"];
|
|
2
|
+
export function is_state_id(state_id) {
|
|
3
|
+
return state_ids.includes(state_id);
|
|
4
|
+
}
|
|
5
|
+
export const states_by_state_id = {
|
|
6
|
+
AL: {
|
|
7
|
+
state_id: "AL",
|
|
8
|
+
name: "Alabama",
|
|
9
|
+
jurisdiction_id: 2280,
|
|
10
|
+
schools_jurisdiction_id: 13586
|
|
11
|
+
},
|
|
12
|
+
AK: {
|
|
13
|
+
state_id: "AK",
|
|
14
|
+
name: "Alaska",
|
|
15
|
+
jurisdiction_id: 2281,
|
|
16
|
+
schools_jurisdiction_id: 12910
|
|
17
|
+
},
|
|
18
|
+
AZ: {
|
|
19
|
+
state_id: "AZ",
|
|
20
|
+
name: "Arizona",
|
|
21
|
+
jurisdiction_id: 2148,
|
|
22
|
+
schools_jurisdiction_id: 12978
|
|
23
|
+
},
|
|
24
|
+
AR: {
|
|
25
|
+
state_id: "AR",
|
|
26
|
+
name: "Arkansas",
|
|
27
|
+
jurisdiction_id: 2282,
|
|
28
|
+
schools_jurisdiction_id: 12971
|
|
29
|
+
},
|
|
30
|
+
CA: {
|
|
31
|
+
state_id: "CA",
|
|
32
|
+
name: "California",
|
|
33
|
+
jurisdiction_id: 2283,
|
|
34
|
+
schools_jurisdiction_id: 12992
|
|
35
|
+
},
|
|
36
|
+
CO: {
|
|
37
|
+
state_id: "CO",
|
|
38
|
+
name: "Colorado",
|
|
39
|
+
jurisdiction_id: 2284,
|
|
40
|
+
schools_jurisdiction_id: 12897
|
|
41
|
+
},
|
|
42
|
+
CT: {
|
|
43
|
+
state_id: "CT",
|
|
44
|
+
name: "Connecticut",
|
|
45
|
+
jurisdiction_id: 2314,
|
|
46
|
+
schools_jurisdiction_id: 12998
|
|
47
|
+
},
|
|
48
|
+
DE: {
|
|
49
|
+
state_id: "DE",
|
|
50
|
+
name: "Delaware",
|
|
51
|
+
jurisdiction_id: 2315,
|
|
52
|
+
schools_jurisdiction_id: 13105
|
|
53
|
+
},
|
|
54
|
+
FL: {
|
|
55
|
+
state_id: "FL",
|
|
56
|
+
name: "Florida",
|
|
57
|
+
jurisdiction_id: 2316,
|
|
58
|
+
schools_jurisdiction_id: 13111
|
|
59
|
+
},
|
|
60
|
+
GA: {
|
|
61
|
+
state_id: "GA",
|
|
62
|
+
name: "Georgia",
|
|
63
|
+
jurisdiction_id: 2317,
|
|
64
|
+
schools_jurisdiction_id: 13119
|
|
65
|
+
},
|
|
66
|
+
HI: {
|
|
67
|
+
state_id: "HI",
|
|
68
|
+
name: "Hawaii",
|
|
69
|
+
jurisdiction_id: 2156,
|
|
70
|
+
schools_jurisdiction_id: 13127
|
|
71
|
+
},
|
|
72
|
+
ID: {
|
|
73
|
+
state_id: "ID",
|
|
74
|
+
name: "Idaho",
|
|
75
|
+
jurisdiction_id: 2318,
|
|
76
|
+
schools_jurisdiction_id: 13014
|
|
77
|
+
},
|
|
78
|
+
IL: {
|
|
79
|
+
state_id: "IL",
|
|
80
|
+
name: "Illinois",
|
|
81
|
+
jurisdiction_id: 2319,
|
|
82
|
+
schools_jurisdiction_id: 13065
|
|
83
|
+
},
|
|
84
|
+
IN: {
|
|
85
|
+
state_id: "IN",
|
|
86
|
+
name: "Indiana",
|
|
87
|
+
jurisdiction_id: 2159,
|
|
88
|
+
schools_jurisdiction_id: 13068
|
|
89
|
+
},
|
|
90
|
+
IA: {
|
|
91
|
+
state_id: "IA",
|
|
92
|
+
name: "Iowa",
|
|
93
|
+
jurisdiction_id: 2320,
|
|
94
|
+
schools_jurisdiction_id: 12917
|
|
95
|
+
},
|
|
96
|
+
KS: {
|
|
97
|
+
state_id: "KS",
|
|
98
|
+
name: "Kansas",
|
|
99
|
+
jurisdiction_id: 2161,
|
|
100
|
+
schools_jurisdiction_id: 13088
|
|
101
|
+
},
|
|
102
|
+
KY: {
|
|
103
|
+
state_id: "KY",
|
|
104
|
+
name: "Kentucky",
|
|
105
|
+
jurisdiction_id: 2162,
|
|
106
|
+
schools_jurisdiction_id: 13094
|
|
107
|
+
},
|
|
108
|
+
LA: {
|
|
109
|
+
state_id: "LA",
|
|
110
|
+
name: "Louisiana",
|
|
111
|
+
jurisdiction_id: 2163,
|
|
112
|
+
schools_jurisdiction_id: 13130
|
|
113
|
+
},
|
|
114
|
+
ME: {
|
|
115
|
+
state_id: "ME",
|
|
116
|
+
name: "Maine",
|
|
117
|
+
jurisdiction_id: 2164,
|
|
118
|
+
schools_jurisdiction_id: 38491
|
|
119
|
+
},
|
|
120
|
+
MD: {
|
|
121
|
+
state_id: "MD",
|
|
122
|
+
name: "Maryland",
|
|
123
|
+
jurisdiction_id: 2165,
|
|
124
|
+
schools_jurisdiction_id: 14199
|
|
125
|
+
},
|
|
126
|
+
MA: {
|
|
127
|
+
state_id: "MA",
|
|
128
|
+
name: "Massachusetts",
|
|
129
|
+
jurisdiction_id: 2166,
|
|
130
|
+
schools_jurisdiction_id: 13135
|
|
131
|
+
},
|
|
132
|
+
MI: {
|
|
133
|
+
state_id: "MI",
|
|
134
|
+
name: "Michigan",
|
|
135
|
+
jurisdiction_id: 2167,
|
|
136
|
+
schools_jurisdiction_id: 13448
|
|
137
|
+
},
|
|
138
|
+
MN: {
|
|
139
|
+
state_id: "MN",
|
|
140
|
+
name: "Minnesota",
|
|
141
|
+
jurisdiction_id: 2286,
|
|
142
|
+
schools_jurisdiction_id: 13233
|
|
143
|
+
},
|
|
144
|
+
MS: {
|
|
145
|
+
state_id: "MS",
|
|
146
|
+
name: "Mississippi",
|
|
147
|
+
jurisdiction_id: 2287,
|
|
148
|
+
schools_jurisdiction_id: 12965
|
|
149
|
+
},
|
|
150
|
+
MO: {
|
|
151
|
+
state_id: "MO",
|
|
152
|
+
name: "Missouri",
|
|
153
|
+
jurisdiction_id: 2288,
|
|
154
|
+
schools_jurisdiction_id: 12955
|
|
155
|
+
},
|
|
156
|
+
MT: {
|
|
157
|
+
state_id: "MT",
|
|
158
|
+
name: "Montana",
|
|
159
|
+
jurisdiction_id: 2289,
|
|
160
|
+
schools_jurisdiction_id: 38286
|
|
161
|
+
},
|
|
162
|
+
NE: {
|
|
163
|
+
state_id: "NE",
|
|
164
|
+
name: "Nebraska",
|
|
165
|
+
jurisdiction_id: 2290,
|
|
166
|
+
schools_jurisdiction_id: 13050
|
|
167
|
+
},
|
|
168
|
+
NV: {
|
|
169
|
+
state_id: "NV",
|
|
170
|
+
name: "Nevada",
|
|
171
|
+
jurisdiction_id: 2291,
|
|
172
|
+
schools_jurisdiction_id: 13425
|
|
173
|
+
},
|
|
174
|
+
NH: {
|
|
175
|
+
state_id: "NH",
|
|
176
|
+
name: "New Hampshire",
|
|
177
|
+
jurisdiction_id: 2292,
|
|
178
|
+
schools_jurisdiction_id: 13062
|
|
179
|
+
},
|
|
180
|
+
NJ: {
|
|
181
|
+
state_id: "NJ",
|
|
182
|
+
name: "New Jersey",
|
|
183
|
+
jurisdiction_id: 2293,
|
|
184
|
+
schools_jurisdiction_id: 13244
|
|
185
|
+
},
|
|
186
|
+
NM: {
|
|
187
|
+
state_id: "NM",
|
|
188
|
+
name: "New Mexico",
|
|
189
|
+
jurisdiction_id: 2294,
|
|
190
|
+
schools_jurisdiction_id: 13251
|
|
191
|
+
},
|
|
192
|
+
NY: {
|
|
193
|
+
state_id: "NY",
|
|
194
|
+
name: "New York",
|
|
195
|
+
jurisdiction_id: 2295,
|
|
196
|
+
schools_jurisdiction_id: 13429
|
|
197
|
+
},
|
|
198
|
+
NC: {
|
|
199
|
+
state_id: "NC",
|
|
200
|
+
name: "North Carolina",
|
|
201
|
+
jurisdiction_id: 2296,
|
|
202
|
+
schools_jurisdiction_id: 13009
|
|
203
|
+
},
|
|
204
|
+
ND: {
|
|
205
|
+
state_id: "ND",
|
|
206
|
+
name: "North Dakota",
|
|
207
|
+
jurisdiction_id: 2297,
|
|
208
|
+
schools_jurisdiction_id: 13042
|
|
209
|
+
},
|
|
210
|
+
OH: {
|
|
211
|
+
state_id: "OH",
|
|
212
|
+
name: "Ohio",
|
|
213
|
+
jurisdiction_id: 2298,
|
|
214
|
+
schools_jurisdiction_id: 13224
|
|
215
|
+
},
|
|
216
|
+
OK: {
|
|
217
|
+
state_id: "OK",
|
|
218
|
+
name: "Oklahoma",
|
|
219
|
+
jurisdiction_id: 2299,
|
|
220
|
+
schools_jurisdiction_id: 13223
|
|
221
|
+
},
|
|
222
|
+
OR: {
|
|
223
|
+
state_id: "OR",
|
|
224
|
+
name: "Oregon",
|
|
225
|
+
jurisdiction_id: 2300,
|
|
226
|
+
schools_jurisdiction_id: 13221
|
|
227
|
+
},
|
|
228
|
+
PA: {
|
|
229
|
+
state_id: "PA",
|
|
230
|
+
name: "Pennsylvania",
|
|
231
|
+
jurisdiction_id: 2301,
|
|
232
|
+
schools_jurisdiction_id: 12918
|
|
233
|
+
},
|
|
234
|
+
RI: {
|
|
235
|
+
state_id: "RI",
|
|
236
|
+
name: "Rhode Island",
|
|
237
|
+
jurisdiction_id: 2302,
|
|
238
|
+
schools_jurisdiction_id: 12926
|
|
239
|
+
},
|
|
240
|
+
SC: {
|
|
241
|
+
state_id: "SC",
|
|
242
|
+
name: "South Carolina",
|
|
243
|
+
jurisdiction_id: 2303,
|
|
244
|
+
schools_jurisdiction_id: 12929
|
|
245
|
+
},
|
|
246
|
+
SD: {
|
|
247
|
+
state_id: "SD",
|
|
248
|
+
name: "South Dakota",
|
|
249
|
+
jurisdiction_id: 2304,
|
|
250
|
+
schools_jurisdiction_id: 12938
|
|
251
|
+
},
|
|
252
|
+
TN: {
|
|
253
|
+
state_id: "TN",
|
|
254
|
+
name: "Tennessee",
|
|
255
|
+
jurisdiction_id: 2305,
|
|
256
|
+
schools_jurisdiction_id: 12942
|
|
257
|
+
},
|
|
258
|
+
TX: {
|
|
259
|
+
state_id: "TX",
|
|
260
|
+
name: "Texas",
|
|
261
|
+
jurisdiction_id: 2306,
|
|
262
|
+
schools_jurisdiction_id: 12949
|
|
263
|
+
},
|
|
264
|
+
UT: {
|
|
265
|
+
state_id: "UT",
|
|
266
|
+
name: "Utah",
|
|
267
|
+
jurisdiction_id: 2307,
|
|
268
|
+
schools_jurisdiction_id: 65780
|
|
269
|
+
},
|
|
270
|
+
VT: {
|
|
271
|
+
state_id: "VT",
|
|
272
|
+
name: "Vermont",
|
|
273
|
+
jurisdiction_id: 2308,
|
|
274
|
+
schools_jurisdiction_id: 47348
|
|
275
|
+
},
|
|
276
|
+
VA: {
|
|
277
|
+
state_id: "VA",
|
|
278
|
+
name: "Virginia",
|
|
279
|
+
jurisdiction_id: 2309,
|
|
280
|
+
schools_jurisdiction_id: 13026
|
|
281
|
+
},
|
|
282
|
+
WA: {
|
|
283
|
+
state_id: "WA",
|
|
284
|
+
name: "Washington",
|
|
285
|
+
jurisdiction_id: 2310,
|
|
286
|
+
schools_jurisdiction_id: 13032
|
|
287
|
+
},
|
|
288
|
+
WV: {
|
|
289
|
+
state_id: "WV",
|
|
290
|
+
name: "West Virginia",
|
|
291
|
+
jurisdiction_id: 2311,
|
|
292
|
+
schools_jurisdiction_id: 13056
|
|
293
|
+
},
|
|
294
|
+
WI: {
|
|
295
|
+
state_id: "WI",
|
|
296
|
+
name: "Wisconsin",
|
|
297
|
+
jurisdiction_id: 2312,
|
|
298
|
+
schools_jurisdiction_id: 13044
|
|
299
|
+
},
|
|
300
|
+
WY: {
|
|
301
|
+
state_id: "WY",
|
|
302
|
+
name: "Wyoming",
|
|
303
|
+
jurisdiction_id: 2313,
|
|
304
|
+
schools_jurisdiction_id: 13148
|
|
305
|
+
}
|
|
306
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class Tweet {
|
|
2
|
+
readonly tweet_id: string;
|
|
3
|
+
readonly username: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly tweet_time: string;
|
|
6
|
+
readonly tweet_content: string;
|
|
7
|
+
readonly quote?: string;
|
|
8
|
+
readonly html: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
constructor(tweet: any);
|
|
11
|
+
static is(tweet: any): tweet is Tweet;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class Tweet {
|
|
2
|
+
tweet_id;
|
|
3
|
+
username;
|
|
4
|
+
url;
|
|
5
|
+
tweet_time;
|
|
6
|
+
tweet_content;
|
|
7
|
+
quote;
|
|
8
|
+
html;
|
|
9
|
+
text;
|
|
10
|
+
constructor(tweet) {
|
|
11
|
+
if (!Tweet.is(tweet)) {
|
|
12
|
+
throw Error("Invalid input.");
|
|
13
|
+
}
|
|
14
|
+
this.tweet_id = tweet.tweet_id;
|
|
15
|
+
this.username = tweet.username;
|
|
16
|
+
this.url = tweet.url;
|
|
17
|
+
this.tweet_time = tweet.tweet_time;
|
|
18
|
+
this.tweet_content = tweet.tweet_content;
|
|
19
|
+
this.quote = tweet.quote;
|
|
20
|
+
this.html = tweet.html;
|
|
21
|
+
this.text = tweet.text;
|
|
22
|
+
}
|
|
23
|
+
static is(tweet) {
|
|
24
|
+
return (tweet !== undefined &&
|
|
25
|
+
typeof tweet.tweet_id === "string" &&
|
|
26
|
+
typeof tweet.username === "string" &&
|
|
27
|
+
typeof tweet.url === "string" &&
|
|
28
|
+
typeof tweet.tweet_time === "string" &&
|
|
29
|
+
typeof tweet.tweet_content === "string" &&
|
|
30
|
+
(tweet.quote === undefined || typeof tweet.quote === "string") &&
|
|
31
|
+
(typeof tweet.html === "string") &&
|
|
32
|
+
(typeof tweet.text === "string"));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ScoutAux } from "./Scout.js";
|
|
2
|
+
export declare class User {
|
|
3
|
+
readonly user_id: string;
|
|
4
|
+
readonly admin: boolean;
|
|
5
|
+
readonly active: boolean;
|
|
6
|
+
readonly scout_ids: string[];
|
|
7
|
+
readonly email: string;
|
|
8
|
+
readonly [x: string]: any;
|
|
9
|
+
constructor(user: any);
|
|
10
|
+
static is(user: any): user is User;
|
|
11
|
+
}
|
|
12
|
+
export declare class UserAux extends User {
|
|
13
|
+
readonly scouts: ScoutAux[];
|
|
14
|
+
constructor(user: any);
|
|
15
|
+
static is(user: any): user is UserAux;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ScoutAux } from "./Scout.js";
|
|
2
|
+
export class User {
|
|
3
|
+
user_id;
|
|
4
|
+
admin;
|
|
5
|
+
active;
|
|
6
|
+
scout_ids;
|
|
7
|
+
email;
|
|
8
|
+
constructor(user) {
|
|
9
|
+
if (!User.is(user)) {
|
|
10
|
+
throw Error("Invalid Input.");
|
|
11
|
+
}
|
|
12
|
+
this.user_id = user.user_id;
|
|
13
|
+
this.admin = user.admin;
|
|
14
|
+
this.active = user.active;
|
|
15
|
+
this.scout_ids = user.scout_ids;
|
|
16
|
+
this.email = user.email;
|
|
17
|
+
}
|
|
18
|
+
static is(user) {
|
|
19
|
+
return (user !== undefined &&
|
|
20
|
+
typeof user.user_id === "string" &&
|
|
21
|
+
typeof user.admin === "boolean" &&
|
|
22
|
+
typeof user.active === "boolean" &&
|
|
23
|
+
typeof user.email === "string" &&
|
|
24
|
+
Array.isArray(user.scout_ids) &&
|
|
25
|
+
user.scout_ids.every((scout_id) => typeof scout_id === "string"));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class UserAux extends User {
|
|
29
|
+
scouts;
|
|
30
|
+
constructor(user) {
|
|
31
|
+
if (!UserAux.is(user)) {
|
|
32
|
+
throw Error("Invalid Input.");
|
|
33
|
+
}
|
|
34
|
+
super(user);
|
|
35
|
+
this.scouts = user.scouts;
|
|
36
|
+
}
|
|
37
|
+
static is(user) {
|
|
38
|
+
return (User.is(user) &&
|
|
39
|
+
Array.isArray(user.scouts) &&
|
|
40
|
+
user.scouts.every(ScoutAux.is));
|
|
41
|
+
}
|
|
42
|
+
}
|
package/eslint.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { defineConfig } from "eslint/config";
|
|
5
|
+
|
|
6
|
+
export default defineConfig([
|
|
7
|
+
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"], languageOptions: { globals: globals.browser } },
|
|
8
|
+
{
|
|
9
|
+
rules: {
|
|
10
|
+
"@typescript-eslint/explicit-function-return-type": "error"
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
]);
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createDefaultPreset } from "ts-jest"
|
|
2
|
+
|
|
3
|
+
const tsJestTransformCfg = createDefaultPreset().transform;
|
|
4
|
+
|
|
5
|
+
/** @type {import("jest").Config} **/
|
|
6
|
+
export default {
|
|
7
|
+
testEnvironment: "node",
|
|
8
|
+
transform: {
|
|
9
|
+
...tsJestTransformCfg,
|
|
10
|
+
},
|
|
11
|
+
transformIgnorePatterns: ["/node_modules/(?!@smithy|@aws-sdk).+\\.js$"],
|
|
12
|
+
globals : {
|
|
13
|
+
"ts-jest" : {
|
|
14
|
+
useESM : true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
extensionsToTreatAsEsm : [".ts"],
|
|
18
|
+
testTimeout : 30000,
|
|
19
|
+
testPathIgnorePatterns: ['dist/']
|
|
20
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "scout-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/src/index.js",
|
|
5
|
+
"types": "dist/src/index.d.ts",
|
|
6
|
+
"directories": {
|
|
7
|
+
"test": "test"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
11
|
+
"build": "tsc && tsc-alias"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"description": "",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"dependencies": {},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@eslint/js": "^9.39.2",
|
|
20
|
+
"@types/jest": "^30.0.0",
|
|
21
|
+
"eslint": "^9.39.2",
|
|
22
|
+
"globals": "^17.3.0",
|
|
23
|
+
"jest": "^30.2.0",
|
|
24
|
+
"jiti": "^2.6.1",
|
|
25
|
+
"ts-jest": "^29.4.6",
|
|
26
|
+
"tsc-alias": "^1.8.16",
|
|
27
|
+
"tsx": "^4.21.0",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"typescript-eslint": "^8.55.0"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./types/Scout"
|
|
2
|
+
export * from "./types/ScoutDocument"
|
|
3
|
+
export * from "./types/Conversation"
|
|
4
|
+
export * from "./types/APIError"
|
|
5
|
+
export * from "./types/ScoutConfig"
|
|
6
|
+
export * from "./types/Jurisdiction"
|
|
7
|
+
export * from "./types/JurisdictionDocument"
|
|
8
|
+
export * from "./types/Message"
|
|
9
|
+
export * from "./types/OfficeClass"
|
|
10
|
+
export * from "./types/Party"
|
|
11
|
+
export * from "./types/Sources"
|
|
12
|
+
export * from "./types/State"
|
|
13
|
+
export * from "./types/Tweet"
|
|
14
|
+
export * from "./types/User"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const default_messages_by_status : Record<number, string> = {
|
|
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
|
+
504 : "Gateway Timeout",
|
|
9
|
+
600 : "Failed to Parse Output"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export class APIError extends Error {
|
|
14
|
+
status : number
|
|
15
|
+
constructor(status : number, message?: string) {
|
|
16
|
+
const default_message = default_messages_by_status[status]
|
|
17
|
+
super(message !== undefined ? message : default_message !== undefined ? default_message : "Error")
|
|
18
|
+
this.name = "APIError"
|
|
19
|
+
this.status = status
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const bill_types = ["HR", "S", "HJRES", "SJRES", "HCONRES", "SCONRES", "HRES", "SRES"] as const
|
|
2
|
+
|
|
3
|
+
export type BillType = typeof bill_types[number]
|
|
4
|
+
|
|
5
|
+
export function is_bill_type(bill_type : any) : bill_type is BillType {
|
|
6
|
+
return bill_types.includes(bill_type)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class Bill {
|
|
10
|
+
readonly congress_id : number
|
|
11
|
+
readonly bill_id : string
|
|
12
|
+
readonly type : string
|
|
13
|
+
readonly number : number
|
|
14
|
+
readonly title : string
|
|
15
|
+
readonly intro_date? : string
|
|
16
|
+
readonly policy_area_name? : string
|
|
17
|
+
readonly committee_ids? : string[]
|
|
18
|
+
readonly xml_url? : string
|
|
19
|
+
readonly s3_filename? : string
|
|
20
|
+
readonly vector_keys? : string[]
|
|
21
|
+
|
|
22
|
+
constructor(bill : any) {
|
|
23
|
+
if (!Bill.is(bill)) {
|
|
24
|
+
throw Error("Invalid input.")
|
|
25
|
+
}
|
|
26
|
+
this.congress_id = bill.congress_id
|
|
27
|
+
this.bill_id = bill.bill_id
|
|
28
|
+
this.type = bill.type
|
|
29
|
+
this.number = bill.number
|
|
30
|
+
this.title = bill.title
|
|
31
|
+
this.intro_date = bill.intro_date
|
|
32
|
+
this.policy_area_name = bill.policy_area_name
|
|
33
|
+
this.committee_ids = bill.committee_ids
|
|
34
|
+
this.xml_url = bill.xml_url
|
|
35
|
+
this.s3_filename = bill.s3_filename
|
|
36
|
+
this.vector_keys = bill.vector_keys
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static is(bill : any) : bill is Bill {
|
|
41
|
+
return (
|
|
42
|
+
bill !== undefined &&
|
|
43
|
+
typeof bill.congress_id === "number" &&
|
|
44
|
+
typeof bill.bill_id === "string" &&
|
|
45
|
+
typeof bill.type === "string" &&
|
|
46
|
+
typeof bill.number === "number" &&
|
|
47
|
+
typeof bill.title === "string" &&
|
|
48
|
+
(bill.intro_date === undefined || typeof bill.intro_date === "string") &&
|
|
49
|
+
(bill.policy_area_name === undefined || typeof bill.policy_area_name === "string") &&
|
|
50
|
+
(bill.committee_ids === undefined || Array.isArray(bill.committee_ids) && bill.committee_ids.every((committee_id : any) => typeof committee_id === "string")) &&
|
|
51
|
+
(bill.xml_url === undefined || typeof bill.xml_url === "string") &&
|
|
52
|
+
(bill.s3_filename === undefined || typeof bill.s3_filename === "string") &&
|
|
53
|
+
(bill.vector_keys === undefined || Array.isArray(bill.vector_keys) && bill.vector_keys.every((vector_key : any) => typeof vector_key === "string"))
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Message } from "./Message"
|
|
2
|
+
|
|
3
|
+
export class Conversation {
|
|
4
|
+
readonly user_id : string
|
|
5
|
+
readonly conversation_id : string
|
|
6
|
+
readonly scout_id : string
|
|
7
|
+
readonly time : string
|
|
8
|
+
readonly [x : string] : any
|
|
9
|
+
|
|
10
|
+
constructor(conversation : any) {
|
|
11
|
+
if (!Conversation.is(conversation)) {
|
|
12
|
+
throw Error("Invalid input.")
|
|
13
|
+
}
|
|
14
|
+
this.user_id = conversation.user_id
|
|
15
|
+
this.conversation_id = conversation.conversation_id
|
|
16
|
+
this.scout_id = conversation.scout_id
|
|
17
|
+
this.time = conversation.time
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static is(conversation : any) : conversation is Conversation {
|
|
21
|
+
return (
|
|
22
|
+
conversation !== undefined &&
|
|
23
|
+
typeof conversation.user_id === "string" &&
|
|
24
|
+
typeof conversation.conversation_id === "string" &&
|
|
25
|
+
typeof conversation.scout_id === "string" &&
|
|
26
|
+
typeof conversation.time === "string"
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class ConversationAux extends Conversation {
|
|
32
|
+
readonly messages : Message[]
|
|
33
|
+
readonly max_action_time : string
|
|
34
|
+
|
|
35
|
+
constructor(conversation : any) {
|
|
36
|
+
if (!ConversationAux.is(conversation)) {
|
|
37
|
+
throw Error("Invalid input.")
|
|
38
|
+
}
|
|
39
|
+
super(conversation)
|
|
40
|
+
this.messages = conversation.messages
|
|
41
|
+
this.max_action_time = conversation.max_action_time
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static is(conversation : any) : conversation is ConversationAux {
|
|
45
|
+
return (
|
|
46
|
+
Conversation.is(conversation) &&
|
|
47
|
+
Array.isArray(conversation.messages) &&
|
|
48
|
+
conversation.messages.every(Message.is) &&
|
|
49
|
+
typeof conversation.max_action_time === "string"
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export enum JurisdictionLevel {
|
|
2
|
+
OTHER = 0,
|
|
3
|
+
NATION = 1,
|
|
4
|
+
STATE = 2,
|
|
5
|
+
COUNTY = 3,
|
|
6
|
+
CITY = 4,
|
|
7
|
+
SCHOOL = 5
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function is_jurisdiction_level(jurisdiction_level : any) : jurisdiction_level is JurisdictionLevel {
|
|
11
|
+
return [0, 1, 2, 3, 4, 5].includes(jurisdiction_level)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Jurisdiction {
|
|
15
|
+
readonly jurisdiction_id : number
|
|
16
|
+
readonly name : string
|
|
17
|
+
readonly path : number[]
|
|
18
|
+
readonly sub_jurisdiction_ids : number[]
|
|
19
|
+
readonly super_jurisdiction_id? : number
|
|
20
|
+
readonly level : JurisdictionLevel
|
|
21
|
+
readonly state_jurisdiction_id? : number
|
|
22
|
+
readonly county_jurisdiction_id? : number
|
|
23
|
+
readonly city_jurisdiction_id? : number
|
|
24
|
+
readonly school_jurisdiction_id? : number
|
|
25
|
+
readonly geographic : boolean
|
|
26
|
+
|
|
27
|
+
constructor(jurisdiction : any) {
|
|
28
|
+
if (!Jurisdiction.is(jurisdiction)) {
|
|
29
|
+
throw Error("Invalid input.")
|
|
30
|
+
}
|
|
31
|
+
this.jurisdiction_id = jurisdiction.jurisdiction_id
|
|
32
|
+
this.name = jurisdiction.name
|
|
33
|
+
this.path = jurisdiction.path
|
|
34
|
+
this.sub_jurisdiction_ids = jurisdiction.sub_jurisdiction_ids
|
|
35
|
+
this.super_jurisdiction_id = jurisdiction.super_jurisdiction_id
|
|
36
|
+
this.level = jurisdiction.level
|
|
37
|
+
this.state_jurisdiction_id = jurisdiction.state_jurisdiction_id
|
|
38
|
+
this.county_jurisdiction_id = jurisdiction.county_jurisdiction_id
|
|
39
|
+
this.city_jurisdiction_id = jurisdiction.city_jurisdiction_id
|
|
40
|
+
this.school_jurisdiction_id = jurisdiction.school_jurisdiction_id
|
|
41
|
+
this.geographic = jurisdiction.geographic
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static is(jurisdiction : any) : jurisdiction is Jurisdiction {
|
|
45
|
+
return (
|
|
46
|
+
jurisdiction !== undefined &&
|
|
47
|
+
typeof jurisdiction.jurisdiction_id === "number" &&
|
|
48
|
+
typeof jurisdiction.name === "string" &&
|
|
49
|
+
Array.isArray(jurisdiction.path) &&
|
|
50
|
+
jurisdiction.path.every((jurisdiction_id : any) => typeof jurisdiction_id === "number") &&
|
|
51
|
+
Array.isArray(jurisdiction.sub_jurisdiction_ids) &&
|
|
52
|
+
jurisdiction.sub_jurisdiction_ids.every((jurisdiction_id : any) => typeof jurisdiction_id === "number") &&
|
|
53
|
+
is_jurisdiction_level(jurisdiction.level) &&
|
|
54
|
+
typeof jurisdiction.geographic === "boolean" &&
|
|
55
|
+
(jurisdiction.super_jurisdiction_id === undefined || typeof jurisdiction.super_jurisdiction_id === "number") &&
|
|
56
|
+
(jurisdiction.state_jurisdiction_id === undefined || typeof jurisdiction.state_jurisdiction_id === "number") &&
|
|
57
|
+
(jurisdiction.county_jurisdiction_id === undefined || typeof jurisdiction.county_jurisdiction_id === "number") &&
|
|
58
|
+
(jurisdiction.city_jurisdiction_id === undefined || typeof jurisdiction.city_jurisdiction_id === "number") &&
|
|
59
|
+
(jurisdiction.school_jurisdiction_id === undefined || typeof jurisdiction.school_jurisdiction_id === "number")
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|