import { BucketSpecFn, Filter, FilterLike, LockFn, OmitFn, StoreRecord } from '@xh/hoist/data'; import { Cube } from './Cube'; import { CubeField } from './CubeField'; /** * Queries determine what data is extracted, grouped, and aggregated from a {@link Cube}. * Passed via the `query` property of {@link ViewConfig} when creating a View. * * Key options beyond `dimensions` and `filter`: `includeRoot` adds a grand-total row, * `includeLeaves` exposes source records as tree children, and `provideLeaves` makes them * accessible programmatically without rendering in the tree. * * See the Cube package README (`data/cube/README.md#querying-with-views`) for query patterns. * * @see Cube * @see View */ export interface QueryConfig { /** * The Cube to query. Required, but note that the preferred {@link Cube.executeQuery} API will * install a reference to itself on the query config (automatically). */ cube?: Cube; /** * Fields or field names. If unspecified will include all available {@link Cube.fields}. * Specify a subset to optimize aggregation performance. */ fields?: string[] | CubeField[]; /** * Fields or field names on which data should be grouped and aggregated. These are the ordered * grouping levels in the resulting hierarchy - e.g. ['Country', 'State', 'City']. * * If not provided or empty, the resulting data will not be grouped. Specify 'includeRoot' or * 'includeLeaves' in that case, otherwise no data will be returned. */ dimensions?: string[] | CubeField[]; /** * Filters to apply to leaf data, or configs to create. Note that leaf data will be filtered * and then aggregated - i.e. the filters provided here will filter in/out the lowest level * facts and _won't_ operate directly on any aggregates. * * Arrays will be combined into a single 'AND' CompoundFilter. */ filter?: FilterLike; /** * True to include a synthetic root node in the return with grand totals (aggregations across * all data returned by the query). Pairs well with {@link StoreConfig.loadRootAsSummary} and * {@link GridConfig.showSummary} to display a docked grand total row for grids rendering * Cube results. */ includeRoot?: boolean; /** * True to include leaf nodes (the "flat" facts originally loaded into the Cube) as the * {@link ViewRowData.children} of the lowest level of aggregated `dimensions`. * * False (the default) to only return aggregate rows based on requested `dimensions`. * * Useful when you wish to e.g. load Cube results into a tree grid and allow users to expand * aggregated groups all the way out to see the source data. See also `provideLeaves`, which * will provide access to these nodes without exposing as `children`. */ includeLeaves?: boolean; /** * True to provide access to leaf nodes via the {@link getCubeLeaves} helper on the * lowest level of aggregated `dimensions`. This will allow programmatic access to the leaves * used to produce a given aggregation, without exposing them as `children` in a way that would * cause them to be rendered in a tree grid. * * Useful when e.g. a full leaf-level drill-down is not desired, but the app still needs * access to those leaves to display in a separate view or for further processing. * * See also the more common `includeLeaves`. */ provideLeaves?: boolean; /** * True (default) to recursively omit single-child parents in the hierarchy. * Apps can implement further omit logic using `omitFn`. */ omitRedundantNodes?: boolean; /** * Optional function to be called for each aggregate node to determine if it should be "locked", * preventing drill-down into its children. * * Defaults to {@link Cube.lockFn}. */ lockFn?: LockFn; /** * Optional function to be called for each dimension during row generation to determine if the * children of that dimension should be bucketed into additional dynamic dimensions. * * This can be used to break selected aggregations into sub-groups dynamically, without having * to define another dimension in the Cube and have it apply to all aggregations. See the * {@link BucketSpecFn} type and {@link BucketSpec} interface for additional information. * * Defaults to {@link Cube.bucketSpecFn}. */ bucketSpecFn?: BucketSpecFn; /** * Optional function to be called on all single child rows during view processing. * Return true to omit the row. Defaults to Cube.omitFn. */ omitFn?: OmitFn; } /** * {@inheritDoc QueryConfig} * * @mcpHint query spec against a Cube, produced by executeQuery / createView */ export declare class Query { /** * Queried fields, sorted by name. Includes `dimensions`, added here if not already present. */ readonly fields: CubeField[]; readonly dimensions: CubeField[]; readonly filter: Filter; readonly hasFilter: boolean; readonly includeRoot: boolean; readonly includeLeaves: boolean; readonly provideLeaves: boolean; readonly omitRedundantNodes: boolean; readonly cube: Cube; readonly lockFn: LockFn; readonly bucketSpecFn: BucketSpecFn; readonly omitFn: OmitFn; private readonly _rawFields; private readonly _testFn; constructor({ cube, fields, dimensions, filter, includeRoot, includeLeaves, provideLeaves, omitRedundantNodes, lockFn, bucketSpecFn, omitFn }: QueryConfig); clone(overrides: Partial): Query; test(record: StoreRecord): boolean; /** * True if the provided other Query is equivalent to this instance. */ equals(other: Query): boolean; /** * True if the provided other Query is equivalent to this instance, not considering the filter. */ equalsExcludingFilter(other: Query): boolean; private parseFields; private parseDimensions; }