/** * @fileoverview Shared input contract for CDE tools that take a national/state/agency scope and a * year/month range or a whole-year range: the scope and identifier fields, the year/month range * fields (with each endpoint's year floor), identifier normalization, and the pre-fetch checks for * scope parameters, the current-year ceiling, and range order. Annual endpoints combine * {@link scopeFields} with their own year fields and resolve through {@link resolveScopedYears}. * Each tool still declares the matching `errors[]` entries inline; the `ctx` parameter types * below fail to compile when one is missing. * @module mcp-server/tools/cde-scoped-range */ import { type TypedFail, z } from '@cyanheads/mcp-ts-core'; import type { CdeScopedWindow, CdeYearWindow } from '../../services/fbi-api/types.js'; /** * Reasons {@link resolveScopedRange} and {@link resolveScopedYears} can fail with; each tool * declares all four. */ export type ScopedRangeReason = 'scope_param_missing' | 'scope_param_incompatible' | 'year_out_of_range' | 'invalid_date_range'; /** The scope field and the identifier fields state and agency scope each require one of. */ export declare function scopeFields(): { scope: z.ZodEnum<{ agency: "agency"; national: "national"; state: "state"; }>; state_abbr: z.ZodPreprocess, unknown>; ori: z.ZodPreprocess, unknown>; }; /** * Scope, identifier, and year/month range fields for a CDE scoped endpoint. `floorYear` is the * endpoint's first year with data and becomes the JSON Schema `minimum` on both year fields; the * ceiling (the current UTC year) is checked per call by {@link resolveScopedRange}. */ export declare function scopedRangeFields(floorYear: number): { scope: z.ZodEnum<{ agency: "agency"; national: "national"; state: "state"; }>; state_abbr: z.ZodPreprocess, unknown>; ori: z.ZodPreprocess, unknown>; from_year: z.ZodNumber; from_month: z.ZodDefault; to_year: z.ZodNumber; to_month: z.ZodDefault; }; /** Parsed scope and identifier fields, as {@link scopeFields} produces them. */ type ScopeInput = z.output>>; /** Parsed scope fields with the first and last year of a range. */ type ScopeYearsInput = ScopeInput & { from_year: number; to_year: number; }; /** Parsed scope and range fields, as {@link scopedRangeFields} produces them. */ export type ScopedRangeInput = z.output>>; /** A validated scope with its normalized identifier and the MM-YYYY bounds CDE expects. */ export type ResolvedScopedRange = CdeScopedWindow; /** * Fail with `year_out_of_range` when any year is after the current UTC year. The clock is read on * every call, so a long-running server never serves a stale ceiling. The hint names the window. */ export declare function assertYearsNotFuture(years: readonly { field: string; year: number; }[], floorYear: number, ctx: { fail: TypedFail<'year_out_of_range'>; }): void; /** * Validate a scoped range before any fetch and normalize its identifier to uppercase. Checks run * in order: the scope's identifier is present, no identifier is supplied that the scope ignores, * no year is after the current UTC year, and the start is no later than the end. */ export declare function resolveScopedRange(input: ScopedRangeInput, floorYear: number, ctx: { fail: TypedFail; }): ResolvedScopedRange; /** * Validate a scoped whole-year range before any fetch and normalize its identifier to uppercase, * for endpoints that serve annual series. Checks run in the order {@link resolveScopedRange} * uses, with the range order compared on years alone. */ export declare function resolveScopedYears(input: ScopeYearsInput, floorYear: number, ctx: { fail: TypedFail; }): CdeYearWindow; export {}; //# sourceMappingURL=cde-scoped-range.d.ts.map