import { ComplexQueryOptions } from './ComplexQuery.js'; import { ResultItems, AsyncQueryResult, IndexableThing, SortOptions, PaginationOptions, Metadata } from './api/Store.js'; import { ComplexQueryExpression } from './api/ComplexQueryLang.js'; import 'apprt-core/Events'; import '@arcgis/core/geometry/Geometry'; /** * Sorts the given {@link ResultItems} by the rules specified in "options.sort". * * @param items Result of a query. * @param options Options which define how the items are sorted. * @returns A sorted copy of the given query result. * If "options.sort" is not specified, the given items are returned unsorted. */ declare function sort(items: ResultItems, options?: SortOptions): ResultItems; /** * Returns a section of the given {@link ResultItems}. * * The returned section starts at index "options.start" and has got a maximum length of "options.count". * @param items Result of a query. * @param options Options with start/count flags. * - If "options.start" is not specified, the returned section starts at index 0. * - If "options.count" is not specified, * the returned section ends with the last element of the given query result. * - If neither "options.start nor "options.count" is specified, the given query result is returned. * @returns A section of the given query result. */ declare function paginate(items: ResultItems, options?: PaginationOptions): ResultItems; /** * Sorts and paginates the given {@link ResultItems}. * * * First the given items are sorted by the rules specified in "options.sort". * Afterwards a section of the sorted result is created and returned. * The returned section starts at index "options.start" and has got a maximum length of "options.count". * @param items Result of a query. * @param options Options with sort/start/count flags. * - If "options.sort" is not specified, the given query result is not sorted. * - If "options.start" is not specified, the returned result section starts at index 0 of the sorted result. * - If "options.count" is not specified, * the returned section ends with the last element of the sorted result. * @returns Sorted section of the given result. */ declare function sortAndPaginate(items: ResultItems, options?: SortOptions & PaginationOptions): ResultItems; /** * Helper to create {@link ResultItems} from an items array. * Note that the array will be modified. * * @param items Array of items. * @param total Number of total items. * @returns Result items. */ declare function buildResult(items: ReadonlyArray, total?: number): ResultItems; /** * Creates a query result dependent of the input parameter. * It is intended for backwards compatibility to ensure that an AsyncQueryResult carries e.g a 'total' promise. * @param result Original result. * @returns A QueryResult object. */ declare function toQueryResult(result: T[]): ResultItems; declare function toQueryResult(result: Promise>): AsyncQueryResult; declare function toQueryResult(result: undefined): ResultItems; /** * This function creates a new function which can be used to implement * a Store.query method by evaluating and filtering data available in an iterable, e.g. array. * * @example * ```ts * import { createComplexQueryEngine } from "store-api/utils"; * import { AsyncStore, ComplexQueryExpression, QueryOptions } from "./api"; * * type MyItemType = Record; * * class MyStore implements AsyncStore { * items: MyItemType[] = [{ a: 1 }, { b: 2 }]; * async query(complexQuery?: ComplexQueryExpression, options?: QueryOptions) { * // filter, sort, paginate the items array * return createComplexQueryEngine(complexQuery, options)(this.items); * } * } * ``` * @param query a complex query expression * @param options complex query, sort and paginate options. * @returns A function which filters, sorts and paginates the given query result. */ declare function createComplexQueryEngine(query?: ComplexQueryExpression, options?: ComplexQueryOptions & SortOptions & PaginationOptions): (items: ResultItems) => ResultItems; /** * Helper to filter store metadata based on a partial metadata configuration. * @param filterMetadataDefinition this metadata will be merged with the originalMetadata. * Only fields listed in this metadata definition are available in the merged result. * Fields will only be merged if they match a field in the original metadata. * If the filterMetadataDefinition has 'undefined' fields the original fields are used. * @param originalMetadata The source metadata. * @param idPropertyName property used to represent the ID * @returns new metadata with combined properties. */ declare function mergeMetadata(filterMetadataDefinition: Partial | undefined, originalMetadata: Partial | undefined, idPropertyName: string): Metadata; export { buildResult, createComplexQueryEngine, mergeMetadata, paginate, sort, sortAndPaginate, toQueryResult };