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 account = new Command("account").description(commandDescriptions['account'])
13
+ const account = new Command("account").description(commandDescriptions['account']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const accountGet = async ({ parseOutput = true, sdk = undefined}) => {
16
18
 
@@ -40,18 +42,22 @@ const accountCreate = async ({ userId, email, password, name, parseOutput = true
40
42
  let payload = {};
41
43
 
42
44
  /** Body Params */
45
+
43
46
  if (typeof userId !== 'undefined') {
44
47
  payload['userId'] = userId;
45
48
  }
46
49
 
50
+
47
51
  if (typeof email !== 'undefined') {
48
52
  payload['email'] = email;
49
53
  }
50
54
 
55
+
51
56
  if (typeof password !== 'undefined') {
52
57
  payload['password'] = password;
53
58
  }
54
59
 
60
+
55
61
  if (typeof name !== 'undefined') {
56
62
  payload['name'] = name;
57
63
  }
@@ -77,10 +83,12 @@ const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = u
77
83
  let payload = {};
78
84
 
79
85
  /** Body Params */
86
+
80
87
  if (typeof email !== 'undefined') {
81
88
  payload['email'] = email;
82
89
  }
83
90
 
91
+
84
92
  if (typeof password !== 'undefined') {
85
93
  payload['password'] = password;
86
94
  }
@@ -145,6 +153,7 @@ const accountUpdateName = async ({ name, parseOutput = true, sdk = undefined}) =
145
153
  let payload = {};
146
154
 
147
155
  /** Body Params */
156
+
148
157
  if (typeof name !== 'undefined') {
149
158
  payload['name'] = name;
150
159
  }
@@ -170,10 +179,12 @@ const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true
170
179
  let payload = {};
171
180
 
172
181
  /** Body Params */
182
+
173
183
  if (typeof password !== 'undefined') {
174
184
  payload['password'] = password;
175
185
  }
176
186
 
187
+
177
188
  if (typeof oldPassword !== 'undefined') {
178
189
  payload['oldPassword'] = oldPassword;
179
190
  }
@@ -199,10 +210,12 @@ const accountUpdatePhone = async ({ phone, password, parseOutput = true, sdk = u
199
210
  let payload = {};
200
211
 
201
212
  /** Body Params */
213
+
202
214
  if (typeof phone !== 'undefined') {
203
215
  payload['phone'] = phone;
204
216
  }
205
217
 
218
+
206
219
  if (typeof password !== 'undefined') {
207
220
  payload['password'] = password;
208
221
  }
@@ -269,10 +282,12 @@ const accountCreateRecovery = async ({ email, url, parseOutput = true, sdk = und
269
282
  let payload = {};
270
283
 
271
284
  /** Body Params */
285
+
272
286
  if (typeof email !== 'undefined') {
273
287
  payload['email'] = email;
274
288
  }
275
289
 
290
+
276
291
  if (typeof url !== 'undefined') {
277
292
  payload['url'] = url;
278
293
  }
@@ -300,18 +315,22 @@ const accountUpdateRecovery = async ({ userId, secret, password, passwordAgain,
300
315
  let payload = {};
301
316
 
302
317
  /** Body Params */
318
+
303
319
  if (typeof userId !== 'undefined') {
304
320
  payload['userId'] = userId;
305
321
  }
306
322
 
323
+
307
324
  if (typeof secret !== 'undefined') {
308
325
  payload['secret'] = secret;
309
326
  }
310
327
 
328
+
311
329
  if (typeof password !== 'undefined') {
312
330
  payload['password'] = password;
313
331
  }
314
332
 
333
+
315
334
  if (typeof passwordAgain !== 'undefined') {
316
335
  payload['passwordAgain'] = passwordAgain;
317
336
  }
@@ -388,10 +407,12 @@ const accountCreateEmailSession = async ({ email, password, parseOutput = true,
388
407
  let payload = {};
389
408
 
390
409
  /** Body Params */
410
+
391
411
  if (typeof email !== 'undefined') {
392
412
  payload['email'] = email;
393
413
  }
394
414
 
415
+
395
416
  if (typeof password !== 'undefined') {
396
417
  payload['password'] = password;
397
418
  }
@@ -418,14 +439,17 @@ const accountCreateMagicURLSession = async ({ userId, email, url, parseOutput =
418
439
  let payload = {};
419
440
 
420
441
  /** Body Params */
442
+
421
443
  if (typeof userId !== 'undefined') {
422
444
  payload['userId'] = userId;
423
445
  }
424
446
 
447
+
425
448
  if (typeof email !== 'undefined') {
426
449
  payload['email'] = email;
427
450
  }
428
451
 
452
+
429
453
  if (typeof url !== 'undefined') {
430
454
  payload['url'] = url;
431
455
  }
@@ -451,10 +475,12 @@ const accountUpdateMagicURLSession = async ({ userId, secret, parseOutput = true
451
475
  let payload = {};
452
476
 
453
477
  /** Body Params */
478
+
454
479
  if (typeof userId !== 'undefined') {
455
480
  payload['userId'] = userId;
456
481
  }
457
482
 
483
+
458
484
  if (typeof secret !== 'undefined') {
459
485
  payload['secret'] = secret;
460
486
  }
@@ -512,10 +538,12 @@ const accountCreatePhoneSession = async ({ userId, phone, parseOutput = true, sd
512
538
  let payload = {};
513
539
 
514
540
  /** Body Params */
541
+
515
542
  if (typeof userId !== 'undefined') {
516
543
  payload['userId'] = userId;
517
544
  }
518
545
 
546
+
519
547
  if (typeof phone !== 'undefined') {
520
548
  payload['phone'] = phone;
521
549
  }
@@ -541,10 +569,12 @@ const accountUpdatePhoneSession = async ({ userId, secret, parseOutput = true, s
541
569
  let payload = {};
542
570
 
543
571
  /** Body Params */
572
+
544
573
  if (typeof userId !== 'undefined') {
545
574
  payload['userId'] = userId;
546
575
  }
547
576
 
577
+
548
578
  if (typeof secret !== 'undefined') {
549
579
  payload['secret'] = secret;
550
580
  }
@@ -640,6 +670,7 @@ const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefi
640
670
  let payload = {};
641
671
 
642
672
  /** Body Params */
673
+
643
674
  if (typeof url !== 'undefined') {
644
675
  payload['url'] = url;
645
676
  }
@@ -665,10 +696,12 @@ const accountUpdateVerification = async ({ userId, secret, parseOutput = true, s
665
696
  let payload = {};
666
697
 
667
698
  /** Body Params */
699
+
668
700
  if (typeof userId !== 'undefined') {
669
701
  payload['userId'] = userId;
670
702
  }
671
703
 
704
+
672
705
  if (typeof secret !== 'undefined') {
673
706
  payload['secret'] = secret;
674
707
  }
@@ -711,10 +744,12 @@ const accountUpdatePhoneVerification = async ({ userId, secret, parseOutput = tr
711
744
  let payload = {};
712
745
 
713
746
  /** Body Params */
747
+
714
748
  if (typeof userId !== 'undefined') {
715
749
  payload['userId'] = userId;
716
750
  }
717
751
 
752
+
718
753
  if (typeof secret !== 'undefined') {
719
754
  payload['secret'] = secret;
720
755
  }
@@ -740,9 +775,9 @@ account
740
775
  account
741
776
  .command(`create`)
742
777
  .description(`Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](/docs/client/account#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](/docs/client/account#accountCreateSession).`)
743
- .requiredOption(`--userId <userId>`, `Unique 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.`)
778
+ .requiredOption(`--userId <userId>`, `Unique 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.`)
744
779
  .requiredOption(`--email <email>`, `User email.`)
745
- .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
780
+ .requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
746
781
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
747
782
  .action(actionRunner(accountCreate))
748
783
 
@@ -761,7 +796,7 @@ account
761
796
  account
762
797
  .command(`listLogs`)
763
798
  .description(`Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log.`)
764
- .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`)
799
+ .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`)
765
800
  .action(actionRunner(accountListLogs))
766
801
 
767
802
  account
@@ -828,15 +863,15 @@ account
828
863
 
829
864
  account
830
865
  .command(`createEmailSession`)
831
- .description(`Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.`)
866
+ .description(`Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits).`)
832
867
  .requiredOption(`--email <email>`, `User email.`)
833
868
  .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
834
869
  .action(actionRunner(accountCreateEmailSession))
835
870
 
836
871
  account
837
872
  .command(`createMagicURLSession`)
838
- .description(`Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.`)
839
- .requiredOption(`--userId <userId>`, `Unique 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.`)
873
+ .description(`Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits).`)
874
+ .requiredOption(`--userId <userId>`, `Unique 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
875
  .requiredOption(`--email <email>`, `User email.`)
841
876
  .option(`--url <url>`, `URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
842
877
  .action(actionRunner(accountCreateMagicURLSession))
@@ -850,17 +885,17 @@ account
850
885
 
851
886
  account
852
887
  .command(`createOAuth2Session`)
853
- .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.. `)
888
+ .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). `)
854
889
  .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.`)
855
890
  .option(`--success <success>`, `URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
856
891
  .option(`--failure <failure>`, `URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
857
- .option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.`)
892
+ .option(`--scopes [scopes...]`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.`)
858
893
  .action(actionRunner(accountCreateOAuth2Session))
859
894
 
860
895
  account
861
896
  .command(`createPhoneSession`)
862
- .description(`Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.`)
863
- .requiredOption(`--userId <userId>`, `Unique 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.`)
897
+ .description(`Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits).`)
898
+ .requiredOption(`--userId <userId>`, `Unique 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.`)
864
899
  .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
865
900
  .action(actionRunner(accountCreatePhoneSession))
866
901
 
@@ -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 avatars = new Command("avatars").description(commandDescriptions['avatars'])
13
+ const avatars = new Command("avatars").description(commandDescriptions['avatars']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
14
16
 
15
17
  const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
16
18
  /* @param {string} code */
@@ -0,0 +1,44 @@
1
+ const fs = require('fs');
2
+ const pathLib = require('path');
3
+ const tar = require("tar");
4
+ const ignore = require("ignore");
5
+ const { promisify } = require('util');
6
+ const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
8
+ const { Command } = require('commander');
9
+ const { sdkForProject, sdkForConsole } = require('../sdks')
10
+ const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
+ const { localConfig, globalConfig } = require("../config");
12
+
13
+ const console = new Command("console").description(commandDescriptions['console']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
16
+
17
+ const consoleVariables = async ({ parseOutput = true, sdk = undefined}) => {
18
+
19
+ let client = !sdk ? await sdkForProject() : sdk;
20
+ let path = '/console/variables';
21
+ let payload = {};
22
+ let response = undefined;
23
+ response = await client.call('get', path, {
24
+ 'content-type': 'application/json',
25
+ }, payload);
26
+
27
+ if (parseOutput) {
28
+ parse(response)
29
+ success()
30
+ }
31
+ return response;
32
+ }
33
+
34
+
35
+ console
36
+ .command(`variables`)
37
+ .description(`Get all Environment Variables that are relevant for the console.`)
38
+ .action(actionRunner(consoleVariables))
39
+
40
+
41
+ module.exports = {
42
+ console,
43
+ consoleVariables
44
+ };