appwrite-utils-cli 0.0.8 → 0.0.10

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.
@@ -236,6 +236,7 @@ export class ImportController {
236
236
  results.forEach((result) => {
237
237
  if (result.status === "rejected") {
238
238
  console.error("A process batch promise was rejected:", result.reason);
239
+ logger.error("An error occurred during creation: ", result.reason);
239
240
  }
240
241
  });
241
242
  }
@@ -1,5 +1,4 @@
1
1
  import { type Databases } from "node-appwrite";
2
- import { type Operation } from "./backup.js";
3
2
  import { z } from "zod";
4
3
  /**
5
4
  * Object that contains the context for an action that needs to be executed after import
@@ -136,7 +135,7 @@ export declare const ContextObject: z.ZodObject<{
136
135
  }>;
137
136
  export type ContextObject = z.infer<typeof ContextObject>;
138
137
  export declare const createOrFindAfterImportOperation: (database: Databases, collectionId: string, context: ContextObject) => Promise<void>;
139
- export declare const addBatch: (database: Databases, operation: Operation, data: string) => Promise<string>;
138
+ export declare const addBatch: (database: Databases, data: string) => Promise<string>;
140
139
  export declare const getAfterImportOperations: (database: Databases, collectionId: string) => Promise<{
141
140
  error: string;
142
141
  status: "error" | "pending" | "ready" | "in_progress" | "completed" | "cancelled";
@@ -29,19 +29,16 @@ export const createOrFindAfterImportOperation = async (database, collectionId, c
29
29
  // Directly create a new batch for the context without checking for an existing batch
30
30
  const contextData = JSON.stringify(context);
31
31
  // Create a new batch with the contextData
32
- const newBatchId = await addBatch(database, operation, contextData);
32
+ const newBatchId = await addBatch(database, contextData);
33
33
  // Update the operation with the new batch's $id
34
- operation.batches.push(newBatchId);
34
+ operation.batches = [...operation.batches, newBatchId];
35
35
  await database.updateDocument("migrations", "currentOperations", operation.$id, { batches: operation.batches });
36
36
  };
37
- export const addBatch = async (database, operation, data) => {
37
+ export const addBatch = async (database, data) => {
38
38
  const batch = await database.createDocument("migrations", "batches", ID.unique(), {
39
39
  data,
40
40
  processed: false,
41
41
  });
42
- await database.updateDocument("migrations", "currentOperations", operation.$id, {
43
- batches: [...(operation.batches || []), batch.$id],
44
- });
45
42
  return batch.$id;
46
43
  };
47
44
  export const getAfterImportOperations = async (database, collectionId) => {
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.8",
4
+ "version": "0.0.10",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -396,6 +396,7 @@ export class ImportController {
396
396
  results.forEach((result) => {
397
397
  if (result.status === "rejected") {
398
398
  console.error("A process batch promise was rejected:", result.reason);
399
+ logger.error("An error occurred during creation: ", result.reason);
399
400
  }
400
401
  });
401
402
  }
@@ -42,9 +42,9 @@ export const createOrFindAfterImportOperation = async (
42
42
  // Directly create a new batch for the context without checking for an existing batch
43
43
  const contextData = JSON.stringify(context);
44
44
  // Create a new batch with the contextData
45
- const newBatchId = await addBatch(database, operation, contextData);
45
+ const newBatchId = await addBatch(database, contextData);
46
46
  // Update the operation with the new batch's $id
47
- operation.batches.push(newBatchId);
47
+ operation.batches = [...operation.batches, newBatchId];
48
48
  await database.updateDocument(
49
49
  "migrations",
50
50
  "currentOperations",
@@ -53,11 +53,7 @@ export const createOrFindAfterImportOperation = async (
53
53
  );
54
54
  };
55
55
 
56
- export const addBatch = async (
57
- database: Databases,
58
- operation: Operation,
59
- data: string
60
- ) => {
56
+ export const addBatch = async (database: Databases, data: string) => {
61
57
  const batch = await database.createDocument(
62
58
  "migrations",
63
59
  "batches",
@@ -67,14 +63,6 @@ export const addBatch = async (
67
63
  processed: false,
68
64
  }
69
65
  );
70
- await database.updateDocument(
71
- "migrations",
72
- "currentOperations",
73
- operation.$id,
74
- {
75
- batches: [...(operation.batches || []), batch.$id],
76
- }
77
- );
78
66
  return batch.$id;
79
67
  };
80
68