/** @packageDocumentation
 * @module Content
 */
import { Id64String } from "@itwin/core-bentley";
import { ClassInfo, CompressedClassInfoJSON, RelatedClassInfo, RelatedClassInfoJSON, RelatedClassInfoWithOptionalRelationship, RelatedClassInfoWithOptionalRelationshipJSON, RelationshipPath, RelationshipPathJSON } from "../EC.js";
import { InstanceFilterDefinition } from "../InstanceFilterDefinition.js";
import { Ruleset } from "../rules/Ruleset.js";
import { CategoryDescription, CategoryDescriptionJSON } from "./Category.js";
import { Field, FieldDescriptor, FieldJSON } from "./Fields.js";
/**
 * Data structure that describes an ECClass in content [[Descriptor]].
 * @public
 */
export interface SelectClassInfo {
    /** Information about the ECClass */
    selectClassInfo: ClassInfo;
    /** Is the class handled polymorphically */
    isSelectPolymorphic: boolean;
    /** Relationship path from input class to the select class. */
    pathFromInputToSelectClass?: RelatedClassInfoWithOptionalRelationship[];
    /** Relationship paths to [related property]($docs/presentation/content/Terminology#related-properties) classes */
    relatedPropertyPaths?: RelationshipPath[];
    /** Relationship paths to navigation property classes */
    navigationPropertyClasses?: RelatedClassInfo[];
    /** Relationship paths to [related instance]($docs/presentation/content/Terminology#related-instance) classes. */
    relatedInstancePaths?: RelationshipPath[];
}
/**
 * Serialized [[SelectClassInfo]] JSON representation
 * @public
 */
export interface SelectClassInfoJSON<TClassInfoJSON = ClassInfo> {
    selectClassInfo: TClassInfoJSON;
    isSelectPolymorphic: boolean;
    pathFromInputToSelectClass?: RelatedClassInfoWithOptionalRelationshipJSON<TClassInfoJSON>[];
    relatedPropertyPaths?: RelationshipPathJSON<TClassInfoJSON>[];
    navigationPropertyClasses?: RelatedClassInfoJSON<TClassInfoJSON>[];
    relatedInstancePaths?: RelationshipPathJSON<TClassInfoJSON>[];
}
/** @public */
export declare namespace SelectClassInfo {
    /** Deserialize [[SelectClassInfo]] from compressed JSON */
    function fromCompressedJSON(json: SelectClassInfoJSON<string>, classesMap: {
        [id: string]: CompressedClassInfoJSON;
    }): SelectClassInfo;
    /** Serialize [[SelectClassInfo]] to compressed JSON */
    function toCompressedJSON(selectClass: SelectClassInfo, classesMap: {
        [id: string]: CompressedClassInfoJSON;
    }): SelectClassInfoJSON<string>;
}
/**
 * Flags that control content format.
 * @public
 */
export declare enum ContentFlags {
    /** Each content record only has [[InstanceKey]] and no data */
    KeysOnly = 1,
    /** Each content record additionally has a display label */
    ShowLabels = 4,
    /** All content records are merged into a single record (see [Merging values]($docs/presentation/content/terminology#value-merging)) */
    MergeResults = 8,
    /** Content has only distinct values */
    DistinctValues = 16,
    /** Doesn't create property or calculated fields. Can be used in conjunction with [[ShowLabels]]. */
    NoFields = 32,
    /**
     * Set related input keys on [[Item]] objects when creating content. This helps identify which [[Item]] is associated to which
     * given input key at the cost of performance creating those items.
     */
    IncludeInputKeys = 256
}
/**
 * Data sorting direction
 * @public
 */
export declare enum SortDirection {
    Ascending = 0,
    Descending = 1
}
/**
 * Data structure that contains selection information. Used
 * for cases when requesting content after a selection change.
 *
 * @public
 */
export interface SelectionInfo {
    /** Name of selection provider which cause the selection change */
    providerName: string;
    /** Level of selection that changed */
    level?: number;
}
/**
 * Serialized [[Descriptor]] JSON representation.
 * @public
 */
