/** @module @airtable/blocks/models: Aggregators */ /** */ import { AggregatorKey } from '../types/aggregators'; import Sdk from '../sdk'; import Record from './record'; import Field from './field'; /** * Aggregators can be used to compute aggregates for cell values. * * @example * ```js * import {aggregators} from '@airtable/blocks/models'; * * // To get a list of aggregators supported for a specific field: * const fieldAggregators = myField.availableAggregators; * * // To compute the total attachment size of an attachment field: * const aggregator = aggregators.totalAttachmentSize; * const value = aggregator.aggregate(myRecords, myAttachmentField); * const valueAsString = aggregate.aggregateToString(myRecords, myAttachmentField); * ``` * @docsPath models/Aggregator */ export interface Aggregator { /** A unique key for this aggregator that can be used to identify it in code. */ key: AggregatorKey; /** A user friendly name for this aggregator that can be displayed to users. */ displayName: string; /** A short user friendly name for this aggregator that can be displayed to users. */ shortDisplayName: string; /** Aggregates the value of `field` in each of `records` to produce a single value. */ aggregate(records: Array, field: Field): unknown; /** Aggregates the value of `field` in each of `records` to produce a single value, formatted as a string. */ aggregateToString(records: Array, field: Field): string; } /** * Note: this is hidden instead of internal as it is the type of the public models.aggregators. * * If its internal, typescript won't know about it since the types will be stripped, and typescript * blocks will error due to incomplete type definitions. * * @hidden */ export interface Aggregators { [key: string]: Aggregator; } /** * Note: this is hidden instead of internal as it is used to determine the type of the public * models.aggregators. * * If its internal, typescript won't know about it since the types will be stripped, and typescript * blocks will error due to incomplete type definitions. * * TODO: this should be made less brittle. * * @hidden */ export default function createAggregators(): Aggregators; export declare function __injectSdkIntoCreateAggregators(_sdk: Sdk): void;