legiscan-ts 3.0.0 → 3.0.1
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/README.md +25 -8
- package/dist/cli.mjs +71 -104
- package/dist/index.cjs +96 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1059 -1391
- package/dist/index.d.ts +1059 -1391
- package/dist/index.js +72 -105
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -39,13 +39,30 @@ The client provides async methods corresponding to each API call. For example, t
|
|
|
39
39
|
```js
|
|
40
40
|
let results = await client.getSearch("education AND javascript");
|
|
41
41
|
for (let result of results) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
let details = await client.getBill(result.bill_id);
|
|
43
|
+
Object.assign(result, details);
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Generally, the objects returned by the client methods will match the schema described in the [API documentation](https://legiscan.com/misc/LegiScan_API_User_Manual.pdf), but with some normalization applied. For example, when calling `getBill`, the status, event, and sponsor type fields will be normalized to their string representations, with an added `*_id` property containing the numerical code. This is meant to create more consistency between API calls, some of which return flags as strings and some as numerical codes.
|
|
48
48
|
|
|
49
|
+
## Response schemas
|
|
50
|
+
|
|
51
|
+
The package exports the Zod schemas used to validate the client's normalized responses, such as `zGetBill`, `zGetSearch`, and `zGetSessionList`. You can use their Zod APIs to validate stored responses or compose your own schemas:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { zGetBill, type Bill } from "@ryangarber/legiscan-ts";
|
|
55
|
+
import { z } from "zod";
|
|
56
|
+
|
|
57
|
+
const bill = zGetBill.parse(savedResponse);
|
|
58
|
+
const summarySchema = zGetBill.pick({ bill_id: true, title: true });
|
|
59
|
+
type Summary = z.infer<typeof summarySchema>;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Field descriptions are available at runtime through `.description` and in IntelliSense on schema properties, parsed results, and inferred types. Response types such as `Bill` are inferred directly from these schemas, and the client uses those same types for its return values.
|
|
63
|
+
|
|
64
|
+
These schemas describe the normalized client results. Raw LegiScan API responses may need the conversions performed by the client before they can be parsed.
|
|
65
|
+
|
|
49
66
|
# CLI
|
|
50
67
|
|
|
51
68
|
When installed globally, or when executed from an `npm run` script, the `legiscan` command provides [ND-JSON](https://github.com/ndjson/ndjson-spec) output from API calls. Some of these calls return a lot of results, or need to be filtered, and that's easier to do with newline-delimited output in languages and tools that support streaming from invoked processes.
|
|
@@ -84,13 +101,13 @@ var hash = bill.change_hash;
|
|
|
84
101
|
|
|
85
102
|
var details = db.data.cache[hash];
|
|
86
103
|
if (details) {
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
// use the cached info
|
|
105
|
+
details = JSON.parse(details);
|
|
89
106
|
} else {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
// get a fresh copy and cache it
|
|
108
|
+
details = await client.getBill(bill.bill_id);
|
|
109
|
+
db.data.cache[hash] = JSON.stringify(details);
|
|
110
|
+
await db.write();
|
|
94
111
|
}
|
|
95
112
|
```
|
|
96
113
|
|
package/dist/cli.mjs
CHANGED
|
@@ -319,7 +319,7 @@ const BillType = {
|
|
|
319
319
|
Remonstration: 22,
|
|
320
320
|
CommitteeBill: 23
|
|
321
321
|
};
|
|
322
|
-
const
|
|
322
|
+
const VoteType = {
|
|
323
323
|
Yea: 1,
|
|
324
324
|
Nay: 2,
|
|
325
325
|
Abstain: 3,
|
|
@@ -399,9 +399,8 @@ function zNames(haystack) {
|
|
|
399
399
|
function zNumbers(haystack) {
|
|
400
400
|
return z.union(Object.values(haystack).map((n) => z.literal(n)));
|
|
401
401
|
}
|
|
402
|
-
// src/
|
|
403
|
-
|
|
404
|
-
const _zSession = z.object({
|
|
402
|
+
// src/types.ts
|
|
403
|
+
const SessionSchema = z.object({
|
|
405
404
|
session_id: z.number().describe("Internal session id"),
|
|
406
405
|
session_name: z.string().describe("State specific session name"),
|
|
407
406
|
session_title: z.string().describe("Normalized session title with year(s) and Regular/Nth Special Session"),
|
|
@@ -415,13 +414,11 @@ const _zSession = z.object({
|
|
|
415
414
|
prior: z.boolean().describe("Flag for session being archived"),
|
|
416
415
|
sine_die: z.boolean().describe("Flag for session being adjourned sine die")
|
|
417
416
|
});
|
|
418
|
-
|
|
419
|
-
const zGetSessionList = z.array(_zSession.extend({
|
|
417
|
+
const SessionListSchema = z.array(SessionSchema.extend({
|
|
420
418
|
session_hash: z.hash("md5").nullable().describe("Hash of session data, used for caching"),
|
|
421
419
|
dataset_hash: z.hash("md5").nullable().describe("Hash of entire dataset, used for caching")
|
|
422
420
|
}));
|
|
423
|
-
|
|
424
|
-
const _zBillText = z.object({
|
|
421
|
+
const BillTextSchema = z.object({
|
|
425
422
|
doc_id: z.number().describe("Internal document id"),
|
|
426
423
|
bill_id: z.number().optional().describe("Internal bill id"),
|
|
427
424
|
type: zNames(TextType).describe("Type of draft text"),
|
|
@@ -441,38 +438,30 @@ const _zBillText = z.object({
|
|
|
441
438
|
alt_mime_raw: z.string().nullable().describe("Raw MIME type of the alternate document, e.g. 'application/pdf'"),
|
|
442
439
|
alt_state_link: z.url().nullable().describe("URL of alternate document on state website"),
|
|
443
440
|
alt_text_size: z.number().nullable().describe("Size in bytes of the decoded BASE64 alternate document (add 33% for base64)"),
|
|
444
|
-
alt_text_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded BASE64 alternate document")
|
|
441
|
+
alt_text_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded BASE64 alternate document"),
|
|
442
|
+
doc: z.base64().describe("BASE64 encoded document").nullish(),
|
|
443
|
+
alt_doc: z.base64().describe("BASE64 encoded alternate document").nullish()
|
|
445
444
|
});
|
|
446
|
-
|
|
447
|
-
const zGetBillText = _zBillText.extend({
|
|
448
|
-
doc: z.base64().describe("BASE64 encoded document"),
|
|
449
|
-
alt_doc: z.unknown()
|
|
450
|
-
});
|
|
451
|
-
/** @public */
|
|
452
|
-
const _zCommittee = z.object({
|
|
445
|
+
const CommitteeSchema = z.object({
|
|
453
446
|
committee_id: z.number().describe("Internal committee id"),
|
|
454
447
|
chamber_raw: z.string().describe("Internal chamber name, e.g. 'S' or 'H'"),
|
|
455
448
|
chamber_id: z.number().describe("Internal chamber id"),
|
|
456
449
|
name: z.string().describe("Committee name")
|
|
457
450
|
});
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
/** @public */
|
|
461
|
-
const _zBillProgress = z.object({
|
|
451
|
+
const CommitteeReferralSchema = z.intersection(CommitteeSchema, z.object({ date: z.iso.date().describe("Date of referral") }));
|
|
452
|
+
const BillProgressSchema = z.object({
|
|
462
453
|
date: z.iso.date().describe("Date of progress event"),
|
|
463
454
|
event: zNames(Progress).describe("Normalized progress event"),
|
|
464
455
|
event_id: zNumbers(Progress).describe("Internal progress event id")
|
|
465
456
|
});
|
|
466
|
-
|
|
467
|
-
const _zBillHistory = z.object({
|
|
457
|
+
const BillHistorySchema = z.object({
|
|
468
458
|
date: z.iso.date().describe("Date of action"),
|
|
469
459
|
action: z.string().describe("Description of action taken"),
|
|
470
460
|
chamber_raw: z.string().nullable().describe("Internal chamber name"),
|
|
471
461
|
chamber_id: z.number().nullable().describe("Internal chamber id"),
|
|
472
462
|
importance: z.boolean().describe("Flag for major steps (i.e. those included in progress list)")
|
|
473
463
|
});
|
|
474
|
-
|
|
475
|
-
const _zPerson = z.object({
|
|
464
|
+
const PersonSchema = z.object({
|
|
476
465
|
people_id: z.number().describe("Internal person id"),
|
|
477
466
|
person_hash: z.string().describe("Hash of the person's details, used for caching"),
|
|
478
467
|
party: zNames(Party).describe("Normalized party, e.g. 'Democrat' or 'Republican'"),
|
|
@@ -501,23 +490,18 @@ const _zPerson = z.object({
|
|
|
501
490
|
state_federal: z.unknown(),
|
|
502
491
|
bio: z.unknown()
|
|
503
492
|
});
|
|
504
|
-
|
|
505
|
-
const zGetPerson = _zPerson.extend({});
|
|
506
|
-
/** @public */
|
|
507
|
-
const _zSast = z.object({
|
|
493
|
+
const SastSchema = z.object({
|
|
508
494
|
type: zNames(SastType).describe("Normalized sast type"),
|
|
509
495
|
type_id: zNumbers(SastType).describe("Internal sast id"),
|
|
510
496
|
type_raw: z.string().describe("Internal sast type name"),
|
|
511
497
|
sast_bill_number: z.string().describe("Bill number of the sast, e.g. HB 1234"),
|
|
512
498
|
sast_bill_id: z.number().describe("Internal bill id of the sast")
|
|
513
499
|
});
|
|
514
|
-
|
|
515
|
-
const _zSubject = z.object({
|
|
500
|
+
const SubjectSchema = z.object({
|
|
516
501
|
subject_id: z.number().describe("Internal subject id"),
|
|
517
502
|
subject_name: z.string().describe("Name of the subject")
|
|
518
503
|
});
|
|
519
|
-
|
|
520
|
-
const _zVote = z.object({
|
|
504
|
+
const VoteSchema = z.object({
|
|
521
505
|
roll_call_id: z.number().describe("Internal roll call id"),
|
|
522
506
|
date: z.iso.date().describe("Date of the vote"),
|
|
523
507
|
description: z.string().describe("Description of the vote"),
|
|
@@ -530,8 +514,7 @@ const _zVote = z.object({
|
|
|
530
514
|
chamber_id: z.number().describe("Internal chamber id"),
|
|
531
515
|
chamber_raw: z.string().describe("Internal chamber name, e.g. 'S' or 'H'")
|
|
532
516
|
});
|
|
533
|
-
|
|
534
|
-
const _zAmendment = z.object({
|
|
517
|
+
const AmendmentSchema = z.object({
|
|
535
518
|
amendment_id: z.number().describe("Internal amendment id"),
|
|
536
519
|
adopted: z.boolean().describe("Flag for whether the amendment was adopted"),
|
|
537
520
|
chamber_id: z.number().describe("Internal chamber id"),
|
|
@@ -552,16 +535,12 @@ const _zAmendment = z.object({
|
|
|
552
535
|
alt_mime_raw: z.string().nullable().describe("Raw MIME type of the alternate document, e.g. 'application/pdf'"),
|
|
553
536
|
alt_state_link: z.url().nullable().describe("URL of the alternate document on state website"),
|
|
554
537
|
alt_amendment_size: z.number().nullable().describe("Size in bytes of the decoded alternate BASE64 document (add 33% for base64)"),
|
|
555
|
-
alt_amendment_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded alternate BASE64 document")
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
bill_id: z.number().describe("Internal bill id the amendment belongs to"),
|
|
560
|
-
doc: z.base64().describe("BASE64 encoded document"),
|
|
561
|
-
alt_doc: z.base64().nullable().describe("BASE64 encoded alternate document")
|
|
538
|
+
alt_amendment_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded alternate BASE64 document"),
|
|
539
|
+
bill_id: z.number().describe("Internal bill id the amendment belongs to").nullish(),
|
|
540
|
+
doc: z.base64().describe("BASE64 encoded document").nullish(),
|
|
541
|
+
alt_doc: z.base64().nullable().describe("BASE64 encoded alternate document").nullish()
|
|
562
542
|
});
|
|
563
|
-
|
|
564
|
-
const _zSupplement = z.object({
|
|
543
|
+
const SupplementSchema = z.object({
|
|
565
544
|
supplement_id: z.number().describe("Internal supplement id"),
|
|
566
545
|
date: z.iso.date().nullable().describe("Date of the supplement"),
|
|
567
546
|
type: zNames(SupplementType).describe("Normalized supplement type"),
|
|
@@ -580,16 +559,12 @@ const _zSupplement = z.object({
|
|
|
580
559
|
alt_mime_raw: z.string().nullable().describe("Raw MIME type of the alternate document, e.g. 'application/pdf'"),
|
|
581
560
|
alt_state_link: z.url().nullable().describe("URL of the alternate document on state website"),
|
|
582
561
|
alt_supplement_size: z.number().nullable().describe("Size in bytes of the decoded alternate BASE64 document (add 33% for base64)"),
|
|
583
|
-
alt_supplement_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded alternate BASE64 document")
|
|
562
|
+
alt_supplement_hash: z.hash("md5").nullable().describe("MD5 hash of the decoded alternate BASE64 document"),
|
|
563
|
+
bill_id: z.number().describe("Internal bill id the supplement belongs to").nullish(),
|
|
564
|
+
doc: z.base64().describe("BASE64 encoded document").nullish(),
|
|
565
|
+
alt_doc: z.base64().nullable().describe("BASE64 encoded alternate document").nullish()
|
|
584
566
|
});
|
|
585
|
-
|
|
586
|
-
const zGetSupplement = _zSupplement.extend({
|
|
587
|
-
bill_id: z.number().describe("Internal bill id the supplement belongs to"),
|
|
588
|
-
doc: z.base64().describe("BASE64 encoded document"),
|
|
589
|
-
alt_doc: z.base64().nullable().describe("BASE64 encoded alternate document")
|
|
590
|
-
});
|
|
591
|
-
/** @public */
|
|
592
|
-
const _zEvent = z.object({
|
|
567
|
+
const EventSchema = z.object({
|
|
593
568
|
type: zNames(EventType).describe("Normalized event type"),
|
|
594
569
|
type_id: zNumbers(EventType).describe("Internal event type id"),
|
|
595
570
|
type_raw: z.string().describe("Internal event type name"),
|
|
@@ -598,8 +573,7 @@ const _zEvent = z.object({
|
|
|
598
573
|
location: z.string().nullable().describe("Location of the event (if available)"),
|
|
599
574
|
description: z.string().describe("Description of the event")
|
|
600
575
|
});
|
|
601
|
-
|
|
602
|
-
const _zBill = z.object({
|
|
576
|
+
const BillBaseSchema = z.object({
|
|
603
577
|
bill_id: z.number().describe("Internal bill id"),
|
|
604
578
|
bill_number: z.string().describe("Bill number, e.g. HB 1234"),
|
|
605
579
|
title: z.string().describe("Official bill title"),
|
|
@@ -610,43 +584,40 @@ const _zBill = z.object({
|
|
|
610
584
|
status_date: z.iso.date().nullable().describe("Date of last progress update (if available)"),
|
|
611
585
|
change_hash: z.hash("md5").describe("Hash of bill data, used for caching")
|
|
612
586
|
});
|
|
613
|
-
|
|
614
|
-
const _zBillWithAction = _zBill.extend({
|
|
587
|
+
const MasterListSchema = z.array(BillBaseSchema.extend({
|
|
615
588
|
last_action: z.string().nullable().describe("Description of the bill's last action (if available)"),
|
|
616
589
|
last_action_date: z.iso.date().nullable().describe("Date of the bill's last action (if available)")
|
|
617
|
-
});
|
|
618
|
-
const
|
|
619
|
-
z.array(_zBillWithAction.extend({
|
|
590
|
+
}));
|
|
591
|
+
const SearchSchema = z.array(BillBaseSchema.extend({
|
|
620
592
|
relevance: z.number().describe("Relevance score of the search result"),
|
|
621
593
|
state: zNames(State).describe("Normalized state"),
|
|
622
594
|
state_id: zNumbers(State).describe("Internal state id"),
|
|
623
595
|
bill_id: z.number().describe("Internal bill id"),
|
|
624
596
|
text_url: z.url().describe("URL of the bill text on legiscan.com"),
|
|
625
|
-
research_url: z.url().describe("URL of the bill research page on legiscan.com")
|
|
597
|
+
research_url: z.url().describe("URL of the bill research page on legiscan.com"),
|
|
598
|
+
last_action: z.string().nullable().describe("Description of the bill's last action (if available)"),
|
|
599
|
+
last_action_date: z.iso.date().nullable().describe("Date of the bill's last action (if available)")
|
|
626
600
|
}).omit({
|
|
627
601
|
description: true,
|
|
628
602
|
status: true,
|
|
629
603
|
status_id: true,
|
|
630
604
|
status_date: true
|
|
631
605
|
}));
|
|
632
|
-
|
|
633
|
-
const _zBillVote = _zVote.extend({
|
|
606
|
+
const BillVoteSchema = VoteSchema.extend({
|
|
634
607
|
url: z.url().describe("URL of the vote on legiscan.com"),
|
|
635
608
|
state_link: z.url().describe("URL of the vote on state website")
|
|
636
609
|
});
|
|
637
|
-
|
|
638
|
-
const _zSponsor = _zPerson.extend({
|
|
610
|
+
const SponsorSchema = PersonSchema.extend({
|
|
639
611
|
sponsor_type: zNames(SponsorType).describe("Normalized sponsor type"),
|
|
640
612
|
sponsor_type_id: zNumbers(SponsorType).describe("Internal sponsor type id"),
|
|
641
613
|
sponsor_order: z.number().describe("Order of sponsorship")
|
|
642
614
|
});
|
|
643
|
-
|
|
644
|
-
const zGetBill = _zBill.extend({
|
|
615
|
+
const BillSchema = BillBaseSchema.extend({
|
|
645
616
|
session_id: z.number().describe("Internal session id"),
|
|
646
|
-
session:
|
|
617
|
+
session: SessionSchema.describe("Session object"),
|
|
647
618
|
state_link: z.url().describe("URL of bill on state website"),
|
|
648
619
|
completed: z.boolean().describe("Flag for whether bill is completed"),
|
|
649
|
-
progress: z.array(
|
|
620
|
+
progress: z.array(BillProgressSchema).describe("Major history of the bill (i.e. important items from history)"),
|
|
650
621
|
state: zNames(State).describe("Normalized state"),
|
|
651
622
|
state_id: zNumbers(State).describe("Internal state id"),
|
|
652
623
|
state_raw: z.string().describe("Internal state name"),
|
|
@@ -658,37 +629,33 @@ const zGetBill = _zBill.extend({
|
|
|
658
629
|
current_body_id: z.number().nullable().describe("Internal body id (current)"),
|
|
659
630
|
current_body_raw: z.string().nullable().describe("Internal body name (current)"),
|
|
660
631
|
pending_committee_id: z.number().describe("Internal committee id"),
|
|
661
|
-
committee: z.array(
|
|
662
|
-
referrals: z.array(
|
|
663
|
-
history: z.array(
|
|
664
|
-
sponsors: z.array(
|
|
665
|
-
sasts: z.array(
|
|
666
|
-
subjects: z.array(
|
|
667
|
-
texts: z.array(
|
|
668
|
-
votes: z.array(
|
|
669
|
-
amendments: z.array(
|
|
670
|
-
supplements: z.array(
|
|
671
|
-
calendar: z.array(
|
|
632
|
+
committee: z.array(CommitteeSchema).describe("List of committees if pending"),
|
|
633
|
+
referrals: z.array(CommitteeReferralSchema).describe("History of committee referrals"),
|
|
634
|
+
history: z.array(BillHistorySchema).describe("Full history of the bill"),
|
|
635
|
+
sponsors: z.array(SponsorSchema).describe("Sponsors of the bill"),
|
|
636
|
+
sasts: z.array(SastSchema).describe("SASTs of the bill"),
|
|
637
|
+
subjects: z.array(SubjectSchema).describe("Subjects of the bill"),
|
|
638
|
+
texts: z.array(BillTextSchema).describe("Documents from the bill"),
|
|
639
|
+
votes: z.array(BillVoteSchema).describe("Votes for the bill"),
|
|
640
|
+
amendments: z.array(AmendmentSchema).describe("Amendments to the bill"),
|
|
641
|
+
supplements: z.array(SupplementSchema).describe("Supplements to the bill"),
|
|
642
|
+
calendar: z.array(EventSchema).describe("Events related to the bill")
|
|
672
643
|
});
|
|
673
|
-
|
|
674
|
-
const _zRollCallVote = z.object({
|
|
644
|
+
const RollCallVoteSchema = z.object({
|
|
675
645
|
people_id: z.number().describe("Internal person id"),
|
|
676
|
-
vote: zNames(
|
|
677
|
-
vote_id: zNumbers(
|
|
646
|
+
vote: zNames(VoteType).describe("Vote of the person"),
|
|
647
|
+
vote_id: zNumbers(VoteType).describe("Internal vote id"),
|
|
678
648
|
vote_raw: z.string().describe("Internal vote name")
|
|
679
649
|
});
|
|
680
|
-
|
|
681
|
-
const zGetRollCall = _zVote.extend({
|
|
650
|
+
const RollCallSchema = VoteSchema.extend({
|
|
682
651
|
bill_id: z.number().describe("Internal bill id the vote belongs to"),
|
|
683
|
-
votes: z.array(
|
|
652
|
+
votes: z.array(RollCallVoteSchema).describe("Individual votes for the roll call")
|
|
684
653
|
});
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
/** @public */
|
|
688
|
-
const zGetSponsoredList = z.array(z.object({
|
|
654
|
+
const SessionPeopleSchema = z.array(PersonSchema.extend({}));
|
|
655
|
+
const SponsoredListSchema = z.array(z.object({
|
|
689
656
|
bill_id: z.number().describe("Internal bill id"),
|
|
690
657
|
bill_number: z.string().describe("Bill number, e.g. HB 1234"),
|
|
691
|
-
session:
|
|
658
|
+
session: SessionSchema
|
|
692
659
|
}));
|
|
693
660
|
// src/client.ts
|
|
694
661
|
/**
|
|
@@ -740,7 +707,7 @@ var LegiscanClient = class {
|
|
|
740
707
|
*/
|
|
741
708
|
async getSessionList({ state }) {
|
|
742
709
|
const { sessions } = await this.request("getSessionList", { ...state ? { state: asName(State, state) } : {} });
|
|
743
|
-
return
|
|
710
|
+
return SessionListSchema.parse(sessions.map((s) => ({
|
|
744
711
|
session_id: s.session_id,
|
|
745
712
|
state: asName(State, s.state_id),
|
|
746
713
|
state_id: s.state_id,
|
|
@@ -768,7 +735,7 @@ var LegiscanClient = class {
|
|
|
768
735
|
...state ? { state: asName(State, state) } : {},
|
|
769
736
|
...session ? { id: session.toString() } : {}
|
|
770
737
|
});
|
|
771
|
-
return
|
|
738
|
+
return MasterListSchema.parse(numericalToArray(masterlist).map((b) => ({
|
|
772
739
|
bill_id: b.bill_id,
|
|
773
740
|
bill_number: b.number,
|
|
774
741
|
title: b.title,
|
|
@@ -789,7 +756,7 @@ var LegiscanClient = class {
|
|
|
789
756
|
*/
|
|
790
757
|
async getBillText({ id }) {
|
|
791
758
|
const { text } = await this.request("getBillText", { id });
|
|
792
|
-
return
|
|
759
|
+
return BillTextSchema.parse({
|
|
793
760
|
doc_id: text.doc_id,
|
|
794
761
|
bill_id: text.bill_id,
|
|
795
762
|
type: asName(TextType, text.type_id),
|
|
@@ -822,7 +789,7 @@ var LegiscanClient = class {
|
|
|
822
789
|
async getBill({ id }) {
|
|
823
790
|
const { bill } = await this.request("getBill", { id });
|
|
824
791
|
if (!Array.isArray(bill.committee)) bill.committee = [bill.committee];
|
|
825
|
-
return
|
|
792
|
+
return BillSchema.parse({
|
|
826
793
|
bill_id: bill.bill_id,
|
|
827
794
|
change_hash: bill.change_hash,
|
|
828
795
|
session_id: bill.session_id,
|
|
@@ -1027,7 +994,7 @@ var LegiscanClient = class {
|
|
|
1027
994
|
*/
|
|
1028
995
|
async getAmendment({ id }) {
|
|
1029
996
|
const { amendment } = await this.request("getAmendment", { id });
|
|
1030
|
-
return
|
|
997
|
+
return AmendmentSchema.parse({
|
|
1031
998
|
amendment_id: amendment.amendment_id,
|
|
1032
999
|
bill_id: amendment.bill_id,
|
|
1033
1000
|
adopted: Boolean(amendment.adopted),
|
|
@@ -1061,7 +1028,7 @@ var LegiscanClient = class {
|
|
|
1061
1028
|
*/
|
|
1062
1029
|
async getSupplement({ id }) {
|
|
1063
1030
|
const { supplement } = await this.request("getSupplement", { id });
|
|
1064
|
-
return
|
|
1031
|
+
return SupplementSchema.parse({
|
|
1065
1032
|
supplement_id: supplement.supplement_id,
|
|
1066
1033
|
bill_id: supplement.bill_id,
|
|
1067
1034
|
date: supplement.date !== "0000-00-00" ? supplement.date : null,
|
|
@@ -1093,7 +1060,7 @@ var LegiscanClient = class {
|
|
|
1093
1060
|
*/
|
|
1094
1061
|
async getRollCall({ id }) {
|
|
1095
1062
|
const { roll_call } = await this.request("getRollCall", { id });
|
|
1096
|
-
return
|
|
1063
|
+
return RollCallSchema.parse({
|
|
1097
1064
|
roll_call_id: roll_call.roll_call_id,
|
|
1098
1065
|
bill_id: roll_call.bill_id,
|
|
1099
1066
|
date: roll_call.date,
|
|
@@ -1108,7 +1075,7 @@ var LegiscanClient = class {
|
|
|
1108
1075
|
chamber_raw: roll_call.chamber,
|
|
1109
1076
|
votes: numericalToArray(roll_call.votes).map((v) => ({
|
|
1110
1077
|
people_id: v.people_id,
|
|
1111
|
-
vote: asName(
|
|
1078
|
+
vote: asName(VoteType, v.vote_id),
|
|
1112
1079
|
vote_id: v.vote_id,
|
|
1113
1080
|
vote_raw: v.vote_text
|
|
1114
1081
|
}))
|
|
@@ -1121,7 +1088,7 @@ var LegiscanClient = class {
|
|
|
1121
1088
|
*/
|
|
1122
1089
|
async getPerson({ id }) {
|
|
1123
1090
|
const { person } = await this.request("getPerson", { id });
|
|
1124
|
-
return
|
|
1091
|
+
return PersonSchema.parse({
|
|
1125
1092
|
people_id: person.people_id,
|
|
1126
1093
|
person_hash: person.person_hash,
|
|
1127
1094
|
party: asName(Party, parseInt(person.party_id, 10)),
|
|
@@ -1158,7 +1125,7 @@ var LegiscanClient = class {
|
|
|
1158
1125
|
*/
|
|
1159
1126
|
async getSessionPeople({ id }) {
|
|
1160
1127
|
const { sessionpeople: { people } } = await this.request("getSessionPeople", { id });
|
|
1161
|
-
return
|
|
1128
|
+
return SessionPeopleSchema.parse((people ?? []).map((person) => ({
|
|
1162
1129
|
people_id: person.people_id,
|
|
1163
1130
|
person_hash: person.person_hash,
|
|
1164
1131
|
party: asName(Party, parseInt(person.party_id, 10)),
|
|
@@ -1195,7 +1162,7 @@ var LegiscanClient = class {
|
|
|
1195
1162
|
*/
|
|
1196
1163
|
async getSponsoredList({ id }) {
|
|
1197
1164
|
const { sponsoredbills: { sessions, bills } } = await this.request("getSponsoredList", { id });
|
|
1198
|
-
return
|
|
1165
|
+
return SponsoredListSchema.parse(bills.map((b) => ({
|
|
1199
1166
|
bill_id: b.bill_id,
|
|
1200
1167
|
bill_number: b.number,
|
|
1201
1168
|
session: sessions.map((s) => ({
|
|
@@ -1245,7 +1212,7 @@ var LegiscanClient = class {
|
|
|
1245
1212
|
...state ? { state: asName(State, state) } : {},
|
|
1246
1213
|
...year ? { year: year.toString() } : {}
|
|
1247
1214
|
});
|
|
1248
|
-
yield* numericalToArray(searchresult).map((b) => ({
|
|
1215
|
+
yield* SearchSchema.parse(numericalToArray(searchresult).map((b) => ({
|
|
1249
1216
|
relevance: b.relevance,
|
|
1250
1217
|
state: b.state,
|
|
1251
1218
|
state_id: asNumber(State, b.state),
|
|
@@ -1258,7 +1225,7 @@ var LegiscanClient = class {
|
|
|
1258
1225
|
last_action: b.last_action,
|
|
1259
1226
|
last_action_date: b.last_action_date,
|
|
1260
1227
|
title: b.title
|
|
1261
|
-
}));
|
|
1228
|
+
})));
|
|
1262
1229
|
page++;
|
|
1263
1230
|
if (searchresult.summary.page_total < page) return;
|
|
1264
1231
|
}
|