appwrite-cli 1.2.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 (57) hide show
  1. package/README.md +4 -4
  2. package/docs/examples/account/create.md +1 -1
  3. package/docs/examples/account/update-password.md +1 -1
  4. package/docs/examples/console/variables.md +1 -0
  5. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  6. package/docs/examples/databases/get-document.md +2 -1
  7. package/docs/examples/databases/update-boolean-attribute.md +6 -0
  8. package/docs/examples/databases/update-datetime-attribute.md +6 -0
  9. package/docs/examples/databases/update-email-attribute.md +6 -0
  10. package/docs/examples/databases/update-enum-attribute.md +7 -0
  11. package/docs/examples/databases/update-float-attribute.md +8 -0
  12. package/docs/examples/databases/update-integer-attribute.md +8 -0
  13. package/docs/examples/databases/update-ip-attribute.md +6 -0
  14. package/docs/examples/databases/update-relationship-attribute.md +5 -0
  15. package/docs/examples/databases/update-string-attribute.md +6 -0
  16. package/docs/examples/databases/update-url-attribute.md +6 -0
  17. package/docs/examples/functions/create.md +1 -1
  18. package/docs/examples/functions/update.md +1 -1
  19. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  20. package/docs/examples/projects/update-auth-password-history.md +3 -0
  21. package/docs/examples/teams/create-membership.md +3 -1
  22. package/docs/examples/teams/get-prefs.md +2 -0
  23. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  24. package/docs/examples/teams/update-prefs.md +3 -0
  25. package/docs/examples/users/update-password.md +1 -1
  26. package/index.js +2 -0
  27. package/install.ps1 +2 -2
  28. package/install.sh +1 -1
  29. package/lib/client.js +7 -7
  30. package/lib/commands/account.js +40 -7
  31. package/lib/commands/console.js +44 -0
  32. package/lib/commands/databases.js +727 -103
  33. package/lib/commands/deploy.js +270 -146
  34. package/lib/commands/functions.js +35 -9
  35. package/lib/commands/generic.js +6 -3
  36. package/lib/commands/init.js +215 -179
  37. package/lib/commands/projects.js +139 -5
  38. package/lib/commands/storage.js +37 -9
  39. package/lib/commands/teams.js +102 -16
  40. package/lib/commands/users.js +51 -2
  41. package/lib/config.js +84 -6
  42. package/lib/parser.js +6 -2
  43. package/lib/questions.js +307 -280
  44. package/package.json +1 -1
  45. package/docs/examples/account/get-logs.md +0 -2
  46. package/docs/examples/account/get-sessions.md +0 -1
  47. package/docs/examples/functions/retry-build.md +0 -4
  48. package/docs/examples/locale/get-continents.md +0 -1
  49. package/docs/examples/locale/get-countries-e-u.md +0 -1
  50. package/docs/examples/locale/get-countries-phones.md +0 -1
  51. package/docs/examples/locale/get-countries.md +0 -1
  52. package/docs/examples/locale/get-currencies.md +0 -1
  53. package/docs/examples/locale/get-languages.md +0 -1
  54. package/docs/examples/teams/get-memberships.md +0 -4
  55. package/docs/examples/users/get-logs.md +0 -3
  56. package/docs/examples/users/get-memberships.md +0 -2
  57. package/docs/examples/users/get-sessions.md +0 -2
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Appwrite Command Line SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-1.2.1-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-1.3.0-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
8
8
 
9
- **This SDK is compatible with Appwrite server version 1.2.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
9
+ **This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
10
10
 
11
11
  Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
12
12
 
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
29
29
 
30
30
  ```sh
31
31
  $ appwrite -v
32
- 1.2.1
32
+ 2.0.0
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -58,7 +58,7 @@ $ iwr -useb https://appwrite.io/cli/install.ps1 | iex
58
58
  Once the installation completes, you can verify your install using
59
59
  ```
60
60
  $ appwrite -v
