appwrite-cli 0.18.5 → 1.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 (79) hide show
  1. package/.github/workflows/npm-publish.yml +8 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +4 -4
  4. package/appwrite.json +4 -0
  5. package/docs/examples/account/create-phone-session.md +1 -1
  6. package/docs/examples/account/get-logs.md +0 -1
  7. package/docs/examples/account/list-logs.md +2 -0
  8. package/docs/examples/account/list-sessions.md +1 -0
  9. package/docs/examples/account/update-phone.md +1 -1
  10. package/docs/examples/avatars/get-initials.md +0 -1
  11. package/docs/examples/databases/create-collection.md +2 -3
  12. package/docs/examples/databases/create-datetime-attribute.md +7 -0
  13. package/docs/examples/databases/create-document.md +0 -1
  14. package/docs/examples/databases/list-collection-logs.md +0 -1
  15. package/docs/examples/databases/list-collections.md +0 -4
  16. package/docs/examples/databases/list-document-logs.md +0 -1
  17. package/docs/examples/databases/list-documents.md +0 -6
  18. package/docs/examples/databases/list-logs.md +0 -1
  19. package/docs/examples/databases/list.md +0 -4
  20. package/docs/examples/databases/update-collection.md +0 -1
  21. package/docs/examples/databases/update-document.md +0 -1
  22. package/docs/examples/functions/create-variable.md +4 -0
  23. package/docs/examples/functions/create.md +1 -1
  24. package/docs/examples/functions/delete-variable.md +3 -0
  25. package/docs/examples/functions/get-function-usage.md +3 -0
  26. package/docs/examples/functions/get-usage.md +0 -1
  27. package/docs/examples/functions/get-variable.md +3 -0
  28. package/docs/examples/functions/list-deployments.md +0 -4
  29. package/docs/examples/functions/list-executions.md +0 -3
  30. package/docs/examples/functions/list-variables.md +2 -0
  31. package/docs/examples/functions/list.md +0 -4
  32. package/docs/examples/functions/update-variable.md +5 -0
  33. package/docs/examples/functions/update.md +1 -1
  34. package/docs/examples/locale/list-continents.md +1 -0
  35. package/docs/examples/locale/list-countries-e-u.md +1 -0
  36. package/docs/examples/locale/list-countries-phones.md +1 -0
  37. package/docs/examples/locale/list-countries.md +1 -0
  38. package/docs/examples/locale/list-currencies.md +1 -0
  39. package/docs/examples/locale/list-languages.md +1 -0
  40. package/docs/examples/projects/list.md +0 -4
  41. package/docs/examples/storage/create-bucket.md +1 -1
  42. package/docs/examples/storage/create-file.md +0 -1
  43. package/docs/examples/storage/list-buckets.md +0 -4
  44. package/docs/examples/storage/list-files.md +0 -4
  45. package/docs/examples/storage/update-bucket.md +1 -1
  46. package/docs/examples/storage/update-file.md +0 -1
  47. package/docs/examples/teams/get-memberships.md +0 -4
  48. package/docs/examples/teams/list-logs.md +0 -1
  49. package/docs/examples/teams/list-memberships.md +4 -0
  50. package/docs/examples/teams/list.md +0 -4
  51. package/docs/examples/users/create-argon2user.md +5 -0
  52. package/docs/examples/users/create-bcrypt-user.md +5 -0
  53. package/docs/examples/users/create-m-d5user.md +5 -0
  54. package/docs/examples/users/create-p-h-pass-user.md +5 -0
  55. package/docs/examples/users/create-s-h-a-user.md +6 -0
  56. package/docs/examples/users/create-scrypt-modified-user.md +8 -0
  57. package/docs/examples/users/create-scrypt-user.md +10 -0
  58. package/docs/examples/users/create.md +3 -2
  59. package/docs/examples/users/get-logs.md +0 -1
  60. package/docs/examples/users/list-logs.md +3 -0
  61. package/docs/examples/users/list-memberships.md +2 -0
  62. package/docs/examples/users/list-sessions.md +2 -0
  63. package/docs/examples/users/list.md +0 -4
  64. package/install.ps1 +2 -2
  65. package/install.sh +1 -1
  66. package/lib/client.js +7 -3
  67. package/lib/commands/account.js +24 -29
  68. package/lib/commands/avatars.js +2 -7
  69. package/lib/commands/databases.js +154 -210
  70. package/lib/commands/deploy.js +12 -3
  71. package/lib/commands/functions.js +227 -93
  72. package/lib/commands/generic.js +3 -3
  73. package/lib/commands/locale.js +24 -24
  74. package/lib/commands/projects.js +10 -30
  75. package/lib/commands/storage.js +53 -105
  76. package/lib/commands/teams.js +20 -65
  77. package/lib/commands/users.js +425 -47
  78. package/lib/questions.js +1 -1
  79. package/package.json +1 -1
