import {z} from 'zod' export type GetApiApiV1UsSessionLawsListArgs = {jurisdiction: 'al' | 'ak' | 'as' | 'az' | 'ar' | 'ca' | 'co' | 'ct' | 'de' | 'dc' | 'fl' | 'ga' | 'gu' | 'hi' | 'id' | 'il' | 'in' | 'ia' | 'ks' | 'ky' | 'la' | 'me' | 'md' | 'ma' | 'mi' | 'mn' | 'ms' | 'mo' | 'mt' | 'ne' | 'nv' | 'nh' | 'nj' | 'nm' | 'ny' | 'nc' | 'nd' | 'mp' | 'oh' | 'ok' | 'or' | 'pa' | 'pr' | 'ri' | 'sc' | 'sd' | 'tn' | 'tx' | 'ut' | 'vt' | 'vi' | 'va' | 'wa' | 'wv' | 'wi' | 'wy', session?: (string | null) | undefined, series?: (Array<'general' | 'public' | 'public_act' | 'special_act' | 'private_and_special' | 'act' | 'acts' | 'law' | 'local' | 'municipal' | 'appropriation' | 'resolve' | 'resolves' | 'resolution' | 'resolution_chapter' | 'joint_resolution' | 'concurrent_resolution' | 'memorial' | 'initiated_bill' | 'constitutional_amendment' | 'private' | 'constitutional_resolution' | 'competing_measure_resolution' | 'resolution_act'> | null) | undefined, instrumentType?: (Array<'act' | 'joint_resolution' | 'concurrent_resolution' | 'resolution' | 'resolve' | 'memorial' | 'other'> | null) | undefined, approvedFrom?: (string | null) | undefined, approvedTo?: (string | null) | undefined, effectiveFrom?: (string | null) | undefined, effectiveTo?: (string | null) | undefined, hasText?: (boolean | null) | undefined, textStatus?: ('held' | 'withheld' | 'not_held' | 'pending' | null) | undefined, isLaw?: (boolean | null) | undefined, enactmentOutcome?: (Array<'signed' | 'became_law_without_signature' | 'veto_overridden' | 'line_item_veto' | 'vetoed' | 'pocket_veto' | 'not_presented' | 'approved_by_voters' | 'unknown'> | null) | undefined, updatedSince?: (string | null) | undefined, q?: (string | null) | undefined, order?: ('asc' | 'desc') | undefined, cursor?: (string | null) | undefined, limit?: number | undefined, 'Idempotency-Key'?: (string | null) | undefined}; export type GetApiApiV1UsSessionLawsListOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const sessionLawSession = z.object({code: z.string(), label: z.string().nullable().optional(), type: z.string().nullable().optional(), year: z.number().int().nullable().optional()}); export const sessionLawSummary = z.object({sessionLawId: z.string(), lawId: z.string().nullable().optional(), jurisdiction: z.string(), citation: z.string(), citableAs: z.string().nullable().optional(), citationShort: z.string().nullable().optional(), session: sessionLawSession, series: z.string(), instrumentType: z.string(), number: z.string().nullable().optional(), billKey: z.string().nullable().optional(), billNumber: z.string().nullable().optional(), numberingYear: z.number().int().nullable().optional(), title: z.string().nullable().optional(), shortTitle: z.string().nullable().optional(), approvedDate: z.string().nullable().optional(), approvedDateDerived: z.boolean().optional(), effectiveFirst: z.string().nullable().optional(), effectiveLast: z.string().nullable().optional(), enactmentOutcome: z.string(), isLaw: z.boolean().nullable().optional(), textStatus: z.enum(["held", "withheld", "not_held", "pending"]), withheldReason: z.string().nullable().optional(), charCount: z.number().int().nullable().optional(), estimatedBodyPages: z.number().int().nullable().optional(), textSha256: z.string().nullable().optional(), versionNo: z.number().int().nullable().optional(), amendatoryMarkup: z.string().nullable().optional(), markupConvention: z.string().nullable().optional(), documentKind: z.string().nullable().optional(), identityConfidence: z.string(), officialUrl: z.string().nullable().optional(), officialUrlBasis: z.string().nullable().optional(), licenseNote: z.string().nullable().optional(), updatedAt: z.string().nullable().optional()}); export const sessionLawListCoverage = z.object({scope: z.enum(["session", "jurisdiction"]), jurisdiction: z.string(), status: z.enum(["complete", "partial", "not_held", "filter_unavailable"]), unavailableFilters: z.array(z.string()).optional(), session: sessionLawSession.nullable().optional(), sessionsHeld: z.number().int().gte(0).optional(), partialSessions: z.array(z.string()).optional(), reason: z.string().nullable().optional(), message: z.string()}); export const sessionLawListResponse = z.object({processingTimeMs: z.number().optional(), creditsConsumed: z.number().int().optional(), results: z.array(sessionLawSummary).optional(), count: z.number().int().optional(), nextCursor: z.string().nullable().optional(), hasMore: z.boolean().optional(), coverage: sessionLawListCoverage.nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List a state's session laws * * GET /api/v1/us/session-laws/list * * Also accepts auth: ApiKeyHeader */ export const getApiApiV1UsSessionLawsList = async (args: GetApiApiV1UsSessionLawsListArgs, options?: GetApiApiV1UsSessionLawsListOptions) => { const {baseUrl = "https://api.vaquill.ai", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.jurisdiction != null) query.append("jurisdiction", String(args.jurisdiction)) if (args.session != null) query.append("session", String(args.session)) for (const item of args.series ?? []) query.append("series", String(item)) for (const item of args.instrumentType ?? []) query.append("instrumentType", String(item)) if (args.approvedFrom != null) query.append("approvedFrom", String(args.approvedFrom)) if (args.approvedTo != null) query.append("approvedTo", String(args.approvedTo)) if (args.effectiveFrom != null) query.append("effectiveFrom", String(args.effectiveFrom)) if (args.effectiveTo != null) query.append("effectiveTo", String(args.effectiveTo)) if (args.hasText != null) query.append("hasText", String(args.hasText)) if (args.textStatus != null) query.append("textStatus", String(args.textStatus)) if (args.isLaw != null) query.append("isLaw", String(args.isLaw)) for (const item of args.enactmentOutcome ?? []) query.append("enactmentOutcome", String(item)) if (args.updatedSince != null) query.append("updatedSince", String(args.updatedSince)) if (args.q != null) query.append("q", String(args.q)) if (args.order != null) query.append("order", String(args.order)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.limit != null) query.append("limit", String(args.limit)) if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (ApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/us/session-laws/list${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(sessionLawListResponse, await res.json()) };