catalog-react: remove $eq and $ne value predicate

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-02-24 00:40:10 +01:00
parent 6047a3e1b3
commit 6c047a5a37
5 changed files with 4 additions and 14 deletions
@@ -65,8 +65,8 @@ describe('createEntityPredicateSchema', () => {
{ kind: 'component', 'spec.type': { $in: ['service'] } },
{ 'spec.owner': { $exists: true } },
{ 'spec.owner': { $exists: false } },
{ 'spec.type': { $eq: 'service' } },
{ 'spec.type': { $ne: 'service' } },
{ 'spec.type': 'service' },
{ $not: { 'spec.type': 'service' } },
{
kind: 'component',
'metadata.annotations.github.com/repo': { $exists: true },
@@ -42,8 +42,6 @@ export function createEntityPredicateSchema(z: typeof zImpl) {
valuePredicateSchema = z.union([
comparableValueSchema,
z.object({ $exists: z.boolean() }),
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({ $contains: predicateSchema }),
]) as ZodType<EntityPredicateValue>;
@@ -211,8 +211,8 @@ describe('evaluateEntityPredicate', () => {
],
['s,w,a', { 'spec.owner': { $exists: true } }],
['g', { 'spec.owner': { $exists: false } }],
['s', { 'spec.type': { $eq: 'service' } }],
['w,g,a', { 'spec.type': { $ne: 'service' } }],
['s', { 'spec.type': 'service' }],
['w,g,a', { $not: { 'spec.type': 'service' } }],
['', { 'spec.type': null }],
[
's,w',
@@ -99,12 +99,6 @@ function evaluatePredicateValue(
}
return value === undefined;
}
if ('$eq' in filter) {
return valuesAreEqual(value, filter.$eq);
}
if ('$ne' in filter) {
return !valuesAreEqual(value, filter.$ne);
}
return false;
}
@@ -33,8 +33,6 @@ export type EntityPredicateExpression = {
export type EntityPredicateValue =
| EntityPredicatePrimitive
| { $exists: boolean }
| { $eq: EntityPredicatePrimitive }
| { $ne: EntityPredicatePrimitive }
| { $in: EntityPredicatePrimitive[] }
| { $contains: EntityPredicateExpression };