/** @module @airtable/blocks/models: RecordQueryResult */ /** */ import Sdk from "../sdk"; import { FlowAnyObject, FlowAnyExistential, FlowAnyFunction } from "../private_utils"; import { VisList, NormalizedGroupLevel } from "../types/airtable_interface"; import { GroupLevelData, GroupData } from "../types/view"; import Table from "./table"; import View from "./view"; import RecordQueryResult, { WatchableRecordQueryResultKey, NormalizedRecordQueryResultOpts, NormalizedSortConfig } from "./record_query_result"; import Field from "./field"; import Record from "./record"; import ObjectPool from "./object_pool"; import RecordStore from "./record_store"; import ViewDataStore from "./view_data_store"; import GroupedRecordQueryResult from "./grouped_record_query_result"; import { GroupLevels } from "./view_metadata_query_result"; /** @hidden */ interface TableOrViewQueryResultData { recordIds: Array | null; groups: Array | null; groupLevels: Array | null; } /** * Represents a set of records directly from a view or table. See {@link RecordQueryResult} for main * documentation. * * Do not instantiate. You can get instances of this class by calling * `table.selectRecords` or `view.selectRecords`. * * @docsPath models/query results/TableOrViewQueryResult */ declare class TableOrViewQueryResult extends RecordQueryResult { /** @internal */ static _className: string; /** @internal */ _sourceModel: Table | View; /** @internal */ _mostRecentSourceModelLoadPromise: Promise | null; /** @internal */ _table: Table; /** @internal */ _fieldIdsSetToLoadOrNullIfAllFields: { [key: string]: true; } | null; /** @internal */ _visList: VisList | null; /** @internal */ _sorts: Array | null; /** @internal */ _groupLevels: Array | null; /** @internal */ _orderedRecordIds: Array | null; /** @internal */ _orderedGroups: Array | null; /** @internal */ _loadedGroupLevels: Array | null; /** @internal */ _recordIdsSet: { [key: string]: true | void; } | null; /** @internal */ _cellValueKeyWatchCounts: { [key: string]: number; }; /** @internal */ __groupedRecordQueryResultPool: ObjectPool; /** @internal */ constructor(sdk: Sdk, sourceModel: Table | View, normalizedOpts: NormalizedRecordQueryResultOpts); /** @internal */ get _dataOrNullIfDeleted(): TableOrViewQueryResultData | null; /** @internal */ get __sourceModelId(): string; /** @internal */ get __poolKey(): string; /** * @internal (since we may not be able to return parent model instances in the immutable models world) * The table that records in this RecordQueryResult are part of */ get parentTable(): Table; /** * @internal (since we may not be able to return parent model instances in the immutable models world) * The view that was used to obtain this RecordQueryResult by calling * `view.selectRecords`. Null if the RecordQueryResult was obtained by calling * `table.selectRecords`. */ get parentView(): View | null; /** * The record IDs in this RecordQueryResult. * Throws if data is not loaded yet. * Can be watched. */ get recordIds(): Array; /** * The ordered GroupedRecordQueryResult's in this RecordQueryResult. * Throws if data is not loaded yet. * Can be watched. * * @hidden */ get groups(): Array | null; /** * The GroupLevels in this RecordQueryResult. * Throws if data is not loaded yet. * Can be watched. * * @hidden */ get groupLevels(): GroupLevels | null; /** * The set of record IDs in this RecordQueryResult. * Throws if data is not loaded yet. * * @internal */ _getOrGenerateRecordIdsSet(): { [key: string]: true | void; }; /** * The fields that were used to create this RecordQueryResult. * Null if fields were not specified, which means the RecordQueryResult * will load all fields in the table. */ get fields(): Array | null; /** @internal */ get _cellValuesForSortWatchKeys(): Array; /** @internal */ get _cellValuesForGroupWatchKeys(): Array; /** @internal */ get _sourceModelRecordIds(): Array; /** @internal */ get _sourceModelGroups(): Array | null; /** @internal */ get _sourceModelGroupLevels(): Array | null; /** @internal */ get _sourceModelRecords(): Array; /** @internal */ _incrementCellValueKeyWatchCountAndWatchIfNecessary(key: string, watchCallback: FlowAnyFunction): void; /** @internal */ _decrementCellValueKeyWatchCountAndUnwatchIfPossible(key: string, watchCallback: FlowAnyFunction): void; /** @inheritdoc */ watch(keys: WatchableRecordQueryResultKey | ReadonlyArray, callback: FlowAnyFunction, context?: FlowAnyObject | null): Array; /** @inheritdoc */ unwatch(keys: WatchableRecordQueryResultKey | ReadonlyArray, callback: FlowAnyFunction, context?: FlowAnyObject | null): Array; /** @inheritdoc */ loadDataAsync(): Promise; /** * @internal */ _getChangedKeysOnLoad(): Array; /** @internal */ _loadDataAsync(): Promise>; /** @inheritdoc */ unloadData(): void; /** @internal */ _unloadData(): void; /** @internal */ _addRecordIdsToVisList(recordIds: Array): void; /** @internal */ _onGroupLevelsChanged(model: RecordStore | ViewDataStore, key: string, updates?: { addedRecordIds: Array; removedRecordIds: Array; } | null): void; /** @internal */ _onGroupsChanged(model: RecordStore | ViewDataStore, key: string, updates?: { addedRecordIds: Array; removedRecordIds: Array; } | null): void; /** @internal */ _onRecordsChanged(model: RecordStore | ViewDataStore, key: string, updates?: { addedRecordIds: Array; removedRecordIds: Array; } | null): void; /** @internal */ _onCellValuesForGroupChanged(recordStore: RecordStore, key: string, recordIds?: Array | null, fieldId?: string | null): void; /** @internal */ _onCellValuesForSortChanged(recordStore: RecordStore, key: string, recordIds?: Array | null, fieldId?: string | null): void; /** @internal */ _onFieldConfigChanged(_field: Field, _key: string): void; /** @internal */ _onTableFieldsChanged(table: Table, key: string, updates: { addedFieldIds: Array; removedFieldIds: Array; }): void; /** @internal */ _onCellValuesChanged(table: Table, key: string, updates?: FlowAnyObject | null): void; /** @internal */ _onCellValuesInFieldChanged(table: Table, key: string, recordIds?: Array | null, fieldId?: string | null): void; /** @internal */ _generateOrderedRecordIds(): Array; /** @internal */ _generateAndLoadOrderedGroups(): Array | null; /** @internal */ _unloadOrderedGroupsIfNeeded(): void; /** * If groupings change then some groups will need to be created, and some removed * This (TODO: will) handle the diffing necessary to unload, and reload only the changed groups. * Also triggers the WatchableKeys.group, as by necessity this will have changed. * * @internal */ _unloadRemovedGroupsAndLoadNewGroupsAndTriggerWatches(): void; /** @internal */ _replaceVisList(): void; /** @internal */ _getSortsWithDeletedFieldsFiltered(): Array; /** @internal */ _spawnErrorForDeletion(): Error; } export default TableOrViewQueryResult;