feat(11-01): implement tender-query.builder (GREEN)

buildTenderWhere: conditional Prisma where-builder covering keyword
(D-01), openOnly deadline default + explicit deadline range (D-04),
and NULL-graceful value filter (D-05, Kern-Test: value filter never
eliminates estimatedValue=null rows). buildOrderBy: sort whitelist
(deadline/value/published) defaulting to publishedAt desc (UI-01,
T-11-01 — no dynamic orderBy keys from user input).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-21 15:48:56 +02:00
parent 426a1ea3b8
commit fed5ecbc43
2 changed files with 97 additions and 4 deletions
@@ -122,10 +122,12 @@ describe('buildTenderWhere', () => {
const where = buildTenderWhere(dto({ valueMin: 1000 }));
const and = (where.AND as Array<Record<string, unknown>>) ?? [];
const valueClause = and.find((c) => 'OR' in c) as
| { OR: Array<Record<string, unknown>> }
| undefined;
const rangeBranch = valueClause?.OR.find((b) => 'estimatedValue' in b && b.estimatedValue !== null);
const valueClause = and.find(
(c) => 'OR' in c && JSON.stringify(c).includes('estimatedValue'),
) as { OR: Array<Record<string, unknown>> } | undefined;
const rangeBranch = valueClause?.OR.find(
(b) => 'estimatedValue' in b && b.estimatedValue !== null,
);
expect(rangeBranch).toEqual({ estimatedValue: { gte: 1000 } });
});