1
0
Fork 0
mirror of synced 2024-06-09 22:34:46 +12:00

Merge branch 'master' of https://github.com/appwrite/appwrite into feat-265-realtime

This commit is contained in:
Torsten Dittmann 2021-05-26 09:36:52 +02:00
commit 6e1d40fd76
19 changed files with 138 additions and 93 deletions

View file

@ -15,6 +15,8 @@
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Follow Appwrite on StackShare](https://img.shields.io/badge/follow%20on-stackshare-blue?style=flat-square)](https://stackshare.io/appwrite)
[**Appwrite 0.8 has been released! Learn what's new!**](https://dev.to/appwrite/announcing-appwrite-0-8-an-open-source-self-hosted-baas-kda)
Appwrite is an end-to-end backend server for Web, Mobile, Native, or Backend apps packaged as a set of Docker<nobr> microservices. Appwrite abstracts the complexity and repetitiveness required to build a modern backend API from scratch and allows you to build secure apps faster.
Using Appwrite, you can easily integrate your app with user authentication & multiple sign-in methods, a database for storing and querying users and team data, storage and file management, image manipulation, Cloud Functions, and [more services](https://appwrite.io/docs).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -15,7 +15,7 @@ return [
[
'key' => 'web',
'name' => 'Web',
'version' => '3.0.0',
'version' => '3.0.4',
'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.0',
'version' => '0.6.2',
'url' => 'https://github.com/appwrite/sdk-for-flutter',
'package' => 'https://pub.dev/packages/appwrite',
'enabled' => true,
@ -178,7 +178,7 @@ return [
[
'key' => 'nodejs',
'name' => 'Node.js',
'version' => '2.2.0',
'version' => '2.2.2',
'url' => 'https://github.com/appwrite/sdk-for-node',
'package' => 'https://www.npmjs.com/package/node-appwrite',
'enabled' => true,
@ -195,7 +195,7 @@ return [
[
'key' => 'deno',
'name' => 'Deno',
'version' => '0.2.0',
'version' => '0.2.1',
'url' => 'https://github.com/appwrite/sdk-for-deno',
'package' => 'https://deno.land/x/appwrite',
'enabled' => true,
@ -212,7 +212,7 @@ return [
[
'key' => 'php',
'name' => 'PHP',
'version' => '2.1.0',
'version' => '2.1.1',
'url' => 'https://github.com/appwrite/sdk-for-php',
'package' => 'https://packagist.org/packages/appwrite/appwrite',
'enabled' => true,
@ -229,7 +229,7 @@ return [
[
'key' => 'python',
'name' => 'Python',
'version' => '0.2.0',
'version' => '0.2.1',
'url' => 'https://github.com/appwrite/sdk-for-python',
'package' => 'https://pypi.org/project/appwrite/',
'enabled' => true,
@ -246,7 +246,7 @@ return [
[
'key' => 'ruby',
'name' => 'Ruby',
'version' => '2.1.0',
'version' => '2.1.1',
'url' => 'https://github.com/appwrite/sdk-for-ruby',
'package' => 'https://rubygems.org/gems/appwrite',
'enabled' => true,
@ -314,7 +314,7 @@ return [
[
'key' => 'dart',
'name' => 'Dart',
'version' => '0.6.0',
'version' => '0.6.1',
'url' => 'https://github.com/appwrite/sdk-for-dart',
'package' => 'https://pub.dev/packages/dart_appwrite',
'enabled' => true,
@ -331,7 +331,7 @@ return [
[
'key' => 'cli',
'name' => 'Command Line',
'version' => '0.10.0',
'version' => '0.10.1',
'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

File diff suppressed because one or more lines are too long

View file

@ -714,10 +714,16 @@ App::post('/v1/account/sessions/anonymous')
$detector->getDevice()
));
$user->setAttribute('sessions', $session, Document::SET_TYPE_APPEND);
Authorization::setRole('user:'.$user->getId());
$session = $projectDB->createDocument($session->getArrayCopy());
if (false === $session) {
throw new Exception('Failed saving session to DB', 500);
}
$user->setAttribute('sessions', $session, Document::SET_TYPE_APPEND);
$user = $projectDB->updateDocument($user->getArrayCopy());
if (false === $user) {
@ -759,6 +765,9 @@ App::post('/v1/account/jwt')
->label('sdk.namespace', 'account')
->label('sdk.method', 'createJWT')
->label('sdk.description', '/docs/references/account/create-jwt.md')
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_JWT)
->label('abuse-limit', 10)
->label('abuse-key', 'url:{url},userId:{param-userId}')
->inject('response')

View file

@ -6,6 +6,7 @@ use Utopia\Storage\Device\Local;
use Utopia\Storage\Storage;
use Appwrite\ClamAV\Network;
use Appwrite\Event\Event;
use RuntimeException;
App::get('/v1/health')
->desc('Get HTTP')
@ -262,11 +263,17 @@ App::get('/v1/health/anti-virus')
$antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310));
$response->json([
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
'version' => @$antiVirus->version(),
]);
try {
$response->json([
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
'version' => @$antiVirus->version(),
]);
} catch( RuntimeException $e) {
$response->json([
'status' => 'offline',
'version' => '',
]);
}
});
App::get('/v1/health/stats') // Currently only used internally

View file

@ -22,6 +22,7 @@ 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')
@ -245,7 +246,7 @@ App::get('/v1/storage/files/:fileId/preview')
->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
->param('borderRadius', 0, new Range(0, 4000), 'Preview image border radius in pixels. Pass an integer between 0 to 4000.', true)
->param('opacity', 1, new Range(0,1), 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true)
->param('opacity', 1, new Range(0,1, Range::TYPE_FLOAT), 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true)
->param('rotation', 0, new Range(0,360), 'Preview image rotation in degrees. Pass an integer between 0 and 360.', true)
->param('background', '', new HexColor(), 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true)
->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true)

View file

@ -45,6 +45,7 @@ $http
'http_compression' => true,
'http_compression_level' => 6,
'package_max_length' => $payloadSize,
'buffer_output_size' => $payloadSize,
])
;

View file

@ -134,7 +134,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<input type="hidden" name="fileId" data-ls-bind="{{file.$id}}" />
</form>
</div>
<div class="col span-4">
<div class="col span-4 text-size-small">
<div class="margin-bottom-small">File Preview</div>
<div class="margin-bottom-small">
@ -145,9 +145,20 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<a href="" data-ls-attrs="href={{env.ENDPOINT}}/v1/storage/files/{{file.$id}}/view?project={{router.params.project}}&mode=admin" target="_blank" rel="noopener"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny"></i> New Window <i class="icon-link-ext"></i></a>
</div>
<div class="margin-bottom">
<div class="margin-bottom-small">
<a href="" data-ls-attrs="href={{env.ENDPOINT}}/v1/storage/files/{{file.$id}}/download?project={{router.params.project}}&mode=admin" target="_blank" rel="noopener"><i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny"></i> Download <i class="icon-link-ext"></i></a>
</div>
<div class="margin-bottom-tiny">
<i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny"></i> Type: <span data-ls-bind="{{file.mimeType}}"></span>
</div>
<div class="margin-bottom-tiny">
<i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny"></i> Size: <span data-ls-bind="{{file.sizeOriginal|humanFileSize}}"></span>
<span data-ls-bind="{{file.sizeOriginal|humanFileUnit}}"></span>
</div>
<div class="margin-bottom">
<i class="icon-angle-circled-right margin-start-negative-tiny margin-end-tiny"></i> Created at: <span data-ls-bind="{{file.dateCreated|dateText}}"></span>
</div>
</div>
</div>

View file

@ -62,7 +62,7 @@
"slickdeals/statsd": "3.0.2"
},
"require-dev": {
"appwrite/sdk-generator": "0.10.2",
"appwrite/sdk-generator": "0.10.6",
"swoole/ide-helper": "4.6.6",
"textalk/websocket": "1.5.2",
"phpunit/phpunit": "9.5.4",

50
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": "d722be0ec2f73f6436fc99b64bd69f0a",
"content-hash": "e433ce62dd355a107816e8967d5c769d",
"packages": [
{
"name": "adhocore/jwt",
@ -1693,16 +1693,16 @@
},
{
"name": "utopia-php/framework",
"version": "0.14.0",
"version": "0.14.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework.git",
"reference": "92d4a36f3b0e22393a31877c5317c96e01760339"
"reference": "632113288bebe41cbef79f0d355bd91609767b8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/92d4a36f3b0e22393a31877c5317c96e01760339",
"reference": "92d4a36f3b0e22393a31877c5317c96e01760339",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/632113288bebe41cbef79f0d355bd91609767b8c",
"reference": "632113288bebe41cbef79f0d355bd91609767b8c",
"shasum": ""
},
"require": {
@ -1736,9 +1736,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/framework/issues",
"source": "https://github.com/utopia-php/framework/tree/0.14.0"
"source": "https://github.com/utopia-php/framework/tree/0.14.1"
},
"time": "2021-04-15T21:01:44+00:00"
"time": "2021-05-21T06:41:45+00:00"
},
{
"name": "utopia-php/image",
@ -2340,16 +2340,16 @@
},
{
"name": "appwrite/sdk-generator",
"version": "0.10.2",
"version": "0.10.6",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "0e963a0691ec43f39664bcce7860a11e0a152300"
"reference": "ab4adb0b9126c617e11c8fdf4352c8aa9a715ecc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/0e963a0691ec43f39664bcce7860a11e0a152300",
"reference": "0e963a0691ec43f39664bcce7860a11e0a152300",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/ab4adb0b9126c617e11c8fdf4352c8aa9a715ecc",
"reference": "ab4adb0b9126c617e11c8fdf4352c8aa9a715ecc",
"shasum": ""
},
"require": {
@ -2383,22 +2383,22 @@
"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.10.2"
"source": "https://github.com/appwrite/sdk-generator/tree/0.10.6"
},
"time": "2021-05-19T19:25:14+00:00"
"time": "2021-05-24T14:32:40+00:00"
},
{
"name": "composer/package-versions-deprecated",
"version": "1.11.99.1",
"version": "1.11.99.2",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6"
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
"shasum": ""
},
"require": {
@ -2442,7 +2442,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.1"
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2"
},
"funding": [
{
@ -2458,20 +2458,20 @@
"type": "tidelift"
}
],
"time": "2020-11-11T10:22:58+00:00"
"time": "2021-05-24T07:46:03+00:00"
},
{
"name": "composer/semver",
"version": "3.2.4",
"version": "3.2.5",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464"
"reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/a02fdf930a3c1c3ed3a49b5f63859c0c20e10464",
"reference": "a02fdf930a3c1c3ed3a49b5f63859c0c20e10464",
"url": "https://api.github.com/repos/composer/semver/zipball/31f3ea725711245195f62e54ffa402d8ef2fdba9",
"reference": "31f3ea725711245195f62e54ffa402d8ef2fdba9",
"shasum": ""
},
"require": {
@ -2523,7 +2523,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.2.4"
"source": "https://github.com/composer/semver/tree/3.2.5"
},
"funding": [
{
@ -2539,7 +2539,7 @@
"type": "tidelift"
}
],
"time": "2020-11-13T08:59:24+00:00"
"time": "2021-05-24T12:41:47+00:00"
},
{
"name": "composer/xdebug-handler",

View file

@ -1,3 +1,7 @@
## 0.6.1
- Fix for image preview param types
## 0.6.0
- Upgraded to Null-safety, minimum Dart SDK required 2.12.0

View file

@ -1,3 +1,11 @@
## 0.6.2
- Fixed deployment bug
## 0.6.1
- Fix for image preview param types
## 0.6.0
- Upgraded to Null-safety, minimum Dart SDK required 2.12.0

View file

@ -10,12 +10,11 @@ Initialize your SDK code with your project ID which can be found in your project
```js
// Init your Web SDK
const appwrite = new Appwrite();
const sdk = new Appwrite();
appwrite
sdk
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
.setProject('455x34dfkj') // Your project ID
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;
```
@ -24,35 +23,32 @@ Once your SDK object is set, access any of the Appwrite services and choose any
```js
// Register User
appwrite
.account.create('me@example.com', 'password', 'Jane Doe')
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
sdk.account.create('me@example.com', 'password', 'Jane Doe')
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
```
### Full Example
```js
// Init your Web SDK
const appwrite = new Appwrite();
const sdk = new Appwrite();
appwrite
sdk
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
.setProject('455x34dfkj')
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;
// Register User
appwrite
.account.create('me@example.com', 'password', 'Jane Doe')
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
sdk.account.create('me@example.com', 'password', 'Jane Doe')
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
```
### Learn more

View file

@ -5,6 +5,7 @@ namespace Appwrite\Specification\Format;
use Appwrite\Specification\Format;
use Appwrite\Template\Template;
use stdClass;
use Utopia\Validator;
class OpenAPI3 extends Format
{
@ -230,24 +231,24 @@ class OpenAPI3 extends Format
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
break;
case 'Utopia\Validator\Boolean':
$node['schema']['type'] = 'boolean';
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = false;
break;
case 'Appwrite\Database\Validator\UID':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
break;
case 'Appwrite\Network\Validator\Email':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'email';
$node['schema']['x-example'] = 'email@example.com';
break;
case 'Appwrite\Network\Validator\URL':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'url';
$node['schema']['x-example'] = 'https://example.com';
break;
@ -261,7 +262,7 @@ class OpenAPI3 extends Format
break;
case 'Utopia\Storage\Validator\File':
$consumes = ['multipart/form-data'];
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'binary';
break;
case 'Utopia\Validator\ArrayList':
@ -271,24 +272,24 @@ class OpenAPI3 extends Format
];
break;
case 'Appwrite\Auth\Validator\Password':
$node['schema']['type'] = 'string';
$node['schema']['format'] = 'format';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'password';
$node['schema']['x-example'] = 'password';
break;
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
$node['schema']['type'] = 'integer';
$node['schema']['format'] = 'int32';
$node['schema']['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number': $validator->getType();
$node['schema']['format'] = $validator->getType() == Validator::TYPE_INTEGER ? 'int32' : 'float';
$node['schema']['x-example'] = $validator->getMin();
break;
case 'Utopia\Validator\Numeric':
$node['schema']['type'] = 'integer';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'int32';
break;
case 'Utopia\Validator\Length':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
break;
case 'Appwrite\Network\Validator\Host':
$node['schema']['type'] = 'string';
$node['schema']['type'] = $validator->getType();
$node['schema']['format'] = 'url';
$node['schema']['x-example'] = 'https://example.com';
break;

View file

@ -6,6 +6,7 @@ use Appwrite\Specification\Format;
use Appwrite\Template\Template;
use Appwrite\Utopia\Response\Model;
use stdClass;
use Utopia\Validator;
class Swagger2 extends Format
{
@ -227,24 +228,24 @@ class Swagger2 extends Format
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['type'] = 'string';
$node['type'] = $validator->getType();
$node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
break;
case 'Utopia\Validator\Boolean':
$node['type'] = 'boolean';
$node['type'] = $validator->getType();
$node['x-example'] = false;
break;
case 'Appwrite\Database\Validator\UID':
$node['type'] = 'string';
$node['type'] = $validator->getType();
$node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']';
break;
case 'Appwrite\Network\Validator\Email':
$node['type'] = 'string';
$node['type'] = $validator->getType();
$node['format'] = 'email';
$node['x-example'] = 'email@example.com';
break;
case 'Appwrite\Network\Validator\URL':
$node['type'] = 'string';
$node['type'] = $validator->getType();
$node['format'] = 'url';
$node['x-example'] = 'https://example.com';
break;
@ -268,24 +269,24 @@ class Swagger2 extends Format
];
break;
case 'Appwrite\Auth\Validator\Password':
$node['type'] = 'string';
$node['format'] = 'format';
$node['type'] = $validator->getType();
$node['format'] = 'password';
$node['x-example'] = 'password';
break;
case 'Utopia\Validator\Range': /** @var \Utopia\Validator\Range $validator */
$node['type'] = 'integer';
$node['format'] = 'int32';
$node['type'] = $validator->getType() === Validator::TYPE_FLOAT ? 'number': $validator->getType();
$node['format'] = $validator->getType() == Validator::TYPE_INTEGER ? 'int32' : 'float';
$node['x-example'] = $validator->getMin();
break;
case 'Utopia\Validator\Numeric':
$node['type'] = 'integer';
$node['type'] = $validator->getType();
$node['format'] = 'int32';
break;
case 'Utopia\Validator\Length':
$node['type'] = 'string';
$node['type'] = $validator->getType();
break;
case 'Appwrite\Network\Validator\Host':
$node['type'] = 'string';
$node['type'] = $validator->getType();
$node['format'] = 'url';
$node['x-example'] = 'https://example.com';
break;

View file

@ -240,6 +240,10 @@ class AccountCustomClientTest extends Scope
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['userId']);
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];