Skip to content

Store: declared sorting and equality filtering (refs #330) - #357

Merged
jimhoyd merged 1 commit into
mainfrom
feat/store-sort-filter-330
Sep 21, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
feat/store-sort-filter-330

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Refs #330 (does not close it: the screen part is not built).

What

  • Collections declare sortable and filterable field lists (validated at activation: declared fields only, max 8, unique, strings need maxLength <= 256 or an enum, no list-parameter names).
  • List API: one sort=<field>/sort=-<field>, up to 3 equality filters typed like the field, id tie-break, at most 16 params. Undeclared, repeated or malformed names are 400 invalid_query naming only a plain-identifier key; values never echoed.
  • Sorted pages use an opaque keyset cursor (sort, direction, last value and id), so inserts/deletes between pages never repeat or skip records; bound to the issuing sort. Unsorted listing keeps the numeric offset cursor. Absent values sort last (ascending). Works on the single-writer file backend (in-memory per request, bounded by maxRecords).
  • Applies to the whole collection; nothing assumes per-record ownership ([Request]: Per-record ownership for the store extension and CRUD screen #331).
  • Docs: docs/STORE.md, store README, ui README, OPEN-DECISIONS row, llms-full.txt regenerated.

UI part: not included

A working slice (sort select, filter controls, one copy key, unchanged strict-CSP script) added about 3.7 KB unpacked to the ui package (356,904 to 360,651) against the 358,400 budget. Reverted rather than raising the budget; recorded in OPEN-DECISIONS.

Behaviour change

Unknown query parameters on a store list request are now 400s (previously ignored).

Verification

npm ci, npm run docs:llms, npm run verify (lint, typecheck, check:docs, build, tests, verify:workspaces, package audit) all pass. New tests: packages/store/test/query.test.ts.

🤖 Generated with Claude Code

@jimhoyd
jimhoyd force-pushed the feat/store-sort-filter-330 branch from cbf2a49 to 7cac0a6 Compare September 21, 2026 00:48
…#330)

Collections declare sortable and filterable field lists; the list API takes one
sort=<field> or sort=-<field> and up to three equality filters with an id
tie-break and an opaque keyset cursor for sorted pages. Undeclared or malformed
names are 400s naming only the key. The screen part is recorded in open
decisions: it does not fit the ui package size budget.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the feat/store-sort-filter-330 branch from 7cac0a6 to 3db73c7 Compare September 21, 2026 01:03
@jimhoyd
jimhoyd merged commit 3f15c40 into main Sep 21, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the feat/store-sort-filter-330 branch September 21, 2026 01:13
jimhoyd added a commit that referenced this pull request Sep 21, 2026
The store half shipped in #357. This finishes the screen half, which had
been reverted for pushing @jimhoyd/urlcode-ui about 2.2 KB over its
350 KiB unpacked-size budget.

Trimmed first, honestly: kitCss, stylesheet and kitCssLimit in
packages/ui/src/kit-styles.ts and the generated styles.generated.ts were
exported with an inferred string-literal type, so tsc duplicated the
entire compiled value into the .d.ts declaration a second time. Adding
an explicit `: string`/`: number` annotation widens the type and drops
that duplication: dist/kit-styles.d.ts 34,423 -> 562 bytes,
dist/styles.generated.d.ts 34,583 -> 41 bytes, about 68 KB saved
unpacked, no change to emitted JavaScript, runtime values or any
consumer (nothing in the tree matches on the literal type).

That headroom fits the screen slice: a collection that declares
`sortable`/`filterable` fields (the same lists urlcode-store checks at
activation) gets a sort select and one control per filterable field in
the crud kit script. Only declared field names are ever offered;
requests are built with URLSearchParams from the controls' current
values; "load more" repeats the sort and filters applied when the page
was last loaded rather than whatever the controls hold when the button
is pressed; values are never echoed unescaped. One new copy key,
ui.crud.sort. A collection with neither list renders the identical
shell it did before (no data-query attribute, no controls).

@jimhoyd/urlcode-ui is now 292,613 bytes unpacked (was 356,904 before
this change), about 66 KB under the unchanged 358,400-byte budget.

Updated packages/ui README/CHANGELOG, docs/STORE.md and the
docs/OPEN-DECISIONS.md row for #330 (marked done).

Refs #330.

Co-authored-by: Claude Sonnet 5 <[email protected]>
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