appwrite-utils-cli 0.0.69 → 0.0.70

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
@@ -132,6 +132,7 @@ This setup ensures that developers have robust tools at their fingertips to mana
132
132
 
133
133
  ### Changelog
134
134
 
135
+ - 0.0.70: Bump to `node-appwrite` version
135
136
  - 0.0.69: Fixed single ID not getting replaced due to the below change =D also, `nice`
136
137
  - 0.0.68: Fixed the occasional case where, when mapping ID's from old data to new, there would be an array of ID's to match against. `idMappings` now supports arrays.
137
138
  - 0.0.67: Fixed `updates` in `importDef`'s update mappings overwriting postImportActions from the original
@@ -1,4 +1,5 @@
1
- import { Databases, Storage, InputFile, Query, ID, Client, } from "node-appwrite";
1
+ import { Databases, Storage, Query, ID, Client, Compression, } from "node-appwrite";
2
+ import { InputFile } from "node-appwrite/file";
2
3
  import path from "path";
3
4
  import fs from "fs";
4
5
  import os from "os";
@@ -208,11 +209,11 @@ export const afterImportActions = {
208
209
  return await tryAwaitWithRetry(async () => await storage.getBucket(bucketId));
209
210
  }
210
211
  catch (error) {
211
- return await tryAwaitWithRetry(async () => await storage.createBucket(bucketId, bucketName, permissions, fileSecurity, enabled, maxFileSize, allowedExtensions, compression, encryption, antivirus));
212
+ return await tryAwaitWithRetry(async () => await storage.createBucket(bucketId, bucketName, permissions, fileSecurity, enabled, maxFileSize, allowedExtensions, compression ? Compression.Gzip : undefined, encryption, antivirus));
212
213
  }
213
214
  }
214
215
  else {
215
- return await tryAwaitWithRetry(async () => await storage.createBucket(bucketId || ID.unique(), bucketName, permissions, fileSecurity, enabled, maxFileSize, allowedExtensions, compression, encryption, antivirus));
216
+ return await tryAwaitWithRetry(async () => await storage.createBucket(bucketId || ID.unique(), bucketName, permissions, fileSecurity, enabled, maxFileSize, allowedExtensions, compression ? Compression.Gzip : undefined, encryption, antivirus));
216
217
  }
217
218
  }
218
219
  catch (error) {
@@ -1,4 +1,4 @@
1
- import { Client, Databases, Query } from "node-appwrite";
1
+ import { Client, Databases, IndexType, Query, } from "node-appwrite";
2
2
  import { getAppwriteClient, tryAwaitWithRetry, } from "../utils/helperFunctions.js";
3
3
  import { transferDocumentsBetweenDbsLocalToLocal, transferDocumentsBetweenDbsLocalToRemote, } from "./collections.js";
4
4
  import { createOrUpdateAttribute } from "./attributes.js";
@@ -1,4 +1,4 @@
1
- import { ID, InputFile, Query, } from "node-appwrite";
1
+ import {} from "node-appwrite";
2
2
  import { validationRules, } from "appwrite-utils";
3
3
  import { converterFunctions } from "appwrite-utils";
4
4
  import { convertObjectBySchema } from "./converters.js";
@@ -1,5 +1,5 @@
1
1
  import { indexSchema } from "appwrite-utils";
2
- import { Databases, Query } from "node-appwrite";
2
+ import { Databases, IndexType, Query } from "node-appwrite";
3
3
  import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
4
4
  // import {}
5
5
  export const createOrUpdateIndex = async (dbId, db, collectionId, index) => {
@@ -1,4 +1,5 @@
1
- import { Storage, Databases, Query, InputFile, ID, Permission, } from "node-appwrite";
1
+ import { Storage, Databases, Query, ID, Permission, } from "node-appwrite";
2
+ import { InputFile } from "node-appwrite/file";
2
3
  import {} from "./backup.js";
3
4
  import { splitIntoBatches } from "./migrationHelper.js";
4
5
  import { getAppwriteClient, tryAwaitWithRetry, } from "../utils/helperFunctions.js";
@@ -307,7 +308,9 @@ export const transferStorageLocalToRemote = async (localStorage, endpoint, proje
307
308
  }
308
309
  }
309
310
  for (const file of allFromFiles) {
310
- await tryAwaitWithRetry(async () => await remoteStorage.createFile(toBucketId, file.$id, file, file.$permissions));
311
+ const fileData = await tryAwaitWithRetry(async () => await localStorage.getFileDownload(file.bucketId, file.$id));
312
+ const fileToCreate = InputFile.fromBuffer(Buffer.from(fileData), file.name);
313
+ await tryAwaitWithRetry(async () => await remoteStorage.createFile(toBucketId, file.$id, fileToCreate, file.$permissions));
311
314
  numberOfFiles++;
312
315
  }
313
316
  console.log(`Transferred ${numberOfFiles} files from ${fromBucketId} to ${toBucketId}`);
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.69",
4
+ "version": "0.0.70",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -33,14 +33,14 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@types/inquirer": "^9.0.7",
36
- "appwrite-utils": "^0.3.5",
36
+ "appwrite-utils": "^0.3.6",
37
37
  "commander": "^12.0.0",
38
38
  "inquirer": "^9.2.20",
39
39
  "js-yaml": "^4.1.0",
40
40
  "lodash": "^4.17.21",
41
41
  "luxon": "^3.4.4",
42
42
  "nanostores": "^0.10.3",
43
- "node-appwrite": "^12.0.1",
43
+ "node-appwrite": "^13.0.0",
44
44
  "tsx": "^4.9.3",
45
45
  "ulid": "^2.3.0",
46
46
  "winston": "^3.13.0",
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  Databases,
3
3
  Storage,
4
- InputFile,
5
4
  Query,
6
5
  ID,
7
6
  type Models,
8
7
  Client,
8
+ Compression,
9
9
  } from "node-appwrite";
