1
0
Fork 0
mirror of synced 2024-06-25 17:50:38 +12:00

Merge branch '0.9.x' into feat-upgrade-runtimes

This commit is contained in:
Damodar Lohani 2021-07-04 11:11:36 +05:45
commit 02c5eba4e4
45 changed files with 6336 additions and 1600 deletions

3
.gitignore vendored
View file

@ -5,4 +5,5 @@
/.idea/
.DS_Store
.php_cs.cache
debug/
debug/
app/sdks

View file

@ -3,6 +3,7 @@
## Features
- Added support for Android
- Added a new Cloud Functions runtime for Java
- Added a new gravity option when croping storage images using the file preview endpoint (#1260)
- Upgraded GEOIP DB file to Jun 2021 release (#1256)
- Added file created date to file info on the console (#1183)
@ -22,6 +23,7 @@
- _APP_INFLUXDB_HOST
- _APP_INFLUXDB_PORT
- Added new endpoint to get a session based on it's ID (#1294)
- Added added a new version param to the migration script (#1342)
## Breaking Changes (Read before upgrading!)
- Renamed `env` param on `/v1/functions` to `runtime` (#1314)
@ -39,6 +41,7 @@
- Fixed missing session object when OAuth session creation event is triggered (#1208)
- Fixed bug where we didn't ignore the email case, converted all emails to lowercase internally (#1243)
- Fixed a console bug where you can't click a user with no name, added a placehoder for anonyomous users (#1220)
- Fixed unique keys not being updated when changing a user's email address (#1301)
## Security

View file

@ -16,7 +16,7 @@ FROM php:8.0-cli-alpine as step1
ENV PHP_REDIS_VERSION=5.3.4 \
PHP_SWOOLE_VERSION=v4.6.7 \
PHP_IMAGICK_VERSION=master \
PHP_IMAGICK_VERSION=3.5.0 \
PHP_YAML_VERSION=2.2.1 \
PHP_MAXMINDDB_VERSION=v1.10.1
@ -53,10 +53,8 @@ RUN \
make && make install && \
cd .. && \
## Imagick Extension
## Last working commit https://github.com/Imagick/imagick/commit/35741750aa1cda2b7ac354bfa6128fa037e9cf32
git clone --branch $PHP_IMAGICK_VERSION https://github.com/Imagick/imagick && \
git clone --depth 1 --branch $PHP_IMAGICK_VERSION https://github.com/imagick/imagick && \
cd imagick && \
git checkout 35741750aa1cda2b7ac354bfa6128fa037e9cf32 && \
phpize && \
./configure && \
make && make install && \
@ -152,10 +150,12 @@ RUN \
brotli-dev \
yaml-dev \
imagemagick \
imagemagick-dev \
libmaxminddb-dev \
certbot \
docker-cli \
docker-compose \
libgomp \
&& docker-php-ext-install sockets opcache pdo_mysql \
&& apk del .deps \
&& rm -rf /var/cache/apk/*

View file

@ -15,7 +15,7 @@ return [
[
'key' => 'web',
'name' => 'Web',
'version' => '3.1.0',
'version' => '3.2.0',
'url' => 'https://github.com/appwrite/sdk-for-web',
'package' => 'https://www.npmjs.com/package/appwrite',
'enabled' => true,
@ -62,7 +62,7 @@ return [
[
'key' => 'flutter',
'name' => 'Flutter',
'version' => '0.6.4',
'version' => '0.7.0',
'url' => 'https://github.com/appwrite/sdk-for-flutter',
'package' => 'https://pub.dev/packages/appwrite',
'enabled' => true,
@ -152,7 +152,7 @@ return [
[
'key' => 'web',
'name' => 'Console',
'version' => '2.0.0',
'version' => '2.1.0',
'url' => 'https://github.com/appwrite/sdk-for-console',
'package' => '',
'enabled' => true,
@ -179,7 +179,7 @@ return [
[
'key' => 'nodejs',
'name' => 'Node.js',
'version' => '2.3.0',
'version' => '2.4.0',
'url' => 'https://github.com/appwrite/sdk-for-node',
'package' => 'https://www.npmjs.com/package/node-appwrite',
'enabled' => true,
@ -196,7 +196,7 @@ return [
[
'key' => 'deno',
'name' => 'Deno',
'version' => '0.2.2',
'version' => '0.3.0',
'url' => 'https://github.com/appwrite/sdk-for-deno',
'package' => 'https://deno.land/x/appwrite',
'enabled' => true,
@ -213,7 +213,7 @@ return [
[
'key' => 'php',
'name' => 'PHP',
'version' => '2.1.2',
'version' => '2.2.0',
'url' => 'https://github.com/appwrite/sdk-for-php',
'package' => 'https://packagist.org/packages/appwrite/appwrite',
'enabled' => true,
@ -230,7 +230,7 @@ return [
[
'key' => 'python',
'name' => 'Python',
'version' => '0.3.0',
'version' => '0.4.0',
'url' => 'https://github.com/appwrite/sdk-for-python',
'package' => 'https://pypi.org/project/appwrite/',
'enabled' => true,
@ -247,7 +247,7 @@ return [
[
'key' => 'ruby',
'name' => 'Ruby',
'version' => '2.2.0',
'version' => '2.3.0',
'url' => 'https://github.com/appwrite/sdk-for-ruby',
'package' => 'https://rubygems.org/gems/appwrite',
'enabled' => true,
@ -264,7 +264,7 @@ return [
[
'key' => 'go',
'name' => 'Go',
'version' => '0.0.7',
'version' => '0.1.0',
'url' => 'https://github.com/appwrite/sdk-for-go',
'package' => '',
'enabled' => false,
@ -315,7 +315,7 @@ return [
[
'key' => 'dart',
'name' => 'Dart',
'version' => '0.6.3',
'version' => '0.7.0',
'url' => 'https://github.com/appwrite/sdk-for-dart',
'package' => 'https://pub.dev/packages/dart_appwrite',
'enabled' => true,
@ -332,7 +332,7 @@ return [
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '0.10.0',
'version' => '0.11.0',
'url' => 'https://github.com/appwrite/sdk-for-cli',
'package' => 'https://github.com/appwrite/sdk-for-cli',
'enabled' => true,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1155,14 +1155,23 @@ App::patch('/v1/account/email')
// TODO after this user needs to confirm mail again
$user = $projectDB->updateDocument(\array_merge(
if (!$isAnonymousUser) {
// Remove previous unique ID.
$projectDB->deleteUniqueKey(\md5($user->getArrayCopy()['$collection'].':'.'email'.'='.$user->getAttribute('email')));
}
$document = (\array_merge(
$user->getArrayCopy(),
($isAnonymousUser ? [ 'password' => Auth::passwordHash($password) ] : []),
[
'email' => $email,
'emailVerification' => false,
]
));
));
$user = $projectDB->updateDocument($document);
$projectDB->addUniqueKey(\md5($document['$collection'].':'.'email'.'='.$email));
if (false === $user) {
throw new Exception('Failed saving user to DB', 500);

View file

@ -22,7 +22,6 @@ use Utopia\Image\Image;
use Appwrite\OpenSSL\OpenSSL;
use Appwrite\Utopia\Response;
use Utopia\Config\Config;
use Utopia\Validator\Numeric;
App::post('/v1/storage/files')
->desc('Create File')
@ -280,7 +279,7 @@ App::get('/v1/storage/files/:fileId/preview')
$fileLogos = Config::getParam('storage-logos');
$date = \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache
$key = \md5($fileId.$width.$height.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
$key = \md5($fileId.$width.$height.$gravity.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
$file = $projectDB->getDocument($fileId);
@ -300,7 +299,7 @@ App::get('/v1/storage/files/:fileId/preview')
$cipher = null;
$background = (empty($background)) ? 'eceff1' : $background;
$type = \strtolower(\pathinfo($path, PATHINFO_EXTENSION));
$key = \md5($path.$width.$height.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
$key = \md5($path.$width.$height.$gravity.$quality.$borderWidth.$borderColor.$borderRadius.$opacity.$rotation.$background.$storage.$output);
}
$compressor = new GZIP();

View file

@ -7,7 +7,7 @@ use Appwrite\Network\Validator\Host;
use Appwrite\Utopia\Response;
use Utopia\App;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;
use Utopia\Storage\Validator\File;
@ -24,7 +24,7 @@ App::get('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -42,7 +42,7 @@ App::post('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -60,7 +60,7 @@ App::patch('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -78,7 +78,7 @@ App::put('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -96,7 +96,7 @@ App::delete('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -114,7 +114,7 @@ App::get('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -132,7 +132,7 @@ App::post('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -150,7 +150,7 @@ App::patch('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -168,7 +168,7 @@ App::put('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -186,7 +186,7 @@ App::delete('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -230,7 +230,7 @@ App::post('/v1/mock/tests/general/upload')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->param('file', [], new File(), 'Sample file param', false)
->inject('request')

View file

@ -8,12 +8,20 @@ use Appwrite\Database\Database;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Migration\Version;
use Appwrite\Migration\Migration;
use Utopia\Validator\Text;
$cli
->task('migrate')
->action(function () use ($register) {
Console::success('Starting Data Migration');
->param('version', APP_VERSION_STABLE, new Text(8), 'Version to migrate to.', true)
->action(function ($version) use ($register) {
if (!array_key_exists($version, Migration::$versions)) {
Console::error("Version {$version} not found.");
Console::exit(1);
return;
}
Console::success('Starting Data Migration to version '.$version);
$db = $register->get('db', true);
$cache = $register->get('cache', true);
@ -38,7 +46,8 @@ $cli
$projects = [$console];
$count = 0;
$migration = new Version\V08($register->get('db')); //TODO: remove hardcoded version and move to dynamic migration
$class = 'Appwrite\\Migration\\Version\\'.Migration::$versions[$version];
$migration = new $class($register->get('db'));
while ($sum > 0) {
foreach ($projects as $project) {

View file

@ -225,8 +225,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
\exec('mkdir -p '.$resultExamples.' && cp -r '.$result.'/docs/examples '.$resultExamples);
Console::success("Copied code examples for {$language['name']} SDK to: {$resultExamples}");
\exec('rm -rf '.$result);
Console::success("Removed source code directory '{$result}' for {$language['name']} SDK");
}
}

View file

@ -612,7 +612,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
--code='/myrepo/myfunction'" data-forms-code="powershell" data-lang="powershell" data-lang-label="PowerShell"></textarea>
</div>
<p>Learn more about <a href="" target="_blank">creating tags</a>, installing and using the <a href="" target="_blank">Appwrite CLI</a>.</p>
<p>Learn more about <a href="https://appwrite.io/docs/server/functions#functionsCreateTag" target="_blank">creating tags</a>, installing and using the <a href="https://appwrite.io/docs/command-line" target="_blank">Appwrite CLI</a>.</p>
</li>
<li>
<h2 style="display: none">Manual</h2>

View file

@ -62,7 +62,7 @@
"slickdeals/statsd": "3.1.0"
},
"require-dev": {
"appwrite/sdk-generator": "0.11.0",
"appwrite/sdk-generator": "0.11.1",
"swoole/ide-helper": "4.6.7",
"phpunit/phpunit": "9.5.6",
"vimeo/psalm": "4.7.2"

26
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8133b7af84411021118804b9d174b9d5",
"content-hash": "65ff5003b9122286423aa030cb6983ea",
"packages": [
{
"name": "adhocore/jwt",
@ -2403,16 +2403,16 @@
},
{
"name": "appwrite/sdk-generator",
"version": "0.11.0",
"version": "0.11.1",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "96c41c44f930a4d40184cd0f3c7dca76d2cca7e1"
"reference": "9809c31f27037d088fb832cdec0e8fbc93d1d388"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/96c41c44f930a4d40184cd0f3c7dca76d2cca7e1",
"reference": "96c41c44f930a4d40184cd0f3c7dca76d2cca7e1",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9809c31f27037d088fb832cdec0e8fbc93d1d388",
"reference": "9809c31f27037d088fb832cdec0e8fbc93d1d388",
"shasum": ""
},
"require": {
@ -2446,9 +2446,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.11.0"
"source": "https://github.com/appwrite/sdk-generator/tree/0.11.1"
},
"time": "2021-07-01T13:51:23+00:00"
"time": "2021-07-02T10:15:53+00:00"
},
{
"name": "composer/package-versions-deprecated",
@ -3117,16 +3117,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.10.5",
"version": "v4.11.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f"
"reference": "fe14cf3672a149364fb66dfe11bf6549af899f94"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f",
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fe14cf3672a149364fb66dfe11bf6549af899f94",
"reference": "fe14cf3672a149364fb66dfe11bf6549af899f94",
"shasum": ""
},
"require": {
@ -3167,9 +3167,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5"
"source": "https://github.com/nikic/PHP-Parser/tree/v4.11.0"
},
"time": "2021-05-03T19:11:20+00:00"
"time": "2021-07-03T13:36:55+00:00"
},
{
"name": "openlss/lib-array2xml",

View file

@ -5,7 +5,7 @@ sdk
.setProject('5df5acd0d48c2') // Your project ID
;
let promise = sdk.functions.create('[NAME]', [], 'java-11');
let promise = sdk.functions.create('[NAME]', [], 'java-11.0');
promise.then(function (response) {
console.log(response); // Success

View file

@ -1 +1 @@
appwrite functions create --name="[NAME]" --execute="" --runtime="java-11" --vars="{}" --events="" --schedule="" --timeout="1"
appwrite functions create --name="[NAME]" --execute="" --runtime="java-11.0" --vars="{}" --events="" --schedule="" --timeout="1"

View file

@ -13,7 +13,7 @@ void main() { // Init SDK
Future result = functions.create(
name: '[NAME]',
execute: [],
runtime: 'java-11',
runtime: 'java-11.0',
);
result

View file

@ -12,7 +12,7 @@ client
;
let promise = functions.create('[NAME]', [], 'java-11');
let promise = functions.create('[NAME]', [], 'java-11.0');
promise.then(function (response) {
console.log(response);

View file

@ -10,4 +10,4 @@ client
Functions functions = new Functions(client);
HttpResponseMessage result = await functions.Create("[NAME]", [List<object>], "java-11");
HttpResponseMessage result = await functions.Create("[NAME]", [List<object>], "java-11.0");

View file

@ -11,7 +11,7 @@ suspend fun main() {
val response = functions.create(
name = "[NAME]",
execute = listOf(),
runtime = "java-11",
runtime = "java-11.0",
)
val json = response.body?.string()
}

View file

@ -11,7 +11,7 @@ client
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
let promise = functions.create('[NAME]', [], 'java-11');
let promise = functions.create('[NAME]', [], 'java-11.0');
promise.then(function (response) {
console.log(response);

View file

@ -13,4 +13,4 @@ $client
$functions = new Functions($client);
$result = $functions->create('[NAME]', [], 'java-11');
$result = $functions->create('[NAME]', [], 'java-11.0');

View file

@ -11,4 +11,4 @@ client = Client()
functions = Functions(client)
result = functions.create('[NAME]', [], 'java-11')
result = functions.create('[NAME]', [], 'java-11.0')

View file

@ -10,6 +10,6 @@ client
functions = Appwrite::Functions.new(client);
response = functions.create(name: '[NAME]', execute: [], runtime: 'java-11');
response = functions.create(name: '[NAME]', execute: [], runtime: 'java-11.0');
puts response

View file

@ -1 +1,3 @@
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.
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..

View file

@ -40,7 +40,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -68,7 +68,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -45,7 +45,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -122,7 +122,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -0,0 +1,85 @@
## Getting Started
### Init your SDK
Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.
```kotlin
import io.appwrite.Client
import io.appwrite.services.Account
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
.setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
}
```
### Make Your First Request
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```kotlin
val users = Users(client)
val response = users.create(
email = "email@example.com",
password = "password",
)
val json = response.body?.string()
```
### Full Example
```kotlin
import io.appwrite.Client
import io.appwrite.services.Users
suspend fun main() {
val client = Client(context)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
.setSelfSigned(true) // Use only on dev mode with a self-signed SSL cert
val users = Users(client)
val response = users.create(
email = "email@example.com",
password = "password",
)
val json = response.body?.string()
}
```
### Error Handling
The Appwrite Kotlin SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
```kotlin
import io.appwrite.Client
import io.appwrite.services.Users
suspend fun main() {
val users = Users(client)
try {
val response = users.create(
email = "email@example.com",
password = "password",
)
var jsonString = response.body?.string() ?: ""
} catch (e: AppwriteException) {
println(e)
}
}
```
### Learn more
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)
- 🚂 [Appwrite Kotlin Playground](https://github.com/appwrite/playground-for-kotlin)

View file

@ -68,7 +68,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -56,7 +56,7 @@ try {
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -57,7 +57,7 @@ except AppwriteException as e:
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -57,7 +57,7 @@ end
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

View file

@ -52,7 +52,7 @@ sdk.account.create('me@example.com', 'password', 'Jane Doe')
```
### Learn more
You can use followng resources to learn more and get help
You can use following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)

7549
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,8 +14,6 @@
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-jsmin": "^0.1.5",
"gulp-less": "^4.0.1",
"ls-service-form2json": "^1.0.0",
"yargs-parser": "^20.2.7"
"gulp-less": "^5.0.0"
}
}

View file

@ -91,12 +91,21 @@ abstract class Adapter
/**
* Delete Unique Key.
*
* @param int $key
* @param string $key
*
* @return array
*/
abstract public function deleteUniqueKey($key);
/**
* Add Unique Key.
*
* @param string $key
*
* @return array
*/
abstract public function addUniqueKey($key);
/**
* Create Namespace.
*

View file

@ -366,7 +366,7 @@ class MySQL extends Adapter
/**
* Delete Unique Key.
*
* @param int $key
* @param string $key
*
* @return array
*
@ -383,6 +383,30 @@ class MySQL extends Adapter
return [];
}
/**
* Add Unique Key.
*
* @param string $key
*
* @return array
*
* @throws Exception
*/
public function addUniqueKey($key)
{
$st = $this->getPDO()->prepare('INSERT INTO `'.$this->getNamespace().'.database.unique`
SET `key` = :key;
');
$st->bindValue(':key', $key, PDO::PARAM_STR);
if (!$st->execute()) {
throw new Duplicate('Duplicated Property: '.$key);
}
return [];
}
/**
* Create Relation.
*

View file

@ -168,6 +168,22 @@ class Redis extends Adapter
return $data;
}
/**
* Add Unique Key.
*
* @param $key
*
* @return array
*
* @throws Exception
*/
public function addUniqueKey($key)
{
$data = $this->adapter->addUniqueKey($key);
return $data;
}
/**
* Create Namespace.
*

View file

@ -370,6 +370,18 @@ class Database
return new Document($this->adapter->deleteUniqueKey($key));
}
/**
* @param int $key
*
* @return Document|false
*
* @throws AuthorizationException
*/
public function addUniqueKey($key)
{
return new Document($this->adapter->addUniqueKey($key));
}
/**
* @return array
*/

View file

@ -31,6 +31,16 @@ abstract class Migration
*/
protected $projectDB;
/**
* @var array
*/
public static array $versions = [
'0.6.0' => 'V05',
'0.7.0' => 'V06',
'0.8.0' => 'V07',
'0.9.0' => 'V08',
];
/**
* Migration constructor.
*

View file

@ -1,14 +0,0 @@
<?php
namespace Appwrite\Migration\Version;
use Utopia\CLI\Console;
use Appwrite\Migration\Migration;
class V04 extends Migration
{
public function execute(): void
{
Console::log('I got nothing to do.');
}
}

View file

@ -591,6 +591,29 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 400);
// Test if we can create a new account with the old email
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $data['email'],
'password' => $data['password'],
'name' => $data['name'],
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $data['email']);
$this->assertEquals($response['body']['name'], $data['name'],);
$data['email'] = $newEmail;
return $data;

View file

@ -36,4 +36,17 @@ abstract class MigrationTest extends TestCase
]);
}
/**
* Check versions array integrity.
*/
public function testMigrationVersions()
{
require_once __DIR__.'/../../../app/init.php';
foreach (Migration::$versions as $version => $class) {
$this->assertTrue(class_exists('Appwrite\\Migration\\Version\\'.$class));
}
// Test if current version exists
$this->assertArrayHasKey(APP_VERSION_STABLE, Migration::$versions);
}
}