catalog-react: remove $nin predicate

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-02-23 14:37:45 +01:00
parent 0171b0b489
commit 99306adc3c
5 changed files with 9 additions and 7 deletions
@@ -54,7 +54,6 @@ describe('createEntityPredicateSchema', () => {
],
},
{ kind: 'component', 'spec.type': { $in: ['service'] } },
{ kind: 'component', 'spec.type': { $nin: ['service'] } },
{ 'spec.owner': { $exists: true } },
{ 'spec.owner': { $exists: false } },
{ 'spec.type': { $eq: 'service' } },
@@ -28,7 +28,6 @@ export function createEntityPredicateSchema(z: typeof zImpl) {
z.object({ $eq: z.union([primitiveSchema, z.array(primitiveSchema)]) }),
z.object({ $ne: z.union([primitiveSchema, z.array(primitiveSchema)]) }),
z.object({ $in: z.array(primitiveSchema) }),
z.object({ $nin: z.array(primitiveSchema) }),
z.object({ $all: z.array(primitiveSchema) }),
z.object({ $elemMatch: z.lazy(() => z.record(filterValueSchema)) }),
]) as ZodType<EntityPredicateValue>;
@@ -192,7 +192,15 @@ describe('evaluateEntityPredicate', () => {
},
],
['s', { kind: 'component', 'spec.type': { $in: ['service'] } }],
['w', { kind: 'component', 'spec.type': { $nin: ['service'] } }],
[
'w',
{
$and: [
{ kind: 'component' },
{ $not: { 'spec.type': { $in: ['service'] } } },
],
},
],
['s,w,a', { 'spec.owner': { $exists: true } }],
['g', { 'spec.owner': { $exists: false } }],
['s', { 'spec.type': { $eq: 'service' } }],
@@ -95,9 +95,6 @@ function evaluatePredicateValue(
if ('$in' in filter) {
return filter.$in.includes(value as EntityPredicatePrimitive);
}
if ('$nin' in filter) {
return !filter.$nin.includes(value as EntityPredicatePrimitive);
}
if ('$exists' in filter) {
if (filter.$exists === true) {
return value !== undefined;
@@ -35,7 +35,6 @@ export type EntityPredicateValue =
| { $eq: EntityPredicatePrimitive }
| { $ne: EntityPredicatePrimitive }
| { $in: EntityPredicatePrimitive[] }
| { $nin: EntityPredicatePrimitive[] }
| { $all: EntityPredicatePrimitive[] }
| { $elemMatch: EntityPredicateExpression };