10
+ import { InputFile } from "node-appwrite/file";
10
11
  import path from "path";
11
12
  import fs from "fs";
12
13
  import os from "os";
@@ -385,7 +386,7 @@ export const afterImportActions = {
385
386
  enabled,
386
387
  maxFileSize,
387
388
  allowedExtensions,
388
- compression,
389
+ compression ? Compression.Gzip : undefined,
389
390
  encryption,
390
391
  antivirus
391
392
  )
@@ -402,7 +403,7 @@ export const afterImportActions = {
402
403
  enabled,
403
404
  maxFileSize,
404
405
  allowedExtensions,
405
- compression,
406
+ compression ? Compression.Gzip : undefined,
406
407
  encryption,
407
408
  antivirus
408
409
  )
@@ -1,4 +1,10 @@
1
- import { Client, Databases, Query, type Models } from "node-appwrite";
1
+ import {
2
+ Client,
3
+ Databases,
4
+ IndexType,
5
+ Query,
6
+ type Models,
7
+ } from "node-appwrite";
2
8
  import {
3
9
  getAppwriteClient,
4
10
  tryAwaitWithRetry,
@@ -139,7 +145,7 @@ export const transferDatabaseLocalToLocal = async (
139
145
  targetDbId,
140
146
  newCollection.$id,
141
147
  index.key,
142
- index.type,
148
+ index.type as IndexType,
143
149
  index.attributes,
144
150
  index.orders
145
151
  )
@@ -226,7 +232,7 @@ export const transferDatabaseLocalToRemote = async (
226
232
  toDbId,
227
233
  toCollection.$id,
228
234
  index.key,
229
- index.type,
235
+ index.type as IndexType,
230
236
  index.attributes,
231
237
  index.orders
232
238
  )
@@ -1,10 +1,4 @@
1
- import {
2
- ID,
3
- InputFile,
4
- Query,
5
- type Databases,
6
- type Storage,
7
- } from "node-appwrite";
1
+ import { type Databases, type Storage } from "node-appwrite";
8
2
  import type { AppwriteConfig } from "appwrite-utils";
9
3
  import {
10
4
  validationRules,
@@ -1,5 +1,5 @@
1
1
  import { indexSchema, type Index } from "appwrite-utils";
2
- import { Databases, Query, type Models } from "node-appwrite";
2
+ import { Databases, IndexType, Query, type Models } from "node-appwrite";
3
3
  import { tryAwaitWithRetry } from "../utils/helperFunctions.js";
4
4
  // import {}
5
5
 
@@ -19,7 +19,7 @@ export const createOrUpdateIndex = async (
19
19
  dbId,
20
20
  collectionId,
21
21
  index.key,
22
- index.type,
22
+ index.type as IndexType,
23
23
  index.attributes,
24
24
  index.orders
25
25
  );
@@ -2,11 +2,11 @@ import {
2
2
  Storage,
3
3
  Databases,
4
4
  Query,
5
- InputFile,
6
5
  type Models,
7
6
  ID,
8
7
  Permission,
9
8
  } from "node-appwrite";
9
+ import { InputFile } from "node-appwrite/file";
10
10
  import { type OperationCreate, type BackupCreate } from "./backup.js";
11
11
  import { splitIntoBatches } from "./migrationHelper.js";
12
12
  import type { AppwriteConfig } from "appwrite-utils";
@@ -490,12 +490,16 @@ export const transferStorageLocalToRemote = async (
490
490
  }
491
491
 
492
492
  for (const file of allFromFiles) {
493
+ const fileData = await tryAwaitWithRetry(
494
+ async () => await localStorage.getFileDownload(file.bucketId, file.$id)
495
+ );
496
+ const fileToCreate = InputFile.fromBuffer(Buffer.from(fileData), file.name);
493
497
  await tryAwaitWithRetry(
494
498
  async () =>
495
499
  await remoteStorage.createFile(
496
500
  toBucketId,
497
501
  file.$id,
498
- file,
502
+ fileToCreate,
499
503
  file.$permissions
500
504
  )
501
505
  );