import * as i0 from '@angular/core';
import * as i1 from '@angular/common';
import { IdType } from 'imng-nrsrx-client-utils';
import { Observable } from 'rxjs';

declare class ImngODataClientModule {
    static ɵfac: i0.ɵɵFactoryDeclaration<ImngODataClientModule, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<ImngODataClientModule, never, [typeof i1.CommonModule], never>;
    static ɵinj: i0.ɵɵInjectorDeclaration<ImngODataClientModule>;
}

interface IFilterOperator {
    name: string;
    toODataString: ((field: string, value?: IdType, isRelativeValue?: boolean) => string) | ((field: string, value?: IdType[], isRelativeValue?: boolean) => string);
}

/**
 * A basic filter expression.
 */
interface IFilter {
    /**
     * The data item field to which the filter operator is applied.
     */
    field: string;
    /**
     * The filter operator (comparison).
     *
     * The supported operators are:
     * * `FilterOperators.equalTo` (equal to)
     * * `FilterOperators.notEqualTo` (not equal to)
     * * `FilterOperators.isNull` (is equal to null)
     * * `FilterOperators.notNull` (is not equal to null)
     * * `FilterOperators.lessThan` (less than)
     * * `FilterOperators.lessThanOrEqualTo` (less than or equal to)
     * * `FilterOperators.greaterThan` (greater than)
     * * `FilterOperators.greaterThanOrEqualTo` (greater than or equal to)
     * * `FilterOperators.in` (specified value should be an array)
     * * `FilterOperators.notIn` (specified value should be an array)
     *
     * The following operators are supported for string fields only:
     * * `FilterOperators.startsWith`
     * * `FilterOperators.endsWith`
     * * `FilterOperators.contains`
     * * `FilterOperators.notContains`
     * * `FilterOperators.isEmpty`
     * * `FilterOperators.notempty`
     */
    operator: IFilterOperator | string;
    /**
     * The value to which the field is compared. Has to be of the same type as the field.
     */
    value?: IdType | IdType[] | boolean | null;
    /**
     * Determines if the string comparison is case-insensitive.
     */
    ignoreCase?: boolean;
    /**
    This is used to determine if the value being compared against a relative field (parentTable/idColumn) vs a static value ('12345').
    */
    isRelativeValue?: boolean;
}
declare function isFilter(source: ICompositeFilter | IFilter | IChildFilter | string): source is IFilter;

/**
 * A complex filter expression.
 */
interface ICompositeFilter {
    /**
     * The logical operation to use when the `filter.filters` option is set.
     *
     * The supported values are:
     * * `"and"`
     * * `"or"`
     */
    logic: 'or' | 'and';
    /**
     * The nested filter expressions
     */
    filters: Array<IFilter | IChildFilter | ICompositeFilter>;
}
declare function isCompositeFilter(source: ICompositeFilter | IFilter | IChildFilter): source is ICompositeFilter;

interface IChildFilter extends IFilter {
    /**
     * Used to support child entity filtering:
     * Child table name/navigation property
     * */
    childTable: string;
    /**
     * Used to support child entity filtering:
     * Specifies whether all or some of the child records have to match the given criteria
     * */
    linqOperation: 'all' | 'any';
}
declare function isChildFilter(source: ICompositeFilter | IFilter | IChildFilter): source is IChildFilter;

declare enum ComputationOperators {
    Multiply = "mul",
    Divide = "div",
    Add = "add",
    Subtract = "sub",
    Modulus = "mod"
}

interface Computation {
    /** This is the first value to be used in the computation */
    fieldA: string | number;
    /** This is the second value to be used in the computation */
    fieldB: string | number;
    operator: ComputationOperators | string;
    /** This MUST differ from the names of declared or dynamic properties of the identified resources. */
    alias: string;
}
declare function isComputation(source: string | Computation): source is Computation;

/**
 * The sort descriptor used by the `orderBy` method.
 */
