appwrite-cli 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Formula/appwrite.rb +1 -1
- package/LICENSE.md +2 -2
- package/README.md +4 -4
- package/docs/examples/account/create-phone-session.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/functions/create-build.md +4 -0
- package/docs/examples/graphql/mutation.md +2 -0
- package/docs/examples/graphql/query.md +2 -0
- package/docs/examples/projects/create.md +1 -0
- package/docs/examples/projects/update-auth-duration.md +3 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
- package/docs/examples/projects/update-o-auth2.md +1 -0
- package/docs/examples/users/update-phone.md +1 -1
- package/index.js +14 -1
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/account.js +10 -8
- package/lib/commands/avatars.js +3 -1
- package/lib/commands/databases.js +12 -10
- package/lib/commands/deploy.js +86 -1
- package/lib/commands/functions.js +9 -7
- package/lib/commands/generic.js +9 -0
- package/lib/commands/graphql.js +85 -0
- package/lib/commands/health.js +3 -1
- package/lib/commands/init.js +27 -1
- package/lib/commands/locale.js +3 -1
- package/lib/commands/projects.js +85 -5
- package/lib/commands/storage.js +10 -8
- package/lib/commands/teams.js +5 -3
- package/lib/commands/users.js +11 -9
- package/lib/config.js +39 -0
- package/lib/parser.js +1 -0
- package/lib/questions.js +28 -1
- package/package.json +1 -1
package/Formula/appwrite.rb
CHANGED
|
@@ -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: "
|
|
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)
|
|
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
|
|
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
|

|
|
4
|
-

