appwrite-utils-cli 0.10.68 → 0.10.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
@@ -148,6 +148,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
148
148
 
149
149
  ## Changelog
150
150
 
151
+ - 0.10.70: Fixed `--transfer-users` phones
151
152
  - 0.10.67: Added `--transfer-users` boolean flag to also transfer users between projects
152
153
  - 0.10.66: Fixed `ignore` always being an empty array, if not set, so it properly ignores the defaults
153
154
  - 0.10.65: Fixed the stupid local functions not caring about the ignore string, and added `__pycache__` and `.venv` to default ignores
@@ -29,7 +29,4 @@ export declare const transferDocumentsBetweenDbsLocalToRemote: (localDb: Databas
29
29
  */
30
30
  export declare const transferDatabaseLocalToLocal: (localDb: Databases, fromDbId: string, targetDbId: string) => Promise<void>;
31
31
  export declare const transferDatabaseLocalToRemote: (localDb: Databases, endpoint: string, projectId: string, apiKey: string, fromDbId: string, toDbId: string) => Promise<void>;
32
- export declare const transferUsersLocalToRemote: (localUsers: Users, endpoint: string, projectId: string, apiKey: string, options?: {
33
- limit?: number;
34
- offset?: number;
35
- }) => Promise<void>;
32
+ export declare const transferUsersLocalToRemote: (localUsers: Users, endpoint: string, projectId: string, apiKey: string) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { tryAwaitWithRetry } from "appwrite-utils";
1
+ import { converterFunctions, tryAwaitWithRetry } from "appwrite-utils";
2
2
  import { Client, Databases, IndexType, Query, Storage, Users, } from "node-appwrite";
3
3
  import { InputFile } from "node-appwrite/file";
4
4
  import { getAppwriteClient } from "../utils/helperFunctions.js";
@@ -378,9 +378,9 @@ export const transferDatabaseLocalToRemote = async (localDb, endpoint, projectId
378
378
  }
379
379
  }
380
380
  };
381
- export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId, apiKey, options = {}) => {
381
+ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId, apiKey) => {
382
382
  console.log(chalk.blue("Starting user transfer to remote instance..."));
383
- const client = getClient(endpoint, apiKey, projectId);
383
+ const client = getClient(endpoint, projectId, apiKey);
384
384
  const remoteUsers = new Users(client);
385
385
  let totalTransferred = 0;
386
386
  let lastId;
@@ -404,7 +404,10 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
404
404
  catch (error) {
405
405
  // User doesn't exist, proceed with creation
406
406
  }
407
- await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, user.phone, // phone - optional
407
+ const phone = user.phone
408
+ ? converterFunctions.convertPhoneStringToUSInternational(user.phone)
409
+ : undefined;
410
+ await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, // phone - optional
408
411
  user.password, // password - cannot transfer hashed passwords
409
412
  user.name));
410
413
  // Update user preferences and status
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.10.68",
4
+ "version": "0.10.70",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -1,4 +1,4 @@
1
- import { tryAwaitWithRetry } from "appwrite-utils";
1
+ import { converterFunctions, tryAwaitWithRetry } from "appwrite-utils";
2
2
  import {
3
3
  Client,
4
4
  Databases,
@@ -774,15 +774,11 @@ export const transferUsersLocalToRemote = async (
774
774
  localUsers: Users,
775
775
  endpoint: string,
776
776
  projectId: string,
777
- apiKey: string,
778
- options: {
779
- limit?: number;
780
- offset?: number;
781
- } = {}
777
+ apiKey: string
782
778
  ) => {
783
779
  console.log(chalk.blue("Starting user transfer to remote instance..."));
784
780
 
785
- const client = getClient(endpoint, apiKey, projectId);
781
+ const client = getClient(endpoint, projectId, apiKey);
786
782
  const remoteUsers = new Users(client);
787
783
 
788
784
  let totalTransferred = 0;
@@ -815,11 +811,15 @@ export const transferUsersLocalToRemote = async (
815
811
  // User doesn't exist, proceed with creation
816
812
  }
817
813
 
814
+ const phone = user.phone
815
+ ? converterFunctions.convertPhoneStringToUSInternational(user.phone)
816
+ : undefined;
817
+
818
818
  await tryAwaitWithRetry(async () =>
819
819
  remoteUsers.create(
820
820
  user.$id,
821
821
  user.email,
822
- user.phone, // phone - optional
822
+ phone, // phone - optional
823
823
  user.password, // password - cannot transfer hashed passwords
824
824
  user.name
825
825
  )