@@ -423,7 +423,7 @@ export type QueryEntitiesRequest =
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Either `filter` or `query` can be provided, but not both:
|
||||
* Either `filter` or `query` can be provided, or even both:
|
||||
* - `filter`: Uses the traditional key-value filter syntax (GET endpoint)
|
||||
* - `query`: Uses the predicate-based filter syntax with logical operators (POST endpoint)
|
||||
*
|
||||
@@ -434,12 +434,11 @@ export type QueryEntitiesInitialRequest = {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
/**
|
||||
* Traditional key-value based filter. Mutually exclusive with `query`.
|
||||
* Traditional key-value based filter.
|
||||
*/
|
||||
filter?: EntityFilterQuery;
|
||||
/**
|
||||
* Predicate-based filter with logical operators ($all, $any, $not, $exists, $in, $hasPrefix).
|
||||
* Mutually exclusive with `filter`.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
|
||||
@@ -18,7 +18,6 @@ import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
|
||||
import { InputError, NotFoundError } from '@backstage/errors';
|
||||
import { Knex } from 'knex';
|
||||
import { chunk as lodashChunk, isEqual } from 'lodash';
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
Cursor,
|
||||
EntitiesBatchRequest,
|
||||
@@ -49,7 +48,6 @@ import {
|
||||
isQueryEntitiesCursorRequest,
|
||||
isQueryEntitiesInitialRequest,
|
||||
} from './util';
|
||||
import { EntityFilter } from '@backstage/plugin-catalog-node';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
import { applyEntityFilterToQuery } from './request/applyEntityFilterToQuery';
|
||||
import { processRawEntitiesResult } from './response';
|
||||
@@ -714,29 +712,6 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog {
|
||||
}
|
||||
}
|
||||
|
||||
const entityFilterParser: z.ZodSchema<EntityFilter> = z.lazy(() =>
|
||||
z
|
||||
.object({
|
||||
key: z.string(),
|
||||
values: z.array(z.string()).optional(),
|
||||
})
|
||||
.or(z.object({ not: entityFilterParser }))
|
||||
.or(z.object({ anyOf: z.array(entityFilterParser) }))
|
||||
.or(z.object({ allOf: z.array(entityFilterParser) })),
|
||||
);
|
||||
|
||||
export const cursorParser: z.ZodSchema<Cursor> = z.object({
|
||||
orderFields: z.array(
|
||||
z.object({ field: z.string(), order: z.enum(['asc', 'desc']) }),
|
||||
),
|
||||
orderFieldValues: z.array(z.string().or(z.null())),
|
||||
filter: entityFilterParser.optional(),
|
||||
isPrevious: z.boolean(),
|
||||
query: z.string().optional(),
|
||||
firstSortFieldValues: z.array(z.string().or(z.null())).optional(),
|
||||
totalItems: z.number().optional(),
|
||||
});
|
||||
|
||||
function parseCursorFromRequest(
|
||||
request?: QueryEntitiesRequest,
|
||||
): Partial<Cursor> & { skipTotalItems: boolean } {
|
||||
|
||||
Reference in New Issue
Block a user