appwrite-cli 0.16.0 → 0.18.1

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 (90) hide show
  1. package/README.md +4 -16
  2. package/docs/examples/account/{create-session.md → create-email-session.md} +1 -1
  3. package/docs/examples/account/create-phone-session.md +3 -0
  4. package/docs/examples/account/create-phone-verification.md +1 -0
  5. package/docs/examples/account/update-phone-session.md +3 -0
  6. package/docs/examples/account/update-phone-verification.md +3 -0
  7. package/docs/examples/account/update-phone.md +3 -0
  8. package/docs/examples/account/update-status.md +1 -0
  9. package/docs/examples/{database → databases}/create-boolean-attribute.md +2 -1
  10. package/docs/examples/{database → databases}/create-collection.md +2 -1
  11. package/docs/examples/{database → databases}/create-document.md +2 -1
  12. package/docs/examples/{database → databases}/create-email-attribute.md +2 -1
  13. package/docs/examples/{database → databases}/create-enum-attribute.md +2 -1
  14. package/docs/examples/{database → databases}/create-float-attribute.md +2 -1
  15. package/docs/examples/{database → databases}/create-index.md +2 -1
  16. package/docs/examples/{database → databases}/create-integer-attribute.md +2 -1
  17. package/docs/examples/{database → databases}/create-ip-attribute.md +2 -1
  18. package/docs/examples/{database → databases}/create-string-attribute.md +2 -1
  19. package/docs/examples/{database → databases}/create-url-attribute.md +2 -1
  20. package/docs/examples/databases/create.md +3 -0
  21. package/docs/examples/databases/delete-attribute.md +4 -0
  22. package/docs/examples/databases/delete-collection.md +3 -0
  23. package/docs/examples/{database → databases}/delete-document.md +2 -1
  24. package/docs/examples/databases/delete-index.md +4 -0
  25. package/docs/examples/databases/delete.md +2 -0
  26. package/docs/examples/databases/get-attribute.md +4 -0
  27. package/docs/examples/databases/get-collection-usage.md +4 -0
  28. package/docs/examples/databases/get-collection.md +3 -0
  29. package/docs/examples/databases/get-database-usage.md +3 -0
  30. package/docs/examples/{database → databases}/get-document.md +2 -1
  31. package/docs/examples/databases/get-index.md +4 -0
  32. package/docs/examples/databases/get-usage.md +2 -0
  33. package/docs/examples/databases/get.md +2 -0
  34. package/docs/examples/databases/list-attributes.md +3 -0
  35. package/docs/examples/databases/list-collection-logs.md +5 -0
  36. package/docs/examples/databases/list-collections.md +8 -0
  37. package/docs/examples/{database → databases}/list-document-logs.md +2 -1
  38. package/docs/examples/databases/list-documents.md +10 -0
  39. package/docs/examples/databases/list-indexes.md +3 -0
  40. package/docs/examples/databases/list-logs.md +4 -0
  41. package/docs/examples/databases/list.md +7 -0
  42. package/docs/examples/{database → databases}/update-collection.md +2 -1
  43. package/docs/examples/{database → databases}/update-document.md +3 -2
  44. package/docs/examples/databases/update.md +3 -0
  45. package/docs/examples/projects/create-key.md +2 -1
  46. package/docs/examples/projects/update-key.md +2 -1
  47. package/docs/examples/projects/update-webhook-signature.md +3 -0
  48. package/docs/examples/teams/list-logs.md +4 -0
  49. package/docs/examples/users/get-memberships.md +2 -0
  50. package/docs/examples/users/{update-verification.md → update-email-verification.md} +1 -1
  51. package/docs/examples/users/update-phone-verification.md +3 -0
  52. package/docs/examples/users/update-phone.md +3 -0
  53. package/index.js +2 -2
  54. package/install.ps1 +9 -5
  55. package/install.sh +1 -1
  56. package/lib/client.js +6 -7
  57. package/lib/commands/account.js +230 -56
  58. package/lib/commands/avatars.js +12 -9
  59. package/lib/commands/{database.js → databases.js} +484 -181
  60. package/lib/commands/deploy.js +156 -73
  61. package/lib/commands/functions.js +26 -9
  62. package/lib/commands/generic.js +13 -6
  63. package/lib/commands/health.js +3 -23
  64. package/lib/commands/init.js +43 -24
  65. package/lib/commands/locale.js +3 -0
  66. package/lib/commands/projects.js +50 -8
  67. package/lib/commands/storage.js +8 -5
  68. package/lib/commands/teams.js +45 -5
  69. package/lib/commands/users.js +101 -7
  70. package/lib/config.js +6 -4
  71. package/lib/parser.js +1 -1
  72. package/lib/questions.js +87 -4
  73. package/lib/sdks.js +17 -1
  74. package/lib/utils.js +19 -0
  75. package/package.json +8 -6
  76. package/docs/examples/account/delete.md +0 -1
  77. package/docs/examples/database/delete-attribute.md +0 -3
  78. package/docs/examples/database/delete-collection.md +0 -2
  79. package/docs/examples/database/delete-index.md +0 -3
  80. package/docs/examples/database/get-attribute.md +0 -3
  81. package/docs/examples/database/get-collection-usage.md +0 -3
  82. package/docs/examples/database/get-collection.md +0 -2
  83. package/docs/examples/database/get-index.md +0 -3
  84. package/docs/examples/database/get-usage.md +0 -2
  85. package/docs/examples/database/list-attributes.md +0 -2
  86. package/docs/examples/database/list-collection-logs.md +0 -4
  87. package/docs/examples/database/list-collections.md +0 -7
  88. package/docs/examples/database/list-documents.md +0 -9
  89. package/docs/examples/database/list-indexes.md +0 -2
  90. package/docs/examples/health/get-queue-usage.md +0 -1