export interface DescriptorJSON {
    classesMap: {
        [id: string]: CompressedClassInfoJSON;
    };
    connectionId: string;
    inputKeysHash: string;
    selectionInfo?: SelectionInfo;
    displayType: string;
    selectClasses: SelectClassInfoJSON<Id64String>[];
    categories: CategoryDescriptionJSON[];
    fields: FieldJSON<Id64String>[];
    sortingFieldName?: string;
    sortDirection?: SortDirection;
    contentFlags: number;
    fieldsFilterExpression?: string;
    instanceFilter?: InstanceFilterDefinition;
    ruleset?: Ruleset;
}
/**
 * Descriptor overrides that can be used to customize content
 * @public
 */
export interface DescriptorOverrides {
    /**
     * Content display type. Can be accessed in presentation rules and used
     * to modify content in various ways. Defaults to empty string.
     */
    displayType?: string;
    /** Content flags used for content customization. See [[ContentFlags]] */
    contentFlags?: number;
    /** Fields selector that allows excluding or including only specified fields. */
    fieldsSelector?: {
        /** Should the specified fields be included or excluded */
        type: "include" | "exclude";
        /** A list of field descriptors that identify fields to include / exclude */
        fields: FieldDescriptor[];
    };
    /** Specification for sorting data. */
    sorting?: {
        /** Identifier of the field to use for sorting */
        field: FieldDescriptor;
        /** Sort direction */
        direction: SortDirection;
    };
    /**
     * [ECExpression]($docs/presentation/advanced/ECExpressions.md) for filtering content by
     * select fields.
     *
     * This is different from [[instanceFilter]] as filtering is applied on the union of all selects,
     * which removes access to content instance property values. Instead of referencing properties
     * through `this.PropertyName` alias, the expression should reference them by field names. In cases
     * when properties field merges multiple properties, this allows applying the filter on all of them
     * at once. This is useful for filtering table rows by column value, when content is displayed in
     * table format.
     */
    fieldsFilterExpression?: string;
    /**
     * Instances filter that allows filtering content by class, properties of specific class
     * or properties of instances related to the content instance.
     *
     * This is different from [[fieldsFilterExpression]] as filter is applied at a lower level - on
     * specific select class rather than a union of multiple select classes. This means the filter has
     * access to properties of that class and they can be referenced using symbols like `this.Property`.
     * This is useful for filtering instances of specific class.
     */
    instanceFilter?: InstanceFilterDefinition;
}
/**
 * Descriptor properties
 * @public
 */
export interface DescriptorSource {
    /** Id of the connection used to create the descriptor */
    readonly connectionId?: string;
    /** Hash of the input keys used to create the descriptor */
    readonly inputKeysHash?: string;
    /** Selection info used to create the descriptor */
    readonly selectionInfo?: SelectionInfo;
    /** Display type used to create the descriptor */
    readonly displayType: string;
    /** A list of classes that will be selected from when creating content with this descriptor */
    readonly selectClasses: SelectClassInfo[];
    /** A list of content field categories used in this descriptor */
    readonly categories: CategoryDescription[];
    /** A list of fields contained in the descriptor */
    readonly fields: Field[];
    /** [[ContentFlags]] used to create the descriptor */
    readonly contentFlags: number;
    /** Field used to sort the content */
    readonly sortingField?: Field;
    /** Sorting direction */
    readonly sortDirection?: SortDirection;
    /**
     * A ruleset used to create this descriptor.
     * Only set if descriptor is created using a ruleset different from the input ruleset, e.g. when creating a hierarchy level descriptor.
     */
    readonly ruleset?: Ruleset;
    /**
     * [ECExpression]($docs/presentation/advanced/ECExpressions.md) for filtering content by
     * select fields.
     *
     * This is different from [[instanceFilter]] as filtering is applied on the union of all selects,
     * which removes access to content instance property values. Instead of referencing properties
     * through `this.PropertyName` alias, the expression should reference them by field names. In cases
     * when properties field merges multiple properties, this allows applying the filter on all of them
     * at once. This is useful for filtering table rows by column value, when content is displayed in
     * table format.
     */
    fieldsFilterExpression?: string;
    /**
     * Instances filter that allows filtering content by class, properties of specific class
     * or properties of instances related to the content instance.
     *
     * This is different from [[fieldsFilterExpression]] as filter is applied at a lower level - on
     * specific select class rather than a union of multiple select classes. This means the filter has
     * access to properties of that class and they can be referenced using symbols like `this.Property`.
     * This is useful for filtering instances of specific class.
     */
    instanceFilter?: InstanceFilterDefinition;
}
/**
 * Data structure that describes content: fields, sorting, filtering, format, etc.
 * Descriptor may be changed to control how content is created.
 *
 * @public
 */
