From 46b530378d1f3fdfa4f3d04a57c16b6eb8af3ae8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Mar 2026 12:18:04 +0100 Subject: [PATCH] frontend-app-api: revert predicate traversal cleanup Restore the more defensive predicate traversal implementation after the narrowing cleanup turned out not to be worth the type fallout. Signed-off-by: Patrik Oldsberg Made-with: Cursor --- .../frontend-app-api/src/wiring/predicates.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/frontend-app-api/src/wiring/predicates.ts b/packages/frontend-app-api/src/wiring/predicates.ts index 4ae9c8f135..819036fc17 100644 --- a/packages/frontend-app-api/src/wiring/predicates.ts +++ b/packages/frontend-app-api/src/wiring/predicates.ts @@ -160,17 +160,21 @@ function extractPredicateKeyNames( if (typeof predicate !== 'object' || predicate === null) { return []; } - const typedPredicate = predicate as FilterPredicate & Record; - if ('$all' in typedPredicate && Array.isArray(typedPredicate.$all)) { - return typedPredicate.$all.flatMap(p => extractPredicateKeyNames(p, key)); + const obj = predicate as Record; + if (Array.isArray(obj.$all)) { + return (obj.$all as FilterPredicate[]).flatMap(p => + extractPredicateKeyNames(p, key), + ); } - if ('$any' in typedPredicate && Array.isArray(typedPredicate.$any)) { - return typedPredicate.$any.flatMap(p => extractPredicateKeyNames(p, key)); + if (Array.isArray(obj.$any)) { + return (obj.$any as FilterPredicate[]).flatMap(p => + extractPredicateKeyNames(p, key), + ); } - if ('$not' in typedPredicate && typedPredicate.$not !== undefined) { - return extractPredicateKeyNames(typedPredicate.$not, key); + if (obj.$not !== undefined) { + return extractPredicateKeyNames(obj.$not as FilterPredicate, key); } - const value = typedPredicate[key]; + const value = obj[key]; if (typeof value === 'object' && value !== null && !Array.isArray(value)) { const contains = (value as Record).$contains; if (typeof contains === 'string') {