appwrite-utils-cli 0.9.52 → 0.9.54

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/README.md CHANGED
@@ -124,6 +124,8 @@ This updated CLI ensures that developers have robust tools at their fingertips t
124
124
 
125
125
  ## Changelog
126
126
 
127
+ - 0.9.53: Added small delay (`100ms`) between collection deletions, reduced other delays from `1000` to `500/250ms`
128
+ - 0.9.53: Reduced delay, went too far
127
129
  - 0.9.52: Add delay after creating indexes, attributes, and others to prevent `fetch failed` errors during large-scale collection creation
128
130
  - 0.9.51: Fix transfer databases, remove "ensure duplicates" check
129
131
  - 0.9.5: Fixed not checking for storage bucket for each database (checking the creation status) when importing data
@@ -218,7 +218,7 @@ export const createUpdateCollectionAttributes = async (db, dbId, collection, att
218
218
  }
219
219
  });
220
220
  // Add delay after each batch
221
- await delay(2000);
221
+ await delay(500);
222
222
  }
223
223
  console.log(`Finished creating/updating attributes for collection: ${collection.name}`);
224
224
  };
@@ -24,6 +24,6 @@ export const createOrUpdateIndexes = async (dbId, db, collectionId, indexes) =>
24
24
  for (const index of indexes) {
25
25
  await tryAwaitWithRetry(async () => await createOrUpdateIndex(dbId, db, collectionId, index));
26
26
  // Add delay after each index creation/update
27
- await delay(1000);
27
+ await delay(500);
28
28
  }
29
29
  };
@@ -97,6 +97,7 @@ export const wipeDatabase = async (database, databaseId) => {
97
97
  collectionName: name,
98
98
  });
99
99
  tryAwaitWithRetry(async () => await database.deleteCollection(databaseId, collectionId)); // Try to delete the collection and ignore errors if it doesn't exist or if it's already being deleted
100
+ await delay(100);
100
101
  }
101
102
  return collectionsDeleted;
102
103
  };
@@ -174,16 +175,16 @@ export const createOrUpdateCollections = async (database, databaseId, config, de
174
175
  await tryAwaitWithRetry(async () => await database.updateCollection(databaseId, collectionToUse.$id, collection.name, permissions, collection.documentSecurity ?? false, collection.enabled ?? true));
175
176
  }
176
177
  // Add delay after creating/updating collection
177
- await delay(1000);
178
+ await delay(250);
178
179
  // Update attributes and indexes for the collection
179
180
  console.log("Creating Attributes");
180
181
  await createUpdateCollectionAttributes(database, databaseId, collectionToUse, attributes);
181
182
  // Add delay after creating attributes
182
- await delay(1000);
183
+ await delay(250);
183
184
  console.log("Creating Indexes");
184
185
  await createOrUpdateIndexes(databaseId, database, collectionToUse.$id, indexes ?? []);
185
186
  // Add delay after creating indexes
186
- await delay(1000);
187
+ await delay(250);
187
188
  }
188
189
  // Process any remaining tasks in the queue
189
190
  await processQueue(database, databaseId);
@@ -1,5 +1,5 @@
1
1
  import { Databases, Query } from "node-appwrite";
2
- import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
2
+ import { delay, tryAwaitWithRetry } from "../utils/helperFunctions.js";
3
3
  import { fetchAllCollections } from "../collections/methods.js";
4
4
  export const fetchAllDatabases = async (database) => {
5
5
  const databases = await tryAwaitWithRetry(async () => await database.list([Query.limit(25)]));
@@ -28,6 +28,7 @@ export const wipeDatabase = async (database, databaseId) => {
28
28
  console.log(`Deleting collection: ${collectionId}`);
29
29
  collectionsDeleted.push({ collectionId, collectionName: name });
30
30
  await tryAwaitWithRetry(async () => await database.deleteCollection(databaseId, collectionId));
31
+ await delay(100);
31
32
  }
32
33
  return collectionsDeleted;
33
34
  };
@@ -1,7 +1,7 @@
1
1
  import { Databases, Query } from "node-appwrite";
2
2
  import { createOrUpdateAttribute } from "./attributes.js";
3
3
  import { getMigrationCollectionSchemas } from "./backup.js";
