appwrite-cli 0.17.1 → 0.18.3

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 (81) 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/{database → databases}/create-boolean-attribute.md +2 -1
  9. package/docs/examples/{database → databases}/create-collection.md +2 -1
  10. package/docs/examples/{database → databases}/create-document.md +2 -1
  11. package/docs/examples/{database → databases}/create-email-attribute.md +2 -1
  12. package/docs/examples/{database → databases}/create-enum-attribute.md +2 -1
  13. package/docs/examples/{database → databases}/create-float-attribute.md +2 -1
  14. package/docs/examples/{database → databases}/create-index.md +2 -1
  15. package/docs/examples/{database → databases}/create-integer-attribute.md +2 -1
  16. package/docs/examples/{database → databases}/create-ip-attribute.md +2 -1
  17. package/docs/examples/{database → databases}/create-string-attribute.md +2 -1
  18. package/docs/examples/{database → databases}/create-url-attribute.md +2 -1
  19. package/docs/examples/databases/create.md +3 -0
  20. package/docs/examples/databases/delete-attribute.md +4 -0
  21. package/docs/examples/databases/delete-collection.md +3 -0
  22. package/docs/examples/{database → databases}/delete-document.md +2 -1
  23. package/docs/examples/databases/delete-index.md +4 -0
  24. package/docs/examples/databases/delete.md +2 -0
  25. package/docs/examples/databases/get-attribute.md +4 -0
  26. package/docs/examples/databases/get-collection-usage.md +4 -0
  27. package/docs/examples/databases/get-collection.md +3 -0
  28. package/docs/examples/databases/get-database-usage.md +3 -0
  29. package/docs/examples/{database → databases}/get-document.md +2 -1
  30. package/docs/examples/databases/get-index.md +4 -0
  31. package/docs/examples/databases/get-usage.md +2 -0
  32. package/docs/examples/databases/get.md +2 -0
  33. package/docs/examples/databases/list-attributes.md +3 -0
  34. package/docs/examples/databases/list-collection-logs.md +5 -0
  35. package/docs/examples/databases/list-collections.md +8 -0
  36. package/docs/examples/{database → databases}/list-document-logs.md +2 -1
  37. package/docs/examples/databases/list-documents.md +10 -0
  38. package/docs/examples/databases/list-indexes.md +3 -0
  39. package/docs/examples/databases/list-logs.md +4 -0
  40. package/docs/examples/databases/list.md +7 -0
  41. package/docs/examples/{database → databases}/update-collection.md +2 -1
  42. package/docs/examples/{database → databases}/update-document.md +3 -2
  43. package/docs/examples/databases/update.md +3 -0
  44. package/docs/examples/projects/create-key.md +2 -1
  45. package/docs/examples/projects/update-key.md +2 -1
  46. package/docs/examples/projects/update-webhook-signature.md +3 -0
  47. package/docs/examples/users/{update-verification.md → update-email-verification.md} +1 -1
  48. package/docs/examples/users/update-phone-verification.md +3 -0
  49. package/docs/examples/users/update-phone.md +3 -0
  50. package/index.js +2 -2
  51. package/install.ps1 +2 -2
  52. package/install.sh +1 -1
  53. package/lib/client.js +3 -3
  54. package/lib/commands/account.js +202 -31
  55. package/lib/commands/{database.js → databases.js} +477 -177
  56. package/lib/commands/deploy.js +153 -71
  57. package/lib/commands/functions.js +4 -4
  58. package/lib/commands/generic.js +2 -2
  59. package/lib/commands/init.js +42 -24
  60. package/lib/commands/projects.js +43 -4
  61. package/lib/commands/storage.js +3 -3
  62. package/lib/commands/teams.js +2 -2
  63. package/lib/commands/users.js +71 -5
  64. package/lib/parser.js +1 -1
  65. package/lib/questions.js +45 -3
  66. package/package.json +1 -1
  67. package/docs/examples/account/delete.md +0 -1
  68. package/docs/examples/database/delete-attribute.md +0 -3
  69. package/docs/examples/database/delete-collection.md +0 -2
  70. package/docs/examples/database/delete-index.md +0 -3
  71. package/docs/examples/database/get-attribute.md +0 -3
  72. package/docs/examples/database/get-collection-usage.md +0 -3
  73. package/docs/examples/database/get-collection.md +0 -2
  74. package/docs/examples/database/get-index.md +0 -3
  75. package/docs/examples/database/get-usage.md +0 -2
  76. package/docs/examples/database/list-attributes.md +0 -2
  77. package/docs/examples/database/list-collection-logs.md +0 -4
  78. package/docs/examples/database/list-collections.md +0 -7
  79. package/docs/examples/database/list-documents.md +0 -9
  80. package/docs/examples/database/list-indexes.md +0 -2
  81. package/docs/examples/health/get-queue-usage.md +0 -1
@@ -194,6 +194,35 @@ const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true
194
194
  return response;
195
195
  }
