appwrite-utils-cli 0.0.6 → 0.0.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.
@@ -165,6 +165,7 @@ export class ImportController {
165
165
  });
166
166
  if (!userToCreate.success) {
167
167
  console.error(userToCreate.error);
168
+ logger.error(userToCreate.error);
168
169
  return;
169
170
  }
170
171
  const user = await usersController.createUserAndReturn(userToCreate.data);
@@ -187,7 +188,7 @@ export class ImportController {
187
188
  console.log(`Set createIdToUse to ${createIdToUse}. Deleted keys: ${deletedKeys.join(", ")}.`);
188
189
  }
189
190
  else if (isMembersCollection) {
190
- console.log(`Skipping user & contact creation for ${item} due to lack of email...`);
191
+ logger.error(`Skipping user & contact creation for ${item} due to lack of email...`);
191
192
  }
192
193
  context = { ...context, ...finalItem };
193
194
  if (!(await this.importDataActions.validateItem(finalItem, importDef.attributeMappings, context))) {
@@ -201,12 +202,14 @@ export class ImportController {
201
202
  if (createdContext) {
202
203
  afterContext = createdContext;
203
204
  }
205
+ logger.info(`Handled create for ${context.docId}}`);
204
206
  }
205
207
  else {
206
208
  const updatedContext = await this.handleUpdate(context, finalItem, importDef);
207
209
  if (updatedContext) {
208
210
  afterContext = updatedContext;
209
211
  }
212
+ logger.info(`Handled update for ${context.docId}`);
210
213
  }
211
214
  if (afterContext) {
212
215
  context = { ...context, ...afterContext };
@@ -1,4 +1,4 @@
1
- import { Storage, Databases, Query, InputFile, ID, } from "node-appwrite";
1
+ import { Storage, Databases, Query, InputFile, ID, Permission, } from "node-appwrite";
2
2
  import {} from "./backup.js";
3
3
  import { splitIntoBatches } from "./migrationHelper.js";
4
4
  export const logOperation = async (db, dbId, operationDetails, operationId) => {
@@ -39,7 +39,12 @@ export const initOrGetDocumentStorage = async (storage, config, dbName) => {
39
39
  catch (e) {
40
40
  // ID documentStorage
41
41
  // Name Document Storage
42
- const documentStorage = await storage.createBucket(`${config.documentBucketId}_${dbName.toLowerCase().replace(" ", "")}`, "Document Storage");
42
+ const documentStorage = await storage.createBucket(`${config.documentBucketId}_${dbName.toLowerCase().replace(" ", "")}`, `Document Storage ${dbName}`, [
43
+ Permission.read("any"),
44
+ Permission.create("users"),
45
+ Permission.update("users"),
46
+ Permission.delete("users"),
47
+ ]);
43
48
  return documentStorage;
44
49
  }
45
50
  };
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.0.6",
4
+ "version": "0.0.8",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -281,6 +281,7 @@ export class ImportController {
281
281
  });
282
282
  if (!userToCreate.success) {
283
283
  console.error(userToCreate.error);
284
+ logger.error(userToCreate.error);
284
285
  return;
285
286
  }
286
287
  const user = await usersController.createUserAndReturn(
@@ -314,7 +315,7 @@ export class ImportController {
314
315
  )}.`
315
316
  );
316
317
  } else if (isMembersCollection) {
317
- console.log(
318
+ logger.error(
318
319
  `Skipping user & contact creation for ${item} due to lack of email...`
319
320
  );
320
321
  }
@@ -346,6 +347,7 @@ export class ImportController {
346
347
  if (createdContext) {
347
348
  afterContext = createdContext;
348
349
  }
350
+ logger.info(`Handled create for ${context.docId}}`);
349
351
  } else {
350
352
  const updatedContext = await this.handleUpdate(
351
353
  context,
@@ -355,6 +357,7 @@ export class ImportController {
355
357
  if (updatedContext) {
356
358
  afterContext = updatedContext;
357
359
  }
360
+ logger.info(`Handled update for ${context.docId}`);
358
361
  }
359
362
  if (afterContext) {
360
363
  context = { ...context, ...afterContext };
@@ -5,6 +5,7 @@ import {
5
5
  InputFile,
6
6
  type Models,
7
7
  ID,
8
+ Permission,
8
9
  } from "node-appwrite";
9
10
  import { type OperationCreate, type BackupCreate } from "./backup.js";
10
11
  import { splitIntoBatches } from "./migrationHelper.js";
@@ -72,7 +73,13 @@ export const initOrGetDocumentStorage = async (
72
73
  // Name Document Storage
73
74
  const documentStorage = await storage.createBucket(
74
75
  `${config.documentBucketId}_${dbName.toLowerCase().replace(" ", "")}`,
75
- "Document Storage"
76
+ `Document Storage ${dbName}`,
77
+ [
78
+ Permission.read("any"),
79
+ Permission.create("users"),
80
+ Permission.update("users"),
81
+ Permission.delete("users"),
82
+ ]
76
83
  );
77
84
  return documentStorage;
78
85
  }