import { ObjectMap } from "../private_utils"; import { NormalizedSortConfig } from "../models/record_query_result"; import { Stat } from "./stat"; import { AggregatorKey } from "./aggregators"; import { BaseData, BasePermissionData, ModelChange } from "./base"; import { BlockInstallationId } from "./block"; import { CursorData } from "./cursor"; import { FieldData, FieldId, FieldType } from "./field"; import { RecordActionData, RecordActionDataCallback } from "./record_action_data"; import { GlobalConfigUpdate, GlobalConfigData, GlobalConfigPath, GlobalConfigPathValidationResult } from "./global_config"; import { RecordData, RecordId } from "./record"; import { UndoRedoMode } from "./undo_redo"; import { ViewportSizeConstraint } from "./viewport"; import { Mutation, PartialMutation, PermissionCheckResult, UpdateFieldOptionsOpts } from "./mutations"; import { TableId } from "./table"; import { GroupData, ViewColorsByRecordIdData, ViewFieldOrderData, ViewId, GroupLevelData } from "./view"; import { RequestJson, ResponseJson } from "./backend_fetch_types"; /** @hidden */ export declare enum BlockRunContextType { DASHBOARD_APP = "dashboardApp", VIEW = "view" } /** @hidden */ export interface BlockInstallationPageBlockRunContext { type: BlockRunContextType.DASHBOARD_APP; } /** @hidden */ export interface ViewBlockRunContext { type: BlockRunContextType.VIEW; tableId: TableId; viewId: ViewId; } /** @hidden */ export declare type BlockRunContext = BlockInstallationPageBlockRunContext | ViewBlockRunContext; /** @hidden */ export interface PartialViewData { visibleRecordIds: Array; fieldOrder: ViewFieldOrderData; colorsByRecordId: ViewColorsByRecordIdData | null; groups?: Array | null; groupLevels?: Array | null; } /** @hidden */ export declare type NormalizedGroupLevel = GroupLevelData; /** @hidden */ export interface NormalizedViewMetadata { /** Group levels, can be null or unspecified (null to clear, unspecified to not overwrite) */ groupLevels?: Array | null | undefined; } /** @hidden */ export interface SdkInitData { initialKvValuesByKey: GlobalConfigData; isDevelopmentMode: boolean; baseData: BaseData; blockInstallationId: BlockInstallationId; isFullscreen: boolean; isFirstRun: boolean; intentData: unknown; isUsingNewLookupCellValueFormat?: true | undefined; runContext: BlockRunContext; } /** @hidden */ export interface IdGenerator { generateRecordId(): string; generateFieldId(): string; generateTableId(): string; } /** @hidden */ export interface UrlConstructor { getTableUrl(tableId: TableId): string; getViewUrl(viewId: ViewId, tableId: TableId): string; getRecordUrl(recordId: RecordId, tableId: TableId): string; getAttachmentClientUrl(appInterface: AppInterface, attachmentId: string, attachmentUrl: string): string; } /** @hidden */ export interface AggregatorConfig { key: AggregatorKey; displayName: string; shortDisplayName: string; } /** @hidden */ export interface Aggregators { aggregate(appInterface: AppInterface, summaryFunctionKey: AggregatorKey, cellValues: Array, fieldData: FieldData): unknown; aggregateToString(appInterface: AppInterface, summaryFunctionKey: AggregatorKey, cellValues: Array, fieldData: FieldData): string; getAggregatorConfig(summaryFunctionKey: AggregatorKey): AggregatorConfig; getAllAvailableAggregatorKeys(): Array; getAvailableAggregatorKeysForField(fieldData: FieldData): Array; } /** @hidden */ declare type CellValueValidationResult = { isValid: true; } | { isValid: false; reason: string; }; /** @hidden */ declare type FieldConfigValidationResult = { isValid: true; } | { isValid: false; reason: string; }; /** @hidden */ export interface FieldTypeConfig { type: FieldType; options?: { [key: string]: unknown; }; } /** @hidden */ interface FieldUiConfig { iconName: string; desiredCellWidthForRecordCard: number; minimumCellWidthForRecordCard: number; } /** @hidden */ export interface FieldTypeProvider { isComputed(fieldData: FieldData): boolean; validateCellValueForUpdate(appInterface: AppInterface, newCellValue: unknown, currentCellValue: unknown, fieldData: FieldData): CellValueValidationResult; getConfig(appInterface: AppInterface, fieldData: FieldData, fieldNamesById: ObjectMap): FieldTypeConfig; validateConfigForUpdate(appInterface: AppInterface, newConfig: FieldTypeConfig, currentConfig: FieldTypeConfig | null, fieldData: FieldData | null, billingPlanGrouping: string, opts?: UpdateFieldOptionsOpts): FieldConfigValidationResult; canBePrimary(appInterface: AppInterface, config: FieldTypeConfig, billingPlanGrouping: string): boolean; convertStringToCellValue(appInterface: AppInterface, string: string, fieldData: FieldData): unknown; convertCellValueToString(appInterface: AppInterface, cellValue: unknown, fieldData: FieldData): string; getCellRendererData(appInterface: AppInterface, cellValue: unknown, fieldData: FieldData, shouldWrap: boolean): { cellValueHtml: string; attributes: { [key: string]: unknown; }; }; getUiConfig: (appInterface: AppInterface, fieldData: FieldData) => FieldUiConfig; } /** @hidden */ export interface GlobalConfigHelpers { validatePath(path: GlobalConfigPath, store: GlobalConfigData): GlobalConfigPathValidationResult; validateAndApplyUpdates(updates: ReadonlyArray, store: GlobalConfigData): { newKvStore: GlobalConfigData; changedTopLevelKeys: Array; }; } /** * AppInterface should never be used directly by the SDK, so we don't describe the type. * * @hidden */ export declare type AppInterface = unknown; /** @hidden */ export interface VisList { removeRecordIds(recordIds: Array): void; addRecordData(recordData: RecordData): void; getOrderedRecordIds(): Array; } /** * AirtableInterface is designed as the communication interface between the * Block SDK and Airtable. The mechanism through which we communicate with Airtable * depends on the context in which the block is running (i.e. frontend or backend), * but the interface should remain consistent. * * @hidden */ export interface AirtableInterface { sdkInitData: SdkInitData; idGenerator: IdGenerator; urlConstructor: UrlConstructor; aggregators: Aggregators; fieldTypeProvider: FieldTypeProvider; globalConfigHelpers: GlobalConfigHelpers; assertAllowedSdkPackageVersion: (packageName: string, packageVersion: string) => void; /** * table */ fetchAndSubscribeToTableDataAsync(tableId: string): Promise<{ recordsById: { [recordId: string]: RecordData; }; }>; unsubscribeFromTableData(tableId: string): void; fetchAndSubscribeToCellValuesInFieldsAsync(tableId: string, fieldIds: Array): Promise; unsubscribeFromCellValuesInFields(tableId: string, fieldIds: Array): void; /** * view */ fetchAndSubscribeToViewDataAsync(tableId: string, viewId: string): Promise; unsubscribeFromViewData(tableId: string, viewId: string): void; fetchDefaultCellValuesByFieldIdAsync(tableId: string, viewId: string | null): Promise<{ [key: string]: unknown; }>; applyMutationAsync(mutation: Mutation, opts?: { holdForMs?: number; }): Promise; checkPermissionsForMutation(mutation: PartialMutation, basePermissionData: BasePermissionData): PermissionCheckResult; subscribeToModelUpdates(callback: (data: { changes: ReadonlyArray; }) => void): void; subscribeToGlobalConfigUpdates(callback: (data: { updates: ReadonlyArray; }) => void): void; subscribeToSettingsButtonClick(callback: () => void): void; subscribeToEnterFullScreen(callback: () => void): void; subscribeToExitFullScreen(callback: () => void): void; subscribeToFocus(callback: () => void): void; fetchAndSubscribeToCursorDataAsync(): Promise; unsubscribeFromCursorData(): void; expandRecord(tableId: string, recordId: string, recordIds: Array | null): void; expandRecordList(tableId: string, recordIds: Array, fieldIds: Array | null): void; expandRecordPickerAsync(tableId: string, recordIds: Array, fieldIds: Array | null, shouldAllowCreatingRecord: boolean): Promise; reloadFrame(): void; setSettingsButtonVisibility(isVisible: boolean): void; setUndoRedoMode(mode: UndoRedoMode): void; setFullscreenMaxSize(maxFullscreenSize: ViewportSizeConstraint): void; enterFullscreen(): void; exitFullscreen(): void; createVisList(appInterface: AppInterface, recordDatas: Array, fieldDatas: Array, sorts: Array): VisList; setActiveViewOrTable(tableId: TableId, viewId?: ViewId): void; fetchAndSubscribeToPerformRecordActionAsync(callback: RecordActionDataCallback): Promise; performBackendFetchAsync(requestJson: RequestJson): Promise; /** * internal utils */ trackEvent(eventSchemaName: string, eventData: { [key: string]: unknown; }): void; trackExposure(featureName: string): void; sendStat(stat: Stat): void; } export {};