|
|
5
5
|
[](https://travis-ci.com/appwrite/sdk-generator)
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
|
8
8
|
|
|
9
|
-
**This SDK is compatible with Appwrite server version 1.
|
|
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).**
|
|
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
|
|
32
|
+
1.2.1
|
|
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
|
|
61
|
+
1.2.1
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Getting Started
|
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");
|
|
@@ -11,6 +17,7 @@ const { account } = require("./lib/commands/account");
|
|
|
11
17
|
const { avatars } = require("./lib/commands/avatars");
|
|
12
18
|
const { databases } = require("./lib/commands/databases");
|
|
13
19
|
const { functions } = require("./lib/commands/functions");
|
|
20
|
+
const { graphql } = require("./lib/commands/graphql");
|
|
14
21
|
const { health } = require("./lib/commands/health");
|
|
15
22
|
const { locale } = require("./lib/commands/locale");
|
|
16
23
|
const { projects } = require("./lib/commands/projects");
|
|
@@ -20,6 +27,10 @@ const { users } = require("./lib/commands/users");
|
|
|
20
27
|
|
|
21
28
|
program
|
|
22
29
|
.description(commandDescriptions['main'])
|
|
30
|
+
.configureHelp({
|
|
31
|
+
helpWidth: process.stdout.columns || 80,
|
|
32
|
+
sortSubcommands: true
|
|
33
|
+
})
|
|
23
34
|
.version(version, "-v, --version")
|
|
24
35
|
.option("--verbose", "Show complete error log")
|
|
25
36
|
.option("--json", "Output in JSON format")
|
|
@@ -38,6 +49,7 @@ program
|
|
|
38
49
|
.addCommand(avatars)
|
|
39
50
|
.addCommand(databases)
|
|
40
51
|
.addCommand(functions)
|
|
52
|
+
.addCommand(graphql)
|
|
41
53
|
.addCommand(health)
|
|
42
54
|
.addCommand(locale)
|
|
43
55
|
.addCommand(projects)
|
|
@@ -46,4 +58,5 @@ program
|
|
|
46
58
|
.addCommand(users)
|
|
47
59
|
.addCommand(client)
|
|
48
60
|
.parse(process.argv);
|
|
49
|
-
|
|
61
|
+
|
|
62
|
+
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
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/1.1
|
|
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"
|
|
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
|
|
100
|
+
GITHUB_LATEST_VERSION="1.2.1"
|
|
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
|
@@ -15,8 +15,8 @@ class Client {
|
|
|
15
15
|
'x-sdk-name': 'Command Line',
|
|
16
16
|
'x-sdk-platform': 'console',
|
|
17
17
|
'x-sdk-language': 'cli',
|
|
18
|
-
'x-sdk-version': '1.1
|
|
19
|
-
'user-agent' : `AppwriteCLI/1.1
|
|
18
|
+
'x-sdk-version': '1.2.1',
|
|
19
|
+
'user-agent' : `AppwriteCLI/1.2.1 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
20
20
|
'X-Appwrite-Response-Format' : '1.0.0',
|
|
21
21
|
};
|
|
22
22
|
}
|
package/lib/commands/account.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const account = new Command("account").description(commandDescriptions['account'])
|
|
13
|
+
const account = new Command("account").description(commandDescriptions['account']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const accountGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
|
|
@@ -740,7 +742,7 @@ account
|
|
|
740
742
|
account
|
|
741
743
|
.command(`create`)
|
|
742
744
|
.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).`)
|
|
743
|
-
.requiredOption(`--userId <userId>`, `Unique Id. Choose
|
|
745
|
+
.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.`)
|
|
744
746
|
.requiredOption(`--email <email>`, `User email.`)
|
|
745
747
|
.requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
|
|
746
748
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -828,15 +830,15 @@ account
|
|
|
828
830
|
|
|
829
831
|
account
|
|
830
832
|
.command(`createEmailSession`)
|
|
831
|
-
.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.`)
|
|
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).`)
|
|
832
834
|
.requiredOption(`--email <email>`, `User email.`)
|
|
833
835
|
.requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
|
|
834
836
|
.action(actionRunner(accountCreateEmailSession))
|
|
835
837
|
|
|
836
838
|
account
|
|
837
839
|
.command(`createMagicURLSession`)
|
|
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.`)
|
|
839
|
-
.requiredOption(`--userId <userId>`, `Unique Id. Choose
|
|
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).`)
|
|
841
|
+
.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.`)
|
|
840
842
|
.requiredOption(`--email <email>`, `User email.`)
|
|
841
843
|
.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.`)
|
|
842
844
|
.action(actionRunner(accountCreateMagicURLSession))
|
|
@@ -850,7 +852,7 @@ account
|
|
|
850
852
|
|
|
851
853
|
account
|
|
852
854
|
.command(`createOAuth2Session`)
|
|
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
|
|
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). `)
|
|
854
856
|
.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.`)
|
|
855
857
|
.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.`)
|
|
856
858
|
.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,8 +861,8 @@ account
|
|
|
859
861
|
|
|
860
862
|
account
|
|
861
863
|
.command(`createPhoneSession`)
|
|
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.`)
|
|
863
|
-
.requiredOption(`--userId <userId>`, `Unique Id. Choose
|
|
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).`)
|
|
865
|
+
.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.`)
|
|
864
866
|
.requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
|
|
865
867
|
.action(actionRunner(accountCreatePhoneSession))
|
|
866
868
|
|
package/lib/commands/avatars.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const avatars = new Command("avatars").description(commandDescriptions['avatars'])
|
|
13
|
+
const avatars = new Command("avatars").description(commandDescriptions['avatars']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
|
|
16
18
|
/* @param {string} code */
|
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const databases = new Command("databases").description(commandDescriptions['databases'])
|
|
13
|
+
const databases = new Command("databases").description(commandDescriptions['databases']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const databasesList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -1125,7 +1127,7 @@ databases
|
|
|
1125
1127
|
databases
|
|
1126
1128
|
.command(`create`)
|
|
1127
1129
|
.description(`Create a new Database. `)
|
|
1128
|
-
.requiredOption(`--databaseId <databaseId>`, `Unique Id. Choose
|
|
1130
|
+
.requiredOption(`--databaseId <databaseId>`, `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.`)
|
|
1129
1131
|
.requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
|
|
1130
1132
|
.action(actionRunner(databasesCreate))
|
|
1131
1133
|
|
|
@@ -1145,7 +1147,7 @@ databases
|
|
|
1145
1147
|
.command(`update`)
|
|
1146
1148
|
.description(`Update a database by its unique ID.`)
|
|
1147
1149
|
.requiredOption(`--databaseId <databaseId>`, `Database ID.`)
|
|
1148
|
-
.requiredOption(`--name <name>`, `
|
|
1150
|
+
.requiredOption(`--name <name>`, `Database name. Max length: 128 chars.`)
|
|
1149
1151
|
.action(actionRunner(databasesUpdate))
|
|
1150
1152
|
|
|
1151
1153
|
databases
|
|
@@ -1166,9 +1168,9 @@ databases
|
|
|
1166
1168
|
.command(`createCollection`)
|
|
1167
1169
|
.description(`Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console.`)
|
|
1168
1170
|
.requiredOption(`--databaseId <databaseId>`, `Database ID.`)
|
|
1169
|
-
.requiredOption(`--collectionId <collectionId>`, `Unique Id. Choose
|
|
1171
|
+
.requiredOption(`--collectionId <collectionId>`, `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.`)
|
|
1170
1172
|
.requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
|
|
1171
|
-
.option(`--permissions <permissions...>`, `An array of permissions strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
1173
|
+
.option(`--permissions <permissions...>`, `An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
1172
1174
|
.option(`--documentSecurity <documentSecurity>`, `Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
1173
1175
|
.action(actionRunner(databasesCreateCollection))
|
|
1174
1176
|
|
|
@@ -1185,7 +1187,7 @@ databases
|
|
|
1185
1187
|
.requiredOption(`--databaseId <databaseId>`, `Database ID.`)
|
|
1186
1188
|
.requiredOption(`--collectionId <collectionId>`, `Collection ID.`)
|
|
1187
1189
|
.requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
|
|
1188
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default the current
|
|
1190
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
1189
1191
|
.option(`--documentSecurity <documentSecurity>`, `Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
1190
1192
|
.option(`--enabled <enabled>`, `Is collection enabled?`, parseBool)
|
|
1191
1193
|
.action(actionRunner(databasesUpdateCollection))
|
|
@@ -1327,7 +1329,7 @@ databases
|
|
|
1327
1329
|
|
|
1328
1330
|
databases
|
|
1329
1331
|
.command(`listDocuments`)
|
|
1330
|
-
.description(`Get a list of all the user's documents in a given collection. You can use the query params to filter your results
|
|
1332
|
+
.description(`Get a list of all the user's documents in a given collection. You can use the query params to filter your results.`)
|
|
1331
1333
|
.requiredOption(`--databaseId <databaseId>`, `Database ID.`)
|
|
1332
1334
|
.requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).`)
|
|
1333
1335
|
.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). Maximum of 100 queries are allowed, each 4096 characters long.`)
|
|
@@ -1338,9 +1340,9 @@ databases
|
|
|
1338
1340
|
.description(`Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console.`)
|
|
1339
1341
|
.requiredOption(`--databaseId <databaseId>`, `Database ID.`)
|
|
1340
1342
|
.requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.`)
|
|
1341
|
-
.requiredOption(`--documentId <documentId>`, `Document ID. Choose
|
|
1343
|
+
.requiredOption(`--documentId <documentId>`, `Document 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.`)
|
|
1342
1344
|
.requiredOption(`--data <data>`, `Document data as JSON object.`)
|
|
1343
|
-
.option(`--permissions <permissions...>`, `An array of permissions strings. By default the current user is granted
|
|
1345
|
+
.option(`--permissions <permissions...>`, `An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
|
|
1344
1346
|
.action(actionRunner(databasesCreateDocument))
|
|
1345
1347
|
|
|
1346
1348
|
databases
|
|
@@ -1358,7 +1360,7 @@ databases
|
|
|
1358
1360
|
.requiredOption(`--collectionId <collectionId>`, `Collection ID.`)
|
|
1359
1361
|
.requiredOption(`--documentId <documentId>`, `Document ID.`)
|
|
1360
1362
|
.option(`--data <data>`, `Document data as JSON object. Include only attribute and value pairs to be updated.`)
|
|
1361
|
-
.option(`--permissions <permissions...>`, `An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
1363
|
+
.option(`--permissions <permissions...>`, `An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
1362
1364
|
.action(actionRunner(databasesUpdateDocument))
|
|
1363
1365
|
|
|
1364
1366
|
databases
|
package/lib/commands/deploy.js
CHANGED
|
@@ -2,7 +2,7 @@ const inquirer = require("inquirer");
|
|
|
2
2
|
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
3
3
|
const { Command } = require("commander");
|
|
4
4
|
const { localConfig } = require("../config");
|
|
5
|
-
const { questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
|
|
5
|
+
const { questionsDeployTeams, questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
|
|
6
6
|
const { actionRunner, success, log, error, commandDescriptions } = require("../parser");
|
|
7
7
|
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
|
|
8
8
|
const {
|
|
@@ -25,6 +25,11 @@ const {
|
|
|
25
25
|
databasesListIndexes,
|
|
26
26
|
databasesDeleteIndex
|
|
27
27
|
} = require("./databases");
|
|
28
|
+
const {
|
|
29
|
+
teamsGet,
|
|
30
|
+
teamsUpdate,
|
|
31
|
+
teamsCreate
|
|
32
|
+
} = require("./teams");
|
|
28
33
|
|
|
29
34
|
const POOL_DEBOUNCE = 2000; // in milliseconds
|
|
30
35
|
const POOL_MAX_DEBOUNCES = 30;
|
|
@@ -138,6 +143,9 @@ const awaitPools = {
|
|
|
138
143
|
|
|
139
144
|
const deploy = new Command("deploy")
|
|
140
145
|
.description(commandDescriptions['deploy'])
|
|
146
|
+
.configureHelp({
|
|
147
|
+
helpWidth: process.stdout.columns || 80
|
|
148
|
+
})
|
|
141
149
|
.action(actionRunner(async (_options, command) => {
|
|
142
150
|
command.help()
|
|
143
151
|
}));
|
|
@@ -593,6 +601,76 @@ const deployCollection = async ({ all, yes } = {}) => {
|
|
|
593
601
|
}
|
|
594
602
|
}
|
|
595
603
|
|
|
604
|
+
const deployTeam = async ({ all, yes } = {}) => {
|
|
605
|
+
let response = {};
|
|
606
|
+
|
|
607
|
+
let teamIds = [];
|
|
608
|
+
const configTeams = localConfig.getTeams();
|
|
609
|
+
|
|
610
|
+
if(all) {
|
|
611
|
+
if (configTeams.length === 0) {
|
|
612
|
+
throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
|
|
613
|
+
}
|
|
614
|
+
teamIds.push(...configTeams.map((t) => t.$id));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if(teamIds.length === 0) {
|
|
618
|
+
let answers = await inquirer.prompt(questionsDeployTeams[0])
|
|
619
|
+
teamIds.push(...answers.teams);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
let teams = [];
|
|
623
|
+
|
|
624
|
+
for(const teamId of teamIds) {
|
|
625
|
+
const idTeams = configTeams.filter((t) => t.$id === teamId);
|
|
626
|
+
teams.push(...idTeams);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
for (let team of teams) {
|
|
630
|
+
log(`Deploying team ${team.name} ( ${team['$id']} )`)
|
|
631
|
+
|
|
632
|
+
try {
|
|
633
|
+
response = await teamsGet({
|
|
634
|
+
teamId: team['$id'],
|
|
635
|
+
parseOutput: false,
|
|
636
|
+
})
|
|
637
|
+
log(`Team ${team.name} ( ${team['$id']} ) already exists.`);
|
|
638
|
+
|
|
639
|
+
if(!yes) {
|
|
640
|
+
answers = await inquirer.prompt(questionsDeployTeams[1])
|
|
641
|
+
if (answers.override !== "YES") {
|
|
642
|
+
log(`Received "${answers.override}". Skipping ${team.name} ( ${team['$id']} )`);
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
log(`Updating team ...`)
|
|
648
|
+
|
|
649
|
+
await teamsUpdate({
|
|
650
|
+
teamId: team['$id'],
|
|
651
|
+
name: team.name,
|
|
652
|
+
parseOutput: false
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
success(`Deployed ${team.name} ( ${team['$id']} )`);
|
|
656
|
+
} catch (e) {
|
|
657
|
+
if (e.code == 404) {
|
|
658
|
+
log(`Team ${team.name} does not exist in the project. Creating ... `);
|
|
659
|
+
|
|
660
|
+
response = await teamsCreate({
|
|
661
|
+
teamId: team['$id'],
|
|
662
|
+
name: team.name,
|
|
663
|
+
parseOutput: false
|
|
664
|
+
})
|
|
665
|
+
|
|
666
|
+
success(`Deployed ${team.name} ( ${team['$id']} )`);
|
|
667
|
+
} else {
|
|
668
|
+
throw e;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
596
674
|
deploy
|
|
597
675
|
.command("function")
|
|
598
676
|
.description("Deploy functions in the current directory.")
|
|
@@ -608,6 +686,13 @@ deploy
|
|
|
608
686
|
.option(`--yes`, `Flag to confirm all warnings`)
|
|
609
687
|
.action(actionRunner(deployCollection));
|
|
610
688
|
|
|
689
|
+
deploy
|
|
690
|
+
.command("team")
|
|
691
|
+
.description("Deploy teams in the current project.")
|
|
692
|
+
.option(`--all`, `Flag to deploy all teams`)
|
|
693
|
+
.option(`--yes`, `Flag to confirm all warnings`)
|
|
694
|
+
.action(actionRunner(deployTeam));
|
|
695
|
+
|
|
611
696
|
module.exports = {
|
|
612
697
|
deploy
|
|
613
698
|
}
|
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const functions = new Command("functions").description(commandDescriptions['functions'])
|
|
13
|
+
const functions = new Command("functions").description(commandDescriptions['functions']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const functionsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -426,7 +428,7 @@ const functionsDeleteDeployment = async ({ functionId, deploymentId, parseOutput
|
|
|
426
428
|
return response;
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
const
|
|
431
|
+
const functionsCreateBuild = async ({ functionId, deploymentId, buildId, parseOutput = true, sdk = undefined}) => {
|
|
430
432
|
/* @param {string} functionId */
|
|
431
433
|
/* @param {string} deploymentId */
|
|
432
434
|
/* @param {string} buildId */
|
|
@@ -675,7 +677,7 @@ functions
|
|
|
675
677
|
functions
|
|
676
678
|
.command(`create`)
|
|
677
679
|
.description(`Create a new function. You can pass a list of [permissions](/docs/permissions) to allow different project users or team with access to execute the function using the client API.`)
|
|
678
|
-
.requiredOption(`--functionId <functionId>`, `Function ID. Choose
|
|
680
|
+
.requiredOption(`--functionId <functionId>`, `Function 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.`)
|
|
679
681
|
.requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
|
|
680
682
|
.requiredOption(`--execute <execute...>`, `An array of strings with execution roles. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 64 characters long.`)
|
|
681
683
|
.requiredOption(`--runtime <runtime>`, `Execution runtime.`)
|
|
@@ -759,16 +761,16 @@ functions
|
|
|
759
761
|
.action(actionRunner(functionsDeleteDeployment))
|
|
760
762
|
|
|
761
763
|
functions
|
|
762
|
-
.command(`
|
|
764
|
+
.command(`createBuild`)
|
|
763
765
|
.description(``)
|
|
764
766
|
.requiredOption(`--functionId <functionId>`, `Function ID.`)
|
|
765
767
|
.requiredOption(`--deploymentId <deploymentId>`, `Deployment ID.`)
|
|
766
768
|
.requiredOption(`--buildId <buildId>`, `Build unique ID.`)
|
|
767
|
-
.action(actionRunner(
|
|
769
|
+
.action(actionRunner(functionsCreateBuild))
|
|
768
770
|
|
|
769
771
|
functions
|
|
770
772
|
.command(`listExecutions`)
|
|
771
|
-
.description(`Get a list of all the current user function execution logs. You can use the query params to filter your results
|
|
773
|
+
.description(`Get a list of all the current user function execution logs. You can use the query params to filter your results.`)
|
|
772
774
|
.requiredOption(`--functionId <functionId>`, `Function ID.`)
|
|
773
775
|
.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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration`)
|
|
774
776
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
@@ -848,7 +850,7 @@ module.exports = {
|
|
|
848
850
|
functionsGetDeployment,
|
|
849
851
|
functionsUpdateDeployment,
|
|
850
852
|
functionsDeleteDeployment,
|
|
851
|
-
|
|
853
|
+
functionsCreateBuild,
|
|
852
854
|
functionsListExecutions,
|
|
853
855
|
functionsCreateExecution,
|
|
854
856
|
functionsGetExecution,
|
package/lib/commands/generic.js
CHANGED
|
@@ -9,6 +9,9 @@ const { accountCreateEmailSession, accountDeleteSession } = require("./account")
|
|
|
9
9
|
|
|
10
10
|
const login = new Command("login")
|
|
11
11
|
.description(commandDescriptions['login'])
|
|
12
|
+
.configureHelp({
|
|
13
|
+
helpWidth: process.stdout.columns || 80
|
|
14
|
+
})
|
|
12
15
|
.action(actionRunner(async () => {
|
|
13
16
|
const answers = await inquirer.prompt(questionsLogin)
|
|
14
17
|
|
|
@@ -26,6 +29,9 @@ const login = new Command("login")
|
|
|
26
29
|
|
|
27
30
|
const logout = new Command("logout")
|
|
28
31
|
.description(commandDescriptions['logout'])
|
|
32
|
+
.configureHelp({
|
|
33
|
+
helpWidth: process.stdout.columns || 80
|
|
34
|
+
})
|
|
29
35
|
.action(actionRunner(async () => {
|
|
30
36
|
let client = await sdkForConsole();
|
|
31
37
|
|
|
@@ -41,6 +47,9 @@ const logout = new Command("logout")
|
|
|
41
47
|
|
|
42
48
|
const client = new Command("client")
|
|
43
49
|
.description(commandDescriptions['client'])
|
|
50
|
+
.configureHelp({
|
|
51
|
+
helpWidth: process.stdout.columns || 80
|
|
52
|
+
})
|
|
44
53
|
.option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
|
|
45
54
|
.option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
|
|
46
55
|
.option("--projectId <projectId>", "Set your Appwrite project ID")
|
|
@@ -0,0 +1,85 @@
|
|
|
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 graphql = new Command("graphql").description(commandDescriptions['graphql']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const graphqlQuery = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
18
|
+
/* @param {object} query */
|
|
19
|
+
|
|
20
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
21
|
+
let path = '/graphql';
|
|
22
|
+
let payload = {};
|
|
23
|
+
|
|
24
|
+
/** Body Params */
|
|
25
|
+
if (typeof query !== 'undefined') {
|
|
26
|
+
payload['query'] = JSON.parse(query);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let response = undefined;
|
|
30
|
+
response = await client.call('post', path, {
|
|
31
|
+
'x-sdk-graphql': 'true',
|
|
32
|
+
'content-type': 'application/json',
|
|
33
|
+
}, payload);
|
|
34
|
+
|
|
35
|
+
if (parseOutput) {
|
|
36
|
+
parse(response)
|
|
37
|
+
success()
|
|
38
|
+
}
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const graphqlMutation = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
43
|
+
/* @param {object} query */
|
|
44
|
+
|
|
45
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
46
|
+
let path = '/graphql/mutation';
|
|
47
|
+
let payload = {};
|
|
48
|
+
|
|
49
|
+
/** Body Params */
|
|
50
|
+
if (typeof query !== 'undefined') {
|
|
51
|
+
payload['query'] = JSON.parse(query);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let response = undefined;
|
|
55
|
+
response = await client.call('post', path, {
|
|
56
|
+
'x-sdk-graphql': 'true',
|
|
57
|
+
'content-type': 'application/json',
|
|
58
|
+
}, payload);
|
|
59
|
+
|
|
60
|
+
if (parseOutput) {
|
|
61
|
+
parse(response)
|
|
62
|
+
success()
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
graphql
|
|
69
|
+
.command(`query`)
|
|
70
|
+
.description(`Execute a GraphQL mutation.`)
|
|
71
|
+
.requiredOption(`--query <query>`, `The query or queries to execute.`)
|
|
72
|
+
.action(actionRunner(graphqlQuery))
|
|
73
|
+
|
|
74
|
+
graphql
|
|
75
|
+
.command(`mutation`)
|
|
76
|
+
.description(`Execute a GraphQL mutation.`)
|
|
77
|
+
.requiredOption(`--query <query>`, `The query or queries to execute.`)
|
|
78
|
+
.action(actionRunner(graphqlMutation))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
graphql,
|
|
83
|
+
graphqlQuery,
|
|
84
|
+
graphqlMutation
|
|
85
|
+
};
|
package/lib/commands/health.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const health = new Command("health").description(commandDescriptions['health'])
|
|
13
|
+
const health = new Command("health").description(commandDescriptions['health']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const healthGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
|
package/lib/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require("path");
|
|
|
3
3
|
const childProcess = require('child_process');
|
|
4
4
|
const { Command } = require("commander");
|
|
5
5
|
const inquirer = require("inquirer");
|
|
6
|
-
const { teamsCreate } = require("./teams");
|
|
6
|
+
const { teamsCreate, teamsList } = require("./teams");
|
|
7
7
|
const { projectsCreate } = require("./projects");
|
|
8
8
|
const { functionsCreate } = require("./functions");
|
|
9
9
|
const { databasesListCollections, databasesList } = require("./databases");
|
|
@@ -14,6 +14,9 @@ const { success, log, actionRunner, commandDescriptions } = require("../parser")
|
|
|
14
14
|
|
|
15
15
|
const init = new Command("init")
|
|
16
16
|
.description(commandDescriptions['init'])
|
|
17
|
+
.configureHelp({
|
|
18
|
+
helpWidth: process.stdout.columns || 80
|
|
19
|
+
})
|
|
17
20
|
.action(actionRunner(async (_options, command) => {
|
|
18
21
|
command.help();
|
|
19
22
|
}));
|
|
@@ -186,6 +189,24 @@ const initCollection = async ({ all, databaseId } = {}) => {
|
|
|
186
189
|
success();
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
const initTeam = async () => {
|
|
193
|
+
// TODO: Pagination?
|
|
194
|
+
let response = await teamsList({
|
|
195
|
+
queries: [ 'limit(100)' ],
|
|
196
|
+
parseOutput: false
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
let teams = response.teams;
|
|
200
|
+
log(`Found ${teams.length} teams`);
|
|
201
|
+
|
|
202
|
+
teams.forEach(async team => {
|
|
203
|
+
log(`Fetching ${team.name} ...`);
|
|
204
|
+
localConfig.addTeam(team);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
success();
|
|
208
|
+
}
|
|
209
|
+
|
|
189
210
|
init
|
|
190
211
|
.command("project")
|
|
191
212
|
.description("Initialise your Appwrite project")
|
|
@@ -203,6 +224,11 @@ init
|
|
|
203
224
|
.option(`--all`, `Flag to initialize all databases`)
|
|
204
225
|
.action(actionRunner(initCollection))
|
|
205
226
|
|
|
227
|
+
init
|
|
228
|
+
.command("team")
|
|
229
|
+
.description("Initialise your Appwrite teams")
|
|
230
|
+
.action(actionRunner(initTeam))
|
|
231
|
+
|
|
206
232
|
module.exports = {
|
|
207
233
|
init,
|
|
208
234
|
};
|
package/lib/commands/locale.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const locale = new Command("locale").description(commandDescriptions['locale'])
|
|
13
|
+
const locale = new Command("locale").description(commandDescriptions['locale']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const localeGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
|
package/lib/commands/projects.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const projects = new Command("projects").description(commandDescriptions['projects'])
|
|
13
|
+
const projects = new Command("projects").description(commandDescriptions['projects']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const projectsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -39,10 +41,11 @@ const projectsList = async ({ queries, search, parseOutput = true, sdk = undefin
|
|
|
39
41
|
return response;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
const projectsCreate = async ({ projectId, name, teamId, description, logo, url, legalName, legalCountry, legalState, legalCity, legalAddress, legalTaxId, parseOutput = true, sdk = undefined}) => {
|
|
44
|
+
const projectsCreate = async ({ projectId, name, teamId, region, description, logo, url, legalName, legalCountry, legalState, legalCity, legalAddress, legalTaxId, parseOutput = true, sdk = undefined}) => {
|
|
43
45
|
/* @param {string} projectId */
|
|
44
46
|
/* @param {string} name */
|
|
45
47
|
/* @param {string} teamId */
|
|
48
|
+
/* @param {string} region */
|
|
46
49
|
/* @param {string} description */
|
|
47
50
|
/* @param {string} logo */
|
|
48
51
|
/* @param {string} url */
|
|
@@ -70,6 +73,10 @@ const projectsCreate = async ({ projectId, name, teamId, description, logo, url,
|
|
|
70
73
|
payload['teamId'] = teamId;
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
if (typeof region !== 'undefined') {
|
|
77
|
+
payload['region'] = region;
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
if (typeof description !== 'undefined') {
|
|
74
81
|
payload['description'] = description;
|
|
75
82
|
}
|
|
@@ -231,6 +238,31 @@ const projectsDelete = async ({ projectId, password, parseOutput = true, sdk = u
|
|
|
231
238
|
return response;
|
|
232
239
|
}
|
|
233
240
|
|
|
241
|
+
const projectsUpdateAuthDuration = async ({ projectId, duration, parseOutput = true, sdk = undefined}) => {
|
|
242
|
+
/* @param {string} projectId */
|
|
243
|
+
/* @param {number} duration */
|
|
244
|
+
|
|
245
|
+
let client = !sdk ? await sdkForConsole() : sdk;
|
|
246
|
+
let path = '/projects/{projectId}/auth/duration'.replace('{projectId}', projectId);
|
|
247
|
+
let payload = {};
|
|
248
|
+
|
|
249
|
+
/** Body Params */
|
|
250
|
+
if (typeof duration !== 'undefined') {
|
|
251
|
+
payload['duration'] = duration;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let response = undefined;
|
|
255
|
+
response = await client.call('patch', path, {
|
|
256
|
+
'content-type': 'application/json',
|
|
257
|
+
}, payload);
|
|
258
|
+
|
|
259
|
+
if (parseOutput) {
|
|
260
|
+
parse(response)
|
|
261
|
+
success()
|
|
262
|
+
}
|
|
263
|
+
return response;
|
|
264
|
+
}
|
|
265
|
+
|
|
234
266
|
const projectsUpdateAuthLimit = async ({ projectId, limit, parseOutput = true, sdk = undefined}) => {
|
|
235
267
|
/* @param {string} projectId */
|
|
236
268
|
/* @param {number} limit */
|
|
@@ -256,6 +288,31 @@ const projectsUpdateAuthLimit = async ({ projectId, limit, parseOutput = true, s
|
|
|
256
288
|
return response;
|
|
257
289
|
}
|
|
258
290
|
|
|
291
|
+
const projectsUpdateAuthSessionsLimit = async ({ projectId, limit, parseOutput = true, sdk = undefined}) => {
|
|
292
|
+
/* @param {string} projectId */
|
|
293
|
+
/* @param {number} limit */
|
|
294
|
+
|
|
295
|
+
let client = !sdk ? await sdkForConsole() : sdk;
|
|
296
|
+
let path = '/projects/{projectId}/auth/max-sessions'.replace('{projectId}', projectId);
|
|
297
|
+
let payload = {};
|
|
298
|
+
|
|
299
|
+
/** Body Params */
|
|
300
|
+
if (typeof limit !== 'undefined') {
|
|
301
|
+
payload['limit'] = limit;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let response = undefined;
|
|
305
|
+
response = await client.call('patch', path, {
|
|
306
|
+
'content-type': 'application/json',
|
|
307
|
+
}, payload);
|
|
308
|
+
|
|
309
|
+
if (parseOutput) {
|
|
310
|
+
parse(response)
|
|
311
|
+
success()
|
|
312
|
+
}
|
|
313
|
+
return response;
|
|
314
|
+
}
|
|
315
|
+
|
|
259
316
|
const projectsUpdateAuthStatus = async ({ projectId, method, status, parseOutput = true, sdk = undefined}) => {
|
|
260
317
|
/* @param {string} projectId */
|
|
261
318
|
/* @param {string} method */
|
|
@@ -509,11 +566,12 @@ const projectsDeleteKey = async ({ projectId, keyId, parseOutput = true, sdk = u
|
|
|
509
566
|
return response;
|
|
510
567
|
}
|
|
511
568
|
|
|
512
|
-
const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, parseOutput = true, sdk = undefined}) => {
|
|
569
|
+
const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, enabled, parseOutput = true, sdk = undefined}) => {
|
|
513
570
|
/* @param {string} projectId */
|
|
514
571
|
/* @param {string} provider */
|
|
515
572
|
/* @param {string} appId */
|
|
516
573
|
/* @param {string} secret */
|
|
574
|
+
/* @param {boolean} enabled */
|
|
517
575
|
|
|
518
576
|
let client = !sdk ? await sdkForConsole() : sdk;
|
|
519
577
|
let path = '/projects/{projectId}/oauth2'.replace('{projectId}', projectId);
|
|
@@ -532,6 +590,10 @@ const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, parseO
|
|
|
532
590
|
payload['secret'] = secret;
|
|
533
591
|
}
|
|
534
592
|
|
|
593
|
+
if (typeof enabled !== 'undefined') {
|
|
594
|
+
payload['enabled'] = enabled;
|
|
595
|
+
}
|
|
596
|
+
|
|
535
597
|
let response = undefined;
|
|
536
598
|
response = await client.call('patch', path, {
|
|
537
599
|
'content-type': 'application/json',
|
|
@@ -920,16 +982,17 @@ const projectsUpdateWebhookSignature = async ({ projectId, webhookId, parseOutpu
|
|
|
920
982
|
projects
|
|
921
983
|
.command(`list`)
|
|
922
984
|
.description(``)
|
|
923
|
-
.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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name`)
|
|
985
|
+
.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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId`)
|
|
924
986
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
925
987
|
.action(actionRunner(projectsList))
|
|
926
988
|
|
|
927
989
|
projects
|
|
928
990
|
.command(`create`)
|
|
929
991
|
.description(``)
|
|
930
|
-
.requiredOption(`--projectId <projectId>`, `Unique Id. Choose
|
|
992
|
+
.requiredOption(`--projectId <projectId>`, `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.`)
|
|
931
993
|
.requiredOption(`--name <name>`, `Project name. Max length: 128 chars.`)
|
|
932
994
|
.requiredOption(`--teamId <teamId>`, `Team unique ID.`)
|
|
995
|
+
.option(`--region <region>`, `Project Region.`)
|
|
933
996
|
.option(`--description <description>`, `Project description. Max length: 256 chars.`)
|
|
934
997
|
.option(`--logo <logo>`, `Project logo.`)
|
|
935
998
|
.option(`--url <url>`, `Project URL.`)
|
|
@@ -970,6 +1033,13 @@ projects
|
|
|
970
1033
|
.requiredOption(`--password <password>`, `Your user password for confirmation. Must be at least 8 chars.`)
|
|
971
1034
|
.action(actionRunner(projectsDelete))
|
|
972
1035
|
|
|
1036
|
+
projects
|
|
1037
|
+
.command(`updateAuthDuration`)
|
|
1038
|
+
.description(``)
|
|
1039
|
+
.requiredOption(`--projectId <projectId>`, `Project unique ID.`)
|
|
1040
|
+
.requiredOption(`--duration <duration>`, `Project session length in seconds. Max length: 31536000 seconds.`, parseInteger)
|
|
1041
|
+
.action(actionRunner(projectsUpdateAuthDuration))
|
|
1042
|
+
|
|
973
1043
|
projects
|
|
974
1044
|
.command(`updateAuthLimit`)
|
|
975
1045
|
.description(``)
|
|
@@ -977,6 +1047,13 @@ projects
|
|
|
977
1047
|
.requiredOption(`--limit <limit>`, `Set the max number of users allowed in this project. Use 0 for unlimited.`, parseInteger)
|
|
978
1048
|
.action(actionRunner(projectsUpdateAuthLimit))
|
|
979
1049
|
|
|
1050
|
+
projects
|
|
1051
|
+
.command(`updateAuthSessionsLimit`)
|
|
1052
|
+
.description(``)
|
|
1053
|
+
.requiredOption(`--projectId <projectId>`, `Project unique ID.`)
|
|
1054
|
+
.requiredOption(`--limit <limit>`, `Set the max number of users allowed in this project. Value allowed is between 1-100. Default is 10`, parseInteger)
|
|
1055
|
+
.action(actionRunner(projectsUpdateAuthSessionsLimit))
|
|
1056
|
+
|
|
980
1057
|
projects
|
|
981
1058
|
.command(`updateAuthStatus`)
|
|
982
1059
|
.description(``)
|
|
@@ -1065,6 +1142,7 @@ projects
|
|
|
1065
1142
|
.requiredOption(`--provider <provider>`, `Provider Name`)
|
|
1066
1143
|
.option(`--appId <appId>`, `Provider app ID. Max length: 256 chars.`)
|
|
1067
1144
|
.option(`--secret <secret>`, `Provider secret key. Max length: 512 chars.`)
|
|
1145
|
+
.option(`--enabled <enabled>`, `Provider status. Set to 'false' to disable new session creation.`, parseBool)
|
|
1068
1146
|
.action(actionRunner(projectsUpdateOAuth2))
|
|
1069
1147
|
|
|
1070
1148
|
projects
|
|
@@ -1184,7 +1262,9 @@ module.exports = {
|
|
|
1184
1262
|
projectsGet,
|
|
1185
1263
|
projectsUpdate,
|
|
1186
1264
|
projectsDelete,
|
|
1265
|
+
projectsUpdateAuthDuration,
|
|
1187
1266
|
projectsUpdateAuthLimit,
|
|
1267
|
+
projectsUpdateAuthSessionsLimit,
|
|
1188
1268
|
projectsUpdateAuthStatus,
|
|
1189
1269
|
projectsListDomains,
|
|
1190
1270
|
projectsCreateDomain,
|
package/lib/commands/storage.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const storage = new Command("storage").description(commandDescriptions['storage'])
|
|
13
|
+
const storage = new Command("storage").description(commandDescriptions['storage']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -570,9 +572,9 @@ storage
|
|
|
570
572
|
storage
|
|
571
573
|
.command(`createBucket`)
|
|
572
574
|
.description(`Create a new storage bucket.`)
|
|
573
|
-
.requiredOption(`--bucketId <bucketId>`, `Unique Id. Choose
|
|
575
|
+
.requiredOption(`--bucketId <bucketId>`, `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.`)
|
|
574
576
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
575
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
577
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
576
578
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
577
579
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
578
580
|
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the '_APP_STORAGE_LIMIT' environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
|
|
@@ -593,7 +595,7 @@ storage
|
|
|
593
595
|
.description(`Update a storage bucket by its unique ID.`)
|
|
594
596
|
.requiredOption(`--bucketId <bucketId>`, `Bucket unique ID.`)
|
|
595
597
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
596
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
598
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
597
599
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
598
600
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
599
601
|
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
|
|
@@ -611,7 +613,7 @@ storage
|
|
|
611
613
|
|
|
612
614
|
storage
|
|
613
615
|
.command(`listFiles`)
|
|
614
|
-
.description(`Get a list of all the user files. You can use the query params to filter your results
|
|
616
|
+
.description(`Get a list of all the user files. You can use the query params to filter your results.`)
|
|
615
617
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
616
618
|
.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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
|
|
617
619
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
@@ -621,9 +623,9 @@ storage
|
|
|
621
623
|
.command(`createFile`)
|
|
622
624
|
.description(`Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of '5MB'. The 'content-range' header values should always be in bytes. When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in 'x-appwrite-id' header to allow the server to know that the partial upload is for the existing file and not for a new one. If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. `)
|
|
623
625
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
624
|
-
.requiredOption(`--fileId <fileId>`, `File ID. Choose
|
|
626
|
+
.requiredOption(`--fileId <fileId>`, `File 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.`)
|
|
625
627
|
.requiredOption(`--file <file>`, `Binary file.`)
|
|
626
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default the current user is granted
|
|
628
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
|
|
627
629
|
.action(actionRunner(storageCreateFile))
|
|
628
630
|
|
|
629
631
|
storage
|
|
@@ -638,7 +640,7 @@ storage
|
|
|
638
640
|
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
639
641
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
640
642
|
.requiredOption(`--fileId <fileId>`, `File unique ID.`)
|
|
641
|
-
.option(`--permissions <permissions...>`, `An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
643
|
+
.option(`--permissions <permissions...>`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
642
644
|
.action(actionRunner(storageUpdateFile))
|
|
643
645
|
|
|
644
646
|
storage
|
package/lib/commands/teams.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const teams = new Command("teams").description(commandDescriptions['teams'])
|
|
13
|
+
const teams = new Command("teams").description(commandDescriptions['teams']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const teamsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -324,7 +326,7 @@ const teamsUpdateMembershipStatus = async ({ teamId, membershipId, userId, secre
|
|
|
324
326
|
|
|
325
327
|
teams
|
|
326
328
|
.command(`list`)
|
|
327
|
-
.description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.
|
|
328
329
|
|
|
329
330
|
In admin mode, this endpoint returns a list of all the teams in the current project. [Learn more about different API modes](/docs/admin).`)
|
|
331
|
+
.description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.`)
|
|
330
332
|
.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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total`)
|
|
331
333
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
332
334
|
.action(actionRunner(teamsList))
|
|
@@ -332,7 +334,7 @@ teams
|
|
|
332
334
|
teams
|
|
333
335
|
.command(`create`)
|
|
334
336
|
.description(`Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.`)
|
|
335
|
-
.requiredOption(`--teamId <teamId>`, `Team ID. Choose
|
|
337
|
+
.requiredOption(`--teamId <teamId>`, `Team 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.`)
|
|
336
338
|
.requiredOption(`--name <name>`, `Team name. Max length: 128 chars.`)
|
|
337
339
|
.option(`--roles <roles...>`, `Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`)
|
|
338
340
|
.action(actionRunner(teamsCreate))
|
package/lib/commands/users.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const users = new Command("users").description(commandDescriptions['users'])
|
|
13
|
+
const users = new Command("users").description(commandDescriptions['users']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const usersList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -790,7 +792,7 @@ users
|
|
|
790
792
|
users
|
|
791
793
|
.command(`create`)
|
|
792
794
|
.description(`Create a new user.`)
|
|
793
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
795
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
794
796
|
.option(`--email <email>`, `User email.`)
|
|
795
797
|
.option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
|
|
796
798
|
.option(`--password <password>`, `Plain text user password. Must be at least 8 chars.`)
|
|
@@ -800,7 +802,7 @@ users
|
|
|
800
802
|
users
|
|
801
803
|
.command(`createArgon2User`)
|
|
802
804
|
.description(`Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
803
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
805
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
804
806
|
.requiredOption(`--email <email>`, `User email.`)
|
|
805
807
|
.requiredOption(`--password <password>`, `User password hashed using Argon2.`)
|
|
806
808
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -809,7 +811,7 @@ users
|
|
|
809
811
|
users
|
|
810
812
|
.command(`createBcryptUser`)
|
|
811
813
|
.description(`Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
812
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
814
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
813
815
|
.requiredOption(`--email <email>`, `User email.`)
|
|
814
816
|
.requiredOption(`--password <password>`, `User password hashed using Bcrypt.`)
|
|
815
817
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -818,7 +820,7 @@ users
|
|
|
818
820
|
users
|
|
819
821
|
.command(`createMD5User`)
|
|
820
822
|
.description(`Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
821
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
823
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
822
824
|
.requiredOption(`--email <email>`, `User email.`)
|
|
823
825
|
.requiredOption(`--password <password>`, `User password hashed using MD5.`)
|
|
824
826
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -827,7 +829,7 @@ users
|
|
|
827
829
|
users
|
|
828
830
|
.command(`createPHPassUser`)
|
|
829
831
|
.description(`Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
830
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
832
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or pass the string 'ID.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.`)
|
|
831
833
|
.requiredOption(`--email <email>`, `User email.`)
|
|
832
834
|
.requiredOption(`--password <password>`, `User password hashed using PHPass.`)
|
|
833
835
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -836,7 +838,7 @@ users
|
|
|
836
838
|
users
|
|
837
839
|
.command(`createScryptUser`)
|
|
838
840
|
.description(`Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
839
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
841
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
840
842
|
.requiredOption(`--email <email>`, `User email.`)
|
|
841
843
|
.requiredOption(`--password <password>`, `User password hashed using Scrypt.`)
|
|
842
844
|
.requiredOption(`--passwordSalt <passwordSalt>`, `Optional salt used to hash password.`)
|
|
@@ -850,7 +852,7 @@ users
|
|
|
850
852
|
users
|
|
851
853
|
.command(`createScryptModifiedUser`)
|
|
852
854
|
.description(`Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
853
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
855
|
+
.requiredOption(`--userId <userId>`, `User 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.`)
|
|
854
856
|
.requiredOption(`--email <email>`, `User email.`)
|
|
855
857
|
.requiredOption(`--password <password>`, `User password hashed using Scrypt Modified.`)
|
|
856
858
|
.requiredOption(`--passwordSalt <passwordSalt>`, `Salt used to hash password.`)
|
|
@@ -862,7 +864,7 @@ users
|
|
|
862
864
|
users
|
|
863
865
|
.command(`createSHAUser`)
|
|
864
866
|
.description(`Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
865
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
867
|
+
.requiredOption(`--userId <userId>`, `User 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
868
|
.requiredOption(`--email <email>`, `User email.`)
|
|
867
869
|
.requiredOption(`--password <password>`, `User password hashed using SHA.`)
|
|
868
870
|
.option(`--passwordVersion <passwordVersion>`, `Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'`)
|
package/lib/config.js
CHANGED
|
@@ -166,6 +166,45 @@ class Local extends Config {
|
|
|
166
166
|
this.set("collections", collections);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
getTeams() {
|
|
170
|
+
if (!this.has("teams")) {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
return this.get("teams");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getTeam($id) {
|
|
177
|
+
if (!this.has("teams")) {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let teams = this.get("teams");
|
|
182
|
+
for (let i = 0; i < teams.length; i++) {
|
|
183
|
+
if (teams[i]['$id'] == $id) {
|
|
184
|
+
return teams[i];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
addTeam(props) {
|
|
192
|
+
if (!this.has("teams")) {
|
|
193
|
+
this.set("teams", []);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let teams = this.get("teams");
|
|
197
|
+
for (let i = 0; i < teams.length; i++) {
|
|
198
|
+
if (teams[i]['$id'] == props['$id']) {
|
|
199
|
+
teams[i] = props;
|
|
200
|
+
this.set("teams", teams);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
teams.push(props);
|
|
205
|
+
this.set("teams", teams);
|
|
206
|
+
}
|
|
207
|
+
|
|
169
208
|
getProject() {
|
|
170
209
|
if (!this.has("projectId") || !this.has("projectName")) {
|
|
171
210
|
return {};
|
package/lib/parser.js
CHANGED
|
@@ -149,6 +149,7 @@ const logo = "\n _ _ _ ___ __ _____
|
|
|
149
149
|
|
|
150
150
|
const commandDescriptions = {
|
|
151
151
|
"account": `The account command allows you to authenticate and manage a user account.`,
|
|
152
|
+
"graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
|
|
152
153
|
"avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
|
|
153
154
|
"databases": `The databases command allows you to create structured collections of documents, query and filter lists of documents.`,
|
|
154
155
|
"deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,
|
package/lib/questions.js
CHANGED
|
@@ -255,7 +255,7 @@ const questionsDeployFunctions = [
|
|
|
255
255
|
{
|
|
256
256
|
type: "input",
|
|
257
257
|
name: "override",
|
|
258
|
-
message: 'Are you sure you want to override this function's variables? This can lead to loss of secrets! Type "YES" to confirm.'
|
|
258
|
+
message: 'Are you sure you want to override this function\'s variables? This can lead to loss of secrets! Type "YES" to confirm.'
|
|
259
259
|
},
|
|
260
260
|
]
|
|
261
261
|
|
|
@@ -300,6 +300,32 @@ const questionsGetEntrypoint = [
|
|
|
300
300
|
},
|
|
301
301
|
]
|
|
302
302
|
|
|
303
|
+
const questionsDeployTeams = [
|
|
304
|
+
{
|
|
305
|
+
type: "checkbox",
|
|
306
|
+
name: "teams",
|
|
307
|
+
message: "Which teams would you like to deploy?",
|
|
308
|
+
choices: () => {
|
|
309
|
+
let teams = localConfig.getTeams();
|
|
310
|
+
if (teams.length === 0) {
|
|
311
|
+
throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
|
|
312
|
+
}
|
|
313
|
+
let choices = teams.map((team, idx) => {
|
|
314
|
+
return {
|
|
315
|
+
name: `${team.name} (${team['$id']})`,
|
|
316
|
+
value: team.$id
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
return choices;
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
type: "input",
|
|
324
|
+
name: "override",
|
|
325
|
+
message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
|
|
326
|
+
},
|
|
327
|
+
]
|
|
328
|
+
|
|
303
329
|
module.exports = {
|
|
304
330
|
questionsInitProject,
|
|
305
331
|
questionsLogin,
|
|
@@ -307,5 +333,6 @@ module.exports = {
|
|
|
307
333
|
questionsInitCollection,
|
|
308
334
|
questionsDeployFunctions,
|
|
309
335
|
questionsDeployCollections,
|
|
336
|
+
questionsDeployTeams,
|
|
310
337
|
questionsGetEntrypoint
|
|
311
338
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "1.1
|
|
5
|
+
"version": "1.2.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|