import type { Models } from "node-appwrite"; /** * Interface for sync selection summary */ export interface SyncSelectionSummary { databases: DatabaseSelection[]; buckets: BucketSelection[]; totalDatabases: number; totalTables: number; totalBuckets: number; newItems: { databases: number; tables: number; buckets: number; }; existingItems: { databases: number; tables: number; buckets: number; }; } /** * Database selection with associated tables */ export interface DatabaseSelection { databaseId: string; databaseName: string; tableIds: string[]; tableNames: string[]; isNew: boolean; } /** * Bucket selection with associated database */ export interface BucketSelection { bucketId: string; bucketName: string; databaseId?: string; databaseName?: string; isNew: boolean; } /** * Options for database selection */ export interface DatabaseSelectionOptions { showSelectAll?: boolean; allowNewOnly?: boolean; defaultSelected?: string[]; } /** * Options for table selection */ export interface TableSelectionOptions { showSelectAll?: boolean; allowNewOnly?: boolean; defaultSelected?: string[]; showDatabaseContext?: boolean; } /** * Options for bucket selection */ export interface BucketSelectionOptions { showSelectAll?: boolean; allowNewOnly?: boolean; defaultSelected?: string[]; groupByDatabase?: boolean; } /** * Response from existing config prompt */ export interface ExistingConfigResponse { syncExisting: boolean; modifyConfiguration: boolean; } /** * Comprehensive selection dialog system for enhanced sync flow * * This class provides interactive dialogs for selecting databases, tables/collections, * and storage buckets during sync operations. It supports both new and existing * configurations with visual indicators and comprehensive confirmation flows. * * @example * ```typescript * import { SelectionDialogs } from './shared/selectionDialogs.js'; * import type { Models } from 'node-appwrite'; * * // Example usage in a sync command * const availableDatabases: Models.Database[] = await getAvailableDatabases(); * const configuredDatabases = config.databases || []; * * // Prompt about existing configuration * const { syncExisting, modifyConfiguration } = await SelectionDialogs.promptForExistingConfig(configuredDatabases); * * if (modifyConfiguration) { * // Select databases * const selectedDatabaseIds = await SelectionDialogs.selectDatabases( * availableDatabases, * configuredDatabases, * { showSelectAll: true, allowNewOnly: !syncExisting } * ); * * // For each database, select tables * const tableSelectionsMap = new Map(); * const availableTablesMap = new Map(); * * for (const databaseId of selectedDatabaseIds) { * const database = availableDatabases.find(db => db.$id === databaseId)!; * const availableTables = await getTablesForDatabase(databaseId); * const configuredTables = getConfiguredTablesForDatabase(databaseId); * * availableTablesMap.set(databaseId, availableTables); * * const selectedTableIds = await SelectionDialogs.selectTablesForDatabase( * databaseId, * database.name, * availableTables, * configuredTables, * { showSelectAll: true, allowNewOnly: !syncExisting } * ); * * tableSelectionsMap.set(databaseId, selectedTableIds); * } * * // Select buckets * const availableBuckets = await getAvailableBuckets(); * const configuredBuckets = config.buckets || []; * const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases( * selectedDatabaseIds, * availableBuckets, * configuredBuckets, * { showSelectAll: true, groupByDatabase: true } * ); * * // Create selection objects * const databaseSelections = SelectionDialogs.createDatabaseSelection( * selectedDatabaseIds, * availableDatabases, * tableSelectionsMap, * configuredDatabases, * availableTablesMap * ); * * const bucketSelections = SelectionDialogs.createBucketSelection( * selectedBucketIds, * availableBuckets, * configuredBuckets, * availableDatabases * ); * * // Show final confirmation * const selectionSummary = SelectionDialogs.createSyncSelectionSummary( * databaseSelections, * bucketSelections * ); * * const confirmed = await SelectionDialogs.confirmSyncSelection(selectionSummary); * * if (confirmed) { * // Proceed with sync operation * await performSync(databaseSelections, bucketSelections); * } * } * ``` */ export declare class SelectionDialogs { /** * Prompts user about existing configuration */ static promptForExistingConfig(configuredItems: any[]): Promise; /** * Shows database selection dialog with indicators for configured vs new databases */ static selectDatabases(availableDatabases: Models.Database[], configuredDatabases: any[], options?: DatabaseSelectionOptions): Promise; /** * Shows table/collection selection dialog for a specific database */ static selectTablesForDatabase(databaseId: string, databaseName: string, availableTables: any[], configuredTables: any[], options?: TableSelectionOptions): Promise; /** * Shows bucket selection dialog for selected databases */ static selectBucketsForDatabases(selectedDatabaseIds: string[], availableBuckets: any[], configuredBuckets: any[], options?: BucketSelectionOptions): Promise; /** * Shows bucket selection for push operations with merged local+remote buckets. * Unlike selectBucketsForDatabases, this shows all buckets as a flat list * with source indicators (Local only, Remote only, Configured). */ static selectBucketsForPush(mergedBuckets: any[], configuredBuckets: any[], options?: BucketSelectionOptions): Promise; /** * Shows final confirmation dialog with sync selection summary */ static confirmSyncSelection(selectionSummary: SyncSelectionSummary, operationType?: 'push' | 'pull' | 'sync'): Promise; /** * Creates a sync selection summary from selected items */ static createSyncSelectionSummary(databaseSelections: DatabaseSelection[], bucketSelections: BucketSelection[]): SyncSelectionSummary; /** * Helper method to create database selection objects */ static createDatabaseSelection(selectedDatabaseIds: string[], availableDatabases: Models.Database[], tableSelectionsMap: Map, configuredDatabases: any[], availableTablesMap?: Map): DatabaseSelection[]; /** * Helper method to create bucket selection objects */ static createBucketSelection(selectedBucketIds: string[], availableBuckets: any[], configuredBuckets: any[], availableDatabases: Models.Database[]): BucketSelection[]; /** * Shows a progress message during selection operations */ static showProgress(message: string): void; /** * Shows an error message and handles graceful cancellation */ static showError(message: string, error?: Error): void; /** * Shows a warning message */ static showWarning(message: string): void; /** * Shows a success message */ static showSuccess(message: string): void; }