appwrite-utils-cli 1.2.18 → 1.2.20

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.
@@ -391,9 +391,8 @@ const transferDocumentWithRetry = async (db, dbId, collectionId, documentId, doc
391
391
  }
392
392
  catch (error) {
393
393
  // Check if document already exists
394
- if (error.code === 409 || error.message?.includes('already exists')) {
395
- console.log(chalk.yellow(`Document ${documentId} already exists, skipping...`));
396
- return true;
394
+ if (error.code === 409 || error.message?.toLowerCase().includes('already exists')) {
395
+ await db.updateDocument(dbId, collectionId, documentId, documentData, permissions);
397
396
  }
398
397
  if (retryCount < maxRetries) {
399
398
  // Calculate exponential backoff: 1s, 2s, 4s
@@ -1052,7 +1052,7 @@ export class ComprehensiveTransfer {
1052
1052
  const updateTasks = documentPairs.map(({ doc, targetDoc, reason }) => this.limit(async () => {
1053
1053
  try {
1054
1054
  const { $id, $createdAt, $updatedAt, $permissions, $databaseId, $collectionId, ...docData } = doc;
1055
- await tryAwaitWithRetry(async () => targetDb.updateDocument(targetDbId, targetCollectionId, doc.$id, docData, doc.$permissions));
1055
+ await tryAwaitWithRetry(async () => targetDb.updateDocument(targetDbId, targetCollectionId, doc.$id, docData, $permissions));
1056
1056
  successCount++;
1057
1057
  }
1058
1058
  catch (error) {
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": "1.2.18",
4
+ "version": "1.2.20",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -640,9 +640,14 @@ const transferDocumentWithRetry = async (
640
640
  return true;
641
641
  } catch (error: any) {
642
642
  // Check if document already exists
643
- if (error.code === 409 || error.message?.includes('already exists')) {
644
- console.log(chalk.yellow(`Document ${documentId} already exists, skipping...`));
645
- return true;
643
+ if (error.code === 409 || error.message?.toLowerCase().includes('already exists')) {
644
+ await db.updateDocument(
645
+ dbId,
646
+ collectionId,
647
+ documentId,
648
+ documentData,
649
+ permissions
650
+ );
646
651
  }
647
652
 
648
653
  if (retryCount < maxRetries) {
@@ -1898,7 +1898,7 @@ export class ComprehensiveTransfer {
1898
1898
  targetCollectionId,
1899
1899
  doc.$id,
1900
1900
  docData,
1901
- doc.$permissions
1901
+ $permissions,
1902
1902
  )
1903
1903
  );
1904
1904