Repository navigation
Fix inconsistent repeated-key acceptance across query families (#102) - #143
Merged
Merged
Conversation
Repeatable (the codec accepting UrlParams.toRecord's array shape for a repeated key) was applied at Query.schema's include only, while sort, fields[TYPE] and the filter grammar's list-valued positions stayed comma-only - two spellings of the same grammar, one accepted and one rejected, with no principle distinguishing them. - Query.schema: sort and fields[TYPE] now widen to Repeatable at the flat wire struct, matching include; FlatFields moves with the runtime. - The standalone constructors (Query.Include, Query.Fieldset, Query.Sort) compose Repeatable under their item codec via a new repeatable helper in internal/codecs.ts, so they gain the same acceptance directly. - The filter grammar (internal/filter.ts) accepts a repeated key at its list-valued positions (shorthand filter[f], filter[f][op], a group form condition's [value] member), rejecting it everywhere else (a group's conjunction, any memberOf, a condition's path/operator) exactly as before. - CommaSeparated/Sort now drop empty comma segments (a,,b / a,b,) instead of handing them to the item schema as a bogus item - documented as a deliberate decision, not an incidental side effect. Encoding is unchanged: every family still emits the single canonical comma form, verified by decode-then-encode round-trip tests through Query.canonical. Updates the two tests that previously locked in the old asymmetric behavior, and docs/filter-grammar.md and README to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSKpjhULi2X6jR71XDmrRn
…ur-w8h59u # Conflicts: # src/internal/codecs.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #102:
Repeatable(the codec that acceptsUrlParams.toRecord's array shape for a repeatedkey alongside the comma form) was applied at
Query.schema'sincludeonly.sort,fields[TYPE], and the filter grammar's list-valued positions stayed comma-only — two spellings ofthe same grammar, one accepted and one rejected, with no principle distinguishing them.
Query.schema:sortandfields[TYPE]now widen toRepeatableat the flat wire struct,matching
include;FlatFieldsmoves with the runtime.Query.Include,Query.Fieldset,Query.Sort): composeRepeatableunder their item codec via a newrepeatablehelper ininternal/codecs.ts— theyhave no flat/nested split to inherit the fix from
Query.schema, so they needed it directly.internal/filter.ts) now accepts a repeated key at its list-valuedpositions (shorthand
filter[f],filter[f][op], a group form condition's[value]member),rejecting it everywhere else (a group's conjunction, any
memberOf, a condition's path/operator)exactly as before.
FilterWireValuealready typedstring | string[]; the runtime unconditionallyrejected arrays regardless.
CommaSeparated/Sortnow drop empty comma segments (a,,b, a trailingcomma) instead of handing them to the item schema as a bogus item. This is a deliberate behavior
change, not an incidental side effect, so the changeset is
minor.Encoding is unchanged — every family still emits the single canonical comma form, verified with
decode-then-encode round-trip tests through
Query.canonical.Test plan
repeated filter key, and "only
includeis repeatable")sort,fields[TYPE], the filtergrammar's list-valued positions, and the standalone
Query.Include/Fieldset/Sortconstructors
pnpm run check(typecheck + lint + format:check + test, including theexamples/*packages)pnpm run docgen(compiles and runs every JSDoc@example)docs/filter-grammar.mdandREADME.mdto match🤖 Generated with Claude Code
https://claude.ai/code/session_01VSKpjhULi2X6jR71XDmrRn
Generated by Claude Code