interface Sort {
    /**
     * The field that is sorted.
     */
    field: string;
    /**
     * The sort direction. If no direction is set, the descriptor will be skipped during processing.
     *
     * The available values are:
     * - `asc` => ascending
     * - `desc` => descending
     */
    dir?: 'asc' | 'desc';
}

interface ODataQuery {
    /**
     * The number of records to be skipped by the pager.
     */
    skip?: number;
    /**
     * The number of records to take.
     */
    top?: number;
    /**
     * The descriptors used for sorting.
     */
    orderBy?: Array<Sort>;
    /**
     * The descriptors used for filtering.
     */
    filter?: ICompositeFilter;
    /**
     * Used to specify the retrieval of related tables/entities.
     */
    expand?: Array<Expander>;
    /**
     * Specifies the list of properties to retrieve
     */
    select?: string[];
    /**
     * Request a total count of records.
     * Note: Filter expressions will affect this value.
     * Default: true
     */
    count?: boolean;
    /**
     * Specifies aggregation behavior for the collection of entries.
     */
    apply?: string;
    /**
     * Specifies computed properties that can be used in $select, $filter or $orderby expressions.
     */
    compute?: Array<Computation | string>;
}

interface Expander extends ODataQuery {
    table: string;
}
declare function isExpander(source: string | Expander): source is Expander;

interface FetchOptions {
    /**
     * Collection of child table properties that are rendered on the table
     */
    boundChildTableProperties?: BoundChildTableProperty[];
    /**
     * Collection of property names that are of type: nullable Date
     */
    dateNullableProps?: string[];
    /**
     * Collection of property names that are of type: nullable UTC DateTime
     *    Note: these properties will be converted to local date time
     */
    utcNullableProps?: string[];
    /**
     * Set to true to force request via cache-busting.
     * Default: false;
     */
    bustCache?: boolean;
}
interface BoundChildTableProperty {
    /**
     * This is the child table name
     */
    table: string;
    /**
     * This is the field name on the child table that is bound
     */
    field: string;
    /**
     * This controls if 'all' child records have to meet the the conditions
     * or if 'any' of the child records have to meet the condition.
     * Default: 'any'
     */
    linqOperation?: 'all' | 'any';
}

interface IFilterOperators {
    [key: string]: IFilterOperator;
}
/**
 * Represents the list of supported simple filter operators.
 */
declare class FilterOperators {
    /**
     * The `eq` operator.
     */
    static readonly equals: IFilterOperator;
    /**
     * The `gt` operator.
     */
    static readonly greaterThan: IFilterOperator;
    /**
     * The `ge` operator.
     */
    static readonly greaterThanOrEquals: IFilterOperator;
    /**
     * The `lt` operator.
     */
    static readonly lessThan: IFilterOperator;
    /**
     * The `le` operator.
     */
    static readonly lessThanOrEquals: IFilterOperator;
    /**
     * The `ne` operator.
     */
    static readonly notEquals: IFilterOperator;
    /**
     * The `in` operator.
     */
    static readonly in: IFilterOperator;
    /**
     * The `not in` operator.
     */
    static readonly notIn: IFilterOperator;
    /**
     * The `is not null` operator.
     */
    static readonly notNull: IFilterOperator;
    /**
     * The `is null` operator.
     */
    static readonly isNull: IFilterOperator;
    /**
     * The `contains` operator.
     */
    static readonly contains: IFilterOperator;
    /**
     * The `not contain` operator.
     */
    static readonly notContains: IFilterOperator;
    /**
     * The `ends with` operator.
     */
    static readonly endsWith: IFilterOperator;
    /**
     * The `not ends with` operator.
     */
    static readonly notEndsWith: IFilterOperator;
    /**
     * The `startswith` operator.
     */
    static readonly startsWith: IFilterOperator;
    /**
     * The `not start with` operator.
     */
    static readonly notStartsWith: IFilterOperator;
    /**
     * The `empty` operator.
     */
    static readonly isEmpty: IFilterOperator;
    /**
     * The `not empty` operator.
     */
    static readonly notEmpty: IFilterOperator;
}
declare const filterOperators: IFilterOperators;

