appwrite-utils-cli 0.0.45 → 0.0.47
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
|
@@ -86,6 +86,7 @@ This setup ensures that developers have robust tools at their fingertips to mana
|
|
|
86
86
|
|
|
87
87
|
### Changelog
|
|
88
88
|
|
|
89
|
+
- 0.0.48: Minor bugfixes in many releases, too small to take note of
|
|
89
90
|
- 0.0.38: Lots of optimizations done to the code, added `tryAwaitWithRetry` for `fetch failed` and others like it errors (looking at you `server error`) -- this should prevent things from going sideways.
|
|
90
91
|
- 0.0.37: Added `documentSecurity`, `enabled`, and `$id` to the `init` collection
|
|
91
92
|
- 0.0.36: Made it update collections by default, sometimes you gotta do what you gotta do
|
|
@@ -146,13 +146,13 @@ export const createOrUpdateCollections = async (database, databaseId, config, de
|
|
|
146
146
|
let collectionId;
|
|
147
147
|
if (!collectionToUse) {
|
|
148
148
|
console.log(`Creating collection: ${collection.name}`);
|
|
149
|
-
|
|
149
|
+
let foundColl = deletedCollections?.find((coll) => coll.collectionName.toLowerCase().trim().replace(" ", "") ===
|
|
150
150
|
collection.name.toLowerCase().trim().replace(" ", ""));
|
|
151
|
-
if (
|
|
152
|
-
collectionId =
|
|
151
|
+
if (collection.$id) {
|
|
152
|
+
collectionId = collection.$id; // Always use the provided $id if present
|
|
153
153
|
}
|
|
154
|
-
else if (
|
|
155
|
-
collectionId =
|
|
154
|
+
else if (foundColl && !usedIds.has(foundColl.collectionId)) {
|
|
155
|
+
collectionId = foundColl.collectionId; // Use ID from deleted collection if not already used
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
158
|
collectionId = ID.unique(); // Generate a new unique ID
|
|
@@ -54,13 +54,8 @@ export class ImportController {
|
|
|
54
54
|
console.log(`Starting import data for database: ${db.name}`);
|
|
55
55
|
console.log(`---------------------------------`);
|
|
56
56
|
// await this.importCollections(db);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await dataLoader.start(db.$id);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.log(`Using data from previous import run`);
|
|
63
|
-
}
|
|
57
|
+
dataLoader = new DataLoader(this.appwriteFolderPath, this.importDataActions, this.database, this.config, this.setupOptions.shouldWriteFile);
|
|
58
|
+
await dataLoader.start(db.$id);
|
|
64
59
|
await this.importCollections(db, dataLoader);
|
|
65
60
|
await resolveAndUpdateRelationships(db.$id, this.database, this.config);
|
|
66
61
|
await this.executePostImportActions(db.$id, dataLoader);
|
|
@@ -78,7 +73,7 @@ export class ImportController {
|
|
|
78
73
|
dataLoader.getCollectionKey(collection.name);
|
|
79
74
|
const importOperationId = dataLoader.collectionImportOperations.get(dataLoader.getCollectionKey(collection.name));
|
|
80
75
|
const createBatches = (finalData) => {
|
|
81
|
-
let maxBatchLength =
|
|
76
|
+
let maxBatchLength = 100;
|
|
82
77
|
const finalBatches = [];
|
|
83
78
|
for (let i = 0; i < finalData.length; i++) {
|
|
84
79
|
if (i % maxBatchLength === 0) {
|
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.
|
|
4
|
+
"version": "0.0.47",
|
|
5
5
|
"main": "src/main.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -201,16 +201,16 @@ export const createOrUpdateCollections = async (
|
|
|
201
201
|
let collectionId: string;
|
|
202
202
|
if (!collectionToUse) {
|
|
203
203
|
console.log(`Creating collection: ${collection.name}`);
|
|
204
|
-
|
|
204
|
+
let foundColl = deletedCollections?.find(
|
|
205
205
|
(coll) =>
|
|
206
206
|
coll.collectionName.toLowerCase().trim().replace(" ", "") ===
|
|
207
207
|
collection.name.toLowerCase().trim().replace(" ", "")
|
|
208
208
|
);
|
|
209
209
|
|
|
210
|
-
if (
|
|
210
|
+
if (collection.$id) {
|
|
211
|
+
collectionId = collection.$id; // Always use the provided $id if present
|
|
212
|
+
} else if (foundColl && !usedIds.has(foundColl.collectionId)) {
|
|
211
213
|
collectionId = foundColl.collectionId; // Use ID from deleted collection if not already used
|
|
212
|
-
} else if (collection.$id && !usedIds.has(collection.$id)) {
|
|
213
|
-
collectionId = collection.$id; // Use the provided $id if not already used
|
|
214
214
|
} else {
|
|
215
215
|
collectionId = ID.unique(); // Generate a new unique ID
|
|
216
216
|
}
|
|
@@ -92,18 +92,14 @@ export class ImportController {
|
|
|
92
92
|
console.log(`Starting import data for database: ${db.name}`);
|
|
93
93
|
console.log(`---------------------------------`);
|
|
94
94
|
// await this.importCollections(db);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await dataLoader.start(db.$id);
|
|
104
|
-
} else {
|
|
105
|
-
console.log(`Using data from previous import run`);
|
|
106
|
-
}
|
|
95
|
+
dataLoader = new DataLoader(
|
|
96
|
+
this.appwriteFolderPath,
|
|
97
|
+
this.importDataActions,
|
|
98
|
+
this.database,
|
|
99
|
+
this.config,
|
|
100
|
+
this.setupOptions.shouldWriteFile
|
|
101
|
+
);
|
|
102
|
+
await dataLoader.start(db.$id);
|
|
107
103
|
await this.importCollections(db, dataLoader);
|
|
108
104
|
await resolveAndUpdateRelationships(db.$id, this.database, this.config);
|
|
109
105
|
await this.executePostImportActions(db.$id, dataLoader);
|
|
@@ -125,7 +121,7 @@ export class ImportController {
|
|
|
125
121
|
dataLoader.getCollectionKey(collection.name)
|
|
126
122
|
);
|
|
127
123
|
const createBatches = (finalData: CollectionImportData["data"]) => {
|
|
128
|
-
let maxBatchLength =
|
|
124
|
+
let maxBatchLength = 100;
|
|
129
125
|
const finalBatches: CollectionImportData["data"][] = [];
|
|
130
126
|
for (let i = 0; i < finalData.length; i++) {
|
|
131
127
|
if (i % maxBatchLength === 0) {
|