appwrite-utils-cli 0.9.995 → 0.9.996
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/dist/utilsController.js +40 -23
- package/package.json +1 -1
- package/src/utilsController.ts +151 -63
package/dist/utilsController.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Client, Databases, Query, Storage } from "node-appwrite";
|
2
2
|
import {} from "appwrite-utils";
|
3
|
-
import { loadConfig, findAppwriteConfig, findFunctionsDir } from "./utils/loadConfigs.js";
|
3
|
+
import { loadConfig, findAppwriteConfig, findFunctionsDir, } from "./utils/loadConfigs.js";
|
4
4
|
import { UsersController } from "./migrations/users.js";
|
5
5
|
import { AppwriteToX } from "./migrations/appwriteToX.js";
|
6
6
|
import { ImportController } from "./migrations/importController.js";
|
@@ -14,7 +14,7 @@ import { afterImportActions } from "./migrations/afterImportActions.js";
|
|
14
14
|
import { transferDatabaseLocalToLocal, transferDatabaseLocalToRemote, transferStorageLocalToLocal, transferStorageLocalToRemote, } from "./migrations/transfer.js";
|
15
15
|
import { getClient } from "./utils/getClientFromConfig.js";
|
16
16
|
import { fetchAllDatabases } from "./migrations/databases.js";
|
17
|
-
import { listFunctions, updateFunctionSpecifications } from "./functions/methods.js";
|
17
|
+
import { listFunctions, updateFunctionSpecifications, } from "./functions/methods.js";
|
18
18
|
import chalk from "chalk";
|
19
19
|
import { deployLocalFunction } from "./functions/deployments.js";
|
20
20
|
import fs from "node:fs";
|
@@ -131,7 +131,9 @@ export class UtilsController {
|
|
131
131
|
await this.init();
|
132
132
|
if (!this.appwriteServer)
|
133
133
|
throw new Error("Appwrite server not initialized");
|
134
|
-
const { functions } = await listFunctions(this.appwriteServer, [
|
134
|
+
const { functions } = await listFunctions(this.appwriteServer, [
|
135
|
+
Query.limit(1000),
|
136
|
+
]);
|
135
137
|
return functions;
|
136
138
|
}
|
137
139
|
async findFunctionDirectories() {
|
@@ -145,7 +147,7 @@ export class UtilsController {
|
|
145
147
|
const functionPath = path.join(functionsDir, entry.name);
|
146
148
|
// Match with config functions by name
|
147
149
|
if (this.config?.functions) {
|
148
|
-
const matchingFunc = this.config.functions.find(f => f.name.toLowerCase() === entry.name.toLowerCase());
|
150
|
+
const matchingFunc = this.config.functions.find((f) => f.name.toLowerCase() === entry.name.toLowerCase());
|
149
151
|
if (matchingFunc) {
|
150
152
|
functionDirMap.set(matchingFunc.name, functionPath);
|
151
153
|
}
|
@@ -159,7 +161,7 @@ export class UtilsController {
|
|
159
161
|
if (!this.appwriteServer)
|
160
162
|
throw new Error("Appwrite server not initialized");
|
161
163
|
if (!functionConfig) {
|
162
|
-
functionConfig = this.config?.functions?.find(f => f.name === functionName);
|
164
|
+
functionConfig = this.config?.functions?.find((f) => f.name === functionName);
|
163
165
|
}
|
164
166
|
if (!functionConfig)
|
165
167
|
throw new Error(`Function ${functionName} not found in config`);
|
@@ -170,7 +172,9 @@ export class UtilsController {
|
|
170
172
|
if (!this.appwriteServer)
|
171
173
|
throw new Error("Appwrite server not initialized");
|
172
174
|
const localFunctions = this.config?.functions || [];
|
173
|
-
const remoteFunctions = await listFunctions(this.appwriteServer, [
|
175
|
+
const remoteFunctions = await listFunctions(this.appwriteServer, [
|
176
|
+
Query.limit(1000),
|
177
|
+
]);
|
174
178
|
for (const localFunction of localFunctions) {
|
175
179
|
console.log(chalk.blue(`Syncing function ${localFunction.name}...`));
|
176
180
|
await this.deployFunction(localFunction.name);
|
@@ -188,19 +192,22 @@ export class UtilsController {
|
|
188
192
|
}
|
189
193
|
async wipeBucketFromDatabase(database) {
|
190
194
|
// Check configured bucket in database config
|
191
|
-
const configuredBucket = this.config?.databases?.find(db => db.$id === database.$id)?.bucket;
|
195
|
+
const configuredBucket = this.config?.databases?.find((db) => db.$id === database.$id)?.bucket;
|
192
196
|
if (configuredBucket?.$id) {
|
193
197
|
await this.wipeDocumentStorage(configuredBucket.$id);
|
194
198
|
}
|
195
199
|
// Also check for document bucket ID pattern
|
196
200
|
if (this.config?.documentBucketId) {
|
197
|
-
const documentBucketId = `${this.config.documentBucketId}_${database.$id
|
201
|
+
const documentBucketId = `${this.config.documentBucketId}_${database.$id
|
202
|
+
.toLowerCase()
|
203
|
+
.trim()
|
204
|
+
.replace(/\s+/g, "")}`;
|
198
205
|
try {
|
199
206
|
await this.wipeDocumentStorage(documentBucketId);
|
200
207
|
}
|
201
208
|
catch (error) {
|
202
209
|
// Ignore if bucket doesn't exist
|
203
|
-
if (error?.type !==
|
210
|
+
if (error?.type !== "storage_bucket_not_found") {
|
204
211
|
throw error;
|
205
212
|
}
|
206
213
|
}
|
@@ -278,11 +285,13 @@ export class UtilsController {
|
|
278
285
|
return this.appwriteFolderPath;
|
279
286
|
}
|
280
287
|
async transferData(options) {
|
281
|
-
// Remove database requirement check
|
282
288
|
let sourceClient = this.database;
|
283
289
|
let targetClient;
|
284
290
|
let sourceDatabases = [];
|
285
291
|
let targetDatabases = [];
|
292
|
+
if (!sourceClient) {
|
293
|
+
throw new Error("Source database not initialized");
|
294
|
+
}
|
286
295
|
if (options.isRemote) {
|
287
296
|
if (!options.transferEndpoint ||
|
288
297
|
!options.transferProject ||
|
@@ -290,39 +299,47 @@ export class UtilsController {
|
|
290
299
|
throw new Error("Remote transfer options are missing");
|
291
300
|
}
|
292
301
|
const remoteClient = getClient(options.transferEndpoint, options.transferProject, options.transferKey);
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
targetDatabases = await fetchAllDatabases(targetClient);
|
297
|
-
}
|
302
|
+
targetClient = new Databases(remoteClient);
|
303
|
+
sourceDatabases = await fetchAllDatabases(sourceClient);
|
304
|
+
targetDatabases = await fetchAllDatabases(targetClient);
|
298
305
|
}
|
299
|
-
else
|
306
|
+
else {
|
300
307
|
targetClient = sourceClient;
|
301
308
|
sourceDatabases = targetDatabases = await fetchAllDatabases(sourceClient);
|
302
309
|
}
|
303
|
-
//
|
310
|
+
// Always perform database transfer if databases are specified
|
304
311
|
if (options.fromDb && options.targetDb) {
|
305
312
|
const fromDb = sourceDatabases.find((db) => db.$id === options.fromDb.$id);
|
306
313
|
const targetDb = targetDatabases.find((db) => db.$id === options.targetDb.$id);
|
307
314
|
if (!fromDb || !targetDb) {
|
308
315
|
throw new Error("Source or target database not found");
|
309
316
|
}
|
317
|
+
console.log(chalk.blue(`Starting database transfer from ${fromDb.$id} to ${targetDb.$id}`));
|
310
318
|
if (options.isRemote && targetClient) {
|
311
319
|
await transferDatabaseLocalToRemote(sourceClient, options.transferEndpoint, options.transferProject, options.transferKey, fromDb.$id, targetDb.$id);
|
312
320
|
}
|
313
|
-
else
|
321
|
+
else {
|
314
322
|
await transferDatabaseLocalToLocal(sourceClient, fromDb.$id, targetDb.$id);
|
315
323
|
}
|
316
324
|
}
|
317
|
-
// Handle storage transfer
|
325
|
+
// Handle storage transfer
|
318
326
|
if (this.storage && (options.sourceBucket || options.fromDb)) {
|
319
327
|
const sourceBucketId = options.sourceBucket?.$id ||
|
320
|
-
(options.fromDb &&
|
321
|
-
|
328
|
+
(options.fromDb &&
|
329
|
+
this.config?.documentBucketId &&
|
330
|
+
`${this.config.documentBucketId}_${options.fromDb.$id
|
331
|
+
.toLowerCase()
|
332
|
+
.trim()
|
333
|
+
.replace(/\s+/g, "")}`);
|
322
334
|
const targetBucketId = options.targetBucket?.$id ||
|
323
|
-
(options.targetDb &&
|
324
|
-
|
335
|
+
(options.targetDb &&
|
336
|
+
this.config?.documentBucketId &&
|
337
|
+
`${this.config.documentBucketId}_${options.targetDb.$id
|
338
|
+
.toLowerCase()
|
339
|
+
.trim()
|
340
|
+
.replace(/\s+/g, "")}`);
|
325
341
|
if (sourceBucketId && targetBucketId) {
|
342
|
+
console.log(chalk.blue(`Starting storage transfer from ${sourceBucketId} to ${targetBucketId}`));
|
326
343
|
if (options.isRemote) {
|
327
344
|
await transferStorageLocalToRemote(this.storage, options.transferEndpoint, options.transferProject, options.transferKey, sourceBucketId, targetBucketId);
|
328
345
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "appwrite-utils-cli",
|
3
3
|
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
4
|
-
"version": "0.9.
|
4
|
+
"version": "0.9.996",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/utilsController.ts
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
import { Client, Databases, Query, Storage, type Models } from "node-appwrite";
|
2
|
-
import {
|
3
|
-
|
2
|
+
import {
|
3
|
+
type AppwriteConfig,
|
4
|
+
type AppwriteFunction,
|
5
|
+
type Specification,
|
6
|
+
} from "appwrite-utils";
|
7
|
+
import {
|
8
|
+
loadConfig,
|
9
|
+
findAppwriteConfig,
|
10
|
+
findFunctionsDir,
|
11
|
+
} from "./utils/loadConfigs.js";
|
4
12
|
import { UsersController } from "./migrations/users.js";
|
5
13
|
import { AppwriteToX } from "./migrations/appwriteToX.js";
|
6
14
|
import { ImportController } from "./migrations/importController.js";
|
@@ -42,7 +50,10 @@ import {
|
|
42
50
|
} from "./migrations/transfer.js";
|
43
51
|
import { getClient } from "./utils/getClientFromConfig.js";
|
44
52
|
import { fetchAllDatabases } from "./migrations/databases.js";
|
45
|
-
import {
|
53
|
+
import {
|
54
|
+
listFunctions,
|
55
|
+
updateFunctionSpecifications,
|
56
|
+
} from "./functions/methods.js";
|
46
57
|
import chalk from "chalk";
|
47
58
|
import { deployLocalFunction } from "./functions/deployments.js";
|
48
59
|
import fs from "node:fs";
|
@@ -106,13 +117,13 @@ export class UtilsController {
|
|
106
117
|
async reloadConfig() {
|
107
118
|
this.config = await loadConfig(this.appwriteFolderPath);
|
108
119
|
this.appwriteServer = new Client();
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
120
|
+
this.appwriteServer
|
121
|
+
.setEndpoint(this.config.appwriteEndpoint)
|
122
|
+
.setProject(this.config.appwriteProject)
|
123
|
+
.setKey(this.config.appwriteKey);
|
124
|
+
this.database = new Databases(this.appwriteServer);
|
125
|
+
this.storage = new Storage(this.appwriteServer);
|
126
|
+
this.config.appwriteClient = this.appwriteServer;
|
116
127
|
}
|
117
128
|
|
118
129
|
async setupMigrationDatabase() {
|
@@ -139,8 +150,11 @@ export class UtilsController {
|
|
139
150
|
await this.ensureDatabaseConfigBucketsExist(databases);
|
140
151
|
await ensureDatabasesExist(this.config, databases);
|
141
152
|
}
|
142
|
-
|
143
|
-
async ensureCollectionsExist(
|
153
|
+
|
154
|
+
async ensureCollectionsExist(
|
155
|
+
database: Models.Database,
|
156
|
+
collections?: Models.Collection[]
|
157
|
+
) {
|
144
158
|
await this.init();
|
145
159
|
if (!this.config) throw new Error("Config not initialized");
|
146
160
|
await ensureCollectionsExist(this.config, database, collections);
|
@@ -185,25 +199,28 @@ export class UtilsController {
|
|
185
199
|
|
186
200
|
async listAllFunctions() {
|
187
201
|
await this.init();
|
188
|
-
if (!this.appwriteServer)
|
189
|
-
|
202
|
+
if (!this.appwriteServer)
|
203
|
+
throw new Error("Appwrite server not initialized");
|
204
|
+
const { functions } = await listFunctions(this.appwriteServer, [
|
205
|
+
Query.limit(1000),
|
206
|
+
]);
|
190
207
|
return functions;
|
191
208
|
}
|
192
209
|
|
193
210
|
async findFunctionDirectories() {
|
194
211
|
const functionsDir = findFunctionsDir(this.appwriteFolderPath);
|
195
212
|
if (!functionsDir) return new Map();
|
196
|
-
|
213
|
+
|
197
214
|
const functionDirMap = new Map<string, string>();
|
198
215
|
const entries = fs.readdirSync(functionsDir, { withFileTypes: true });
|
199
|
-
|
216
|
+
|
200
217
|
for (const entry of entries) {
|
201
218
|
if (entry.isDirectory()) {
|
202
219
|
const functionPath = path.join(functionsDir, entry.name);
|
203
220
|
// Match with config functions by name
|
204
221
|
if (this.config?.functions) {
|
205
222
|
const matchingFunc = this.config.functions.find(
|
206
|
-
f => f.name.toLowerCase() === entry.name.toLowerCase()
|
223
|
+
(f) => f.name.toLowerCase() === entry.name.toLowerCase()
|
207
224
|
);
|
208
225
|
if (matchingFunc) {
|
209
226
|
functionDirMap.set(matchingFunc.name, functionPath);
|
@@ -214,30 +231,46 @@ export class UtilsController {
|
|
214
231
|
return functionDirMap;
|
215
232
|
}
|
216
233
|
|
217
|
-
async deployFunction(
|
234
|
+
async deployFunction(
|
235
|
+
functionName: string,
|
236
|
+
functionPath?: string,
|
237
|
+
functionConfig?: AppwriteFunction
|
238
|
+
) {
|
218
239
|
await this.init();
|
219
|
-
if (!this.appwriteServer)
|
220
|
-
|
240
|
+
if (!this.appwriteServer)
|
241
|
+
throw new Error("Appwrite server not initialized");
|
242
|
+
|
221
243
|
if (!functionConfig) {
|
222
|
-
functionConfig = this.config?.functions?.find(
|
244
|
+
functionConfig = this.config?.functions?.find(
|
245
|
+
(f) => f.name === functionName
|
246
|
+
);
|
223
247
|
}
|
224
|
-
if (!functionConfig)
|
225
|
-
|
226
|
-
|
248
|
+
if (!functionConfig)
|
249
|
+
throw new Error(`Function ${functionName} not found in config`);
|
250
|
+
|
251
|
+
await deployLocalFunction(
|
252
|
+
this.appwriteServer,
|
253
|
+
functionName,
|
254
|
+
functionConfig,
|
255
|
+
functionPath
|
256
|
+
);
|
227
257
|
}
|
228
|
-
|
258
|
+
|
229
259
|
async syncFunctions() {
|
230
260
|
await this.init();
|
231
|
-
if (!this.appwriteServer)
|
232
|
-
|
261
|
+
if (!this.appwriteServer)
|
262
|
+
throw new Error("Appwrite server not initialized");
|
263
|
+
|
233
264
|
const localFunctions = this.config?.functions || [];
|
234
|
-
const remoteFunctions = await listFunctions(this.appwriteServer, [
|
235
|
-
|
265
|
+
const remoteFunctions = await listFunctions(this.appwriteServer, [
|
266
|
+
Query.limit(1000),
|
267
|
+
]);
|
268
|
+
|
236
269
|
for (const localFunction of localFunctions) {
|
237
270
|
console.log(chalk.blue(`Syncing function ${localFunction.name}...`));
|
238
271
|
await this.deployFunction(localFunction.name);
|
239
272
|
}
|
240
|
-
|
273
|
+
|
241
274
|
console.log(chalk.green("✨ All functions synchronized successfully!"));
|
242
275
|
}
|
243
276
|
|
@@ -252,26 +285,34 @@ export class UtilsController {
|
|
252
285
|
|
253
286
|
async wipeBucketFromDatabase(database: Models.Database) {
|
254
287
|
// Check configured bucket in database config
|
255
|
-
const configuredBucket = this.config?.databases?.find(
|
288
|
+
const configuredBucket = this.config?.databases?.find(
|
289
|
+
(db) => db.$id === database.$id
|
290
|
+
)?.bucket;
|
256
291
|
if (configuredBucket?.$id) {
|
257
292
|
await this.wipeDocumentStorage(configuredBucket.$id);
|
258
293
|
}
|
259
294
|
|
260
295
|
// Also check for document bucket ID pattern
|
261
296
|
if (this.config?.documentBucketId) {
|
262
|
-
const documentBucketId = `${this.config.documentBucketId}_${database.$id
|
297
|
+
const documentBucketId = `${this.config.documentBucketId}_${database.$id
|
298
|
+
.toLowerCase()
|
299
|
+
.trim()
|
300
|
+
.replace(/\s+/g, "")}`;
|
263
301
|
try {
|
264
302
|
await this.wipeDocumentStorage(documentBucketId);
|
265
303
|
} catch (error: any) {
|
266
304
|
// Ignore if bucket doesn't exist
|
267
|
-
if (error?.type !==
|
305
|
+
if (error?.type !== "storage_bucket_not_found") {
|
268
306
|
throw error;
|
269
307
|
}
|
270
308
|
}
|
271
309
|
}
|
272
310
|
}
|
273
311
|
|
274
|
-
async wipeCollection(
|
312
|
+
async wipeCollection(
|
313
|
+
database: Models.Database,
|
314
|
+
collection: Models.Collection
|
315
|
+
) {
|
275
316
|
await this.init();
|
276
317
|
if (!this.database) throw new Error("Database not initialized");
|
277
318
|
await wipeCollection(this.database, database.$id, collection.$id);
|
@@ -283,7 +324,10 @@ export class UtilsController {
|
|
283
324
|
await wipeDocumentStorage(this.storage, bucketId);
|
284
325
|
}
|
285
326
|
|
286
|
-
async createOrUpdateCollectionsForDatabases(
|
327
|
+
async createOrUpdateCollectionsForDatabases(
|
328
|
+
databases: Models.Database[],
|
329
|
+
collections: Models.Collection[] = []
|
330
|
+
) {
|
287
331
|
await this.init();
|
288
332
|
if (!this.database || !this.config)
|
289
333
|
throw new Error("Database or config not initialized");
|
@@ -359,7 +403,10 @@ export class UtilsController {
|
|
359
403
|
await appwriteToX.toSchemas(databases);
|
360
404
|
}
|
361
405
|
|
362
|
-
async syncDb(
|
406
|
+
async syncDb(
|
407
|
+
databases: Models.Database[] = [],
|
408
|
+
collections: Models.Collection[] = []
|
409
|
+
) {
|
363
410
|
await this.init();
|
364
411
|
if (!this.database) throw new Error("Database not initialized");
|
365
412
|
if (databases.length === 0) {
|
@@ -376,12 +423,15 @@ export class UtilsController {
|
|
376
423
|
}
|
377
424
|
|
378
425
|
async transferData(options: TransferOptions): Promise<void> {
|
379
|
-
// Remove database requirement check
|
380
426
|
let sourceClient = this.database;
|
381
427
|
let targetClient: Databases | undefined;
|
382
428
|
let sourceDatabases: Models.Database[] = [];
|
383
429
|
let targetDatabases: Models.Database[] = [];
|
384
430
|
|
431
|
+
if (!sourceClient) {
|
432
|
+
throw new Error("Source database not initialized");
|
433
|
+
}
|
434
|
+
|
385
435
|
if (options.isRemote) {
|
386
436
|
if (
|
387
437
|
!options.transferEndpoint ||
|
@@ -396,20 +446,20 @@ export class UtilsController {
|
|
396
446
|
options.transferProject,
|
397
447
|
options.transferKey
|
398
448
|
);
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
}
|
405
|
-
} else if (this.database) {
|
449
|
+
|
450
|
+
targetClient = new Databases(remoteClient);
|
451
|
+
sourceDatabases = await fetchAllDatabases(sourceClient);
|
452
|
+
targetDatabases = await fetchAllDatabases(targetClient);
|
453
|
+
} else {
|
406
454
|
targetClient = sourceClient;
|
407
|
-
sourceDatabases = targetDatabases = await fetchAllDatabases(sourceClient
|
455
|
+
sourceDatabases = targetDatabases = await fetchAllDatabases(sourceClient);
|
408
456
|
}
|
409
457
|
|
410
|
-
//
|
458
|
+
// Always perform database transfer if databases are specified
|
411
459
|
if (options.fromDb && options.targetDb) {
|
412
|
-
const fromDb = sourceDatabases.find(
|
460
|
+
const fromDb = sourceDatabases.find(
|
461
|
+
(db) => db.$id === options.fromDb!.$id
|
462
|
+
);
|
413
463
|
const targetDb = targetDatabases.find(
|
414
464
|
(db) => db.$id === options.targetDb!.$id
|
415
465
|
);
|
@@ -418,35 +468,57 @@ export class UtilsController {
|
|
418
468
|
throw new Error("Source or target database not found");
|
419
469
|
}
|
420
470
|
|
471
|
+
console.log(
|
472
|
+
chalk.blue(
|
473
|
+
`Starting database transfer from ${fromDb.$id} to ${targetDb.$id}`
|
474
|
+
)
|
475
|
+
);
|
476
|
+
|
421
477
|
if (options.isRemote && targetClient) {
|
422
478
|
await transferDatabaseLocalToRemote(
|
423
|
-
sourceClient
|
479
|
+
sourceClient,
|
424
480
|
options.transferEndpoint!,
|
425
481
|
options.transferProject!,
|
426
482
|
options.transferKey!,
|
427
483
|
fromDb.$id,
|
428
484
|
targetDb.$id
|
429
485
|
);
|
430
|
-
} else
|
486
|
+
} else {
|
431
487
|
await transferDatabaseLocalToLocal(
|
432
|
-
sourceClient
|
488
|
+
sourceClient,
|
433
489
|
fromDb.$id,
|
434
490
|
targetDb.$id
|
435
491
|
);
|
436
492
|
}
|
437
493
|
}
|
438
494
|
|
439
|
-
// Handle storage transfer
|
495
|
+
// Handle storage transfer
|
440
496
|
if (this.storage && (options.sourceBucket || options.fromDb)) {
|
441
|
-
const sourceBucketId =
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
497
|
+
const sourceBucketId =
|
498
|
+
options.sourceBucket?.$id ||
|
499
|
+
(options.fromDb &&
|
500
|
+
this.config?.documentBucketId &&
|
501
|
+
`${this.config.documentBucketId}_${options.fromDb.$id
|
502
|
+
.toLowerCase()
|
503
|
+
.trim()
|
504
|
+
.replace(/\s+/g, "")}`);
|
505
|
+
|
506
|
+
const targetBucketId =
|
507
|
+
options.targetBucket?.$id ||
|
508
|
+
(options.targetDb &&
|
509
|
+
this.config?.documentBucketId &&
|
510
|
+
`${this.config.documentBucketId}_${options.targetDb.$id
|
511
|
+
.toLowerCase()
|
512
|
+
.trim()
|
513
|
+
.replace(/\s+/g, "")}`);
|
448
514
|
|
449
515
|
if (sourceBucketId && targetBucketId) {
|
516
|
+
console.log(
|
517
|
+
chalk.blue(
|
518
|
+
`Starting storage transfer from ${sourceBucketId} to ${targetBucketId}`
|
519
|
+
)
|
520
|
+
);
|
521
|
+
|
450
522
|
if (options.isRemote) {
|
451
523
|
await transferStorageLocalToRemote(
|
452
524
|
this.storage,
|
@@ -469,11 +541,27 @@ export class UtilsController {
|
|
469
541
|
console.log(chalk.green("Transfer completed"));
|
470
542
|
}
|
471
543
|
|
472
|
-
async updateFunctionSpecifications(
|
544
|
+
async updateFunctionSpecifications(
|
545
|
+
functionId: string,
|
546
|
+
specification: Specification
|
547
|
+
) {
|
473
548
|
await this.init();
|
474
|
-
if (!this.appwriteServer)
|
475
|
-
|
476
|
-
|
477
|
-
|
549
|
+
if (!this.appwriteServer)
|
550
|
+
throw new Error("Appwrite server not initialized");
|
551
|
+
console.log(
|
552
|
+
chalk.green(
|
553
|
+
`Updating function specifications for ${functionId} to ${specification}`
|
554
|
+
)
|
555
|
+
);
|
556
|
+
await updateFunctionSpecifications(
|
557
|
+
this.appwriteServer,
|
558
|
+
functionId,
|
559
|
+
specification
|
560
|
+
);
|
561
|
+
console.log(
|
562
|
+
chalk.green(
|
563
|
+
`Successfully updated function specifications for ${functionId} to ${specification}`
|
564
|
+
)
|
565
|
+
);
|
478
566
|
}
|
479
567
|
}
|