Repository navigation
refactor(agent-bff): extract the filter-schema derivation out of unfolded-paths.ts - #2036
Conversation
1 new issue
|
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🛟 Help
|
PMerlet
left a comment
There was a problem hiding this comment.
Spec (PRD-1546): conforms. The filter schema moves to its own module with no behaviour change, and no test assertion was edited.
|
|
||
| filterable.forEach(field => { | ||
| // An empty set would emit `enum: []`, which forbids every value and makes the leaf unsatisfiable — | ||
| // the trap `fieldsEnum` guards above. `collectFilterableFields` cannot produce one, but `Unfolding` |
There was a problem hiding this comment.
Claude Opus 5.5 (claude-opus-5-5): Preferential: a reader of this guard looks for fieldsEnum above and does not find it in this file.
Code
The comment at unfolded-filter-schema.ts:50 points above, but fieldsEnum stayed behind at unfolded-paths.ts:84.
A way out: name unfolded-paths.ts in the comment instead of saying above.
There was a problem hiding this comment.
Fixed in 0abca46: the comment is gone rather than reworded, since the guard reads on its own. For the record, the reason it exists: an empty operator set would emit enum: [], which makes the filter leaf unsatisfiable (the same trap fieldsEnum guards in unfolded-paths.ts).
PMerlet
left a comment
There was a problem hiding this comment.
Approved after /validator run 2036-20261023150129-PMerlet: nothing blocking posted, 1 preferential or code style, 0 suppressed below all.

Moves the per-collection filter schema derivation out of
unfolded-paths.tsintounfolded-filter-schema.ts. Pure move: the served document is byte-identical.fixes PRD-1546
What
packages/agent-bff/src/openapi/unfolded-filter-schema.ts(new, 176 lines)AGGREGATORS,isFieldSetKnown,isFilterSetKnown,groupByOperators,leafShape,filterLeaves,filterSchema(default export), copied verbatim with their commentspackages/agent-bff/src/openapi/unfolded-paths.ts(786 to 618 lines)Why
isFieldSetKnownmoves too and is exported back:isFilterSetKnownneeds it andfieldRefsstill reads it, so leaving it behind would make the two files import each other.filterSchemaandfilterLeavesnow type their inputs as{ pool }and{ key, collection }instead ofDepsandPick<CollectionPlan, ...>, the same shapes, so the new module needs nothing fromunfolded-paths.ts.AGGREGATORShad no other user (data/agent-query.tsdeclares its own).How to test
generateOpenApiDocument+serializeOpenApibefore and after, 8 cases: generic, generic with AI route, generic withpublicUrl+basePath, unfolded (test fixture), unfolded with AI route, unfolded without actions, unfolded withno_fields, unfolded with an emptyfilterablemarkedundocumentableFilterdiff -rempty, 8 files identical1c6ab81vs baselinee98f1bd(main), real stack:smoke(forest-bffCLI against a v1-express agent, API key, includes the served OpenAPI check) andgateway-api-rename(generic and unfolded document served over cli, bff and gateway mounts)yarn workspace @forestadmin/agent-bff testgit diff --stat origin/main -- packages/agent-bff/testnpx tsc --noEmit -p packages/agent-bff,npx eslinton both filesDefinition of Done
General
Security