Skip to content

refactor(search): type the search spec, part and binding parameters - #45

Draft
jm-rivera wants to merge 1 commit into
feat/client-generated-typesfrom
feat/typed-search-spec
Draft

jm-rivera wants to merge 1 commit into
feat/client-generated-typesfrom
feat/typed-search-spec

Conversation

@jm-rivera

Copy link
Copy Markdown
Contributor

Stacks on #43.

The DataSearch components and the src/lib/search helpers take the page's spec, part and binding types in place of any, so a reader that skips an absent member fails to compile. 112 such parameters are typed. Three remain, each at a boundary: flattenPart in searchClient.ts reads an unvalidated response body, and previewColumns.test.ts edits a trimmed fixture in place.

SpecReading in types.ts is Partial<Spec> | UnreadableSpec, the shape a helper that accepts any part's spec reads, and UnreadableSpec.stat_vars is unknown, the raw value that failed validation. A spec's StatVars reach a reader only through readStatVars in view.ts, which returns nothing for an unreadable spec. Nested members keep the wire's optionality, which exposed readers that assumed a bare coverage has dimensions, that requested_window is never 'latest', and that entity_type and download are never null. Test fixtures go through partialSpec and partialSlot in test/fixtures/partial.ts, which take a deep partial of the wire type, so each member a fixture names keeps its wire name and type. Two fixtures named members ObservationSeries lacks (series_key and index) and now name stat_var.

Three behaviours change, and a reviewer should confirm each. A spec flagged statVarsUnreadable supplies no StatVar count, years or members read from the value that failed validation, so the measure token's About drops its count and span and the Why panel counts no variables (servedMembership, servedSeriesCount, yearsText and buildWhySummary in view.ts, and servedSpan, latestDate and singleStatVarSpec in tokenAbout.ts). priceBasis in unitLabel.ts reads a prices value other than current or constant as unknown and falls back to the unit ref and the qualifier, where it printed the unknown value as constant prices. withResolvedSlotEdit in promote.ts returns the identity unchanged for a spec with no slots, where it threw, a path no rendered slot menu reaches.

Testing: typecheck, lint, lint:css, the 1,613 tests outside db/ and pnpm build pass. A new why.test.ts case gives an unreadable spec with { served_count: 3, member_count: "3" } to the measure About and buildWhySummary, and fails when readStatVars is bypassed.

The DataSearch components and the src/lib/search helpers take the
page's Spec, Part and Slot types where they took any, so a reader that
skips an absent member fails to compile. SpecReading is
Partial<Spec> | UnreadableSpec, and an unreadable spec's stat_vars is
unknown, so StatVars reach a reader only through readStatVars.

A spec flagged statVarsUnreadable supplies no StatVar count, years or
members from the value that failed validation. priceBasis reads a
prices value other than current or constant as unknown, and
withResolvedSlotEdit returns the identity unchanged for a spec with no
slots. Test fixtures go through partialSpec and partialSlot, which take
a deep partial of the wire type; two fixtures that named non-members of
ObservationSeries now name stat_var.
@jm-rivera
jm-rivera added this pull request to stack #44 October 21, 2026 17:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant