Skip to content

Commit f9eb3ae

Browse files
Merge pull request #11 from appwrite/dev
feat: update version
2 parents 03de4d4 + 90efaa0 commit f9eb3ae

34 files changed

+132
-75
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Appwrite Command Line SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
5+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
56
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
67
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
78

8-
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
9+
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
910

10-
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.
11-
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.
12-
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
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)
1312

1413
![Appwrite](https://appwrite.io/images/github.png)
1514

app/Appwrite/services/account.php renamed to app/account.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,22 @@
255255
$parser->parseResponse($response);
256256
});
257257

258+
$cli
259+
->task('getSession')
260+
->label('description', "Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.\n\n")
261+
->param('sessionId', '' , new Wildcard() , 'Session unique ID. Use the string 'current' to get the current device session.', false)
262+
->action(function ( $sessionId ) use ($parser) {
263+
/** @var string $sessionId */
264+
265+
$client = new Client();
266+
$path = str_replace(['{sessionId}'], [$sessionId], '/account/sessions/{sessionId}');
267+
$params = [];
268+
$response = $client->call(Client::METHOD_GET, $path, [
269+
'content-type' => 'application/json',
270+
], $params);
271+
$parser->parseResponse($response);
272+
});
273+
258274
$cli
259275
->task('deleteSession')
260276
->label('description', "Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.\n\n")
@@ -343,6 +359,7 @@
343359
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.",
344360
"getSessions" => "Get currently logged in user list of active sessions across different devices.",
345361
"deleteSessions" => "Delete all sessions from the user account and remove any sessions cookies from the end client.",
362+
"getSession" => "Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.",
346363
"deleteSession" => "Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted.",
347364
"createVerification" => "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.
348365
File renamed without changes.

app/Appwrite/services/client.php renamed to app/client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
$cli
110110
->task('version')
111111
->action(function() {
112-
Console::log('CLI Version : 0.10.0');
113-
Console::log('Server Version : 0.8.0');
112+
Console::log('CLI Version : 0.11.0');
113+
Console::log('Server Version : 0.9.0');
114114
});
115115

116116

File renamed without changes.