export declare class Descriptor implements DescriptorSource {
    /** Id of the connection used to create the descriptor */
    readonly connectionId?: string;
    /** Hash of the input keys used to create the descriptor */
    readonly inputKeysHash?: string;
    /** Selection info used to create the descriptor */
    readonly selectionInfo?: SelectionInfo;
    /** Display type used to create the descriptor */
    readonly displayType: string;
    /** A list of classes that will be selected when creating content with this descriptor */
    readonly selectClasses: SelectClassInfo[];
    /** A list of content field categories used in this descriptor */
    readonly categories: CategoryDescription[];
    /** A list of fields contained in the descriptor */
    readonly fields: Field[];
    /** [[ContentFlags]] used to create the descriptor */
    readonly contentFlags: number;
    /**
     * A ruleset used to create this descriptor.
     * Only set if descriptor is created using a ruleset different from the input ruleset, e.g. when creating a hierarchy level descriptor.
     */
    readonly ruleset?: Ruleset;
    /** Field used to sort the content */
    sortingField?: Field;
    /** Sorting direction */
    sortDirection?: SortDirection;
    /**
     * [ECExpression]($docs/presentation/advanced/ECExpressions.md) for filtering content by
     * select fields.
     *
     * This is different from [[instanceFilter]] as filtering is applied on the union of all selects,
     * which removes access to content instance property values. Instead of referencing properties
     * through `this.PropertyName` alias, the expression should reference them by field names. In cases
     * when properties field merges multiple properties, this allows applying the filter on all of them
     * at once. This is useful for filtering table rows by column value, when content is displayed in
     * table format.
     */
    fieldsFilterExpression?: string;
    /**
     * Instances filter that allows filtering content by class, properties of specific class
     * or properties of instances related to the content instance.
     *
     * This is different from [[fieldsFilterExpression]] as filter is applied at a lower level - on
     * specific select class rather than a union of multiple select classes. This means the filter has
     * access to properties of that class and they can be referenced using symbols like `this.Property`.
     * This is useful for filtering instances of specific class.
     */
    instanceFilter?: InstanceFilterDefinition;
    /** Construct a new Descriptor using a [[DescriptorSource]] */
    constructor(source: DescriptorSource);
    /** Serialize [[Descriptor]] to JSON */
    toJSON(): DescriptorJSON;
    /** Deserialize [[Descriptor]] from JSON */
    static fromJSON(json: DescriptorJSON | undefined): Descriptor | undefined;
    private static getFieldsFromJSON;
    /**
     * Get field by its name
     * @param name Name of the field to find
     * @param recurse Recurse into nested fields
     */
    getFieldByName(name: string, recurse?: boolean): Field | undefined;
    /**
     * Get field by its descriptor.
     */
    getFieldByDescriptor(fieldDescriptor: FieldDescriptor, recurse?: boolean): Field | undefined;
    /**
     * Create descriptor overrides object from this descriptor.
     * @public
     */
    createDescriptorOverrides(): DescriptorOverrides;
}
//# sourceMappingURL=Descriptor.d.ts.map