appwrite-utils-cli 0.10.85 → 1.0.1
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.
- package/.appwrite/.yaml_schemas/appwrite-config.schema.json +380 -0
- package/.appwrite/.yaml_schemas/collection.schema.json +255 -0
- package/.appwrite/collections/Categories.yaml +182 -0
- package/.appwrite/collections/ExampleCollection.yaml +36 -0
- package/.appwrite/collections/Posts.yaml +227 -0
- package/.appwrite/collections/Users.yaml +149 -0
- package/.appwrite/config.yaml +109 -0
- package/.appwrite/import/README.md +148 -0
- package/.appwrite/import/categories-import.yaml +129 -0
- package/.appwrite/import/posts-import.yaml +208 -0
- package/.appwrite/import/users-import.yaml +130 -0
- package/.appwrite/importData/categories.json +194 -0
- package/.appwrite/importData/posts.json +270 -0
- package/.appwrite/importData/users.json +220 -0
- package/.appwrite/schemas/categories.json +128 -0
- package/.appwrite/schemas/exampleCollection.json +52 -0
- package/.appwrite/schemas/posts.json +173 -0
- package/.appwrite/schemas/users.json +125 -0
- package/README.md +261 -33
- package/dist/collections/attributes.js +3 -2
- package/dist/collections/methods.js +56 -38
- package/dist/config/yamlConfig.d.ts +501 -0
- package/dist/config/yamlConfig.js +452 -0
- package/dist/databases/setup.d.ts +6 -0
- package/dist/databases/setup.js +119 -0
- package/dist/functions/methods.d.ts +1 -1
- package/dist/functions/methods.js +5 -2
- package/dist/functions/openapi.d.ts +4 -0
- package/dist/functions/openapi.js +60 -0
- package/dist/interactiveCLI.d.ts +5 -0
- package/dist/interactiveCLI.js +196 -52
- package/dist/main.js +91 -30
- package/dist/migrations/afterImportActions.js +2 -2
- package/dist/migrations/appwriteToX.d.ts +10 -0
- package/dist/migrations/appwriteToX.js +15 -4
- package/dist/migrations/backup.d.ts +16 -16
- package/dist/migrations/dataLoader.d.ts +83 -1
- package/dist/migrations/dataLoader.js +4 -4
- package/dist/migrations/importController.js +25 -18
- package/dist/migrations/importDataActions.js +2 -2
- package/dist/migrations/logging.d.ts +9 -1
- package/dist/migrations/logging.js +41 -22
- package/dist/migrations/migrationHelper.d.ts +4 -4
- package/dist/migrations/relationships.js +1 -1
- package/dist/migrations/services/DataTransformationService.d.ts +55 -0
- package/dist/migrations/services/DataTransformationService.js +158 -0
- package/dist/migrations/services/FileHandlerService.d.ts +75 -0
- package/dist/migrations/services/FileHandlerService.js +236 -0
- package/dist/migrations/services/ImportOrchestrator.d.ts +97 -0
- package/dist/migrations/services/ImportOrchestrator.js +488 -0
- package/dist/migrations/services/RateLimitManager.d.ts +138 -0
- package/dist/migrations/services/RateLimitManager.js +279 -0
- package/dist/migrations/services/RelationshipResolver.d.ts +120 -0
- package/dist/migrations/services/RelationshipResolver.js +332 -0
- package/dist/migrations/services/UserMappingService.d.ts +109 -0
- package/dist/migrations/services/UserMappingService.js +277 -0
- package/dist/migrations/services/ValidationService.d.ts +74 -0
- package/dist/migrations/services/ValidationService.js +260 -0
- package/dist/migrations/transfer.d.ts +0 -6
- package/dist/migrations/transfer.js +16 -132
- package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +384 -0
- package/dist/migrations/yaml/YamlImportConfigLoader.js +375 -0
- package/dist/migrations/yaml/YamlImportIntegration.d.ts +87 -0
- package/dist/migrations/yaml/YamlImportIntegration.js +330 -0
- package/dist/migrations/yaml/generateImportSchemas.d.ts +17 -0
- package/dist/migrations/yaml/generateImportSchemas.js +575 -0
- package/dist/schemas/authUser.d.ts +9 -9
- package/dist/shared/attributeManager.d.ts +17 -0
- package/dist/shared/attributeManager.js +273 -0
- package/dist/shared/confirmationDialogs.d.ts +75 -0
- package/dist/shared/confirmationDialogs.js +236 -0
- package/dist/shared/functionManager.d.ts +48 -0
- package/dist/shared/functionManager.js +322 -0
- package/dist/shared/indexManager.d.ts +24 -0
- package/dist/shared/indexManager.js +150 -0
- package/dist/shared/jsonSchemaGenerator.d.ts +51 -0
- package/dist/shared/jsonSchemaGenerator.js +313 -0
- package/dist/shared/logging.d.ts +10 -0
- package/dist/shared/logging.js +46 -0
- package/dist/shared/messageFormatter.d.ts +37 -0
- package/dist/shared/messageFormatter.js +152 -0
- package/dist/shared/migrationHelpers.d.ts +173 -0
- package/dist/shared/migrationHelpers.js +142 -0
- package/dist/shared/operationLogger.d.ts +3 -0
- package/dist/shared/operationLogger.js +25 -0
- package/dist/shared/operationQueue.d.ts +13 -0
- package/dist/shared/operationQueue.js +79 -0
- package/dist/shared/progressManager.d.ts +62 -0
- package/dist/shared/progressManager.js +215 -0
- package/dist/shared/schemaGenerator.d.ts +18 -0
- package/dist/shared/schemaGenerator.js +523 -0
- package/dist/storage/methods.d.ts +3 -1
- package/dist/storage/methods.js +144 -55
- package/dist/storage/schemas.d.ts +56 -16
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/users/methods.d.ts +16 -0
- package/dist/users/methods.js +276 -0
- package/dist/utils/configMigration.d.ts +1 -0
- package/dist/utils/configMigration.js +156 -0
- package/dist/utils/dataConverters.d.ts +46 -0
- package/dist/utils/dataConverters.js +139 -0
- package/dist/utils/loadConfigs.d.ts +15 -4
- package/dist/utils/loadConfigs.js +377 -51
- package/dist/utils/schemaStrings.js +2 -1
- package/dist/utils/setupFiles.d.ts +2 -1
- package/dist/utils/setupFiles.js +723 -28
- package/dist/utils/validationRules.d.ts +43 -0
- package/dist/utils/validationRules.js +42 -0
- package/dist/utils/yamlConverter.d.ts +48 -0
- package/dist/utils/yamlConverter.js +98 -0
- package/dist/utilsController.js +65 -43
- package/package.json +19 -15
- package/src/collections/attributes.ts +3 -2
- package/src/collections/methods.ts +85 -51
- package/src/config/yamlConfig.ts +488 -0
- package/src/{migrations/setupDatabase.ts → databases/setup.ts} +11 -5
- package/src/functions/methods.ts +8 -4
- package/src/functions/templates/count-docs-in-collection/package.json +25 -0
- package/src/functions/templates/count-docs-in-collection/tsconfig.json +28 -0
- package/src/functions/templates/typescript-node/package.json +24 -0
- package/src/functions/templates/typescript-node/tsconfig.json +28 -0
- package/src/functions/templates/uv/README.md +31 -0
- package/src/functions/templates/uv/pyproject.toml +29 -0
- package/src/interactiveCLI.ts +230 -63
- package/src/main.ts +111 -37
- package/src/migrations/afterImportActions.ts +2 -2
- package/src/migrations/appwriteToX.ts +17 -4
- package/src/migrations/dataLoader.ts +4 -4
- package/src/migrations/importController.ts +30 -22
- package/src/migrations/importDataActions.ts +2 -2
- package/src/migrations/relationships.ts +1 -1
- package/src/migrations/services/DataTransformationService.ts +196 -0
- package/src/migrations/services/FileHandlerService.ts +311 -0
- package/src/migrations/services/ImportOrchestrator.ts +669 -0
- package/src/migrations/services/RateLimitManager.ts +363 -0
- package/src/migrations/services/RelationshipResolver.ts +461 -0
- package/src/migrations/services/UserMappingService.ts +345 -0
- package/src/migrations/services/ValidationService.ts +349 -0
- package/src/migrations/transfer.ts +22 -228
- package/src/migrations/yaml/YamlImportConfigLoader.ts +427 -0
- package/src/migrations/yaml/YamlImportIntegration.ts +419 -0
- package/src/migrations/yaml/generateImportSchemas.ts +589 -0
- package/src/shared/attributeManager.ts +429 -0
- package/src/shared/confirmationDialogs.ts +327 -0
- package/src/shared/functionManager.ts +515 -0
- package/src/shared/indexManager.ts +253 -0
- package/src/shared/jsonSchemaGenerator.ts +403 -0
- package/src/shared/logging.ts +74 -0
- package/src/shared/messageFormatter.ts +195 -0
- package/src/{migrations/migrationHelper.ts → shared/migrationHelpers.ts} +22 -4
- package/src/{migrations/helper.ts → shared/operationLogger.ts} +7 -2
- package/src/{migrations/queue.ts → shared/operationQueue.ts} +1 -1
- package/src/shared/progressManager.ts +278 -0
- package/src/{migrations/schemaStrings.ts → shared/schemaGenerator.ts} +71 -17
- package/src/storage/methods.ts +199 -78
- package/src/types.ts +2 -2
- package/src/{migrations/users.ts → users/methods.ts} +2 -2
- package/src/utils/configMigration.ts +212 -0
- package/src/utils/loadConfigs.ts +414 -52
- package/src/utils/schemaStrings.ts +2 -1
- package/src/utils/setupFiles.ts +742 -40
- package/src/{migrations → utils}/validationRules.ts +1 -1
- package/src/utils/yamlConverter.ts +131 -0
- package/src/utilsController.ts +75 -54
- package/src/functions/templates/poetry/README.md +0 -30
- package/src/functions/templates/poetry/pyproject.toml +0 -16
- package/src/migrations/attributes.ts +0 -561
- package/src/migrations/backup.ts +0 -205
- package/src/migrations/databases.ts +0 -39
- package/src/migrations/dbHelpers.ts +0 -92
- package/src/migrations/indexes.ts +0 -40
- package/src/migrations/logging.ts +0 -29
- package/src/migrations/storage.ts +0 -538
- /package/src/{migrations → functions}/openapi.ts +0 -0
- /package/src/functions/templates/{poetry → uv}/src/__init__.py +0 -0
- /package/src/functions/templates/{poetry → uv}/src/index.py +0 -0
- /package/src/{migrations/converters.ts → utils/dataConverters.ts} +0 -0
@@ -0,0 +1,215 @@
|
|
1
|
+
import cliProgress from "cli-progress";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import { MessageFormatter } from "./messageFormatter.js";
|
4
|
+
export class ProgressManager {
|
5
|
+
static instances = new Map();
|
6
|
+
bar;
|
7
|
+
startTime;
|
8
|
+
totalItems;
|
9
|
+
completed = 0;
|
10
|
+
id;
|
11
|
+
title;
|
12
|
+
constructor(id, total, options = {}) {
|
13
|
+
this.id = id;
|
14
|
+
this.totalItems = total;
|
15
|
+
this.startTime = Date.now();
|
16
|
+
this.title = options.title || "Processing";
|
17
|
+
const format = options.format ||
|
18
|
+
`${chalk.cyan(this.title)} ${chalk.yellow("[{bar}]")} {percentage}% | {value}/{total} | ETA: {eta}s | Speed: {speed}/s`;
|
19
|
+
this.bar = new cliProgress.SingleBar({
|
20
|
+
format,
|
21
|
+
barCompleteChar: '█',
|
22
|
+
barIncompleteChar: '░',
|
23
|
+
hideCursor: true,
|
24
|
+
clearOnComplete: false,
|
25
|
+
stopOnComplete: true,
|
26
|
+
...options,
|
27
|
+
}, cliProgress.Presets.shades_classic);
|
28
|
+
this.bar.start(total, 0);
|
29
|
+
}
|
30
|
+
static create(id, total, options = {}) {
|
31
|
+
if (ProgressManager.instances.has(id)) {
|
32
|
+
const existing = ProgressManager.instances.get(id);
|
33
|
+
existing.stop();
|
34
|
+
}
|
35
|
+
const instance = new ProgressManager(id, total, options);
|
36
|
+
ProgressManager.instances.set(id, instance);
|
37
|
+
return instance;
|
38
|
+
}
|
39
|
+
static get(id) {
|
40
|
+
return ProgressManager.instances.get(id);
|
41
|
+
}
|
42
|
+
update(current, detail) {
|
43
|
+
this.completed = current;
|
44
|
+
// Calculate speed
|
45
|
+
const elapsed = (Date.now() - this.startTime) / 1000;
|
46
|
+
const speed = elapsed > 0 ? Math.round(current / elapsed) : 0;
|
47
|
+
this.bar.update(current, {
|
48
|
+
speed,
|
49
|
+
detail: detail || '',
|
50
|
+
});
|
51
|
+
if (detail) {
|
52
|
+
// Update the payload for custom formatting
|
53
|
+
this.bar.update(current, { detail });
|
54
|
+
}
|
55
|
+
}
|
56
|
+
increment(amount = 1, detail) {
|
57
|
+
this.update(this.completed + amount, detail);
|
58
|
+
}
|
59
|
+
setTotal(total) {
|
60
|
+
this.totalItems = total;
|
61
|
+
this.bar.setTotal(total);
|
62
|
+
}
|
63
|
+
stop(showSummary = true) {
|
64
|
+
this.bar.stop();
|
65
|
+
if (showSummary) {
|
66
|
+
const duration = Date.now() - this.startTime;
|
67
|
+
const rate = this.completed / (duration / 1000);
|
68
|
+
MessageFormatter.success(`${this.title} completed`, {
|
69
|
+
prefix: `${this.completed}/${this.totalItems} items in ${MessageFormatter.formatDuration(duration)} (${rate.toFixed(1)}/s)`
|
70
|
+
});
|
71
|
+
}
|
72
|
+
ProgressManager.instances.delete(this.id);
|
73
|
+
}
|
74
|
+
fail(error) {
|
75
|
+
this.bar.stop();
|
76
|
+
MessageFormatter.error(`${this.title} failed: ${error}`);
|
77
|
+
ProgressManager.instances.delete(this.id);
|
78
|
+
}
|
79
|
+
getStats() {
|
80
|
+
const duration = Date.now() - this.startTime;
|
81
|
+
const rate = this.completed / (duration / 1000);
|
82
|
+
return {
|
83
|
+
completed: this.completed,
|
84
|
+
total: this.totalItems,
|
85
|
+
percentage: (this.completed / this.totalItems) * 100,
|
86
|
+
duration,
|
87
|
+
rate,
|
88
|
+
remaining: this.totalItems - this.completed,
|
89
|
+
eta: this.completed > 0 ? ((this.totalItems - this.completed) / rate) * 1000 : 0,
|
90
|
+
};
|
91
|
+
}
|
92
|
+
static stopAll() {
|
93
|
+
for (const [id, instance] of ProgressManager.instances) {
|
94
|
+
instance.stop(false);
|
95
|
+
}
|
96
|
+
ProgressManager.instances.clear();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
export class MultiProgressManager {
|
100
|
+
multiBar;
|
101
|
+
bars = new Map();
|
102
|
+
startTime;
|
103
|
+
constructor(options = {}) {
|
104
|
+
this.startTime = Date.now();
|
105
|
+
this.multiBar = new cliProgress.MultiBar({
|
106
|
+
clearOnComplete: false,
|
107
|
+
hideCursor: true,
|
108
|
+
format: options.format || `${chalk.cyan("{title}")} ${chalk.yellow("[{bar}]")} {percentage}% | {value}/{total} | {detail}`,
|
109
|
+
barCompleteChar: '█',
|
110
|
+
barIncompleteChar: '░',
|
111
|
+
}, cliProgress.Presets.shades_classic);
|
112
|
+
}
|
113
|
+
addTask(id, total, title) {
|
114
|
+
const bar = this.multiBar.create(total, 0, {
|
115
|
+
title: title.padEnd(20),
|
116
|
+
detail: '',
|
117
|
+
});
|
118
|
+
this.bars.set(id, bar);
|
119
|
+
}
|
120
|
+
updateTask(id, current, detail) {
|
121
|
+
const bar = this.bars.get(id);
|
122
|
+
if (bar) {
|
123
|
+
bar.update(current, {
|
124
|
+
detail: detail || '',
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
incrementTask(id, amount = 1, detail) {
|
129
|
+
const bar = this.bars.get(id);
|
130
|
+
if (bar) {
|
131
|
+
const currentValue = bar.getProgress() * bar.getTotal();
|
132
|
+
this.updateTask(id, currentValue + amount, detail);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
completeTask(id) {
|
136
|
+
const bar = this.bars.get(id);
|
137
|
+
if (bar) {
|
138
|
+
bar.update(bar.getTotal());
|
139
|
+
}
|
140
|
+
}
|
141
|
+
failTask(id, error) {
|
142
|
+
const bar = this.bars.get(id);
|
143
|
+
if (bar) {
|
144
|
+
bar.update(bar.getProgress() * bar.getTotal(), {
|
145
|
+
detail: chalk.red(`Failed: ${error}`),
|
146
|
+
});
|
147
|
+
}
|
148
|
+
}
|
149
|
+
stop(showSummary = true) {
|
150
|
+
this.multiBar.stop();
|
151
|
+
if (showSummary) {
|
152
|
+
const duration = Date.now() - this.startTime;
|
153
|
+
MessageFormatter.success(`All tasks completed in ${MessageFormatter.formatDuration(duration)}`);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
getTaskStats(id) {
|
157
|
+
const bar = this.bars.get(id);
|
158
|
+
if (!bar)
|
159
|
+
return null;
|
160
|
+
const progress = bar.getProgress();
|
161
|
+
const total = bar.getTotal();
|
162
|
+
const completed = Math.floor(progress * total);
|
163
|
+
return {
|
164
|
+
completed,
|
165
|
+
total,
|
166
|
+
percentage: progress * 100,
|
167
|
+
remaining: total - completed,
|
168
|
+
};
|
169
|
+
}
|
170
|
+
getAllStats() {
|
171
|
+
const stats = new Map();
|
172
|
+
for (const [id, bar] of this.bars) {
|
173
|
+
stats.set(id, this.getTaskStats(id));
|
174
|
+
}
|
175
|
+
return stats;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
// Utility functions for common progress scenarios
|
179
|
+
export const ProgressUtils = {
|
180
|
+
async withProgress(id, total, title, operation) {
|
181
|
+
const progress = ProgressManager.create(id, total, { title });
|
182
|
+
try {
|
183
|
+
const result = await operation(progress);
|
184
|
+
progress.stop();
|
185
|
+
return result;
|
186
|
+
}
|
187
|
+
catch (error) {
|
188
|
+
progress.fail(error instanceof Error ? error.message : String(error));
|
189
|
+
throw error;
|
190
|
+
}
|
191
|
+
},
|
192
|
+
async processArrayWithProgress(items, processor, options = {}) {
|
193
|
+
const { title = "Processing items", batchSize = 1, showDetail = true } = options;
|
194
|
+
const progress = ProgressManager.create(`process-${Date.now()}`, items.length, { title });
|
195
|
+
const results = [];
|
196
|
+
try {
|
197
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
198
|
+
const batch = items.slice(i, i + batchSize);
|
199
|
+
const batchResults = await Promise.all(batch.map(async (item, batchIndex) => {
|
200
|
+
const result = await processor(item, i + batchIndex);
|
201
|
+
const detail = showDetail ? `Item ${i + batchIndex + 1}: ${String(item).slice(0, 30)}...` : undefined;
|
202
|
+
progress.update(i + batchIndex + 1, detail);
|
203
|
+
return result;
|
204
|
+
}));
|
205
|
+
results.push(...batchResults);
|
206
|
+
}
|
207
|
+
progress.stop();
|
208
|
+
return results;
|
209
|
+
}
|
210
|
+
catch (error) {
|
211
|
+
progress.fail(error instanceof Error ? error.message : String(error));
|
212
|
+
throw error;
|
213
|
+
}
|
214
|
+
},
|
215
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { AppwriteConfig, Attribute } from "appwrite-utils";
|
2
|
+
export declare class SchemaGenerator {
|
3
|
+
private relationshipMap;
|
4
|
+
private config;
|
5
|
+
private appwriteFolderPath;
|
6
|
+
constructor(config: AppwriteConfig, appwriteFolderPath: string);
|
7
|
+
updateYamlCollections(): void;
|
8
|
+
updateTsSchemas(): void;
|
9
|
+
updateConfig(config: AppwriteConfig): void;
|
10
|
+
private extractRelationships;
|
11
|
+
private addRelationship;
|
12
|
+
generateSchemas(options?: {
|
13
|
+
format?: "zod" | "json" | "both";
|
14
|
+
verbose?: boolean;
|
15
|
+
}): void;
|
16
|
+
createSchemaString: (name: string, attributes: Attribute[]) => string;
|
17
|
+
typeToZod: (attribute: Attribute) => string;
|
18
|
+
}
|