appwrite-cli 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/Formula/appwrite.rb +1 -1
  2. package/LICENSE.md +2 -2
  3. package/README.md +4 -4
  4. package/docs/examples/account/create-phone-session.md +1 -1
  5. package/docs/examples/account/create.md +1 -1
  6. package/docs/examples/account/update-password.md +1 -1
  7. package/docs/examples/account/update-phone.md +1 -1
  8. package/docs/examples/console/variables.md +1 -0
  9. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  10. package/docs/examples/databases/get-document.md +2 -1
  11. package/docs/examples/databases/update-boolean-attribute.md +6 -0
  12. package/docs/examples/databases/update-datetime-attribute.md +6 -0
  13. package/docs/examples/databases/update-email-attribute.md +6 -0
  14. package/docs/examples/databases/update-enum-attribute.md +7 -0
  15. package/docs/examples/databases/update-float-attribute.md +8 -0
  16. package/docs/examples/databases/update-integer-attribute.md +8 -0
  17. package/docs/examples/databases/update-ip-attribute.md +6 -0
  18. package/docs/examples/databases/update-relationship-attribute.md +5 -0
  19. package/docs/examples/databases/update-string-attribute.md +6 -0
  20. package/docs/examples/databases/update-url-attribute.md +6 -0
  21. package/docs/examples/functions/{retry-build.md → create-build.md} +1 -1
  22. package/docs/examples/functions/create.md +1 -1
  23. package/docs/examples/functions/update.md +1 -1
  24. package/docs/examples/graphql/mutation.md +2 -0
  25. package/docs/examples/graphql/query.md +2 -0
  26. package/docs/examples/projects/create.md +1 -0
  27. package/docs/examples/projects/update-auth-duration.md +3 -0
  28. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  29. package/docs/examples/projects/update-auth-password-history.md +3 -0
  30. package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
  31. package/docs/examples/projects/update-o-auth2.md +1 -0
  32. package/docs/examples/teams/create-membership.md +3 -1
  33. package/docs/examples/teams/get-prefs.md +2 -0
  34. package/docs/examples/teams/{update.md → update-name.md} +1 -1
  35. package/docs/examples/teams/update-prefs.md +3 -0
  36. package/docs/examples/users/update-password.md +1 -1
  37. package/docs/examples/users/update-phone.md +1 -1
  38. package/index.js +16 -1
  39. package/install.ps1 +2 -2
  40. package/install.sh +1 -1
  41. package/lib/client.js +7 -7
  42. package/lib/commands/account.js +46 -11
  43. package/lib/commands/avatars.js +3 -1
  44. package/lib/commands/console.js +44 -0
  45. package/lib/commands/databases.js +735 -109
  46. package/lib/commands/deploy.js +350 -141
  47. package/lib/commands/functions.js +44 -16
  48. package/lib/commands/generic.js +15 -3
  49. package/lib/commands/graphql.js +85 -0
  50. package/lib/commands/health.js +3 -1
  51. package/lib/commands/init.js +224 -162
  52. package/lib/commands/locale.js +3 -1
  53. package/lib/commands/projects.js +223 -9
  54. package/lib/commands/storage.js +43 -13
  55. package/lib/commands/teams.js +107 -19
  56. package/lib/commands/users.js +62 -11
  57. package/lib/config.js +122 -5
  58. package/lib/parser.js +7 -2
  59. package/lib/questions.js +311 -257
  60. package/package.json +1 -1
@@ -4,7 +4,7 @@ class Appwrite < Formula
4
4
  desc "CLI is a Node based command-line tool for Appwrite API"
5
5
  homepage "https://appwrite.io"
6
6
  license "BSD-3-Clause"
7
- head "https://github.com/appwrite/sdk-for-cli.git", branch: "main"
7
+ head "https://github.com/appwrite/sdk-for-cli.git", branch: "master"
8
8
 
9
9
  depends_on "node"
10
10
 
package/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors.
1
+ Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification,
7
7
 
8
8
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
9
 
