import { Operators, Query } from 'contensis-core-api'; import { VersionStatus } from 'contensis-core-api'; import { DataFormats } from './Enums'; export type FieldOperators = Exclude; export type SearchQueryFilter = { key: string | string[]; value: string | boolean; operator: FieldOperators; }; export type SearchQueryOptions = { assetTypes?: string[]; contentTypeIds?: string[]; dataFormats?: DataFormats[]; entryTitles?: string[]; excludeIds?: string[]; fields?: string[]; filters?: SearchQueryFilter[]; includeArchived?: boolean; includeDeleted?: boolean; includeIds?: string[]; includePaths?: string[]; languages?: string[]; pageSize?: number; pageIndex?: number; orderBy?: string[]; searchTerm?: string; useDelivery?: boolean; versionStatus?: VersionStatus; webpageTemplates?: string[]; weightedSearchFields?: WeightedSearchField[]; where?: CustomWhereClause; }; export type WeightedSearchField = { /** The id of the field to query against */ fieldId: string; /** The weighting applied to the field */ weight: number; }; export type WhereClause = { /** The field we wish to query */ field: string; /** The value we want to evaluate with the chosen operator */ [key: string]: any; }; /** * N.B. This shares syntax with adding where operators to a search query when using the Delivery API via HTTP, and should be used sparingly for exceptional cases where the standard query falls short */ export type CustomWhereClause = (WhereClause | { not: WhereClause; } | { and: WhereClause[]; } | { or: WhereClause[]; })[]; export type SearchQuery = (options: SearchQueryOptions) => Query;