@@ -114,20 +114,16 @@ const accountCreateJWT = async ({ parseOutput = true, sdk = undefined}) => {
114
114
  return response;
115
115
  }
116
116
 
117
- const accountGetLogs = async ({ limit, offset, parseOutput = true, sdk = undefined}) => {
118
- /* @param {number} limit */
119
- /* @param {number} offset */
117
+ const accountListLogs = async ({ queries, parseOutput = true, sdk = undefined}) => {
118
+ /* @param {string[]} queries */
120
119
 
121
120
  let client = !sdk ? await sdkForProject() : sdk;
122
121
  let path = '/account/logs';
123
122
  let payload = {};
124
123
 
125
124
  /** Query Params */
126
- if (typeof limit !== 'undefined') {
127
- payload['limit'] = limit;
128
- }
129
- if (typeof offset !== 'undefined') {
130
- payload['offset'] = offset;
125
+ if (typeof queries !== 'undefined') {
126
+ payload['queries'] = queries;
131
127
  }
132
128
  let response = undefined;
133
129
  response = await client.call('get', path, {
@@ -194,8 +190,8 @@ const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true
194
190
  return response;
195
191
  }
196
192
 
197
- const accountUpdatePhone = async ({ number, password, parseOutput = true, sdk = undefined}) => {
198
- /* @param {string} number */
193
+ const accountUpdatePhone = async ({ phone, password, parseOutput = true, sdk = undefined}) => {
194
+ /* @param {string} phone */
199
195
  /* @param {string} password */
200
196
 
201
197
  let client = !sdk ? await sdkForProject() : sdk;
@@ -203,8 +199,8 @@ const accountUpdatePhone = async ({ number, password, parseOutput = true, sdk =
203
199
  let payload = {};
204
200
 
205
201
  /** Body Params */
206
- if (typeof number !== 'undefined') {
207
- payload['number'] = number;
202
+ if (typeof phone !== 'undefined') {
203
+ payload['phone'] = phone;
208
204
  }
209
205
 
210
206
  if (typeof password !== 'undefined') {
@@ -332,7 +328,7 @@ const accountUpdateRecovery = async ({ userId, secret, password, passwordAgain,
332
328
  return response;
333
329
  }
334
330
 
335
- const accountGetSessions = async ({ parseOutput = true, sdk = undefined}) => {
331
+ const accountListSessions = async ({ parseOutput = true, sdk = undefined}) => {
336
332
 
337
333
  let client = !sdk ? await sdkForProject() : sdk;
338
334
  let path = '/account/sessions';
@@ -507,9 +503,9 @@ const accountCreateOAuth2Session = async ({ provider, success, failure, scopes,
507
503
  return response;
508
504
  }
509
505
 
510
- const accountCreatePhoneSession = async ({ userId, number, parseOutput = true, sdk = undefined}) => {
506
+ const accountCreatePhoneSession = async ({ userId, phone, parseOutput = true, sdk = undefined}) => {
511
507
  /* @param {string} userId */
512
- /* @param {string} number */
508
+ /* @param {string} phone */
513
509
 
514
510
  let client = !sdk ? await sdkForProject() : sdk;
515
511
  let path = '/account/sessions/phone';
@@ -520,8 +516,8 @@ const accountCreatePhoneSession = async ({ userId, number, parseOutput = true, s
520
516
  payload['userId'] = userId;
521
517
  }
522
518
 
523
- if (typeof number !== 'undefined') {
524
- payload['number'] = number;
519
+ if (typeof phone !== 'undefined') {
520
+ payload['phone'] = phone;
525
521
  }
526
522
 
527
523
  let response = undefined;
@@ -763,11 +759,10 @@ account
763
759
  .action(actionRunner(accountCreateJWT))
764
760
 
765
761
  account
766
- .command(`getLogs`)
762
+ .command(`listLogs`)
767
763
  .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.`)
768
- .option(`--limit <limit>`, `Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
769
- .option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
770
- .action(actionRunner(accountGetLogs))
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`)
765
+ .action(actionRunner(accountListLogs))
771
766
 
772
767
  account
773
768
  .command(`updateName`)
@@ -785,7 +780,7 @@ account
785
780
  account
786
781
  .command(`updatePhone`)
787
782
  .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.`)
783
+ .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
789
784
  .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
790
785
  .action(actionRunner(accountUpdatePhone))
791
786
 
@@ -817,9 +812,9 @@ account
817
812
  .action(actionRunner(accountUpdateRecovery))
818
813
 
819
814
  account
820
- .command(`getSessions`)
815
+ .command(`listSessions`)
821
816
  .description(`Get currently logged in user list of active sessions across different devices.`)
822
- .action(actionRunner(accountGetSessions))
817
+ .action(actionRunner(accountListSessions))
823
818
 
824
819
  account
825
820
  .command(`deleteSessions`)
@@ -840,7 +835,7 @@ account
840
835
 
841
836
  account
842
837
  .command(`createMagicURLSession`)
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.`)
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.`)
844
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.`)
845
840
  .requiredOption(`--email <email>`, `User email.`)
846
841
  .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.`)
@@ -856,7 +851,7 @@ account
856
851
  account
857
852
  .command(`createOAuth2Session`)
858
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.. `)
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.`)
854
+ .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.`)
860
855
  .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.`)
861
856
  .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.`)
862
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.`)
@@ -866,7 +861,7 @@ account
866
861
  .command(`createPhoneSession`)
867
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.`)
868
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.`)
869
- .requiredOption(`--number <number>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
864
+ .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
870
865
  .action(actionRunner(accountCreatePhoneSession))
871
866
 
872
867
  account
@@ -931,7 +926,7 @@ module.exports = {
931
926
  accountCreate,
932
927
  accountUpdateEmail,
933
928
  accountCreateJWT,
934
- accountGetLogs,
929
+ accountListLogs,
935
930
  accountUpdateName,
936
931
  accountUpdatePassword,
937
932
  accountUpdatePhone,
@@ -939,7 +934,7 @@ module.exports = {
939
934
  accountUpdatePrefs,
940
935
  accountCreateRecovery,
941
936
  accountUpdateRecovery,
942
- accountGetSessions,
937
+ accountListSessions,
943
938
  accountDeleteSessions,
944
939
  accountCreateAnonymousSession,
945
940
  accountCreateEmailSession,
@@ -187,11 +187,10 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
187
187
  }
188
188
  }
189
189
 
190
- const avatarsGetInitials = async ({ name, width, height, color, background, parseOutput = true, sdk = undefined, destination}) => {
190
+ const avatarsGetInitials = async ({ name, width, height, background, parseOutput = true, sdk = undefined, destination}) => {
191
191
  /* @param {string} name */
192
192
  /* @param {number} width */
193
193
  /* @param {number} height */
194
- /* @param {string} color */
195
194
  /* @param {string} background */
196
195
 
197
196
  let client = !sdk ? await sdkForProject() : sdk;
@@ -208,9 +207,6 @@ const avatarsGetInitials = async ({ name, width, height, color, background, pars
208
207
  if (typeof height !== 'undefined') {
209
208
  payload['height'] = height;
210
209
  }
211
- if (typeof color !== 'undefined') {
212
- payload['color'] = color;
213
- }
214
210
  if (typeof background !== 'undefined') {
215
211
  payload['background'] = background;
216
212
  }
@@ -301,7 +297,7 @@ avatars
301
297
 
302
298
  avatars
303
299
  .command(`getFlag`)
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. `)
300
+ .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. Country codes follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. 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. `)
305
301
  .requiredOption(`--code <code>`, `Country Code. ISO Alpha-2 country code format.`)
306
302
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
307
303
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -324,7 +320,6 @@ avatars
324
320
  .option(`--name <name>`, `Full Name. When empty, current user name or email will be used. Max length: 128 chars.`)
325
321
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
326
322
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
327
- .option(`--color <color>`, `Changes text color. By default a random color will be picked and stay will persistent to the given name.`)
328
323
  .option(`--background <background>`, `Changes background color. By default a random color will be picked and stay will persistent to the given name.`)
329
324
  .requiredOption(`--destination <path>`, `output file path.`)
330
325
  .action(actionRunner(avatarsGetInitials))