/** * @fileoverview Opt-in monthly rows for the CDE totals tools, read from the `type=counts` view of * the same path and selector: the `include_monthly` input field, the paired totals and counts * requests, the `monthly` output schema, the row builder (MM-YYYY keys sorted chronologically, * CDE's -1 rate read as null), and the markdown month table. * @module mcp-server/tools/cde-monthly */ import { type Context, z } from '@cyanheads/mcp-ts-core'; import { type IdentifierCheck } from './cde-totals.js'; import type { FbiMonthlyCounts } from '../../services/fbi-api/types.js'; /** The `include_monthly` input field of every totals tool. */ export declare const includeMonthlyField: z.ZodDefault; /** * The totals request, and with `includeMonthly` the counts request for the same path, run side by * side. Both requests share one signal: caller cancellation reaches each, and the first request to * fail aborts the other, so a sibling waiting out retry backoff stops spending the API key's quota. * The call settles once both have, and throws the first failure's own error, never the sibling's * abort. */ export declare function totalsWithCounts(ctx: Context, includeMonthly: boolean, totals: (ctx: Context) => Promise, counts: (ctx: Context) => Promise): Promise<[T, FbiMonthlyCounts | undefined]>; /** One monthly column: the CDE series it reads, its table header, and what it holds. */ interface SeriesColumn { description: string; header: string; /** Series name in CDE's `{Entity} {series}` keys, e.g. `Arrests`. */ series: string; } type Columns = Readonly>; /** One month for the scoped entity: the tool's counts and rates, then populations and coverage. */ type MonthlyRow = { year: number; month: number; } & Record & { population: number | null; participated_population: number | null; population_coverage_percent: number | null; }; /** * What the monthly rows say about the scoped identifier: `unchecked` when monthly was not * requested, `unreported` when every row lacks a participated_population. */ export declare function identifierCheck(rows: readonly { participated_population: number | null; }[] | null | undefined): IdentifierCheck; /** * The monthly schema, row builder, and table for one tool's series: `counts` fields read the * scoped entity's `actuals`, `rates` fields its `rates`, both keyed by CDE series name. */ export declare function monthlySeries(spec: { counts: Columns; rates: Columns; }): { /** The `monthly` output field. */ field: z.ZodOptional> & Record> & { population: z.ZodNullable; participated_population: z.ZodNullable; population_coverage_percent: z.ZodNullable; } extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>>>; /** * Every month CDE sent for the scoped entity, sorted chronologically (CDE sends MM-YYYY keys * in string order). Null when CDE names no series for the state or ORI. * @throws SerializationError on a month key that is not MM-YYYY. */ rows(data: FbiMonthlyCounts): MonthlyRow[] | null; /** The month table: one row per month, every column, — for a value CDE did not send. */ table(monthly: readonly MonthlyRow[]): string[]; }; export {}; //# sourceMappingURL=cde-monthly.d.ts.map