appwrite-cli 1.1.1 → 2.0.0

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.
Files changed (60) hide show
  1. package/Formula/appwrite.rb +1 -1
  2. package/LICENSE.md +2 -2
  3. package/README.md +4 -4
  4. package/docs/examples/account/create-phone-session.md +1 -1
  5. package/docs/examples/account/create.md +1 -1
  6. package/docs/examples/account/update-password.md +1 -1
  7. package/docs/examples/account/update-phone.md +1 -1
  8. package/docs/examples/console/variables.md +1 -0
  9. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  10. package/docs/examples/databases/get-document.md +2 -1
  11. package/docs/examples/databases/update-boolean-attribute.md +6 -0
  12. package/docs/examples/databases/update-datetime-attribute.md +6 -0
  13. package/docs/examples/databases/update-email-attribute.md +6 -0
  14. package/docs/examples/databases/update-enum-attribute.md +7 -0
  15. package/docs/examples/databases/update-float-attribute.md +8 -0
  16. package/docs/examples/databases/update-integer-attribute.md +8 -0
  17. package/docs/examples/databases/update-ip-attribute.md +6 -0
  18. package/docs/examples/databases/update-relationship-attribute.md +5 -0
  19. package/docs/examples/databases/update-string-attribute.md +6 -0
  20. package/docs/examples/databases/update-url-attribute.md +6 -0
  21. package/docs/examples/functions/{retry-build.md → create-build.md} +1 -1
  22. package/docs/examples/functions/create.md +1 -1
  23. package/docs/examples/functions/update.md +1 -1
  24. package/docs/examples/graphql/mutation.md +2 -0
  25. package/docs/examples/graphql/query.md +2 -0
  26. package/docs/examples/projects/create.md +1 -0
  27. package/docs/examples/projects/update-auth-duration.md +3 -0
  28. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  29. package/docs/examples/projects/update-auth-password-history.md +3 -0
  30. package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
  31. package/docs/examples/projects/update-o-auth2.md +1 -0
  32. package/docs/examples/teams/create-membership.md +3 -1
  33. package/docs/examples/teams/get-prefs.md +2 -0
  34. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  35. package/docs/examples/teams/update-prefs.md +3 -0
  36. package/docs/examples/users/update-password.md +1 -1
  37. package/docs/examples/users/update-phone.md +1 -1
  38. package/index.js +16 -1
  39. package/install.ps1 +2 -2
  40. package/install.sh +1 -1
  41. package/lib/client.js +7 -7
  42. package/lib/commands/account.js +46 -11
  43. package/lib/commands/avatars.js +3 -1
  44. package/lib/commands/console.js +44 -0
  45. package/lib/commands/databases.js +735 -109
  46. package/lib/commands/deploy.js +350 -141
  47. package/lib/commands/functions.js +44 -16
  48. package/lib/commands/generic.js +15 -3
  49. package/lib/commands/graphql.js +85 -0
  50. package/lib/commands/health.js +3 -1
  51. package/lib/commands/init.js +224 -162
  52. package/lib/commands/locale.js +3 -1
  53. package/lib/commands/projects.js +223 -9
  54. package/lib/commands/storage.js +43 -13
  55. package/lib/commands/teams.js +107 -19
  56. package/lib/commands/users.js +62 -11
  57. package/lib/config.js +122 -5
  58. package/lib/parser.js +7 -2
  59. package/lib/questions.js +311 -257
  60. package/package.json +1 -1
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
12
 