196
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
+
197
226
  const accountGetPrefs = async ({ parseOutput = true, sdk = undefined}) => {
198
227
 
199
228
  let client = !sdk ? await sdkForProject() : sdk;
@@ -320,25 +349,13 @@ const accountGetSessions = async ({ parseOutput = true, sdk = undefined}) => {
320
349
  return response;
321
350
  }
322
351
 
323
- const accountCreateSession = async ({ email, password, parseOutput = true, sdk = undefined}) => {
324
- /* @param {string} email */
325
- /* @param {string} password */
352
+ const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
326
353
 
327
354
  let client = !sdk ? await sdkForProject() : sdk;
328
355
  let path = '/account/sessions';
329
356
  let payload = {};
330
-
331
- /** Body Params */
332
- if (typeof email !== 'undefined') {
333
- payload['email'] = email;
334
- }
335
-
336
- if (typeof password !== 'undefined') {
337
- payload['password'] = password;
338
- }
339
-
340
357
  let response = undefined;
341
- response = await client.call('post', path, {
358
+ response = await client.call('delete', path, {
342
359
  'content-type': 'application/json',
343
360
  }, payload);
344
361
 
@@ -349,13 +366,13 @@ const accountCreateSession = async ({ email, password, parseOutput = true, sdk =
349
366
  return response;
350
367
  }
351
368
 
352
- const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) => {
369
+ const accountCreateAnonymousSession = async ({ parseOutput = true, sdk = undefined}) => {
353
370
 
354
371
  let client = !sdk ? await sdkForProject() : sdk;
355
- let path = '/account/sessions';
372
+ let path = '/account/sessions/anonymous';
356
373
  let payload = {};
357
374
  let response = undefined;
358
- response = await client.call('delete', path, {
375
+ response = await client.call('post', path, {
359
376
  'content-type': 'application/json',
360
377
  }, payload);
361
378
 
@@ -366,11 +383,23 @@ const accountDeleteSessions = async ({ parseOutput = true, sdk = undefined}) =>
366
383
  return response;
367
384
  }
368
385
 
369
- 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 */
370
389
 
371
390
  let client = !sdk ? await sdkForProject() : sdk;
372
- let path = '/account/sessions/anonymous';
391
+ let path = '/account/sessions/email';
373
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
+
374
403
  let response = undefined;
375
404
  response = await client.call('post', path, {
376
405
  'content-type': 'application/json',
@@ -478,6 +507,64 @@ const accountCreateOAuth2Session = async ({ provider, success, failure, scopes,
478
507
  return response;
479
508
  }
480
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
+
481
568
  const accountGetSession = async ({ sessionId, parseOutput = true, sdk = undefined}) => {
482
569
  /* @param {string} sessionId */
483
570
 
@@ -602,6 +689,52 @@ const accountUpdateVerification = async ({ userId, secret, parseOutput = true, s
602
689
  return response;
603
690
  }
604
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
+
605
738
 
606
739
  account
607
740
  .command(`get`)
@@ -649,6 +782,13 @@ account
649
782
  .option(`--oldPassword <oldPassword>`, `Current user password. Must be at least 8 chars.`)
650
783
  .action(actionRunner(accountUpdatePassword))
651
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
+
652
792
  account
653
793
  .command(`getPrefs`)
654
794
  .description(`Get currently logged in user preferences as a key-value object.`)
@@ -681,13 +821,6 @@ account
681
821
  .description(`Get currently logged in user list of active sessions across different devices.`)
682
822
  .action(actionRunner(accountGetSessions))
683
823
 
684
- account
685
- .command(`createSession`)
686
- .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.`)
687
- .requiredOption(`--email <email>`, `User email.`)
688
- .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
689
- .action(actionRunner(accountCreateSession))
690
-
691
824
  account
692
825
  .command(`deleteSessions`)
693
826
  .description(`Delete all sessions from the user account and remove any sessions cookies from the end client.`)
@@ -698,6 +831,13 @@ account
698
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).`)
699
832
  .action(actionRunner(accountCreateAnonymousSession))
700
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
+
701
841
  account
702
842
  .command(`createMagicURLSession`)
703
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.`)
@@ -716,12 +856,26 @@ account
716
856
  account
717
857
  .command(`createOAuth2Session`)
718
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.. `)
719
- .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, 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.`)
720
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.`)
721
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.`)
722
- .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 128 characters long.`)
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.`)
723
863
  .action(actionRunner(accountCreateOAuth2Session))
724
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
+
725
879
  account
726
880
  .command(`getSession`)
727
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.`)
@@ -747,7 +901,7 @@ account
747
901
 
748
902
  account
749
903
  .command(`createVerification`)
750
- .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. `)
751
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.`)
752
906
  .action(actionRunner(accountCreateVerification))
753
907
 
@@ -758,6 +912,18 @@ account
758
912
  .requiredOption(`--secret <secret>`, `Valid verification token.`)
759
913
  .action(actionRunner(accountUpdateVerification))
760
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
+
761
927
 
762
928
  module.exports = {
763
929
  account,
@@ -768,21 +934,26 @@ module.exports = {
768
934
  accountGetLogs,
769
935
  accountUpdateName,
770
936
  accountUpdatePassword,
937
+ accountUpdatePhone,
771
938
  accountGetPrefs,
772
939
  accountUpdatePrefs,
773
940
  accountCreateRecovery,
774
941
  accountUpdateRecovery,
775
942
  accountGetSessions,
776
- accountCreateSession,
777
943
  accountDeleteSessions,
778
944
  accountCreateAnonymousSession,
945
+ accountCreateEmailSession,
779
946
  accountCreateMagicURLSession,
780
947
  accountUpdateMagicURLSession,
781
948
  accountCreateOAuth2Session,
949
+ accountCreatePhoneSession,
950
+ accountUpdatePhoneSession,
782
951
  accountGetSession,
783
952
  accountUpdateSession,
784
953
  accountDeleteSession,
785
954
  accountUpdateStatus,
786
955
  accountCreateVerification,
787
- accountUpdateVerification
956
+ accountUpdateVerification,
957
+ accountCreatePhoneVerification,
958
+ accountUpdatePhoneVerification
788
959
  };