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.
Files changed (60) hide show
  1. package/dist/src/index.d.ts +14 -0
  2. package/dist/src/index.js +14 -0
  3. package/dist/src/types/APIError.d.ts +4 -0
  4. package/dist/src/types/APIError.js +19 -0
  5. package/dist/src/types/Bill.d.ts +19 -0
  6. package/dist/src/types/Bill.js +47 -0
  7. package/dist/src/types/Bot.d.ts +28 -0
  8. package/dist/src/types/Bot.js +72 -0
  9. package/dist/src/types/BotDocument.d.ts +14 -0
  10. package/dist/src/types/BotDocument.js +38 -0
  11. package/dist/src/types/Conversation.d.ts +16 -0
  12. package/dist/src/types/Conversation.js +41 -0
  13. package/dist/src/types/DoersAPIError.d.ts +4 -0
  14. package/dist/src/types/DoersAPIError.js +19 -0
  15. package/dist/src/types/DoersIQConfig.d.ts +27 -0
  16. package/dist/src/types/DoersIQConfig.js +1 -0
  17. package/dist/src/types/Jurisdiction.d.ts +24 -0
  18. package/dist/src/types/Jurisdiction.js +57 -0
  19. package/dist/src/types/JurisdictionDocument.d.ts +15 -0
  20. package/dist/src/types/JurisdictionDocument.js +44 -0
  21. package/dist/src/types/Message.d.ts +23 -0
  22. package/dist/src/types/Message.js +63 -0
  23. package/dist/src/types/OfficeClass.d.ts +17 -0
  24. package/dist/src/types/OfficeClass.js +132 -0
  25. package/dist/src/types/Party.d.ts +10 -0
  26. package/dist/src/types/Party.js +26 -0
  27. package/dist/src/types/Scout.d.ts +28 -0
  28. package/dist/src/types/Scout.js +72 -0
  29. package/dist/src/types/ScoutConfig.d.ts +27 -0
  30. package/dist/src/types/ScoutConfig.js +1 -0
  31. package/dist/src/types/ScoutDocument.d.ts +14 -0
  32. package/dist/src/types/ScoutDocument.js +38 -0
  33. package/dist/src/types/Sources.d.ts +50 -0
  34. package/dist/src/types/Sources.js +138 -0
  35. package/dist/src/types/State.d.ts +11 -0
  36. package/dist/src/types/State.js +306 -0
  37. package/dist/src/types/Tweet.d.ts +12 -0
  38. package/dist/src/types/Tweet.js +34 -0
  39. package/dist/src/types/User.d.ts +16 -0
  40. package/dist/src/types/User.js +42 -0
  41. package/eslint.config.ts +13 -0
  42. package/jest.config.js +20 -0
  43. package/package.json +31 -0
  44. package/src/index.ts +14 -0
  45. package/src/types/APIError.ts +21 -0
  46. package/src/types/Bill.ts +57 -0
  47. package/src/types/Conversation.ts +52 -0
  48. package/src/types/Jurisdiction.ts +62 -0
  49. package/src/types/JurisdictionDocument.ts +48 -0
  50. package/src/types/Message.ts +73 -0
  51. package/src/types/OfficeClass.ts +150 -0
  52. package/src/types/Party.ts +36 -0
  53. package/src/types/Scout.ts +83 -0
  54. package/src/types/ScoutConfig.ts +28 -0
  55. package/src/types/ScoutDocument.ts +43 -0
  56. package/src/types/Sources.ts +163 -0
  57. package/src/types/State.ts +317 -0
  58. package/src/types/Tweet.ts +38 -0
  59. package/src/types/User.ts +53 -0
  60. package/tsconfig.json +34 -0
