appwrite-cli 0.14.0 → 0.17.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.
- package/README.md +159 -4
- package/docs/examples/account/update-status.md +1 -0
- package/docs/examples/teams/list-logs.md +4 -0
- package/docs/examples/users/get-memberships.md +2 -0
- package/install.ps1 +98 -0
- package/install.sh +1 -9
- package/lib/client.js +7 -8
- package/lib/commands/account.js +33 -30
- package/lib/commands/avatars.js +14 -11
- package/lib/commands/database.js +16 -13
- package/lib/commands/deploy.js +4 -3
- package/lib/commands/functions.js +74 -36
- package/lib/commands/generic.js +11 -4
- package/lib/commands/health.js +5 -25
- package/lib/commands/init.js +1 -1
- package/lib/commands/locale.js +5 -2
- package/lib/commands/projects.js +9 -6
- package/lib/commands/storage.js +64 -38
- package/lib/commands/teams.js +45 -5
- package/lib/commands/users.js +33 -5
- package/lib/config.js +6 -4
- package/lib/questions.js +35 -2
- package/lib/sdks.js +17 -1
- package/lib/utils.js +19 -0
- package/package.json +8 -5
- package/docs/examples/account/delete.md +0 -1
- package/docs/examples/health/get-queue-usage.md +0 -1
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
|
|
9
|
+
**This SDK is compatible with Appwrite server version 0.14.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
|
-
0.
|
|
32
|
+
0.17.0
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -58,9 +58,164 @@ $ 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
|
-
0.
|
|
61
|
+
0.17.0
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## Getting Started
|
|
65
|
+
|
|
66
|
+
Before you can use the CLI, you need to login to your Appwrite account.
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
$ appwrite login
|
|
70
|
+
|
|
71
|
+
? Enter your email test@test.com
|
|
72
|
+
? Enter your password ********
|
|
73
|
+
✓ Success
|
|
74
|
+
```
|
|
75
|
+
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 )
|
|
76
|
+
|
|
77
|
+
* ### Initialising your project
|
|
78
|
+
Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
$ appwrite init project
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The following prompt will guide you through the setup process. The `init` command also creates an `appwrite.json` file representing your Appwrite project.
|
|
85
|
+
|
|
86
|
+
The `appwrite.json` file does a lot of things.
|
|
87
|
+
* Provides context to the CLI
|
|
88
|
+
* Keeps track of all your cloud functions
|
|
89
|
+
* Keeps track of all your project's collections
|
|
90
|
+
* Helps you deploy your Appwrite project to production and more..
|
|
91
|
+
|
|
92
|
+
You can also fetch all the collections in your current project using
|
|
93
|
+
```sh
|
|
94
|
+
appwrite init collection
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The CLI also comes with a convenient `--all` flag to perform both these steps at once.
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
appwrite init --all
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
* ### Creating and deploying cloud functions
|
|
104
|
+
|
|
105
|
+
The CLI makes it extremely easy to create and deploy Appwrite's cloud functions. Initialise your new function using
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
$ appwrite init function
|
|
109
|
+
? What would you like to name your function? My Awesome Function
|
|
110
|
+
? What runtime would you like to use? Node.js (node-15.5)
|
|
111
|
+
✓ Success
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This will create a new function `My Awesome Function` in your current Appwrite project and also create a template function for you to get started.
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
$ tree My\ Awesome\ Function
|
|
118
|
+
|
|
119
|
+
My Awesome Function
|
|
120
|
+
├── README.md
|
|
121
|
+
├── index.js
|
|
122
|
+
├── package-lock.json
|
|
123
|
+
└── package.json
|
|
124
|
+
|
|
125
|
+
0 directories, 4 files
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
You can now deploy this function using
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
$ appwrite deploy function
|
|
132
|
+
|
|
133
|
+
? Which functions would you like to deploy? My Awesome Function (61d1a4c81dfcd95bc834)
|
|
134
|
+
ℹ Info Deploying function My Awesome Function ( 61d1a4c81dfcd95bc834 )
|
|
135
|
+
✓ Success Deployed My Awesome Function ( 61d1a4c81dfcd95bc834 )
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Your function has now been deployed on your Appwrite server! As soon as the build process is finished, you can start executing the function.
|
|
139
|
+
|
|
140
|
+
* ### Deploying Collections
|
|
141
|
+
|
|
142
|
+
Similarly, you can deploy all your collections to your Appwrite server using
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
appwrite deploy collections
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The `deploy` command also comes with a convenient `--all` flag to deploy all your functions and collections at once.
|
|
149
|
+
|
|
150
|
+
```sh
|
|
151
|
+
appwrite deploy --all
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> ### Note
|
|
155
|
+
> By default, requests to domains with self signed SSL certificates (or no certificates) are disabled. If you trust the domain, you can bypass the certificate validation using
|
|
156
|
+
```sh
|
|
157
|
+
$ appwrite client --selfSigned true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Usage
|
|
161
|
+
|
|
162
|
+
The Appwrite CLI follows the following general syntax.
|
|
163
|
+
```sh
|
|
164
|
+
$ appwrite [COMMAND] --[OPTIONS]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A few sample commands to get you started
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
$ appwrite users create --userId "unique()" --email hello@appwrite.io --password very_strong_password
|
|
171
|
+
$ appwrite users list
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
To create a document you can use the following command
|
|
175
|
+
```sh
|
|
176
|
+
$ appwrite database createDocument --collectionId <ID> --documentId 'unique()' --data '{ "Name": "Iron Man" }' --read role:all team:abc
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Some Gotchas
|
|
180
|
+
- `data` must be a valid JSON string where each key and value are enclosed in double quotes `"` like the example above.
|
|
181
|
+
- Some arguments like the `read` and `write` permissions are expected to be arrays. In the Appwrite CLI, array values are passed in using space as a separator like in the example above.
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
To get information about the different services available, you can use
|
|
185
|
+
```sh
|
|
186
|
+
$ appwrite -h
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
To get information about a particular service and the commands available in a service you can use
|
|
190
|
+
```sh
|
|
191
|
+
$ appwrite users // or
|
|
192
|
+
$ appwrite users --help // or
|
|
193
|
+
$ appwrite users help // or
|
|
194
|
+
$ appwrite accounts
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
To get information about a particular command and the parameters it accepts, you can use
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
$ appwrite users list --help
|
|
201
|
+
$ appwrite account get --help
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
At any point, you can view or reset the CLI configuration using the `client` service.
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
$ appwrite client --debug
|
|
208
|
+
// This will display your endpoint, projectID, API key and so on.
|
|
209
|
+
$ appwrite client --reset
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## CI mode
|
|
213
|
+
|
|
214
|
+
The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
appwrite client --endpoint http://localhost/v1 --projectId <PROJECT_ID> --key <API KEY>
|
|
218
|
+
```
|
|
64
219
|
|
|
65
220
|
## Contribution
|
|
66
221
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
appwrite account updateStatus
|
package/install.ps1
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
## <script src="/dist/scripts/cli-bash.js"></script>
|
|
2
|
+
## <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/themes/prism-okaidia.min.css" rel="stylesheet" />
|
|
3
|
+
## <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/components/prism-core.min.js" data-manual></script>
|
|
4
|
+
## <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/components/prism-powershell.min.js"></script>
|
|
5
|
+
## <style>body {color: #272822; background-color: #272822; font-size: 0.8em;} </style>
|
|
6
|
+
# Love open-source, dev-tooling and passionate about code as much as we do?
|
|
7
|
+
# ---
|
|
8
|
+
# We're always looking for awesome hackers like you to join our 100% remote team!
|
|
9
|
+
# Check and see if you find any relevant position @ https://appwrite.io/company/careers 👩💻 😎
|
|
10
|
+
# (and let us know you found this message...)
|
|
11
|
+
|
|
12
|
+
# This script contains hidden JS code to allow better readability and syntax highlighting
|
|
13
|
+
# You can use "View source" of this page to see the full script.
|
|
14
|
+
|
|
15
|
+
# REPO
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.17.0/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.17.0/appwrite-cli-win-arm64.exe"
|
|
18
|
+
|
|
19
|
+
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
|
+
|
|
21
|
+
# Appwrite download directory
|
|
22
|
+
$APPWRITE_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath $APPWRITE_BINARY_NAME
|
|
23
|
+
|
|
24
|
+
# Appwrite CLI location
|
|
25
|
+
$APPWRITE_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Appwrite"
|
|
26
|
+
$APPWRITE_INSTALL_PATH = Join-Path -Path "$APPWRITE_INSTALL_DIR" -ChildPath "$APPWRITE_BINARY_NAME"
|
|
27
|
+
|
|
28
|
+
$USER_PATH_ENV_VAR = [Environment]::GetEnvironmentVariable("PATH", "User")
|
|
29
|
+
|
|
30
|
+
function Greeting {
|
|
31
|
+
Write-Host @"
|
|
32
|
+
|
|
33
|
+
_ _ _ ___ __ _____
|
|
34
|
+
/_\ _ __ _ ____ ___ __(_) |_ ___ / __\ / / \_ \
|
|
35
|
+
//_\\| '_ \| '_ \ \ /\ / / '__| | __/ _ \ / / / / / /\/
|
|
36
|
+
/ _ \ |_) | |_) \ V V /| | | | || __/ / /___/ /___/\/ /_
|
|
37
|
+
\_/ \_/ .__/| .__/ \_/\_/ |_| |_|\__\___| \____/\____/\____/
|
|
38
|
+
|_| |_|
|
|
39
|
+
|
|
40
|
+
"@ -ForegroundColor red
|
|
41
|
+
Write-Host "Welcome to the Appwrite CLI install shield."
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
function CheckSystemInfo {
|
|
46
|
+
Write-Host "[1/4] Getting System Info ..."
|
|
47
|
+
if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') {
|
|
48
|
+
Write-Host "PowerShell requires an execution policy of 'RemoteSigned'."
|
|
49
|
+
Write-Host "To make this change please run:"
|
|
50
|
+
Write-Host "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'"
|
|
51
|
+
break
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function DownloadBinary {
|
|
56
|
+
Write-Host "[2/4] Downloading Appwrite CLI binary ..."
|
|
57
|
+
Write-Host "🚦 Fetching latest version ... " -ForegroundColor green
|
|
58
|
+
|
|
59
|
+
if((Get-CimInstance Win32_operatingsystem).OSArchitecture -like '*ARM*') {
|
|
60
|
+
Invoke-WebRequest -Uri $GITHUB_arm64_URL -OutFile $APPWRITE_DOWNLOAD_DIR
|
|
61
|
+
} else {
|
|
62
|
+
Invoke-WebRequest -Uri $GITHUB_x64_URL -OutFile $APPWRITE_DOWNLOAD_DIR
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
New-Item -ItemType Directory -Path $APPWRITE_INSTALL_DIR
|
|
66
|
+
Move-Item $APPWRITE_DOWNLOAD_DIR $APPWRITE_INSTALL_PATH
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
function Install {
|
|
71
|
+
Write-Host "[3/4] Starting installation ..."
|
|
72
|
+
|
|
73
|
+
if ($USER_PATH_ENV_VAR -like '*Appwrite*') {
|
|
74
|
+
Write-Host "Skipping to add Appwrite to User Path."
|
|
75
|
+
} else {
|
|
76
|
+
[System.Environment]::SetEnvironmentVariable("PATH", $USER_PATH_ENV_VAR + ";$APPWRITE_INSTALL_DIR", "User")
|
|
77
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function CleanUp {
|
|
82
|
+
Write-Host "Cleaning up mess ..."
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function InstallCompleted {
|
|
86
|
+
Write-Host "[4/4] Finishing Installation ... "
|
|
87
|
+
cleanup
|
|
88
|
+
Write-Host "🤘 May the force be with you."
|
|
89
|
+
Write-Host "To get started with Appwrite CLI, please visit https://appwrite.io/docs/command-line"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Greeting
|
|
94
|
+
CheckSystemInfo
|
|
95
|
+
DownloadBinary
|
|
96
|
+
Install
|
|
97
|
+
CleanUp
|
|
98
|
+
InstallCompleted
|
package/install.sh
CHANGED
|
@@ -97,15 +97,7 @@ printSuccess() {
|
|
|
97
97
|
downloadBinary() {
|
|
98
98
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
res=$(curl -L -s -H 'Accept: application/json' https://github.com/$GITHUB_REPOSITORY_NAME/releases/latest)
|
|
102
|
-
if [[ "$res" == *"error"* ]]; then
|
|
103
|
-
printf "${RED}❌ There was an error. Try again later.${NC} \n"
|
|
104
|
-
exit 1
|
|
105
|
-
fi
|
|
106
|
-
printSuccess
|
|
107
|
-
|
|
108
|
-
GITHUB_LATEST_VERSION=$( echo $res | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
|
|
100
|
+
GITHUB_LATEST_VERSION="0.17.0"
|
|
109
101
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
110
102
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
111
103
|
|
package/lib/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const axios = require("axios");
|
|
3
|
+
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
3
4
|
const FormData = require("form-data");
|
|
4
5
|
const AppwriteException = require("./exception.js");
|
|
5
6
|
const { globalConfig } = require("./config.js");
|
|
@@ -11,9 +12,9 @@ class Client {
|
|
|
11
12
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
12
13
|
this.headers = {
|
|
13
14
|
'content-type': '',
|
|
14
|
-
'x-sdk-version': 'appwrite:cli:0.
|
|
15
|
-
'User-Agent' : `AppwriteCLI/0.
|
|
16
|
-
'X-Appwrite-Response-Format' : '0.
|
|
15
|
+
'x-sdk-version': 'appwrite:cli:0.17.0',
|
|
16
|
+
'User-Agent' : `AppwriteCLI/0.17.0 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
17
|
+
'X-Appwrite-Response-Format' : '0.14.0',
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -151,7 +152,7 @@ class Client {
|
|
|
151
152
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
headers = Object.assign(this.headers, headers);
|
|
155
|
+
headers = Object.assign({}, this.headers, headers);
|
|
155
156
|
|
|
156
157
|
let contentType = headers["content-type"].toLowerCase();
|
|
157
158
|
|
|
@@ -180,11 +181,9 @@ class Client {
|
|
|
180
181
|
params: method.toUpperCase() === "GET" ? params : {},
|
|
181
182
|
headers: headers,
|
|
182
183
|
data:
|
|
183
|
-
method.toUpperCase() === "GET" ||
|
|
184
|
-
contentType.startsWith("multipart/form-data")
|
|
185
|
-
? formData
|
|
186
|
-
: params,
|
|
184
|
+
method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? formData : params,
|
|
187
185
|
json: contentType.startsWith("application/json"),
|
|
186
|
+
transformRequest: method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? undefined : (data) => JSONbig.stringify(data),
|
|
188
187
|
responseType: responseType,
|
|
189
188
|
};
|
|
190
189
|
try {
|
package/lib/commands/account.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const pathLib = require('path');
|
|
3
|
+
const tar = require("tar");
|
|
4
|
+
const ignore = require("ignore");
|
|
2
5
|
const { promisify } = require('util');
|
|
3
6
|
const libClient = require('../client.js');
|
|
4
|
-
const
|
|
7
|
+
const { getAllFiles } = require('../utils.js');
|
|
5
8
|
const { Command } = require('commander');
|
|
6
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -65,23 +68,6 @@ const accountCreate = async ({ userId, email, password, name, parseOutput = true
|
|
|
65
68
|
return response;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
const accountDelete = async ({ parseOutput = true, sdk = undefined}) => {
|
|
69
|
-
|
|
70
|
-
let client = !sdk ? await sdkForProject() : sdk;
|
|
71
|
-
let path = '/account';
|
|
72
|
-
let payload = {};
|
|
73
|
-
let response = undefined;
|
|
74
|
-
response = await client.call('delete', path, {
|
|
75
|
-
'content-type': 'application/json',
|
|
76
|
-
}, payload);
|
|
77
|
-
|
|
78
|
-
if (parseOutput) {
|
|
79
|
-
parse(response)
|
|
80
|
-
success()
|
|
81
|
-
}
|
|
82
|
-
return response;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
71
|
const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = undefined}) => {
|
|
86
72
|
/* @param {string} email */
|
|
87
73
|
/* @param {string} password */
|
|
@@ -234,7 +220,7 @@ const accountUpdatePrefs = async ({ prefs, parseOutput = true, sdk = undefined})
|
|
|
234
220
|
|
|
235
221
|
/** Body Params */
|
|
236
222
|
if (typeof prefs !== 'undefined') {
|
|
237
|
-
payload['prefs'] = prefs;
|
|
223
|
+
payload['prefs'] = JSON.parse(prefs);
|
|
238
224
|
}
|
|
239
225
|
|
|
240
226
|
let response = undefined;
|
|
@@ -546,6 +532,23 @@ const accountDeleteSession = async ({ sessionId, parseOutput = true, sdk = undef
|
|
|
546
532
|
return response;
|
|
547
533
|
}
|
|
548
534
|
|
|
535
|
+
const accountUpdateStatus = async ({ parseOutput = true, sdk = undefined}) => {
|
|
536
|
+
|
|
537
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
538
|
+
let path = '/account/status';
|
|
539
|
+
let payload = {};
|
|
540
|
+
let response = undefined;
|
|
541
|
+
response = await client.call('patch', path, {
|
|
542
|
+
'content-type': 'application/json',
|
|
543
|
+
}, payload);
|
|
544
|
+
|
|
545
|
+
if (parseOutput) {
|
|
546
|
+
parse(response)
|
|
547
|
+
success()
|
|
548
|
+
}
|
|
549
|
+
return response;
|
|
550
|
+
}
|
|
551
|
+
|
|
549
552
|
const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefined}) => {
|
|
550
553
|
/* @param {string} url */
|
|
551
554
|
|
|
@@ -614,11 +617,6 @@ account
|
|
|
614
617
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
615
618
|
.action(actionRunner(accountCreate))
|
|
616
619
|
|
|
617
|
-
account
|
|
618
|
-
.command(`delete`)
|
|
619
|
-
.description(`Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately.`)
|
|
620
|
-
.action(actionRunner(accountDelete))
|
|
621
|
-
|
|
622
620
|
account
|
|
623
621
|
.command(`updateEmail`)
|
|
624
622
|
.description(`Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. `)
|
|
@@ -646,7 +644,7 @@ account
|
|
|
646
644
|
|
|
647
645
|
account
|
|
648
646
|
.command(`updatePassword`)
|
|
649
|
-
.description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and
|
|
647
|
+
.description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.`)
|
|
650
648
|
.requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
|
|
651
649
|
.option(`--oldPassword <oldPassword>`, `Current user password. Must be at least 8 chars.`)
|
|
652
650
|
.action(actionRunner(accountUpdatePassword))
|
|
@@ -718,10 +716,10 @@ account
|
|
|
718
716
|
account
|
|
719
717
|
.command(`createOAuth2Session`)
|
|
720
718
|
.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.. `)
|
|
721
|
-
.requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch,
|
|
719
|
+
.requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe.`)
|
|
722
720
|
.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.`)
|
|
723
721
|
.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.`)
|
|
724
|
-
.option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.`)
|
|
722
|
+
.option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 128 characters long.`)
|
|
725
723
|
.action(actionRunner(accountCreateOAuth2Session))
|
|
726
724
|
|
|
727
725
|
account
|
|
@@ -732,7 +730,7 @@ account
|
|
|
732
730
|
|
|
733
731
|
account
|
|
734
732
|
.command(`updateSession`)
|
|
735
|
-
.description(
|
|
733
|
+
.description(`Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token.`)
|
|
736
734
|
.requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to update the current device session.`)
|
|
737
735
|
.action(actionRunner(accountUpdateSession))
|
|
738
736
|
|
|
@@ -742,6 +740,11 @@ account
|
|
|
742
740
|
.requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to delete the current device session.`)
|
|
743
741
|
.action(actionRunner(accountDeleteSession))
|
|
744
742
|
|
|
743
|
+
account
|
|
744
|
+
.command(`updateStatus`)
|
|
745
|
+
.description(`Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.`)
|
|
746
|
+
.action(actionRunner(accountUpdateStatus))
|
|
747
|
+
|
|
745
748
|
account
|
|
746
749
|
.command(`createVerification`)
|
|
747
750
|
.description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateVerification). The verification link sent to the user's email address is valid for 7 days. Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. `)
|
|
@@ -760,7 +763,6 @@ module.exports = {
|
|
|
760
763
|
account,
|
|
761
764
|
accountGet,
|
|
762
765
|
accountCreate,
|
|
763
|
-
accountDelete,
|
|
764
766
|
accountUpdateEmail,
|
|
765
767
|
accountCreateJWT,
|
|
766
768
|
accountGetLogs,
|
|
@@ -780,6 +782,7 @@ module.exports = {
|
|
|
780
782
|
accountGetSession,
|
|
781
783
|
accountUpdateSession,
|
|
782
784
|
accountDeleteSession,
|
|
785
|
+
accountUpdateStatus,
|
|
783
786
|
accountCreateVerification,
|
|
784
787
|
accountUpdateVerification
|
|
785
|
-
};
|
|
788
|
+
};
|
package/lib/commands/avatars.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const pathLib = require('path');
|
|
3
|
+
const tar = require("tar");
|
|
4
|
+
const ignore = require("ignore");
|
|
2
5
|
const { promisify } = require('util');
|
|
3
6
|
const libClient = require('../client.js');
|
|
4
|
-
const
|
|
7
|
+
const { getAllFiles } = require('../utils.js');
|
|
5
8
|
const { Command } = require('commander');
|
|
6
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
7
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -271,7 +274,7 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
|
|
|
271
274
|
|
|
272
275
|
avatars
|
|
273
276
|
.command(`getBrowser`)
|
|
274
|
-
.description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user /account/sessions endpoint. Use width, height and quality arguments to change the output settings.`)
|
|
277
|
+
.description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.`)
|
|
275
278
|
.requiredOption(`--code <code>`, `Browser Code.`)
|
|
276
279
|
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
277
280
|
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
@@ -281,7 +284,7 @@ avatars
|
|
|
281
284
|
|
|
282
285
|
avatars
|
|
283
286
|
.command(`getCreditCard`)
|
|
284
|
-
.description(`The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings
|
|
287
|
+
.description(`The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
|
|
285
288
|
.requiredOption(`--code <code>`, `Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.`)
|
|
286
289
|
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
287
290
|
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
@@ -298,7 +301,7 @@ avatars
|
|
|
298
301
|
|
|
299
302
|
avatars
|
|
300
303
|
.command(`getFlag`)
|
|
301
|
-
.description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings
|
|
304
|
+
.description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
|
|
302
305
|
.requiredOption(`--code <code>`, `Country Code. ISO Alpha-2 country code format.`)
|
|
303
306
|
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
304
307
|
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
@@ -308,16 +311,16 @@ avatars
|
|
|
308
311
|
|
|
309
312
|
avatars
|
|
310
313
|
.command(`getImage`)
|
|
311
|
-
.description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol
|
|
314
|
+
.description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. `)
|
|
312
315
|
.requiredOption(`--url <url>`, `Image URL which you want to crop.`)
|
|
313
|
-
.option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000.`, parseInteger)
|
|
314
|
-
.option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000.`, parseInteger)
|
|
316
|
+
.option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
|
|
317
|
+
.option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
|
|
315
318
|
.requiredOption(`--destination <path>`, `output file path.`)
|
|
316
319
|
.action(actionRunner(avatarsGetImage))
|
|
317
320
|
|
|
318
321
|
avatars
|
|
319
322
|
.command(`getInitials`)
|
|
320
|
-
.description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials
|
|
323
|
+
.description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
|
|
321
324
|
.option(`--name <name>`, `Full Name. When empty, current user name or email will be used. Max length: 128 chars.`)
|
|
322
325
|
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
323
326
|
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
|
|
@@ -328,9 +331,9 @@ avatars
|
|
|
328
331
|
|
|
329
332
|
avatars
|
|
330
333
|
.command(`getQR`)
|
|
331
|
-
.description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image
|
|
334
|
+
.description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. `)
|
|
332
335
|
.requiredOption(`--text <text>`, `Plain text to be converted to QR code image.`)
|
|
333
|
-
.option(`--size <size>`, `QR code size. Pass an integer between
|
|
336
|
+
.option(`--size <size>`, `QR code size. Pass an integer between 1 to 1000. Defaults to 400.`, parseInteger)
|
|
334
337
|
.option(`--margin <margin>`, `Margin from edge. Pass an integer between 0 to 10. Defaults to 1.`, parseInteger)
|
|
335
338
|
.option(`--download <download>`, `Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.`, parseBool)
|
|
336
339
|
.requiredOption(`--destination <path>`, `output file path.`)
|
|
@@ -346,4 +349,4 @@ module.exports = {
|
|
|
346
349
|
avatarsGetImage,
|
|
347
350
|
avatarsGetInitials,
|
|
348
351
|
avatarsGetQR
|
|
349
|
-
};
|
|
352
|
+
};
|