interface ODataResult<T extends {
    id?: IdType;
} | unknown> {
    value: T[];
    count?: number;
    '@odata.count'?: number;
}
declare function createEmptyODataResult<T extends {
    id?: IdType;
} | unknown>(): ODataResult<T>;
declare function isODataResult<T extends {
    id?: IdType;
} | unknown>(source: unknown): source is ODataResult<T>;

interface IArrayFilter extends IFilter {
    /**
     * The supported operators are:
     * * `FilterOperators.in` (specified value should be an array)
     * * `FilterOperators.notIn` (specified value should be an array)
     */
    operator: IFilterOperator | string;
    /**
     * The value to which the field is compared. Has to be of the same type as the field.
     */
    value?: IdType[] | null;
}
declare function isArrayFilter(source: ICompositeFilter | IFilter | IChildFilter | string): source is IArrayFilter;

declare const uuidRegex: RegExp;
declare class ODataClientService {
    private readonly httpClient;
    fetch<T extends object>(odataEndpoint: string, query: ODataQuery, options?: FetchOptions): Observable<ODataResult<T>>;
    static ɵfac: i0.ɵɵFactoryDeclaration<ODataClientService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<ODataClientService>;
}
declare function getODataString(query: ODataQuery, options?: FetchOptions): string;
declare function processExpanders(query: ODataQuery, queryString: string): string;
declare function getExpansionString(element: Expander): string;
declare function processOrderBy(query: ODataQuery, queryString: string): string;
declare function processSimpleParameters(parameterName: 'skip' | 'top', query: ODataQuery, queryString: string): string;
declare function processCacheBusting(options: FetchOptions, queryString: string): string;
declare function processCount(query: ODataQuery, queryString: string): string;
declare function processDates(queryString: string): string;
declare function processGuids(queryString: string): string;
declare function processSelectors(state: ODataQuery, queryString: string): string;

declare const getFilterOperator: (operatorName: string) => IFilterOperator;

declare function createODataResult<T extends {
    id?: IdType;
} | unknown>(t: T[]): ODataResult<T>;

declare function serializeValue(value?: IdType, isRelativeValue?: boolean): string;
declare const serializeSimpleFilter: (field: string, operator: string, value?: IdType, isRelativeValue?: boolean) => string;
declare const serializeArrayFilter: (field: string, operator: string, values?: IdType[], isRelativeValue?: boolean) => string;
declare const serializeFunctionFilter: (field: string, func: string, value?: IdType, isRelativeValue?: boolean) => string;

declare function processFilters(query: ODataQuery, queryString: string): string;
declare function serializeCompositeFilter(compositeFilter: ICompositeFilter): string;
declare function serializeFilterItem(filter: IFilter | IChildFilter | ICompositeFilter): string;
declare function isNotEmptyFilter(filter: IFilter | IChildFilter | ICompositeFilter): boolean;
declare function serializeFilter(filter: IFilter | IChildFilter): string;

export { ComputationOperators, FilterOperators, ImngODataClientModule, ODataClientService, createEmptyODataResult, createODataResult, filterOperators, getExpansionString, getFilterOperator, getODataString, isArrayFilter, isChildFilter, isCompositeFilter, isComputation, isExpander, isFilter, isNotEmptyFilter, isODataResult, processCacheBusting, processCount, processDates, processExpanders, processFilters, processGuids, processOrderBy, processSelectors, processSimpleParameters, serializeArrayFilter, serializeCompositeFilter, serializeFilter, serializeFilterItem, serializeFunctionFilter, serializeSimpleFilter, serializeValue, uuidRegex };
export type { BoundChildTableProperty, Computation, Expander, FetchOptions, IArrayFilter, IChildFilter, ICompositeFilter, IFilter, IFilterOperator, IFilterOperators, ODataQuery, ODataResult, Sort };
