import { Constructor } from '@loopback/core'; import { AnyObject, Model } from '@loopback/repository'; import { SearchResult } from './models'; import { SearchQuery } from './models/search-query.model'; export type SearchFunctionType = (query: SearchQuery) => Promise; export type SearchableModelsService = { add: (model: typeof Model) => Promise; delete: (model: typeof Model) => Promise; get: () => Promise<(typeof Model)[]>; }; export interface Searchable { name: string; description: string; } export type SearchableModelsList = (SearchableModel | typeof Model)[]; export interface SearchServiceConfig { useCustomSequence?: boolean; useSequelize?: boolean; doNotMountCoreComponent?: boolean; models: SearchableModelsList; type?: Constructor & typeof Model; ignoreColumns?: ModelProperties[]; controller?: SearchControllerConfig; } export type ModelProperties = keyof Partial>; export type SearchControllerConfig = { name?: string; basePath: string; authorizations?: string[]; authenticate?: boolean; recentCount?: number; recents?: boolean; }; export declare class SearchableModel { model: S; columns: ColumnMap; identifier?: string; } export declare function isSearchableModel(arg: SearchableModel | typeof Model): arg is SearchableModel; export type ColumnMap = { [key in ModelProperties]+?: string; }; export type SearchWhereFilterMap = { [key: string]: SearchWhereFilter; }; export declare type SearchWhereFilter = Condition | AndClause | OrClause; export interface AndClause { and: SearchWhereFilter[]; } export interface OrClause { or: SearchWhereFilter[]; } export declare type Condition = { [P in keyof MT]?: PredicateComparison | (MT[P] & ShortHandEqualType); }; export declare type PredicateComparison = { eq?: PT; neq?: PT; gt?: PT; gte?: PT; lt?: PT; lte?: PT; inq?: PT[]; nin?: PT[]; between?: [PT, PT]; }; export declare type PredicateValueType = PT | PT[] | [PT, PT]; export declare type ShortHandEqualType = string | number | boolean | Date; export type Query = { sql: string; params: ShortHandEqualType[]; }; export type Queries = (Query | Queries)[];