app/Appwrite/services/functions.php renamed to app/functions.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@
7474
->label('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.\n\n")
7575
->param('name', '' , new Wildcard() , 'Function name. Max length: 128 chars.', false)
7676
->param('execute', '' , new Wildcard() , 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', false)
77-
->param('env', '' , new Wildcard() , 'Execution enviornment.', false)
77+
->param('runtime', '' , new Wildcard() , 'Execution runtime.', false)
7878
->param('vars', [] , new Wildcard() , 'Key-value JSON object.', true)
7979
->param('events', [] , new Wildcard() , 'Events list.', true)
8080
->param('schedule', '' , new Wildcard() , 'Schedule CRON syntax.', true)
8181
->param('timeout', 15 , new Wildcard() , 'Function maximum execution time in seconds.', true)
82-
->action(function ( $name, $execute, $env, $vars, $events, $schedule, $timeout ) use ($parser) {
82+
->action(function ( $name, $execute, $runtime, $vars, $events, $schedule, $timeout ) use ($parser) {
8383
/** @var string $name */
8484
/** @var array $execute */
85-
/** @var string $env */
85+
/** @var string $runtime */
8686
/** @var object $vars */
8787
/** @var array $events */
8888
/** @var string $schedule */
@@ -94,7 +94,7 @@
9494
/** Body Params */
9595
$params['name'] = $name;
9696
$params['execute'] = !is_array($execute) ? array($execute) : $execute;
97-
$params['env'] = $env;
97+
$params['runtime'] = $runtime;
9898
$params['vars'] = $vars;
9999
$params['events'] = !is_array($events) ? array($events) : $events;
100100
$params['schedule'] = $schedule;
@@ -308,14 +308,15 @@
308308
$params = [];
309309
/** Body Params */
310310
$params['command'] = $command;
311-
$cloudFunctionPath = realpath(__DIR__.'/../../../files/'.$code);
312-
$cloudFunctionParentDir = dirname($cloudFunctionPath, 1);
313-
$cloudFunctionDirName = basename($cloudFunctionPath);
311+
$code = \urldecode($code);
312+
$cloudFunctionPath = realpath(__DIR__.'/../files/'.$code);
313+
$cloudFunctionParentDir = escapeshellarg(dirname($cloudFunctionPath, 1));
314+
$cloudFunctionDirName = escapeshellarg(basename($cloudFunctionPath));
314315
if (file_exists($cloudFunctionPath) === false ) {
315316
throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. ");
316317
}
317318
$archiveName = 'code.tar.gz';
318-
$volumeMountPoint = realpath(__DIR__.'/../../../files/');
319+
$volumeMountPoint = realpath(__DIR__.'/../files/');
319320
exec("tar -zcvf $archiveName -C $cloudFunctionParentDir $cloudFunctionDirName && mv $archiveName $volumeMountPoint");
320321
$archivePath = realpath($volumeMountPoint."/$archiveName");
321322
$cFile = new \CURLFile($archivePath, 'application/x-gzip' , basename($archivePath));
File renamed without changes.
File renamed without changes.

app/Appwrite/services/init.php renamed to app/init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Utopia\CLI\Console;
1111
use Appwrite\Parser;
1212

13-
const USER_PREFERENCES_FILE = __DIR__."/../../.preferences/.prefs.json";
13+
const USER_PREFERENCES_FILE = __DIR__."/.preferences/.prefs.json";
1414
const PREFERENCE_ENDPOINT = "endpoint";
1515

1616
/**
File renamed without changes.

app/Appwrite/services/storage.php renamed to app/storage.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
$path = str_replace([], [], '/storage/files');
8585
$params = [];
8686
/** Body Params */
87-
$file = realpath(__DIR__.'/../../../files/'.$file);
87+
$file = realpath(__DIR__.'/../files/'.\urldecode($file));
8888
if (file_exists($file) === false ) {
8989
throw new Exception("Path doesn't exist. Please ensure that the path is within the current directory. ");
9090
}
@@ -175,6 +175,7 @@
175175
->param('fileId', '' , new Wildcard() , 'File unique ID', false)
176176
->param('width', 0 , new Wildcard() , 'Resize preview image width, Pass an integer between 0 to 4000.', true)
177177
->param('height', 0 , new Wildcard() , 'Resize preview image height, Pass an integer between 0 to 4000.', true)
178+
->param('gravity', 'center' , new Wildcard() , 'Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right', true)
178179
->param('quality', 100 , new Wildcard() , 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
179180
->param('borderWidth', 0 , new Wildcard() , 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
180181
->param('borderColor', '' , new Wildcard() , 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
@@ -183,10 +184,11 @@
183184
->param('rotation', 0 , new Wildcard() , 'Preview image rotation in degrees. Pass an integer between 0 and 360.', true)
184185
->param('background', '' , new Wildcard() , 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true)
185186
->param('output', '' , new Wildcard() , 'Output format type (jpeg, jpg, png, gif and webp).', true)
186-
->action(function ( $fileId, $width, $height, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output ) use ($parser) {
187+
->action(function ( $fileId, $width, $height, $gravity, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output ) use ($parser) {
187188
/** @var string $fileId */
188189
/** @var integer $width */
189190
/** @var integer $height */
191+
/** @var string $gravity */
190192
/** @var integer $quality */
191193
/** @var integer $borderWidth */
192194
/** @var string $borderColor */
@@ -202,6 +204,7 @@
202204
/** Query Params */
203205
$params['width'] = $width;
204206
$params['height'] = $height;
207+
$params['gravity'] = $gravity;
205208
$params['quality'] = $quality;
206209
$params['borderWidth'] = $borderWidth;
207210
$params['borderColor'] = $borderColor;
File renamed without changes.

app/Appwrite/services/users.php renamed to app/users.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,26 @@
247247
$parser->parseResponse($response);
248248
});
249249

250+
$cli
251+
->task('updateVerification')
252+
->label('description', "Update the user email verification status by its unique ID.\n\n")
253+
->param('userId', '' , new Wildcard() , 'User unique ID.', false)
254+
->param('emailVerification', '' , new Wildcard() , 'User Email Verification Status.', false)
255+
->action(function ( $userId, $emailVerification ) use ($parser) {
256+
/** @var string $userId */
257+
/** @var boolean $emailVerification */
258+
259+
$client = new Client();
260+
$path = str_replace(['{userId}'], [$userId], '/users/{userId}/verification');
261+
$params = [];
262+
/** Body Params */
263+
$params['emailVerification'] = $emailVerification;
264+
$response = $client->call(Client::METHOD_PATCH, $path, [
265+
'content-type' => 'application/json',
266+
], $params);
267+
$parser->parseResponse($response);
268+
});
269+
250270

251271
$cli
252272
->task('help')
@@ -273,6 +293,7 @@
273293
"deleteSessions" => "Delete all user's sessions by using the user's unique ID.",
274294
"deleteSession" => "Delete a user sessions by its unique ID.",
275295
"updateStatus" => "Update the user status by its unique ID.",
296+
"updateVerification" => "Update the user email verification status by its unique ID.",
276297
];
277298
$parser->formatArray($commands);
278299
Console::log("\nRun 'appwrite users COMMAND --help' for more information on a command.");

bin/account

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/account.php help
4+
php /usr/local/code/app/account.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/account.php $@
6+
php /usr/local/code/app/account.php $@
77
fi

bin/avatars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/avatars.php help
4+
php /usr/local/code/app/avatars.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/avatars.php $@
6+
php /usr/local/code/app/avatars.php $@
77
fi

bin/client

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/client.php help
4+
php /usr/local/code/app/client.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/client.php $@
6+
php /usr/local/code/app/client.php $@
77
fi

bin/database

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/database.php help
4+
php /usr/local/code/app/database.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/database.php $@
6+
php /usr/local/code/app/database.php $@
77
fi

bin/functions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/functions.php help
4+
php /usr/local/code/app/functions.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/functions.php $@
6+
php /usr/local/code/app/functions.php $@
77
fi

bin/health

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/health.php help
4+
php /usr/local/code/app/health.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/health.php $@
6+
php /usr/local/code/app/health.php $@
77
fi

bin/help

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
php /usr/local/code/app/Appwrite/services/help.php $@
3+
php /usr/local/code/app/help.php $@

bin/init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
php /usr/local/code/app/Appwrite/services/init.php init $@
3+
php /usr/local/code/app/init.php init $@

bin/locale

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/locale.php help
4+
php /usr/local/code/app/locale.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/locale.php $@
6+
php /usr/local/code/app/locale.php $@
77
fi

bin/storage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/storage.php help
4+
php /usr/local/code/app/storage.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/storage.php $@
6+
php /usr/local/code/app/storage.php $@
77
fi

bin/teams

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/teams.php help
4+
php /usr/local/code/app/teams.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/teams.php $@
6+
php /usr/local/code/app/teams.php $@
77
fi

bin/users

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
if [[ $# -eq 0 ]]; then
4-
php /usr/local/code/app/Appwrite/services/users.php help
4+
php /usr/local/code/app/users.php help
55
else
6-
php /usr/local/code/app/Appwrite/services/users.php $@
6+
php /usr/local/code/app/users.php $@
77
fi

bin/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
php /usr/local/code/app/Appwrite/services/client.php version
3+
php /usr/local/code/app/client.php version

docs/examples/account/get-session.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appwrite account getSession --sessionId="[SESSION_ID]"

docs/examples/functions/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
appwrite functions create --name="[NAME]" --execute="" --env="dotnet-3.1" --vars="{}" --events="" --schedule="" --timeout="1"
1+
appwrite functions create --name="[NAME]" --execute="" --runtime="java-11.0" --vars="{}" --events="" --schedule="" --timeout="1"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
appwrite storage getFilePreview --fileId="[FILE_ID]" --width="0" --height="0" --quality="0" --borderWidth="0" --borderColor="" --borderRadius="0" --opacity="0" --rotation="0" --background="" --output="jpg"
1+
appwrite storage getFilePreview --fileId="[FILE_ID]" --width="0" --height="0" --gravity="center" --quality="0" --borderWidth="0" --borderColor="" --borderRadius="0" --opacity="0" --rotation="0" --background="" --output="jpg"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appwrite users updateVerification --userId="[USER_ID]" --emailVerification=""

install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $APPWRITE_EXECUTABLE_FILEPATH = Join-Path -Path $APPWRITE_INSTALL_DIR -ChildPath
2525
$APPWRITE_CLI_IMAGE_NAME = "appwrite/cli"
2626

2727
# Appwrite CLI image version
28-
$APPWRITE_CLI_IMAGE_VERSION = "0.10.0"
28+
$APPWRITE_CLI_IMAGE_VERSION = "0.11.0"
2929

3030
$APPWRITE_EXECUTABLE_CONTENT = @"
3131
`$allowList = 'version', 'help', 'init', 'client' , 'account', 'avatars', 'database', 'functions', 'health', 'locale', 'storage', 'teams', 'users'

install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ APPWRITE_TEMP_NAME=temp
3030
APPWRITE_CLI_IMAGE_NAME=appwrite/cli
3131

3232
# Appwrite CLI image version
33-
APPWRITE_CLI_IMAGE_VERSION=0.10.0
33+
APPWRITE_CLI_IMAGE_VERSION=0.11.0
3434

3535
# sudo is required to copy executable to APPWRITE_INSTALL_DIR for linux
3636
USE_SUDO="false"
@@ -147,7 +147,7 @@ for x in "${@}" ; do
147147
_args=$_args" "$x
148148
done
149149
150-
bash -c "docker run -i --rm --volume appwrite-cli:/usr/local/code/app/.preferences/ --volume $(pwd):/usr/local/code/files:rw --network host '$APPWRITE_CLI_IMAGE_NAME:$APPWRITE_CLI_IMAGE_VERSION' $_args" ' > $APPWRITE_TEMP_NAME
150+
bash -c "docker run -i --rm --volume appwrite-cli:/usr/local/code/app/.preferences/ --volume \"$PWD\":/usr/local/code/files:rw --network host '$APPWRITE_CLI_IMAGE_NAME:$APPWRITE_CLI_IMAGE_VERSION' $_args" ' > $APPWRITE_TEMP_NAME
151151

152152
printf "${GREEN}🚧 Setting Permissions ${NC}\n"
153153
chmod +x $APPWRITE_TEMP_NAME

0 commit comments

Comments
 (0)