import type { IFieldVo } from '@teable/core'; import type { IGetBasePermissionVo, IGetTempTokenVo, IRecordsVo } from '@teable/openapi'; import type { AsyncMethodReturns } from 'penpal'; import type { IRange, SelectionRegionType } from '../components/grid/interface'; export interface IUIConfig { isExpand?: boolean; isShowingSettings?: boolean; theme?: string; } export type IUrlParams = Partial>; export interface ISelection { range: IRange[]; type: SelectionRegionType; } export interface IGetSelectionRecordsVo { records: IRecordsVo['records']; fields: IFieldVo[]; } export type IBasePermissions = IGetBasePermissionVo; export interface IParentBridgeUIMethods { expandRecord: (recordIds: string[]) => void; expandPlugin: () => void; } export interface IParentBridgeUtilsMethods { updateStorage: (storage?: Record) => Promise>; getAuthCode: () => Promise; getSelfTempToken: () => Promise; getSelectionRecords: (selection: ISelection, options?: { skip?: number; take?: number; }) => Promise; } export type IParentBridgeMethods = IParentBridgeUIMethods & IParentBridgeUtilsMethods; export interface IChildBridgeMethods { syncUIConfig: (uiConfig: IUIConfig) => void; syncSelection: (selection?: ISelection) => void; syncBasePermissions: (permissions: IBasePermissions) => void; syncUrlParams: (urlParams: IUrlParams) => void; } export type IBridgeListener = { on: (event: T, listener: IChildBridgeMethods[T]) => void; removeListener: (event: T, listener: IChildBridgeMethods[T]) => void; removeAllListeners: (event?: T) => void; destroy: () => void; }; export type IPluginBridge = AsyncMethodReturns & IBridgeListener;