/** * @fileoverview Generic factory for dialects that translate BrAPI v2.1 plural * filter keys (`studyDbIds`, `germplasmDbIds`, …) to the v2.0 singular forms * the upstream actually honors. Used by both the SGN/Breedbase family * (`cassavabase-dialect`) and the BrAPI Community Test Server * (`brapi-test-dialect`) — the two share an identical translation engine but * carry different per-endpoint mappings, drop lists, and search-route flags, * so the data lives in each dialect module while the engine lives here. * * @module services/brapi-dialect/singularizing-dialect */ import type { BrapiDialect } from './types.js'; /** * One entry in the plural→singular translation table. Carries the target * filter name plus a `verified` flag that's `true` when the mapping was * empirically narrowed against a live server, `false` when it's inferred from * the v2.0/v2.1 naming pattern but hasn't been independently checked. * * The flag drives two things: the warning the dialect emits on downcast * (softer wording for inferred mappings, since the mapping might also be * wrong); and the verified-mapping summary on the orientation envelope so * agents can see the dialect's confidence floor without inspecting source. */ export interface DialectFilterMapping { target: string; verified: boolean; } /** Compact shorthand: `'singular'` expands to `{ target: 'singular', verified: false }`. */ export type DialectFilterMappingInput = string | DialectFilterMapping; export interface SingularizingDialectConfig { /** * POST `/search/{noun}` routes the dialect knows are dead — advertised in * `/calls` but unresponsive in practice. Forwarded onto `BrapiDialect` * verbatim. Omit when search routes work normally. */ disabledSearchEndpoints?: ReadonlySet; /** * Per-endpoint set of filter keys to drop entirely — the server silently * ignores them in both plural and singular form. Drops surface a warning so * the agent stops trusting the response as if the filter were honored. */ droppedFilters?: Readonly>>; /** Stable dialect id surfaced in logs and the orientation envelope. */ id: string; /** Human-readable label used in warning text (e.g. `CassavaBase`). */ label: string; /** * Optional row-normalizer. Receives the endpoint segment and one upstream * row pre-schema. Forwarded onto `BrapiDialect.normalizeRow` verbatim — see * that interface for semantics. Omit on dialects with no shape quirks. */ normalizeRow?: (endpoint: string, row: Record) => Record; /** Compatibility notes surfaced in brapi_connect / brapi_server_info. */ notes?: readonly string[]; /** * Per-endpoint mapping from the v2.1 plural filter key to its singular form. * Keyed by bare resource segment (`studies`, no slash). Values may be a * bare string (treated as `{target, verified: false}`) or an explicit * `DialectFilterMapping` so authors can mark live-verified mappings * distinctly from inferred ones. Endpoints not listed pass through with no * translation. */ pluralToSingular: Readonly>>>; } /** * Build a `BrapiDialect` whose `adaptGetFilters` translates plural v2.1 filter * names to the configured singulars, drops blacklisted keys, and downcasts * multi-value arrays to the first element with a loud warning (the v2.0 GET * surface can't express multi-value filters; the agent should re-call per * value or use a curated tool that paginates). */ export declare function createSingularizingDialect(config: SingularizingDialectConfig): BrapiDialect; //# sourceMappingURL=singularizing-dialect.d.ts.map