13
- const users = new Command("users").description(commandDescriptions['users'])
13
+ const users = new Command("users").description(commandDescriptions['users']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const usersList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
16
18
  /* @param {string[]} queries */
@@ -51,22 +53,27 @@ const usersCreate = async ({ userId, email, phone, password, name, parseOutput =
51
53
  let payload = {};
52
54
 
53
55
  /** Body Params */
56
+
54
57
  if (typeof userId !== 'undefined') {
55
58
  payload['userId'] = userId;
56
59
  }
57
60
 
61
+
58
62
  if (typeof email !== 'undefined') {
59
63
  payload['email'] = email;
60
64
  }
61
65
 
66
+
62
67
  if (typeof phone !== 'undefined') {
63
68
  payload['phone'] = phone;
64
69
  }
65
70
 
71
+
66
72
  if (typeof password !== 'undefined') {
67
73
  payload['password'] = password;
68
74
  }
69
75
 
76
+
70
77
  if (typeof name !== 'undefined') {
71
78
  payload['name'] = name;
72
79
  }
@@ -94,18 +101,22 @@ const usersCreateArgon2User = async ({ userId, email, password, name, parseOutpu
94
101
  let payload = {};
95
102
 
96
103
  /** Body Params */
104
+
97
105
  if (typeof userId !== 'undefined') {
98
106
  payload['userId'] = userId;
99
107
  }
100
108
 
109
+
101
110
  if (typeof email !== 'undefined') {
102
111
  payload['email'] = email;
103
112
  }
104
113
 
114
+
105
115
  if (typeof password !== 'undefined') {
106
116
  payload['password'] = password;
107
117
  }
108
118
 
119
+
109
120
  if (typeof name !== 'undefined') {
110
121
  payload['name'] = name;
111
122
  }
@@ -133,18 +144,22 @@ const usersCreateBcryptUser = async ({ userId, email, password, name, parseOutpu
133
144
  let payload = {};
134
145
 
135
146
  /** Body Params */
147
+
136
148
  if (typeof userId !== 'undefined') {
137
149
  payload['userId'] = userId;
138
150
  }
139
151
 
152
+
140
153
  if (typeof email !== 'undefined') {
141
154
  payload['email'] = email;
142
155
  }
143
156
 
157
+
144
158
  if (typeof password !== 'undefined') {
145
159
  payload['password'] = password;
146
160
  }
147
161
 
162
+
148
163
  if (typeof name !== 'undefined') {
149
164
  payload['name'] = name;
150
165
  }
@@ -172,18 +187,22 @@ const usersCreateMD5User = async ({ userId, email, password, name, parseOutput =
172
187
  let payload = {};
173
188
 
174
189
  /** Body Params */
190
+
175
191
  if (typeof userId !== 'undefined') {
176
192
  payload['userId'] = userId;
177
193
  }
178
194
 
195
+
179
196
  if (typeof email !== 'undefined') {
180
197
  payload['email'] = email;
181
198
  }
182
199
 
200
+
183
201
  if (typeof password !== 'undefined') {
184
202
  payload['password'] = password;
185
203
  }
186
204
 
205
+
187
206
  if (typeof name !== 'undefined') {
188
207
  payload['name'] = name;
189
208
  }
@@ -211,18 +230,22 @@ const usersCreatePHPassUser = async ({ userId, email, password, name, parseOutpu
211
230
  let payload = {};
212
231
 
213
232
  /** Body Params */
233
+
214
234
  if (typeof userId !== 'undefined') {
215
235
  payload['userId'] = userId;
216
236
  }
217
237
 
238
+
218
239
  if (typeof email !== 'undefined') {
219
240
  payload['email'] = email;
220
241
  }
221
242
 
243
+
222
244
  if (typeof password !== 'undefined') {
223
245
  payload['password'] = password;
224
246
  }
225
247
 
248
+
226
249
  if (typeof name !== 'undefined') {
227
250
  payload['name'] = name;
228
251
  }
@@ -255,38 +278,47 @@ const usersCreateScryptUser = async ({ userId, email, password, passwordSalt, pa
255
278
  let payload = {};
256
279
 
257
280
  /** Body Params */
281
+
258
282
  if (typeof userId !== 'undefined') {
259
283
  payload['userId'] = userId;
260
284
  }
261
285
 
286
+
262
287
  if (typeof email !== 'undefined') {
263
288
  payload['email'] = email;
264
289
  }
265
290
 
291
+
266
292
  if (typeof password !== 'undefined') {
267
293
  payload['password'] = password;
268
294
  }
269
295
 
296
+
270
297
  if (typeof passwordSalt !== 'undefined') {
271
298
  payload['passwordSalt'] = passwordSalt;
272
299
  }
273
300
 
301
+
274
302
  if (typeof passwordCpu !== 'undefined') {
275
303
  payload['passwordCpu'] = passwordCpu;
276
304
  }
277
305
 
306
+
278
307
  if (typeof passwordMemory !== 'undefined') {
279
308
  payload['passwordMemory'] = passwordMemory;
280
309
  }
281
310
 
311
+
282
312
  if (typeof passwordParallel !== 'undefined') {
283
313
  payload['passwordParallel'] = passwordParallel;
284
314
  }
285
315
 
316
+
286
317
  if (typeof passwordLength !== 'undefined') {
287
318
  payload['passwordLength'] = passwordLength;
288
319
  }
289
320
 
321
+
290
322
  if (typeof name !== 'undefined') {
291
323
  payload['name'] = name;
292
324
  }
@@ -317,30 +349,37 @@ const usersCreateScryptModifiedUser = async ({ userId, email, password, password
317
349
  let payload = {};
318
350
 
319
351
  /** Body Params */
352
+
320
353
  if (typeof userId !== 'undefined') {
321
354
  payload['userId'] = userId;
322
355
  }
323
356
 
357
+
324
358
  if (typeof email !== 'undefined') {
325
359
  payload['email'] = email;
326
360
  }
327
361
 
362
+
328
363
  if (typeof password !== 'undefined') {
329
364
  payload['password'] = password;
330
365
  }
331
366
 
367
+
332
368
  if (typeof passwordSalt !== 'undefined') {
333
369
  payload['passwordSalt'] = passwordSalt;
334
370
  }
335
371
 
372
+
336
373
  if (typeof passwordSaltSeparator !== 'undefined') {
337
374
  payload['passwordSaltSeparator'] = passwordSaltSeparator;
338
375
  }
339
376
 
377
+
340
378
  if (typeof passwordSignerKey !== 'undefined') {
341
379
  payload['passwordSignerKey'] = passwordSignerKey;
342
380
  }
343
381
 
382
+
344
383
  if (typeof name !== 'undefined') {
345
384
  payload['name'] = name;
346
385
  }
@@ -369,22 +408,27 @@ const usersCreateSHAUser = async ({ userId, email, password, passwordVersion, na
369
408
  let payload = {};
370
409
 
371
410
  /** Body Params */
411
+
372
412
  if (typeof userId !== 'undefined') {
373
413
  payload['userId'] = userId;
374
414
  }
375
415
 
416
+
376
417
  if (typeof email !== 'undefined') {
377
418
  payload['email'] = email;
378
419
  }
379
420
 
421
+
380
422
  if (typeof password !== 'undefined') {
381
423
  payload['password'] = password;
382
424
  }
383
425
 
426
+
384
427
  if (typeof passwordVersion !== 'undefined') {
385
428
  payload['passwordVersion'] = passwordVersion;
386
429
  }
387
430
 
431
+
388
432
  if (typeof name !== 'undefined') {
389
433
  payload['name'] = name;
390
434
  }
@@ -473,6 +517,7 @@ const usersUpdateEmail = async ({ userId, email, parseOutput = true, sdk = undef
473
517
  let payload = {};
474
518
 
475
519
  /** Body Params */
520
+
476
521
  if (typeof email !== 'undefined') {
477
522
  payload['email'] = email;
478
523
  }
@@ -540,6 +585,7 @@ const usersUpdateName = async ({ userId, name, parseOutput = true, sdk = undefin
540
585
  let payload = {};
541
586
 
542
587
  /** Body Params */
588
+
543
589
  if (typeof name !== 'undefined') {
544
590
  payload['name'] = name;
545
591
  }
@@ -565,6 +611,7 @@ const usersUpdatePassword = async ({ userId, password, parseOutput = true, sdk =
565
611
  let payload = {};
566
612
 
567
613
  /** Body Params */
614
+
568
615
  if (typeof password !== 'undefined') {
569
616
  payload['password'] = password;
570
617
  }
@@ -590,6 +637,7 @@ const usersUpdatePhone = async ({ userId, number, parseOutput = true, sdk = unde
590
637
  let payload = {};
591
638
 
592
639
  /** Body Params */
640
+
593
641
  if (typeof number !== 'undefined') {
594
642
  payload['number'] = number;
595
643
  }
@@ -713,6 +761,7 @@ const usersUpdateStatus = async ({ userId, status, parseOutput = true, sdk = und
713
761
  let payload = {};
714
762
 
715
763
  /** Body Params */
764
+
716
765
  if (typeof status !== 'undefined') {
717
766
  payload['status'] = status;
718
767
  }
@@ -738,6 +787,7 @@ const usersUpdateEmailVerification = async ({ userId, emailVerification, parseOu
738
787
  let payload = {};
739
788
 
740
789
  /** Body Params */
790
+
741
791
  if (typeof emailVerification !== 'undefined') {
742
792
  payload['emailVerification'] = emailVerification;
743
793
  }
@@ -763,6 +813,7 @@ const usersUpdatePhoneVerification = async ({ userId, phoneVerification, parseOu
763
813
  let payload = {};
764
814
 
765
815
  /** Body Params */
816
+
766
817
  if (typeof phoneVerification !== 'undefined') {
767
818
  payload['phoneVerification'] = phoneVerification;
768
819
  }
@@ -783,14 +834,14 @@ const usersUpdatePhoneVerification = async ({ userId, phoneVerification, parseOu
783
834
  users
784
835
  .command(`list`)
785
836
  .description(`Get a list of all the project's users. You can use the query params to filter your results.`)
786
- .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification`)
837
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification`)
787
838
  .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
788
839
  .action(actionRunner(usersList))
789
840
 
790
841
  users
791
842
  .command(`create`)
792
843
  .description(`Create a new user.`)
793
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
844
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
794
845
  .option(`--email <email>`, `User email.`)
795
846
  .option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
796
847
  .option(`--password <password>`, `Plain text user password. Must be at least 8 chars.`)
@@ -800,7 +851,7 @@ users
800
851
  users
801
852
  .command(`createArgon2User`)
802
853
  .description(`Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
803
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
854
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
804
855
  .requiredOption(`--email <email>`, `User email.`)
805
856
  .requiredOption(`--password <password>`, `User password hashed using Argon2.`)
806
857
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
@@ -809,7 +860,7 @@ users
809
860
  users
810
861
  .command(`createBcryptUser`)
811
862
  .description(`Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
812
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
863
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
813
864
  .requiredOption(`--email <email>`, `User email.`)
814
865
  .requiredOption(`--password <password>`, `User password hashed using Bcrypt.`)
815
866
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
@@ -818,7 +869,7 @@ users
818
869
  users
819
870
  .command(`createMD5User`)
820
871
  .description(`Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
821
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
872
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
822
873
  .requiredOption(`--email <email>`, `User email.`)
823
874
  .requiredOption(`--password <password>`, `User password hashed using MD5.`)
824
875
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
@@ -827,7 +878,7 @@ users
827
878
  users
828
879
  .command(`createPHPassUser`)
829
880
  .description(`Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
830
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
881
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or pass the string 'ID.unique()'to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
831
882
  .requiredOption(`--email <email>`, `User email.`)
832
883
  .requiredOption(`--password <password>`, `User password hashed using PHPass.`)
833
884
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
@@ -836,7 +887,7 @@ users
836
887
  users
837
888
  .command(`createScryptUser`)
838
889
  .description(`Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
839
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
890
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
840
891
  .requiredOption(`--email <email>`, `User email.`)
841
892
  .requiredOption(`--password <password>`, `User password hashed using Scrypt.`)
842
893
  .requiredOption(`--passwordSalt <passwordSalt>`, `Optional salt used to hash password.`)
@@ -850,7 +901,7 @@ users
850
901
  users
851
902
  .command(`createScryptModifiedUser`)
852
903
  .description(`Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
853
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
904
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
854
905
  .requiredOption(`--email <email>`, `User email.`)
855
906
  .requiredOption(`--password <password>`, `User password hashed using Scrypt Modified.`)
856
907
  .requiredOption(`--passwordSalt <passwordSalt>`, `Salt used to hash password.`)
@@ -862,7 +913,7 @@ users
862
913
  users
863
914
  .command(`createSHAUser`)
864
915
  .description(`Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
865
- .requiredOption(`--userId <userId>`, `User ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
916
+ .requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
866
917
  .requiredOption(`--email <email>`, `User email.`)
867
918
  .requiredOption(`--password <password>`, `User password hashed using SHA.`)
868
919
  .option(`--passwordVersion <passwordVersion>`, `Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'`)
@@ -899,7 +950,7 @@ users
899
950
  .command(`listLogs`)
900
951
  .description(`Get the user activity logs list by its unique ID.`)
901
952
  .requiredOption(`--userId <userId>`, `User ID.`)
902
- .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset`)
953
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset`)
903
954
  .action(actionRunner(usersListLogs))
904
955
 
905
956
  users
package/lib/config.js CHANGED
@@ -22,7 +22,7 @@ class Config {
22
22
 
23
23
  write() {
24
24
  let dir = _path.dirname(this.path)
25
- if (!fs.existsSync(dir)){
25
+ if (!fs.existsSync(dir)) {
26
26
  fs.mkdirSync(dir, { recursive: true });
27
27
  }
28
28
  fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4));
@@ -135,7 +135,7 @@ class Local extends Config {
135
135
  }
136
136
 
137
137
  getCollection($id) {
138
- if (!this.has("collection")) {
138
+ if (!this.has("collections")) {
139
139
  return {};
140
140
  }
141
141
 
@@ -156,7 +156,7 @@ class Local extends Config {
156
156
 
157
157
  let collections = this.get("collections");
158
158
  for (let i = 0; i < collections.length; i++) {
159
- if (collections[i]['$id'] == props['$id']) {
159
+ if (collections[i]['$id'] == props['$id'] && collections[i]['databaseId'] == props['databaseId']) {
160
160
  collections[i] = props;
161
161
  this.set("collections", collections);
162
162
  return;
@@ -166,6 +166,123 @@ class Local extends Config {
166
166
  this.set("collections", collections);
167
167
  }
168
168
 
169
+ getBuckets() {
170
+ if (!this.has("buckets")) {
171
+ return [];
172
+ }
173
+ return this.get("buckets");
174
+ }
175
+
176
+ getBucket($id) {
177
+ if (!this.has("buckets")) {
178
+ return {};
179
+ }
180
+
181
+ let buckets = this.get("buckets");
182
+ for (let i = 0; i < buckets.length; i++) {
183
+ if (buckets[i]['$id'] == $id) {
184
+ return buckets[i];
185
+ }
186
+ }
187
+
188
+ return {};
189
+ }
190
+
191
+ addBucket(props) {
192
+ if (!this.has("buckets")) {
193
+ this.set("buckets", []);
194
+ }
195
+
196
+ let buckets = this.get("buckets");
197
+ for (let i = 0; i < buckets.length; i++) {
198
+ if (buckets[i]['$id'] == props['$id']) {
199
+ buckets[i] = props;
200
+ this.set("buckets", buckets);
201
+ return;
202
+ }
203
+ }
204
+ buckets.push(props);
205
+ this.set("buckets", buckets);
206
+ }
207
+
208
+ getDatabases() {
209
+ if (!this.has("databases")) {
210
+ return [];
211
+ }
212
+ return this.get("databases");
213
+ }
214
+
215
+ getDatabase($id) {
216
+ if (!this.has("databases")) {
217
+ return {};
218
+ }
219
+
220
+ let databases = this.get("databases");
221
+ for (let i = 0; i < databases.length; i++) {
222
+ if (databases[i]['$id'] == $id) {
223
+ return databases[i];
224
+ }
225
+ }
226
+
227
+ return {};
228
+ }
229
+
230
+ addDatabase(props) {
231
+ if (!this.has("databases")) {
232
+ this.set("databases", []);
233
+ }
234
+
235
+ let databases = this.get("databases");
236
+ for (let i = 0; i < databases.length; i++) {
237
+ if (databases[i]['$id'] == props['$id']) {
238
+ databases[i] = props;
239
+ this.set("databases", databases);
240
+ return;
241
+ }
242
+ }
243
+ databases.push(props);
244
+ this.set("databases", databases);
245
+ }
246
+
247
+ getTeams() {
248
+ if (!this.has("teams")) {
249
+ return [];
250
+ }
251
+ return this.get("teams");
252
+ }
253
+
254
+ getTeam($id) {
255
+ if (!this.has("teams")) {
256
+ return {};
257
+ }
258
+
259
+ let teams = this.get("teams");
260
+ for (let i = 0; i < teams.length; i++) {
261
+ if (teams[i]['$id'] == $id) {
262
+ return teams[i];
263
+ }
264
+ }
265
+
266
+ return {};
267
+ }
268
+
269
+ addTeam(props) {
270
+ if (!this.has("teams")) {
271
+ this.set("teams", []);
272
+ }
273
+
274
+ let teams = this.get("teams");
275
+ for (let i = 0; i < teams.length; i++) {
276
+ if (teams[i]['$id'] == props['$id']) {
277
+ teams[i] = props;
278
+ this.set("teams", teams);
279
+ return;
280
+ }
281
+ }
282
+ teams.push(props);
283
+ this.set("teams", teams);
284
+ }
285
+
169
286
  getProject() {
170
287
  if (!this.has("projectId") || !this.has("projectName")) {
171
288
  return {};
@@ -261,6 +378,6 @@ class Global extends Config {
261
378
  }
262
379
 
263
380
  module.exports = {
264
- localConfig : new Local(),
265
- globalConfig : new Global(),
381
+ localConfig: new Local(),
382
+ globalConfig: new Global(),
266
383
  };
package/lib/parser.js CHANGED
@@ -23,8 +23,12 @@ const parse = (data) => {
23
23
  drawJSON(data[key]);
24
24
  }
25
25
  } else if (typeof data[key] === 'object') {
26
- console.log(`${chalk.yellow.bold.underline(key)}`)
27
- parse(data[key]);
26
+ if (data[key] && data[key].constructor.name === 'BigNumber') {
27
+ console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
28
+ } else {
29
+ console.log(`${chalk.yellow.bold.underline(key)}`)
30
+ parse(data[key]);
31
+ }
28
32
  } else {
29
33
  console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
30
34
  }
@@ -149,6 +153,7 @@ const logo = "\n _ _ _ ___ __ _____
149
153
 
150
154
  const commandDescriptions = {
151
155
  "account": `The account command allows you to authenticate and manage a user account.`,
156
+ "graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
152
157
  "avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
153
158
  "databases": `The databases command allows you to create structured collections of documents, query and filter lists of documents.`,
154
159
  "deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,