10
- 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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.0.0-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.0.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.1.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.1.1
61
+ 2.0.0
62
62
  ```
63
63
 
64
64
  ## Getting Started
@@ -1,3 +1,3 @@
1
1
  appwrite account createPhoneSession \
2
2
  --userId [USER_ID] \
3
- --phone ''
3
+ --phone +12065550100
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  appwrite account updatePhone \
2
- --phone '' \
2
+ --phone +12065550100 \
3
3
  --password password
@@ -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,4 +1,4 @@
1
- appwrite functions retryBuild \
1
+ appwrite functions createBuild \
2
2
  --functionId [FUNCTION_ID] \
3
3
  --deploymentId [DEPLOYMENT_ID] \
4
4
  --buildId [BUILD_ID]
@@ -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,2 @@
1
+ appwrite graphql mutation \
2
+ --query '{ "key": "value" }'
@@ -0,0 +1,2 @@
1
+ appwrite graphql query \
2
+ --query '{ "key": "value" }'
@@ -11,3 +11,4 @@ appwrite projects create \
11
11
 
12
12
 
13
13
 
14
+
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthDuration \
2
+ --projectId [PROJECT_ID] \
3
+ --duration 0
@@ -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
@@ -0,0 +1,3 @@
1
+ appwrite projects updateAuthSessionsLimit \
2
+ --projectId [PROJECT_ID] \
3
+ --limit 1
@@ -3,3 +3,4 @@ appwrite projects updateOAuth2 \
3
3
  --provider amazon \
4
4
 
5
5
 
6
+
@@ -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 ''
@@ -1,3 +1,3 @@
1
1
  appwrite users updatePhone \
2
2
  --userId [USER_ID] \
3
- --number ''
3
+ --number +12065550100
package/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  #! /usr/bin/env node
2
+
3
+ /** Required to set max width of the help commands */
4
+ const oldWidth = process.stdout.columns
5
+ process.stdout.columns = 100
6
+ /** ---------------------------------------------- */
7
+
2
8
  const program = require("commander");
3
9
  const chalk = require("chalk");
4
10
  const { version } = require("./package.json");
@@ -9,8 +15,10 @@ const { init } = require("./lib/commands/init");
9
15
  const { deploy } = require("./lib/commands/deploy");
10
16
  const { account } = require("./lib/commands/account");
11
17
  const { avatars } = require("./lib/commands/avatars");
18
+ const { console } = require("./lib/commands/console");
12
19
  const { databases } = require("./lib/commands/databases");
13
20
  const { functions } = require("./lib/commands/functions");
21
+ const { graphql } = require("./lib/commands/graphql");
14
22
  const { health } = require("./lib/commands/health");
15
23
  const { locale } = require("./lib/commands/locale");
16
24
  const { projects } = require("./lib/commands/projects");
@@ -20,6 +28,10 @@ const { users } = require("./lib/commands/users");
20
28
 
21
29
  program
22
30
  .description(commandDescriptions['main'])
31
+ .configureHelp({
32
+ helpWidth: process.stdout.columns || 80,
33
+ sortSubcommands: true
34
+ })
23
35
  .version(version, "-v, --version")
24
36
  .option("--verbose", "Show complete error log")
25
37
  .option("--json", "Output in JSON format")
@@ -36,8 +48,10 @@ program
36
48
  .addCommand(logout)
37
49
  .addCommand(account)
38
50
  .addCommand(avatars)
51
+ .addCommand(console)
39
52
  .addCommand(databases)
40
53
  .addCommand(functions)
54
+ .addCommand(graphql)
41
55
  .addCommand(health)
42
56
  .addCommand(locale)
43
57
  .addCommand(projects)
@@ -46,4 +60,5 @@ program
46
60
  .addCommand(users)
47
61
  .addCommand(client)
48
62
  .parse(process.argv);
49
-
63
+
64
+ process.stdout.columns = oldWidth;
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.1.1/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.1.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.1.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.1.1',
19
- 'user-agent' : `AppwriteCLI/1.1.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"]) {