@@ -0,0 +1,48 @@
1
+ export 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
+
14
+ constructor(jurisdiction_document : any) {
15
+ if (!JurisdictionDocument.is(jurisdiction_document)) {
16
+ throw Error("Invalid input.")
17
+ }
18
+ this.jurisdiction_id = jurisdiction_document.jurisdiction_id
19
+ this.document_id = jurisdiction_document.document_id
20
+ this.media_id = jurisdiction_document.media_id
21
+ this.origin = jurisdiction_document.origin
22
+ this.s3_filename = jurisdiction_document.s3_filename
23
+ this.time = jurisdiction_document.time
24
+ this.title = jurisdiction_document.title
25
+ this.type = jurisdiction_document.type
26
+ this.url = jurisdiction_document.url
27
+ this.vector_keys = jurisdiction_document.vector_keys
28
+ this.location = jurisdiction_document.location
29
+ }
30
+
31
+ static is(jurisdiction_document : any) : jurisdiction_document is JurisdictionDocument {
32
+ return (
33
+ jurisdiction_document !== undefined &&
34
+ typeof jurisdiction_document.jurisdiction_id === "number" &&
35
+ typeof jurisdiction_document.document_id === "string" &&
36
+ typeof jurisdiction_document.media_id === "string" &&
37
+ typeof jurisdiction_document.origin === "string" &&
38
+ (jurisdiction_document.s3_filename === undefined || typeof jurisdiction_document.s3_filename === "string") &&
39
+ (jurisdiction_document.time === undefined || typeof jurisdiction_document.time === "string") &&
40
+ typeof jurisdiction_document.title === "string" &&
41
+ typeof jurisdiction_document.type === "string" &&
42
+ typeof jurisdiction_document.url === "string" &&
43
+ (jurisdiction_document.vector_keys === undefined || Array.isArray(jurisdiction_document.vector_keys) &&
44
+ jurisdiction_document.vector_keys.every((vector_key : any) => typeof vector_key === "string")) &&
45
+ (jurisdiction_document.location === undefined || typeof jurisdiction_document.location === "string")
46
+ )
47
+ }
48
+ }
@@ -0,0 +1,73 @@
1
+ import { Sources } from "./Sources"
2
+
3
+ export class Fragment {
4
+ readonly text : string
5
+ readonly sources : Sources
6
+
7
+ constructor(fragment : any) {
8
+ if (!Fragment.is(fragment)) {
9
+ throw Error("Invalid input.")
10
+ }
11
+ this.text = fragment.text
12
+ this.sources = fragment.sources
13
+ }
14
+
15
+ static is(fragment : any) : fragment is Fragment {
16
+ return (
17
+ fragment !== undefined &&
18
+ typeof fragment.text === "string" &&
19
+ Sources.is(fragment.sources)
20
+ )
21
+ }
22
+ }
23
+
24
+ export class Message {
25
+ readonly user_id : string
26
+ readonly message_id : string
27
+ readonly scout_id : string
28
+ readonly conversation_id : string
29
+ readonly time : string
30
+ readonly mode : "chat" | "write"
31
+ readonly role : "user" | "scout"
32
+ readonly system_prompt? : string
33
+ readonly grok_text? : string
34
+ readonly fragments? : Fragment[]
35
+ readonly sources? : Sources
36
+ readonly text : string
37
+
38
+ constructor(message : any) {
39
+ if (!Message.is(message)) {
40
+ throw Error("Invalid input.")
41
+ }
42
+ this.user_id = message.user_id
43
+ this.message_id = message.message_id
44
+ this.scout_id = message.scout_id
45
+ this.conversation_id = message.conversation_id
46
+ this.time = message.time
47
+ this.mode = message.mode
48
+ this.role = message.role
49
+ this.system_prompt = message.system_prompt
50
+ this.grok_text = message.grok_text
51
+ this.fragments = message.fragments
52
+ this.sources = message.sources
53
+ this.text = message.text
54
+ }
55
+
56
+ static is(message : any) : message is Message {
57
+ return (
58
+ message !== undefined &&
59
+ typeof message.user_id === "string" &&
60
+ typeof message.message_id === "string" &&
61
+ typeof message.scout_id === "string" &&
62
+ typeof message.conversation_id === "string" &&
63
+ typeof message.time === "string" &&
64
+ ["chat", "write"].includes(message.mode) &&
65
+ ["user", "scout"].includes(message.role) &&
66
+ (message.system_prompt === undefined || typeof message.system_prompt === "string") &&
67
+ (message.grok_text === undefined || typeof message.grok_text === "string") &&
68
+ (message.fragments === undefined || Array.isArray(message.fragments) && message.fragments.every(Fragment.is)) &&
69
+ (message.sources === undefined || Sources.is(message.sources)) &&
70
+ typeof message.text === "string"
71
+ )
72
+ }
73
+ }
@@ -0,0 +1,150 @@
1
+ import { JurisdictionLevel } from "./Jurisdiction"
2
+
3
+ const office_class_ids = ["ORG", "USH", "USS", "STG", "STH", "STS", "STB", "COG", "CIG", "LOB"] as const
4
+
5
+ export type OfficeClassID = typeof office_class_ids[number]
6
+
7
+ export function is_office_class_id(office_class_id : any) : office_class_id is OfficeClassID {
8
+ return office_class_ids.includes(office_class_id)
9
+ }
10
+
11
+ export interface OfficeClass {
12
+ office_class_id : OfficeClassID,
13
+ name : string,
14
+ type : "candidate" | "organization",
15
+ office_id_template : string,
16
+ jurisdiction_level? : JurisdictionLevel,
17
+ jurisdictions_mutable : Boolean,
18
+ require_district : Boolean,
19
+ require_initial_jurisdiction : Boolean,
20
+ office_names? : string[]
21
+
22
+ }
23
+
24
+ export const office_classes_by_office_class_id : Record<OfficeClassID, OfficeClass> = {
25
+ "ORG" : {
26
+ office_class_id : "ORG",
27
+ name : "Organization",
28
+ type : "organization",
29
+ office_id_template : "O-[state_id]",
30
+ jurisdictions_mutable : true,
31
+ require_district : false,
32
+ require_initial_jurisdiction : false
33
+ },
34
+ "USH" : {
35
+ office_class_id : "USH",
36
+ name : "U.S. House",
37
+ type : "candidate",
38
+ office_id_template : "H-[state_id]",
39
+ jurisdictions_mutable : true,
40
+ require_district : true,
41
+ require_initial_jurisdiction : false
42
+ },
43
+ "USS" : {
44
+ office_class_id : "USS",
45
+ name : "U.S. Senate",
46
+ type : "candidate",
47
+ office_id_template : "S-[state_id]",
48
+ jurisdiction_level : JurisdictionLevel.STATE,
49
+ jurisdictions_mutable : false,
50
+ require_district : false,
51
+ require_initial_jurisdiction : false
52
+ },
53
+ "STG" : {
54
+ office_class_id : "STG",
55
+ name : "State (Executive) Government",
56
+ type : "candidate",
57
+ office_id_template : "[state_id]-G",
58
+ jurisdiction_level : JurisdictionLevel.STATE,
59
+ jurisdictions_mutable : false,
60
+ require_district : false,
61
+ require_initial_jurisdiction : false,
62
+ office_names : [
63
+ "Governor",
64
+ "Lieutenant Governor",
65
+ "Secretary of State",
66
+ "Treasurer",
67
+ "Auditor",
68
+ "Attorney General"
69
+ ]
70
+ },
71
+ "STH" : {
72
+ office_class_id : "STH",
73
+ name : "State House",
74
+ type : "candidate",
75
+ office_id_template : "[state_id]-H",
76
+ jurisdictions_mutable : true,
77
+ require_district : true,
78
+ require_initial_jurisdiction : false
79
+ },
80
+ "STS" : {
81
+ office_class_id : "STS",
82
+ name : "State Senate",
83
+ type : "candidate",
84
+ office_id_template : "[state_id]-S",
85
+ jurisdictions_mutable : true,
86
+ require_district : true,
87
+ require_initial_jurisdiction : false
88
+ },
89
+ "STB" : {
90
+ office_class_id : "STB",
91
+ name : "State School Board",
92
+ type : "candidate",
93
+ office_id_template : "[state_id]-B",
94
+ jurisdiction_level : JurisdictionLevel.SCHOOL,
95
+ jurisdictions_mutable : true,
96
+ require_district : true,
97
+ require_initial_jurisdiction : true,
98
+ office_names : [
99
+ "Board Member"
100
+ ]
101
+ },
102
+ "COG" : {
103
+ office_class_id : "COG",
104
+ name : "County Government",
105
+ type : "candidate",
106
+ office_id_template : "[state_id]-C",
107
+ jurisdiction_level : JurisdictionLevel.COUNTY,
108
+ jurisdictions_mutable : true,
109
+ require_district : false,
110
+ require_initial_jurisdiction : true,
111
+ office_names : [
112
+ "Mayor",
113
+ "Councillor",
114
+ "Commissioner",
115
+ "Clerk",
116
+ "Recorder",
117
+ "Auditor",
118
+ "Surveyor",
119
+ "District Attorney",
120
+ "Sheriff"
121
+ ]
122
+ },
123
+ "CIG" : {
124
+ office_class_id : "CIG",
125
+ name : "City Government",
126
+ type : "candidate",
127
+ office_id_template : "[state_id]-M",
128
+ jurisdiction_level : JurisdictionLevel.CITY,
129
+ jurisdictions_mutable : true,
130
+ require_district : false,
131
+ require_initial_jurisdiction : true,
132
+ office_names : [
133
+ "Mayor",
134
+ "Councillor"
135
+ ]
136
+ },
137
+ "LOB" : {
138
+ office_class_id : "LOB",
139
+ name : "Local School Board",
140
+ type : "candidate",
141
+ office_id_template : "[state_id]-E",
142
+ jurisdiction_level : JurisdictionLevel.SCHOOL,
143
+ jurisdictions_mutable : true,
144
+ require_district : false,
145
+ require_initial_jurisdiction : true,
146
+ office_names : [
147
+ "Board Member"
148
+ ]
149
+ }
150
+ }
@@ -0,0 +1,36 @@
1
+ const party_ids = ["DEM", "REP", "NON", "ETC"] as const
2
+
3
+ export type PartyID = typeof party_ids[number]
4
+
5
+ export function is_party_id(party_id : any) : party_id is PartyID {
6
+ return party_ids.includes(party_id)
7
+ }
8
+
9
+ export interface Party {
10
+ party_id : PartyID,
11
+ name : string,
12
+ adjective : string
13
+ }
14
+
15
+ export const parties_by_party_id : Record<PartyID, Party> = {
16
+ DEM : {
17
+ party_id : "DEM",
18
+ name : "Democratic Party",
19
+ adjective : "Democratic"
20
+ },
21
+ REP : {
22
+ party_id : "REP",
23
+ name : "Republican Party",
24
+ adjective : "Republican"
25
+ },
26
+ ETC : {
27
+ party_id : "ETC",
28
+ name : "Other Party",
29
+ adjective : "Third-Party"
30
+ },
31
+ NON : {
32
+ party_id : "NON",
33
+ name : "Nonpartisan",
34
+ adjective : "Nonpartisan"
35
+ }
36
+ }
@@ -0,0 +1,83 @@
1
+ import { is_office_class_id, OfficeClassID } from "./OfficeClass"
2
+ import { Jurisdiction } from "./Jurisdiction"
3
+ import { is_state_id, StateID } from "./State"
4
+ import { is_party_id, PartyID } from "./Party"
5
+
6
+ export class Scout {
7
+ readonly office_id : string
8
+ readonly number : string
9
+ readonly scout_id : string
10
+ readonly name : string
11
+ readonly active : boolean
12
+ readonly state_id : StateID
13
+ readonly district? : number
14
+ readonly party_id : PartyID
15
+ readonly tone_description_refresh : boolean
16
+ readonly jurisdiction_ids : number[]
17
+ readonly office_class_id : OfficeClassID
18
+ readonly office_name? : string
19
+ readonly [x : string] : any
20
+
21
+ constructor(scout : any) {
22
+ if (!Scout.is(scout)) {
23
+ throw Error("Invalid input.")
24
+ }
25
+ this.office_id = scout.office_id
26
+ this.number = scout.number
27
+ this.scout_id = scout.scout_id
28
+ this.name = scout.name
29
+ this.active = scout.active
30
+ this.state_id = scout.state_id
31
+ this.district = scout.district
32
+ this.party_id = scout.party_id
33
+ this.tone_description_refresh = scout.tone_description_refresh
34
+ this.jurisdiction_ids = scout.jurisdiction_ids
35
+ this.office_class_id = scout.office_class_id
36
+ this.office_name = scout.office_name
37
+ }
38
+
39
+ static is(scout : any) : scout is Scout {
40
+ return (
41
+ scout !== undefined &&
42
+ typeof scout.office_id === "string" &&
43
+ typeof scout.number === "string" &&
44
+ typeof scout.scout_id === "string" &&
45
+ typeof scout.name === "string" &&
46
+ typeof scout.active === "boolean" &&
47
+ is_state_id(scout.state_id) &&
48
+ (scout.district === undefined || typeof scout.district === "number") &&
49
+ is_party_id(scout.party_id) &&
50
+ typeof scout.tone_description_refresh === "boolean" &&
51
+ Array.isArray(scout.jurisdiction_ids) &&
52
+ scout.jurisdiction_ids.every((jurisdiction_id : any) => typeof jurisdiction_id === "number") &&
53
+ is_office_class_id(scout.office_class_id) &&
54
+ (scout.office_name === undefined || typeof scout.office_name === "string")
55
+ )
56
+ }
57
+ }
58
+
59
+ export class ScoutAux extends Scout {
60
+ readonly jurisdictions : Jurisdiction[]
61
+ readonly photo_download_url? : string
62
+ readonly tone_description? : string
63
+
64
+ constructor(scout : any) {
65
+ if (!ScoutAux.is(scout)) {
66
+ throw Error("Invalid input.")
67
+ }
68
+ super(scout)
69
+ this.jurisdictions = scout.jurisdictions
70
+ this.photo_download_url = scout.photo_download_url
71
+ this.tone_description = scout.tone_description
72
+ }
73
+
74
+ static is(scout : any) : scout is ScoutAux {
75
+ return (
76
+ Scout.is(scout) &&
77
+ Array.isArray(scout.jurisdictions) &&
78
+ scout.jurisdictions.every(Jurisdiction.is) &&
79
+ (scout.photo_download_url === undefined || typeof scout.photo_download_url === "string") &&
80
+ (scout.tone_description === undefined || typeof scout.tone_description === "string")
81
+ )
82
+ }
83
+ }
@@ -0,0 +1,28 @@
1
+ export interface ScoutUtilsConfig {
2
+ region : string,
3
+ scraping_bee_api_key? : string,
4
+ xai_api_key? : string,
5
+ citizenportal_api_key? : string,
6
+ [key : string]: any
7
+ }
8
+
9
+ export interface ScoutConfig extends ScoutUtilsConfig {
10
+ port : number,
11
+ api_url : string,
12
+ client_url : string,
13
+ auth_url : string,
14
+ cognito_user_pool_id : string,
15
+ cognito_client_id : string,
16
+ cognito_client_secret : string,
17
+ secret_key : string,
18
+ admin_key : string,
19
+ dynamodb_scouts : string,
20
+ dynamodb_scout_documents : string,
21
+ dynamodb_conversations : string,
22
+ dynamodb_jurisdictions : string,
23
+ dynamodb_jurisdiction_documents : string,
24
+ dynamodb_messages : string,
25
+ dynamodb_users : string,
26
+ s3_bucket : string,
27
+ s3vectors_bucket : string
28
+ }
@@ -0,0 +1,43 @@
1
+ import { Tweet } from "./Tweet"
2
+
3
+ export class ScoutDocument {
4
+ readonly scout_id : string
5
+ readonly document_id : string
6
+ readonly type : "URL" | "TWEET" | "TWITTER"
7
+ readonly s3_filename? : string
8
+ readonly url? : string
9
+ readonly username? : string
10
+ readonly vector_keys? : string[]
11
+ readonly tweet? : Tweet
12
+ readonly text? : string
13
+
14
+ constructor(scout_document : any) {
15
+ if (!ScoutDocument.is(scout_document)) {
16
+ throw Error("Invalid input.")
17
+ }
18
+ this.scout_id = scout_document.scout_id
19
+ this.document_id = scout_document.document_id
20
+ this.type = scout_document.type
21
+ this.s3_filename = scout_document.s3_filename
22
+ this.url = scout_document.url
23
+ this.username = scout_document.username
24
+ this.vector_keys = scout_document.vector_keys
25
+ this.tweet = scout_document.tweet
26
+ this.text = scout_document.text
27
+ }
28
+
29
+ static is(scout_document : any) : scout_document is ScoutDocument {
30
+ return (
31
+ scout_document !== undefined &&
32
+ typeof scout_document.scout_id === "string" &&
33
+ typeof scout_document.document_id === "string" &&
34
+ typeof scout_document.type === "string" &&
35
+ (scout_document.s3_filename === undefined || typeof scout_document.s3_filename === "string") &&
36
+ (scout_document.url === undefined || typeof scout_document.url === "string") &&
37
+ (scout_document.username === undefined || typeof scout_document.username === "string") &&
38
+ (scout_document.vector_keys === undefined || Array.isArray(scout_document.vector_keys) && scout_document.vector_keys.every((vector_key : any) => typeof vector_key === "string")) &&
39
+ (scout_document.tweet === undefined || Tweet.is(scout_document.tweet)) &&
40
+ (scout_document.text === undefined || typeof scout_document.text === "string")
41
+ )
42
+ }
43
+ }
@@ -0,0 +1,163 @@
1
+ import { ScoutDocument } from "./ScoutDocument"
2
+ import { JurisdictionDocument } from "./JurisdictionDocument"
3
+ import { Bill } from "./Bill"
4
+
5
+ export class ScoutDocumentSource {
6
+ readonly chunk_text : string
7
+ readonly description : string
8
+ readonly label : string
9
+ readonly type : string
10
+ readonly vector_key : string
11
+ readonly document : ScoutDocument
12
+
13
+ constructor(scout_document_source : any) {
14
+ if (!ScoutDocumentSource.is(scout_document_source)) {
15
+ throw Error("Invalid input.")
16
+ }
17
+ this.chunk_text = scout_document_source.chunk_text
18
+ this.description = scout_document_source.description
19
+ this.label = scout_document_source.label
20
+ this.type = scout_document_source.type
21
+ this.vector_key = scout_document_source.vector_key
22
+ this.document = scout_document_source.document
23
+ }
24
+
25
+ static is(scout_document_source : any) : scout_document_source is ScoutDocumentSource {
26
+ return (
27
+ scout_document_source !== undefined &&
28
+ typeof scout_document_source.chunk_text === "string" &&
29
+ typeof scout_document_source.description === "string" &&
30
+ typeof scout_document_source.label === "string" &&
31
+ typeof scout_document_source.type === "string" &&
32
+ typeof scout_document_source.vector_key === "string" &&
33
+ ScoutDocument.is(scout_document_source.document)
34
+ )
35
+ }
36
+ }
37
+
38
+ export class JurisdictionDocumentSource {
39
+ readonly chunk_text : string
40
+ readonly description : string
41
+ readonly label : string
42
+ readonly type : string
43
+ readonly vector_key : string
44
+ readonly document : JurisdictionDocument
45
+
46
+ constructor(jurisdiction_document_source : any) {
47
+ if (!JurisdictionDocumentSource.is(jurisdiction_document_source)) {
48
+ throw Error("Invalid input.")
49
+ }
50
+ this.chunk_text = jurisdiction_document_source.chunk_text
51
+ this.description = jurisdiction_document_source.description
52
+ this.label = jurisdiction_document_source.label
53
+ this.type = jurisdiction_document_source.type
54
+ this.vector_key = jurisdiction_document_source.vector_key
55
+ this.document = jurisdiction_document_source.document
56
+ }
57
+
58
+ static is(jurisdiction_document_source : any) : jurisdiction_document_source is JurisdictionDocumentSource {
59
+ return (
60
+ jurisdiction_document_source !== undefined &&
61
+ typeof jurisdiction_document_source.chunk_text === "string" &&
62
+ typeof jurisdiction_document_source.description === "string" &&
63
+ typeof jurisdiction_document_source.label === "string" &&
64
+ typeof jurisdiction_document_source.type === "string" &&
65
+ typeof jurisdiction_document_source.vector_key === "string" &&
66
+ JurisdictionDocument.is(jurisdiction_document_source.document)
67
+ )
68
+ }
69
+ }
70
+
71
+ export class BillDocumentSource {
72
+ readonly chunk_text : string
73
+ readonly description : string
74
+ readonly label : string
75
+ readonly type : string
76
+ readonly vector_key : string
77
+ readonly bill : Bill
78
+
79
+ constructor(bill_document_source : any) {
80
+ if (!BillDocumentSource.is(bill_document_source)) {
81
+ throw Error("Invalid input.")
82
+ }
83
+ this.chunk_text = bill_document_source.chunk_text
84
+ this.description = bill_document_source.description
85
+ this.label = bill_document_source.label
86
+ this.type = bill_document_source.type
87
+ this.vector_key = bill_document_source.vector_key
88
+ this.bill = bill_document_source.bill
89
+ }
90
+
91
+ static is(bill_document_source : any) : bill_document_source is BillDocumentSource {
92
+ return (
93
+ bill_document_source !== undefined &&
94
+ typeof bill_document_source.chunk_text === "string" &&
95
+ typeof bill_document_source.description === "string" &&
96
+ typeof bill_document_source.label === "string" &&
97
+ typeof bill_document_source.type === "string" &&
98
+ typeof bill_document_source.vector_key === "string" &&
99
+ Bill.is(bill_document_source.bill)
100
+ )
101
+ }
102
+ }
103
+
104
+ export class GrokSource {
105
+ readonly title : string
106
+ readonly url : string
107
+ readonly start_index : number
108
+ readonly end_index : number
109
+ readonly type : string
110
+
111
+ constructor(grok_source : any) {
112
+ if (!GrokSource.is(grok_source)) {
113
+ throw Error("Invalid input.")
114
+ }
115
+ this.title = grok_source.title
116
+ this.url = grok_source.url
117
+ this.start_index = grok_source.start_index
118
+ this.end_index = grok_source.end_index
119
+ this.type = grok_source.type
120
+ }
121
+
122
+ static is(grok_source : any) : grok_source is GrokSource {
123
+ return (
124
+ grok_source !== undefined &&
125
+ typeof grok_source.title === "string" &&
126
+ typeof grok_source.url === "string" &&
127
+ typeof grok_source.start_index === "number" &&
128
+ typeof grok_source.end_index === "number" &&
129
+ typeof grok_source.type === "string"
130
+ )
131
+ }
132
+ }
133
+
134
+ export class Sources {
135
+ readonly B : BillDocumentSource[]
136
+ readonly S : ScoutDocumentSource[]
137
+ readonly J : JurisdictionDocumentSource[]
138
+ readonly G : GrokSource[]
139
+
140
+ constructor(sources : any) {
141
+ if (!Sources.is(sources)) {
142
+ throw Error("Invalid input.")
143
+ }
144
+ this.B = sources.B
145
+ this.S = sources.S
146
+ this.J = sources.J
147
+ this.G = sources.G
148
+ }
149
+
150
+ static is(sources : any) : sources is Sources {
151
+ return (
152
+ sources !== undefined &&
153
+ Array.isArray(sources.B) &&
154
+ sources.B.every(BillDocumentSource.is) &&
155
+ Array.isArray(sources.S) &&
156
+ sources.S.every(ScoutDocumentSource.is) &&
157
+ Array.isArray(sources.J) &&
158
+ sources.J.every(JurisdictionDocumentSource.is) &&
159
+ Array.isArray(sources.G) &&
160
+ sources.G.every(GrokSource.is)
161
+ )
162
+ }
163
+ }