@@ -1,7 +1,10 @@
1
1
  const fs = require('fs');
2
+ const pathLib = require('path');
2
3
  const tar = require("tar");
4
+ const ignore = require("ignore");
3
5
  const { promisify } = require('util');
4
6
  const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
5
8
  const { Command } = require('commander');
6
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
7
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -65,23 +68,6 @@ const accountCreate = async ({ userId, email, password, name, parseOutput = true
65
68
  return response;
66
69
  }
67
70
 
68
- const accountDelete = async ({ parseOutput = true, sdk = undefined}) => {
69
-
70
- let client = !sdk ? await sdkForProject() : sdk;
71
- let path = '/account';
72
- let payload = {};
73
- let response = undefined;
74
- response = await client.call('delete', path, {
75
- 'content-type': 'application/json',
76
- }, payload);
77
-
78
- if (parseOutput) {
79
- parse(response)
80
- success()
81
- }
82
- return response;
83
- }
84
-
85
71
  const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = undefined}) => {
86
72
  /* @param {string} email */
87
73
  /* @param {string} password */
@@ -208,6 +194,35 @@ const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true
208
194
  return response;
209
195
  }
210
196
 
197
+ const accountUpdatePhone = async ({ number, password, parseOutput = true, sdk = undefined}) => {
198
+ /* @param {string} number */
199
+ /* @param {string} password */
200
+
201
+ let client = !sdk ? await sdkForProject() : sdk;
202
+ let path = '/account/phone';
203
+ let payload = {};
204
+
205
+ /** Body Params */
206
+ if (typeof number !== 'undefined') {
207
+ payload['number'] = number;
208
+ }
209
+
210
+ if (typeof password !== 'undefined') {
211
+ payload['password'] = password;
212
+ }
213
+
214
+ let response = undefined;
215
+ response = await client.call('patch', path, {
216
+ 'content-type': 'application/json',
217
+ }, payload);
218
+
219
+ if (parseOutput) {
220
+ parse(response)
221
+ success()
222
+ }
223
+ return response;
224
+ }
225
+
211
226
  const accountGetPrefs = async ({ parseOutput = true, sdk = undefined}) => {
212
227
 
213
228
  let client = !sdk ? await sdkForProject() : sdk;
@@ -334,25 +349,13 @@ const accountGetSessions = async ({ parseOutput = true, sdk = undefined}) => {
334
349
  return response;
335
350
  }
336
351
 
337
- const accountCreateSession = async ({ email, password, parseOutput = true, sdk = undefined}) => {
338
- /* @param {string} email */
339
- /* @param {string} password */
352
+ const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
340
353
 
341
354
  let client = !sdk ? await sdkForProject() : sdk;
342
355
  let path = '/account/sessions';
343
356
  let payload = {};
344
-
345
- /** Body Params */
346
- if (typeof email !== 'undefined') {
347
- payload['email'] = email;
348
- }
349
-
350
- if (typeof password !== 'undefined') {
351
- payload['password'] = password;
352
- }
353
-
354
357
  let response = undefined;
355
- response = await client.call('post', path, {
358
+ response = await client.call('delete', path, {
356
359
  'content-type': 'application/json',
357
360
  }, payload);
358
361
 
@@ -363,13 +366,13 @@ const accountCreateSession = async ({ email, password, parseOutput = true, sdk =
363
366
  return response;
364
367
  }
365
368
 
366
- const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
369
+ const accountCreateAnonymousSession = async ({ parseOutput = true, sdk = undefined}) => {
367
370
 
368
371
  let client = !sdk ? await sdkForProject() : sdk;
369
- let path = '/account/sessions';
372
+ let path = '/account/sessions/anonymous';
370
373
  let payload = {};
371
374
  let response = undefined;
372
- response = await client.call('delete', path, {
375
+ response = await client.call('post', path, {
373
376
  'content-type': 'application/json',
374
377
  }, payload);
375
378
 
@@ -380,11 +383,23 @@ const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) =>
380
383
  return response;
381
384
  }
382
385
 
383
- const accountCreateAnonymousSession = async ({ parseOutput = true, sdk = undefined}) => {
386
+ const accountCreateEmailSession = async ({ email, password, parseOutput = true, sdk = undefined}) => {
387
+ /* @param {string} email */
388
+ /* @param {string} password */
384
389
 
385
390
  let client = !sdk ? await sdkForProject() : sdk;
386
- let path = '/account/sessions/anonymous';
391
+ let path = '/account/sessions/email';
387
392
  let payload = {};
393
+
394
+ /** Body Params */
395
+ if (typeof email !== 'undefined') {
396
+ payload['email'] = email;
397
+ }
398
+
399
+ if (typeof password !== 'undefined') {
400
+ payload['password'] = password;
401
+ }
402
+
388
403
  let response = undefined;
389
404
  response = await client.call('post', path, {
390
405
  'content-type': 'application/json',
@@ -492,6 +507,64 @@ const accountCreateOAuth2Session = async ({ provider, success, failure, scopes,
492
507
  return response;
493
508
  }
494
509
 
510
+ const accountCreatePhoneSession = async ({ userId, number, parseOutput = true, sdk = undefined}) => {
511
+ /* @param {string} userId */
512
+ /* @param {string} number */
513
+
514
+ let client = !sdk ? await sdkForProject() : sdk;
515
+ let path = '/account/sessions/phone';
516
+ let payload = {};
517
+
518
+ /** Body Params */
519
+ if (typeof userId !== 'undefined') {
520
+ payload['userId'] = userId;
521
+ }
522
+
523
+ if (typeof number !== 'undefined') {
524
+ payload['number'] = number;
525
+ }
526
+
527
+ let response = undefined;
528
+ response = await client.call('post', path, {
529
+ 'content-type': 'application/json',
530
+ }, payload);
531
+
532
+ if (parseOutput) {
533
+ parse(response)
534
+ success()
535
+ }
536
+ return response;
537
+ }
538
+
539
+ const accountUpdatePhoneSession = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
540
+ /* @param {string} userId */
541
+ /* @param {string} secret */
542
+
543
+ let client = !sdk ? await sdkForProject() : sdk;
544
+ let path = '/account/sessions/phone';
545
+ let payload = {};
546
+
547
+ /** Body Params */
548
+ if (typeof userId !== 'undefined') {
549
+ payload['userId'] = userId;
550
+ }
551
+
552
+ if (typeof secret !== 'undefined') {
553
+ payload['secret'] = secret;
554
+ }
555
+
556
+ let response = undefined;
557
+ response = await client.call('put', path, {
558
+ 'content-type': 'application/json',
559
+ }, payload);
560
+
561
+ if (parseOutput) {
562
+ parse(response)
563
+ success()
564
+ }
565
+ return response;
566
+ }
567
+
495
568
  const accountGetSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
496
569
  /* @param {string} sessionId */
497
570
 
@@ -546,6 +619,23 @@ const accountDeleteSession = async ({ sessionId, parseOutput = true, sdk = undef
546
619
  return response;
547
620
  }
548
621
 
622
+ const accountUpdateStatus = async ({ parseOutput = true, sdk = undefined}) => {
623
+
624
+ let client = !sdk ? await sdkForProject() : sdk;
625
+ let path = '/account/status';
626
+ let payload = {};
627
+ let response = undefined;
628
+ response = await client.call('patch', path, {
629
+ 'content-type': 'application/json',
630
+ }, payload);
631
+
632
+ if (parseOutput) {
633
+ parse(response)
634
+ success()
635
+ }
636
+ return response;
637
+ }
638
+
549
639
  const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefined}) => {
550
640
  /* @param {string} url */
551
641
 
@@ -599,6 +689,52 @@ const accountUpdateVerification = async ({ userId, secret, parseOutput = true, s
599
689
  return response;
600
690
  }
601
691
 
692
+ const accountCreatePhoneVerification = async ({ parseOutput = true, sdk = undefined}) => {
693
+
694
+ let client = !sdk ? await sdkForProject() : sdk;
695
+ let path = '/account/verification/phone';
696
+ let payload = {};
697
+ let response = undefined;
698
+ response = await client.call('post', path, {
699
+ 'content-type': 'application/json',
700
+ }, payload);
701
+
702
+ if (parseOutput) {
703
+ parse(response)
704
+ success()
705
+ }
706
+ return response;
707
+ }
708
+
709
+ const accountUpdatePhoneVerification = async ({ userId, secret, parseOutput = true, sdk = undefined}) => {
710
+ /* @param {string} userId */
711
+ /* @param {string} secret */
712
+
713
+ let client = !sdk ? await sdkForProject() : sdk;
714
+ let path = '/account/verification/phone';
715
+ let payload = {};
716
+
717
+ /** Body Params */
718
+ if (typeof userId !== 'undefined') {
719
+ payload['userId'] = userId;
720
+ }
721
+
722
+ if (typeof secret !== 'undefined') {
723
+ payload['secret'] = secret;
724
+ }
725
+
726
+ let response = undefined;
727
+ response = await client.call('put', path, {
728
+ 'content-type': 'application/json',
729
+ }, payload);
730
+
731
+ if (parseOutput) {
732
+ parse(response)
733
+ success()
734
+ }
735
+ return response;
736
+ }
737
+
602
738
 
603
739
  account
604
740
  .command(`get`)
@@ -614,11 +750,6 @@ account
614
750
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
615
751
  .action(actionRunner(accountCreate))
616
752
 
617
- account
618
- .command(`delete`)
619
- .description(`Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately.`)
620
- .action(actionRunner(accountDelete))
621
-
622
753
  account
623
754
  .command(`updateEmail`)
624
755
  .description(`Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. `)
@@ -646,11 +777,18 @@ account
646
777
 
647
778
  account
648
779
  .command(`updatePassword`)
649
- .description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and Team Invites, oldPassword is optional.`)
780
+ .description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.`)
650
781
  .requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
651
782
  .option(`--oldPassword <oldPassword>`, `Current user password. Must be at least 8 chars.`)
652
783
  .action(actionRunner(accountUpdatePassword))
653
784
 
785
+ account
786
+ .command(`updatePhone`)
787
+ .description(`Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) endpoint to send a confirmation SMS.`)
788
+ .requiredOption(`--number <number>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
789
+ .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
790
+ .action(actionRunner(accountUpdatePhone))
791
+
654
792
  account
655
793
  .command(`getPrefs`)
656
794
  .description(`Get currently logged in user preferences as a key-value object.`)
@@ -683,13 +821,6 @@ account
683
821
  .description(`Get currently logged in user list of active sessions across different devices.`)
684
822
  .action(actionRunner(accountGetSessions))
685
823
 
686
- account
687
- .command(`createSession`)
688
- .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.`)
689
- .requiredOption(`--email <email>`, `User email.`)
690
- .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
691
- .action(actionRunner(accountCreateSession))
692
-
693
824
  account
694
825
  .command(`deleteSessions`)
695
826
  .description(`Delete all sessions from the user account and remove any sessions cookies from the end client.`)
@@ -700,6 +831,13 @@ account
700
831
  .description(`Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 session](/docs/client/account#accountCreateOAuth2Session).`)
701
832
  .action(actionRunner(accountCreateAnonymousSession))
702
833
 
834
+ account
835
+ .command(`createEmailSession`)
836
+ .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.`)
837
+ .requiredOption(`--email <email>`, `User email.`)
838
+ .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
839
+ .action(actionRunner(accountCreateEmailSession))
840
+
703
841
  account
704
842
  .command(`createMagicURLSession`)
705
843
  .description(`Sends the user an email with a secret key for creating a session. 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.`)
@@ -718,12 +856,26 @@ account
718
856
  account
719
857
  .command(`createOAuth2Session`)
720
858
  .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.. `)
721
- .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress, stripe.`)
859
+ .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, autodesk, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.`)
722
860
  .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.`)
723
861
  .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.`)
724
- .option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.`)
862
+ .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.`)
725
863
  .action(actionRunner(accountCreateOAuth2Session))
726
864
 
865
+ account
866
+ .command(`createPhoneSession`)
867
+ .description(`Sends the user an SMS with a secret key for creating a session. 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.`)
868
+ .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.`)
869
+ .requiredOption(`--number <number>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
870
+ .action(actionRunner(accountCreatePhoneSession))
871
+
872
+ account
873
+ .command(`updatePhoneSession`)
874
+ .description(`Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](/docs/client/account#accountCreatePhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session.`)
875
+ .requiredOption(`--userId <userId>`, `User ID.`)
876
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
877
+ .action(actionRunner(accountUpdatePhoneSession))
878
+
727
879
  account
728
880
  .command(`getSession`)
729
881
  .description(`Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.`)
@@ -732,7 +884,7 @@ account
732
884
 
733
885
  account
734
886
  .command(`updateSession`)
735
- .description(``)
887
+ .description(`Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token.`)
736
888
  .requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to update the current device session.`)
737
889
  .action(actionRunner(accountUpdateSession))
738
890
 
@@ -742,9 +894,14 @@ account
742
894
  .requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to delete the current device session.`)
743
895
  .action(actionRunner(accountDeleteSession))
744
896
 
897
+ account
898
+ .command(`updateStatus`)
899
+ .description(`Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.`)
900
+ .action(actionRunner(accountUpdateStatus))
901
+
745
902
  account
746
903
  .command(`createVerification`)
747
- .description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateVerification). The verification link sent to the user's email address is valid for 7 days. Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. `)
904
+ .description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateEmailVerification). The verification link sent to the user's email address is valid for 7 days. Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. `)
748
905
  .requiredOption(`--url <url>`, `URL to redirect the user back to your app from the verification email. 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.`)
749
906
  .action(actionRunner(accountCreateVerification))
750
907
 
@@ -755,31 +912,48 @@ account
755
912
  .requiredOption(`--secret <secret>`, `Valid verification token.`)
756
913
  .action(actionRunner(accountUpdateVerification))
757
914
 
915
+ account
916
+ .command(`createPhoneVerification`)
917
+ .description(`Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) endpoint. Learn more about how to [complete the verification process](/docs/client/account#accountUpdatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes.`)
918
+ .action(actionRunner(accountCreatePhoneVerification))
919
+
920
+ account
921
+ .command(`updatePhoneVerification`)
922
+ .description(`Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code.`)
923
+ .requiredOption(`--userId <userId>`, `User ID.`)
924
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
925
+ .action(actionRunner(accountUpdatePhoneVerification))
926
+
758
927
 
759
928
  module.exports = {
760
929
  account,
761
930
  accountGet,
762
931
  accountCreate,
763
- accountDelete,
764
932
  accountUpdateEmail,
765
933
  accountCreateJWT,
766
934
  accountGetLogs,
767
935
  accountUpdateName,
768
936
  accountUpdatePassword,
937
+ accountUpdatePhone,
769
938
  accountGetPrefs,
770
939
  accountUpdatePrefs,
771
940
  accountCreateRecovery,
772
941
  accountUpdateRecovery,
773
942
  accountGetSessions,
774
- accountCreateSession,
775
943
  accountDeleteSessions,
776
944
  accountCreateAnonymousSession,
945
+ accountCreateEmailSession,
777
946
  accountCreateMagicURLSession,
778
947
  accountUpdateMagicURLSession,
779
948
  accountCreateOAuth2Session,
949
+ accountCreatePhoneSession,
950
+ accountUpdatePhoneSession,
780
951
  accountGetSession,
781
952
  accountUpdateSession,
782
953
  accountDeleteSession,
954
+ accountUpdateStatus,
783
955
  accountCreateVerification,
784
- accountUpdateVerification
956
+ accountUpdateVerification,
957
+ accountCreatePhoneVerification,
958
+ accountUpdatePhoneVerification
785
959
  };
@@ -1,7 +1,10 @@
1
1
  const fs = require('fs');
2
+ const pathLib = require('path');
2
3
  const tar = require("tar");
4
+ const ignore = require("ignore");
3
5
  const { promisify } = require('util');
4
6
  const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
5
8
  const { Command } = require('commander');
6
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
7
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -271,7 +274,7 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
271
274
 
272
275
  avatars
273
276
  .command(`getBrowser`)
274
- .description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user /account/sessions endpoint. Use width, height and quality arguments to change the output settings.`)
277
+ .description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.`)
275
278
  .requiredOption(`--code <code>`, `Browser Code.`)
276
279
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
277
280
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -281,7 +284,7 @@ avatars
281
284
 
282
285
  avatars
283
286
  .command(`getCreditCard`)
284
- .description(`The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings.`)
287
+ .description(`The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
285
288
  .requiredOption(`--code <code>`, `Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.`)
286
289
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
287
290
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -298,7 +301,7 @@ avatars
298
301
 
299
302
  avatars
300
303
  .command(`getFlag`)
301
- .description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings.`)
304
+ .description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
302
305
  .requiredOption(`--code <code>`, `Country Code. ISO Alpha-2 country code format.`)
303
306
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
304
307
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -308,16 +311,16 @@ avatars
308
311
 
309
312
  avatars
310
313
  .command(`getImage`)
311
- .description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.`)
314
+ .description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. `)
312
315
  .requiredOption(`--url <url>`, `Image URL which you want to crop.`)
313
- .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000.`, parseInteger)
314
- .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000.`, parseInteger)
316
+ .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
317
+ .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
315
318
  .requiredOption(`--destination <path>`, `output file path.`)
316
319
  .action(actionRunner(avatarsGetImage))
317
320
 
318
321
  avatars
319
322
  .command(`getInitials`)
320
- .description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials.`)
323
+ .description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
321
324
  .option(`--name <name>`, `Full Name. When empty, current user name or email will be used. Max length: 128 chars.`)
322
325
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
323
326
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -328,9 +331,9 @@ avatars
328
331
 
329
332
  avatars
330
333
  .command(`getQR`)
331
- .description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image.`)
334
+ .description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. `)
332
335
  .requiredOption(`--text <text>`, `Plain text to be converted to QR code image.`)
333
- .option(`--size <size>`, `QR code size. Pass an integer between 0 to 1000. Defaults to 400.`, parseInteger)
336
+ .option(`--size <size>`, `QR code size. Pass an integer between 1 to 1000. Defaults to 400.`, parseInteger)
334
337
  .option(`--margin <margin>`, `Margin from edge. Pass an integer between 0 to 10. Defaults to 1.`, parseInteger)
335
338
  .option(`--download <download>`, `Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.`, parseBool)
336
339
  .requiredOption(`--destination <path>`, `output file path.`)