appwrite-utils-cli 1.7.7 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,214 @@
1
+ import type { Models } from "node-appwrite";
2
+ /**
3
+ * Interface for sync selection summary
4
+ */
5
+ export interface SyncSelectionSummary {
6
+ databases: DatabaseSelection[];
7
+ buckets: BucketSelection[];
8
+ totalDatabases: number;
9
+ totalTables: number;
10
+ totalBuckets: number;
11
+ newItems: {
12
+ databases: number;
13
+ tables: number;
14
+ buckets: number;
15
+ };
16
+ existingItems: {
17
+ databases: number;
18
+ tables: number;
19
+ buckets: number;
20
+ };
21
+ }
22
+ /**
23
+ * Database selection with associated tables
24
+ */
25
+ export interface DatabaseSelection {
26
+ databaseId: string;
27
+ databaseName: string;
28
+ tableIds: string[];
29
+ tableNames: string[];
30
+ isNew: boolean;
31
+ }
32
+ /**
33
+ * Bucket selection with associated database
34
+ */
35
+ export interface BucketSelection {
36
+ bucketId: string;
37
+ bucketName: string;
38
+ databaseId?: string;
39
+ databaseName?: string;
40
+ isNew: boolean;
41
+ }
42
+ /**
43
+ * Options for database selection
44
+ */
45
+ export interface DatabaseSelectionOptions {
46
+ showSelectAll?: boolean;
47
+ allowNewOnly?: boolean;
48
+ defaultSelected?: string[];
49
+ }
50
+ /**
51
+ * Options for table selection
52
+ */
53
+ export interface TableSelectionOptions {
54
+ showSelectAll?: boolean;
55
+ allowNewOnly?: boolean;
56
+ defaultSelected?: string[];
57
+ showDatabaseContext?: boolean;
58
+ }
59
+ /**
60
+ * Options for bucket selection
61
+ */
62
+ export interface BucketSelectionOptions {
63
+ showSelectAll?: boolean;
64
+ allowNewOnly?: boolean;
65
+ defaultSelected?: string[];
66
+ groupByDatabase?: boolean;
67
+ }
68
+ /**
69
+ * Response from existing config prompt
70
+ */
71
+ export interface ExistingConfigResponse {
72
+ syncExisting: boolean;
73
+ modifyConfiguration: boolean;
74
+ }
75
+ /**
76
+ * Comprehensive selection dialog system for enhanced sync flow
77
+ *
78
+ * This class provides interactive dialogs for selecting databases, tables/collections,
79
+ * and storage buckets during sync operations. It supports both new and existing
80
+ * configurations with visual indicators and comprehensive confirmation flows.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * import { SelectionDialogs } from './shared/selectionDialogs.js';
85
+ * import type { Models } from 'node-appwrite';
86
+ *
87
+ * // Example usage in a sync command
88
+ * const availableDatabases: Models.Database[] = await getAvailableDatabases();
89
+ * const configuredDatabases = config.databases || [];
90
+ *
91
+ * // Prompt about existing configuration
92
+ * const { syncExisting, modifyConfiguration } = await SelectionDialogs.promptForExistingConfig(configuredDatabases);
93
+ *
94
+ * if (modifyConfiguration) {
95
+ * // Select databases
96
+ * const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
97
+ * availableDatabases,
98
+ * configuredDatabases,
99
+ * { showSelectAll: true, allowNewOnly: !syncExisting }
100
+ * );
101
+ *
102
+ * // For each database, select tables
103
+ * const tableSelectionsMap = new Map<string, string[]>();
104
+ * const availableTablesMap = new Map<string, any[]>();
105
+ *
106
+ * for (const databaseId of selectedDatabaseIds) {
107
+ * const database = availableDatabases.find(db => db.$id === databaseId)!;
108
+ * const availableTables = await getTablesForDatabase(databaseId);
109
+ * const configuredTables = getConfiguredTablesForDatabase(databaseId);
110
+ *
111
+ * availableTablesMap.set(databaseId, availableTables);
112
+ *
113
+ * const selectedTableIds = await SelectionDialogs.selectTablesForDatabase(
114
+ * databaseId,
115
+ * database.name,
116
+ * availableTables,
117
+ * configuredTables,
118
+ * { showSelectAll: true, allowNewOnly: !syncExisting }
119
+ * );
120
+ *
121
+ * tableSelectionsMap.set(databaseId, selectedTableIds);
122
+ * }
123
+ *
124
+ * // Select buckets
125
+ * const availableBuckets = await getAvailableBuckets();
126
+ * const configuredBuckets = config.buckets || [];
127
+ * const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
128
+ * selectedDatabaseIds,
129
+ * availableBuckets,
130
+ * configuredBuckets,
131
+ * { showSelectAll: true, groupByDatabase: true }
132
+ * );
133
+ *
134
+ * // Create selection objects
135
+ * const databaseSelections = SelectionDialogs.createDatabaseSelection(
136
+ * selectedDatabaseIds,
137
+ * availableDatabases,
138
+ * tableSelectionsMap,
139
+ * configuredDatabases,
140
+ * availableTablesMap
141
+ * );
142
+ *
143
+ * const bucketSelections = SelectionDialogs.createBucketSelection(
144
+ * selectedBucketIds,
145
+ * availableBuckets,
146
+ * configuredBuckets,
147
+ * availableDatabases
148
+ * );
149
+ *
150
+ * // Show final confirmation
151
+ * const selectionSummary = SelectionDialogs.createSyncSelectionSummary(
152
+ * databaseSelections,
153
+ * bucketSelections
154
+ * );
155
+ *
156
+ * const confirmed = await SelectionDialogs.confirmSyncSelection(selectionSummary);
157
+ *
158
+ * if (confirmed) {
159
+ * // Proceed with sync operation
160
+ * await performSync(databaseSelections, bucketSelections);
161
+ * }
162
+ * }
163
+ * ```
164
+ */
165
+ export declare class SelectionDialogs {
166
+ /**
167
+ * Prompts user about existing configuration
168
+ */
169
+ static promptForExistingConfig(configuredItems: any[]): Promise<ExistingConfigResponse>;
170
+ /**
171
+ * Shows database selection dialog with indicators for configured vs new databases
172
+ */
173
+ static selectDatabases(availableDatabases: Models.Database[], configuredDatabases: any[], options?: DatabaseSelectionOptions): Promise<string[]>;
174
+ /**
175
+ * Shows table/collection selection dialog for a specific database
176
+ */
177
+ static selectTablesForDatabase(databaseId: string, databaseName: string, availableTables: any[], configuredTables: any[], options?: TableSelectionOptions): Promise<string[]>;
178
+ /**
179
+ * Shows bucket selection dialog for selected databases
180
+ */
181
+ static selectBucketsForDatabases(selectedDatabaseIds: string[], availableBuckets: any[], configuredBuckets: any[], options?: BucketSelectionOptions): Promise<string[]>;
182
+ /**
183
+ * Shows final confirmation dialog with sync selection summary
184
+ */
185
+ static confirmSyncSelection(selectionSummary: SyncSelectionSummary): Promise<boolean>;
186
+ /**
187
+ * Creates a sync selection summary from selected items
188
+ */
189
+ static createSyncSelectionSummary(databaseSelections: DatabaseSelection[], bucketSelections: BucketSelection[]): SyncSelectionSummary;
190
+ /**
191
+ * Helper method to create database selection objects
192
+ */
193
+ static createDatabaseSelection(selectedDatabaseIds: string[], availableDatabases: Models.Database[], tableSelectionsMap: Map<string, string[]>, configuredDatabases: any[], availableTablesMap?: Map<string, any[]>): DatabaseSelection[];
194
+ /**
195
+ * Helper method to create bucket selection objects
196
+ */
197
+ static createBucketSelection(selectedBucketIds: string[], availableBuckets: any[], configuredBuckets: any[], availableDatabases: Models.Database[]): BucketSelection[];
198
+ /**
199
+ * Shows a progress message during selection operations
200
+ */
201
+ static showProgress(message: string): void;
202
+ /**
203
+ * Shows an error message and handles graceful cancellation
204
+ */
205
+ static showError(message: string, error?: Error): void;
206
+ /**
207
+ * Shows a warning message
208
+ */
209
+ static showWarning(message: string): void;
210
+ /**
211
+ * Shows a success message
212
+ */
213
+ static showSuccess(message: string): void;
214
+ }