UNPKG

jsm-utilities

Version:
92 lines (91 loc) 3.78 kB
export interface QueryLike { where: (filter: any) => QueryLike; } export interface FilterResult<Q, T> { q: Q; totalQ: T; } export interface StringFilterOptions { omit?: boolean; operator?: "and" | "or"; mode?: "exact" | "contains" | "regex" | "startsWith" | "endsWith"; caseSensitive?: boolean; } export interface NumberFilterOptions { omit?: boolean; allowZero?: boolean; precision?: number; operator?: "and" | "or"; } export interface DateFilterOptions { omit?: boolean; timezone?: string; includeTime?: boolean; format?: string; } export interface GeoFilter { type: 'near' | 'within' | 'intersects'; longitude?: number; latitude?: number; maxDistance?: number; minDistance?: number; geometry?: any; spherical?: boolean; } export interface NumberRange { min?: number; max?: number; exact?: number; } export interface FilterConfig { [fieldName: string]: { type: 'string' | 'number' | 'date' | 'boolean' | 'geo' | 'array' | 'custom'; options?: any; transform?: (value: any) => any; validator?: (value: any) => boolean; }; } /** * Enhanced string filter with support for multiple fields and various matching modes */ export declare const createStringFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, fields: F | F[], options?: StringFilterOptions) => FilterResult<Q, T | null>; /** * Enhanced boolean filter */ export declare const createBooleanFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, omit?: boolean) => FilterResult<Q, T | null>; /** * Enhanced date range filter */ export declare const createDateRangeFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, options?: DateFilterOptions) => FilterResult<Q, T | null>; /** * Enhanced number filter with range support */ export declare const createNumberFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F | F[], options?: NumberFilterOptions) => FilterResult<Q, T | null>; /** * Array filter for matching array fields */ export declare const createArrayFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, options?: { omit?: boolean; matchAll?: boolean; size?: number; }) => FilterResult<Q, T | null>; /** * Geospatial filter */ export declare const createGeoFilter: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, geoFilter: GeoFilter, field: F) => FilterResult<Q, T | null>; /** * Text search filter */ export declare const createTextSearchFilter: <Q = any, T = any>(q: Q, totalQ: T | null, searchText: string, options?: { language?: string; caseSensitive?: boolean; diacriticSensitive?: boolean; }) => FilterResult<Q, T | null>; /** * Configuration-driven filter function */ export declare const createConfigurableFilter: <Q = any, T = any>(q: Q, totalQ: T | null, filters: Record<string, any>, config: FilterConfig) => FilterResult<Q, T | null>; export declare const createStringFilter_deprecated: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, fields: F | F[], omit?: boolean, operator?: "and" | "or") => FilterResult<Q, T | null>; export declare const createBooleanFilter_deprecated: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, omit?: boolean) => FilterResult<Q, T | null>; export declare const createDateRangeFilter_deprecated: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, omit?: boolean) => FilterResult<Q, T | null>; export declare const createNumberFilter_deprecated: <F = string, Q = any, T = any>(q: Q, totalQ: T | null, value: any, field: F, omit?: boolean) => FilterResult<Q, T | null>;