catalog-react: remove $nor predicate

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-02-23 14:35:39 +01:00
parent c216b1a6f5
commit 0171b0b489
5 changed files with 6 additions and 14 deletions
@@ -31,9 +31,6 @@ describe('createEntityPredicateSchema', () => {
{
$or: [{ kind: 'component', 'spec.type': 'service' }, { kind: 'group' }],
},
{
$nor: [{ kind: 'component', 'spec.type': 'service' }, { kind: 'group' }],
},
{
relations: {
$elemMatch: { type: 'ownedBy', targetRef: 'group:default/g' },
@@ -68,7 +65,6 @@ describe('createEntityPredicateSchema', () => {
},
{ $and: [{ x: { $exists: true } }] },
{ $or: [{ x: { $exists: true } }] },
{ $nor: [{ x: { $exists: true } }] },
{ $not: { x: { $exists: true } } },
{ $not: { $and: [{ x: { $exists: true } }] } },
])('should accept valid predicate %j', predicate => {
@@ -89,7 +85,6 @@ describe('createEntityPredicateSchema', () => {
1,
{ $and: [{ x: { $unknown: true } }] },
{ $or: [{ x: { $unknown: true } }] },
{ $nor: [{ x: { $unknown: true } }] },
{ $not: { x: { $unknown: true } } },
{ $not: { $and: [{ x: { $unknown: true } }] } },
{ $unknown: 'foo' },
@@ -37,7 +37,6 @@ export function createEntityPredicateSchema(z: typeof zImpl) {
z.union([
z.object({ $and: z.array(filterSchema) }),
z.object({ $or: z.array(filterSchema) }),
z.object({ $nor: z.array(filterSchema) }),
z.object({ $not: filterSchema }),
z.record(z.string().regex(/^(?!\$).*$/), filterValueSchema),
]),
@@ -148,10 +148,12 @@ describe('evaluateEntityPredicate', () => {
[
'w,a',
{
$nor: [
{ kind: 'component', 'spec.type': 'service' },
{ kind: 'group' },
],
$not: {
$or: [
{ kind: 'component', 'spec.type': 'service' },
{ kind: 'group' },
],
},
},
],
[
@@ -46,9 +46,6 @@ export function evaluateEntityPredicate(
if ('$or' in filter) {
return filter.$or.some(f => evaluateEntityPredicate(f, value));
}
if ('$nor' in filter) {
return !filter.$nor.some(f => evaluateEntityPredicate(f, value));
}
if ('$not' in filter) {
return !evaluateEntityPredicate(filter.$not, value);
}
@@ -19,7 +19,6 @@ export type EntityPredicate =
| EntityPredicateExpression
| { $and: EntityPredicate[] }
| { $or: EntityPredicate[] }
| { $nor: EntityPredicate[] }
| { $not: EntityPredicate };
/** @alpha */