61
- 1.2.1
61
+ 2.0.0
62
62
  ```
63
63
 
64
64
  ## Getting Started
@@ -1,5 +1,5 @@
1
1
  appwrite account create \
2
2
  --userId [USER_ID] \
3
3
  --email email@example.com \
4
- --password password \
4
+ --password '' \
5
5
 
@@ -1,3 +1,3 @@
1
1
  appwrite account updatePassword \
2
- --password password \
2
+ --password '' \
3
3
 
@@ -0,0 +1 @@
1
+ appwrite console variables
@@ -0,0 +1,9 @@
1
+ appwrite databases createRelationshipAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --relatedCollectionId [RELATED_COLLECTION_ID] \
5
+ --type oneToOne \
6
+
7
+
8
+
9
+
@@ -1,4 +1,5 @@
1
1
  appwrite databases getDocument \
2
2
  --databaseId [DATABASE_ID] \
3
3
  --collectionId [COLLECTION_ID] \
4
- --documentId [DOCUMENT_ID]
4
+ --documentId [DOCUMENT_ID] \
5
+
@@ -0,0 +1,6 @@
1
+ appwrite databases updateBooleanAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default false
@@ -0,0 +1,6 @@
1
+ appwrite databases updateDatetimeAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default ''
@@ -0,0 +1,6 @@
1
+ appwrite databases updateEmailAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default email@example.com
@@ -0,0 +1,7 @@
1
+ appwrite databases updateEnumAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --elements one two three \
6
+ --required false \
7
+ --default [DEFAULT]
@@ -0,0 +1,8 @@
1
+ appwrite databases updateFloatAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --min null \
7
+ --max null \
8
+ --default null
@@ -0,0 +1,8 @@
1
+ appwrite databases updateIntegerAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --min null \
7
+ --max null \
8
+ --default null
@@ -0,0 +1,6 @@
1
+ appwrite databases updateIpAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default ''
@@ -0,0 +1,5 @@
1
+ appwrite databases updateRelationshipAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+
@@ -0,0 +1,6 @@
1
+ appwrite databases updateStringAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default [DEFAULT]
@@ -0,0 +1,6 @@
1
+ appwrite databases updateUrlAttribute \
2
+ --databaseId [DATABASE_ID] \
3
+ --collectionId [COLLECTION_ID] \
4
+ --key '' \
5
+ --required false \
6
+ --default https://example.com
@@ -1,9 +1,9 @@
1
1
  appwrite functions create \
2
2
  --functionId [FUNCTION_ID] \
3
3
  --name [NAME] \
4
- --execute "any" \
5
4
  --runtime node-14.5 \
6
5
 
7
6
 
8
7
 
9
8
 
9
+
@@ -1,7 +1,7 @@
1
1
  appwrite functions update \
2
2
  --functionId [FUNCTION_ID] \
3
3
  --name [NAME] \
4
- --execute "any" \
4
+
5
5
 
6
6
 
7
7
 
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthPasswordDictionary \
2
+ --projectId [PROJECT_ID] \
3
+ --enabled false
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthPasswordHistory \
2
+ --projectId [PROJECT_ID] \
3
+ --limit 0
@@ -1,6 +1,8 @@
1
1
  appwrite teams createMembership \
2
2
  --teamId [TEAM_ID] \
3
- --email email@example.com \
4
3
  --roles one two three \
5
4
  --url https://example.com \
6
5
 
6
+
7
+
8
+
@@ -0,0 +1,2 @@
1
+ appwrite teams getPrefs \
2
+ --teamId [TEAM_ID]
@@ -1,3 +1,3 @@
1
- appwrite teams update \
1
+ appwrite teams updateName \
2
2
  --teamId [TEAM_ID] \
3
3
  --name [NAME]
@@ -0,0 +1,3 @@
1
+ appwrite teams updatePrefs \
2
+ --teamId [TEAM_ID] \
3
+ --prefs '{ "key": "value" }'
@@ -1,3 +1,3 @@
1
1
  appwrite users updatePassword \
2
2
  --userId [USER_ID] \
3
- --password password
3
+ --password ''
package/index.js CHANGED
@@ -15,6 +15,7 @@ const { init } = require("./lib/commands/init");
15
15
  const { deploy } = require("./lib/commands/deploy");
16
16
  const { account } = require("./lib/commands/account");
17
17
  const { avatars } = require("./lib/commands/avatars");
18
+ const { console } = require("./lib/commands/console");
18
19
  const { databases } = require("./lib/commands/databases");
19
20
  const { functions } = require("./lib/commands/functions");
20
21
  const { graphql } = require("./lib/commands/graphql");
@@ -47,6 +48,7 @@ program
47
48
  .addCommand(logout)
48
49
  .addCommand(account)
49
50
  .addCommand(avatars)
51
+ .addCommand(console)
50
52
  .addCommand(databases)
51
53
  .addCommand(functions)
52
54
  .addCommand(graphql)
package/install.ps1 CHANGED
@@ -13,8 +13,8 @@
13
13
  # You can use "View source" of this page to see the full script.
14
14
 
15
15
  # REPO
16
- $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.2.1/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.2.1/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/2.0.0/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/2.0.0/appwrite-cli-win-arm64.exe"
18
18
 
19
19
  $APPWRITE_BINARY_NAME = "appwrite.exe"
20
20
 
package/install.sh CHANGED
@@ -97,7 +97,7 @@ printSuccess() {
97
97
  downloadBinary() {
98
98
  echo "[2/4] Downloading executable for $OS ($ARCH) ..."
99
99
 
100
- GITHUB_LATEST_VERSION="1.2.1"
100
+ GITHUB_LATEST_VERSION="2.0.0"
101
101
  GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102
102
  GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103
103
 
package/lib/client.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const os = require('os');
2
+ const https = require("https");
2
3
  const axios = require("axios");
3
4
  const JSONbig = require("json-bigint")({ storeAsString: false });
4
5
  const FormData = require("form-data");
@@ -15,8 +16,8 @@ class Client {
15
16
  'x-sdk-name': 'Command Line',
16
17
  'x-sdk-platform': 'console',
17
18
  'x-sdk-language': 'cli',
18
- 'x-sdk-version': '1.2.1',
19
- 'user-agent' : `AppwriteCLI/1.2.1 (${os.type()} ${os.version()}; ${os.arch()})`,
19
+ 'x-sdk-version': '2.0.0',
20
+ 'user-agent' : `AppwriteCLI/2.0.0 (${os.type()} ${os.version()}; ${os.arch()})`,
20
21
  'X-Appwrite-Response-Format' : '1.0.0',
21
22
  };
22
23
  }
@@ -150,11 +151,6 @@ class Client {
150
151
  params = {},
151
152
  responseType = "json"
152
153
  ) {
153
- if (this.selfSigned == true) {
154
- // Allow self signed requests
155
- process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
156
- }
157
-
158
154
  headers = Object.assign({}, this.headers, headers);
159
155
 
160
156
  let contentType = headers["content-type"].toLowerCase();
@@ -190,6 +186,10 @@ class Client {
190
186
  transformResponse: [ (data) => data ? JSONbig.parse(data) : data ],
191
187
  responseType: responseType,
192
188
  };
189
+ if (this.selfSigned == true) {
190
+ // Allow self signed requests
191
+ options.httpsAgent = new https.Agent({ rejectUnauthorized: false });
192
+ }
193
193
  try {
194
194
  let response = await axios(options);
195
195
  if (response.headers["set-cookie"]) {
@@ -42,18 +42,22 @@ const accountCreate = async ({ userId, email, password, name, parseOutput = true
42
42
  let payload = {};
43
43
 
44
44
  /** Body Params */
45
+
45
46
  if (typeof userId !== 'undefined') {
46
47
  payload['userId'] = userId;
47
48
  }
48
49
 
50
+
49
51
  if (typeof email !== 'undefined') {
50
52
  payload['email'] = email;
51
53
  }
52
54
 
55
+
53
56
  if (typeof password !== 'undefined') {
54
57
  payload['password'] = password;
55
58
  }
56
59
 
60
+
57
61
  if (typeof name !== 'undefined') {
58
62
  payload['name'] = name;
59
63
  }
@@ -79,10 +83,12 @@ const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = u
79
83
  let payload = {};
80
84
 
81
85
  /** Body Params */
86
+
82
87
  if (typeof email !== 'undefined') {
83
88
  payload['email'] = email;
84
89
  }
85
90
 
91
+
86
92
  if (typeof password !== 'undefined') {
87
93
  payload['password'] = password;
88
94
  }
@@ -147,6 +153,7 @@ const accountUpdateName = async ({ name, parseOutput = true, sdk = undefined}) =
147
153
  let payload = {};
148
154
 
149
155
  /** Body Params */
156
+
150
157
  if (typeof name !== 'undefined') {
151
158
  payload['name'] = name;
152
159
  }
@@ -172,10 +179,12 @@ const accountUpdatePassword = async ({ password, oldPassword, parseOutput = true
172
179
  let payload = {};
173
180
 
174
181
  /** Body Params */
182
+
175
183
  if (typeof password !== 'undefined') {
176
184
  payload['password'] = password;
177
185
  }
178
186
 
187
+
179
188
  if (typeof oldPassword !== 'undefined') {
180
189
  payload['oldPassword'] = oldPassword;
181
190
  }
@@ -201,10 +210,12 @@ const accountUpdatePhone = async ({ phone, password, parseOutput = true, sdk = u
201
210
  let payload = {};
202
211
 
203
212
  /** Body Params */
213
+
204
214
  if (typeof phone !== 'undefined') {
205
215
  payload['phone'] = phone;
206
216
  }
207
217
 
218
+
208
219
  if (typeof password !== 'undefined') {
209
220
  payload['password'] = password;
210
221
  }
@@ -271,10 +282,12 @@ const accountCreateRecovery = async ({ email, url, parseOutput = true, sdk = und
271
282
  let payload = {};
272
283
 
273
284
  /** Body Params */
285
+
274
286
  if (typeof email !== 'undefined') {
275
287
  payload['email'] = email;
276
288
  }
277
289
 
290
+
278
291
  if (typeof url !== 'undefined') {
279
292
  payload['url'] = url;
280
293
  }
@@ -302,18 +315,22 @@ const accountUpdateRecovery = async ({ userId, secret, password, passwordAgain,
302
315
  let payload = {};
303
316
 
304
317
  /** Body Params */
318
+
305
319
  if (typeof userId !== 'undefined') {
306
320
  payload['userId'] = userId;
307
321
  }
308
322
 
323
+
309
324
  if (typeof secret !== 'undefined') {
310
325
  payload['secret'] = secret;
311
326
  }
312
327
 
328
+
313
329
  if (typeof password !== 'undefined') {
314
330
  payload['password'] = password;
315
331
  }
316
332
 
333
+
317
334
  if (typeof passwordAgain !== 'undefined') {
318
335
  payload['passwordAgain'] = passwordAgain;
319
336
  }
@@ -390,10 +407,12 @@ const accountCreateEmailSession = async ({ email, password, parseOutput = true,
390
407
  let payload = {};
391
408
 
392
409
  /** Body Params */
410
+
393
411
  if (typeof email !== 'undefined') {
394
412
  payload['email'] = email;
395
413
  }
396
414
 
415
+
397
416
  if (typeof password !== 'undefined') {
398
417
  payload['password'] = password;
399
418
  }
@@ -420,14 +439,17 @@ const accountCreateMagicURLSession = async ({ userId, email, url, parseOutput =
420
439
  let payload = {};
421
440
 
422
441
  /** Body Params */
442
+
423
443
  if (typeof userId !== 'undefined') {
424
444
  payload['userId'] = userId;
425
445
  }
426
446
 
447
+
427
448
  if (typeof email !== 'undefined') {
428
449
  payload['email'] = email;
429
450
  }
430
451
 
452
+
431
453
  if (typeof url !== 'undefined') {
432
454
  payload['url'] = url;
433
455
  }
@@ -453,10 +475,12 @@ const accountUpdateMagicURLSession = async ({ userId, secret, parseOutput = true
453
475
  let payload = {};
454
476
 
455
477
  /** Body Params */
478
+
456
479
  if (typeof userId !== 'undefined') {
457
480
  payload['userId'] = userId;
458
481
  }
459
482
 
483
+
460
484
  if (typeof secret !== 'undefined') {
461
485
  payload['secret'] = secret;
462
486
  }
@@ -514,10 +538,12 @@ const accountCreatePhoneSession = async ({ userId, phone, parseOutput = true, sd
514
538
  let payload = {};
515
539
 
516
540
  /** Body Params */
541
+
517
542
  if (typeof userId !== 'undefined') {
518
543
  payload['userId'] = userId;
519
544
  }
520
545
 
546
+
521
547
  if (typeof phone !== 'undefined') {
522
548
  payload['phone'] = phone;
523
549
  }
@@ -543,10 +569,12 @@ const accountUpdatePhoneSession = async ({ userId, secret, parseOutput = true, s
543
569
  let payload = {};
544
570
 
545
571
  /** Body Params */
572
+
546
573
  if (typeof userId !== 'undefined') {
547
574
  payload['userId'] = userId;
548
575
  }
549
576
 
577
+
550
578
  if (typeof secret !== 'undefined') {
551
579
  payload['secret'] = secret;
552
580
  }
@@ -642,6 +670,7 @@ const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefi
642
670
  let payload = {};
643
671
 
644
672
  /** Body Params */
673
+
645
674
  if (typeof url !== 'undefined') {
646
675
  payload['url'] = url;
647
676
  }
@@ -667,10 +696,12 @@ const accountUpdateVerification = async ({ userId, secret, parseOutput = true, s
667
696
  let payload = {};
668
697
 
669
698
  /** Body Params */
699
+
670
700
  if (typeof userId !== 'undefined') {
671
701
  payload['userId'] = userId;
672
702
  }
673
703
 
704
+
674
705
  if (typeof secret !== 'undefined') {
675
706
  payload['secret'] = secret;
676
707
  }
@@ -713,10 +744,12 @@ const accountUpdatePhoneVerification = async ({ userId, secret, parseOutput = tr
713
744
  let payload = {};
714
745
 
715
746
  /** Body Params */
747
+
716
748
  if (typeof userId !== 'undefined') {
717
749
  payload['userId'] = userId;
718
750
  }
719
751
 
752
+
720
753
  if (typeof secret !== 'undefined') {
721
754
  payload['secret'] = secret;
722
755
  }
@@ -744,7 +777,7 @@ account
744
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).`)
745
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.`)
746
779
  .requiredOption(`--email <email>`, `User email.`)
747
- .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
780
+ .requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
748
781
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
749
782
  .action(actionRunner(accountCreate))
750
783
 
@@ -763,7 +796,7 @@ account
763
796
  account
764
797
  .command(`listLogs`)
765
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.`)
766
- .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`)
767
800
  .action(actionRunner(accountListLogs))
768
801
 
769
802
  account
@@ -830,14 +863,14 @@ account
830
863
 
831
864
  account
832
865
  .command(`createEmailSession`)
833
- .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#limits).`)
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).`)
834
867
  .requiredOption(`--email <email>`, `User email.`)
835
868
  .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
836
869
  .action(actionRunner(accountCreateEmailSession))
837
870
 
838
871
  account
839
872
  .command(`createMagicURLSession`)
840
- .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#limits).`)
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).`)
841
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.`)
842
875
  .requiredOption(`--email <email>`, `User email.`)
843
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.`)
@@ -852,16 +885,16 @@ account
852
885
 
853
886
  account
854
887
  .command(`createOAuth2Session`)
855
- .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#limits). `)
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). `)
856
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.`)
857
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.`)
858
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.`)
859
- .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.`)
860
893
  .action(actionRunner(accountCreateOAuth2Session))
861
894
 
862
895
  account
863
896
  .command(`createPhoneSession`)
864
- .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#limits).`)
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).`)
865
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.`)
866
899
  .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
867
900
  .action(actionRunner(accountCreatePhoneSession))
@@ -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
+ };