4
- import { areCollectionNamesSame, toCamelCase, tryAwaitWithRetry, } from "../utils/index.js";
4
+ import { areCollectionNamesSame, delay, toCamelCase, tryAwaitWithRetry, } from "../utils/index.js";
5
5
  import {} from "appwrite-utils";
6
6
  import { ulid } from "ulidx";
7
7
  export const setupMigrationDatabase = async (config) => {
@@ -48,6 +48,7 @@ export const setupMigrationDatabase = async (config) => {
48
48
  for (const attribute of attributes) {
49
49
  try {
50
50
  await createOrUpdateAttribute(database, db.$id, collectionFound, attribute);
51
+ await delay(100);
51
52
  console.log(`Attribute created/updated: ${attribute.key}`);
52
53
  }
53
54
  catch (attrError) {
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.52",
4
+ "version": "0.9.54",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -476,7 +476,7 @@ export const createUpdateCollectionAttributes = async (
476
476
  });
477
477
 
478
478
  // Add delay after each batch
479
- await delay(2000);
479
+ await delay(500);
480
480
  }
481
481
  console.log(
482
482
  `Finished creating/updating attributes for collection: ${collection.name}`
@@ -50,6 +50,6 @@ export const createOrUpdateIndexes = async (
50
50
  async () => await createOrUpdateIndex(dbId, db, collectionId, index)
51
51
  );
52
52
  // Add delay after each index creation/update
53
- await delay(1000);
53
+ await delay(500);
54
54
  }
55
55
  };
@@ -141,6 +141,7 @@ export const wipeDatabase = async (
141
141
  tryAwaitWithRetry(
142
142
  async () => await database.deleteCollection(databaseId, collectionId)
143
143
  ); // Try to delete the collection and ignore errors if it doesn't exist or if it's already being deleted
144
+ await delay(100);
144
145
  }
145
146
  return collectionsDeleted;
146
147
  };
@@ -261,7 +262,7 @@ export const createOrUpdateCollections = async (
261
262
  }
262
263
 
263
264
  // Add delay after creating/updating collection
264
- await delay(1000);
265
+ await delay(250);
265
266
 
266
267
  // Update attributes and indexes for the collection
267
268
  console.log("Creating Attributes");
@@ -273,7 +274,7 @@ export const createOrUpdateCollections = async (
273
274
  );
274
275
 
275
276
  // Add delay after creating attributes
276
- await delay(1000);
277
+ await delay(250);
277
278
 
278
279
  console.log("Creating Indexes");
279
280
  await createOrUpdateIndexes(
@@ -284,7 +285,7 @@ export const createOrUpdateCollections = async (
284
285
  );
285
286
 
286
287
  // Add delay after creating indexes
287
- await delay(1000);
288
+ await delay(250);
288
289
  }
289
290
  // Process any remaining tasks in the queue
290
291
  await processQueue(database, databaseId);
@@ -1,5 +1,5 @@
1
1
  import { Databases, Query, type Models } from "node-appwrite";
2
- import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
2
+ import { delay, tryAwaitWithRetry } from "../utils/helperFunctions.js";
3
3
  import { fetchAllCollections } from "../collections/methods.js";
4
4
 
5
5
  export const fetchAllDatabases = async (
@@ -41,6 +41,7 @@ export const wipeDatabase = async (
41
41
  await tryAwaitWithRetry(
42
42
  async () => await database.deleteCollection(databaseId, collectionId)
43
43
  );
44
+ await delay(100);
44
45
  }
45
46
 
46
47
  return collectionsDeleted;
@@ -3,6 +3,7 @@ import { createOrUpdateAttribute } from "./attributes.js";
3
3
  import { getMigrationCollectionSchemas } from "./backup.js";
4
4
  import {
5
5
  areCollectionNamesSame,
6
+ delay,
6
7
  toCamelCase,
7
8
  tryAwaitWithRetry,
8
9
  } from "../utils/index.js";
@@ -87,6 +88,7 @@ export const setupMigrationDatabase = async (config: AppwriteConfig) => {
87
88
  collectionFound,
88
89
  attribute
89
90
  );
91
+ await delay(100);
90
92
  console.log(`Attribute created/updated: ${attribute.key}`);
91
93
  } catch (attrError) {
92
94
  console.error(