import { DataTable, DuckDbConnector, DuckDbSliceState, LoadFileOptions } from '@sqlrooms/duckdb'; import { CreateLayoutSliceProps, LayoutSliceState } from '@sqlrooms/layout'; import { BaseRoomConfig, DataSource, FileDataSource, LayoutConfig } from '@sqlrooms/room-config'; import { BaseRoomStoreState, CommandSliceState, CreateBaseRoomSliceProps } from '@sqlrooms/room-store'; import { ProgressInfo } from '@sqlrooms/utils'; import { ReactNode } from 'react'; import { StateCreator, StoreApi } from 'zustand'; import { DataSourceState, DataSourceStatus, RoomFileInfo, RoomFileState } from './types'; export type RoomShellSliceConfig = BaseRoomConfig; export type RoomShellStore = StoreApi; export type TaskProgress = { progress?: number | undefined; message: string; }; export type RoomShellSliceState = { initialize?: () => Promise; room: BaseRoomStoreState['room'] & { config: RoomShellSliceConfig; tasksProgress: Record; setConfig: (config: RoomShellSliceConfig) => void; setTaskProgress: (id: string, taskProgress: TaskProgress | undefined) => void; getLoadingProgress: () => TaskProgress | undefined; roomFiles: RoomFileInfo[]; roomFilesProgress: { [pathname: string]: RoomFileState; }; isDataAvailable: boolean; dataSourceStates: { [tableName: string]: DataSourceState; }; /** * Load a file data source. A fileDataSourceLoader implementation can be passed to * createRoomShellSlice to specify how file data sources should be loaded. * * @example * ```ts * ...createRoomShellSlice({ * config: { * dataSources: [ * { type: 'file', fileName: 'earthquakes.parquet', tableName: 'earthquakes' }, * ], * }, * room: { * fileDataSourceLoader: async ({fileName}, onProgress) => * await downloadFile(`https://some.url/${fileName}`, {onProgress}), * }, * })(set, get, store) * ``` * * @param fileName - The name of the file to load. * @param onProgress - A callback to report the progress of the download. * @returns The loaded file. */ fileDataSourceLoader?: ({ fileName }: FileDataSource, onProgress: (progress: ProgressInfo) => void) => Promise; CustomErrorBoundary: React.ComponentType<{ onRetry?: () => void; children?: ReactNode; }>; setRoomTitle(title: string): void; setDescription(description: string): void; /** * Add or update a SQL query data source. * @param tableName - The name of the table to create or update. * @param query - The SQL query to execute. * @param oldTableName - The name of the table to replace (optional). */ addOrUpdateSqlQueryDataSource(tableName: string, query: string, oldTableName?: string, abortSignal?: AbortSignal): Promise; areDatasetsReady(): boolean; addRoomFile(file: File | string, tableName?: string, loadFileOptions?: LoadFileOptions): Promise; /** * @deprecated Use removeDataSource or removeRoomFile instead */ removeSqlQueryDataSource(tableName: string): Promise; /** * Removes a data source from the room by tableName. * @param tableName - The name of the table of the data source to remove. */ removeDataSource(tableName: string): Promise; /** * Removes a file data source from the room by pathname. * @param pathname - The pathname of the file to remove. */ removeRoomFile(pathname: string): Promise; setRoomFiles(info: RoomFileInfo[]): void; setRoomFileProgress(pathname: string, fileState: RoomFileState): void; addDataSource: (dataSource: DataSource, status?: DataSourceStatus) => Promise; }; } & DuckDbSliceState & LayoutSliceState & CommandSliceState; /** * This type takes a union type U (for example, A | B) and transforms it into an intersection type (A & B). This is useful because if you pass in, say, two slices of type { a: number } and { b: string }, the union of the slice types would be { a: number } | { b: string }, but you really want an object that has both properties—i.e. { a: number } & { b: string }. */ type CreateRoomShellSliceProps = CreateBaseRoomSliceProps & { connector?: DuckDbConnector; config?: Partial; layout?: CreateLayoutSliceProps; fileDataSourceLoader?: RoomShellSliceState['room']['fileDataSourceLoader']; CustomErrorBoundary?: RoomShellSliceState['room']['CustomErrorBoundary']; /** @deprecated Use direct props instead e.g. layout.panels */ room?: Partial>; }; export declare function createRoomShellSlice(props: CreateRoomShellSliceProps): StateCreator; export declare function useBaseRoomShellStore(selector: (state: RS) => T): T; export {}; //# sourceMappingURL=RoomShellSlice.d.ts.map