UNPKG

@aciiverse/aciifx-cli

Version:

The powerful CLI for aciiFX backend in combination with fetcii

96 lines (95 loc) 3.04 kB
export declare namespace filter { interface Req { query: { [key: string]: any; }; } interface GetQueryParamsOptions { all?: boolean; filters?: boolean; orderBy?: boolean; topSkip?: boolean; select?: boolean; } interface GetQueryParams { filters?: FiltersType; orderBy?: OrderByType; top?: number; skip?: number; select?: string[]; } export enum CompareOperator { Equal = "eq", NotEqual = "neq", GreaterThan = "gt", GreaterEqual = "ge", LessThan = "lt", LessEqual = "le", Inside = "in", NotInside = "ni" } export interface Filter { operator: CompareOperator; value: any; } export interface FiltersType { [key: string]: FilterContent; } export interface FilterContent { filters: Filter[]; and: boolean; } export interface SQLFilterExport { sql: string; values: any[]; } interface OrderBy { property: string; ascending: boolean; } export type OrderByType = OrderBy | OrderBy[]; /** * @async * @method gets the query params * @param {Req} req the route request * @param {GetQueryParamsOptions} options for defining which params should readed * @returns {Promise<GetQueryParams>} all `query params` as an object * @author Flowtastisch * @memberof Aciiverse * @date 21.11.2024 */ export function getQueryParams(req: Req, options: GetQueryParamsOptions): Promise<GetQueryParams>; /** * @method gets only the first filter value, that exists for the searched property * @param {FiltersType} filters in which to search * @param {string} property search property * @author Flowtastisch * @memberof Aciiverse * @date 21.11.2024 */ export function getFirstFilterValue(filters: FiltersType, property: string): any | undefined; /** * @method gets a filter by it's property * @param {FiltersType} filters in which to search * @param {string} property * @returns {FilterContent} the raw filter content * @author Flowtastisch * @memberof Aciiverse * @date 21.11.2024 */ export function getFilter(filters: FiltersType, property: string): FilterContent; /** * @method gets a filter by it's property * @param {FiltersType} filters in which to search * @param {string} property * @param {string} sqlProperty property as sql property * @returns {SQLFilterExport | undefined} the filter in sql syntax and it's values * @example sql: ` t.title = ? AND t.title != ? AND t.title LIKE %?% ` * @example values: `[ Acii, Lacii, Joyboy ]` * @author Flowtastisch * @memberof Aciiverse * @date 20.11.2024 */ export function getFilterSQL(filters: FiltersType, property: string, sqlProperty: string): SQLFilterExport | undefined; export {}; }